66 #define __FUNC__ "Parser_dhCreate"
85 ptr->value = (
char *)
MALLOC_DH (6 *
sizeof (
char));
87 strcpy (ptr->name,
"JUNK");
88 strcpy (ptr->value,
"JUNK");
92 #define __FUNC__ "Parser_dhDestroy"
107 while (ptr1 != NULL);
114 #define __FUNC__ "Parser_dhUpdateFromFile"
121 if ((fp = fopen (filename,
"r")) == NULL)
123 sprintf (
msgBuf_dh,
"can't open >>%s<< for reading", filename);
128 sprintf (
msgBuf_dh,
"updating parser from file: >>%s<<", filename);
132 if (fgets (line, 80, fp) == NULL)
136 if (sscanf (line,
"%s %s", name, value) != 2)
146 #define __FUNC__ "Parser_dhInit"
163 for (j = 1; j < argc; ++j)
165 if (strcmp (argv[j],
"-db_filename") == 0)
181 if (argv[i][0] ==
'-')
183 char value[] = {
"1" };
185 if (i + 1 < argc && argv[i + 1][0] ==
'-'
186 && argv[i + 1][1] ==
'-')
191 if ((i + 1 == argc || argv[i + 1][0] ==
'-') && !flag)
211 #define __FUNC__ "Parser_dhHasSwitch"
218 if (p != NULL &&
find (p, s, &node))
220 if (!strcmp (node->
value,
"0"))
224 else if (!strcmp (node->
value,
"false"))
228 else if (!strcmp (node->
value,
"False"))
232 else if (!strcmp (node->
value,
"FALSE"))
247 #define __FUNC__ "Parser_dhReadInt"
254 if (p != NULL &&
find (p, in, &node))
256 *out = atoi (node->
value);
257 if (!strcmp (node->
value,
"0"))
270 #define __FUNC__ "Parser_dhReadDouble"
277 if (p != NULL &&
find (p, in, &node))
279 *out = atof (node->
value);
285 #define __FUNC__ "Parser_dhReadString"
292 if (p != NULL &&
find (p, in, &node))
301 #define __FUNC__ "Parser_dhPrint"
312 fprintf (fp,
"------------------------ registered options:\n");
315 fprintf (fp,
"Parser object is invalid; nothing to print!\n");
322 fprintf (fp,
" %s %s\n", ptr->name, ptr->value);
333 #define __FUNC__ "Parser_dhInsert"
341 goto PARSER_NOT_INITED;
344 if (
find (p, option, &node))
346 int length2 = strlen (node->value) + 1;
347 length = strlen (value) + 1;
348 if (length2 < length)
351 node->value = (
char *)
MALLOC_DH (length *
sizeof (
char));
354 strcpy (node->value, value);
363 length = strlen (option) + 1;
364 node->name = (
char *)
MALLOC_DH (length *
sizeof (
char));
366 strcpy (node->name, option);
367 length = strlen (value) + 1;
368 node->value = (
char *)
MALLOC_DH (length *
sizeof (
char));
370 strcpy (node->value, value);
380 #define __FUNC__ "find"
385 bool foundit =
false;
386 while (tmpPtr != NULL)
388 if (strcmp (tmpPtr->name, option) == 0)
394 tmpPtr = tmpPtr->
next;
400 #define __FUNC__ "init_from_default_settings_private"
void Parser_dhCreate(Parser_dh *p)
static void init_from_default_settings_private(Parser_dh p)
void Parser_dhUpdateFromFile(Parser_dh p, char *filename)
bool Parser_dhHasSwitch(Parser_dh p, char *s)
void Parser_dhPrint(Parser_dh p, FILE *fp, bool allPrint)
void Parser_dhInsert(Parser_dh p, char *option, char *value)
bool Parser_dhReadDouble(Parser_dh p, char *in, double *out)
bool Parser_dhReadInt(Parser_dh p, char *in, int *out)
void Parser_dhDestroy(Parser_dh p)
void Parser_dhInit(Parser_dh p, int argc, char *argv[])
bool Parser_dhReadString(Parser_dh p, char *in, char **out)
#define END_FUNC_VAL_2(retval)
char msgBuf_dh[MSG_BUF_SIZE_DH]
static bool find(Parser_dh p, char *option, OptionsNode **ptr)