+void get_config (void)
+{
+ int a;
+ int rv;
+ FILE *fp;
+
+ /*
+ * What we're going to try to do here is append a whole bunch of
+ * nulls to the citadel.config file, so we can keep the old config
+ * values if they exist, but if the file is missing or from an
+ * earlier version with a shorter config structure, when setup tries
+ * to read the old config parameters, they'll all come up zero.
+ * The length of the config file will be set to what it's supposed
+ * to be when we rewrite it, because we replace the old file with a
+ * completely new copy.
+ */
+ if ((a = open(file_citadel_config, O_WRONLY | O_CREAT | O_APPEND,
+ S_IRUSR | S_IWUSR)) == -1) {
+ display_error("%s citadel.config [%s][%s]\n", _("setup: cannot append"), file_citadel_config, strerror(errno));
+ cleanup(errno);
+ }
+ fp = fdopen(a, "ab");
+ if (fp == NULL) {
+ display_error("%s citadel.config [%s][%s]\n", _("setup: cannot append"), file_citadel_config, strerror(errno));
+ cleanup(errno);
+ }
+ for (a = 0; a < sizeof(struct config); ++a) {
+ putc(0, fp);
+ }
+ fclose(fp);
+
+ /* now we re-open it, and read the old or blank configuration */
+ fp = fopen(file_citadel_config, "rb");
+ if (fp == NULL) {
+ display_error("%s citadel.config [%s][%s]\n", _("setup: cannot open"), file_citadel_config, strerror(errno));
+ cleanup(errno);
+ return;
+ }
+ rv = fread((char *) &config, sizeof(struct config), 1, fp);
+ if (rv == -1)
+ display_error("%s citadel.config [%s][%s]\n", _("setup: cannot write"), file_citadel_config, strerror(errno));
+ fclose(fp);