Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Sobota, 17. október 2026

Rozdiely pre libcfg+/src/cfg+.c medzi verziami 1.13 a 1.14

verzia 1.13, 2001/12/01 01:27:47 verzia 1.14, 2001/12/05 23:58:48
Riadok 25  CFG_CONTEXT cfg_get_context(struct cfg_o
Riadok 25  CFG_CONTEXT cfg_get_context(struct cfg_o
                 return NULL;                  return NULL;
   
         memset(con, '\0', sizeof(*con));          memset(con, '\0', sizeof(*con));
           con->type = CFG_NO_CONTEXT;
   
         con->line_stop_str = strdyn_create_ar(default_line_stop_str);          con->line_stop_str = strdyn_create_ar(default_line_stop_str);
         con->file_stop_str = strdyn_create_ar(default_file_stop_str);          con->file_stop_str = strdyn_create_ar(default_file_stop_str);
Riadok 38  CFG_CONTEXT cfg_get_context(struct cfg_o
Riadok 39  CFG_CONTEXT cfg_get_context(struct cfg_o
                 strdyn_create_ar(default_file_option_arg_separator);                  strdyn_create_ar(default_file_option_arg_separator);
   
         if (con->line_stop_str == NULL          if (con->line_stop_str == NULL
                                                         || con->file_stop_str == NULL                          || con->file_stop_str == NULL
                                                         || con->comment_str == NULL                          || con->comment_str == NULL
                                                         || con->short_option_prefix == NULL                          || con->short_option_prefix == NULL
                                                         || con->long_option_prefix == NULL                          || con->long_option_prefix == NULL
                                                         || con->line_option_arg_separator == NULL                          || con->line_option_arg_separator == NULL
                                                         || con->file_option_arg_separator == NULL                          || con->file_option_arg_separator == NULL
            )             )
                 return NULL;                  return NULL;
   
Riadok 53  CFG_CONTEXT cfg_get_context(struct cfg_o
Riadok 54  CFG_CONTEXT cfg_get_context(struct cfg_o
 }  }
   
 CFG_CONTEXT cfg_get_cmdline_context(  CFG_CONTEXT cfg_get_cmdline_context(
                                                 int argc,                  int argc,
                                                 char **argv,                  char **argv,
                                                 struct cfg_option *options                  struct cfg_option *options
                                                 )                  )
 {  {
         CFG_CONTEXT con;          CFG_CONTEXT con;
   
Riadok 70  CFG_CONTEXT cfg_get_cmdline_context(
Riadok 71  CFG_CONTEXT cfg_get_cmdline_context(
 }  }
   
 CFG_CONTEXT cfg_get_cfgfile_context(  CFG_CONTEXT cfg_get_cfgfile_context(
                                                 int begin_pos,                  long begin_pos,
                                                 int end_pos,                  long end_pos,
                                                 char *filename,                  char *filename,
                                                 struct cfg_option *options                  struct cfg_option *options
                                                 )                  )
 {  {
         CFG_CONTEXT con;          CFG_CONTEXT con;
   
Riadok 88  CFG_CONTEXT cfg_get_cfgfile_context(
Riadok 89  CFG_CONTEXT cfg_get_cfgfile_context(
 }  }
   
 void cfg_set_cmdline_context(  void cfg_set_cmdline_context(
                                                 const CFG_CONTEXT con,                  const CFG_CONTEXT con,
                                                 int argc,                  int argc,
                                                 char **argv                  char **argv
                                                 )                  )
 {  {
         con->type = CFG_CMDLINE;          con->type = CFG_CMDLINE;
   
Riadok 105  void cfg_set_cmdline_context(
Riadok 106  void cfg_set_cmdline_context(
 }  }
   
 void cfg_set_cfgfile_context(  void cfg_set_cfgfile_context(
                                                 const CFG_CONTEXT con,                  const CFG_CONTEXT con,
                                                 int begin_pos,                  long begin_pos,
                                                 int end_pos,                  long end_pos,
                                                 char *filename                  char *filename
                                                 )                  )
 {  {
         con->type = CFG_CFGFILE;          con->type = CFG_CFGFILE;
   
         con->begin_pos = begin_pos;          con->begin_pos = begin_pos;
         con->end_pos = end_pos;          con->end_pos = end_pos;
         con->filename = (char *) filename;          con->filename = (char *) filename;
   
           con->fhandle = NULL;
 }  }
   
 void cfg_free_context(const CFG_CONTEXT con)  void cfg_free_context(const CFG_CONTEXT con)
Riadok 143  void cfg_free_context(const CFG_CONTEXT
Riadok 146  void cfg_free_context(const CFG_CONTEXT
         if (con->cur_arg != NULL)          if (con->cur_arg != NULL)
                 free(con->cur_arg);                  free(con->cur_arg);
   
         con->cur_opt_type = CFG_NONE_OPTION;  
         con->cur_opt = con->cur_arg = NULL;          con->cur_opt = con->cur_arg = NULL;
           con->cur_opt_type = CFG_NONE_OPTION;
   
   
           if (con->fhandle != NULL)
                   fclose(con->fhandle);
   
           con->fhandle = NULL;
           con->filename = NULL;
   
           con->type = CFG_NO_CONTEXT;
   
         free((void *) con);          free((void *) con);
 }  }
Riadok 158  int main(int argc, char **argv)
Riadok 170  int main(int argc, char **argv)
         int ret;          int ret;
   
         int o_nice = 20, o_verbose = 0;          int o_nice = 20, o_verbose = 0;
           char *o_cfgfile = NULL;
         char **o_name = NULL, **o_string = NULL, **o_leftover = NULL;          char **o_name = NULL, **o_string = NULL, **o_leftover = NULL;
         int o_boolean = 0;          int o_boolean = 0;
         int o_int = -33, **o_multi_int = NULL;          int o_int = -33, **o_multi_int = NULL;
Riadok 172  int main(int argc, char **argv)
Riadok 185  int main(int argc, char **argv)
                 { "nice", 'n', "nice", CFG_INT, (void *) &o_nice, 0 },                  { "nice", 'n', "nice", CFG_INT, (void *) &o_nice, 0 },
                 { "verbose", 'v', "verbose", CFG_BOOLEAN + CFG_MULTI, (void *) &o_verbose, 0 },                  { "verbose", 'v', "verbose", CFG_BOOLEAN + CFG_MULTI, (void *) &o_verbose, 0 },
                 { "name", 'a', "name", CFG_STRING + CFG_MULTI_SEPARATED, (void *) &o_name, 0 },                  { "name", 'a', "name", CFG_STRING + CFG_MULTI_SEPARATED, (void *) &o_name, 0 },
                   { "config-file", 'f', NULL, CFG_STRING, (void *) &o_cfgfile, 0 },
   
                 { "bool", 'b', "boolean", CFG_BOOLEAN, (void *) &o_boolean, 1 },                  { "bool", 'b', "boolean", CFG_BOOLEAN, (void *) &o_boolean, 1 },
                 { "int", 'i', "int", CFG_INT, (void *) &o_int, 0 },                  { "int", 'i', "int", CFG_INT, (void *) &o_int, 0 },
Riadok 195  int main(int argc, char **argv)
Riadok 209  int main(int argc, char **argv)
   
         while ((ret = cfg_get_next_opt(con)) > 0) {          while ((ret = cfg_get_next_opt(con)) > 0) {
                 printf("ret = %d, opt = '%s', arg = '%s', idx = %d, argv[idx] = '%s'\n",                  printf("ret = %d, opt = '%s', arg = '%s', idx = %d, argv[idx] = '%s'\n",
                                                                 ret,                                  ret,
                                                                 cfg_get_cur_opt(con),                                  cfg_get_cur_opt(con),
                                                                 cfg_get_cur_arg(con),                                  cfg_get_cur_arg(con),
                                                                 cfg_get_cur_idx(con),                                  cfg_get_cur_idx(con),
                                                                 argv[cfg_get_cur_idx(con)]);                                  argv[cfg_get_cur_idx(con)]);
         }          }
   
         fputs("***** ", stdout);          fputs("***** ", stdout);
Riadok 242  int main(int argc, char **argv)
Riadok 256  int main(int argc, char **argv)
   
         if (ret != CFG_OK)          if (ret != CFG_OK)
                 printf("***** opt = '%s', arg = '%s', idx = %d, argv[idx] = '%s'\n",                  printf("***** opt = '%s', arg = '%s', idx = %d, argv[idx] = '%s'\n",
                                                                 cfg_get_cur_opt(con),                                  cfg_get_cur_opt(con),
                                                                 cfg_get_cur_arg(con),                                  cfg_get_cur_arg(con),
                                                                 cfg_get_cur_idx(con),                                  cfg_get_cur_idx(con),
                                                                 argv[cfg_get_cur_idx(con)]);                                  argv[cfg_get_cur_idx(con)]);
   
   
         cfg_free_context(con);          cfg_free_context(con);
Riadok 353  int main(int argc, char **argv)
Riadok 367  int main(int argc, char **argv)
                         puts("o_leftover uninitialized");                          puts("o_leftover uninitialized");
         }          }
   
           if (o_cfgfile != NULL) {
                   con = cfg_get_cfgfile_context(0, 0, o_cfgfile, options);
   
                   while ((ret = cfg_get_next_opt(con)) > 0) {
                           /*
                              printf("ret = %d, opt = '%s', arg = '%s', idx = %d, argv[idx] = '%s'\n",
                              ret,
                              cfg_get_cur_opt(con),
                              cfg_get_cur_arg(con),
                              cfg_get_cur_idx(con),
                              argv[cfg_get_cur_idx(con)]);
                            */
                   }
   
                   printf("error %d\n", ret);
   
                   cfg_free_context(con);
           }
   
   
         return 0;          return 0;
 }  }

Legend:
Odstranené z verzie1.13  
zmenené riadky
  Pridané vo verzii1.14

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok