Changeset 11731 for trunk/ippTools/src/warptool.c
- Timestamp:
- Feb 9, 2007, 11:56:47 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/warptool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/warptool.c
r11723 r11731 32 32 33 33 static bool definerunMode(pxConfig *config); 34 static bool updaterunMode(pxConfig *config); 34 35 static bool addinputexpMode(pxConfig *config); 35 36 static bool toscfileMode(pxConfig *config); … … 43 44 static bool diffimfileMode(pxConfig *config); 44 45 46 static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state); 47 static bool isValidMode(pxConfig *config, const char *mode); 48 45 49 # define MODECASE(caseName, func) \ 46 50 case caseName: \ … … 58 62 switch (config->mode) { 59 63 MODECASE(P4TOOL_MODE_DEFINERUN, definerunMode); 64 MODECASE(P4TOOL_MODE_UPDATERUN, updaterunMode); 60 65 MODECASE(P4TOOL_MODE_ADDINPUTEXP, addinputexpMode); 61 66 MODECASE(P4TOOL_MODE_TOSCFILE, toscfileMode); … … 88 93 } 89 94 95 90 96 static bool definerunMode(pxConfig *config) 91 97 { … … 101 107 if (!mode) { 102 108 psError(PS_ERR_UNKNOWN, true, "-mode is required"); 109 return false; 110 } 111 // check mode 112 if (mode && !isValidMode(config, mode)) { 113 psError(PS_ERR_UNKNOWN, false, "invalud mode"); 103 114 return false; 104 115 } … … 168 179 return true; 169 180 } 181 182 183 static bool updaterunMode(pxConfig *config) 184 { 185 PS_ASSERT_PTR_NON_NULL(config, false); 186 187 bool status = false; 188 psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id"); 189 if (!status) { 190 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4t_id"); 191 return false; 192 } 193 if (!p4_id) { 194 psError(PS_ERR_UNKNOWN, true, "-p4_id is required"); 195 return false; 196 } 197 198 psString state = psMetadataLookupStr(&status, config->args, "-state"); 199 if (!status) { 200 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 201 return false; 202 } 203 if (!state) { 204 psError(PS_ERR_UNKNOWN, true, "-state is required"); 205 return false; 206 } 207 208 if (state) { 209 // set detRun.state to state 210 return setp4RunState(config, p4_id, state); 211 } 212 213 return true; 214 } 215 170 216 171 217 static bool addinputexpMode(pxConfig *config) … … 857 903 return true; 858 904 } 905 906 static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state) 907 { 908 PS_ASSERT_PTR_NON_NULL(p4_id, false); 909 PS_ASSERT_PTR_NON_NULL(state, false); 910 911 // check that state is a valid string value 912 if (!( 913 (strncmp(state, "run", 4) == 0) 914 || (strncmp(state, "stop", 5) == 0) 915 || (strncmp(state, "reg", 4) == 0) 916 ) 917 ) { 918 psError(PS_ERR_UNKNOWN, false, 919 "invalid p4Run state: %s", state); 920 return false; 921 } 922 923 char *query = "UPDATE p4Run SET state = '%s' WHERE det_id = '%s'"; 924 if (!p_psDBRunQuery(config->dbh, query, state, p4_id)) { 925 psError(PS_ERR_UNKNOWN, false, 926 "failed to change state for det_id %s", p4_id); 927 return false; 928 } 929 930 return true; 931 } 932 933 static bool isValidMode(pxConfig *config, const char *mode) 934 { 935 PS_ASSERT_PTR_NON_NULL(config, false); 936 PS_ASSERT_PTR_NON_NULL(mode, false); 937 938 // check that state is a valid string value 939 if (!( 940 (strncmp(mode, "master", 7) == 0) 941 || (strncmp(mode, "verify", 7) == 0) 942 ) 943 ) { 944 psError(PS_ERR_UNKNOWN, false, 945 "invalid detRun mode: %s", mode); 946 return false; 947 } 948 949 return true; 950 }
Note:
See TracChangeset
for help on using the changeset viewer.
