/************************************************************* Do I really need 2 different functions to load the INI and HLP files? They both should reside in the current directory or path. But only HLP should be in the system HELP directories. ***************************************************************/ bool load_ini(void) { bool ok = FALSE; USHORT return_code; char ini_path[FNAME_LEN]; char temp_path[FNAME_LEN]; memset(temp_path, '\0', FNAME_LEN); memset(ini_path, '\0', FNAME_LEN); if(!settings_loaded){ ok = setting_load ("ked.ini"); /* try to load from current dir */ DBG_INI(dout<< " Settings loaded cur dir ="<<ok<<endl); if(!ok) { /* KED.INI must be on PATH */ return_code = DosSearchPath(2,(PSZ)"PATH",(PSZ)"KED.INI",ini_path, sizeof(ini_path)); if (return_code == 0) { ok = setting_load((char *)ini_path); DBG_INI(dout<< " Settings loaded path ="<<ok<<endl); } else { strcpy(temp_path, exe_dir); // DBG_INI(dout<< "settings from exe dir = "<< temp_path<<endl); strcpy(ini_path, find_basesubdir(temp_path)); strcat(ini_path, "KED.INI"); ok = setting_load(ini_path); DBG_INI(dout<<"loaded settings from exe dir = "<<ok<<endl); } } } return ok; }
static int setting_load_int(const char *name, int default_value) { #ifndef WIN32 char *value; if (setting_load(name, &value)) { return atoi(value); } return default_value; #else LONG status; char buffer[SETTINGS_BUF_SIZE]; DWORD ValueType; int value, val_len; ValueType = REG_DWORD; val_len = sizeof(int); status = RegQueryValueEx(cfgKey, name, NULL, &ValueType, &(char)value, &val_len); if (status != ERROR_SUCCESS) { FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, SETTINGS_BUF_SIZE, NULL); debug_msg("Unable to load setting %s: %s\n", name, buffer); return default_value; } return value; #endif }
static char * setting_load_str(const char *name, char *default_value) { #ifndef WIN32 char *value; if (setting_load(name, &value)) { return value; } return default_value; #else LONG status; char buffer[SETTINGS_BUF_SIZE]; DWORD ValueType; int val_len; char *value; ValueType = REG_SZ; /* call RegQueryValueEx once first to get size of string */ status = RegQueryValueEx(cfgKey, name, NULL, &ValueType, NULL, &val_len); if (status != ERROR_SUCCESS) { FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, SETTINGS_BUF_SIZE, NULL); debug_msg("Unable to load setting: %s\n", buffer); return default_value; } /* now that we know size we can allocate memory and call RegQueryValueEx again */ value = (char*)xmalloc(val_len * sizeof(char)); status = RegQueryValueEx(cfgKey, name, NULL, &ValueType, value, &val_len); if (status != ERROR_SUCCESS) { FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, SETTINGS_BUF_SIZE, NULL); debug_msg("Unable to load setting %s: %s\n", name, buffer); return default_value; } return value; #endif }
INT32 main(INT32 argc, CHAR** argv ) { OPZG o; setting_load(&o); token_load(&o); czed_sep(&o); CHAR cmd[2048]; gcc_cmd(cmd, argc, argv); PIPE p; pro_pipe(&p); pro_bash(cmd, &p, PRO_PIPE_RED_ERR); while ( (fgets(cmd,2048,p.finp)) ) czed_parse(&o,cmd); //czed_chkcolor(&o, cmd); czed_sep(&o); pro_pipe_close(&p); return 0; }
static void process_option (char *s) { switch (*s) { // case 's': /* Swap option */ // switch (s[1]) { // default: resume_mode= 1; break; /* fast */ // } // break; // case 'r': /* display rows */ // Vid::get_height()= atoi(s+1); // break; // case 'c': /* display columns */ // Vid::get_width()= atoi(s+1); // break; // case 'M': /* video mode */ // Video::vidparms.w_mode= atoi(s+1); // break; //#ifdef KED_BETA // case 'd': // case 'D': // debug_on = TRUE; // break; //#endif case 'g': /* load settings file if not already loaded */ if (settings_loaded) break; /* else falls through */ case 'G': /* load a settings file */ if (setting_load (s+1)) settings_loaded= TRUE; break; case 'P': /* program name */ strcpy (progname, s+1); break; case 'e': /* default file extension */ strncpy (settings.default_ext, s+1, 4); break; default: redbox_s (20,201,eh_continue,s-1); } }
void flash_init(void) { /* SMCLK | divided by 12 = */ FCTL2 = FWKEY + FSSEL_2 + (FN1|FN3); setting_load(); }