Changeset 19092 for trunk/ippTools/src/camtool.c
- Timestamp:
- Aug 16, 2008, 1:27:58 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/camtool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/camtool.c
r18561 r19092 41 41 static bool maskedMode(pxConfig *config); 42 42 static bool unblockMode(pxConfig *config); 43 static bool pendingcleanuprunMode(pxConfig *config); 44 static bool pendingcleanupexpMode(pxConfig *config); 45 static bool donecleanupMode(pxConfig *config); 43 46 44 47 # define MODECASE(caseName, func) \ … … 71 74 MODECASE(CAMTOOL_MODE_MASKED, maskedMode); 72 75 MODECASE(CAMTOOL_MODE_UNBLOCK, unblockMode); 76 MODECASE(CAMTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 77 MODECASE(CAMTOOL_MODE_PENDINGCLEANUPEXP, pendingcleanupexpMode); 78 MODECASE(CAMTOOL_MODE_DONECLEANUP, donecleanupMode); 73 79 default: 74 80 psAbort("invalid option (this should not happen)"); … … 570 576 571 577 // since there is only one exp per 'run' set camRun.state = 'stop' 572 if (!pxcamRunSetState(config, row->cam_id, " stop")) {578 if (!pxcamRunSetState(config, row->cam_id, "full")) { 573 579 psError(PS_ERR_UNKNOWN, false, "failed to change camRun.state for cam_id: %" PRId64, row->cam_id); 574 580 psFree(row); … … 914 920 return true; 915 921 } 922 923 static bool pendingcleanuprunMode(pxConfig *config) 924 { 925 PS_ASSERT_PTR_NON_NULL(config, NULL); 926 927 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 928 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 929 930 psMetadata *where = psMetadataAlloc(); 931 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 932 933 psString query = pxDataGet("camtool_pendingcleanuprun.sql"); 934 if (!query) { 935 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 936 return false; 937 } 938 939 if (where && psListLength(where->list)) { 940 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 941 psStringAppend(&query, " AND %s", whereClause); 942 psFree(whereClause); 943 } 944 psFree(where); 945 946 // treat limit == 0 as "no limit" 947 if (limit) { 948 psString limitString = psDBGenerateLimitSQL(limit); 949 psStringAppend(&query, " %s", limitString); 950 psFree(limitString); 951 } 952 953 if (!p_psDBRunQuery(config->dbh, query)) { 954 psError(PS_ERR_UNKNOWN, false, "database error"); 955 psFree(query); 956 return false; 957 } 958 psFree(query); 959 960 psArray *output = p_psDBFetchResult(config->dbh); 961 if (!output) { 962 psError(PS_ERR_UNKNOWN, false, "database error"); 963 return false; 964 } 965 if (!psArrayLength(output)) { 966 psTrace("camtool", PS_LOG_INFO, "no rows found"); 967 psFree(output); 968 return true; 969 } 970 971 // negative simple so the default is true 972 if (!ippdbPrintMetadatas(stdout, output, "camPendingCleanupRun", !simple)) { 973 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 974 psFree(output); 975 return false; 976 } 977 978 psFree(output); 979 980 return true; 981 } 982 983 984 static bool pendingcleanupexpMode(pxConfig *config) 985 { 986 PS_ASSERT_PTR_NON_NULL(config, NULL); 987 988 PXOPT_LOOKUP_S64(cam_id, config->args, "-cam_id", false, false); 989 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 990 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 991 992 psMetadata *where = psMetadataAlloc(); 993 if (cam_id) { 994 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); 995 } 996 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 997 998 psString query = pxDataGet("camtool_pendingcleanupexp.sql"); 999 if (!query) { 1000 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1001 return false; 1002 } 1003 1004 if (where && psListLength(where->list)) { 1005 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1006 psStringAppend(&query, " AND %s", whereClause); 1007 psFree(whereClause); 1008 } 1009 psFree(where); 1010 1011 // treat limit == 0 as "no limit" 1012 if (limit) { 1013 psString limitString = psDBGenerateLimitSQL(limit); 1014 psStringAppend(&query, " %s", limitString); 1015 psFree(limitString); 1016 } 1017 1018 if (!p_psDBRunQuery(config->dbh, query)) { 1019 psError(PS_ERR_UNKNOWN, false, "database error"); 1020 psFree(query); 1021 return false; 1022 } 1023 psFree(query); 1024 1025 psArray *output = p_psDBFetchResult(config->dbh); 1026 if (!output) { 1027 psError(PS_ERR_UNKNOWN, false, "database error"); 1028 return false; 1029 } 1030 if (!psArrayLength(output)) { 1031 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1032 psFree(output); 1033 return true; 1034 } 1035 1036 // negative simple so the default is true 1037 if (!ippdbPrintMetadatas(stdout, output, "camPendingCleanupExp", !simple)) { 1038 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1039 psFree(output); 1040 return false; 1041 } 1042 1043 psFree(output); 1044 1045 return true; 1046 } 1047 1048 1049 static bool donecleanupMode(pxConfig *config) 1050 { 1051 PS_ASSERT_PTR_NON_NULL(config, NULL); 1052 1053 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1054 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1055 1056 psMetadata *where = psMetadataAlloc(); 1057 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1058 1059 psString query = pxDataGet("camtool_donecleanup.sql"); 1060 if (!query) { 1061 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1062 return false; 1063 } 1064 1065 if (where && psListLength(where->list)) { 1066 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1067 psStringAppend(&query, " AND %s", whereClause); 1068 psFree(whereClause); 1069 } 1070 psFree(where); 1071 1072 // treat limit == 0 as "no limit" 1073 if (limit) { 1074 psString limitString = psDBGenerateLimitSQL(limit); 1075 psStringAppend(&query, " %s", limitString); 1076 psFree(limitString); 1077 } 1078 1079 if (!p_psDBRunQuery(config->dbh, query)) { 1080 psError(PS_ERR_UNKNOWN, false, "database error"); 1081 psFree(query); 1082 return false; 1083 } 1084 psFree(query); 1085 1086 psArray *output = p_psDBFetchResult(config->dbh); 1087 if (!output) { 1088 psError(PS_ERR_UNKNOWN, false, "database error"); 1089 return false; 1090 } 1091 if (!psArrayLength(output)) { 1092 psTrace("camtool", PS_LOG_INFO, "no rows found"); 1093 psFree(output); 1094 return true; 1095 } 1096 1097 // negative simple so the default is true 1098 if (!ippdbPrintMetadatas(stdout, output, "camDoneCleanup", !simple)) { 1099 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1100 psFree(output); 1101 return false; 1102 } 1103 1104 psFree(output); 1105 1106 return true; 1107 }
Note:
See TracChangeset
for help on using the changeset viewer.
