Changeset 15234
- Timestamp:
- Oct 5, 2007, 5:38:27 PM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 4 edited
-
pxtables.c (modified) (2 diffs)
-
pztool.c (modified) (3 diffs)
-
pztool.h (modified) (1 diff)
-
pztoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pxtables.c
r14485 r15234 51 51 } 52 52 #endif 53 CREATE_TABLE(pzDataStoreCreateTable); 53 54 CREATE_TABLE(summitExpCreateTable); 54 55 CREATE_TABLE(summitImfileCreateTable); … … 137 138 138 139 // DROP_TABLE(expTagCounterDropTable); 140 DROP_TABLE(pzDataStoreDropTable); 139 141 DROP_TABLE(summitExpDropTable); 140 142 DROP_TABLE(summitImfileDropTable); -
trunk/ippTools/src/pztool.c
r15167 r15234 31 31 #include "pztool.h" 32 32 33 static bool adddatastoreMode(pxConfig *config); 34 static bool datastoreMode(pxConfig *config); 33 35 static bool seenMode(pxConfig *config); 34 36 static bool pendingExpMode(pxConfig *config); … … 59 61 60 62 switch (config->mode) { 63 MODECASE(PZTOOL_MODE_ADDDATASTORE, adddatastoreMode); 64 MODECASE(PZTOOL_MODE_DATASTORE, datastoreMode); 61 65 MODECASE(PZTOOL_MODE_SEEN, seenMode); 62 66 MODECASE(PZTOOL_MODE_PENDINGEXP, pendingExpMode); … … 82 86 83 87 exit(exit_status); 88 } 89 90 static bool adddatastoreMode(pxConfig *config) 91 { 92 PS_ASSERT_PTR_NON_NULL(config, false); 93 94 bool status = false; 95 psString camera = psMetadataLookupStr(&status, config->args, "-inst"); 96 if (!status) { 97 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst"); 98 return false; 99 } 100 if (!camera) { 101 psError(PS_ERR_UNKNOWN, true, "-inst is required"); 102 return false; 103 } 104 105 psString telescope = psMetadataLookupStr(&status, config->args, "-telescope"); 106 if (!status) { 107 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -telescope"); 108 return false; 109 } 110 if (!telescope) { 111 psError(PS_ERR_UNKNOWN, true, "-telescope is required"); 112 return false; 113 } 114 115 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 116 if (!status) { 117 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 118 return false; 119 } 120 if (!uri) { 121 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 122 return false; 123 } 124 125 if (!pzDataStoreInsert(config->dbh, 126 camera, 127 telescope, 128 uri 129 )) { 130 psError(PS_ERR_UNKNOWN, false, "database error"); 131 return false; 132 } 133 134 return true; 135 } 136 137 static bool datastoreMode(pxConfig *config) 138 { 139 PS_ASSERT_PTR_NON_NULL(config, false); 140 141 if (!p_psDBRunQuery(config->dbh, "SELECT * FROM pzDataStore")) { 142 psError(PS_ERR_UNKNOWN, false, "database error"); 143 return false; 144 } 145 146 psArray *output = p_psDBFetchResult(config->dbh); 147 if (!output) { 148 psError(PS_ERR_UNKNOWN, false, "database error"); 149 return false; 150 } 151 if (!psArrayLength(output)) { 152 psTrace("pztool", PS_LOG_INFO, "no rows found"); 153 psFree(output); 154 return true; 155 } 156 157 bool simple = false; 158 { 159 bool status = false; 160 simple = psMetadataLookupBool(&status, config->args, "-simple"); 161 if (!status) { 162 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 163 return false; 164 } 165 } 166 167 // negative simple so the default is true 168 if (!ippdbPrintMetadatas(stdout, output, "pzDataStore", !simple)) { 169 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 170 psFree(output); 171 return false; 172 } 173 174 psFree(output); 175 176 return true; 84 177 } 85 178 -
trunk/ippTools/src/pztool.h
r10025 r15234 25 25 typedef enum { 26 26 PZTOOL_MODE_NONE = 0x0, 27 PZTOOL_MODE_ADDDATASTORE, 28 PZTOOL_MODE_DATASTORE, 27 29 PZTOOL_MODE_SEEN, 28 30 PZTOOL_MODE_PENDINGEXP, -
trunk/ippTools/src/pztoolConfig.c
r15032 r15234 42 42 return NULL; 43 43 } 44 45 // -adddatastore 46 psMetadata *adddatastoreArgs = psMetadataAlloc(); 47 psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-inst", 0, 48 "define camera ID", NULL); 49 psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-telescope", 0, 50 "define telescope ID", NULL); 51 psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-uri", 0, 52 "define storage uri", NULL); 53 54 // -datastore 55 psMetadata *datastoreArgs = psMetadataAlloc(); 56 psMetadataAddBool(datastoreArgs, PS_LIST_TAIL, "-simple", 0, 57 "use the simple output format", false); 44 58 45 59 // -seen … … 123 137 psMetadata *modes = psMetadataAlloc(); 124 138 139 PXTOOL_ADD_MODE("-adddatastore", "", PZTOOL_MODE_ADDDATASTORE, adddatastoreArgs); 140 PXTOOL_ADD_MODE("-datastore", "", PZTOOL_MODE_DATASTORE, datastoreArgs); 125 141 PXTOOL_ADD_MODE("-seen", "", PZTOOL_MODE_SEEN, seenArgs); 126 142 PXTOOL_ADD_MODE("-pendingexp", "", PZTOOL_MODE_PENDINGEXP, pendingexpArgs);
Note:
See TracChangeset
for help on using the changeset viewer.
