00001 /* 00002 * smpl_00.c $DRMS/proj/cookbook/ 00003 * 00004 * An extremely simple program that does (almost) nothing at all. 00005 * It illustrates how a module is called from a driver program, in this 00006 * case a locally-provided main program rather than jsoc_main, and the 00007 * use of the command line parsing features in (and outside of) the 00008 * module. 00009 * 00010 * Usage: 00011 * smpl_00 [print= ...] 00012 * 00013 * Bugs: 00014 * The program is of no particular use, and exists merely for heuristic 00015 * and testing purposes. 00016 * 00017 * Revision history is at end of file. 00018 */ 00019 #include <cmdparams.h> 00020 #include <timeio.h> 00021 /* sample module arguments declaration */ 00022 ModuleArgs_t module_args[] = { 00023 /* module-specific argument declarators */ 00024 {ARG_STRING, "print", "done", "message to print on successful completion"}, 00025 /* required end (or blank) argument */ 00026 {ARG_END} 00027 }; 00028 /* required global declaration (normally included in module driver) */ 00029 CmdParams_t cmdparams; 00030 00031 int DoIt (void) { 00032 int status; 00033 char *msg = strdup (cmdparams_get_str (&cmdparams, "print", &status)); 00034 printf ("%s\n", msg); 00035 return 0; 00036 } 00037 00038 int main (int argc, char **argv) { 00039 int status = cmdparams_parse (&cmdparams, argc, argv); 00040 if (status >= 0) return DoIt (); 00041 } 00042 00043 /* 00044 * Revision History 00045 * 00046 * 09.07.27 file created by R Bogart 00047 */