Fix warnings all over citserver; handle function replies; remove unused code.
[citadel.git] / citadel / config.c
index bc42c559a76d36a8985c76e0d57766f406bd8c37..bc9a4128e9bd0b9c8cc5c0793797cee82d5a8bf1 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * Read and write the citadel.config file
  *
  * Copyright (c) 1987-2009 by the citadel.org team
@@ -67,7 +65,14 @@ void get_config(void) {
                                strerror(errno));
                exit(CTDLEXIT_CONFIG);
        }
+       memset(&config, 0, sizeof(struct config));
        rv = fread((char *) &config, sizeof(struct config), 1, cfp);
+       if (rv != 1)
+       {
+               fprintf(stderr, 
+                       "Warning: The config file %s has unexpected size. \n",
+                       file_citadel_config);
+       }
        if (fstat(fileno(cfp), &st)) {
                perror(file_citadel_config);
                exit(CTDLEXIT_CONFIG);
@@ -174,6 +179,9 @@ void put_config(void)
                perror(file_citadel_config);
        else {
                rv = fwrite((char *) &config, sizeof(struct config), 1, cfp);
+               if (rv == -1)
+                       syslog(LOG_EMERG, "Failed to write: %s [%s]\n", 
+                              file_citadel_config, strerror(errno));
                fclose(cfp);
        }
 }