Changeset 19092 for trunk/ippTools/src/difftool.c
- Timestamp:
- Aug 16, 2008, 1:27:58 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r19038 r19092 41 41 static bool definepoprunMode(pxConfig *config); 42 42 static bool definebyqueryMode(pxConfig *config); 43 static bool pendingcleanuprunMode(pxConfig *config); 44 static bool pendingcleanupskyfileMode(pxConfig *config); 45 static bool donecleanupMode(pxConfig *config); 43 46 44 47 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state); … … 62 65 63 66 switch (config->mode) { 64 MODECASE(DIFFTOOL_MODE_DEFINERUN, definerunMode); 65 MODECASE(DIFFTOOL_MODE_UPDATERUN, updaterunMode); 66 MODECASE(DIFFTOOL_MODE_ADDINPUTSKYFILE, addinputskyfileMode); 67 MODECASE(DIFFTOOL_MODE_INPUTSKYFILE, inputskyfileMode); 68 MODECASE(DIFFTOOL_MODE_TODIFFSKYFILE, todiffskyfileMode); 69 MODECASE(DIFFTOOL_MODE_ADDDIFFSKYFILE, adddiffskyfileMode); 70 MODECASE(DIFFTOOL_MODE_DIFFSKYFILE, diffskyfileMode); 71 MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE, revertdiffskyfileMode); 72 MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunMode); 73 MODECASE(DIFFTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 67 MODECASE(DIFFTOOL_MODE_DEFINERUN, definerunMode); 68 MODECASE(DIFFTOOL_MODE_UPDATERUN, updaterunMode); 69 MODECASE(DIFFTOOL_MODE_ADDINPUTSKYFILE, addinputskyfileMode); 70 MODECASE(DIFFTOOL_MODE_INPUTSKYFILE, inputskyfileMode); 71 MODECASE(DIFFTOOL_MODE_TODIFFSKYFILE, todiffskyfileMode); 72 MODECASE(DIFFTOOL_MODE_ADDDIFFSKYFILE, adddiffskyfileMode); 73 MODECASE(DIFFTOOL_MODE_DIFFSKYFILE, diffskyfileMode); 74 MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE, revertdiffskyfileMode); 75 MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunMode); 76 MODECASE(DIFFTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 77 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 78 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode); 79 MODECASE(DIFFTOOL_MODE_DONECLEANUP, donecleanupMode); 74 80 default: 75 81 psAbort("invalid option (this should not happen)"); … … 259 265 260 266 if (count == 2) { 261 if (!setdiffRunState(config, diff_id, " run")) {267 if (!setdiffRunState(config, diff_id, "new")) { 262 268 if (!psDBRollback(config->dbh)) { 263 269 psError(PS_ERR_UNKNOWN, false, "database error"); … … 496 502 } 497 503 498 if (!setdiffRunState(config, diff_id, " stop")) {504 if (!setdiffRunState(config, diff_id, "full")) { 499 505 if (!psDBRollback(config->dbh)) { 500 506 psError(PS_ERR_UNKNOWN, false, "database error"); … … 696 702 697 703 // check that state is a valid string value 698 if (!( 699 (strncmp(state, "run", 4) == 0) 700 || (strncmp(state, "stop", 5) == 0) 701 || (strncmp(state, "reg", 4) == 0) 702 ) 703 ) { 704 psError(PS_ERR_UNKNOWN, false, 705 "invalid diffRun state: %s", state); 704 if (!pxIsValidState(state)) { 705 psError(PS_ERR_UNKNOWN, false, "invalid diffRun state: %s", state); 706 706 return false; 707 707 } … … 1008 1008 return true; 1009 1009 } 1010 1011 static bool pendingcleanuprunMode(pxConfig *config) 1012 { 1013 PS_ASSERT_PTR_NON_NULL(config, NULL); 1014 1015 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1016 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1017 1018 psMetadata *where = psMetadataAlloc(); 1019 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1020 1021 psString query = pxDataGet("difftool_pendingcleanuprun.sql"); 1022 if (!query) { 1023 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1024 return false; 1025 } 1026 1027 if (where && psListLength(where->list)) { 1028 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1029 psStringAppend(&query, " AND %s", whereClause); 1030 psFree(whereClause); 1031 } 1032 psFree(where); 1033 1034 // treat limit == 0 as "no limit" 1035 if (limit) { 1036 psString limitString = psDBGenerateLimitSQL(limit); 1037 psStringAppend(&query, " %s", limitString); 1038 psFree(limitString); 1039 } 1040 1041 if (!p_psDBRunQuery(config->dbh, query)) { 1042 psError(PS_ERR_UNKNOWN, false, "database error"); 1043 psFree(query); 1044 return false; 1045 } 1046 psFree(query); 1047 1048 psArray *output = p_psDBFetchResult(config->dbh); 1049 if (!output) { 1050 psError(PS_ERR_UNKNOWN, false, "database error"); 1051 return false; 1052 } 1053 if (!psArrayLength(output)) { 1054 psTrace("difftool", PS_LOG_INFO, "no rows found"); 1055 psFree(output); 1056 return true; 1057 } 1058 1059 // negative simple so the default is true 1060 if (!ippdbPrintMetadatas(stdout, output, "diffPendingCleanupRun", !simple)) { 1061 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1062 psFree(output); 1063 return false; 1064 } 1065 1066 psFree(output); 1067 1068 return true; 1069 } 1070 1071 1072 static bool pendingcleanupskyfileMode(pxConfig *config) 1073 { 1074 PS_ASSERT_PTR_NON_NULL(config, NULL); 1075 1076 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", false, false); 1077 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1078 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1079 1080 psMetadata *where = psMetadataAlloc(); 1081 if (diff_id) { 1082 PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "=="); 1083 } 1084 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1085 1086 psString query = pxDataGet("difftool_pendingcleanupskyfile.sql"); 1087 if (!query) { 1088 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1089 return false; 1090 } 1091 1092 if (where && psListLength(where->list)) { 1093 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1094 psStringAppend(&query, " AND %s", whereClause); 1095 psFree(whereClause); 1096 } 1097 psFree(where); 1098 1099 // treat limit == 0 as "no limit" 1100 if (limit) { 1101 psString limitString = psDBGenerateLimitSQL(limit); 1102 psStringAppend(&query, " %s", limitString); 1103 psFree(limitString); 1104 } 1105 1106 if (!p_psDBRunQuery(config->dbh, query)) { 1107 psError(PS_ERR_UNKNOWN, false, "database error"); 1108 psFree(query); 1109 return false; 1110 } 1111 psFree(query); 1112 1113 psArray *output = p_psDBFetchResult(config->dbh); 1114 if (!output) { 1115 psError(PS_ERR_UNKNOWN, false, "database error"); 1116 return false; 1117 } 1118 if (!psArrayLength(output)) { 1119 psTrace("difftool", PS_LOG_INFO, "no rows found"); 1120 psFree(output); 1121 return true; 1122 } 1123 1124 // negative simple so the default is true 1125 if (!ippdbPrintMetadatas(stdout, output, "diffPendingCleanupSkyfile", !simple)) { 1126 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1127 psFree(output); 1128 return false; 1129 } 1130 1131 psFree(output); 1132 return true; 1133 } 1134 1135 1136 static bool donecleanupMode(pxConfig *config) 1137 { 1138 PS_ASSERT_PTR_NON_NULL(config, NULL); 1139 1140 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1141 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1142 1143 psMetadata *where = psMetadataAlloc(); 1144 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1145 1146 psString query = pxDataGet("difftool_donecleanup.sql"); 1147 if (!query) { 1148 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1149 return false; 1150 } 1151 1152 if (where && psListLength(where->list)) { 1153 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1154 psStringAppend(&query, " AND %s", whereClause); 1155 psFree(whereClause); 1156 } 1157 psFree(where); 1158 1159 // treat limit == 0 as "no limit" 1160 if (limit) { 1161 psString limitString = psDBGenerateLimitSQL(limit); 1162 psStringAppend(&query, " %s", limitString); 1163 psFree(limitString); 1164 } 1165 1166 if (!p_psDBRunQuery(config->dbh, query)) { 1167 psError(PS_ERR_UNKNOWN, false, "database error"); 1168 psFree(query); 1169 return false; 1170 } 1171 psFree(query); 1172 1173 psArray *output = p_psDBFetchResult(config->dbh); 1174 if (!output) { 1175 psError(PS_ERR_UNKNOWN, false, "database error"); 1176 return false; 1177 } 1178 if (!psArrayLength(output)) { 1179 psTrace("difftool", PS_LOG_INFO, "no rows found"); 1180 psFree(output); 1181 return true; 1182 } 1183 1184 // negative simple so the default is true 1185 if (!ippdbPrintMetadatas(stdout, output, "diffDoneCleanup", !simple)) { 1186 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1187 psFree(output); 1188 return false; 1189 } 1190 1191 psFree(output); 1192 return true; 1193 }
Note:
See TracChangeset
for help on using the changeset viewer.
