Changeset 7820 for trunk/ippTools/src/regtoolConfig.c
- Timestamp:
- Jul 5, 2006, 2:39:22 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/regtoolConfig.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/regtoolConfig.c
r7815 r7820 6 6 7 7 #include "pxtools.h" 8 #include " dettool.h"8 #include "p0search.h" 9 9 10 10 // this function can not fail -- exits on error 11 boolp0searchConfig(pxConfig *config, int argc, char **argv) {11 pxConfig *p0searchConfig(pxConfig *config, int argc, char **argv) { 12 12 if (!config) { 13 13 config = pxConfigAlloc(); … … 15 15 16 16 // setup site config 17 config->modules = pmConfigRead( argc, argv);17 config->modules = pmConfigRead(&argc, argv); 18 18 if (!config->modules) { 19 19 psError(PS_ERR_UNKNOWN, false, "Can't find site configuration"); 20 20 goto FAIL; 21 21 } 22 argc = config->argc;23 22 24 23 // -pending … … 50 49 51 50 #define PXTOOL_MODE(option, modeval, argset) \ 51 { \ 52 int N = 0; \ 52 53 if ((N = psArgumentGet (argc, argv, option))) { \ 53 54 psArgumentRemove (N, &argc, argv); \ … … 57 58 config->mode = modeval; \ 58 59 config->args = psMemIncrRefCounter(argset); \ 59 } 60 } \ 61 } 60 62 61 63 // find which mode we're running under 62 64 PXTOOL_MODE("-pending", P0SEARCH_MODE_PENDING, pendingArgs); 63 PXTOOL_MODE("-update", P0SEARCH_MODE_UPDATE, updatergs); 64 65 PXTOOL_MODE("-update", P0SEARCH_MODE_UPDATE, updateArgs); 65 66 66 67 bool argErr = false; … … 68 69 argErr = true; 69 70 fprintf (stderr, "mode argument is required\n"); 70 } else if (! psArgumentParse( args, &argc, argv) || argc != 1) {71 } else if (! psArgumentParse(config->args, &argc, argv) || argc != 1) { 71 72 argErr = true; 72 73 fprintf (stderr, "error parsing arguments\n"); … … 104 105 { 105 106 psString str = NULL; 106 int n = 0;107 107 bool status = false; 108 bool boolean = false;109 108 109 addWhereStr(exp_id); 110 // convert '-inst' to 'camera' 111 if ((str = psMetadataLookupStr(&status, config->args, "-inst"))) { 112 if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) { 113 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 114 goto FAIL; 115 } 116 } 117 addWhereStr(telescope); 118 addWhereStr(exp_type); 119 addWhereStr(class_id); 120 addWhereStr(filter); 121 } 110 122 111 switch (config->mode) { 112 bool status; 113 case PX_MODE_PENDING: 114 // -exp_id 115 config->exp_id = psMetadataLookupStr(&status, args, "-exp_id"); 116 psMemIncrRefCounter(config->exp_id); 117 EMPTY_TO_NULL_STRING(config->exp_id); 118 // -inst 119 config->camera_name = psMetadataLookupStr(&status, args, "-inst"); 120 psMemIncrRefCounter(config->camera_name); 121 EMPTY_TO_NULL_STRING(config->camera_name); 122 // -telescope 123 config->camera_name = psMetadataLookupStr(&status, args, 124 "-telescope"); 125 psMemIncrRefCounter(config->telescope); 126 EMPTY_TO_NULL_STRING(config->telescope); 127 // -exp_type 128 config->class = psMetadataLookupStr(&status, args, "-exp_type"); 129 psMemIncrRefCounter(config->exp_type); 130 EMPTY_TO_NULL_STRING(config->exp_type); 131 // -class 132 config->class = psMetadataLookupStr(&status, args, "-class"); 133 psMemIncrRefCounter(config->class); 134 EMPTY_TO_NULL_STRING(config->class); 135 break; 136 case PX_MODE_UPDATE: 137 // -exp_id 138 config->exp_id = psMetadataLookupStr(&status, args, "-exp_id"); 139 psMemIncrRefCounter(config->exp_id); 140 EMPTY_TO_NULL_STRING(config->exp_id); 141 // -filter 142 config->filter = psMetadataLookupStr(&status, args, "-filter"); 143 psMemIncrRefCounter(config->filter); 144 EMPTY_TO_NULL_STRING(config->filter); 145 146 break; 147 default: 148 psAbort(argv[0], "invalid option (this should not happen)"); 123 if (config->where->list->n < 1) { 124 psFree(config->where); 125 config->where = NULL; 149 126 } 150 127 151 psFree(args);152 psFree(pendingArgs);153 psFree(updateArgs);154 155 156 psMetadata *where = psMetadataAlloc();157 158 if (config->camera_name != NULL) {159 if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==",160 config->camera_name)) {161 psError(PS_ERR_UNKNOWN, false, "failed to add item camera");162 psFree(where);163 return NULL;164 }165 }166 if (config->filter != NULL) {167 psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==",168 config->filter);169 }170 if (config->exp_id != NULL) {171 psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==",172 config->exp_id);173 }174 if (config->class != NULL) {175 psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==",176 config->class);177 }178 if (config->class_id != NULL) {179 psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",180 config->class_id);181 }182 183 /*184 // psMetadataConfig does not support times yet185 if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) {186 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop);187 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start);188 }189 */190 191 if (where->list->n < 1) {192 psFree(where);193 where = NULL;194 }195 196 config->where = where;197 198 199 // add the input and output images to the args list200 //psMetadataAddStr (args, PS_LIST_TAIL, "-output", 0, "Name of the output image", argv[1]);201 128 202 129 // define Database handle, if used
Note:
See TracChangeset
for help on using the changeset viewer.
