Changeset 18366 for trunk/ippTools/src/chiptool.c
- Timestamp:
- Jun 29, 2008, 3:02:07 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/chiptool.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r18336 r18366 45 45 static bool unmaskedMode(pxConfig *config); 46 46 static bool unblockMode(pxConfig *config); 47 static bool pendingcleanupMode(pxConfig *config); 47 static bool pendingcleanuprunMode(pxConfig *config); 48 static bool pendingcleanupimfileMode(pxConfig *config); 48 49 static bool donecleanupMode(pxConfig *config); 50 static bool runMode(pxConfig *config); 49 51 50 52 static bool chipProcessedCompleteExp(pxConfig *config); … … 67 69 68 70 switch (config->mode) { 69 MODECASE(CHIPTOOL_MODE_DEFINEBYQUERY, definebyqueryMode);71 MODECASE(CHIPTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 70 72 MODECASE(CHIPTOOL_MODE_UPDATERUN, updaterunMode); 71 73 MODECASE(CHIPTOOL_MODE_PENDINGIMFILE, pendingimfileMode); … … 78 80 MODECASE(CHIPTOOL_MODE_UNMASKED, unmaskedMode); 79 81 MODECASE(CHIPTOOL_MODE_UNBLOCK, unblockMode); 80 MODECASE(CHIPTOOL_MODE_PENDINGCLEANUP, pendingcleanupMode); 82 MODECASE(CHIPTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 83 MODECASE(CHIPTOOL_MODE_PENDINGCLEANUPIMFILE, pendingcleanupimfileMode); 81 84 MODECASE(CHIPTOOL_MODE_DONECLEANUP, donecleanupMode); 85 MODECASE(CHIPTOOL_MODE_RUN, runMode); 82 86 default: 83 87 psAbort("invalid option (this should not happen)"); … … 835 839 836 840 837 static bool pendingcleanup Mode(pxConfig *config)841 static bool pendingcleanuprunMode(pxConfig *config) 838 842 { 839 843 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 845 849 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 846 850 847 psString query = pxDataGet("chiptool_pendingcleanup .sql");851 psString query = pxDataGet("chiptool_pendingcleanuprun.sql"); 848 852 if (!query) { 849 853 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 884 888 885 889 // negative simple so the default is true 886 if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanup ", !simple)) {890 if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanupRun", !simple)) { 887 891 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 888 892 psFree(output); … … 896 900 897 901 898 static bool donecleanupMode(pxConfig *config)902 static bool pendingcleanupimfileMode(pxConfig *config) 899 903 { 900 904 PS_ASSERT_PTR_NON_NULL(config, NULL); 901 905 906 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false); 902 907 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 903 908 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 904 909 905 910 psMetadata *where = psMetadataAlloc(); 911 if (chip_id) { 912 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 913 } 906 914 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 907 915 908 psString query = pxDataGet("chiptool_ donecleanup.sql");916 psString query = pxDataGet("chiptool_pendingcleanupimfile.sql"); 909 917 if (!query) { 910 918 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 945 953 946 954 // negative simple so the default is true 955 if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanupImfile", !simple)) { 956 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 957 psFree(output); 958 return false; 959 } 960 961 psFree(output); 962 963 return true; 964 } 965 966 967 static bool donecleanupMode(pxConfig *config) 968 { 969 PS_ASSERT_PTR_NON_NULL(config, NULL); 970 971 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 972 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 973 974 psMetadata *where = psMetadataAlloc(); 975 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 976 977 psString query = pxDataGet("chiptool_donecleanup.sql"); 978 if (!query) { 979 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 980 return false; 981 } 982 983 if (where && psListLength(where->list)) { 984 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 985 psStringAppend(&query, " AND %s", whereClause); 986 psFree(whereClause); 987 } 988 psFree(where); 989 990 // treat limit == 0 as "no limit" 991 if (limit) { 992 psString limitString = psDBGenerateLimitSQL(limit); 993 psStringAppend(&query, " %s", limitString); 994 psFree(limitString); 995 } 996 997 if (!p_psDBRunQuery(config->dbh, query)) { 998 psError(PS_ERR_UNKNOWN, false, "database error"); 999 psFree(query); 1000 return false; 1001 } 1002 psFree(query); 1003 1004 psArray *output = p_psDBFetchResult(config->dbh); 1005 if (!output) { 1006 psError(PS_ERR_UNKNOWN, false, "database error"); 1007 return false; 1008 } 1009 if (!psArrayLength(output)) { 1010 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1011 psFree(output); 1012 return true; 1013 } 1014 1015 // negative simple so the default is true 1016 if (!ippdbPrintMetadatas(stdout, output, "chipDoneCleanup", !simple)) { 1017 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1018 psFree(output); 1019 return false; 1020 } 1021 1022 psFree(output); 1023 1024 return true; 1025 } 1026 1027 1028 static bool runMode(pxConfig *config) 1029 { 1030 PS_ASSERT_PTR_NON_NULL(config, NULL); 1031 1032 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 1033 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1034 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1035 1036 // make sure that the state string is valid 1037 if (!pxIsValidState(state)) { 1038 psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state); 1039 return false; 1040 } 1041 1042 psMetadata *where = psMetadataAlloc(); 1043 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1044 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 1045 1046 psString query = pxDataGet("chiptool_run.sql"); 1047 if (!query) { 1048 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1049 return false; 1050 } 1051 1052 if (where && psListLength(where->list)) { 1053 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1054 psStringAppend(&query, " %s", whereClause); 1055 psFree(whereClause); 1056 } 1057 psFree(where); 1058 1059 // treat limit == 0 as "no limit" 1060 if (limit) { 1061 psString limitString = psDBGenerateLimitSQL(limit); 1062 psStringAppend(&query, " %s", limitString); 1063 psFree(limitString); 1064 } 1065 1066 if (!p_psDBRunQuery(config->dbh, query)) { 1067 psError(PS_ERR_UNKNOWN, false, "database error"); 1068 psFree(query); 1069 return false; 1070 } 1071 psFree(query); 1072 1073 psArray *output = p_psDBFetchResult(config->dbh); 1074 if (!output) { 1075 psError(PS_ERR_UNKNOWN, false, "database error"); 1076 return false; 1077 } 1078 if (!psArrayLength(output)) { 1079 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1080 psFree(output); 1081 return true; 1082 } 1083 1084 // negative simple so the default is true 947 1085 if (!ippdbPrintMetadatas(stdout, output, "chipDoneCleanup", !simple)) { 948 1086 psError(PS_ERR_UNKNOWN, false, "failed to print array"); … … 992 1130 chipRunRow *chipRun = chipRunObjectFromMetadata(row); 993 1131 // set chipRun.state to 'stop' 994 if (!pxchipRunSetState(config, chipRun->chip_id, " stop")) {1132 if (!pxchipRunSetState(config, chipRun->chip_id, "full")) { 995 1133 psError(PS_ERR_UNKNOWN, false, "failed to change chipRun.state for chip_id: %" PRId64, chipRun->chip_id); 996 1134 psFree(chipRun);
Note:
See TracChangeset
for help on using the changeset viewer.
