2 * This function reads the citadel.config file. It should be called at
3 * the beginning of EVERY Citadel program.
17 char bbs_home_directory[PATH_MAX];
18 int home_specified = 0;
20 void get_config(void) {
23 if (chdir( home_specified ? bbs_home_directory : BBSDIR ) != 0) {
24 fprintf(stderr, "Cannot start.\nThere is no Citadel installation in %s\n%s\n",
25 (home_specified ? bbs_home_directory : BBSDIR),
29 cfp=fopen("citadel.config","rb");
31 fprintf(stderr, "Cannot start.\n");
32 fprintf(stderr, "There is no citadel.config in %s\n%s\n",
33 (home_specified ? bbs_home_directory : BBSDIR),
37 fread((char *)&config,sizeof(struct config),1,cfp);
39 if ( (config.c_setup_level / 10) != (REV_LEVEL/10) ) {
40 fprintf(stderr, "config: Your data files are out of date. ");
41 fprintf(stderr, "Run setup to update them.\n");
43 " This program requires level %d.%02d\n",
44 (REV_LEVEL / 100), (REV_LEVEL % 100) );
46 " Data files are currently at %d.%02d\n",
47 (config.c_setup_level / 100),
48 (config.c_setup_level % 100) );
55 * Occasionally, we will need to write the config file, because some operations
56 * change site-wide parameters.
58 void put_config(void) {
61 cfp = fopen("citadel.config", "rb+");
62 fwrite((char *)&config, sizeof(struct config), 1, cfp);