/************************************************************************** * Function: get_private_profile_int() * Arguments: <char *> section - the name of the section to search for * <char *> entry - the name of the entry to find the value of * <int> def - the default value in the event of a failed read * <char *> file_name - the name of the .ini file to read from * Returns: the value located at entry ***************************************************************************/ int get_private_profile_int(char *section, char *entry, int def, char *file_name) { FILE *fp = fopen(file_name,"r"); char buff[MAX_LINE_LENGTH]; if( !fp ) return def; /* Return default value if file does not exist */ if (!read_section (fp, section)) goto err; if (!read_entry (fp, entry, buff, MAX_LINE_LENGTH)) goto err; def = read_int_value (buff, def); err: fclose (fp); return def; }
static int parse_int_values(testspec_t *t, mp_int *in, mp_int *out, mp_result *rval) { int i, pos = 0; char *str; if(rval != NULL) *rval = MP_OK; /* default */ if(in != NULL) { for(i = 0; i < t->num_inputs; ++i) { str = t->input[i]; trim_line(str); if(*str == '=') { int k = abs(atoi(str + 1)) - 1; if(k < 0 || k >= i) { fprintf(stderr, "Line %d: Invalid input back-reference [%s]\n", t->line, str); return 0; } in[i] = in[k]; } else { mp_int reg = g_zreg + pos++; /* grab next free register */ if(read_int_value(reg, str) != MP_OK) { fprintf(stderr, "Line %d: Invalid input value [%s]\n", t->line, str); return 0; } in[i] = reg; } } } for(i = 0; i < t->num_outputs; ++i) { mp_int reg = g_zreg + pos++; str = t->output[i]; trim_line(str); if(strcmp(str, "?") == 0) mp_int_zero(reg); else if(*str == '$') { mp_result code; if(!parse_result_code(str, &code)) { fprintf(stderr, "Line %d: Invalid result code [%s]\n", t->line, str); return 0; } else if(rval == NULL) { fprintf(stderr, "Line %d: Result code not permitted here [%s]\n", t->line, str); return 0; } else *rval = code; /* Provide a dummy value for the corresponding output */ mp_int_zero(reg); } else if(out != NULL && read_int_value(reg, str) != MP_OK) { fprintf(stderr, "Line %d: Invalid output value [%s]\n", t->line, str); return 0; } if(out != NULL) out[i] = reg; } return 1; }