Fossil SCM

Pulled in latest cson amalgamation for the cson_type_id addition and started refactoring some O(N) lookups to O(1) based on that addition.

stephan 2012-07-05 19:03 trunk
Commit cde55bd7a3dc7c5eeb920ff085de1c72955aed1d
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -1422,48 +1422,10 @@
14221422
extern "C" {
14231423
#endif
14241424
14251425
14261426
1427
-/**
1428
- Type IDs corresponding to JavaScript/JSON types.
1429
-*/
1430
-enum cson_type_id {
1431
- /**
1432
- The special "undefined" value constant.
1433
-
1434
- Its value must be 0 for internal reasons.
1435
- */
1436
- CSON_TYPE_UNDEF = 0,
1437
- /**
1438
- The special "null" value constant.
1439
- */
1440
- CSON_TYPE_NULL = 1,
1441
- /**
1442
- The bool value type.
1443
- */
1444
- CSON_TYPE_BOOL = 2,
1445
- /**
1446
- The integer value type, represented in this library
1447
- by cson_int_t.
1448
- */
1449
- CSON_TYPE_INTEGER = 3,
1450
- /**
1451
- The double value type, represented in this library
1452
- by cson_double_t.
1453
- */
1454
- CSON_TYPE_DOUBLE = 4,
1455
- /** The immutable string type. This library stores strings
1456
- as immutable UTF8.
1457
- */
1458
- CSON_TYPE_STRING = 5,
1459
- /** The "Array" type. */
1460
- CSON_TYPE_ARRAY = 6,
1461
- /** The "Object" type. */
1462
- CSON_TYPE_OBJECT = 7
1463
-};
1464
-typedef enum cson_type_id cson_type_id;
14651427
14661428
/**
14671429
This type holds the "vtbl" for type-specific operations when
14681430
working with cson_value objects.
14691431
@@ -2314,16 +2276,14 @@
23142276
{
23152277
return (v && v->api && (v->api->typeID == is)) ? 1 : 0;
23162278
}
23172279
#endif
23182280
2319
-#if 0
23202281
cson_type_id cson_value_type_id( cson_value const * v )
23212282
{
23222283
return (v && v->api) ? v->api->typeID : CSON_TYPE_UNDEF;
23232284
}
2324
-#endif
23252285
23262286
char cson_value_is_undef( cson_value const * v )
23272287
{
23282288
return ( !v || !v->api || (v->api==&cson_value_api_undef))
23292289
? 1 : 0;
@@ -4472,11 +4432,11 @@
44724432
44734433
- (separator) = the separator character
44744434
44754435
- (end) = a pointer to NULL. i.e. (*end == NULL)
44764436
4477
-This function scans *inp for the given separator char or a NULL char.
4437
+This function scans *inp for the given separator char or a NUL char.
44784438
Successive separators at the start of *inp are skipped. The effect is
44794439
that, when this function is called in a loop, all neighboring
44804440
separators are ignored. e.g. the string "aa.bb...cc" will tokenize to
44814441
the list (aa,bb,cc) if the separator is '.' and to (aa.,...cc) if the
44824442
separator is 'b'.
44834443
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -1422,48 +1422,10 @@
1422 extern "C" {
1423 #endif
1424
1425
1426
1427 /**
1428 Type IDs corresponding to JavaScript/JSON types.
1429 */
1430 enum cson_type_id {
1431 /**
1432 The special "undefined" value constant.
1433
1434 Its value must be 0 for internal reasons.
1435 */
1436 CSON_TYPE_UNDEF = 0,
1437 /**
1438 The special "null" value constant.
1439 */
1440 CSON_TYPE_NULL = 1,
1441 /**
1442 The bool value type.
1443 */
1444 CSON_TYPE_BOOL = 2,
1445 /**
1446 The integer value type, represented in this library
1447 by cson_int_t.
1448 */
1449 CSON_TYPE_INTEGER = 3,
1450 /**
1451 The double value type, represented in this library
1452 by cson_double_t.
1453 */
1454 CSON_TYPE_DOUBLE = 4,
1455 /** The immutable string type. This library stores strings
1456 as immutable UTF8.
1457 */
1458 CSON_TYPE_STRING = 5,
1459 /** The "Array" type. */
1460 CSON_TYPE_ARRAY = 6,
1461 /** The "Object" type. */
1462 CSON_TYPE_OBJECT = 7
1463 };
1464 typedef enum cson_type_id cson_type_id;
1465
1466 /**
1467 This type holds the "vtbl" for type-specific operations when
1468 working with cson_value objects.
1469
@@ -2314,16 +2276,14 @@
2314 {
2315 return (v && v->api && (v->api->typeID == is)) ? 1 : 0;
2316 }
2317 #endif
2318
2319 #if 0
2320 cson_type_id cson_value_type_id( cson_value const * v )
2321 {
2322 return (v && v->api) ? v->api->typeID : CSON_TYPE_UNDEF;
2323 }
2324 #endif
2325
2326 char cson_value_is_undef( cson_value const * v )
2327 {
2328 return ( !v || !v->api || (v->api==&cson_value_api_undef))
2329 ? 1 : 0;
@@ -4472,11 +4432,11 @@
4472
4473 - (separator) = the separator character
4474
4475 - (end) = a pointer to NULL. i.e. (*end == NULL)
4476
4477 This function scans *inp for the given separator char or a NULL char.
4478 Successive separators at the start of *inp are skipped. The effect is
4479 that, when this function is called in a loop, all neighboring
4480 separators are ignored. e.g. the string "aa.bb...cc" will tokenize to
4481 the list (aa,bb,cc) if the separator is '.' and to (aa.,...cc) if the
4482 separator is 'b'.
4483
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -1422,48 +1422,10 @@
1422 extern "C" {
1423 #endif
1424
1425
1426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1427
1428 /**
1429 This type holds the "vtbl" for type-specific operations when
1430 working with cson_value objects.
1431
@@ -2314,16 +2276,14 @@
2276 {
2277 return (v && v->api && (v->api->typeID == is)) ? 1 : 0;
2278 }
2279 #endif
2280
 
2281 cson_type_id cson_value_type_id( cson_value const * v )
2282 {
2283 return (v && v->api) ? v->api->typeID : CSON_TYPE_UNDEF;
2284 }
 
2285
2286 char cson_value_is_undef( cson_value const * v )
2287 {
2288 return ( !v || !v->api || (v->api==&cson_value_api_undef))
2289 ? 1 : 0;
@@ -4472,11 +4432,11 @@
4432
4433 - (separator) = the separator character
4434
4435 - (end) = a pointer to NULL. i.e. (*end == NULL)
4436
4437 This function scans *inp for the given separator char or a NUL char.
4438 Successive separators at the start of *inp are skipped. The effect is
4439 that, when this function is called in a loop, all neighboring
4440 separators are ignored. e.g. the string "aa.bb...cc" will tokenize to
4441 the list (aa,bb,cc) if the separator is '.' and to (aa.,...cc) if the
4442 separator is 'b'.
4443
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -132,10 +132,59 @@
132132
/** @def CSON_DOUBLE_T_PFMT
133133
134134
printf()-compatible format token for cson_double_t.
135135
*/
136136
137
+/**
138
+ Type IDs corresponding to JavaScript/JSON types.
139
+
140
+ These are only in the public API to allow O(1) client-side
141
+ dispatching based on cson_value types.
142
+*/
143
+enum cson_type_id {
144
+ /**
145
+ The special "undefined" value constant.
146
+
147
+ Its value must be 0 for internal reasons.
148
+ */
149
+ CSON_TYPE_UNDEF = 0,
150
+ /**
151
+ The special "null" value constant.
152
+ */
153
+ CSON_TYPE_NULL = 1,
154
+ /**
155
+ The bool value type.
156
+ */
157
+ CSON_TYPE_BOOL = 2,
158
+ /**
159
+ The integer value type, represented in this library
160
+ by cson_int_t.
161
+ */
162
+ CSON_TYPE_INTEGER = 3,
163
+ /**
164
+ The double value type, represented in this library
165
+ by cson_double_t.
166
+ */
167
+ CSON_TYPE_DOUBLE = 4,
168
+ /** The immutable string type. This library stores strings
169
+ as immutable UTF8.
170
+ */
171
+ CSON_TYPE_STRING = 5,
172
+ /** The "Array" type. */
173
+ CSON_TYPE_ARRAY = 6,
174
+ /** The "Object" type. */
175
+ CSON_TYPE_OBJECT = 7
176
+};
177
+/**
178
+ Convenience typedef.
179
+*/
180
+typedef enum cson_type_id cson_type_id;
181
+
182
+
183
+/**
184
+ Convenience typedef.
185
+*/
137186
typedef struct cson_value cson_value;
138187
139188
/** @struct cson_value
140189
141190
The core value type of this API. It is opaque to clients, and
@@ -211,10 +260,11 @@
211260
@see cson_value_new_bool()
212261
@see cson_value_true()
213262
@see cson_value_false()
214263
@see cson_value_null()
215264
@see cson_value_free()
265
+ @see cson_value_type_id()
216266
*/
217267
218268
/** @var cson_rc
219269
220270
This object defines the error codes used by cson.
@@ -740,10 +790,16 @@
740790
any existing contents. Returns cson_rc.IOError if the file cannot be opened.
741791
742792
@see cson_output_FILE()
743793
*/
744794
int cson_output_filename( cson_value const * src, char const * dest, cson_output_opt const * fmt );
795
+
796
+/**
797
+ Returns the virtual type of v, or CSON_TYPE_UNDEF if !v.
798
+*/
799
+cson_type_id cson_value_type_id( cson_value const * v );
800
+
745801
746802
/** Returns true if v is null, v->api is NULL, or v holds the special undefined value. */
747803
char cson_value_is_undef( cson_value const * v );
748804
/** Returns true if v contains a null value. */
749805
char cson_value_is_null( cson_value const * v );
750806
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -132,10 +132,59 @@
132 /** @def CSON_DOUBLE_T_PFMT
133
134 printf()-compatible format token for cson_double_t.
135 */
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137 typedef struct cson_value cson_value;
138
139 /** @struct cson_value
140
141 The core value type of this API. It is opaque to clients, and
@@ -211,10 +260,11 @@
211 @see cson_value_new_bool()
212 @see cson_value_true()
213 @see cson_value_false()
214 @see cson_value_null()
215 @see cson_value_free()
 
216 */
217
218 /** @var cson_rc
219
220 This object defines the error codes used by cson.
@@ -740,10 +790,16 @@
740 any existing contents. Returns cson_rc.IOError if the file cannot be opened.
741
742 @see cson_output_FILE()
743 */
744 int cson_output_filename( cson_value const * src, char const * dest, cson_output_opt const * fmt );
 
 
 
 
 
 
745
746 /** Returns true if v is null, v->api is NULL, or v holds the special undefined value. */
747 char cson_value_is_undef( cson_value const * v );
748 /** Returns true if v contains a null value. */
749 char cson_value_is_null( cson_value const * v );
750
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -132,10 +132,59 @@
132 /** @def CSON_DOUBLE_T_PFMT
133
134 printf()-compatible format token for cson_double_t.
135 */
136
137 /**
138 Type IDs corresponding to JavaScript/JSON types.
139
140 These are only in the public API to allow O(1) client-side
141 dispatching based on cson_value types.
142 */
143 enum cson_type_id {
144 /**
145 The special "undefined" value constant.
146
147 Its value must be 0 for internal reasons.
148 */
149 CSON_TYPE_UNDEF = 0,
150 /**
151 The special "null" value constant.
152 */
153 CSON_TYPE_NULL = 1,
154 /**
155 The bool value type.
156 */
157 CSON_TYPE_BOOL = 2,
158 /**
159 The integer value type, represented in this library
160 by cson_int_t.
161 */
162 CSON_TYPE_INTEGER = 3,
163 /**
164 The double value type, represented in this library
165 by cson_double_t.
166 */
167 CSON_TYPE_DOUBLE = 4,
168 /** The immutable string type. This library stores strings
169 as immutable UTF8.
170 */
171 CSON_TYPE_STRING = 5,
172 /** The "Array" type. */
173 CSON_TYPE_ARRAY = 6,
174 /** The "Object" type. */
175 CSON_TYPE_OBJECT = 7
176 };
177 /**
178 Convenience typedef.
179 */
180 typedef enum cson_type_id cson_type_id;
181
182
183 /**
184 Convenience typedef.
185 */
186 typedef struct cson_value cson_value;
187
188 /** @struct cson_value
189
190 The core value type of this API. It is opaque to clients, and
@@ -211,10 +260,11 @@
260 @see cson_value_new_bool()
261 @see cson_value_true()
262 @see cson_value_false()
263 @see cson_value_null()
264 @see cson_value_free()
265 @see cson_value_type_id()
266 */
267
268 /** @var cson_rc
269
270 This object defines the error codes used by cson.
@@ -740,10 +790,16 @@
790 any existing contents. Returns cson_rc.IOError if the file cannot be opened.
791
792 @see cson_output_FILE()
793 */
794 int cson_output_filename( cson_value const * src, char const * dest, cson_output_opt const * fmt );
795
796 /**
797 Returns the virtual type of v, or CSON_TYPE_UNDEF if !v.
798 */
799 cson_type_id cson_value_type_id( cson_value const * v );
800
801
802 /** Returns true if v is null, v->api is NULL, or v holds the special undefined value. */
803 char cson_value_is_undef( cson_value const * v );
804 /** Returns true if v contains a null value. */
805 char cson_value_is_null( cson_value const * v );
806
+46 -40
--- src/json.c
+++ src/json.c
@@ -175,11 +175,13 @@
175175
#define BEGIN_TIMER
176176
#define END_TIMER 0.0
177177
#define HAS_TIMER 0
178178
#endif
179179
180
-
180
+/*
181
+** Returns true (non-0) if fossil appears to be running in JSON mode.
182
+*/
181183
char fossil_has_json(){
182184
return g.json.isJsonMode && (g.isHTTP || g.json.post.o);
183185
}
184186
185187
/*
@@ -467,25 +469,26 @@
467469
** which looks like an integer or is-a JSON bool/null then it is
468470
** converted to an int. If none of those apply then dflt is returned.
469471
*/
470472
int json_getenv_int(char const * pKey, int dflt ){
471473
cson_value const * v = json_getenv(pKey);
472
- if(!v){
473
- return dflt;
474
- }else if( cson_value_is_number(v) ){
475
- return (int)cson_value_get_integer(v);
476
- }else if( cson_value_is_string(v) ){
477
- char const * sv = cson_string_cstr(cson_value_get_string(v));
478
- assert( (NULL!=sv) && "This is quite unexpected." );
479
- return sv ? atoi(sv) : dflt;
480
- }else if( cson_value_is_bool(v) ){
481
- return cson_value_get_bool(v) ? 1 : 0;
482
- }else if( cson_value_is_null(v) ){
483
- return 0;
484
- }else{
485
- /* we should arguably treat JSON null as 0. */
486
- return dflt;
474
+ const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF;
475
+ switch(type){
476
+ case CSON_TYPE_INTEGER:
477
+ case CSON_TYPE_DOUBLE:
478
+ return (int)cson_value_get_integer(v);
479
+ case CSON_TYPE_STRING: {
480
+ char const * sv = cson_string_cstr(cson_value_get_string(v));
481
+ assert( (NULL!=sv) && "This is quite unexpected." );
482
+ return sv ? atoi(sv) : dflt;
483
+ }
484
+ case CSON_TYPE_BOOL:
485
+ return cson_value_get_bool(v) ? 1 : 0;
486
+ case CSON_TYPE_NULL:
487
+ return 0;
488
+ default:
489
+ return dflt;
487490
}
488491
}
489492
490493
491494
/*
@@ -503,31 +506,34 @@
503506
** whether or not this function found a match (it will return -1 in
504507
** that case).
505508
*/
506509
char json_getenv_bool(char const * pKey, char dflt ){
507510
cson_value const * v = json_getenv(pKey);
508
- if(!v){
509
- return dflt;
510
- }else if( cson_value_is_number(v) ){
511
- return cson_value_get_integer(v) ? 1 : 0;
512
- }else if( cson_value_is_string(v) ){
513
- char const * sv = cson_string_cstr(cson_value_get_string(v));
514
- if(!*sv || ('0'==*sv)){
515
- return 0;
516
- }else{
517
- return ((('1'<=*sv) && ('9'>=*sv))
518
- || ('t'==*sv) || ('T'==*sv)
519
- || ('y'==*sv) || ('Y'==*sv)
520
- )
521
- ? 1 : 0;
522
- }
523
- }else if( cson_value_is_bool(v) ){
524
- return cson_value_get_bool(v) ? 1 : 0;
525
- }else if( cson_value_is_null(v) ){
526
- return 0;
527
- }else{
528
- return dflt;
511
+ const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF;
512
+ switch(type){
513
+ case CSON_TYPE_INTEGER:
514
+ case CSON_TYPE_DOUBLE:
515
+ return cson_value_get_integer(v) ? 1 : 0;
516
+ case CSON_TYPE_STRING: {
517
+ char const * sv = cson_string_cstr(cson_value_get_string(v));
518
+ assert( (NULL!=sv) && "This is quite unexpected." );
519
+ if(!*sv || ('0'==*sv)){
520
+ return 0;
521
+ }else{
522
+ return ((('1'<=*sv) && ('9'>=*sv))
523
+ || ('t'==*sv) || ('T'==*sv)
524
+ || ('y'==*sv) || ('Y'==*sv)
525
+ )
526
+ ? 1 : 0;
527
+ }
528
+ }
529
+ case CSON_TYPE_BOOL:
530
+ return cson_value_get_bool(v) ? 1 : 0;
531
+ case CSON_TYPE_NULL:
532
+ return 0;
533
+ default:
534
+ return dflt;
529535
}
530536
}
531537
532538
/*
533539
** Returns the string form of a json_getenv() value, but ONLY If that
@@ -755,13 +761,13 @@
755761
&& cson_value_is_string(g.json.authToken)
756762
&& !PD(login_cookie_name(),NULL)){
757763
/* tell fossil to use this login info.
758764
759765
FIXME?: because the JSON bits don't carry around
760
- login_cookie_name(), there is a potential login hijacking
761
- window here. We may need to change the JSON auth token to be
762
- in the form: login_cookie_name()=...
766
+ login_cookie_name(), there is(?) a potential(?) login hijacking
767
+ window here. We may need to change the JSON auth token to be in
768
+ the form: login_cookie_name()=...
763769
764770
Then again, the hardened cookie value helps ensure that
765771
only a proper key/value match is valid.
766772
*/
767773
cgi_replace_parameter( login_cookie_name(), cson_value_get_cstr(g.json.authToken) );
768774
--- src/json.c
+++ src/json.c
@@ -175,11 +175,13 @@
175 #define BEGIN_TIMER
176 #define END_TIMER 0.0
177 #define HAS_TIMER 0
178 #endif
179
180
 
 
181 char fossil_has_json(){
182 return g.json.isJsonMode && (g.isHTTP || g.json.post.o);
183 }
184
185 /*
@@ -467,25 +469,26 @@
467 ** which looks like an integer or is-a JSON bool/null then it is
468 ** converted to an int. If none of those apply then dflt is returned.
469 */
470 int json_getenv_int(char const * pKey, int dflt ){
471 cson_value const * v = json_getenv(pKey);
472 if(!v){
473 return dflt;
474 }else if( cson_value_is_number(v) ){
475 return (int)cson_value_get_integer(v);
476 }else if( cson_value_is_string(v) ){
477 char const * sv = cson_string_cstr(cson_value_get_string(v));
478 assert( (NULL!=sv) && "This is quite unexpected." );
479 return sv ? atoi(sv) : dflt;
480 }else if( cson_value_is_bool(v) ){
481 return cson_value_get_bool(v) ? 1 : 0;
482 }else if( cson_value_is_null(v) ){
483 return 0;
484 }else{
485 /* we should arguably treat JSON null as 0. */
486 return dflt;
 
487 }
488 }
489
490
491 /*
@@ -503,31 +506,34 @@
503 ** whether or not this function found a match (it will return -1 in
504 ** that case).
505 */
506 char json_getenv_bool(char const * pKey, char dflt ){
507 cson_value const * v = json_getenv(pKey);
508 if(!v){
509 return dflt;
510 }else if( cson_value_is_number(v) ){
511 return cson_value_get_integer(v) ? 1 : 0;
512 }else if( cson_value_is_string(v) ){
513 char const * sv = cson_string_cstr(cson_value_get_string(v));
514 if(!*sv || ('0'==*sv)){
515 return 0;
516 }else{
517 return ((('1'<=*sv) && ('9'>=*sv))
518 || ('t'==*sv) || ('T'==*sv)
519 || ('y'==*sv) || ('Y'==*sv)
520 )
521 ? 1 : 0;
522 }
523 }else if( cson_value_is_bool(v) ){
524 return cson_value_get_bool(v) ? 1 : 0;
525 }else if( cson_value_is_null(v) ){
526 return 0;
527 }else{
528 return dflt;
 
 
 
529 }
530 }
531
532 /*
533 ** Returns the string form of a json_getenv() value, but ONLY If that
@@ -755,13 +761,13 @@
755 && cson_value_is_string(g.json.authToken)
756 && !PD(login_cookie_name(),NULL)){
757 /* tell fossil to use this login info.
758
759 FIXME?: because the JSON bits don't carry around
760 login_cookie_name(), there is a potential login hijacking
761 window here. We may need to change the JSON auth token to be
762 in the form: login_cookie_name()=...
763
764 Then again, the hardened cookie value helps ensure that
765 only a proper key/value match is valid.
766 */
767 cgi_replace_parameter( login_cookie_name(), cson_value_get_cstr(g.json.authToken) );
768
--- src/json.c
+++ src/json.c
@@ -175,11 +175,13 @@
175 #define BEGIN_TIMER
176 #define END_TIMER 0.0
177 #define HAS_TIMER 0
178 #endif
179
180 /*
181 ** Returns true (non-0) if fossil appears to be running in JSON mode.
182 */
183 char fossil_has_json(){
184 return g.json.isJsonMode && (g.isHTTP || g.json.post.o);
185 }
186
187 /*
@@ -467,25 +469,26 @@
469 ** which looks like an integer or is-a JSON bool/null then it is
470 ** converted to an int. If none of those apply then dflt is returned.
471 */
472 int json_getenv_int(char const * pKey, int dflt ){
473 cson_value const * v = json_getenv(pKey);
474 const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF;
475 switch(type){
476 case CSON_TYPE_INTEGER:
477 case CSON_TYPE_DOUBLE:
478 return (int)cson_value_get_integer(v);
479 case CSON_TYPE_STRING: {
480 char const * sv = cson_string_cstr(cson_value_get_string(v));
481 assert( (NULL!=sv) && "This is quite unexpected." );
482 return sv ? atoi(sv) : dflt;
483 }
484 case CSON_TYPE_BOOL:
485 return cson_value_get_bool(v) ? 1 : 0;
486 case CSON_TYPE_NULL:
487 return 0;
488 default:
489 return dflt;
490 }
491 }
492
493
494 /*
@@ -503,31 +506,34 @@
506 ** whether or not this function found a match (it will return -1 in
507 ** that case).
508 */
509 char json_getenv_bool(char const * pKey, char dflt ){
510 cson_value const * v = json_getenv(pKey);
511 const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF;
512 switch(type){
513 case CSON_TYPE_INTEGER:
514 case CSON_TYPE_DOUBLE:
515 return cson_value_get_integer(v) ? 1 : 0;
516 case CSON_TYPE_STRING: {
517 char const * sv = cson_string_cstr(cson_value_get_string(v));
518 assert( (NULL!=sv) && "This is quite unexpected." );
519 if(!*sv || ('0'==*sv)){
520 return 0;
521 }else{
522 return ((('1'<=*sv) && ('9'>=*sv))
523 || ('t'==*sv) || ('T'==*sv)
524 || ('y'==*sv) || ('Y'==*sv)
525 )
526 ? 1 : 0;
527 }
528 }
529 case CSON_TYPE_BOOL:
530 return cson_value_get_bool(v) ? 1 : 0;
531 case CSON_TYPE_NULL:
532 return 0;
533 default:
534 return dflt;
535 }
536 }
537
538 /*
539 ** Returns the string form of a json_getenv() value, but ONLY If that
@@ -755,13 +761,13 @@
761 && cson_value_is_string(g.json.authToken)
762 && !PD(login_cookie_name(),NULL)){
763 /* tell fossil to use this login info.
764
765 FIXME?: because the JSON bits don't carry around
766 login_cookie_name(), there is(?) a potential(?) login hijacking
767 window here. We may need to change the JSON auth token to be in
768 the form: login_cookie_name()=...
769
770 Then again, the hardened cookie value helps ensure that
771 only a proper key/value match is valid.
772 */
773 cgi_replace_parameter( login_cookie_name(), cson_value_get_cstr(g.json.authToken) );
774

Keyboard Shortcuts

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