2 * This function reads the citadel.config file. It should be called at
3 * the beginning of EVERY Citadel program.
19 char bbs_home_directory[PATH_MAX];
20 int home_specified = 0;
22 void get_config(void) {
25 if (chdir( home_specified ? bbs_home_directory : BBSDIR ) != 0) {
26 fprintf(stderr, "Cannot start.\nThere is no Citadel installation in %s\n%s\n",
27 (home_specified ? bbs_home_directory : BBSDIR),
31 cfp=fopen("citadel.config","rb");
33 fprintf(stderr, "Cannot start.\n");
34 fprintf(stderr, "There is no citadel.config in %s\n%s\n",
35 (home_specified ? bbs_home_directory : BBSDIR),
39 fread((char *)&config,sizeof(struct config),1,cfp);
41 if ( (config.c_setup_level / 10) != (REV_LEVEL/10) ) {
42 fprintf(stderr, "config: Your data files are out of date. ");
43 fprintf(stderr, "Run setup to update them.\n");
45 " This program requires level %d.%02d\n",
46 (REV_LEVEL / 100), (REV_LEVEL % 100) );
48 " Data files are currently at %d.%02d\n",
49 (config.c_setup_level / 100),
50 (config.c_setup_level % 100) );
57 * Occasionally, we will need to write the config file, because some operations
58 * change site-wide parameters.
60 void put_config(void) {
63 if ((cfp = fopen("citadel.config", "rb+")) == NULL)
64 perror("citadel.config");
66 fwrite((char *)&config, sizeof(struct config), 1, cfp);