/* MSN Conf file processor * filename: /src/conf.c * Coded by James Greig * James@mor-pah.net * Date: 30/06/03 */ #include #include #include #include "headers/defs.h" #include "headers/conf.h" extern char certificate[128]; extern int args[3][1]; int get_var(); void conf() { int ctr, tmp; int flag = 0; FILE *fp; char *homedir; char ch; char home_directory[255]; char pre[255]; /* Temp Buffer for config lines */ char _confstr[MAX_NO_LINES][MAX_LINE_LENGTH]; /* Temp buffer for valid config lines */ homedir = getenv("HOME"); if (homedir == NULL) { homedir = getenv("USER"); if (homedir == NULL) { homedir = getenv("USERNAME"); if (homedir == NULL) { cli_msg( stderr, "Could not find user's home directory!\n" ); } } strcpy(home_directory,"/home/"); } strcpy(home_directory,homedir); strcat(home_directory,"/.msn/msn.conf"); if ( (fp = fopen(home_directory, "r")) != NULL ){ cli_msg("Reading msn.conf...\n"); } else { cli_msg("No config file found at: %s\n", home_directory); cli_msg("Continuing with command line args and defaults\n"); return; } ctr = 0; while(!feof(fp)) { memset(pre, '\0', sizeof(pre)); fgets(pre, MAX_LINE_LENGTH, fp); if ( ( strstr(pre, "user") > 0 ) || ( strstr(pre, "pass") > 0 ) || ( strstr(pre, "cert") > 0 ) || ( strstr(pre, "log") > 0 )){ strcpy(_confstr[ctr], pre); ctr++; } } /* Username was not specified by an arg switch, so fetch from conf */ if ( username[0] == 0 || certificate[0] == 0) { for(tmp=0;tmp