Remove SvnRunner in preparation to use Ruby
This commit is contained in:
parent
e3c11407c3
commit
e82c661d50
@ -1,82 +0,0 @@
|
||||
#include "SvnRunner.h"
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
SvnRunner::SvnRunner(std::vector<std::string> 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;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
class SvnRunner
|
||||
{
|
||||
public:
|
||||
SvnRunner(std::vector<std::string> 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;
|
||||
};
|
4
src/main.cc
Normal file
4
src/main.cc
Normal file
@ -0,0 +1,4 @@
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
31
src/svi.cc
31
src/svi.cc
@ -1,31 +0,0 @@
|
||||
#include <iostream>
|
||||
#include "SvnRunner.h"
|
||||
#include <getopt.h>
|
||||
#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;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#ifndef SVI_H
|
||||
#define SVI_H
|
||||
|
||||
#define APPLICATION_NAME "svi"
|
||||
#define APPLICATION_VERSION "0.0.0alpha0"
|
||||
|
||||
#endif
|
1
wscript
1
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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user