Changeset 15234 for trunk/ippTools/src/pztool.c
- Timestamp:
- Oct 5, 2007, 5:38:27 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pztool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.
