Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for libcfg+/src/cfg+.c between version 1.5 and 1.6

version 1.5, 2001/10/16 18:22:16 version 1.6, 2001/10/23 00:05:18
Line 3 
Line 3 
 #include <string.h>  #include <string.h>
   
 #include "str/strdyn.h"  #include "str/strdyn.h"
   #include "str/strplus.h"
 #include "cfg.h"  #include "cfg.h"
   
   #include "cfg_parse.c"
   
 static char *default_cmdline_stop_str[2] = { "--", NULL };  static char *default_cmdline_stop_str[2] = { "--", NULL };
 static char *default_cfgfile_stop_str[2] = { "[", NULL };  static char *default_cfgfile_stop_str[2] = { "[", NULL };
 static char *default_cfgfile_comment_str[3] = { "#", ";", NULL };  static char *default_cfgfile_comment_str[3] = { "#", ";", NULL };
Line 53  CFG_CONTEXT cfg_get_context(
Line 56  CFG_CONTEXT cfg_get_context(
            )             )
                 return NULL;                  return NULL;
   
           con->options = options;
   
         return con;          return con;
 }  }
   
Line 101  void cfg_set_cmdline_context(
Line 106  void cfg_set_cmdline_context(
   
         con->argc = argc;          con->argc = argc;
         con->argv = argv;          con->argv = argv;
   
           con->cur_idx = con->flags & CFG_PROCESS_FIRST ? 0 : 1;
 }  }
   
 void cfg_set_cfgfile_context(  void cfg_set_cfgfile_context(
Line 130  void cfg_free_context(
Line 137  void cfg_free_context(
         cfg_clear_cmdline_option_arg_separator(con);          cfg_clear_cmdline_option_arg_separator(con);
         cfg_clear_cfgfile_option_arg_separator(con);          cfg_clear_cfgfile_option_arg_separator(con);
   
           free_currents(con);
   
         free((void *) con);          free((void *) con);
 }  }
   
Line 138  void cfg_free_context(
Line 147  void cfg_free_context(
 int main(int argc, char **argv) {  int main(int argc, char **argv) {
   
         CFG_CONTEXT con;          CFG_CONTEXT con;
         int nice;          int o_nice = 20, o_verbose = 0, ret;
   
         struct cfg_option options[] = {          struct cfg_option options[] = {
                 { "nice", 'n', "nice", CFG_INT, (void *) &nice, 0 },                  { "nice", 'n', "nice", CFG_INT, (void *) &o_nice, 0 },
                   { "verbose", 'v', "verbose", CFG_BOOLEAN, (void *) &o_verbose, 0 },
                 CFG_END_OF_LIST                  CFG_END_OF_LIST
         };          };
   
         con = cfg_get_cmdline_context(argc, argv, options);          con = cfg_get_cmdline_context(argc, argv, options);
   
         puts("x");          while ((ret = cfg_get_next_opt(con)) > 0) {
           }
   
           switch (ret) {
                   case CFG_ERROR_INTERNAL:
                           puts("Command line parsing internal error.");
                           break;
                   case CFG_ERROR_NOMEM:
                           puts("Not enough memory for command line parsing.");
                           break;
                   case CFG_ERROR_NOTALLOWEDARG:
                           puts("Option has not allowed an argument.");
                           break;
                   case CFG_ERROR_BADNUMBER:
                           puts("Bad argument number.");
                           break;
                   case CFG_ERROR_OVERFLOW:
                           puts("Argument overflow.");
                           break;
                   case CFG_ERROR_UNKNOWN:
                           puts("Unknown option.");
                           break;
                   case CFG_OK:
                           puts("All OK.");
                           break;
           }
   
         cfg_free_context(con);          cfg_free_context(con);
   
           printf("o_verbose = %d, o_nice = %d\n", o_verbose, o_nice);
   
         return 0;          return 0;
 }  }
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top