chiark / gitweb /
Moved xmalloc etc. into both.c
authorian <ian>
Sun, 10 Oct 1999 11:39:46 +0000 (11:39 +0000)
committerian <ian>
Sun, 10 Oct 1999 11:39:46 +0000 (11:39 +0000)
both.c
both.h
client.c
debian/changelog
lexer.c
lexer.l
lexer.l.m4
lib.c
lib.h
servexec.c

diff --git a/both.c b/both.c
index 46cf85c73823f1ae16b49b2254a38f1f67c12faf..24a31ffaee2b87ed570aeb859291a90dea3ef7a4 100644 (file)
--- a/both.c
+++ b/both.c
 #include <stdlib.h>
 #include <errno.h>
 
+#include "config.h"
 #include "both.h"
 
+void *xmalloc(size_t s) {
+  void *p;
+  p= malloc(s?s:1); if (!p) syscallerror("malloc");
+  return p;
+}
+
+void *xrealloc(void *p, size_t s) {
+  p= realloc(p,s);
+  if (!p) syscallerror("realloc");
+  return p;
+}
+
+char *xstrsave(const char *s) {
+  char *r;
+
+  r= xmalloc(strlen(s)+1);
+  strcpy(r,s);
+  return r;
+}
+
+
 int working_getc(FILE *file) {
   int c;
   
diff --git a/both.h b/both.h
index 084405db4a461f74a40446b080b4f2df597e50d9..6fd04a5e2561cf56c2390fb71d7e6449e0698e5e 100644 (file)
--- a/both.h
+++ b/both.h
 #ifndef BOTH_H
 #define BOTH_H
 
+/* provided by both.c */
+
+void *xmalloc(size_t s);
+void *xrealloc(void *p, size_t s);
+char *xstrsave(const char *s);
+
 int working_getc(FILE *file);
 size_t working_fread(void *ptr, size_t sz, FILE *file);
 
+/* used by both.c, so must be present */
+
+void syscallerror(const char *what) NONRETURNING;
+
 #endif
index 523a7be3d1dd7ffd98c224b2a2678512fda5a9ff..f7bc9a4928965e4a90d984194e8e4878e6097d54 100644 (file)
--- a/client.c
+++ b/client.c
@@ -168,7 +168,7 @@ static void NONRETURNPRINTFFORMAT(1,2) miscerror(const char *fmt, ...) {
   exit(-1);
 }
 
-static void NONRETURNPRINTFFORMAT(1,2) syscallerror(const char *fmt, ...) {
+static void NONRETURNPRINTFFORMAT(1,2) fsyscallerror(const char *fmt, ...) {
   va_list al;
   int e;
 
@@ -181,6 +181,10 @@ static void NONRETURNPRINTFFORMAT(1,2) syscallerror(const char *fmt, ...) {
   exit(-1);
 }
 
+void syscallerror(const char *what) {
+  fsyscallerror("%s",what);
+}
+
 static void NONRETURNING protoreaderror(FILE *file, const char *where) {
   int e;
 
@@ -300,18 +304,7 @@ static void getprogress(struct progress_msg *progress_r, FILE *file) {
  * the signal asynchronicity starts.  They can do anything they like.
  */
 
-static void *xmalloc(size_t s) {
-  void *p;
-  p= malloc(s?s:1);
-  if (!p) syscallerror("malloc (%lu bytes)",(unsigned long)s);
-  return p;
-}
-
-static void *xrealloc(void *p, size_t s) {
-  p= realloc(p,s);
-  if (!p) syscallerror("realloc (%lu bytes)",(unsigned long)s);
-  return p;
-}
+/* This includes xmalloc and xrealloc from both.c */
 
 static void xfwritestring(const char *s, FILE *file) {
   int l;
@@ -348,7 +341,7 @@ static void disconnect(void) /* DOES return, unlike in daemon */ {
     event_mbuf.type= et_disconnect;
     r= fwrite(&event_mbuf,1,sizeof(event_mbuf),swfile);
     if ((r != sizeof(event_mbuf) || fflush(swfile)) && errno != EPIPE)
-      syscallerror("write to server when disconnecting\n");
+      syscallerror("write to server when disconnecting");
   }
   systemerror= 1;
 }
@@ -590,9 +583,9 @@ static void of_file(const struct optioninfo *oip, const char *value, char *key)
     }
     r= fstat(copyfd,&stab);
     if (r) {
-      if (oip) syscallerror("check filedescriptor %lu (named as target of file "
-                           "descriptor redirection for %lu)",copyfd,fd);
-      else syscallerror("check basic filedescriptor %lu at program start",copyfd);
+      if (oip) fsyscallerror("check filedescriptor %lu (named as target of file "
+                            "descriptor redirection for %lu)",copyfd,fd);
+      else fsyscallerror("check basic filedescriptor %lu at program start",copyfd);
     }
     fdsetup[fd].copyfd= copyfd;
   }
@@ -946,7 +939,7 @@ static void process_override(const char *servicename) {
     break;
   case ot_file:
     ovfile= fopen(overridevalue,"r");
-    if (!ovfile) syscallerror("open overriding configuration file `%s'",overridevalue);
+    if (!ovfile) fsyscallerror("open overriding configuration file `%s'",overridevalue);
     ovbuf= 0; ovavail= ovused= 0;
     while ((c= getc(ovfile)) != EOF) {
       if (!c) miscerror("overriding config file `%s' contains null(s)",overridevalue);
@@ -958,7 +951,7 @@ static void process_override(const char *servicename) {
       ovbuf[ovused++]= c;
     }
     if (ferror(ovfile) || fclose(ovfile))
-      syscallerror("read overriding configuration file `%s'",overridevalue);
+      fsyscallerror("read overriding configuration file `%s'",overridevalue);
     ovbuf= xrealloc(ovbuf,ovused+1);
     ovbuf[ovused]= 0;
     break;
@@ -995,7 +988,7 @@ static int server_connect(void) {
     if (errno == ECONNREFUSED || errno == ENOENT)
       syscallerror("uservd daemon is not running - service not available");
     if (errno != EINTR)
-      syscallerror("unable to connect to uservd daemon: %m");
+      fsyscallerror("unable to connect to uservd daemon: %m");
   }
 
   return sfd;
@@ -1028,16 +1021,16 @@ static void server_preparepipes(void) {
     assert(!pipepathbuf[PIPEPATHMAXLEN]);
     priv_resume();
     if (unlink(pipepathbuf) && errno != ENOENT)
-      syscallerror("remove any old pipe `%s'",pipepathbuf);
+      fsyscallerror("remove any old pipe `%s'",pipepathbuf);
     if (mkfifo(pipepathbuf,0600)) /* permissions are irrelevant */
-      syscallerror("create pipe `%s'",pipepathbuf);
+      fsyscallerror("create pipe `%s'",pipepathbuf);
     tempfd= open(pipepathbuf,O_RDWR);
-    if (tempfd<0) syscallerror("prelim open pipe `%s' for read+write",pipepathbuf);
+    if (tempfd<0) fsyscallerror("prelim open pipe `%s' for read+write",pipepathbuf);
     assert(fdsetup[fd].mods & (fdm_read|fdm_write));
     fdsetup[fd].pipefd=
       open(pipepathbuf, (fdsetup[fd].mods & fdm_read) ? O_WRONLY : O_RDONLY);
-    if (fdsetup[fd].pipefd<0) syscallerror("real open pipe `%s'",pipepathbuf);
-    if (close(tempfd)) syscallerror("close prelim fd onto pipe `%s'",pipepathbuf);
+    if (fdsetup[fd].pipefd<0) fsyscallerror("real open pipe `%s'",pipepathbuf);
+    if (close(tempfd)) fsyscallerror("close prelim fd onto pipe `%s'",pipepathbuf);
     priv_suspend();
   }
 }
@@ -1142,13 +1135,13 @@ static void connect_pipes(void) {
       fdsetup[fd].copyfd=
        open(fdsetup[fd].filename,fdsetup[fd].oflags|O_NOCTTY,0777);
       if (fdsetup[fd].copyfd<0)
-       syscallerror("open file `%s' for fd %d",fdsetup[fd].filename,fd);
+       fsyscallerror("open file `%s' for fd %d",fdsetup[fd].filename,fd);
     }
     blocksignals(SIG_BLOCK);
     child= fork();
     fdsetup[fd].catpid= child;
     blocksignals(SIG_UNBLOCK);
-    if (child==-1) syscallerror("fork for cat for fd %d",fd);
+    if (child==-1) fsyscallerror("fork for cat for fd %d",fd);
     if (!child) {
       snprintf(catnamebuf,sizeof(catnamebuf),"cat fd%d",fd);
       catnamebuf[sizeof(catnamebuf)-1]= 0;
@@ -1168,8 +1161,8 @@ static void connect_pipes(void) {
       exit(-1);
     }
     if (fdsetup[fd].copyfd>2)
-      if (close(fdsetup[fd].copyfd)) syscallerror("close real fd for %d",fd);
-    if (close(fdsetup[fd].pipefd)) syscallerror("close pipe fd for %d",fd);
+      if (close(fdsetup[fd].copyfd)) fsyscallerror("close real fd for %d",fd);
+    if (close(fdsetup[fd].pipefd)) fsyscallerror("close pipe fd for %d",fd);
   }
 }
 
@@ -1204,7 +1197,7 @@ static void dispose_remaining_pipes(void) {
   blocksignals(SIG_BLOCK);
   for (fd=0; fd<fdsetupsize; fd++) {
     if (!(fdsetup[fd].catpid!=-1 && (fdsetup[fd].mods & fdm_close))) continue;
-    if (kill(fdsetup[fd].catpid,SIGKILL)) syscallerror("kill cat for %d",fd);
+    if (kill(fdsetup[fd].catpid,SIGKILL)) fsyscallerror("kill cat for %d",fd);
     fdsetup[fd].killed= 1;
   }
   blocksignals(SIG_UNBLOCK);
index d9d3e57fdae419b4c328a8d162a5368fe2acd81d..e79e2223fd56ecaf9edc07e1d220ce0ae2b8dc23 100644 (file)
@@ -1,11 +1,11 @@
-userv (0.65.1) unstable; urgency=high
+userv (0.65.2) unstable; urgency=high
 
   * Avoid accessing backup, auto-save files, etc, with include-lookup.
     Everything except a-z 0-9 - _ must now be prefixed by a colon.
   * Allow \ to continue lines (and do sensible things with whitespace in
     `message' and `error' directives).
 
- -- Ian Jackson <ian@davenant.greenend.org.uk>  Sat,  9 Oct 1999 19:45:21 +0100
+ --
 
 userv (0.64.1) unstable; urgency=low
 
diff --git a/lexer.c b/lexer.c
index 3cf44067d39bbb92e76a9e217a5966b35872fe04..77542e5b419b260b36e586ae5718c452dbc8af9a 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -801,6 +801,7 @@ char *yytext;
 #include "common.h"
 #include "daemon.h"
 #include "lib.h"
+#include "both.h"
 #include "tokens.h"
 
 #define HYPHEN '-'
@@ -1043,7 +1044,7 @@ YY_DECL
        register char *yy_cp, *yy_bp;
        register int yy_act;
 
-#line 142 "lexer.l"
+#line 143 "lexer.l"
 
 
 
@@ -1130,472 +1131,472 @@ do_action:    /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 144 "lexer.l"
+#line 145 "lexer.l"
 { lr_dir= df_reject; return tokv_word_reject; }
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 145 "lexer.l"
+#line 146 "lexer.l"
 { lr_dir= df_executefromdirectory; return tokv_word_executefromdirectory; }
        YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 146 "lexer.l"
+#line 147 "lexer.l"
 { lr_dir= df_executefrompath; return tokv_word_executefrompath; }
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 147 "lexer.l"
+#line 148 "lexer.l"
 { lr_dir= df_executebuiltin; return tokv_word_executebuiltin; }
        YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 148 "lexer.l"
+#line 149 "lexer.l"
 { lr_dir= df_errorstostderr; return tokv_word_errorstostderr; }
        YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 149 "lexer.l"
+#line 150 "lexer.l"
 { lr_dir= df_errorstosyslog; return tokv_word_errorstosyslog; }
        YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 150 "lexer.l"
+#line 151 "lexer.l"
 { lr_dir= df_errorstofile; return tokv_word_errorstofile; }
        YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 151 "lexer.l"
+#line 152 "lexer.l"
 { lr_dir= dfg_fdwant; lr_fdwant_readwrite=1; return tokv_word_requirefd; }
        YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 152 "lexer.l"
+#line 153 "lexer.l"
 { lr_dir= dfg_fdwant; lr_fdwant_readwrite=0; return tokv_word_allowfd; }
        YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 153 "lexer.l"
+#line 154 "lexer.l"
 { lr_dir= dfg_fdwant; lr_fdwant_readwrite=0; return tokv_word_nullfd; }
        YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 154 "lexer.l"
+#line 155 "lexer.l"
 { lr_dir= dfg_fdwant; lr_fdwant_readwrite=-1; return tokv_word_rejectfd; }
        YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 155 "lexer.l"
+#line 156 "lexer.l"
 { lr_dir= dfg_fdwant; lr_fdwant_readwrite=-1; return tokv_word_ignorefd; }
        YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 156 "lexer.l"
+#line 157 "lexer.l"
 { lr_dir= dfg_setflag; lr_flag= &setenvironment; lr_flagval= 1; return tokv_word_setenvironment; }
        YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 157 "lexer.l"
+#line 158 "lexer.l"
 { lr_dir= dfg_setflag; lr_flag= &setenvironment; lr_flagval= 0; return tokv_word_nosetenvironment; }
        YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 158 "lexer.l"
+#line 159 "lexer.l"
 { lr_dir= dfg_setflag; lr_flag= &suppressargs; lr_flagval= 1; return tokv_word_suppressargs; }
        YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 159 "lexer.l"
+#line 160 "lexer.l"
 { lr_dir= dfg_setflag; lr_flag= &suppressargs; lr_flagval= 0; return tokv_word_nosuppressargs; }
        YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 160 "lexer.l"
+#line 161 "lexer.l"
 { lr_dir= dfg_setflag; lr_flag= &disconnecthup; lr_flagval= 1; return tokv_word_disconnecthup; }
        YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 161 "lexer.l"
+#line 162 "lexer.l"
 { lr_dir= dfg_setflag; lr_flag= &disconnecthup; lr_flagval= 0; return tokv_word_nodisconnecthup; }
        YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 162 "lexer.l"
+#line 163 "lexer.l"
 { lr_dir= df_cd; return tokv_word_cd; }
        YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 163 "lexer.l"
+#line 164 "lexer.l"
 { lr_dir= df_userrcfile; return tokv_word_userrcfile; }
        YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 164 "lexer.l"
+#line 165 "lexer.l"
 { lr_dir= df_include; return tokv_word_include; }
        YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 165 "lexer.l"
+#line 166 "lexer.l"
 { lr_dir= df_include; return tokv_word_includeifexist; }
        YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 166 "lexer.l"
+#line 167 "lexer.l"
 { lr_dir= df_includelookup; return tokv_word_includelookup; }
        YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 167 "lexer.l"
+#line 168 "lexer.l"
 { lr_dir= df_includelookup; return tokv_word_includelookupall; }
        YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 168 "lexer.l"
+#line 169 "lexer.l"
 { lr_dir= df_includedirectory; return tokv_word_includedirectory; }
        YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 169 "lexer.l"
+#line 170 "lexer.l"
 { lr_dir= df_message; return tokv_word_message; }
        YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 170 "lexer.l"
+#line 171 "lexer.l"
 { lr_dir= df_include; return tokv_word_includesysconfig; }
        YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 171 "lexer.l"
+#line 172 "lexer.l"
 { lr_dir= dfi_includeuserrcfile; return tokv_word_includeuserrcfile; }
        YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 172 "lexer.l"
+#line 173 "lexer.l"
 { lr_dir= dfi_includeclientconfig; return tokv_word_includeclientconfig; }
        YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 173 "lexer.l"
+#line 174 "lexer.l"
 { lr_dir= df_quit; return tokv_word_quit; }
        YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 174 "lexer.l"
+#line 175 "lexer.l"
 { lr_dir= df_eof; return tokv_word_eof; }
        YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 175 "lexer.l"
+#line 176 "lexer.l"
 { lr_dir= df_if; return tokv_word_if; }
        YY_BREAK
 case 33:
 YY_RULE_SETUP
-#line 176 "lexer.l"
+#line 177 "lexer.l"
 { lr_dir= df_catchquit; return tokv_word_catchquit; }
        YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 177 "lexer.l"
+#line 178 "lexer.l"
 { lr_dir= df_errorspush; return tokv_word_errorspush; }
        YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 178 "lexer.l"
+#line 179 "lexer.l"
 { lr_controlend= tokv_word_if; return tokv_word_elif; }
        YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 179 "lexer.l"
+#line 180 "lexer.l"
 { lr_controlend= tokv_word_if; return tokv_word_else; }
        YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 180 "lexer.l"
+#line 181 "lexer.l"
 { lr_controlend= tokv_word_if; return tokv_word_fi; }
        YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 181 "lexer.l"
+#line 182 "lexer.l"
 { lr_controlend= tokv_word_catchquit; return tokv_word_hctac; }
        YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 182 "lexer.l"
+#line 183 "lexer.l"
 { lr_controlend= tokv_word_errorspush; return tokv_word_srorre; }
        YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 183 "lexer.l"
+#line 184 "lexer.l"
 { lr_parmcond= pcf_glob; return tokv_word_glob; }
        YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 184 "lexer.l"
+#line 185 "lexer.l"
 { lr_parmcond= pcf_range; return tokv_word_range; }
        YY_BREAK
 case 42:
 YY_RULE_SETUP
-#line 185 "lexer.l"
+#line 186 "lexer.l"
 { lr_parmcond= pcf_grep; return tokv_word_grep; }
        YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 186 "lexer.l"
+#line 187 "lexer.l"
 { lr_bispa= bispa_none; lr_bisexec= bisexec_environment; return tokv_word_environment; }
        YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 187 "lexer.l"
+#line 188 "lexer.l"
 { lr_bispa= bispa_parameter; lr_bisexec= bisexec_parameter; return tokv_word_parameter; }
        YY_BREAK
 case 45:
 YY_RULE_SETUP
-#line 188 "lexer.l"
+#line 189 "lexer.l"
 { lr_bispa= bispa_none; lr_bisexec= bisexec_version; return tokv_word_version; }
        YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 189 "lexer.l"
+#line 190 "lexer.l"
 { lr_bispa= bispa_none; lr_bisexec= bisexec_toplevel; return tokv_word_toplevel; }
        YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 190 "lexer.l"
+#line 191 "lexer.l"
 { lr_bispa= bispa_none; lr_bisexec= bisexec_override; return tokv_word_override; }
        YY_BREAK
 case 48:
 YY_RULE_SETUP
-#line 191 "lexer.l"
+#line 192 "lexer.l"
 { lr_bispa= bispa_none; lr_bisexec= bisexec_shutdown; return tokv_word_shutdown; }
        YY_BREAK
 case 49:
 YY_RULE_SETUP
-#line 192 "lexer.l"
+#line 193 "lexer.l"
 { lr_bispa= bispa_none; lr_bisexec= bisexec_reset; lr_dir= df_reset; return tokv_word_reset; }
        YY_BREAK
 case 50:
 YY_RULE_SETUP
-#line 193 "lexer.l"
+#line 194 "lexer.l"
 { lr_bispa= bispa_none; lr_bisexec= bisexec_execute; lr_dir= df_execute; return tokv_word_execute; }
        YY_BREAK
 case 51:
 YY_RULE_SETUP
-#line 194 "lexer.l"
+#line 195 "lexer.l"
 { lr_bispa= bispa_none; lr_bisexec= bisexec_help; return tokv_word_help; }
        YY_BREAK
 case 52:
 YY_RULE_SETUP
-#line 195 "lexer.l"
+#line 196 "lexer.l"
 { lr_parameter= pf_service; return tokv_word_service; }
        YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 196 "lexer.l"
+#line 197 "lexer.l"
 { lr_parameter= pf_callinguser; return tokv_word_callinguser; }
        YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 197 "lexer.l"
+#line 198 "lexer.l"
 { lr_parameter= pf_callinggroup; return tokv_word_callinggroup; }
        YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 198 "lexer.l"
+#line 199 "lexer.l"
 { lr_parameter= pf_callingusershell; return tokv_word_callingusershell; }
        YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 199 "lexer.l"
+#line 200 "lexer.l"
 { lr_parameter= pf_serviceuser; return tokv_word_serviceuser; }
        YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 200 "lexer.l"
+#line 201 "lexer.l"
 { lr_parameter= pf_servicegroup; return tokv_word_servicegroup; }
        YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 201 "lexer.l"
+#line 202 "lexer.l"
 { lr_parameter= pf_serviceusershell; return tokv_word_serviceusershell; }
        YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 202 "lexer.l"
+#line 203 "lexer.l"
 { lr_loglevel= LOG_DEBUG; return tokv_syslog_debug; }
        YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 203 "lexer.l"
+#line 204 "lexer.l"
 { lr_loglevel= LOG_INFO; return tokv_syslog_info; }
        YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 204 "lexer.l"
+#line 205 "lexer.l"
 { lr_loglevel= LOG_NOTICE; return tokv_syslog_notice; }
        YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 205 "lexer.l"
+#line 206 "lexer.l"
 { lr_loglevel= LOG_WARNING; return tokv_syslog_warning; }
        YY_BREAK
 case 63:
 YY_RULE_SETUP
-#line 206 "lexer.l"
+#line 207 "lexer.l"
 { lr_loglevel= LOG_ERR; return tokv_syslog_err; }
        YY_BREAK
 case 64:
 YY_RULE_SETUP
-#line 207 "lexer.l"
+#line 208 "lexer.l"
 { lr_loglevel= LOG_CRIT; return tokv_syslog_crit; }
        YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 208 "lexer.l"
+#line 209 "lexer.l"
 { lr_loglevel= LOG_ALERT; return tokv_syslog_alert; }
        YY_BREAK
 case 66:
 YY_RULE_SETUP
-#line 209 "lexer.l"
+#line 210 "lexer.l"
 { lr_loglevel= LOG_EMERG; return tokv_syslog_emerg; }
        YY_BREAK
 case 67:
 YY_RULE_SETUP
-#line 210 "lexer.l"
+#line 211 "lexer.l"
 { lr_logfacility= LOG_AUTHPRIV; return tokv_syslog_authpriv; }
        YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 211 "lexer.l"
+#line 212 "lexer.l"
 { lr_logfacility= LOG_CRON; return tokv_syslog_cron; }
        YY_BREAK
 case 69:
 YY_RULE_SETUP
-#line 212 "lexer.l"
+#line 213 "lexer.l"
 { lr_logfacility= LOG_DAEMON; return tokv_syslog_daemon; }
        YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 213 "lexer.l"
+#line 214 "lexer.l"
 { lr_logfacility= LOG_KERN; return tokv_syslog_kern; }
        YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 214 "lexer.l"
+#line 215 "lexer.l"
 { lr_logfacility= LOG_LPR; return tokv_syslog_lpr; }
        YY_BREAK
 case 72:
 YY_RULE_SETUP
-#line 215 "lexer.l"
+#line 216 "lexer.l"
 { lr_logfacility= LOG_MAIL; return tokv_syslog_mail; }
        YY_BREAK
 case 73:
 YY_RULE_SETUP
-#line 216 "lexer.l"
+#line 217 "lexer.l"
 { lr_logfacility= LOG_NEWS; return tokv_syslog_news; }
        YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 217 "lexer.l"
+#line 218 "lexer.l"
 { lr_logfacility= LOG_SYSLOG; return tokv_syslog_syslog; }
        YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 218 "lexer.l"
+#line 219 "lexer.l"
 { lr_logfacility= LOG_USER; return tokv_syslog_user; }
        YY_BREAK
 case 76:
 YY_RULE_SETUP
-#line 219 "lexer.l"
+#line 220 "lexer.l"
 { lr_logfacility= LOG_UUCP; return tokv_syslog_uucp; }
        YY_BREAK
 case 77:
 YY_RULE_SETUP
-#line 220 "lexer.l"
+#line 221 "lexer.l"
 { lr_logfacility= LOG_LOCAL0; return tokv_syslog_local0; }
        YY_BREAK
 case 78:
 YY_RULE_SETUP
-#line 221 "lexer.l"
+#line 222 "lexer.l"
 { lr_logfacility= LOG_LOCAL1; return tokv_syslog_local1; }
        YY_BREAK
 case 79:
 YY_RULE_SETUP
-#line 222 "lexer.l"
+#line 223 "lexer.l"
 { lr_logfacility= LOG_LOCAL2; return tokv_syslog_local2; }
        YY_BREAK
 case 80:
 YY_RULE_SETUP
-#line 223 "lexer.l"
+#line 224 "lexer.l"
 { lr_logfacility= LOG_LOCAL3; return tokv_syslog_local3; }
        YY_BREAK
 case 81:
 YY_RULE_SETUP
-#line 224 "lexer.l"
+#line 225 "lexer.l"
 { lr_logfacility= LOG_LOCAL4; return tokv_syslog_local4; }
        YY_BREAK
 case 82:
 YY_RULE_SETUP
-#line 225 "lexer.l"
+#line 226 "lexer.l"
 { lr_logfacility= LOG_LOCAL5; return tokv_syslog_local5; }
        YY_BREAK
 case 83:
 YY_RULE_SETUP
-#line 226 "lexer.l"
+#line 227 "lexer.l"
 { lr_logfacility= LOG_LOCAL6; return tokv_syslog_local6; }
        YY_BREAK
 case 84:
 YY_RULE_SETUP
-#line 227 "lexer.l"
+#line 228 "lexer.l"
 { lr_logfacility= LOG_LOCAL7; return tokv_syslog_local7; }
        YY_BREAK
 case 85:
 YY_RULE_SETUP
-#line 228 "lexer.l"
+#line 229 "lexer.l"
 { return tokv_word_read; }
        YY_BREAK
 case 86:
 YY_RULE_SETUP
-#line 229 "lexer.l"
+#line 230 "lexer.l"
 { return tokv_word_write; }
        YY_BREAK
 case 87:
 YY_RULE_SETUP
-#line 230 "lexer.l"
+#line 231 "lexer.l"
 { return tokv_dollar; }
        YY_BREAK
 case 88:
 YY_RULE_SETUP
-#line 231 "lexer.l"
+#line 232 "lexer.l"
 { return tokv_openparen; }
        YY_BREAK
 case 89:
 YY_RULE_SETUP
-#line 232 "lexer.l"
+#line 233 "lexer.l"
 { return tokv_closeparen; }
        YY_BREAK
 case 90:
 YY_RULE_SETUP
-#line 233 "lexer.l"
+#line 234 "lexer.l"
 { return tokv_not; }
        YY_BREAK
 case 91:
 YY_RULE_SETUP
-#line 234 "lexer.l"
+#line 235 "lexer.l"
 { return tokv_and; }
        YY_BREAK
 case 92:
 YY_RULE_SETUP
-#line 235 "lexer.l"
+#line 236 "lexer.l"
 { return tokv_or; }
        YY_BREAK
 case 93:
 YY_RULE_SETUP
-#line 236 "lexer.l"
+#line 237 "lexer.l"
 { lr_dir= df_error; lr_loglevel= LOG_ERR; return tokv_word_error; }
        YY_BREAK
 case 94:
 YY_RULE_SETUP
-#line 240 "lexer.l"
+#line 241 "lexer.l"
 {
                          char *ep;
                          lr_min=lr_max= (int)strtoul(yytext,&ep,10);
@@ -1605,7 +1606,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 95:
 YY_RULE_SETUP
-#line 246 "lexer.l"
+#line 247 "lexer.l"
 {
                          char *ep;
                          lr_min= (int)strtoul(yytext,&ep,10);
@@ -1622,7 +1623,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 96:
 YY_RULE_SETUP
-#line 259 "lexer.l"
+#line 260 "lexer.l"
 {
                          char *ep;
                          lr_min= (int)strtoul(yytext,&ep,10);
@@ -1634,27 +1635,27 @@ YY_RULE_SETUP
        YY_BREAK
 case 97:
 YY_RULE_SETUP
-#line 267 "lexer.l"
+#line 268 "lexer.l"
 return tokv_lwsp;
        YY_BREAK
 case 98:
 YY_RULE_SETUP
-#line 268 "lexer.l"
+#line 269 "lexer.l"
 return tokv_lwsp;
        YY_BREAK
 case 99:
 YY_RULE_SETUP
-#line 269 "lexer.l"
+#line 270 "lexer.l"
 cstate->lineno++; return tokv_newline;
        YY_BREAK
 case 100:
 YY_RULE_SETUP
-#line 270 "lexer.l"
+#line 271 "lexer.l"
 cstate->lineno++; return tokv_newline;
        YY_BREAK
 case 101:
 YY_RULE_SETUP
-#line 271 "lexer.l"
+#line 272 "lexer.l"
 {
                          parseerrprint("missing newline at eof after comment");
                          return tokv_error;
@@ -1662,14 +1663,14 @@ YY_RULE_SETUP
        YY_BREAK
 case 102:
 YY_RULE_SETUP
-#line 275 "lexer.l"
+#line 276 "lexer.l"
 {
                          return dequote(yytext);
                        }
        YY_BREAK
 case 103:
 YY_RULE_SETUP
-#line 278 "lexer.l"
+#line 279 "lexer.l"
 {
                          parseerrprint("misquoted or unterminated string");
                          return tokv_error;
@@ -1677,16 +1678,16 @@ YY_RULE_SETUP
        YY_BREAK
 case 104:
 YY_RULE_SETUP
-#line 282 "lexer.l"
+#line 283 "lexer.l"
 return tokv_barestring;
        YY_BREAK
 case YY_STATE_EOF(INITIAL):
-#line 283 "lexer.l"
+#line 284 "lexer.l"
 return tokv_eof;
        YY_BREAK
 case 105:
 YY_RULE_SETUP
-#line 286 "lexer.l"
+#line 287 "lexer.l"
 ECHO;
        YY_BREAK
 
@@ -2572,7 +2573,7 @@ int main()
        return 0;
        }
 #endif
-#line 286 "lexer.l"
+#line 287 "lexer.l"
 
 
 const char *const builtinservicehelpstrings[]= {
diff --git a/lexer.l b/lexer.l
index ac21f695e6c8265e787859a153f3b4ec525a6dc1..f3a2957dfc1b5f6d3e4bf194bc0eb13c2c8113c7 100644 (file)
--- a/lexer.l
+++ b/lexer.l
@@ -43,6 +43,7 @@
 #include "common.h"
 #include "daemon.h"
 #include "lib.h"
+#include "both.h"
 #include "tokens.h"
 
 #define HYPHEN '-'
index 7b26c1507c6c44981be7a1f89746a2ae29d5cde0..22ad0e0ead615ba0f4becb522d88a60c8e655b74 100644 (file)
@@ -42,6 +42,7 @@ include(language.i4)
 #include "common.h"
 #include "daemon.h"
 #include "lib.h"
+#include "both.h"
 #include "tokens.h"
 
 #define HYPHEN '-'
diff --git a/lib.c b/lib.c
index 22c8cd1750a52af1855b242104191d6abb3028a1..1352afa24d74fedcf48c2f369ebda1187f5ec33e 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "common.h"
 #include "lib.h"
+#include "both.h"
 
 char *xstrcat3save(const char *a, const char *b, const char *c) {
   char *r;
@@ -42,14 +43,6 @@ char *xstrcat3save(const char *a, const char *b, const char *c) {
   return r;
 }
 
-char *xstrsave(const char *s) {
-  char *r;
-
-  r= xmalloc(strlen(s)+1);
-  strcpy(r,s);
-  return r;
-}
-
 char *xstrsubsave(const char *begin, int len) {
   char *r;
   
@@ -59,17 +52,6 @@ char *xstrsubsave(const char *begin, int len) {
   return r;
 }
 
-void *xmalloc(size_t s) {
-  void *p;
-  p= malloc(s?s:1); if (!p) syscallerror("malloc");
-  return p;
-}
-
-void *xrealloc(void *p, size_t s) {
-  p= realloc(p,s); if (!p) syscallerror("realloc");
-  return p;
-}
-
 int makeroom(char **buffer, int *size, int needed) {
   if (needed > MAX_GENERAL_STRING) return -1;
   if (*size >= needed) return 0;
diff --git a/lib.h b/lib.h
index 7d78cb9856e1354d4f8e43e57bb167d6079a9953..701201695275b5eaeccc20becde5aede0e2803d1 100644 (file)
--- a/lib.h
+++ b/lib.h
 #define LIB_H
 
 char *xstrcat3save(const char *a, const char *b, const char *c);
-char *xstrsave(const char *s);
 char *xstrsubsave(const char *begin, int len);
 
 void miscerror(const char *what) NONRETURNING;
-void syscallerror(const char *what) NONRETURNING;
-void *xmalloc(size_t s);
-void *xrealloc(void *p, size_t s);
 int makeroom(char **buffer, int *size, int needed);
 /* makeroom returns -1 if needed was far too large; otherwise returns 0. */
 
index fa8b8ac033d4d6e65a179e1e893184469e2af571..ad877f42cc9cb7f2469d47a1b1a1cfab5efe522b 100644 (file)
@@ -35,6 +35,7 @@
 #include "common.h"
 #include "daemon.h"
 #include "lib.h"
+#include "both.h"
 #include "version.h"
 
 static void NONRETURNING serv_syscallfail(const char *msg) {