void read_next_option(STREAM *file, TODOLIST *list) { char c; char *key = NULL; char *value = NULL; while (1) { skip_horizontal_whitespace(file); key = read_option_string(file); if (key[0] == '\0') { free(key); skip_line(file); return; } skip_horizontal_whitespace(file); c = stream_getc(file); if (c != '=') { stream_ungetc(c, file); set_option_bit(list, key, 1); continue; } skip_horizontal_whitespace(file); value = read_option_string(file); set_option(list, key, value); free(key); free(value); } }
double read_option_double(int argc,char *argv[], char *option_f, char *no_option_argument, double default_value,short print) { /* * \author Emanuele Cordano * \date July 2008 * *\param (int) - argc *\param (char *) - argv *\param (char *) - option_f - a string related to the flag which can appear in the command *\param (char *) - no_option_f - a string returned by the routine in case of MISSING option_field *\param (double)- default_value - the DOUBKLE value applied if option_f is missing *\param (short) - print * *\return Return the double value followed by the the string option_f in the command line * */ int s; double d; char *argument; argument=read_option_string(argc,argv,option_f,no_option_argument,print); s=sscanf(argument,"%lf",&d); if (s==0 && print==1) { printf("\nWARNING: No real value found for %s option, the default value %lf is set ",option_f,default_value); free(argument); return default_value; } // d=default_value; free(argument); return d; }