Changeset 11731
- Timestamp:
- Feb 9, 2007, 11:56:47 AM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
-
warptool.c (modified) (7 diffs)
-
warptool.h (modified) (1 diff)
-
warptoolConfig.c (modified) (2 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 } -
trunk/ippTools/src/warptool.h
r11723 r11731 26 26 P4TOOL_MODE_NONE = 0x0, 27 27 P4TOOL_MODE_DEFINERUN, 28 P4TOOL_MODE_UPDATERUN, 28 29 P4TOOL_MODE_ADDINPUTEXP, 29 30 P4TOOL_MODE_TOSCFILE, -
trunk/ippTools/src/warptoolConfig.c
r11723 r11731 56 56 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple", 0, 57 57 "use the simple output format", false); 58 59 // -updaterun 60 psMetadata *updaterunArgs = psMetadataAlloc(); 61 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-p4_id", 0, 62 "define p4 ID (required)", NULL); 63 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, 64 "set state (required)", NULL); 65 #if 0 66 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-workdir", 0, 67 "define workdir (required)", NULL); 68 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-registered", 0, 69 "time detrend run was registered", now); 70 #endif 58 71 59 72 // -addinputexp … … 194 207 // find which mode we're running under 195 208 PXTOOL_MODE("-definerun", P4TOOL_MODE_DEFINERUN, definerunArgs); 209 PXTOOL_MODE("-updaterun", P4TOOL_MODE_UPDATERUN, updaterunArgs); 196 210 PXTOOL_MODE("-addinputexp", P4TOOL_MODE_ADDINPUTEXP, addinputexpArgs); 197 211 PXTOOL_MODE("-toscfile", P4TOOL_MODE_TOSCFILE, toscfileArgs);
Note:
See TracChangeset
for help on using the changeset viewer.
