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

Diff for libcfg+/src/cfg+.c between version 1.46 and 1.47

version 1.46, 2002/07/15 17:02:37 version 1.47, 2002/07/16 13:42:11
Line 80  cfg_get_context(options)
Line 80  cfg_get_context(options)
 } /* }}} */  } /* }}} */
   
         CFG_CONTEXT          CFG_CONTEXT
 cfg_get_cmdline_context(begin_pos, end_pos, argv, options)  cfg_get_cmdline_context(begin_pos, size, argv, options)
         long              begin_pos;          long              begin_pos;
         long              end_pos;          long              size;
         char              **argv;          char              **argv;
         struct cfg_option *options;          struct cfg_option *options;
 { /* {{{ */  { /* {{{ */
Line 92  cfg_get_cmdline_context(begin_pos, end_p
Line 92  cfg_get_cmdline_context(begin_pos, end_p
         if (con == NULL)          if (con == NULL)
                 return NULL;                  return NULL;
   
         cfg_set_cmdline_context(con, begin_pos, end_pos, argv);          cfg_set_cmdline_context(con, begin_pos, size, argv);
   
         return con;          return con;
 } /* }}} */  } /* }}} */
   
         CFG_CONTEXT          CFG_CONTEXT
 cfg_get_cfgfile_context(begin_pos, end_pos, filename, options)  cfg_get_cfgfile_context(begin_pos, size, filename, options)
         long              begin_pos;          long              begin_pos;
         long              end_pos;          long              size;
         char              *filename;          char              *filename;
         struct cfg_option *options;          struct cfg_option *options;
 { /* {{{ */  { /* {{{ */
Line 110  cfg_get_cfgfile_context(begin_pos, end_p
Line 110  cfg_get_cfgfile_context(begin_pos, end_p
         if (con == NULL)          if (con == NULL)
                 return NULL;                  return NULL;
   
         cfg_set_cfgfile_context(con, begin_pos, end_pos, filename);          cfg_set_cfgfile_context(con, begin_pos, size, filename);
   
         return con;          return con;
 } /* }}} */  } /* }}} */
   
         void          void
 cfg_set_cmdline_context(con, begin_pos, end_pos, argv)  cfg_set_cmdline_context(con, begin_pos, size, argv)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
         long              begin_pos;          long              begin_pos;
         long              end_pos;          long              size;
         char              **argv;          char              **argv;
 { /* {{{ */  { /* {{{ */
         cfg_reset_context(con);          cfg_reset_context(con);
   
         con->type      = CFG_CMDLINE;          con->type      = CFG_CMDLINE;
         con->begin_pos = begin_pos;          con->begin_pos = begin_pos;
         con->end_pos   = end_pos;          con->size      = size;
         con->argv      = argv;          con->argv      = argv;
   
         /* TODO: init also by con->begin_pos property */          /* TODO: move this stuff to particular parsing function */
         con->cur_idx      = 0;          /* con->cur_idx      = 0;
         con->cur_idx_tmp  = 0;          con->cur_idx_tmp  = 0;
         con->cur_idx_tmp += con->flags & CFG_PROCESS_FIRST ? 0 : 1;          con->cur_idx_tmp += con->begin_pos; */
         con->cur_idx_tmp += con->begin_pos;  
 } /* }}} */  } /* }}} */
   
         void          void
 cfg_set_cfgfile_context(con, begin_pos, end_pos, filename)  cfg_set_cfgfile_context(con, begin_pos, size, filename)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
         long              begin_pos;          long              begin_pos;
         long              end_pos;          long              size;
         char              *filename;          char              *filename;
 { /* {{{ */  { /* {{{ */
         cfg_reset_context(con);          cfg_reset_context(con);
   
           /* What is this for?! */
         /*          /*
            if (filename == NULL) {             if (filename == NULL) {
            if (begin_pos > 0 && con->fhandle != NULL)             if (begin_pos > 0 && con->fhandle != NULL)
Line 154  cfg_set_cfgfile_context(con, begin_pos,
Line 154  cfg_set_cfgfile_context(con, begin_pos,
   
         con->type      = CFG_CFGFILE;          con->type      = CFG_CFGFILE;
         con->begin_pos = begin_pos;          con->begin_pos = begin_pos;
         con->end_pos   = end_pos;          con->size      = size;
   
         /* TODO: filename copying? (if yes than don't forget memory freeing) */          /* TODO: filename copying? (if yes than don't forget memory freeing) */
         if (filename != NULL)          if (filename != NULL)
Line 167  cfg_set_cfgfile_context(con, begin_pos,
Line 167  cfg_set_cfgfile_context(con, begin_pos,
 cfg_reset_context(con)  cfg_reset_context(con)
         const CFG_CONTEXT con;          const CFG_CONTEXT con;
 { /* {{{ */  { /* {{{ */
         con->error_code  = CFG_OK;          con->error_code      = CFG_OK;
         con->cur_idx     = 0;          con->cur_idx         = 0;
         con->cur_idx_tmp = 0;          con->cur_idx_tmp     = 0;
           con->parsing_started = 0;
   
         if (con->used_opt_idx != NULL) {          if (con->used_opt_idx != NULL) {
                 free(con->used_opt_idx);                  free(con->used_opt_idx);
Line 193  cfg_free_context(con)
Line 194  cfg_free_context(con)
   
         cfg_reset_context(con);          cfg_reset_context(con);
   
         for (i = 0; i < CFG_N_PROPS; i++)          for (i = 0; i < CFG_N_PROPS; i++) {
                 cfg_clear_property(con, i);  #if 0
                   (void) cfg_clear_property(con, i);
                   free(con->prop[i]);
   #else
                   strdyn_free(con->prop[i]);
   #endif
                   con->prop[i] = NULL;
           }
   
         /* con->argc = 0; */  
         con->begin_pos = 0;          con->begin_pos = 0;
         con->end_pos   = 0;          con->size      = 0;
           con->argv      = NULL;
         con->argv = NULL;  
         con->filename  = NULL;          con->filename  = NULL;
         con->type = CFG_NO_CONTEXT;          con->type      = CFG_NO_CONTEXT;
   
         free((void *) con);          free((void *) con);
 } /* }}} */  } /* }}} */
Line 243  cfg_get_error_str(con)
Line 249  cfg_get_error_str(con)
         char *str_opt   = cfg_get_cur_opt(con);          char *str_opt   = cfg_get_cur_opt(con);
         char *str_arg   = cfg_get_cur_arg(con);          char *str_arg   = cfg_get_cur_arg(con);
         char *str_filename = con->filename;          char *str_filename = con->filename;
         int idx = cfg_get_cur_idx(con);          int idx = cfg_get_cur_idx(con) + 1;
         int size;          int size;
   
         /*  
            char *str_idx;  
            char tmp_buf[21];  
   
            if (con->type == CFG_LINE) {  
            str_idx = con->argv[cfg_get_cur_idx(con)];  
            }  
            else {  
            sprintf(str_idx, "%.20s", cfg_get_cur_idx(con))  
            }  
            */  
         str_opt = str_opt == NULL ? "" : str_opt;          str_opt = str_opt == NULL ? "" : str_opt;
         str_arg = str_arg == NULL ? "" : str_arg;          str_arg = str_arg == NULL ? "" : str_arg;
         str_filename = str_filename == NULL ? "" : str_filename;          str_filename = str_filename == NULL ? "" : str_filename;
Line 265  cfg_get_error_str(con)
Line 260  cfg_get_error_str(con)
            must be enough to cover str_type, str_pos, str_idx and the rest             must be enough to cover str_type, str_pos, str_idx and the rest
            of error message with deliminators. */             of error message with deliminators. */
   
 #ifndef max /* Borrowed from libplaton. */  #ifndef max /* Borrowed from libplaton */
 #define max(a, b) (((a) > (b)) ? (a) : (b))  #define max(a, b) (((a) > (b)) ? (a) : (b))
 #endif  #endif
   
Line 342  cfg_get_error_str(con)
Line 337  cfg_get_error_str(con)
                         break;                          break;
   
                 case CFG_ERROR_SEEK_ERROR:                  case CFG_ERROR_SEEK_ERROR:
                         sprintf(s, "seek error in config file '%s'", str_filename);                          sprintf(s, "seek error in %s", str_type);
                         break;                          break;
   
                 case CFG_ERROR_INTERNAL:                  case CFG_ERROR_INTERNAL:

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

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