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

 1 rick  1.1 /*
 2            *  smpl_01.c						$DRMS/proj/cookbook/
 3            *
 4 rick  1.3  *  An extremely simple module that does (almost) nothing at all.
 5            *    It illustrates the structure of a DRMS module and exhibits
 6            *    return status behavior with use of the module verbose flags
 7 rick  1.1  *
 8            *  Usage:
 9 rick  1.2  *    smpl_01 [-avVH]
10 rick  1.1  *
11            *  Bugs:
12            *    The module is of no particular use, and exists merely for heuristic
13            *      and testing purposes.
14            *
15            *  Revision history is at end of file.
16            */
17 rick  1.3 						  /*  required .h inclusion  */
18 rick  1.1 #include <jsoc_main.h>
19 rick  1.3 					     /*  required module identifier  */
20 rick  1.1 char *module_name = "CookbookRecipe:01";
21 rick  1.3 					    /*  optional version identifier
22           		      (recommended, and required for this particular module  */
23 rick  1.1 char *version_id = "1.0";
24 rick  1.3 				  /*  required module arguments declaration  */
25 rick  1.1 ModuleArgs_t module_args[] = {
26 rick  1.3 				   /*  module-specific argument declarators  */
27             {ARG_FLAG,    "a",    "", "force an abort"},
28             {ARG_FLAG,    "v",    "", "run in verbose mode"},
29             {ARG_STRING,	"print", "done", "message to print on successful completion"},
30           				       /*  required end (or blank) argument  */
31 rick  1.1   {ARG_END}
32           };
33 rick  1.3 					    /*  required module declaration  */
34 rick  1.1 int DoIt (void) {
35 rick  1.3   int status;
36 rick  1.1 
37 rick  1.4   char *msg = strdup (cmdparams_get_str (&cmdparams, "print", &status));
38 rick  1.1 
39 rick  1.3   if (params_isflagset (&cmdparams, "v"))
40               printf ("running module %s version %s\n", module_name, version_id);
41             if (params_isflagset (&cmdparams, "a")) {
42               printf ("aborting\n");
43               return 1;
44 rick  1.1   }
45           
46 rick  1.3   printf ("%s\n", msg);
47           				    /*  required status return to jsoc_main  */
48             return 0;
49 rick  1.1 }
50           
51           /*
52            *  Revision History
53            *
54 rick  1.3  *  09.04.13	file created by R Bogart
55 rick  1.1  */

Karen Tian
Powered by
ViewCVS 0.9.4