Fossil SCM
Removed a duplicated function (different name, same code).
Commit
116a098610a8e07f041ee96435992e4c0f345515
Parent
857a6d9142a6b36…
2 files changed
+8
-18
+3
-3
+8
-18
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -566,10 +566,13 @@ | ||
| 566 | 566 | rc = find_option(zCLILong ? zCLILong : zKey, |
| 567 | 567 | zCLIShort, 1); |
| 568 | 568 | } |
| 569 | 569 | if(!rc && fossil_has_json()){ |
| 570 | 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 | + } | |
| 571 | 574 | } |
| 572 | 575 | if(!rc && (argPos>=0)){ |
| 573 | 576 | rc = json_command_arg((unsigned char)argPos); |
| 574 | 577 | } |
| 575 | 578 | return rc; |
| @@ -780,14 +783,15 @@ | ||
| 780 | 783 | } |
| 781 | 784 | return g.json.authToken; |
| 782 | 785 | } |
| 783 | 786 | |
| 784 | 787 | /* |
| 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. | |
| 789 | 793 | */ |
| 790 | 794 | cson_value * json_req_payload_get(char const *pKey){ |
| 791 | 795 | return g.json.reqPayload.o |
| 792 | 796 | ? cson_object_get(g.json.reqPayload.o,pKey) |
| 793 | 797 | : NULL; |
| @@ -1227,24 +1231,10 @@ | ||
| 1227 | 1231 | }else{ |
| 1228 | 1232 | ndx = g.json.cmd.offset + ndx; |
| 1229 | 1233 | return cson_string_cstr(cson_value_get_string(cson_array_get( ar, g.json.cmd.offset + ndx ))); |
| 1230 | 1234 | } |
| 1231 | 1235 | } |
| 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 | 1236 | |
| 1247 | 1237 | /* Returns the C-string form of json_auth_token(), or NULL |
| 1248 | 1238 | ** if json_auth_token() returns NULL. |
| 1249 | 1239 | */ |
| 1250 | 1240 | char const * json_auth_token_cstr(){ |
| 1251 | 1241 |
| --- 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 |
+3
-3
| --- src/json_login.c | ||
| +++ src/json_login.c | ||
| @@ -52,21 +52,21 @@ | ||
| 52 | 52 | then ONLY a GET param of "name" will match ("n" |
| 53 | 53 | is not recognized). If we reverse the order of the |
| 54 | 54 | checks then both forms work. Strangely enough, the |
| 55 | 55 | "p"/"password" check is not affected by this. |
| 56 | 56 | */ |
| 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")); | |
| 58 | 58 | char const * pw = NULL; |
| 59 | 59 | char const * anonSeed = NULL; |
| 60 | 60 | cson_value * payload = NULL; |
| 61 | 61 | int uid = 0; |
| 62 | 62 | /* reminder to self: Fossil internally (for the sake of /wiki) |
| 63 | 63 | interprets paths in the form /foo/bar/baz such that P("name") == |
| 64 | 64 | "bar/baz". This collides with our name/password checking, and |
| 65 | 65 | thus we do some rather elaborate name=... checking. |
| 66 | 66 | */ |
| 67 | - pw = cson_value_get_cstr(json_payload_property("password")); | |
| 67 | + pw = cson_value_get_cstr(json_req_payload_get("password")); | |
| 68 | 68 | if( !pw ){ |
| 69 | 69 | pw = PD("p",NULL); |
| 70 | 70 | if( !pw ){ |
| 71 | 71 | pw = PD("password",NULL); |
| 72 | 72 | } |
| @@ -99,11 +99,11 @@ | ||
| 99 | 99 | }; |
| 100 | 100 | static char seedBuffer[SeedBufLen]; |
| 101 | 101 | cson_value const * jseed = json_getenv(FossilJsonKeys.anonymousSeed); |
| 102 | 102 | seedBuffer[0] = 0; |
| 103 | 103 | if( !jseed ){ |
| 104 | - jseed = json_payload_property(FossilJsonKeys.anonymousSeed); | |
| 104 | + jseed = json_req_payload_get(FossilJsonKeys.anonymousSeed); | |
| 105 | 105 | if( !jseed ){ |
| 106 | 106 | jseed = json_getenv("cs") /* name used by HTML interface */; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | if(jseed){ |
| 110 | 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_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 |