2 * This function reads the citadel.config file. It should be called at
3 * the beginning of EVERY Citadel program.
20 char bbs_home_directory[PATH_MAX];
21 int home_specified = 0;
23 void get_config(void) {
27 if (chdir( home_specified ? bbs_home_directory : BBSDIR ) != 0) {
28 fprintf(stderr, "Cannot start.\nThere is no Citadel installation in %s\n%s\n",
29 (home_specified ? bbs_home_directory : BBSDIR),
33 cfp=fopen("citadel.config","rb");
35 fprintf(stderr, "Cannot start.\n");
36 fprintf(stderr, "There is no citadel.config in %s\n%s\n",
37 (home_specified ? bbs_home_directory : BBSDIR),
41 fread((char *)&config,sizeof(struct config),1,cfp);
42 if (fstat(fileno(cfp), &st)) {
43 perror("citadel.config");
46 if (st.st_uid != BBSUID || st.st_mode != (S_IFREG | S_IRUSR | S_IWUSR))
48 fprintf(stderr, "check the permissions on citadel.config\n");
52 if ( (config.c_setup_level / 10) != (REV_LEVEL/10) ) {
53 fprintf(stderr, "config: Your data files are out of date. ");
54 fprintf(stderr, "Run setup to update them.\n");
56 " This program requires level %d.%02d\n",
57 (REV_LEVEL / 100), (REV_LEVEL % 100) );
59 " Data files are currently at %d.%02d\n",
60 (config.c_setup_level / 100),
61 (config.c_setup_level % 100) );
68 * Occasionally, we will need to write the config file, because some operations
69 * change site-wide parameters.
71 void put_config(void) {
74 if ((cfp = fopen("citadel.config", "rb+")) == NULL)
75 perror("citadel.config");
77 fwrite((char *)&config, sizeof(struct config), 1, cfp);