56 for (; *
s !=
'\0' && isspace(*
s);
s++)
58 if (!isalnum(*
s) && *
s !=
'-') {
63 for (s1 =
s; isalnum(*s1) || *s1 ==
'_' || *s1 ==
'-' || *s1 ==
'('; s1++)
67 *dest = (
char *)strndup(
s, len);
79 if ((b = getc(
in)) == EOF)
95 *dest = strdup(line + 1);
97 *dest = realloc(*dest, strlen(*dest) + strlen(line + 1) + 1);
98 strcat(*dest, line + 1);
104void FC_FUNC_(varinfo_init, VARINFO_INIT)(STR_F_TYPE
const fname STR_ARG1) {
105 char line[256], *fname_c;
110 TO_C_STR1(fname, fname_c);
112 in = fopen(fname_c,
"r");
118 while (fgets(line, 256,
in)) {
120 if (strncasecmp(
"Variable", line, 8) == 0) {
149 if (strncasecmp(
"Type", line, 4) == 0)
152 if (strncasecmp(
"Default", line, 7) == 0)
155 if (strncasecmp(
"Section", line, 7) == 0) {
157 for (; *
s !=
'\0' && isspace(*
s);
s++)
162 if (strncasecmp(
"Description", line, 11) == 0) {
170 if (strncasecmp(
"Option", line, 6) == 0) {
171 char *
name, *value, *
s;
196void FC_FUNC_(varinfo_end, VARINFO_END)() {
231void FC_FUNC_(varinfo_getvar, VARINFO_GETVAR)(STR_F_TYPE
const name,
236 TO_C_STR1(
name, name_c);
237 for (lvar =
vars; (lvar != NULL) && (strcasecmp(name_c, lvar->
name) != 0);
246void FC_FUNC_(varinfo_getinfo, VARINFO_GETINFO)(
const var_type **var,
257 *
name = (*var)->name;
258 *
type = (*var)->type;
261 *
desc = (*var)->desc;
266void FC_FUNC_(varinfo_getopt, VARINFO_GETOPT)(
const var_type **var,
270 else if (*
opt == NULL)
278void FC_FUNC_(varinfo_opt_getinfo,
286 *
name = (*opt)->name;
287 *
desc = (*opt)->desc;
289 if (strncmp(
"bit", (*opt)->value, 3) == 0) {
290 *value = ((
int64_t)1) << strtoll((*opt)->value + 4, NULL, 10);
292 *value = strtoll((*opt)->value, NULL, 10);
314 for (lvar =
vars; (lvar != NULL) && (strcasecmp(var_name, lvar->
name) != 0);
317 return (lvar != NULL);
320void FC_FUNC_(varinfo_search_var, VARINFO_SEARCH_VAR)(
const STR_F_TYPE
name,
330 TO_C_STR1(
name, name_c);
331 for (; (lvar != NULL) && (strcasestr(lvar->
name, name_c) == 0);
339void FC_FUNC_(varinfo_search_option,
340 VARINFO_SEARCH_OPTION)(
const var_type **var,
341 const STR_F_TYPE
name,
int *value,
342 int *ierr STR_ARG1) {
346 TO_C_STR1(
name, name_c);
351 while (
opt != NULL) {
352 if (strcmp(
opt->name, name_c) == 0) {
353 *value = atoi(
opt->value);
354 printf(
"%s|%s|\n",
opt->name, name_c);
real(real64) function s()
int varinfo_variable_exists(const char *var_name)
char * get_token(char *s, char **dest)
int fclose(FILE *__stream)
void get_text(FILE *in, char **dest)