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 ep/src/conf.c between version 1.32 and 1.33

version 1.32, 2002/07/15 19:04:40 version 1.33, 2002/07/17 01:45:34
Line 5 
Line 5 
  * ____________________________________________________________   * ____________________________________________________________
  *   *
  * Developed by Ondrej Jombik <nepto@pobox.sk>   * Developed by Ondrej Jombik <nepto@pobox.sk>
  *          and Lubomir Host <rajo@host.sk>  *          and Lubomir Host <rajo@host.sk>
  * Copyright (c) 2000-2002 Platon SDG, http://www.platon.sk/   * Copyright (c) 2000-2002 Platon SDG, http://www.platon.sk/
  * All rights reserved.   * All rights reserved.
  *   *
Line 371  conf_cfgfile_parse(filename, global, pro
Line 371  conf_cfgfile_parse(filename, global, pro
         cfg_reset_context(global_context);          cfg_reset_context(global_context);
         cfg_reset_context(process_context);          cfg_reset_context(process_context);
   
         cfg_set_cfgfile_context(global_context, 0, 0, filename);          /* Start at first line (0) and parse to end (-1) */
         cfg_set_cfgfile_context(process_context, 0, 0, filename);          cfg_set_cfgfile_context(global_context, 0, -1, filename);
           cfg_set_cfgfile_context(process_context, 0, -1, filename);
   
         for (cur_context = global_context; ; ) {          for (cur_context = global_context; ; ) {
   
Line 386  conf_cfgfile_parse(filename, global, pro
Line 387  conf_cfgfile_parse(filename, global, pro
 #endif  #endif
                         break;                          break;
                 }                  }
                 else {                  else { /* Section boundaries detected */
                         register int   section_no;                          register int   section_no;
                         register char *section_str;                          register char *section_str;
   
Line 408  conf_cfgfile_parse(filename, global, pro
Line 409  conf_cfgfile_parse(filename, global, pro
                                         clear_process_cfg();                                          clear_process_cfg();
                                 }                                  }
   
                                   /* If section name is correct, set appropriate context and
                                      continue with parsing on next line (it is that '+ 1'). */
   
                                 if (section_no == 1) { /* [Global] section */                                  if (section_no == 1) { /* [Global] section */
                                         cfg_set_cfgfile_context(global_context,                                          cfg_set_cfgfile_context(global_context,
                                                         cfg_get_cur_idx(cur_context), 0, NULL);                                                          cfg_get_cur_idx(cur_context) + 1, -1, NULL);
                                         cur_context = global_context;                                          cur_context = global_context;
                                 }                                  }
                                 else { /* [Process] section */                                  else { /* [Process] section */
                                         cfg_set_cfgfile_context(process_context,                                          cfg_set_cfgfile_context(process_context,
                                                         cfg_get_cur_idx(cur_context), 0, NULL);                                                          cfg_get_cur_idx(cur_context) + 1, -1, NULL);
                                         cur_context = process_context;                                          cur_context = process_context;
                                 }                                  }
                         }                          }
                         else {                          else {
                                 msg_error_print("unknown section '%s' in config file '%s'\n",                                  msg_error_print("unknown section '%s' in config file '%s'\n",
                                                 section_str, filename);                                                  section_str, filename);
                                 ret = CFG_ERROR_STOP_STR; /* CFG_ERROR_UNKNOWN */                                  ret = CFG_ERROR_STOP_STR;
                                 cur_context = NULL;                                  cur_context = NULL;
                                 break;                                  break;
                         }                          }
Line 430  conf_cfgfile_parse(filename, global, pro
Line 434  conf_cfgfile_parse(filename, global, pro
         }          }
   
         /* Set returning parameters. */          /* Set returning parameters. */
         if (cur_context == process_context) {          if (ret == CFG_OK) {
                 if (! test_process_cfg_argv(filename))                  if (cur_context == process_context) {
                         ret = CFG_ERROR_STOP_STR;                          if (! test_process_cfg_argv(filename))
                 else if (! add_process_cfg_to_processes(processes, &processes_size))                                  ret = CFG_ERROR_STOP_STR;
                         return CFG_ERR_NOMEM;                          else if (! add_process_cfg_to_processes(processes, &processes_size))
                                   return CFG_ERR_NOMEM;
                   }
         }          }
   
         if (! add_global_cfg_to_global(global))          if (! add_global_cfg_to_global(global))
Line 474  conf_cmdline_parse(argc, argv, global, p
Line 480  conf_cmdline_parse(argc, argv, global, p
         cfg_reset_context(global_context);          cfg_reset_context(global_context);
         cfg_reset_context(process_context);          cfg_reset_context(process_context);
   
         cfg_set_cmdline_context_by_argc(global_context, argc, argv);          cfg_set_cmdline_context(global_context, 0, argc, argv);
         cfg_set_cmdline_context_by_argc(process_context, argc, argv);          cfg_set_cmdline_context(process_context, 0, argc, argv);
   
         /*          /*
          * Yokotasi intelligent parser. :-)           * Yokotasi intelligent parser. :-)
Line 487  conf_cmdline_parse(argc, argv, global, p
Line 493  conf_cmdline_parse(argc, argv, global, p
                 ret = cfg_parse(cur_context);                  ret = cfg_parse(cur_context);
   
                 if (ret < 0 && ret != CFG_ERR_STOP_STR_FOUND) {                  if (ret < 0 && ret != CFG_ERR_STOP_STR_FOUND) {
                         if (! first_loop) {                          if (! first_loop)
                                 /* TODO: better specification about error on command line */  
                                 /* print_cfg_error(cur_context, ret); */  
                                 /* msg_error_print("error on command line (error %d at %s)\n",  
                                    ret, argv[index + cfg_get_cur_idx(cur_context)]); */  
   
                                 break;                                  break;
                         }  
   
                         cur_context = global_context;                          cur_context = global_context;
                         /* not needed:                          /* not needed:
Line 504  conf_cmdline_parse(argc, argv, global, p
Line 504  conf_cmdline_parse(argc, argv, global, p
                 else if (ret == CFG_ERR_STOP_STR_FOUND) {                  else if (ret == CFG_ERR_STOP_STR_FOUND) {
                         register int cur_idx = cfg_get_cur_idx(cur_context);                          register int cur_idx = cfg_get_cur_idx(cur_context);
   
                         if ((cur_idx < 1 && ! first_loop) || index + cur_idx + 1 >= argc) {                          if (cur_idx - index < 1 && ! first_loop) {
                                 msg_error_print("misplaced process separator '--'"                                  msg_error_print("double process separator '--'"
                                                 " on command line\n");                                                  " on command line\n");
                                 break;                                  break;
                         }                          }
   
                           if (cur_idx + 1 >= argc) {
                                   msg_error_print("misplaced process separator '--'"
                                                   " at the end of command line\n");
                                   break;
                           }
   
                         if (cur_context == process_context) {                          if (cur_context == process_context) {
                                 if (first_loop && process_cfg.argv == NULL)                                  if (first_loop && process_cfg.argv == NULL) {
                                         ; /* empty global options (./ep -- ...) are allowed */                                          /* empty global options (./ep -- ...) are allowed */
                                   }
                                 else {                                  else {
                                         if (! test_process_cfg_argv(NULL)) {                                          if (! test_process_cfg_argv(NULL)) {
                                                 ret = CFG_ERROR_STOP_STR;                                                  ret = CFG_ERROR_STOP_STR;
                                                 break;                                                  break;
                                         }                                          }
   
                                         /* Adding to processes array */                                          /* Adding to processes array */
                                 if (! add_process_cfg_to_processes(processes, &processes_size))                                          if (! add_process_cfg_to_processes(processes,
                                                                   &processes_size))
                                                 return CFG_ERR_NOMEM;                                                  return CFG_ERR_NOMEM;
   
                                 }                                  }
Line 527  conf_cmdline_parse(argc, argv, global, p
Line 536  conf_cmdline_parse(argc, argv, global, p
                                 clear_process_cfg();                                  clear_process_cfg();
                         }                          }
   
                         index += cur_idx + 1;                          index = cur_idx + 1;
                         cur_context = process_context;                          cur_context = process_context;
                         cfg_set_cmdline_context_by_argc(cur_context,                          cfg_set_cmdline_context(cur_context, index, argc - index, argv);
                                         argc - index, argv + index);  
                 }                  }
                 else { /* ret == CFG_OK */                  else { /* ret == CFG_OK */
                         break;                          break;
Line 589  print_cfg_error(con)
Line 597  print_cfg_error(con)
 test_process_cfg_argv(config_filename)  test_process_cfg_argv(config_filename)
         const char *config_filename;          const char *config_filename;
 { /* {{{ */  { /* {{{ */
         /* TODO: print ->name[0] if specified, "some process" otherwise */  
         if (process_cfg.argv == NULL) {          if (process_cfg.argv == NULL) {
 #if 0  
                 char *name0 = process_cfg.name == NULL                  if (process_cfg.name != NULL && process_cfg.name[0]) {
                         || process_cfg.name[0] == NULL                          /* At least one process name is defined in this case */
                         || strlen(process_cfg.name[0]) <= 0                          if (config_filename != NULL)
                         ? process_cfg.name[0] : NULL;                                  msg_error_print("process '%s' has not"
 #endif                                                  " 'command' clausule in config file '%s'\n",
                 if (config_filename != NULL) {                                                  process_cfg.name[0],
                         msg_error_print("some process doesn't have specified"                                                  config_filename);
                                         " what to run in config file '%s'\n",                          else
                                         config_filename);                                  msg_error_print("process '%s' has not specified"
                                                   " what to run on command line\n",
                                                   process_cfg.name[0]);
                 }                  }
                 else {                  else {
                         msg_error_print("some process doesn't have specified"                          /* No process name is defined in this case */
                                         " what to run on command line\n");                          if (config_filename != NULL)
                                   msg_error_print("some process has not"
                                                   " 'command' clausule in config file '%s'\n",
                                                   config_filename);
                           else
                                   msg_error_print("some process has not specified"
                                                   " what to run on command line\n");
                 }                  }
   
                 return 0;                  return 0;
Line 658  check_context(context, options)
Line 673  check_context(context, options)
                 if ((*context = cfg_get_context(options)) == NULL)                  if ((*context = cfg_get_context(options)) == NULL)
                         return 0;                          return 0;
   
                 cfg_set_context_flags(*context, CFG_PROCESS_FIRST);                  cfg_set_context_flag(*context, CFG_PROCESS_FIRST);
                   cfg_clear_context_flag(*context, CFG_SKIP_FIRST);
                   cfg_set_context_flag(*context, CFG_FILE_LINE_POS_USAGE);
   
                 /* TODO: one call for multi vals properties */                  /* TODO: one call for multi vals properties */
                 cfg_clear_property(*context, CFG_LINE_STOP_STRING);                  cfg_clear_property(*context, CFG_LINE_STOP_STRING);

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

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