Fossil SCM
s/userName/name/, for consistency.
Commit
94689bbf29c1ab6d2a6b16e24724c3b63c50df56
Parent
225fd3dad33e7a9…
1 file changed
+14
-4
+14
-4
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -945,22 +945,29 @@ | ||
| 945 | 945 | part = cson_value_new_string(arg,strlen(arg)); |
| 946 | 946 | cson_array_append(g.json.cmd.a, part); |
| 947 | 947 | } |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | - while(!g.isHTTP){ /* simulate JSON POST data via input file. */ | |
| 950 | + while(!g.isHTTP){ | |
| 951 | + /* Simulate JSON POST data via input file. Pedantic reminder: | |
| 952 | + error handling does not honor user-supplied g.json.outOpt | |
| 953 | + because outOpt cannot (generically) be configured until after | |
| 954 | + POST-reading is finished. | |
| 955 | + */ | |
| 951 | 956 | FILE * inFile = NULL; |
| 952 | 957 | char const * jfile = find_option("json-input",NULL,1); |
| 953 | 958 | if(!jfile || !*jfile){ |
| 954 | 959 | break; |
| 955 | 960 | } |
| 956 | 961 | inFile = (0==strcmp("-",jfile)) |
| 957 | 962 | ? stdin |
| 958 | 963 | : fopen(jfile,"rb"); |
| 959 | 964 | if(!inFile){ |
| 960 | - json_err(FSL_JSON_E_UNKNOWN,"Could not open JSON file.",1); | |
| 961 | - fossil_exit(1); | |
| 965 | + g.json.resultCode = FSL_JSON_E_UNKNOWN; | |
| 966 | + fossil_fatal("Could not open JSON file [%s].",jfile) | |
| 967 | + /* Does not return. */ | |
| 968 | + ; | |
| 962 | 969 | } |
| 963 | 970 | cgi_parse_POST_JSON(inFile, 0); |
| 964 | 971 | if( stdin != inFile ){ |
| 965 | 972 | fclose(inFile); |
| 966 | 973 | } |
| @@ -1055,10 +1062,13 @@ | ||
| 1055 | 1062 | ** In server/CGI modes the path is taken from PATH_INFO. |
| 1056 | 1063 | ** |
| 1057 | 1064 | ** The returned bytes are owned by g.json.cmd.v and _may_ be |
| 1058 | 1065 | ** invalidated if that object is modified (depending on how it is |
| 1059 | 1066 | ** modified). |
| 1067 | +** | |
| 1068 | +** Note that CLI options are not included in the command path. Use | |
| 1069 | +** find_option() to get those. | |
| 1060 | 1070 | ** |
| 1061 | 1071 | */ |
| 1062 | 1072 | char const * json_command_arg(unsigned char ndx){ |
| 1063 | 1073 | cson_array * ar = g.json.cmd.a; |
| 1064 | 1074 | assert((NULL!=ar) && "Internal error. Was json_mode_bootstrap() called?"); |
| @@ -1450,11 +1460,11 @@ | ||
| 1450 | 1460 | /* reminder: we don't use g.zLogin because it's 0 for the guest |
| 1451 | 1461 | user and the HTML UI appears to currently allow the name to be |
| 1452 | 1462 | changed (but doing so would break other code). */ |
| 1453 | 1463 | char const * str = (char const *)sqlite3_column_text(q.pStmt,0); |
| 1454 | 1464 | if( str ){ |
| 1455 | - cson_object_set( obj, "userName", | |
| 1465 | + cson_object_set( obj, "name", | |
| 1456 | 1466 | cson_value_new_string(str,strlen(str)) ); |
| 1457 | 1467 | } |
| 1458 | 1468 | str = (char const *)sqlite3_column_text(q.pStmt,1); |
| 1459 | 1469 | if( str ){ |
| 1460 | 1470 | cson_object_set( obj, "capabilities", |
| 1461 | 1471 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -945,22 +945,29 @@ | |
| 945 | part = cson_value_new_string(arg,strlen(arg)); |
| 946 | cson_array_append(g.json.cmd.a, part); |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | while(!g.isHTTP){ /* simulate JSON POST data via input file. */ |
| 951 | FILE * inFile = NULL; |
| 952 | char const * jfile = find_option("json-input",NULL,1); |
| 953 | if(!jfile || !*jfile){ |
| 954 | break; |
| 955 | } |
| 956 | inFile = (0==strcmp("-",jfile)) |
| 957 | ? stdin |
| 958 | : fopen(jfile,"rb"); |
| 959 | if(!inFile){ |
| 960 | json_err(FSL_JSON_E_UNKNOWN,"Could not open JSON file.",1); |
| 961 | fossil_exit(1); |
| 962 | } |
| 963 | cgi_parse_POST_JSON(inFile, 0); |
| 964 | if( stdin != inFile ){ |
| 965 | fclose(inFile); |
| 966 | } |
| @@ -1055,10 +1062,13 @@ | |
| 1055 | ** In server/CGI modes the path is taken from PATH_INFO. |
| 1056 | ** |
| 1057 | ** The returned bytes are owned by g.json.cmd.v and _may_ be |
| 1058 | ** invalidated if that object is modified (depending on how it is |
| 1059 | ** modified). |
| 1060 | ** |
| 1061 | */ |
| 1062 | char const * json_command_arg(unsigned char ndx){ |
| 1063 | cson_array * ar = g.json.cmd.a; |
| 1064 | assert((NULL!=ar) && "Internal error. Was json_mode_bootstrap() called?"); |
| @@ -1450,11 +1460,11 @@ | |
| 1450 | /* reminder: we don't use g.zLogin because it's 0 for the guest |
| 1451 | user and the HTML UI appears to currently allow the name to be |
| 1452 | changed (but doing so would break other code). */ |
| 1453 | char const * str = (char const *)sqlite3_column_text(q.pStmt,0); |
| 1454 | if( str ){ |
| 1455 | cson_object_set( obj, "userName", |
| 1456 | cson_value_new_string(str,strlen(str)) ); |
| 1457 | } |
| 1458 | str = (char const *)sqlite3_column_text(q.pStmt,1); |
| 1459 | if( str ){ |
| 1460 | cson_object_set( obj, "capabilities", |
| 1461 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -945,22 +945,29 @@ | |
| 945 | part = cson_value_new_string(arg,strlen(arg)); |
| 946 | cson_array_append(g.json.cmd.a, part); |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | while(!g.isHTTP){ |
| 951 | /* Simulate JSON POST data via input file. Pedantic reminder: |
| 952 | error handling does not honor user-supplied g.json.outOpt |
| 953 | because outOpt cannot (generically) be configured until after |
| 954 | POST-reading is finished. |
| 955 | */ |
| 956 | FILE * inFile = NULL; |
| 957 | char const * jfile = find_option("json-input",NULL,1); |
| 958 | if(!jfile || !*jfile){ |
| 959 | break; |
| 960 | } |
| 961 | inFile = (0==strcmp("-",jfile)) |
| 962 | ? stdin |
| 963 | : fopen(jfile,"rb"); |
| 964 | if(!inFile){ |
| 965 | g.json.resultCode = FSL_JSON_E_UNKNOWN; |
| 966 | fossil_fatal("Could not open JSON file [%s].",jfile) |
| 967 | /* Does not return. */ |
| 968 | ; |
| 969 | } |
| 970 | cgi_parse_POST_JSON(inFile, 0); |
| 971 | if( stdin != inFile ){ |
| 972 | fclose(inFile); |
| 973 | } |
| @@ -1055,10 +1062,13 @@ | |
| 1062 | ** In server/CGI modes the path is taken from PATH_INFO. |
| 1063 | ** |
| 1064 | ** The returned bytes are owned by g.json.cmd.v and _may_ be |
| 1065 | ** invalidated if that object is modified (depending on how it is |
| 1066 | ** modified). |
| 1067 | ** |
| 1068 | ** Note that CLI options are not included in the command path. Use |
| 1069 | ** find_option() to get those. |
| 1070 | ** |
| 1071 | */ |
| 1072 | char const * json_command_arg(unsigned char ndx){ |
| 1073 | cson_array * ar = g.json.cmd.a; |
| 1074 | assert((NULL!=ar) && "Internal error. Was json_mode_bootstrap() called?"); |
| @@ -1450,11 +1460,11 @@ | |
| 1460 | /* reminder: we don't use g.zLogin because it's 0 for the guest |
| 1461 | user and the HTML UI appears to currently allow the name to be |
| 1462 | changed (but doing so would break other code). */ |
| 1463 | char const * str = (char const *)sqlite3_column_text(q.pStmt,0); |
| 1464 | if( str ){ |
| 1465 | cson_object_set( obj, "name", |
| 1466 | cson_value_new_string(str,strlen(str)) ); |
| 1467 | } |
| 1468 | str = (char const *)sqlite3_column_text(q.pStmt,1); |
| 1469 | if( str ){ |
| 1470 | cson_object_set( obj, "capabilities", |
| 1471 |