Changeset 41f82c


Ignore:
Timestamp:
Jul 10, 2012, 1:15:50 PM (13 years ago)
Author:
Frederik Heber <heber@…>
Children:
3cb97b
Parents:
3d4397
git-author:
Frederik Heber <heber@…> (07/06/12 18:54:01)
git-committer:
Frederik Heber <heber@…> (07/10/12 13:15:50)
Message:

Extracted parsing input into keyvalue into own function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/bin/mpqc/mpqc.cc

    r3d4397 r41f82c  
    570570}
    571571
    572 int
    573 try_main(int argc, char *argv[])
    574 {
    575   //trash_stack();
    576 
    577   int i;
    578   const char *devnull = "/dev/null";
    579   atexit(clean_up);
    580 
    581 #ifdef HAVE_FEENABLEEXCEPT
    582   // this uses a glibc extension to trap on individual exceptions
    583 # ifdef FE_DIVBYZERO
    584   feenableexcept(FE_DIVBYZERO);
    585 # endif
    586 # ifdef FE_INVALID
    587   feenableexcept(FE_INVALID);
    588 # endif
    589 # ifdef FE_OVERFLOW
    590   feenableexcept(FE_OVERFLOW);
    591 # endif
    592 #endif
    593 
    594 #ifdef HAVE_FEDISABLEEXCEPT
    595   // this uses a glibc extension to not trap on individual exceptions
    596 # ifdef FE_UNDERFLOW
    597   fedisableexcept(FE_UNDERFLOW);
    598 # endif
    599 # ifdef FE_INEXACT
    600   fedisableexcept(FE_INEXACT);
    601 # endif
    602 #endif
    603 
    604 #if defined(HAVE_SETRLIMIT)
    605   struct rlimit rlim;
    606   rlim.rlim_cur = 0;
    607   rlim.rlim_max = 0;
    608   setrlimit(RLIMIT_CORE,&rlim);
    609 #endif
    610 
    611   ExEnv::init(argc, argv);
    612 
    613   // parse commandline options
    614   GetLongOpt options;
    615   int optind = ParseOptions(options, argc, argv);
    616   const char *output = 0;
    617   ostream *outstream = 0;
    618   ComputeOptions(options, output, outstream);
    619 
    620   // get the message group.  first try the commandline and environment
    621   Ref<MessageGrp> grp;
    622   getMessageGroup(grp, argc, argv);
    623 
    624   // get input file names, either object-oriented or generic
    625   const char *object_input = 0;
    626   const char *generic_input = 0;
    627   getInputFileNames(object_input, generic_input, options, argc, argv);
    628   const char *input;
    629   if (object_input) input = object_input;
    630   if (generic_input) input = generic_input;
    631 
    632   Ref<ParsedKeyVal> parsedkv;
     572/** Parse the input file into the key value container.
     573 *
     574 * \param grp message group
     575 * \param parsedkev keyvalue container
     576 * \param options options structure
     577 * \param input input file name
     578 * \param generic_input filename of generic input
     579 */
     580void parseInputfile(
     581    Ref<MessageGrp> &grp,
     582    Ref<ParsedKeyVal> &parsedkv,
     583    GetLongOpt &options,
     584    const char *&input,
     585    const char *&generic_input
     586    )
     587{
    633588  // read the input file on only node 0
    634589  char *in_char_array;
     
    685640    }
    686641  delete[] in_char_array;
    687 
     642}
     643
     644int
     645try_main(int argc, char *argv[])
     646{
     647  //trash_stack();
     648
     649  int i;
     650  const char *devnull = "/dev/null";
     651  atexit(clean_up);
     652
     653#ifdef HAVE_FEENABLEEXCEPT
     654  // this uses a glibc extension to trap on individual exceptions
     655# ifdef FE_DIVBYZERO
     656  feenableexcept(FE_DIVBYZERO);
     657# endif
     658# ifdef FE_INVALID
     659  feenableexcept(FE_INVALID);
     660# endif
     661# ifdef FE_OVERFLOW
     662  feenableexcept(FE_OVERFLOW);
     663# endif
     664#endif
     665
     666#ifdef HAVE_FEDISABLEEXCEPT
     667  // this uses a glibc extension to not trap on individual exceptions
     668# ifdef FE_UNDERFLOW
     669  fedisableexcept(FE_UNDERFLOW);
     670# endif
     671# ifdef FE_INEXACT
     672  fedisableexcept(FE_INEXACT);
     673# endif
     674#endif
     675
     676#if defined(HAVE_SETRLIMIT)
     677  struct rlimit rlim;
     678  rlim.rlim_cur = 0;
     679  rlim.rlim_max = 0;
     680  setrlimit(RLIMIT_CORE,&rlim);
     681#endif
     682
     683  ExEnv::init(argc, argv);
     684
     685  // parse commandline options
     686  GetLongOpt options;
     687  int optind = ParseOptions(options, argc, argv);
     688  const char *output = 0;
     689  ostream *outstream = 0;
     690  ComputeOptions(options, output, outstream);
     691
     692  // get the message group.  first try the commandline and environment
     693  Ref<MessageGrp> grp;
     694  getMessageGroup(grp, argc, argv);
     695
     696  // get input file names, either object-oriented or generic
     697  const char *object_input = 0;
     698  const char *generic_input = 0;
     699  getInputFileNames(object_input, generic_input, options, argc, argv);
     700  const char *input;
     701  if (object_input) input = object_input;
     702  if (generic_input) input = generic_input;
     703
     704  // parse input into keyvalue container
     705  Ref<ParsedKeyVal> parsedkv;
     706  parseInputfile(grp, parsedkv, options, input, generic_input);
    688707  if (options.retrieve("k")) parsedkv->verbose(1);
    689708  Ref<KeyVal> keyval = new PrefixKeyVal(parsedkv.pointer(),"mpqc");
Note: See TracChangeset for help on using the changeset viewer.