]> oss.titaniummirror.com Git - repo_shell.git/commitdiff
repo_shell uses utility.c
authorR. Steve McKown <rsmckown@gmail.com>
Wed, 26 Sep 2012 21:28:33 +0000 (15:28 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Wed, 26 Sep 2012 22:21:44 +0000 (16:21 -0600)
repo_shell.c

index a104602437f5552820f341247b5e0cfc61136163..df342c87399e0f18f200d7dd8c2c86135cb4a2f4 100644 (file)
@@ -8,6 +8,7 @@
 #include <pwd.h>
 #include <string.h>
 #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]))