00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <jsoc_main.h>
00019 char *module_name = "CookbookRecipe:02";
00020 char *version_id = "1.0";
00021
00022 ModuleArgs_t module_args[] = {
00023 {ARG_STRING, "name", "Not Specified", "a string"},
00024 {ARG_INT, "ival", "1", "a positive integer", "[1,)"},
00025 {ARG_INTS, "iptr", "[0]", "array of integers"},
00026 {ARG_FLOAT, "fval", "0.0", "a real number"},
00027 {ARG_FLOAT, "fvalns", "Unspecified", "a real number"},
00028 {ARG_FLOATS, "fptr", "{2.71828, 3.14159, -1}", "array of real numbers"},
00029 {ARG_TIME, "time", "1582.10.5_00:00:00",
00030 "a time, in standard date_time format"},
00031 {ARG_NUME, "colour", "", "enumerated choice without a default",
00032 "red, orange, yellow, green, blue, indigo, violet"},
00033 {ARG_NUME, "mois", "Brumaire", "enumerated choice with a default",
00034 "Vendémiaire, Brumaire, Frimaire, Nivôse, Pluviôse, Ventôse, Germinal, \
00035 Florial, Prairial, Messidor, Thermidor, Fructidor"},
00036 {ARG_FLAG, "e", "", "a flag value"},
00037 {ARG_END}
00038 };
00039
00040 int DoIt (void) {
00041 CmdParams_t *params = &cmdparams;
00042 double *fpval;
00043 int *ipval;
00044 int i, fpvals, ipvals;
00045 char *colours[] = {"red", "orange", "yellow", "green", "blue", "violet"};
00046 char *moiss[] = {"Vendémiaire", "Brumaire", "Frimaire", "Nivôse", "Pluviôse",
00047 "Ventôse", "Germinal", "Florial", "Prairial", "Messidor", "Thermidor",
00048 "Fructidor"};
00049 char key[64], tbuf[64];
00050
00051 TIME tval = params_get_time (params, "time");
00052 double fval = params_get_double (params, "fval");
00053 int ival = params_get_int (params, "ival");
00054 int colour = params_get_int (params, "colour");
00055 int mois = params_get_int (params, "mois");
00056 char *name = strdup (params_get_str (params, "name"));
00057 int flagset = params_isflagset (params, "e");
00058
00059 printf ("name = %s\n", name);
00060 printf ("fval = %g\n", fval);
00061 printf ("ival = %d\n", ival);
00062 sprint_time (tbuf, tval, "UT", 3);
00063 printf ("time = %s\n", tbuf);
00064 printf ("colour = %d (%s)\n", colour, colours[colour]);
00065 printf ("mois = %d (%s)\n", mois, moiss[mois]);
00066 printf ("-e? : %d\n", flagset);
00067
00068 printf ("fpvals = %d\n", fpvals = params_get_int (params, "fptr_nvals"));
00069 fpval = (double *)malloc (fpvals * sizeof (double));
00070 for (i = 0; i < fpvals; i++) {
00071 sprintf (key, "fptr_%d_value", i);
00072 fpval[i] = params_get_double (params, key);
00073 printf ("fpval[%d] = %g\n", i, fpval[i]);
00074 }
00075 printf ("ipvals = %d\n", ipvals = params_get_int (params, "iptr_nvals"));
00076 ipval = (int *)malloc (ipvals * sizeof (int));
00077 for (i = 0; i < ipvals; i++) {
00078 sprintf (key, "iptr_%d_value", i);
00079 ipval[i] = params_get_int (params, key);
00080 printf ("ipval[%d] = %d\n", i, ipval[i]);
00081 }
00082
00083 return (0);
00084 }
00085
00086
00087
00088
00089
00090
00091