Fossil SCM
style conformance touch-ups.
Commit
45cd04f8c1bf78ceee2235c9f76644d8a87cb1eb
Parent
0bb823032fd4c19…
1 file changed
+16
-10
+16
-10
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -231,12 +231,11 @@ | ||
| 231 | 231 | FIXME: because the JSON bits don't carry around login_cookie_name(), |
| 232 | 232 | there is a login hijacking window here. We need to change the |
| 233 | 233 | JSON auth token to be in the form: login_cookie_name()=... |
| 234 | 234 | */ |
| 235 | 235 | cgi_replace_parameter( login_cookie_name(), cson_value_get_cstr(g.json.authToken) ); |
| 236 | - } | |
| 237 | - else if( g.isCGI ){ | |
| 236 | + }else if( g.isCGI ){ | |
| 238 | 237 | /* try fossil's conventional cookie. */ |
| 239 | 238 | /* Reminder: chicken/egg scenario regarding db access in CLI |
| 240 | 239 | mode because login_cookie_name() needs the db. */ |
| 241 | 240 | char const * zCookie = P(login_cookie_name()); |
| 242 | 241 | if( zCookie && *zCookie ){ |
| @@ -266,12 +265,15 @@ | ||
| 266 | 265 | static char once = 0 /* guard against multiple runs */; |
| 267 | 266 | char const * zPath = P("PATH_INFO"); |
| 268 | 267 | cson_value * pathSplit = |
| 269 | 268 | cson_cgi_getenv(&g.json.cgiCx,"e","PATH_INFO_SPLIT"); |
| 270 | 269 | assert( (0==once) && "json_mode_bootstrap() called too many times!"); |
| 271 | - if( once ) return; | |
| 272 | - else once = 1; | |
| 270 | + if( once ){ | |
| 271 | + return; | |
| 272 | + }else{ | |
| 273 | + once = 1; | |
| 274 | + } | |
| 273 | 275 | g.json.isJsonMode = 1; |
| 274 | 276 | g.json.resultCode = 0; |
| 275 | 277 | g.json.cmdOffset = -1; |
| 276 | 278 | if( !g.isCGI && g.fullHttpReply ){ |
| 277 | 279 | /* workaround for server mode, so we see it as CGI mode. */ |
| @@ -316,18 +318,20 @@ | ||
| 316 | 318 | char const * head = p /* current start-of-token */; |
| 317 | 319 | unsigned int len = 0 /* current token's lengh */; |
| 318 | 320 | assert( g.isCGI && "g.isCGI should have been set by now." ); |
| 319 | 321 | for( ;*p!='?'; ++p){ |
| 320 | 322 | if( !*p || ('/' == *p) ){ |
| 321 | - if( len ) { | |
| 323 | + if( len ){ | |
| 322 | 324 | cson_value * part; |
| 323 | 325 | assert( head != p ); |
| 324 | 326 | part = cson_value_new_string(head, len); |
| 325 | 327 | cson_array_append( ar, part ); |
| 326 | 328 | len = 0; |
| 327 | 329 | } |
| 328 | - if( !*p ) break; | |
| 330 | + if( !*p ){ | |
| 331 | + break; | |
| 332 | + } | |
| 329 | 333 | head = p+1; |
| 330 | 334 | continue; |
| 331 | 335 | } |
| 332 | 336 | ++len; |
| 333 | 337 | } |
| @@ -337,11 +341,13 @@ | ||
| 337 | 341 | char const * arg; |
| 338 | 342 | cson_value * part; |
| 339 | 343 | assert( (!g.isCGI) && "g.isCGI set and we do not expect that to be the case here." ); |
| 340 | 344 | for(i = 1/*skip argv[0]*/; i < g.argc; ++i ){ |
| 341 | 345 | arg = g.argv[i]; |
| 342 | - if( !arg || !*arg ) continue; | |
| 346 | + if( !arg || !*arg ){ | |
| 347 | + continue; | |
| 348 | + } | |
| 343 | 349 | part = cson_value_new_string(arg,strlen(arg)); |
| 344 | 350 | cson_array_append(ar, part); |
| 345 | 351 | } |
| 346 | 352 | } |
| 347 | 353 | } |
| @@ -419,11 +425,11 @@ | ||
| 419 | 425 | |
| 420 | 426 | |
| 421 | 427 | /* Returns the C-string form of json_auth_token(), or NULL |
| 422 | 428 | ** if json_auth_token() returns NULL. |
| 423 | 429 | */ |
| 424 | -char const * json_auth_token_cstr() { | |
| 430 | +char const * json_auth_token_cstr(){ | |
| 425 | 431 | return cson_value_get_cstr( json_auth_token() ); |
| 426 | 432 | } |
| 427 | 433 | |
| 428 | 434 | /* |
| 429 | 435 | ** Holds name-to-function mappings for JSON page/command dispatching. |
| @@ -902,11 +908,11 @@ | ||
| 902 | 908 | /*cgi_printf("{\"cmd\":\"%s\"}\n",cmd); return;*/ |
| 903 | 909 | pageDef = json_handler_for_name(cmd,&JsonPageDefs[0]); |
| 904 | 910 | if( ! pageDef ){ |
| 905 | 911 | json_err( FSL_JSON_E_UNKNOWN_COMMAND, cmd, 0 ); |
| 906 | 912 | return; |
| 907 | - }else if( pageDef->runMode < 0 /*CLI only*/) { | |
| 913 | + }else if( pageDef->runMode < 0 /*CLI only*/){ | |
| 908 | 914 | rc = FSL_JSON_E_WRONG_MODE; |
| 909 | 915 | }else{ |
| 910 | 916 | rc = 0; |
| 911 | 917 | payload = (*pageDef->func)(); |
| 912 | 918 | } |
| @@ -959,11 +965,11 @@ | ||
| 959 | 965 | cgi_set_content_type( cson_cgi_guess_content_type(&g.json.cgiCx) ); |
| 960 | 966 | pageDef = json_handler_for_name(cmd,&JsonPageDefs[0]); |
| 961 | 967 | if( ! pageDef ){ |
| 962 | 968 | json_err( FSL_JSON_E_UNKNOWN_COMMAND, NULL, 1 ); |
| 963 | 969 | return; |
| 964 | - }else if( pageDef->runMode > 0 /*HTTP only*/) { | |
| 970 | + }else if( pageDef->runMode > 0 /*HTTP only*/){ | |
| 965 | 971 | rc = FSL_JSON_E_WRONG_MODE; |
| 966 | 972 | }else{ |
| 967 | 973 | rc = 0; |
| 968 | 974 | payload = (pageDef->func)(); |
| 969 | 975 | } |
| 970 | 976 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -231,12 +231,11 @@ | |
| 231 | FIXME: because the JSON bits don't carry around login_cookie_name(), |
| 232 | there is a login hijacking window here. We need to change the |
| 233 | JSON auth token to be in the form: login_cookie_name()=... |
| 234 | */ |
| 235 | cgi_replace_parameter( login_cookie_name(), cson_value_get_cstr(g.json.authToken) ); |
| 236 | } |
| 237 | else if( g.isCGI ){ |
| 238 | /* try fossil's conventional cookie. */ |
| 239 | /* Reminder: chicken/egg scenario regarding db access in CLI |
| 240 | mode because login_cookie_name() needs the db. */ |
| 241 | char const * zCookie = P(login_cookie_name()); |
| 242 | if( zCookie && *zCookie ){ |
| @@ -266,12 +265,15 @@ | |
| 266 | static char once = 0 /* guard against multiple runs */; |
| 267 | char const * zPath = P("PATH_INFO"); |
| 268 | cson_value * pathSplit = |
| 269 | cson_cgi_getenv(&g.json.cgiCx,"e","PATH_INFO_SPLIT"); |
| 270 | assert( (0==once) && "json_mode_bootstrap() called too many times!"); |
| 271 | if( once ) return; |
| 272 | else once = 1; |
| 273 | g.json.isJsonMode = 1; |
| 274 | g.json.resultCode = 0; |
| 275 | g.json.cmdOffset = -1; |
| 276 | if( !g.isCGI && g.fullHttpReply ){ |
| 277 | /* workaround for server mode, so we see it as CGI mode. */ |
| @@ -316,18 +318,20 @@ | |
| 316 | char const * head = p /* current start-of-token */; |
| 317 | unsigned int len = 0 /* current token's lengh */; |
| 318 | assert( g.isCGI && "g.isCGI should have been set by now." ); |
| 319 | for( ;*p!='?'; ++p){ |
| 320 | if( !*p || ('/' == *p) ){ |
| 321 | if( len ) { |
| 322 | cson_value * part; |
| 323 | assert( head != p ); |
| 324 | part = cson_value_new_string(head, len); |
| 325 | cson_array_append( ar, part ); |
| 326 | len = 0; |
| 327 | } |
| 328 | if( !*p ) break; |
| 329 | head = p+1; |
| 330 | continue; |
| 331 | } |
| 332 | ++len; |
| 333 | } |
| @@ -337,11 +341,13 @@ | |
| 337 | char const * arg; |
| 338 | cson_value * part; |
| 339 | assert( (!g.isCGI) && "g.isCGI set and we do not expect that to be the case here." ); |
| 340 | for(i = 1/*skip argv[0]*/; i < g.argc; ++i ){ |
| 341 | arg = g.argv[i]; |
| 342 | if( !arg || !*arg ) continue; |
| 343 | part = cson_value_new_string(arg,strlen(arg)); |
| 344 | cson_array_append(ar, part); |
| 345 | } |
| 346 | } |
| 347 | } |
| @@ -419,11 +425,11 @@ | |
| 419 | |
| 420 | |
| 421 | /* Returns the C-string form of json_auth_token(), or NULL |
| 422 | ** if json_auth_token() returns NULL. |
| 423 | */ |
| 424 | char const * json_auth_token_cstr() { |
| 425 | return cson_value_get_cstr( json_auth_token() ); |
| 426 | } |
| 427 | |
| 428 | /* |
| 429 | ** Holds name-to-function mappings for JSON page/command dispatching. |
| @@ -902,11 +908,11 @@ | |
| 902 | /*cgi_printf("{\"cmd\":\"%s\"}\n",cmd); return;*/ |
| 903 | pageDef = json_handler_for_name(cmd,&JsonPageDefs[0]); |
| 904 | if( ! pageDef ){ |
| 905 | json_err( FSL_JSON_E_UNKNOWN_COMMAND, cmd, 0 ); |
| 906 | return; |
| 907 | }else if( pageDef->runMode < 0 /*CLI only*/) { |
| 908 | rc = FSL_JSON_E_WRONG_MODE; |
| 909 | }else{ |
| 910 | rc = 0; |
| 911 | payload = (*pageDef->func)(); |
| 912 | } |
| @@ -959,11 +965,11 @@ | |
| 959 | cgi_set_content_type( cson_cgi_guess_content_type(&g.json.cgiCx) ); |
| 960 | pageDef = json_handler_for_name(cmd,&JsonPageDefs[0]); |
| 961 | if( ! pageDef ){ |
| 962 | json_err( FSL_JSON_E_UNKNOWN_COMMAND, NULL, 1 ); |
| 963 | return; |
| 964 | }else if( pageDef->runMode > 0 /*HTTP only*/) { |
| 965 | rc = FSL_JSON_E_WRONG_MODE; |
| 966 | }else{ |
| 967 | rc = 0; |
| 968 | payload = (pageDef->func)(); |
| 969 | } |
| 970 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -231,12 +231,11 @@ | |
| 231 | FIXME: because the JSON bits don't carry around login_cookie_name(), |
| 232 | there is a login hijacking window here. We need to change the |
| 233 | JSON auth token to be in the form: login_cookie_name()=... |
| 234 | */ |
| 235 | cgi_replace_parameter( login_cookie_name(), cson_value_get_cstr(g.json.authToken) ); |
| 236 | }else if( g.isCGI ){ |
| 237 | /* try fossil's conventional cookie. */ |
| 238 | /* Reminder: chicken/egg scenario regarding db access in CLI |
| 239 | mode because login_cookie_name() needs the db. */ |
| 240 | char const * zCookie = P(login_cookie_name()); |
| 241 | if( zCookie && *zCookie ){ |
| @@ -266,12 +265,15 @@ | |
| 265 | static char once = 0 /* guard against multiple runs */; |
| 266 | char const * zPath = P("PATH_INFO"); |
| 267 | cson_value * pathSplit = |
| 268 | cson_cgi_getenv(&g.json.cgiCx,"e","PATH_INFO_SPLIT"); |
| 269 | assert( (0==once) && "json_mode_bootstrap() called too many times!"); |
| 270 | if( once ){ |
| 271 | return; |
| 272 | }else{ |
| 273 | once = 1; |
| 274 | } |
| 275 | g.json.isJsonMode = 1; |
| 276 | g.json.resultCode = 0; |
| 277 | g.json.cmdOffset = -1; |
| 278 | if( !g.isCGI && g.fullHttpReply ){ |
| 279 | /* workaround for server mode, so we see it as CGI mode. */ |
| @@ -316,18 +318,20 @@ | |
| 318 | char const * head = p /* current start-of-token */; |
| 319 | unsigned int len = 0 /* current token's lengh */; |
| 320 | assert( g.isCGI && "g.isCGI should have been set by now." ); |
| 321 | for( ;*p!='?'; ++p){ |
| 322 | if( !*p || ('/' == *p) ){ |
| 323 | if( len ){ |
| 324 | cson_value * part; |
| 325 | assert( head != p ); |
| 326 | part = cson_value_new_string(head, len); |
| 327 | cson_array_append( ar, part ); |
| 328 | len = 0; |
| 329 | } |
| 330 | if( !*p ){ |
| 331 | break; |
| 332 | } |
| 333 | head = p+1; |
| 334 | continue; |
| 335 | } |
| 336 | ++len; |
| 337 | } |
| @@ -337,11 +341,13 @@ | |
| 341 | char const * arg; |
| 342 | cson_value * part; |
| 343 | assert( (!g.isCGI) && "g.isCGI set and we do not expect that to be the case here." ); |
| 344 | for(i = 1/*skip argv[0]*/; i < g.argc; ++i ){ |
| 345 | arg = g.argv[i]; |
| 346 | if( !arg || !*arg ){ |
| 347 | continue; |
| 348 | } |
| 349 | part = cson_value_new_string(arg,strlen(arg)); |
| 350 | cson_array_append(ar, part); |
| 351 | } |
| 352 | } |
| 353 | } |
| @@ -419,11 +425,11 @@ | |
| 425 | |
| 426 | |
| 427 | /* Returns the C-string form of json_auth_token(), or NULL |
| 428 | ** if json_auth_token() returns NULL. |
| 429 | */ |
| 430 | char const * json_auth_token_cstr(){ |
| 431 | return cson_value_get_cstr( json_auth_token() ); |
| 432 | } |
| 433 | |
| 434 | /* |
| 435 | ** Holds name-to-function mappings for JSON page/command dispatching. |
| @@ -902,11 +908,11 @@ | |
| 908 | /*cgi_printf("{\"cmd\":\"%s\"}\n",cmd); return;*/ |
| 909 | pageDef = json_handler_for_name(cmd,&JsonPageDefs[0]); |
| 910 | if( ! pageDef ){ |
| 911 | json_err( FSL_JSON_E_UNKNOWN_COMMAND, cmd, 0 ); |
| 912 | return; |
| 913 | }else if( pageDef->runMode < 0 /*CLI only*/){ |
| 914 | rc = FSL_JSON_E_WRONG_MODE; |
| 915 | }else{ |
| 916 | rc = 0; |
| 917 | payload = (*pageDef->func)(); |
| 918 | } |
| @@ -959,11 +965,11 @@ | |
| 965 | cgi_set_content_type( cson_cgi_guess_content_type(&g.json.cgiCx) ); |
| 966 | pageDef = json_handler_for_name(cmd,&JsonPageDefs[0]); |
| 967 | if( ! pageDef ){ |
| 968 | json_err( FSL_JSON_E_UNKNOWN_COMMAND, NULL, 1 ); |
| 969 | return; |
| 970 | }else if( pageDef->runMode > 0 /*HTTP only*/){ |
| 971 | rc = FSL_JSON_E_WRONG_MODE; |
| 972 | }else{ |
| 973 | rc = 0; |
| 974 | payload = (pageDef->func)(); |
| 975 | } |
| 976 |