From e82c661d50b7f5fd807ebc1a12f65dad37aaadbe Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 29 Jan 2018 16:19:26 -0500 Subject: [PATCH] Remove SvnRunner in preparation to use Ruby --- src/SvnRunner.cc | 82 ------------------------------------------------ src/SvnRunner.h | 19 ----------- src/main.cc | 4 +++ src/svi.cc | 31 ------------------ src/svi.h | 7 ----- wscript | 1 - 6 files changed, 4 insertions(+), 140 deletions(-) delete mode 100644 src/SvnRunner.cc delete mode 100644 src/SvnRunner.h create mode 100644 src/main.cc delete mode 100644 src/svi.cc delete mode 100644 src/svi.h diff --git a/src/SvnRunner.cc b/src/SvnRunner.cc deleted file mode 100644 index 094773a..0000000 --- a/src/SvnRunner.cc +++ /dev/null @@ -1,82 +0,0 @@ -#include "SvnRunner.h" -#include -#include -#include - -SvnRunner::SvnRunner(std::vector arguments) -{ - m_pid = 0; - int fd[2]; - int pipe_rc = pipe(fd); - if (pipe_rc == -1) - { - perror("pipe"); - return; - } - m_pid = fork(); - if (m_pid == -1) - { - perror("fork"); - return; - } - if (m_pid == 0) - { - close(fd[0]); - int dup2_rc = dup2(fd[1], STDOUT_FILENO); - if (dup2_rc == -1) - { - perror("dup2"); - return; - } - char const * argv[arguments.size() + 2]; - argv[0] = "svn"; - argv[arguments.size() + 1] = NULL; - for (unsigned int i = 0; i < arguments.size(); i++) - { - argv[i + 1] = arguments[i].c_str(); - } - int exec_rc = execvp("/usr/bin/svn", (char **)argv); - if (exec_rc == -1) - { - perror("exec"); - exit(1); - } - } - else - { - close(fd[1]); - m_n = 100; - m_line = (char *)malloc(m_n); - m_svn_fh = fdopen(fd[0], "r"); - } -} - -const char * SvnRunner::get_line() -{ - if (m_pid > 0) - { - ssize_t getline_rc = getline(&m_line, &m_n, m_svn_fh); - if (getline_rc == -1) - { - fclose(m_svn_fh); - int status; - int waitpid_rc = waitpid(m_pid, &status, 0); - if (waitpid_rc == -1) - { - perror("waitpid"); - } - m_status = WEXITSTATUS(status); - free(m_line); - m_pid = 0; - return NULL; - } - else - { - return m_line; - } - } - else - { - return NULL; - } -} diff --git a/src/SvnRunner.h b/src/SvnRunner.h deleted file mode 100644 index c5152d1..0000000 --- a/src/SvnRunner.h +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include -#include - -class SvnRunner -{ -public: - SvnRunner(std::vector arguments); - const char * get_line(); - int status() { return m_status; } - -protected: - char * m_line; - size_t m_n; - pid_t m_pid; - FILE * m_svn_fh; - int m_status; -}; diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..ee75368 --- /dev/null +++ b/src/main.cc @@ -0,0 +1,4 @@ +int main(int argc, char * argv[]) +{ + return 0; +} diff --git a/src/svi.cc b/src/svi.cc deleted file mode 100644 index 5bcff31..0000000 --- a/src/svi.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include "SvnRunner.h" -#include -#include "svi.h" - -using namespace std; - -enum -{ - OPT_VERSION = 256, -}; - -int main(int argc, char * argv[]) -{ - static char const optstring[] = "+"; - static struct option const longopts[] = { - {"version", no_argument, NULL, OPT_VERSION}, - {NULL, 0, NULL, 0}, - }; - for (int o; (o = getopt_long(argc, argv, optstring, longopts, NULL)) != -1; ) - { - switch (o) - { - case OPT_VERSION: - printf(APPLICATION_NAME " version " APPLICATION_VERSION "\n"); - return 0; - } - } - - return 0; -} diff --git a/src/svi.h b/src/svi.h deleted file mode 100644 index 0f1e28e..0000000 --- a/src/svi.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef SVI_H -#define SVI_H - -#define APPLICATION_NAME "svi" -#define APPLICATION_VERSION "0.0.0alpha0" - -#endif diff --git a/wscript b/wscript index ccbec4e..03485a5 100644 --- a/wscript +++ b/wscript @@ -6,7 +6,6 @@ def options(opt): def configure(conf): conf.load("compiler_cxx") conf.define("SHARE_DIR", re.sub(r'/$', "", conf.options.prefix) + "/share/svi") - conf.check(header_name = "getopt.h") conf.check_cfg(package = "ruby", args = "--cflags --libs", uselib_store = "ruby") def build(bld):