]> skyeroc.xyz Git - dgamelaunch/commitdiff
DEFCONFIG holds path to config file, hardcoded, edit Makefile for this
authorJoshua Kwan <joshk@triplehelix.org>
Tue, 17 Feb 2004 02:44:33 +0000 (02:44 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Tue, 17 Feb 2004 02:44:33 +0000 (02:44 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@243 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

Makefile
dgamelaunch.c

index 597bac6091e53ca1a137309a9eb043c44a10852a..1210b5a3cd938c7361f460fb35b6df4ce05783de 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,6 @@
 VERSION = 1.4.1
+# Hardcoded path to config file
+DEFCONFIG = /etc/dgamelaunch.conf
 NAME = dgamelaunch
 exclusions = CVS .svn .cvsignore tags
 PREFIX = /usr
@@ -38,7 +40,7 @@ CC = gcc
 LDFLAGS = 
 CFLAGS = -g3 $(optimize) -Wall -Wno-unused $(DEFS)
 INSTALL = install -c
-DEFS = -DVERSION=\"$(VERSION)\"
+DEFS = -DVERSION=\"$(VERSION)\" -DDEFCONFIG=\"$(DEFCONFIG)\"
 SRCS = $(EDITOR) ttyrec.c dgamelaunch.c io.c ttyplay.c mygetnstr.c stripgfx.c strlcpy.c strlcat.c y.tab.c lex.yy.c
 OBJS = $(SRCS:.c=.o)
 LIBS = -lcurses -lcrypt $(LUTIL) -ll
index 49698e9bc31e8931466c3e2100884fc403f70da6..fe31b543ea57a7b3e0efd0c3a00c3ba473844883 100644 (file)
@@ -162,45 +162,56 @@ create_config ()
       graceful_exit(104);
       return;
     }
-
-    if (!myconfig) /* a parse error occurred */
-    {
-      myconfig = &defconfig;
-      return;
-    }
-    /* Fill the rest with defaults */
-    if (!myconfig->shed_user && myconfig->shed_uid == -1)
-    {
-      struct passwd *pw;
-      if ((pw = getpwnam(defconfig.shed_user)))
-        myconfig->shed_uid = pw->pw_uid;
-      else
-       myconfig->shed_uid = defconfig.shed_uid;
-    }
-
-    if (!myconfig->shed_group && myconfig->shed_gid == -1)
+  }
+  else
+  {
+#ifdef DEFCONFIG
+    config = DEFCONFIG;
+    if ((config_file = fopen(DEFCONFIG, "r")) != NULL)
     {
-      struct group *gr;
-      if ((gr = getgrnam(defconfig.shed_group)))
-       myconfig->shed_gid = gr->gr_gid;
-      else
-       myconfig->shed_gid = defconfig.shed_gid;
+      yyin = config_file;
+      yyparse();
+      fclose(config_file);
     }
-
-    if (myconfig->max == 0 && !set_max) myconfig->max = defconfig.max;
-    if (!myconfig->banner) myconfig->banner = defconfig.banner;
-    if (!myconfig->chroot) myconfig->chroot = defconfig.chroot;
-    if (!myconfig->nethack) myconfig->nethack = defconfig.nethack;
-    if (!myconfig->dglroot) myconfig->dglroot = defconfig.dglroot;
-    if (!myconfig->rcfile) myconfig->rcfile = defconfig.rcfile;
-    if (!myconfig->spool) myconfig->spool = defconfig.spool;
-    if (!myconfig->passwd) myconfig->passwd = defconfig.passwd;
-    if (!myconfig->lockfile) myconfig->lockfile = defconfig.lockfile;
+#else
+    myconfig = &defconfig;
+    return;
+#endif
   }
-  else
+
+  if (!myconfig) /* a parse error occurred */
   {
     myconfig = &defconfig;
+    return;
   }
+  /* Fill the rest with defaults */
+  if (!myconfig->shed_user && myconfig->shed_uid == -1)
+  {
+    struct passwd *pw;
+    if ((pw = getpwnam(defconfig.shed_user)))
+      myconfig->shed_uid = pw->pw_uid;
+    else
+      myconfig->shed_uid = defconfig.shed_uid;
+  }
+
+  if (!myconfig->shed_group && myconfig->shed_gid == -1)
+  {
+    struct group *gr;
+    if ((gr = getgrnam(defconfig.shed_group)))
+      myconfig->shed_gid = gr->gr_gid;
+    else
+      myconfig->shed_gid = defconfig.shed_gid;
+  }
+
+  if (myconfig->max == 0 && !set_max) myconfig->max = defconfig.max;
+  if (!myconfig->banner) myconfig->banner = defconfig.banner;
+  if (!myconfig->chroot) myconfig->chroot = defconfig.chroot;
+  if (!myconfig->nethack) myconfig->nethack = defconfig.nethack;
+  if (!myconfig->dglroot) myconfig->dglroot = defconfig.dglroot;
+  if (!myconfig->rcfile) myconfig->rcfile = defconfig.rcfile;
+  if (!myconfig->spool) myconfig->spool = defconfig.spool;
+  if (!myconfig->passwd) myconfig->passwd = defconfig.passwd;
+  if (!myconfig->lockfile) myconfig->lockfile = defconfig.lockfile;
 }
 
 /* ************************************************************* */