(file) Return to smpl_00.c CVS log (file) (dir) Up to [Development] / JSOC / proj / cookbook

Diff for /JSOC/proj/cookbook/smpl_00.c between version 1.1 and 1.6

version 1.1, 2009/04/13 17:35:09 version 1.6, 2011/11/04 00:30:09
Line 1 
Line 1 
 /* /*
  *  smpl_00.c                                           $DRMS/proj/cookbook/  *  smpl_00.c                                           $DRMS/proj/cookbook/
  *  *
  *  An extremely simple module that does (almost) nothing at all.   *  An extremely simple program that does (almost) nothing at all.
  *    It illustrates the structure of a DRMS module and exhibits   *    It illustrates how a module is called from a driver program, in this
  *    return status behavior with use of the module verbose flags   *    case a locally-provided main program rather than jsoc_main, and the
    *    use of the command line parsing features in (and outside of) the
    *    module.
  *  *
  *  Usage:  *  Usage:
  *    smpl [-avVH]   *    smpl_00 [print= ...]
  *  *
  *  Bugs:  *  Bugs:
  *    The module is of no particular use, and exists merely for heuristic   *    The program is of no particular use, and exists merely for heuristic
  *      and testing purposes.  *      and testing purposes.
  *  *
  *  Revision history is at end of file.  *  Revision history is at end of file.
  */  */
                                                   /*  required .h inclusion  */  #include <cmdparams.h>
 #include <jsoc_main.h>  #include <timeio.h>
                                              /*  required module identifier  */                                      /*  sample module arguments declaration  */
 char *module_name = "CookbookRecipe:00";  
                                             /*  optional version identifier  
                       (recommended, and required for this particular module  */  
 char *version_id = "1.0";  
                                   /*  required module arguments declaration  */  
 ModuleArgs_t module_args[] = { ModuleArgs_t module_args[] = {
                                    /*  module-specific argument declarators  */                                    /*  module-specific argument declarators  */
   {ARG_FLAG,    "a",    "", "force an abort"},  
   {ARG_FLAG,    "v",    "", "run in verbose mode"},  
   {ARG_STRING,  "print", "done", "message to print on successful completion"},   {ARG_STRING,  "print", "done", "message to print on successful completion"},
                                        /*  required end (or blank) argument  */                                        /*  required end (or blank) argument  */
   {ARG_END}   {ARG_END}
 }; };
                                             /*  required module declaration  */         /*  required global declaration (normally included in module driver)  */
   CmdParams_t cmdparams;
   
 int DoIt (void) { int DoIt (void) {
   int status;   int status;
     char *msg = strdup (cmdparams_get_str (&cmdparams, "print", &status));
   char *msg = cmdparams_get_str (&cmdparams, "print", &status);  
   
   if (params_isflagset (&cmdparams, "v"))  
     printf ("running module %s version %s\n", module_name, version_id);  
   if (params_isflagset (&cmdparams, "a")) {  
     printf ("aborting\n");  
     return 1;  
   }  
   
   printf ("%s\n", msg);   printf ("%s\n", msg);
   return 0;   return 0;
 } }
  
   int main (int argc, char **argv) {
     int status = cmdparams_parse (&cmdparams, argc, argv);
     if (status >= 0) return DoIt ();
   }
   
 /* /*
  *  Revision History  *  Revision History
  *  *
  *  09.04.13    file created by R Bogart   *  09.07.27    file created by R Bogart
  */  */


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

Karen Tian
Powered by
ViewCVS 0.9.4