Changeset 17171 for trunk/ippTools/src/pxcam.c
- Timestamp:
- Mar 28, 2008, 11:17:03 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pxcam.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pxcam.c
r16170 r17171 31 31 bool pxcamRunSetState(pxConfig *config, psS64 cam_id, const char *state) 32 32 { 33 PS_ASSERT_PTR_NON_NULL(config, false); 33 34 PS_ASSERT_PTR_NON_NULL(state, false); 34 35 … … 51 52 return false; 52 53 } 54 55 return true; 56 } 57 58 59 bool pxcamRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state) 60 { 61 PS_ASSERT_PTR_NON_NULL(config, false); 62 PS_ASSERT_PTR_NON_NULL(state, false); 63 64 // check that state is a valid string value 65 if (!( 66 (strncmp(state, "run", 4) == 0) 67 || (strncmp(state, "stop", 5) == 0) 68 || (strncmp(state, "reg", 4) == 0) 69 ) 70 ) { 71 psError(PS_ERR_UNKNOWN, false, 72 "invalid chipRun state: %s", state); 73 return false; 74 } 75 76 psString query = psStringCopy("UPDATE camRun JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET state = '%s'"); 77 78 if (where) { 79 psString whereClause = psDBGenerateWhereSQL(where, NULL); 80 psStringAppend(&query, " %s", whereClause); 81 psFree(whereClause); 82 } 83 84 if (!p_psDBRunQuery(config->dbh, query, state)) { 85 psFree(query); 86 psError(PS_ERR_UNKNOWN, false, "database error"); 87 return false; 88 } 89 90 psFree(query); 91 92 return true; 93 } 94 95 96 bool pxcamRunSetLabel(pxConfig *config, psS64 cam_id, const char *label) 97 { 98 PS_ASSERT_PTR_NON_NULL(config, false); 99 // note label == NULL should be explicitly allowed 100 101 char *query = "UPDATE camRun SET camRun.label = '%s' WHERE cam_id = %" PRId64; 102 if (!p_psDBRunQuery(config->dbh, query, label, cam_id)) { 103 psError(PS_ERR_UNKNOWN, false, 104 "failed to change state for cam_id %" PRId64, cam_id); 105 return false; 106 } 107 108 return true; 109 } 110 111 112 bool pxcamRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label) 113 { 114 PS_ASSERT_PTR_NON_NULL(config, false); 115 // note label == NULL should be explicitly allowed 116 117 psString query = psStringCopy("UPDATE camRun JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET camRun.label = '%s'"); 118 119 if (where) { 120 psString whereClause = psDBGenerateWhereSQL(where, NULL); 121 psStringAppend(&query, " %s", whereClause); 122 psFree(whereClause); 123 } 124 125 if (!p_psDBRunQuery(config->dbh, query, label)) { 126 psFree(query); 127 psError(PS_ERR_UNKNOWN, false, "database error"); 128 return false; 129 } 130 131 psFree(query); 53 132 54 133 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
