Changeset 34910 for trunk/ippTools/src/releasetool.c
- Timestamp:
- Jan 10, 2013, 5:16:22 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/releasetool.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/releasetool.c
r34908 r34910 97 97 return false; 98 98 } 99 99 100 static bool listsurveyMode(pxConfig *config) 101 { 102 PS_ASSERT_PTR_NON_NULL(config, NULL); 103 104 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 105 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 106 psMetadata *where = psMetadataAlloc(); 107 108 PXOPT_COPY_STR(config->args, where, "-surveyName", "surveyName", "LIKE"); 109 110 psString query = pxDataGet("releasetool_listsurvey.sql"); 111 if (!query) { 112 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 113 return false; 114 } 115 116 if (psListLength(where->list)) { 117 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 118 psStringAppend(&query, " WHERE %s", whereClause); 119 psFree(whereClause); 120 } else { 121 // The list of surveys is short there is no need to require parameters 122 #ifdef notdef 123 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required\n"); 124 psFree(where); 125 return false; 126 #endif 127 } 128 129 if (limit) { 130 psString limitString = psDBGenerateLimitSQL(limit); 131 psStringAppend(&query, " %s", limitString); 132 psFree(limitString); 133 } 134 135 if (!p_psDBRunQuery(config->dbh, query)) { 136 psError(PS_ERR_UNKNOWN, false, "database error"); 137 psFree(query); 138 return false; 139 } 140 psFree(query); 141 142 psArray *output = p_psDBFetchResult(config->dbh); 143 if (!output) { 144 psError(PS_ERR_UNKNOWN, false, "database error"); 145 return false; 146 } 147 148 if (!psArrayLength(output)) { 149 psTrace("releasetool", PS_LOG_INFO, "no rows found"); 150 psFree(output); 151 return true; 152 } 153 154 if (!ippdbPrintMetadatas(stdout, output, "survey", !simple)) { 155 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 156 psFree(output); 157 return false; 158 } 159 160 psFree(output); 161 162 return true; 163 } 164 165 static bool definereleaseMode(pxConfig *config) 166 { 167 PS_ASSERT_PTR_NON_NULL(config, false); 168 169 PXOPT_LOOKUP_STR(releaseName, config->args, "-set_releaseName", true, false); 170 PXOPT_LOOKUP_S32(surveyID, config->args, "-set_surveyID", true, false); 171 PXOPT_LOOKUP_S32(dataRelease, config->args, "-set_dataRelease", false, false); 172 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 173 174 if (!ippReleaseInsert(config->dbh, 175 0, // rel_id (auto_increment) 176 surveyID, 177 releaseName, 178 state, 179 dataRelease 180 )) { 181 psError(PS_ERR_UNKNOWN, false, "failed to insert ippRelease"); 182 return false; 183 } 184 185 return true; 186 } 187 188 static bool updatereleaseMode(pxConfig *config) 189 { 190 PS_ASSERT_PTR_NON_NULL(config, false); 191 192 PXOPT_LOOKUP_STR(releaseName, config->args, "-releaseName", false, false); 193 PXOPT_LOOKUP_S32(rel_id, config->args, "-rel_id", false, false); 194 195 if (!releaseName && !rel_id) { 196 psError(PXTOOLS_ERR_CONFIG, true, "either -releaseName or -rel_id is required\n"); 197 return false; 198 } 199 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 200 201 psMetadata *where = psMetadataAlloc(); 202 203 PXOPT_COPY_S32(config->args, where, "-rel_id", "rel_id", "=="); 204 PXOPT_COPY_STR(config->args, where, "-releaseName", "releaseName", "=="); 205 206 psString query = NULL; 207 psStringAppend(&query, "UPDATE ippRelease SET state = '%s'", state); 208 209 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 210 psStringAppend(&query, " WHERE %s", whereClause); 211 psFree(whereClause); 212 213 if (!p_psDBRunQuery(config->dbh, query)) { 214 psError(PS_ERR_UNKNOWN, false, "database error"); 215 psFree(query); 216 return false; 217 } 218 219 psU64 affected = psDBAffectedRows(config->dbh); 220 psLogMsg("releasetool", PS_LOG_INFO, "Updated %" PRIu64 " ippReleases", affected); 221 222 223 psFree(query); 224 225 return true; 226 } 227 228 static bool listreleaseMode(pxConfig *config) 229 { 230 PS_ASSERT_PTR_NON_NULL(config, NULL); 231 232 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 233 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 234 psMetadata *where = psMetadataAlloc(); 235 236 PXOPT_COPY_STR(config->args, where, "-surveyName", "surveyName", "LIKE"); 237 PXOPT_COPY_STR(config->args, where, "-releaseName", "releaseName", "LIKE"); 238 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 239 PXOPT_COPY_S32(config->args, where, "-rel_id", "rel_id", "=="); 240 241 psString query = pxDataGet("releasetool_listrelease.sql"); 242 if (!query) { 243 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 244 return false; 245 } 246 247 if (psListLength(where->list)) { 248 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 249 psStringAppend(&query, " WHERE %s", whereClause); 250 psFree(whereClause); 251 } else { 252 // The list of releases is short there is no need to require parameters 253 #ifdef notdef 254 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required\n"); 255 psFree(where); 256 return false; 257 #endif 258 } 259 260 if (limit) { 261 psString limitString = psDBGenerateLimitSQL(limit); 262 psStringAppend(&query, " %s", limitString); 263 psFree(limitString); 264 } 265 266 if (!p_psDBRunQuery(config->dbh, query)) { 267 psError(PS_ERR_UNKNOWN, false, "database error"); 268 psFree(query); 269 return false; 270 } 271 psFree(query); 272 273 psArray *output = p_psDBFetchResult(config->dbh); 274 if (!output) { 275 psError(PS_ERR_UNKNOWN, false, "database error"); 276 return false; 277 } 278 279 if (!psArrayLength(output)) { 280 psTrace("releasetool", PS_LOG_INFO, "no rows found"); 281 psFree(output); 282 return true; 283 } 284 285 if (!ippdbPrintMetadatas(stdout, output, "ippRelease", !simple)) { 286 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 287 psFree(output); 288 return false; 289 } 290 291 psFree(output); 292 293 return true; 294 } 295 296 static bool definerelexpMode(pxConfig *config) 100 297 { 101 298 psError(PS_ERR_UNKNOWN, true, "not yet implemented"); 102 299 return false; 103 300 } 104 static bool definereleaseMode(pxConfig *config) 301 302 static bool updaterelexpMode(pxConfig *config) 105 303 { 106 304 psError(PS_ERR_UNKNOWN, true, "not yet implemented"); 107 305 return false; 108 306 } 109 static bool updatereleaseMode(pxConfig *config) 110 { 111 psError(PS_ERR_UNKNOWN, true, "not yet implemented"); 112 return false; 113 } 114 static bool listreleaseMode(pxConfig *config) 115 { 116 psError(PS_ERR_UNKNOWN, true, "not yet implemented"); 117 return false; 118 } 119 static bool definerelexpMode(pxConfig *config) 120 { 121 psError(PS_ERR_UNKNOWN, true, "not yet implemented"); 122 return false; 123 } 124 static bool updaterelexpMode(pxConfig *config) 125 { 126 psError(PS_ERR_UNKNOWN, true, "not yet implemented"); 127 return false; 128 } 307 129 308 static bool listrelexpMode(pxConfig *config) 130 309 { … … 208 387 209 388 if (!psListLength(where->list)) { 210 psError(PXTOOLS_ERR_CONFIG, false, "search param ters are required\n");389 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required\n"); 211 390 psFree(where); 212 391 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
