Changeset 13578 for trunk/ippTools/src/detselectConfig.c
- Timestamp:
- May 31, 2007, 2:58:32 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/detselectConfig.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/detselectConfig.c
r11856 r13578 78 78 "use the simple output format", false); 79 79 80 #define PXTOOL_MODE(option, modeval, argset) \81 { \82 int N = 0; \83 if ((N = psArgumentGet (argc, argv, option))) { \84 psArgumentRemove (N, &argc, argv); \85 if (config->mode) { \86 psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \87 psFree(config); \88 return NULL; \89 } \90 config->mode = modeval; \91 config->args = psMemIncrRefCounter(argset); \92 } \93 if (!psMetadataAddMetadata(argSets, PS_LIST_TAIL, option, 0, NULL, argset)) {;\94 psError(PS_ERR_UNKNOWN, false, "failed to add argset for %s", option);\95 } \96 psFree(argset); \97 }98 99 80 psMetadata *argSets = psMetadataAlloc(); 100 // find which mode we're running under 101 PXTOOL_MODE("-search", DETSELECT_MODE_SEARCH, searchArgs); 102 PXTOOL_MODE("-select", DETSELECT_MODE_SELECT, selectArgs); 103 104 bool argErr = false; 105 if (config->mode == DETSELECT_MODE_NONE) { 106 argErr = true; 107 fprintf (stderr, "mode argument is required\n"); 108 } else if (! psArgumentParse(config->args, &argc, argv) || argc != 1) { 109 argErr = true; 110 fprintf (stderr, "error parsing arguments\n"); 111 } 112 113 if (argErr) { 114 printf("\nPan-STARRS detrend select Tool\n"); 115 printf("Usage: %s <mode> [<options>]\n\n", argv[0]); 116 printf(" <mode> :\n\n"); 117 118 psMetadataIterator *iter = psMetadataIteratorAlloc(argSets, 0, NULL); 119 psMetadataItem *item = NULL; 120 while ((item = psMetadataGetAndIncrement(iter))) { 121 if (!item->type == PS_DATA_METADATA) { 122 psAbort("all options must be specified as a metadata"); } 123 124 fprintf(stdout, "%s ", item->name); 125 psArgumentHelp(item->data.md); 126 } 127 psFree(iter); 128 81 psMetadata *modes = psMetadataAlloc(); 82 83 PXTOOL_ADD_MODE("-search", "search for an appropriate detrend", DETSELECT_MODE_SEARCH, searchArgs); 84 PXTOOL_ADD_MODE("-select", "retreive detrend information", DETSELECT_MODE_SELECT, selectArgs); 85 86 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { 87 psError(PS_ERR_UNKNOWN, true, "option parsing failed"); 129 88 psFree(argSets); 89 psFree(modes); 130 90 psFree(config); 131 91 return NULL; … … 133 93 134 94 psFree(argSets); 95 psFree(modes); 135 96 136 97 // setup search criterion … … 262 223 } 263 224 264 // save argv/argc265 config->argv = argv;266 config->argc = argc;267 268 225 return config; 269 226 }
Note:
See TracChangeset
for help on using the changeset viewer.
