home *** CD-ROM | disk | FTP | other *** search
- #include "microlib.h"
-
- extern char iepdrive[3];
- extern char ieppath[50];
-
- /***************************************************************************\
- |* Function: char *files(int filenum) *|
- |* Description: Converts Alias Name to Pathname. *|
- |* Parameters: filenum --> Which file ? *|
- |* Returns: File's pathname. *|
- |* Uses: Nothing. *|
- \***************************************************************************/
- char *files(filenum)
- int filenum;
- {
- tmp_pathname[0] = '\0';
-
- strcpy(tmp_pathname, ieppath);
- strcat(tmp_pathname, dbfpath);
- strcat(tmp_pathname, dbf[filenum]);
- return(tmp_pathname);
- }
-
- /***************************************************************************\
- |* Function: char *screens(int filenum) *|
- |* Description: Adds Path to screen file name. *|
- |* Parameters: filenum --> Which file ? *|
- |* Returns: File's pathname. *|
- |* Uses: Nothing. *|
- \***************************************************************************/
- char *screens(filenum)
- int filenum;
- {
- tmp_pathname[0] = '\0';
-
- strcpy(tmp_pathname, ieppath);
- strcat(tmp_pathname, scrpath);
- strcat(tmp_pathname, sc[filenum]);
- return(tmp_pathname);
- }
-
- /***************************************************************************\
- |* Function: int read_default_values() *|
- |* Description: Reads the default values from the file IEP.INI . *|
- |* Parameters: None. *|
- |* Returns: Nothing. *|
- |* Uses: Nothing. *|
- \***************************************************************************/
- read_default_values()
- {
- FILE *ini;
- int count;
- long section_ptr;
- char line[80];
-
- if ((ini = fopen("IEP.INI", "r")) == NULL) {
- printf("%sIEP.INI\n", mes[ME+0]);
- exit(1);
- }
-
- line[0]='\0';
- fseek(ini, 0L, SEEK_SET);
- while (!strstr(line, "[colors]")) {
- if ( !fgets(line, 79, ini )) {
- printf(mes[ME+20]);
- exit(1);
- }
- }
- section_ptr = ftell(ini);
-
- custom[MENU_N] = read_integer(ini, "menu_normal", section_ptr);
- custom[MENU_S] = read_integer(ini, "menu_selection", section_ptr);
- custom[MENU_F] = read_integer(ini, "menu_first", section_ptr);
- custom[PULL_N] = read_integer(ini, "pulldown_normal", section_ptr);
- custom[PULL_S] = read_integer(ini, "pulldown_selection", section_ptr);
- custom[PULL_F] = read_integer(ini, "pulldown_first", section_ptr);
- custom[PULL_B] = read_integer(ini, "pulldown_border", section_ptr);
- custom[PULL_D] = read_integer(ini, "pulldown_disabled", section_ptr);
- custom[STAT_N] = read_integer(ini, "status_normal", section_ptr);
- custom[STAT_F] = read_integer(ini, "status_first", section_ptr);
- custom[MESS_N] = read_integer(ini, "help_normal", section_ptr);
- custom[ERR_N] = read_integer(ini, "error_normal", section_ptr);
- custom[ERR_B] = read_integer(ini, "error_border", section_ptr);
- custom[MAIN_N] = read_integer(ini, "main_normal", section_ptr);
- custom[MAIN_I] = read_integer(ini, "main_input", section_ptr);
- custom[MAIN_S] = read_integer(ini, "main_selection", section_ptr);
- custom[WARN_N] = read_integer(ini, "warn_normal", section_ptr);
- custom[HELPSCR_N] = read_integer(ini, "helpscr_normal", section_ptr);
- custom[HELPSCR_T] = read_integer(ini, "helpscr_title", section_ptr);
- custom[HELPSCR_S] = read_integer(ini, "helpscr_nextsym", section_ptr);
- custom[BROWSER_N] = read_integer(ini, "browser_normal", section_ptr);
- custom[BROWSER_S] = read_integer(ini, "browser_selection", section_ptr);
- custom[BROWSER_B] = read_integer(ini, "browser_border", section_ptr);
- custom[WAIT_N] = read_integer(ini, "wait_normal", section_ptr);
- custom[WAIT_B] = read_integer(ini, "wait_border", section_ptr);
-
- line[0]='\0';
- fseek(ini, 0L, SEEK_SET);
- while (!strstr(line, "[editors]")) {
- if( !fgets(line, 79, ini ) ) {
- printf(mes[ME+19]);
- exit(1);
- }
- }
- section_ptr = ftell(ini);
-
- doccreate = read_integer(ini, "create_document", section_ptr);
- read_string(ini, "wordprocessor", wordprocessor, section_ptr);
- read_string(ini, "viewer", viewer, section_ptr);
- read_string(ini, "docpath", docpath, section_ptr);
- if(docpath[strlen(docpath) - 1] != '\\') {
- docpath[strlen(docpath)] = '\\';
- docpath[strlen(docpath) + 1] = '\0';
- }
-
- if(docpath[1] == ':') {
- memcpy(docdrive, docpath, 2);
- docdrive[0] = gtoupper(docdrive[0]);
- docdrive[2] = '\0';
- }
- else
- memcpy(docdrive, space(3), 3);
- read_string(ini, "pattern", pattern, section_ptr);
-
- line[0]='\0';
- fseek(ini, 0L, SEEK_SET);
- while (!strstr(line, "[misc]")) {
- if( !fgets(line, 79, ini ) ) {
- printf(mes[ME+27]);
- exit(1);
- }
- }
- section_ptr = ftell(ini);
- read_string(ini, "ieppath", ieppath, section_ptr);
- if(ieppath[0] != '\0') {
- if(ieppath[strlen(ieppath) - 1] != '\\') {
- ieppath[strlen(ieppath)] = '\\';
- ieppath[strlen(ieppath) + 1] = '\0';
- }
- if(ieppath[1] == ':') {
- memcpy(iepdrive, ieppath, 2);
- iepdrive[0] = gtoupper(iepdrive[0]);
- iepdrive[2] = '\0';
- }
- else
- memcpy(iepdrive, space(3), 3);
- }
-
- read_string(ini, "comm_program", comm_program, section_ptr);
- read_string(ini, "comm_path", comm_path, section_ptr);
- if(comm_path[0] != '\0') {
- if(comm_path[strlen(comm_path) - 1] != '\\') {
- comm_path[strlen(comm_path)] = '\\';
- comm_path[strlen(comm_path) + 1] = '\0';
- }
- if(comm_path[1] == ':') {
- memcpy(comm_drive, comm_path, 2);
- comm_drive[0] = gtoupper(comm_drive[0]);
- comm_drive[2] = '\0';
- }
- else
- memcpy(comm_drive, space(3), 3);
- }
-
- fclose(ini);
- }
-
- /***************************************************************************\
- |* Function: int read_string(FILE *fp, char *key, char *ret_str, *|
- |* long section_ptr) *|
- |* Description: Finds the string "key" in the file "fp" and returns its *|
- |* value. The file must be in the following format: *|
- |* something = value *|
- |* something = value *|
- |* Parameters: FILE *fp -> File to search. *|
- |* char *key -> string to search. *|
- |* Returns: The value after equal sign. *|
- |* Uses: Nothing. *|
- \***************************************************************************/
- static int read_string(fp, key, ret_str, section_ptr)
- FILE *fp;
- char *key;
- char *ret_str;
- long section_ptr;
- {
- char line[80];
- char *line_p;
-
- line[0] = '\0';
-
- fseek(fp, section_ptr, SEEK_SET);
- while (!strstr(line, key)) {
- if( ! fgets(line, 79, fp )) {
- printf("%s %s", mes[ME+54], key);
- fclose(fp);
- exit(-1);
- }
- }
- line_p = strchr(line, '=') + (1 * sizeof(char));
- trim_n(line_p, strlen(line_p));
- strcpy(ret_str, line_p);
- }
-
-
- /***************************************************************************\
- |* Function: int read_integer(FILE *fp, char *key, long section_ptr) *|
- |* Description: Finds the string "key" in the file "fp" and returns its *|
- |* value. The file must be in the following format: *|
- |* something = value *|
- |* something = value *|
- |* Parameters: FILE *fp -> File to search. *|
- |* char *key -> string to search. *|
- |* Returns: The value after equal sign. *|
- |* Uses: Nothing. *|
- \***************************************************************************/
- static int read_integer(fp, key, section_ptr)
- FILE *fp;
- char *key;
- long section_ptr;
- {
- char line[80];
- line[0] = '\0';
-
- fseek(fp, section_ptr, SEEK_SET);
- while (!strstr(line, key)) {
- if( ! fgets(line, 79, fp ) ) {
- printf("%s %s", mes[ME+54], key);
- fclose(fp);
- exit(-1);
- }
- }
- return(atoi(strchr(line, '=') +1)) ;
- }
-
- int trim_n(str, n_ch)
- char *str;
- int n_ch;
- {
- char *old_str;
- int count;
- int pos_d;
-
- /* Allocate memory for the old sting. */
- if( (old_str = (char *) calloc(n_ch, sizeof(char))) == NULL ) {
- w4display(mes[MT], mes[ME+1], (char *) 0);
- w4exit(1);
- }
- strcpy(old_str, str);
-
- pos_d = 0;
- for(count = 0; count < n_ch; count ++) {
- if( old_str[count] == '\n') {
- continue;
- }
- if(old_str[count]==' ' || old_str[count]=='\t') {
- if(old_str[count + 1] == ' ' || old_str[count + 1] == '\n' ||\
- pos_d == 0) {
- continue;
- }
- }
- str[pos_d] = old_str[count];
- pos_d ++;
- }
- str[pos_d] = '\0';
- free(old_str);
- }
-