Fossil SCM

Removed a duplicated function (different name, same code).

stephan 2012-03-16 19:01 trunk
Commit 116a098610a8e07f041ee96435992e4c0f345515
2 files changed +8 -18 +3 -3
+8 -18
--- src/json.c
+++ src/json.c
@@ -566,10 +566,13 @@
566566
rc = find_option(zCLILong ? zCLILong : zKey,
567567
zCLIShort, 1);
568568
}
569569
if(!rc && fossil_has_json()){
570570
rc = json_getenv_cstr(zKey);
571
+ if(!rc && zCLIShort){
572
+ rc = cson_value_get_cstr( cson_object_get( g.json.param.o, zCLIShort) );
573
+ }
571574
}
572575
if(!rc && (argPos>=0)){
573576
rc = json_command_arg((unsigned char)argPos);
574577
}
575578
return rc;
@@ -780,14 +783,15 @@
780783
}
781784
return g.json.authToken;
782785
}
783786
784787
/*
785
-** IFF json.reqPayload.o is not NULL then this returns
786
-** cson_object_get(json.reqPayload.o,pKey), else it returns NULL.
787
-**
788
-** The returned value is owned by (or shared with) json.reqPayload.v.
788
+** If g.json.reqPayload.o is NULL then NULL is returned, else the
789
+** given property is searched for in the request payload. If found it
790
+** is returned. The returned value is owned by (or shares ownership
791
+** with) g.json, and must NOT be cson_value_free()'d by the
792
+** caller.
789793
*/
790794
cson_value * json_req_payload_get(char const *pKey){
791795
return g.json.reqPayload.o
792796
? cson_object_get(g.json.reqPayload.o,pKey)
793797
: NULL;
@@ -1227,24 +1231,10 @@
12271231
}else{
12281232
ndx = g.json.cmd.offset + ndx;
12291233
return cson_string_cstr(cson_value_get_string(cson_array_get( ar, g.json.cmd.offset + ndx )));
12301234
}
12311235
}
1232
-
1233
-/*
1234
-** If g.json.reqPayload.o is NULL then NULL is returned, else the
1235
-** given property is searched for in the request payload. If found it
1236
-** is returned. The returned value is owned by (or shares ownership
1237
-** with) g.json, and must NOT be cson_value_free()'d by the
1238
-** caller.
1239
-*/
1240
-cson_value * json_payload_property( char const * key ){
1241
- return g.json.reqPayload.o ?
1242
- cson_object_get( g.json.reqPayload.o, key )
1243
- : NULL;
1244
-}
1245
-
12461236
12471237
/* Returns the C-string form of json_auth_token(), or NULL
12481238
** if json_auth_token() returns NULL.
12491239
*/
12501240
char const * json_auth_token_cstr(){
12511241
--- src/json.c
+++ src/json.c
@@ -566,10 +566,13 @@
566 rc = find_option(zCLILong ? zCLILong : zKey,
567 zCLIShort, 1);
568 }
569 if(!rc && fossil_has_json()){
570 rc = json_getenv_cstr(zKey);
 
 
 
571 }
572 if(!rc && (argPos>=0)){
573 rc = json_command_arg((unsigned char)argPos);
574 }
575 return rc;
@@ -780,14 +783,15 @@
780 }
781 return g.json.authToken;
782 }
783
784 /*
785 ** IFF json.reqPayload.o is not NULL then this returns
786 ** cson_object_get(json.reqPayload.o,pKey), else it returns NULL.
787 **
788 ** The returned value is owned by (or shared with) json.reqPayload.v.
 
789 */
790 cson_value * json_req_payload_get(char const *pKey){
791 return g.json.reqPayload.o
792 ? cson_object_get(g.json.reqPayload.o,pKey)
793 : NULL;
@@ -1227,24 +1231,10 @@
1227 }else{
1228 ndx = g.json.cmd.offset + ndx;
1229 return cson_string_cstr(cson_value_get_string(cson_array_get( ar, g.json.cmd.offset + ndx )));
1230 }
1231 }
1232
1233 /*
1234 ** If g.json.reqPayload.o is NULL then NULL is returned, else the
1235 ** given property is searched for in the request payload. If found it
1236 ** is returned. The returned value is owned by (or shares ownership
1237 ** with) g.json, and must NOT be cson_value_free()'d by the
1238 ** caller.
1239 */
1240 cson_value * json_payload_property( char const * key ){
1241 return g.json.reqPayload.o ?
1242 cson_object_get( g.json.reqPayload.o, key )
1243 : NULL;
1244 }
1245
1246
1247 /* Returns the C-string form of json_auth_token(), or NULL
1248 ** if json_auth_token() returns NULL.
1249 */
1250 char const * json_auth_token_cstr(){
1251
--- src/json.c
+++ src/json.c
@@ -566,10 +566,13 @@
566 rc = find_option(zCLILong ? zCLILong : zKey,
567 zCLIShort, 1);
568 }
569 if(!rc && fossil_has_json()){
570 rc = json_getenv_cstr(zKey);
571 if(!rc && zCLIShort){
572 rc = cson_value_get_cstr( cson_object_get( g.json.param.o, zCLIShort) );
573 }
574 }
575 if(!rc && (argPos>=0)){
576 rc = json_command_arg((unsigned char)argPos);
577 }
578 return rc;
@@ -780,14 +783,15 @@
783 }
784 return g.json.authToken;
785 }
786
787 /*
788 ** If g.json.reqPayload.o is NULL then NULL is returned, else the
789 ** given property is searched for in the request payload. If found it
790 ** is returned. The returned value is owned by (or shares ownership
791 ** with) g.json, and must NOT be cson_value_free()'d by the
792 ** caller.
793 */
794 cson_value * json_req_payload_get(char const *pKey){
795 return g.json.reqPayload.o
796 ? cson_object_get(g.json.reqPayload.o,pKey)
797 : NULL;
@@ -1227,24 +1231,10 @@
1231 }else{
1232 ndx = g.json.cmd.offset + ndx;
1233 return cson_string_cstr(cson_value_get_string(cson_array_get( ar, g.json.cmd.offset + ndx )));
1234 }
1235 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1236
1237 /* Returns the C-string form of json_auth_token(), or NULL
1238 ** if json_auth_token() returns NULL.
1239 */
1240 char const * json_auth_token_cstr(){
1241
--- src/json_login.c
+++ src/json_login.c
@@ -52,21 +52,21 @@
5252
then ONLY a GET param of "name" will match ("n"
5353
is not recognized). If we reverse the order of the
5454
checks then both forms work. Strangely enough, the
5555
"p"/"password" check is not affected by this.
5656
*/
57
- char const * name = cson_value_get_cstr(json_payload_property("name"));
57
+ char const * name = cson_value_get_cstr(json_req_payload_get("name"));
5858
char const * pw = NULL;
5959
char const * anonSeed = NULL;
6060
cson_value * payload = NULL;
6161
int uid = 0;
6262
/* reminder to self: Fossil internally (for the sake of /wiki)
6363
interprets paths in the form /foo/bar/baz such that P("name") ==
6464
"bar/baz". This collides with our name/password checking, and
6565
thus we do some rather elaborate name=... checking.
6666
*/
67
- pw = cson_value_get_cstr(json_payload_property("password"));
67
+ pw = cson_value_get_cstr(json_req_payload_get("password"));
6868
if( !pw ){
6969
pw = PD("p",NULL);
7070
if( !pw ){
7171
pw = PD("password",NULL);
7272
}
@@ -99,11 +99,11 @@
9999
};
100100
static char seedBuffer[SeedBufLen];
101101
cson_value const * jseed = json_getenv(FossilJsonKeys.anonymousSeed);
102102
seedBuffer[0] = 0;
103103
if( !jseed ){
104
- jseed = json_payload_property(FossilJsonKeys.anonymousSeed);
104
+ jseed = json_req_payload_get(FossilJsonKeys.anonymousSeed);
105105
if( !jseed ){
106106
jseed = json_getenv("cs") /* name used by HTML interface */;
107107
}
108108
}
109109
if(jseed){
110110
--- src/json_login.c
+++ src/json_login.c
@@ -52,21 +52,21 @@
52 then ONLY a GET param of "name" will match ("n"
53 is not recognized). If we reverse the order of the
54 checks then both forms work. Strangely enough, the
55 "p"/"password" check is not affected by this.
56 */
57 char const * name = cson_value_get_cstr(json_payload_property("name"));
58 char const * pw = NULL;
59 char const * anonSeed = NULL;
60 cson_value * payload = NULL;
61 int uid = 0;
62 /* reminder to self: Fossil internally (for the sake of /wiki)
63 interprets paths in the form /foo/bar/baz such that P("name") ==
64 "bar/baz". This collides with our name/password checking, and
65 thus we do some rather elaborate name=... checking.
66 */
67 pw = cson_value_get_cstr(json_payload_property("password"));
68 if( !pw ){
69 pw = PD("p",NULL);
70 if( !pw ){
71 pw = PD("password",NULL);
72 }
@@ -99,11 +99,11 @@
99 };
100 static char seedBuffer[SeedBufLen];
101 cson_value const * jseed = json_getenv(FossilJsonKeys.anonymousSeed);
102 seedBuffer[0] = 0;
103 if( !jseed ){
104 jseed = json_payload_property(FossilJsonKeys.anonymousSeed);
105 if( !jseed ){
106 jseed = json_getenv("cs") /* name used by HTML interface */;
107 }
108 }
109 if(jseed){
110
--- src/json_login.c
+++ src/json_login.c
@@ -52,21 +52,21 @@
52 then ONLY a GET param of "name" will match ("n"
53 is not recognized). If we reverse the order of the
54 checks then both forms work. Strangely enough, the
55 "p"/"password" check is not affected by this.
56 */
57 char const * name = cson_value_get_cstr(json_req_payload_get("name"));
58 char const * pw = NULL;
59 char const * anonSeed = NULL;
60 cson_value * payload = NULL;
61 int uid = 0;
62 /* reminder to self: Fossil internally (for the sake of /wiki)
63 interprets paths in the form /foo/bar/baz such that P("name") ==
64 "bar/baz". This collides with our name/password checking, and
65 thus we do some rather elaborate name=... checking.
66 */
67 pw = cson_value_get_cstr(json_req_payload_get("password"));
68 if( !pw ){
69 pw = PD("p",NULL);
70 if( !pw ){
71 pw = PD("password",NULL);
72 }
@@ -99,11 +99,11 @@
99 };
100 static char seedBuffer[SeedBufLen];
101 cson_value const * jseed = json_getenv(FossilJsonKeys.anonymousSeed);
102 seedBuffer[0] = 0;
103 if( !jseed ){
104 jseed = json_req_payload_get(FossilJsonKeys.anonymousSeed);
105 if( !jseed ){
106 jseed = json_getenv("cs") /* name used by HTML interface */;
107 }
108 }
109 if(jseed){
110

Keyboard Shortcuts

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