From: R. Steve McKown Date: Wed, 26 Sep 2012 21:28:33 +0000 (-0600) Subject: repo_shell uses utility.c X-Git-Tag: 0.3~2 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=repo_shell.git;a=commitdiff_plain;h=52112d0182833dff686ccfe909808cd9b8be5b6e repo_shell uses utility.c --- diff --git a/repo_shell.c b/repo_shell.c index a104602..df342c8 100644 --- a/repo_shell.c +++ b/repo_shell.c @@ -8,6 +8,7 @@ #include #include #include "ini.h" +#include "utility.h" #include "version.h" #define CFG_FILE "/etc/repo_shell.cfg" @@ -20,48 +21,7 @@ typedef struct { char *owner; } cfg_t; -#undef USE_DEFAULTS -#ifdef USE_DEFAULTS /* perhaps we want defaults? Not sure */ -static cfg_t cfg { - svn_root: "/var/lib/svn/repositories", - git_root: "/var/lib/git", - owner: "repo" -}; -#else static cfg_t cfg; -#endif - -static void die(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fprintf(stderr, "error: "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n" ); - va_end(ap); - exit(1); -} - -char *xstrdup(const char *str) -{ - char *ret = strdup(str); - if (!ret) - die("out of memory"); - return ret; -} - -void *xmalloc(size_t size) -{ - void *ret; - - ret = malloc(size); - if (!ret && !size) - ret = malloc(1); - if (!ret) - die("out of memory"); - return ret; -} static uid_t user_uid(char *user) { @@ -257,12 +217,8 @@ int main(int argc, char **argv) execvp(argv[0], (char *const *) argv); } -#ifdef USE_DEFAULTS - ini_parse("repo_shell.cfg", ini_handler, &cfg); -#else if (ini_parse(CFG_FILE, ini_handler, &cfg) < 0) die("cannot read config file %s", CFG_FILE); -#endif prog = xstrdup(argv[2]); if (!strncmp(prog, "git", 3) && isspace(prog[3]))