Only in freeciv/server: .deps Only in freeciv/server: Makefile Only in freeciv/server: civserver diff -cr freeciv.orig/server/civserver.c freeciv/server/civserver.c *** freeciv.orig/server/civserver.c Tue Dec 22 12:31:06 1998 --- freeciv/server/civserver.c Tue Dec 29 16:17:28 1998 *************** *** 19,24 **** --- 19,25 ---- #include #include #include + #include #include #ifdef __EMX__ *************** *** 118,123 **** --- 119,126 ---- char *log_filename=NULL; char *load_filename=NULL; char *script_filename=NULL; + char *civserverrc_filename=NULL; + char name_buffer[MAX_LENGTH_NAME]; int i; int save_counter=0; int log_level=LOG_NORMAL; *************** *** 279,284 **** --- 282,331 ---- /* accept new players, wait for serverop to start..*/ flog(LOG_NORMAL, "Now accepting new client connections"); server_state=PRE_GAME_STATE; + + /* read .civserverrc - compare the following to ../client/optiondlg.c */ + civserverrc_filename = getenv(ENV_CIVSERVERRC); + if (!civserverrc_filename) { + civserverrc_filename = getenv("HOME"); + if (!civserverrc_filename) { + flog(LOG_NORMAL, + "Cannot find $HOME, giving up trying to read %s", DEFAULT_CIVSERVERRC); + } else { + strncpy(name_buffer,civserverrc_filename,MAX_LENGTH_NAME); + name_buffer[MAX_LENGTH_NAME] = '\0'; + { + /* not sure if index() exists everywhere */ + int maxlen; int envlen; char *s; + for (s=DEFAULT_CIVSERVERRC, envlen=0; *s; ++s, ++envlen); + for (s=name_buffer, maxlen=MAX_LENGTH_NAME; *s; ++s, --maxlen); + if (maxlen >= 1+envlen) { + *s = '/'; ++s; + strncpy(s,DEFAULT_CIVSERVERRC,envlen); + s[envlen] = '\0'; + civserverrc_filename = name_buffer; + } else { + civserverrc_filename = (char *)NULL; + flog(LOG_NORMAL, "%s/%s is too long, not reading it", + getenv("HOME"), DEFAULT_CIVSERVERRC); + } + } + } + } + if (civserverrc_filename) { + struct stat ss; + + flog(LOG_DEBUG, "settings file is %s", civserverrc_filename); + + if (stat(civserverrc_filename,&ss)) { + flog(LOG_NORMAL, "Cannot stat %s, skipping it", civserverrc_filename); + } else if (S_ISDIR(ss.st_mode)) { + flog(LOG_NORMAL, "%s is a directory, skipping it", civserverrc_filename); + } else if (!(ss.st_mode & S_IRUSR)) { + flog(LOG_NORMAL, "Cannot read %s, skipping it", civserverrc_filename); + } else { + read_init_script(civserverrc_filename); + } + } if (script_filename) read_init_script(script_filename); diff -cr freeciv.orig/server/civserver.h freeciv/server/civserver.h *** freeciv.orig/server/civserver.h Tue Dec 22 12:31:06 1998 --- freeciv/server/civserver.h Tue Dec 29 15:58:07 1998 *************** *** 16,21 **** --- 16,25 ---- #include "game.h" #include "packets.h" + #define DEFAULT_CIVSERVERRC ".civserverrc" + /* but $HOME/ is prepended */ + #define ENV_CIVSERVERRC "FREECIV_SERVERRC" + /* name of env var to use - $HOME will *not* be appended */ struct connection; struct unit;