(verbosely) skip the strip -x in the case of config -g
[unix-history] / sbin / init.chmr / configure.c
index c180215..1c8ca0f 100644 (file)
@@ -1,10 +1,7 @@
-/*-
- * Copyright (c) 1993 The Regents of the University of California.
+/*
+ * Copyright (c) 1993 Christoph M. Robitschko
  * All rights reserved.
  *
  * All rights reserved.
  *
- * This code is derived from software contributed to Berkeley by
- * Christoph Robitschko.
- *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
  *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
+ *      This product includes software developed by Christoph M. Robitschko
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough specific prior written permission
  *
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 /*
  */
 
 /*
@@ -41,6 +35,7 @@
 
 #ifdef CONFIGURE
 
 
 #ifdef CONFIGURE
 
+#include <errno.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -64,7 +59,7 @@ static int    evaluate_line(char *, int, int, char **, int);
 static int     parseline(char *, int, int, char **);
 
 
 static int     parseline(char *, int, int, char **);
 
 
-char   *fgetline(FILE *, size_t *);                    /* XXX */
+char   *fgetln(FILE *, size_t *);                      /* XXX */
 
 
 extern const struct Command    Commands[];
 
 
 extern const struct Command    Commands[];
@@ -82,10 +77,11 @@ char                *filename;
 {
 static int     ncalled = 0;
 FILE           *cf;
 {
 static int     ncalled = 0;
 FILE           *cf;
-char           *line, *s, *errmsg;
+char           *fline, *line, *s, *errmsg;
 int            lineno;
 char           **cline;
 int            argc;
 int            lineno;
 char           **cline;
 int            argc;
+size_t         len;
 
 
        Debug (1, "Configuring from file %s", filename);
 
 
        Debug (1, "Configuring from file %s", filename);
@@ -103,11 +99,25 @@ int                argc;
        }
        Debug(1, "Config file %s opened.", filename);
 
        }
        Debug(1, "Config file %s opened.", filename);
 
+       if ((line = (char *) malloc(1)) == (char *) 0) {
+               syslog(LOG_ERR, "%s: %s", filename, strerror(errno));
+               ncalled --;
+               return;
+       }
+
        lineno = 0;
        lineno = 0;
-       while ((line = fgetline(cf, (size_t *)0))) {
+       while ((fline = fgetln(cf, &len))) {
                lineno ++;
                lineno ++;
-               if (*line == '#')
+               if (*fline == '#')
                        continue;               /* Skip comment line */
                        continue;               /* Skip comment line */
+               else if (fline[len - 1] == '\n')
+                       --len;
+               if ((line = (char *) realloc(line, len + 1)) == (char *) 0) {
+                       syslog(LOG_ERR, "%s: %s", filename, strerror(errno));
+                       break;
+               }
+               bcopy(fline, line, len);
+               line[len] = '\0';
                for (s = line; *s; s++)
                        if ((*s != ' ') && (*s != '\t'))
                                break;
                for (s = line; *s; s++)
                        if ((*s != ' ') && (*s != '\t'))
                                break;
@@ -118,8 +128,8 @@ int         argc;
                        syslog(LOG_ERR, "%s line %d: %s", filename, lineno, errmsg);
                if (cline && argc > 0)
                        (void)parseline(filename, lineno, argc, cline);
                        syslog(LOG_ERR, "%s line %d: %s", filename, lineno, errmsg);
                if (cline && argc > 0)
                        (void)parseline(filename, lineno, argc, cline);
-
        }
        }
+       free(line);
        fclose(cf);
        ncalled --;
 }
        fclose(cf);
        ncalled --;
 }