/************************************************************************/ /* WiseTools, Release 1.0. This software is copyright */ /* Ewan Birney (c), 1995. */ /* Anyone can distribute/compile and use this software */ /* free of charge as long as this notice remains intact */ /* */ /* Any alterations should be cleared by Ewan Birney. */ /* Email birney@molbiol.ox.ac.uk */ /* URL http://www.molbiol.ox.ac.uk/www/users/birney/wise/topwise.html */ /* */ /* This software is provided as is, and the author does not accept any */ /* liability for its use or performance :) */ /************************************************************************/ #include "wisebase.h" #define MAXFIG 512 #define MAXLINE 512 typedef struct { char * keyword; char * string; char * filename; /* this is not alloc'd */ } config; static config list[MAXFIG]; static int maxnum=0; static char * filenamelist[64]; static int noffiles=0; char * get_usermailname(void) { char * out; out = config_single_from_key("usermailname"); if( out != NULL) return out; out = getenv("user"); if( out != NULL ) return stringalloc(out); out = getenv("USER"); if( out != NULL) return stringalloc(out); return NULL; } boolean is_config_system(void) { return (noffiles == 0 ? FALSE : TRUE); } char ** filename_list(int * retval) { *retval=noffiles; return filenamelist; } boolean read_set_config(void) { char * runner; if( (runner=getenv("WISESYSTEMFILE")) != NULL) read_config_file(runner); else read_config_file("wise.cfg"); if( (runner=getenv("WISEPERSONALFILE")) != NULL) read_config_file(runner); if( is_config_system() == FALSE) { log_full_error(WARNING,0,"Unable to find config files, " "going to try a variety of other filenames. Default has changed " "to wise.cfg for all systems"); read_config_file("wise.cfg"); read_config_file(".wisecfg"); if( is_config_system() == FALSE) log_full_error(WARNING,0,"Unable to find any config files " "will bug out now"); return TRUE; } return TRUE; } int index_from_keyword(char * key) { register int i; if(noffiles == 0) { log_full_error(PEDANTIC,0,"Tried to pull keyword in config " "but no file has been read"); return -1; } for(i=0;i