Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | minor code simplifications. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | json-multitag-test | json |
| Files: | files | file ages | folders |
| SHA1: |
400fe340c25f191b8f24c54ec9d92ec8 |
| User & Date: | stephan 2011-10-20 18:48:17.362 |
Context
|
2011-10-21
| ||
| 15:25 | Fixed a minor mem leak. Got /json/user/save mostly working. check-in: 080acb91be user: stephan tags: json-multitag-test, json | |
|
2011-10-20
| ||
| 18:48 | minor code simplifications. check-in: 400fe340c2 user: stephan tags: json-multitag-test, json | |
| 18:28 | fixed a type conversion error caused by last round of refactoring. check-in: f566811477 user: stephan tags: json-multitag-test, json | |
Changes
Changes to src/json_artifact.c.
| ︙ | ︙ | |||
156 157 158 159 160 161 162 |
return v;
}
/*
** Very incomplete/incorrect impl of /json/artifact/TICKET_ID.
*/
cson_value * json_artifact_ticket( int rid ){
| < | < | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
return v;
}
/*
** Very incomplete/incorrect impl of /json/artifact/TICKET_ID.
*/
cson_value * json_artifact_ticket( int rid ){
cson_object * pay = NULL;
Manifest *pTktChng = NULL;
static cson_value * eventTypeLabel = NULL;
if(! g.perm.RdTkt ){
g.json.resultCode = FSL_JSON_E_DENIED;
return NULL;
}
if(!eventTypeLabel){
eventTypeLabel = json_new_string("ticket");
json_gc_add("$EVENT_TYPE_LABEL(ticket)", eventTypeLabel);
}
pTktChng = manifest_get(rid, CFTYPE_TICKET);
if( pTktChng==0 ){
g.json.resultCode = FSL_JSON_E_MANIFEST_READ_FAILED;
return NULL;
}
pay = cson_new_object();
cson_object_set(pay, "eventType", eventTypeLabel );
cson_object_set(pay, "uuid", json_new_string(pTktChng->zTicketUuid));
cson_object_set(pay, "user", json_new_string(pTktChng->zUser));
cson_object_set(pay, "timestamp", json_julian_to_timestamp(pTktChng->rDate));
manifest_destroy(pTktChng);
return cson_object_value(pay);
}
/*
** Sub-impl of /json/artifact for checkins.
*/
static cson_value * json_artifact_ci( int rid ){
if(! g.perm.Read ){
|
| ︙ | ︙ | |||
228 229 230 231 232 233 234 |
return NULL;
}else{
return json_get_wiki_page_by_rid(rid, 0);
}
}
cson_value * json_artifact_file(int rid){
| < | < | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
return NULL;
}else{
return json_get_wiki_page_by_rid(rid, 0);
}
}
cson_value * json_artifact_file(int rid){
cson_object * pay = NULL;
const char *zMime;
Blob content = empty_blob;
Stmt q = empty_Stmt;
cson_array * checkin_arr = NULL;
#if 0
/*see next #if block below*/
cson_string * tagKey = NULL;
cson_value * checkinV = NULL;
cson_object * checkin = NULL;
#endif
if( ! g.perm.Read ){
json_set_err(FSL_JSON_E_DENIED,
"Requires 'o' privileges.");
return NULL;
}
pay = cson_new_object();
content_get(rid, &content);
cson_object_set(pay, "contentLength",
json_new_int( blob_size(&content) )
/* achtung: overflow potential on 32-bit builds! */);
zMime = mimetype_from_content(&content);
|
| ︙ | ︙ | |||
309 310 311 312 313 314 315 |
cson_object_set_s(checkin, tagKey, json_tags_for_rid(rid,0));
cson_array_append( checkin_arr, checkinV );
}
#else
json_stmt_to_array_of_obj( &q, checkin_arr );
#endif
db_finalize(&q);
| | < | < < | | | | < | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
cson_object_set_s(checkin, tagKey, json_tags_for_rid(rid,0));
cson_array_append( checkin_arr, checkinV );
}
#else
json_stmt_to_array_of_obj( &q, checkin_arr );
#endif
db_finalize(&q);
return cson_object_value(pay);
}
/*
** Impl of /json/artifact. This basically just determines the type of
** an artifact and forwards the real work to another function.
*/
cson_value * json_page_artifact(){
cson_object * pay = NULL;
char const * zName = NULL;
char const * zType = NULL;
char const * zUuid = NULL;
cson_value * entry = NULL;
Blob uuid = empty_blob;
int rc;
int rid = 0;
ArtifactDispatchEntry const * dispatcher = &ArtifactDispatchList[0];
zName = json_find_option_cstr2("uuid", NULL, NULL, 2);
if(!zName || !*zName) {
json_set_err(FSL_JSON_E_MISSING_ARGS,
"Missing 'uuid' argument.");
return NULL;
}
if( validate16(zName, strlen(zName)) ){
if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
zType = "ticket";
goto handle_entry;
}
|
| ︙ | ︙ | |||
401 402 403 404 405 406 407 |
entry = (*dispatcher->func)(rid);
break;
}
}
if(!g.json.resultCode){
assert( NULL != entry );
assert( NULL != zType );
| | < < < | | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
entry = (*dispatcher->func)(rid);
break;
}
}
if(!g.json.resultCode){
assert( NULL != entry );
assert( NULL != zType );
pay = cson_new_object();
cson_object_set( pay, "type", json_new_string(zType) );
/*cson_object_set( pay, "uuid", json_new_string(zUuid) );*/
cson_object_set( pay, "name", json_new_string(zName ? zName : zUuid) );
cson_object_set( pay, "rid", cson_value_new_integer(rid) );
if(entry){
cson_object_set(pay, "artifact", entry);
}
}
veryend:
blob_reset(&uuid);
return cson_object_value(pay);
}
|