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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
cson_value * json_artifact_file(int rid){
cson_value * payV = NULL;
cson_object * pay = NULL;
const char *zMime;
Blob content = empty_blob;
Stmt q = empty_Stmt;
cson_array * checkin_arr = NULL;
if( ! g.perm.Read ){
json_set_err(FSL_JSON_E_DENIED,
"Requires 'o' privileges.");
return NULL;
}
payV = cson_value_new_object();
pay = cson_value_get_object(payV);
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);
cson_object_set(pay, "contentType",
json_new_string(zMime ? zMime : "text/plain"));
if( json_artifact_include_content_flag() && !zMime ){
#if 0
/*see next #if block below*/
cson_string * tagKey = NULL;
cson_value * checkinV = NULL;
cson_object * checkin = NULL;
#endif
cson_object_set(pay, "content",
cson_value_new_string(blob_str(&content),
(unsigned int)blob_size(&content)));
}
blob_reset(&content);
db_prepare(&q,
|
>
>
>
>
>
>
<
<
<
<
<
<
|
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
cson_value * json_artifact_file(int rid){
cson_value * payV = NULL;
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;
}
payV = cson_value_new_object();
pay = cson_value_get_object(payV);
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);
cson_object_set(pay, "contentType",
json_new_string(zMime ? zMime : "text/plain"));
if( json_artifact_include_content_flag() && !zMime ){
cson_object_set(pay, "content",
cson_value_new_string(blob_str(&content),
(unsigned int)blob_size(&content)));
}
blob_reset(&content);
db_prepare(&q,
|