]> andersk Git - moira.git/blobdiff - update/config.c
syslog instead of spewing to stdout.
[moira.git] / update / config.c
index c76592c33c7d4d7abf3c54ebccf6d77c6b7ee2cf..b40670a092381ecc6a410aa38be178dc2e19e69f 100644 (file)
@@ -1,26 +1,30 @@
-/* $Header$
+/* $Id$
  *
  * Routines to handle configuration file for Moira's update_server.
  * These routines must load the file into memory rather than parse
  * it each time as one of the things the server may do is chroot()
  * itself.
  *
- * (c) Copyright 1992 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
  * For copying and distribution information, please see the file
  * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <moira.h>
+#include <unistd.h>
 
+RCSID("$Header$");
 
 #define CONFIG_FILE    "/etc/athena/moira.conf"
 
@@ -37,8 +41,7 @@
 static char *config_buf = NULL;
 static char **config_keys, **config_values;
 
-
-static init()
+static int init(void)
 {
   int fd, count = 0;
   struct stat st;
@@ -53,14 +56,19 @@ static init()
     {
       config_buf = "";
       config_keys = malloc(sizeof(char *) * 2);
+      if (!config_keys)
+       return ENOMEM;
       config_keys[0] = config_keys[1] = NULL;
       return MR_SUCCESS;
     }
+
   if (fstat(fd, &st) < 0)
     return MR_INTERNAL;
+
   config_buf = malloc(st.st_size + 2);
   if (!config_buf)
-    return MR_NO_MEM;
+    return ENOMEM;
+
   if (read(fd, config_buf, st.st_size) < st.st_size)
     {
       free(config_buf);
@@ -80,13 +88,17 @@ static init()
   if (!config_keys || !config_values)
     {
       free(config_buf);
+      free(config_keys);
+      free(config_values);
       config_buf = NULL;
-      return MR_NO_MEM;
+      return ENOMEM;
     }
+
   count = 0;
   for (p = strtok(config_buf, "\n"); p; p = strtok(NULL, "\n"))
     config_keys[count++] = p;
   config_keys[count] = NULL;
+
   for (count = 0; config_keys[count]; count++)
     {
       config_values[count] = "";
This page took 0.079249 seconds and 4 git commands to generate.