Fossil SCM

s/fossil_is_json/fossil_has_json/g. Moved fossil_has_json() (nee fossil_is_json()) decl/docs to json_detail.h.

stephan 2011-10-19 21:13 json-multitag-test
Commit d2c1ae23a90b24f6ca1d7637193a59d5ecf3e680
+3 -18
--- src/json.c
+++ src/json.c
@@ -185,26 +185,11 @@
185185
#define END_TIMER 0.0
186186
#define HAS_TIMER 0
187187
#endif
188188
189189
190
-/*
191
-** Returns true if fossil is running in JSON mode and we are either
192
-** running in HTTP mode OR g.json.post.o is not NULL (meaning POST
193
-** data was fed in from CLI mode).
194
-**
195
-** Specifically, it will return false when any of these apply:
196
-**
197
-** a) Not running in JSON mode (via json command or /json path).
198
-**
199
-** b) We are running in JSON CLI mode, but no POST data has been fed
200
-** in.
201
-**
202
-** Whether or not we need to take args from CLI or POST data makes a
203
-** difference in argument/parameter handling in many JSON rountines.
204
-*/
205
-char fossil_is_json(){
190
+char fossil_has_json(){
206191
return g.json.isJsonMode && (g.isHTTP || g.json.post.o);
207192
}
208193
209194
/*
210195
** Placeholder /json/XXX page impl for NYI (Not Yet Implemented)
@@ -586,11 +571,11 @@
586571
assert(NULL != zKey);
587572
if(!g.isHTTP){
588573
rc = find_option(zCLILong ? zCLILong : zKey,
589574
zCLIShort, 1);
590575
}
591
- if(!rc && fossil_is_json()){
576
+ if(!rc && fossil_has_json()){
592577
rc = json_getenv_cstr(zKey);
593578
}
594579
if(!rc && (argPos>=0)){
595580
rc = json_command_arg((unsigned char)argPos);
596581
}
@@ -616,11 +601,11 @@
616601
if(NULL != find_option(zCLILong ? zCLILong : zKey,
617602
zCLIShort, 0)){
618603
rc = 1;
619604
}
620605
}
621
- if((-1==rc) && fossil_is_json()){
606
+ if((-1==rc) && fossil_has_json()){
622607
rc = json_getenv_bool(zKey,-1);
623608
}
624609
return (-1==rc) ? dflt : rc;
625610
}
626611
627612
--- src/json.c
+++ src/json.c
@@ -185,26 +185,11 @@
185 #define END_TIMER 0.0
186 #define HAS_TIMER 0
187 #endif
188
189
190 /*
191 ** Returns true if fossil is running in JSON mode and we are either
192 ** running in HTTP mode OR g.json.post.o is not NULL (meaning POST
193 ** data was fed in from CLI mode).
194 **
195 ** Specifically, it will return false when any of these apply:
196 **
197 ** a) Not running in JSON mode (via json command or /json path).
198 **
199 ** b) We are running in JSON CLI mode, but no POST data has been fed
200 ** in.
201 **
202 ** Whether or not we need to take args from CLI or POST data makes a
203 ** difference in argument/parameter handling in many JSON rountines.
204 */
205 char fossil_is_json(){
206 return g.json.isJsonMode && (g.isHTTP || g.json.post.o);
207 }
208
209 /*
210 ** Placeholder /json/XXX page impl for NYI (Not Yet Implemented)
@@ -586,11 +571,11 @@
586 assert(NULL != zKey);
587 if(!g.isHTTP){
588 rc = find_option(zCLILong ? zCLILong : zKey,
589 zCLIShort, 1);
590 }
591 if(!rc && fossil_is_json()){
592 rc = json_getenv_cstr(zKey);
593 }
594 if(!rc && (argPos>=0)){
595 rc = json_command_arg((unsigned char)argPos);
596 }
@@ -616,11 +601,11 @@
616 if(NULL != find_option(zCLILong ? zCLILong : zKey,
617 zCLIShort, 0)){
618 rc = 1;
619 }
620 }
621 if((-1==rc) && fossil_is_json()){
622 rc = json_getenv_bool(zKey,-1);
623 }
624 return (-1==rc) ? dflt : rc;
625 }
626
627
--- src/json.c
+++ src/json.c
@@ -185,26 +185,11 @@
185 #define END_TIMER 0.0
186 #define HAS_TIMER 0
187 #endif
188
189
190 char fossil_has_json(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191 return g.json.isJsonMode && (g.isHTTP || g.json.post.o);
192 }
193
194 /*
195 ** Placeholder /json/XXX page impl for NYI (Not Yet Implemented)
@@ -586,11 +571,11 @@
571 assert(NULL != zKey);
572 if(!g.isHTTP){
573 rc = find_option(zCLILong ? zCLILong : zKey,
574 zCLIShort, 1);
575 }
576 if(!rc && fossil_has_json()){
577 rc = json_getenv_cstr(zKey);
578 }
579 if(!rc && (argPos>=0)){
580 rc = json_command_arg((unsigned char)argPos);
581 }
@@ -616,11 +601,11 @@
601 if(NULL != find_option(zCLILong ? zCLILong : zKey,
602 zCLIShort, 0)){
603 rc = 1;
604 }
605 }
606 if((-1==rc) && fossil_has_json()){
607 rc = json_getenv_bool(zKey,-1);
608 }
609 return (-1==rc) ? dflt : rc;
610 }
611
612
--- src/json_branch.c
+++ src/json_branch.c
@@ -77,11 +77,11 @@
7777
}
7878
payV = cson_value_new_object();
7979
pay = cson_value_get_object(payV);
8080
listV = cson_value_new_array();
8181
list = cson_value_get_array(listV);
82
- if(fossil_is_json()){
82
+ if(fossil_has_json()){
8383
range = json_getenv_cstr("range");
8484
}
8585
8686
range = json_find_option_cstr("range",NULL,"r");
8787
if((!range||!*range) && !g.isHTTP){
@@ -326,11 +326,11 @@
326326
json_set_err(FSL_JSON_E_DENIED,
327327
"Requires 'i' permissions.");
328328
return NULL;
329329
}
330330
memset(&opt,0,sizeof(BranchCreateOptions));
331
- if(fossil_is_json()){
331
+ if(fossil_has_json()){
332332
opt.zName = json_getenv_cstr("name");
333333
}
334334
335335
if(!opt.zName){
336336
opt.zName = json_command_arg(g.json.dispatchDepth+1);
337337
--- src/json_branch.c
+++ src/json_branch.c
@@ -77,11 +77,11 @@
77 }
78 payV = cson_value_new_object();
79 pay = cson_value_get_object(payV);
80 listV = cson_value_new_array();
81 list = cson_value_get_array(listV);
82 if(fossil_is_json()){
83 range = json_getenv_cstr("range");
84 }
85
86 range = json_find_option_cstr("range",NULL,"r");
87 if((!range||!*range) && !g.isHTTP){
@@ -326,11 +326,11 @@
326 json_set_err(FSL_JSON_E_DENIED,
327 "Requires 'i' permissions.");
328 return NULL;
329 }
330 memset(&opt,0,sizeof(BranchCreateOptions));
331 if(fossil_is_json()){
332 opt.zName = json_getenv_cstr("name");
333 }
334
335 if(!opt.zName){
336 opt.zName = json_command_arg(g.json.dispatchDepth+1);
337
--- src/json_branch.c
+++ src/json_branch.c
@@ -77,11 +77,11 @@
77 }
78 payV = cson_value_new_object();
79 pay = cson_value_get_object(payV);
80 listV = cson_value_new_array();
81 list = cson_value_get_array(listV);
82 if(fossil_has_json()){
83 range = json_getenv_cstr("range");
84 }
85
86 range = json_find_option_cstr("range",NULL,"r");
87 if((!range||!*range) && !g.isHTTP){
@@ -326,11 +326,11 @@
326 json_set_err(FSL_JSON_E_DENIED,
327 "Requires 'i' permissions.");
328 return NULL;
329 }
330 memset(&opt,0,sizeof(BranchCreateOptions));
331 if(fossil_has_json()){
332 opt.zName = json_getenv_cstr("name");
333 }
334
335 if(!opt.zName){
336 opt.zName = json_command_arg(g.json.dispatchDepth+1);
337
--- src/json_detail.h
+++ src/json_detail.h
@@ -227,7 +227,26 @@
227227
** time the variadic form was introduced we already had use cases
228228
** which segfaulted via json_new_string() because they contain printf
229229
** markup (e.g. wiki content). Been there, debugged that.
230230
*/
231231
cson_value * json_new_string_f( char const * fmt, ... );
232
+
233
+/*
234
+** Returns true if fossil is running in JSON mode and we are either
235
+** running in HTTP mode OR g.json.post.o is not NULL (meaning POST
236
+** data was fed in from CLI mode).
237
+**
238
+** Specifically, it will return false when any of these apply:
239
+**
240
+** a) Not running in JSON mode (via json command or /json path).
241
+**
242
+** b) We are running in JSON CLI mode, but no POST data has been fed
243
+** in.
244
+**
245
+** Whether or not we need to take args from CLI or POST data makes a
246
+** difference in argument/parameter handling in many JSON rountines,
247
+** and thus this distinction.
248
+*/
249
+char fossil_has_json();
250
+
232251
233252
#endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/
234253
--- src/json_detail.h
+++ src/json_detail.h
@@ -227,7 +227,26 @@
227 ** time the variadic form was introduced we already had use cases
228 ** which segfaulted via json_new_string() because they contain printf
229 ** markup (e.g. wiki content). Been there, debugged that.
230 */
231 cson_value * json_new_string_f( char const * fmt, ... );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
233 #endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/
234
--- src/json_detail.h
+++ src/json_detail.h
@@ -227,7 +227,26 @@
227 ** time the variadic form was introduced we already had use cases
228 ** which segfaulted via json_new_string() because they contain printf
229 ** markup (e.g. wiki content). Been there, debugged that.
230 */
231 cson_value * json_new_string_f( char const * fmt, ... );
232
233 /*
234 ** Returns true if fossil is running in JSON mode and we are either
235 ** running in HTTP mode OR g.json.post.o is not NULL (meaning POST
236 ** data was fed in from CLI mode).
237 **
238 ** Specifically, it will return false when any of these apply:
239 **
240 ** a) Not running in JSON mode (via json command or /json path).
241 **
242 ** b) We are running in JSON CLI mode, but no POST data has been fed
243 ** in.
244 **
245 ** Whether or not we need to take args from CLI or POST data makes a
246 ** difference in argument/parameter handling in many JSON rountines,
247 ** and thus this distinction.
248 */
249 char fossil_has_json();
250
251
252 #endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/
253
+6 -6
--- src/json_tag.c
+++ src/json_tag.c
@@ -69,11 +69,11 @@
6969
fRaw = json_find_option_bool("raw",NULL,NULL,0);
7070
fPropagate = json_find_option_bool("propagate",NULL,NULL,0);
7171
zName = json_find_option_cstr("name",NULL,NULL);
7272
zPrefix = fRaw ? "" : "sym-";
7373
if(!zName || !*zName){
74
- if(!fossil_is_json()){
74
+ if(!fossil_has_json()){
7575
zName = json_command_arg(3);
7676
}
7777
if(!zName || !*zName){
7878
json_set_err(FSL_JSON_E_MISSING_ARGS,
7979
"'name' parameter is missing.");
@@ -81,11 +81,11 @@
8181
}
8282
}
8383
8484
zCheckin = json_find_option_cstr("checkin",NULL,NULL);
8585
if( !zCheckin ){
86
- if(!fossil_is_json()){
86
+ if(!fossil_has_json()){
8787
zCheckin = json_command_arg(4);
8888
}
8989
if(!zCheckin || !*zCheckin){
9090
json_set_err(FSL_JSON_E_MISSING_ARGS,
9191
"'checkin' parameter is missing.");
@@ -93,11 +93,11 @@
9393
}
9494
}
9595
9696
9797
zValue = json_find_option_cstr("value",NULL,NULL);
98
- if(!zValue && !fossil_is_json()){
98
+ if(!zValue && !fossil_has_json()){
9999
zValue = json_command_arg(5);
100100
}
101101
102102
db_begin_transaction();
103103
tag_add_artifact(zPrefix, zName, zCheckin, zValue,
@@ -152,11 +152,11 @@
152152
153153
fRaw = json_find_option_bool("raw",NULL,NULL,0);
154154
zPrefix = fRaw ? "" : "sym-";
155155
zName = json_find_option_cstr("name",NULL,NULL);
156156
if(!zName || !*zName){
157
- if(!fossil_is_json()){
157
+ if(!fossil_has_json()){
158158
zName = json_command_arg(3);
159159
}
160160
if(!zName || !*zName){
161161
json_set_err(FSL_JSON_E_MISSING_ARGS,
162162
"'name' parameter is missing.");
@@ -164,11 +164,11 @@
164164
}
165165
}
166166
167167
zCheckin = json_find_option_cstr("checkin",NULL,NULL);
168168
if( !zCheckin ){
169
- if(!fossil_is_json()){
169
+ if(!fossil_has_json()){
170170
zCheckin = json_command_arg(4);
171171
}
172172
if(!zCheckin || !*zCheckin){
173173
json_set_err(FSL_JSON_E_MISSING_ARGS,
174174
"'checkin' parameter is missing.");
@@ -206,11 +206,11 @@
206206
"Requires 'o' permissions.");
207207
return NULL;
208208
}
209209
zName = json_find_option_cstr("name",NULL,NULL);
210210
if(!zName || !*zName){
211
- if(!fossil_is_json()){
211
+ if(!fossil_has_json()){
212212
zName = json_command_arg(3);
213213
}
214214
if(!zName || !*zName){
215215
json_set_err(FSL_JSON_E_MISSING_ARGS,
216216
"'name' parameter is missing.");
217217
--- src/json_tag.c
+++ src/json_tag.c
@@ -69,11 +69,11 @@
69 fRaw = json_find_option_bool("raw",NULL,NULL,0);
70 fPropagate = json_find_option_bool("propagate",NULL,NULL,0);
71 zName = json_find_option_cstr("name",NULL,NULL);
72 zPrefix = fRaw ? "" : "sym-";
73 if(!zName || !*zName){
74 if(!fossil_is_json()){
75 zName = json_command_arg(3);
76 }
77 if(!zName || !*zName){
78 json_set_err(FSL_JSON_E_MISSING_ARGS,
79 "'name' parameter is missing.");
@@ -81,11 +81,11 @@
81 }
82 }
83
84 zCheckin = json_find_option_cstr("checkin",NULL,NULL);
85 if( !zCheckin ){
86 if(!fossil_is_json()){
87 zCheckin = json_command_arg(4);
88 }
89 if(!zCheckin || !*zCheckin){
90 json_set_err(FSL_JSON_E_MISSING_ARGS,
91 "'checkin' parameter is missing.");
@@ -93,11 +93,11 @@
93 }
94 }
95
96
97 zValue = json_find_option_cstr("value",NULL,NULL);
98 if(!zValue && !fossil_is_json()){
99 zValue = json_command_arg(5);
100 }
101
102 db_begin_transaction();
103 tag_add_artifact(zPrefix, zName, zCheckin, zValue,
@@ -152,11 +152,11 @@
152
153 fRaw = json_find_option_bool("raw",NULL,NULL,0);
154 zPrefix = fRaw ? "" : "sym-";
155 zName = json_find_option_cstr("name",NULL,NULL);
156 if(!zName || !*zName){
157 if(!fossil_is_json()){
158 zName = json_command_arg(3);
159 }
160 if(!zName || !*zName){
161 json_set_err(FSL_JSON_E_MISSING_ARGS,
162 "'name' parameter is missing.");
@@ -164,11 +164,11 @@
164 }
165 }
166
167 zCheckin = json_find_option_cstr("checkin",NULL,NULL);
168 if( !zCheckin ){
169 if(!fossil_is_json()){
170 zCheckin = json_command_arg(4);
171 }
172 if(!zCheckin || !*zCheckin){
173 json_set_err(FSL_JSON_E_MISSING_ARGS,
174 "'checkin' parameter is missing.");
@@ -206,11 +206,11 @@
206 "Requires 'o' permissions.");
207 return NULL;
208 }
209 zName = json_find_option_cstr("name",NULL,NULL);
210 if(!zName || !*zName){
211 if(!fossil_is_json()){
212 zName = json_command_arg(3);
213 }
214 if(!zName || !*zName){
215 json_set_err(FSL_JSON_E_MISSING_ARGS,
216 "'name' parameter is missing.");
217
--- src/json_tag.c
+++ src/json_tag.c
@@ -69,11 +69,11 @@
69 fRaw = json_find_option_bool("raw",NULL,NULL,0);
70 fPropagate = json_find_option_bool("propagate",NULL,NULL,0);
71 zName = json_find_option_cstr("name",NULL,NULL);
72 zPrefix = fRaw ? "" : "sym-";
73 if(!zName || !*zName){
74 if(!fossil_has_json()){
75 zName = json_command_arg(3);
76 }
77 if(!zName || !*zName){
78 json_set_err(FSL_JSON_E_MISSING_ARGS,
79 "'name' parameter is missing.");
@@ -81,11 +81,11 @@
81 }
82 }
83
84 zCheckin = json_find_option_cstr("checkin",NULL,NULL);
85 if( !zCheckin ){
86 if(!fossil_has_json()){
87 zCheckin = json_command_arg(4);
88 }
89 if(!zCheckin || !*zCheckin){
90 json_set_err(FSL_JSON_E_MISSING_ARGS,
91 "'checkin' parameter is missing.");
@@ -93,11 +93,11 @@
93 }
94 }
95
96
97 zValue = json_find_option_cstr("value",NULL,NULL);
98 if(!zValue && !fossil_has_json()){
99 zValue = json_command_arg(5);
100 }
101
102 db_begin_transaction();
103 tag_add_artifact(zPrefix, zName, zCheckin, zValue,
@@ -152,11 +152,11 @@
152
153 fRaw = json_find_option_bool("raw",NULL,NULL,0);
154 zPrefix = fRaw ? "" : "sym-";
155 zName = json_find_option_cstr("name",NULL,NULL);
156 if(!zName || !*zName){
157 if(!fossil_has_json()){
158 zName = json_command_arg(3);
159 }
160 if(!zName || !*zName){
161 json_set_err(FSL_JSON_E_MISSING_ARGS,
162 "'name' parameter is missing.");
@@ -164,11 +164,11 @@
164 }
165 }
166
167 zCheckin = json_find_option_cstr("checkin",NULL,NULL);
168 if( !zCheckin ){
169 if(!fossil_has_json()){
170 zCheckin = json_command_arg(4);
171 }
172 if(!zCheckin || !*zCheckin){
173 json_set_err(FSL_JSON_E_MISSING_ARGS,
174 "'checkin' parameter is missing.");
@@ -206,11 +206,11 @@
206 "Requires 'o' permissions.");
207 return NULL;
208 }
209 zName = json_find_option_cstr("name",NULL,NULL);
210 if(!zName || !*zName){
211 if(!fossil_has_json()){
212 zName = json_command_arg(3);
213 }
214 if(!zName || !*zName){
215 json_set_err(FSL_JSON_E_MISSING_ARGS,
216 "'name' parameter is missing.");
217
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -241,11 +241,11 @@
241241
char const * arg = find_option("limit","n",1);
242242
if(arg && *arg){
243243
limit = atoi(arg);
244244
}
245245
}
246
- if( (limit<0) && fossil_is_json() ){
246
+ if( (limit<0) && fossil_has_json() ){
247247
limit = json_getenv_int("limit",-1);
248248
}
249249
return (limit<0) ? defaultLimit : limit;
250250
}
251251
252252
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -241,11 +241,11 @@
241 char const * arg = find_option("limit","n",1);
242 if(arg && *arg){
243 limit = atoi(arg);
244 }
245 }
246 if( (limit<0) && fossil_is_json() ){
247 limit = json_getenv_int("limit",-1);
248 }
249 return (limit<0) ? defaultLimit : limit;
250 }
251
252
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -241,11 +241,11 @@
241 char const * arg = find_option("limit","n",1);
242 if(arg && *arg){
243 limit = atoi(arg);
244 }
245 }
246 if( (limit<0) && fossil_has_json() ){
247 limit = json_getenv_int("limit",-1);
248 }
249 return (limit<0) ? defaultLimit : limit;
250 }
251
252
+1 -1
--- src/name.c
+++ src/name.c
@@ -366,11 +366,11 @@
366366
int name_to_rid_www(const char *zParamName){
367367
int i, rc;
368368
int rid;
369369
const char *zName = P(zParamName);
370370
Blob name;
371
- if(!zName && fossil_is_json()){
371
+ if(!zName && fossil_has_json()){
372372
zName = json_find_option_cstr(zParamName,NULL,NULL);
373373
}
374374
if( zName==0 || zName[0]==0 ) return 0;
375375
blob_init(&name, zName, -1);
376376
rc = name_to_uuid(&name, -1, "*");
377377
--- src/name.c
+++ src/name.c
@@ -366,11 +366,11 @@
366 int name_to_rid_www(const char *zParamName){
367 int i, rc;
368 int rid;
369 const char *zName = P(zParamName);
370 Blob name;
371 if(!zName && fossil_is_json()){
372 zName = json_find_option_cstr(zParamName,NULL,NULL);
373 }
374 if( zName==0 || zName[0]==0 ) return 0;
375 blob_init(&name, zName, -1);
376 rc = name_to_uuid(&name, -1, "*");
377
--- src/name.c
+++ src/name.c
@@ -366,11 +366,11 @@
366 int name_to_rid_www(const char *zParamName){
367 int i, rc;
368 int rid;
369 const char *zName = P(zParamName);
370 Blob name;
371 if(!zName && fossil_has_json()){
372 zName = json_find_option_cstr(zParamName,NULL,NULL);
373 }
374 if( zName==0 || zName[0]==0 ) return 0;
375 blob_init(&name, zName, -1);
376 rc = name_to_uuid(&name, -1, "*");
377

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button