Fossil SCM
Added /json/resultCodes.
Commit
71a1d4483f71aeb4e7943f6a65a567a45db0a6e6
Parent
a403544f2ad2993…
2 files changed
+1
+72
-10
+1
| --- ajax/index.html | ||
| +++ ajax/index.html | ||
| @@ -232,10 +232,11 @@ | ||
| 232 | 232 | <input type='button' value='timeline/ticket' onclick='TheApp.cgi.sendCommand("/json/timeline/ticket")' /> |
| 233 | 233 | <input type='button' value='wiki/list' onclick='TheApp.cgi.sendCommand("/json/wiki/list")' /> |
| 234 | 234 | <input type='button' value='wiki/get Fossil' onclick='TheApp.cgi.sendCommand("/json/wiki/get",{page:"Fossil"})' /> |
| 235 | 235 | <input type='button' value='user/list' onclick='TheApp.cgi.sendCommand("/json/user/list")' /> |
| 236 | 236 | <input type='button' value='user/get' onclick='TheApp.cgi.sendCommand("/json/user/get?name=anonymous")' /> |
| 237 | +<input type='button' value='resultCodes' onclick='TheApp.cgi.sendCommand("/json/resultCodes")' /> | |
| 237 | 238 | <!-- not yet ready... |
| 238 | 239 | <input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' /> |
| 239 | 240 | --> |
| 240 | 241 | |
| 241 | 242 | <!-- |
| 242 | 243 |
| --- ajax/index.html | |
| +++ ajax/index.html | |
| @@ -232,10 +232,11 @@ | |
| 232 | <input type='button' value='timeline/ticket' onclick='TheApp.cgi.sendCommand("/json/timeline/ticket")' /> |
| 233 | <input type='button' value='wiki/list' onclick='TheApp.cgi.sendCommand("/json/wiki/list")' /> |
| 234 | <input type='button' value='wiki/get Fossil' onclick='TheApp.cgi.sendCommand("/json/wiki/get",{page:"Fossil"})' /> |
| 235 | <input type='button' value='user/list' onclick='TheApp.cgi.sendCommand("/json/user/list")' /> |
| 236 | <input type='button' value='user/get' onclick='TheApp.cgi.sendCommand("/json/user/get?name=anonymous")' /> |
| 237 | <!-- not yet ready... |
| 238 | <input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' /> |
| 239 | --> |
| 240 | |
| 241 | <!-- |
| 242 |
| --- ajax/index.html | |
| +++ ajax/index.html | |
| @@ -232,10 +232,11 @@ | |
| 232 | <input type='button' value='timeline/ticket' onclick='TheApp.cgi.sendCommand("/json/timeline/ticket")' /> |
| 233 | <input type='button' value='wiki/list' onclick='TheApp.cgi.sendCommand("/json/wiki/list")' /> |
| 234 | <input type='button' value='wiki/get Fossil' onclick='TheApp.cgi.sendCommand("/json/wiki/get",{page:"Fossil"})' /> |
| 235 | <input type='button' value='user/list' onclick='TheApp.cgi.sendCommand("/json/user/list")' /> |
| 236 | <input type='button' value='user/get' onclick='TheApp.cgi.sendCommand("/json/user/get?name=anonymous")' /> |
| 237 | <input type='button' value='resultCodes' onclick='TheApp.cgi.sendCommand("/json/resultCodes")' /> |
| 238 | <!-- not yet ready... |
| 239 | <input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' /> |
| 240 | --> |
| 241 | |
| 242 | <!-- |
| 243 |
+72
-10
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -214,14 +214,14 @@ | ||
| 214 | 214 | return NULL; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /* |
| 218 | 218 | ** Given a FossilJsonCodes value, it returns a string suitable for use |
| 219 | -** as a resultText string. Returns some unspecified string if errCode | |
| 220 | -** is not one of the FossilJsonCodes values. | |
| 219 | +** as a resultCode string. Returns some unspecified non-empty string | |
| 220 | +** if errCode is not one of the FossilJsonCodes values. | |
| 221 | 221 | */ |
| 222 | -char const * json_err_str( int errCode ){ | |
| 222 | +static char const * json_err_cstr( int errCode ){ | |
| 223 | 223 | switch( errCode ){ |
| 224 | 224 | case 0: return "Success"; |
| 225 | 225 | #define C(X,V) case FSL_JSON_E_ ## X: return V |
| 226 | 226 | |
| 227 | 227 | C(GENERIC,"Generic error"); |
| @@ -231,12 +231,12 @@ | ||
| 231 | 231 | C(TIMEOUT,"Timeout reached"); |
| 232 | 232 | C(ASSERT,"Assertion failed"); |
| 233 | 233 | C(ALLOC,"Resource allocation failed"); |
| 234 | 234 | C(NYI,"Not yet implemented"); |
| 235 | 235 | C(PANIC,"x"); |
| 236 | - C(MANIFEST_READ_FAILED,"Reading artifact manifest failed."); | |
| 237 | - C(FILE_OPEN_FAILED,"Opening file failed."); | |
| 236 | + C(MANIFEST_READ_FAILED,"Reading artifact manifest failed"); | |
| 237 | + C(FILE_OPEN_FAILED,"Opening file failed"); | |
| 238 | 238 | |
| 239 | 239 | C(AUTH,"Authentication error"); |
| 240 | 240 | C(MISSING_AUTH,"Authentication info missing from request"); |
| 241 | 241 | C(DENIED,"Access denied"); |
| 242 | 242 | C(WRONG_MODE,"Request not allowed (wrong operation mode)"); |
| @@ -1322,11 +1322,11 @@ | ||
| 1322 | 1322 | ** response. In either case, onwership of payload is transfered to |
| 1323 | 1323 | ** this function. |
| 1324 | 1324 | ** |
| 1325 | 1325 | ** pMsg is an optional message string property (resultText) of the |
| 1326 | 1326 | ** response. If resultCode is non-0 and pMsg is NULL then |
| 1327 | -** json_err_str() is used to get the error string. The caller may | |
| 1327 | +** json_err_cstr() is used to get the error string. The caller may | |
| 1328 | 1328 | ** provide his own or may use an empty string to suppress the |
| 1329 | 1329 | ** resultText property. |
| 1330 | 1330 | ** |
| 1331 | 1331 | */ |
| 1332 | 1332 | cson_value * json_create_response( int resultCode, |
| @@ -1358,11 +1358,11 @@ | ||
| 1358 | 1358 | |
| 1359 | 1359 | if( 0 != resultCode ){ |
| 1360 | 1360 | if( ! pMsg ){ |
| 1361 | 1361 | pMsg = g.zErrMsg; |
| 1362 | 1362 | if(!pMsg){ |
| 1363 | - pMsg = json_err_str(resultCode); | |
| 1363 | + pMsg = json_err_cstr(resultCode); | |
| 1364 | 1364 | } |
| 1365 | 1365 | } |
| 1366 | 1366 | tmp = json_new_string(json_rc_cstr(resultCode)); |
| 1367 | 1367 | SET(FossilJsonKeys.resultCode); |
| 1368 | 1368 | } |
| @@ -1454,11 +1454,11 @@ | ||
| 1454 | 1454 | ** !g.isHTTP then alsoOutput is ignored and all output is sent to |
| 1455 | 1455 | ** stdout immediately. |
| 1456 | 1456 | ** |
| 1457 | 1457 | ** For generating the resultText property: if msg is not NULL then it |
| 1458 | 1458 | ** is used as-is. If it is NULL then g.zErrMsg is checked, and if that |
| 1459 | -** is NULL then json_err_str(code) is used. | |
| 1459 | +** is NULL then json_err_cstr(code) is used. | |
| 1460 | 1460 | */ |
| 1461 | 1461 | void json_err( int code, char const * msg, char alsoOutput ){ |
| 1462 | 1462 | int rc = code ? code : (g.json.resultCode |
| 1463 | 1463 | ? g.json.resultCode |
| 1464 | 1464 | : FSL_JSON_E_UNKNOWN); |
| @@ -1465,11 +1465,11 @@ | ||
| 1465 | 1465 | cson_value * resp = NULL; |
| 1466 | 1466 | rc = json_dumbdown_rc(rc); |
| 1467 | 1467 | if( rc && !msg ){ |
| 1468 | 1468 | msg = g.zErrMsg; |
| 1469 | 1469 | if(!msg){ |
| 1470 | - msg = json_err_str(rc); | |
| 1470 | + msg = json_err_cstr(rc); | |
| 1471 | 1471 | } |
| 1472 | 1472 | } |
| 1473 | 1473 | resp = json_create_response(rc, msg, NULL); |
| 1474 | 1474 | if(!resp){ |
| 1475 | 1475 | /* about the only error case here is out-of-memory. DO NOT |
| @@ -1508,11 +1508,11 @@ | ||
| 1508 | 1508 | int json_set_err( int code, char const * fmt, ... ){ |
| 1509 | 1509 | assert( (code>=1000) && (code<=9999) ); |
| 1510 | 1510 | free(g.zErrMsg); |
| 1511 | 1511 | g.json.resultCode = code; |
| 1512 | 1512 | if(!fmt || !*fmt){ |
| 1513 | - g.zErrMsg = mprintf("%s", json_err_str(code)); | |
| 1513 | + g.zErrMsg = mprintf("%s", json_err_cstr(code)); | |
| 1514 | 1514 | }else{ |
| 1515 | 1515 | va_list vargs; |
| 1516 | 1516 | va_start(vargs,fmt); |
| 1517 | 1517 | char * msg = vmprintf(fmt, vargs); |
| 1518 | 1518 | va_end(vargs); |
| @@ -1567,10 +1567,71 @@ | ||
| 1567 | 1567 | } |
| 1568 | 1568 | free(tags); |
| 1569 | 1569 | } |
| 1570 | 1570 | return v; |
| 1571 | 1571 | } |
| 1572 | + | |
| 1573 | +/* | |
| 1574 | +** Impl of /json/resultCodes | |
| 1575 | +** | |
| 1576 | +*/ | |
| 1577 | +cson_value * json_page_resultCodes(){ | |
| 1578 | + cson_value * listV = cson_value_new_array(); | |
| 1579 | + cson_array * list = cson_value_get_array(listV); | |
| 1580 | + cson_value * objV = NULL; | |
| 1581 | + cson_object * obj = NULL; | |
| 1582 | + int rc = cson_array_reserve( list, 35 ); | |
| 1583 | + if(rc){ | |
| 1584 | + assert( 0 && "Allocation error."); | |
| 1585 | + exit(1); | |
| 1586 | + } | |
| 1587 | +#define C(K) objV = cson_value_new_object(); obj = cson_value_get_object(objV); \ | |
| 1588 | + cson_object_set(obj, "resultCode", json_new_string(json_rc_cstr(FSL_JSON_E_##K)) ); \ | |
| 1589 | + cson_object_set(obj, "cSymbol", json_new_string("FSL_JSON_E_"#K) ); \ | |
| 1590 | + cson_object_set(obj, "number", cson_value_new_integer(FSL_JSON_E_##K) ); \ | |
| 1591 | + cson_object_set(obj, "description", json_new_string(json_err_cstr(FSL_JSON_E_##K))); \ | |
| 1592 | + cson_array_append( list, objV ); obj = NULL; objV = NULL | |
| 1593 | + | |
| 1594 | + C(GENERIC); | |
| 1595 | + C(INVALID_REQUEST); | |
| 1596 | + C(UNKNOWN_COMMAND); | |
| 1597 | + C(UNKNOWN); | |
| 1598 | + C(TIMEOUT); | |
| 1599 | + C(ASSERT); | |
| 1600 | + C(ALLOC); | |
| 1601 | + C(NYI); | |
| 1602 | + C(PANIC); | |
| 1603 | + C(MANIFEST_READ_FAILED); | |
| 1604 | + C(FILE_OPEN_FAILED); | |
| 1605 | + | |
| 1606 | + C(AUTH); | |
| 1607 | + C(MISSING_AUTH); | |
| 1608 | + C(DENIED); | |
| 1609 | + C(WRONG_MODE); | |
| 1610 | + C(LOGIN_FAILED); | |
| 1611 | + C(LOGIN_FAILED_NOSEED); | |
| 1612 | + C(LOGIN_FAILED_NONAME); | |
| 1613 | + C(LOGIN_FAILED_NOPW); | |
| 1614 | + C(LOGIN_FAILED_NOTFOUND); | |
| 1615 | + | |
| 1616 | + C(USAGE); | |
| 1617 | + C(INVALID_ARGS); | |
| 1618 | + C(MISSING_ARGS); | |
| 1619 | + C(AMBIGUOUS_UUID); | |
| 1620 | + C(UNRESOLVED_UUID); | |
| 1621 | + C(RESOURCE_ALREADY_EXISTS); | |
| 1622 | + C(RESOURCE_NOT_FOUND); | |
| 1623 | + | |
| 1624 | + C(DB); | |
| 1625 | + C(STMT_PREP); | |
| 1626 | + C(STMT_BIND); | |
| 1627 | + C(STMT_EXEC); | |
| 1628 | + C(DB_LOCKED); | |
| 1629 | + C(DB_NEEDS_REBUILD); | |
| 1630 | +#undef C | |
| 1631 | + return listV; | |
| 1632 | +} | |
| 1572 | 1633 | |
| 1573 | 1634 | |
| 1574 | 1635 | /* |
| 1575 | 1636 | ** /json/version implementation. |
| 1576 | 1637 | ** |
| @@ -1928,10 +1989,11 @@ | ||
| 1928 | 1989 | {"dir", json_page_nyi, 0}, |
| 1929 | 1990 | {"HAI",json_page_version,0}, |
| 1930 | 1991 | {"login",json_page_login,1}, |
| 1931 | 1992 | {"logout",json_page_logout,1}, |
| 1932 | 1993 | {"rebuild",json_page_rebuild,0}, |
| 1994 | +{"resultCodes", json_page_resultCodes,0}, | |
| 1933 | 1995 | {"stat",json_page_stat,0}, |
| 1934 | 1996 | {"tag", json_page_nyi,0}, |
| 1935 | 1997 | {"ticket", json_page_nyi,0}, |
| 1936 | 1998 | {"timeline", json_page_timeline,0}, |
| 1937 | 1999 | {"user",json_page_user,0}, |
| 1938 | 2000 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -214,14 +214,14 @@ | |
| 214 | return NULL; |
| 215 | } |
| 216 | |
| 217 | /* |
| 218 | ** Given a FossilJsonCodes value, it returns a string suitable for use |
| 219 | ** as a resultText string. Returns some unspecified string if errCode |
| 220 | ** is not one of the FossilJsonCodes values. |
| 221 | */ |
| 222 | char const * json_err_str( int errCode ){ |
| 223 | switch( errCode ){ |
| 224 | case 0: return "Success"; |
| 225 | #define C(X,V) case FSL_JSON_E_ ## X: return V |
| 226 | |
| 227 | C(GENERIC,"Generic error"); |
| @@ -231,12 +231,12 @@ | |
| 231 | C(TIMEOUT,"Timeout reached"); |
| 232 | C(ASSERT,"Assertion failed"); |
| 233 | C(ALLOC,"Resource allocation failed"); |
| 234 | C(NYI,"Not yet implemented"); |
| 235 | C(PANIC,"x"); |
| 236 | C(MANIFEST_READ_FAILED,"Reading artifact manifest failed."); |
| 237 | C(FILE_OPEN_FAILED,"Opening file failed."); |
| 238 | |
| 239 | C(AUTH,"Authentication error"); |
| 240 | C(MISSING_AUTH,"Authentication info missing from request"); |
| 241 | C(DENIED,"Access denied"); |
| 242 | C(WRONG_MODE,"Request not allowed (wrong operation mode)"); |
| @@ -1322,11 +1322,11 @@ | |
| 1322 | ** response. In either case, onwership of payload is transfered to |
| 1323 | ** this function. |
| 1324 | ** |
| 1325 | ** pMsg is an optional message string property (resultText) of the |
| 1326 | ** response. If resultCode is non-0 and pMsg is NULL then |
| 1327 | ** json_err_str() is used to get the error string. The caller may |
| 1328 | ** provide his own or may use an empty string to suppress the |
| 1329 | ** resultText property. |
| 1330 | ** |
| 1331 | */ |
| 1332 | cson_value * json_create_response( int resultCode, |
| @@ -1358,11 +1358,11 @@ | |
| 1358 | |
| 1359 | if( 0 != resultCode ){ |
| 1360 | if( ! pMsg ){ |
| 1361 | pMsg = g.zErrMsg; |
| 1362 | if(!pMsg){ |
| 1363 | pMsg = json_err_str(resultCode); |
| 1364 | } |
| 1365 | } |
| 1366 | tmp = json_new_string(json_rc_cstr(resultCode)); |
| 1367 | SET(FossilJsonKeys.resultCode); |
| 1368 | } |
| @@ -1454,11 +1454,11 @@ | |
| 1454 | ** !g.isHTTP then alsoOutput is ignored and all output is sent to |
| 1455 | ** stdout immediately. |
| 1456 | ** |
| 1457 | ** For generating the resultText property: if msg is not NULL then it |
| 1458 | ** is used as-is. If it is NULL then g.zErrMsg is checked, and if that |
| 1459 | ** is NULL then json_err_str(code) is used. |
| 1460 | */ |
| 1461 | void json_err( int code, char const * msg, char alsoOutput ){ |
| 1462 | int rc = code ? code : (g.json.resultCode |
| 1463 | ? g.json.resultCode |
| 1464 | : FSL_JSON_E_UNKNOWN); |
| @@ -1465,11 +1465,11 @@ | |
| 1465 | cson_value * resp = NULL; |
| 1466 | rc = json_dumbdown_rc(rc); |
| 1467 | if( rc && !msg ){ |
| 1468 | msg = g.zErrMsg; |
| 1469 | if(!msg){ |
| 1470 | msg = json_err_str(rc); |
| 1471 | } |
| 1472 | } |
| 1473 | resp = json_create_response(rc, msg, NULL); |
| 1474 | if(!resp){ |
| 1475 | /* about the only error case here is out-of-memory. DO NOT |
| @@ -1508,11 +1508,11 @@ | |
| 1508 | int json_set_err( int code, char const * fmt, ... ){ |
| 1509 | assert( (code>=1000) && (code<=9999) ); |
| 1510 | free(g.zErrMsg); |
| 1511 | g.json.resultCode = code; |
| 1512 | if(!fmt || !*fmt){ |
| 1513 | g.zErrMsg = mprintf("%s", json_err_str(code)); |
| 1514 | }else{ |
| 1515 | va_list vargs; |
| 1516 | va_start(vargs,fmt); |
| 1517 | char * msg = vmprintf(fmt, vargs); |
| 1518 | va_end(vargs); |
| @@ -1567,10 +1567,71 @@ | |
| 1567 | } |
| 1568 | free(tags); |
| 1569 | } |
| 1570 | return v; |
| 1571 | } |
| 1572 | |
| 1573 | |
| 1574 | /* |
| 1575 | ** /json/version implementation. |
| 1576 | ** |
| @@ -1928,10 +1989,11 @@ | |
| 1928 | {"dir", json_page_nyi, 0}, |
| 1929 | {"HAI",json_page_version,0}, |
| 1930 | {"login",json_page_login,1}, |
| 1931 | {"logout",json_page_logout,1}, |
| 1932 | {"rebuild",json_page_rebuild,0}, |
| 1933 | {"stat",json_page_stat,0}, |
| 1934 | {"tag", json_page_nyi,0}, |
| 1935 | {"ticket", json_page_nyi,0}, |
| 1936 | {"timeline", json_page_timeline,0}, |
| 1937 | {"user",json_page_user,0}, |
| 1938 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -214,14 +214,14 @@ | |
| 214 | return NULL; |
| 215 | } |
| 216 | |
| 217 | /* |
| 218 | ** Given a FossilJsonCodes value, it returns a string suitable for use |
| 219 | ** as a resultCode string. Returns some unspecified non-empty string |
| 220 | ** if errCode is not one of the FossilJsonCodes values. |
| 221 | */ |
| 222 | static char const * json_err_cstr( int errCode ){ |
| 223 | switch( errCode ){ |
| 224 | case 0: return "Success"; |
| 225 | #define C(X,V) case FSL_JSON_E_ ## X: return V |
| 226 | |
| 227 | C(GENERIC,"Generic error"); |
| @@ -231,12 +231,12 @@ | |
| 231 | C(TIMEOUT,"Timeout reached"); |
| 232 | C(ASSERT,"Assertion failed"); |
| 233 | C(ALLOC,"Resource allocation failed"); |
| 234 | C(NYI,"Not yet implemented"); |
| 235 | C(PANIC,"x"); |
| 236 | C(MANIFEST_READ_FAILED,"Reading artifact manifest failed"); |
| 237 | C(FILE_OPEN_FAILED,"Opening file failed"); |
| 238 | |
| 239 | C(AUTH,"Authentication error"); |
| 240 | C(MISSING_AUTH,"Authentication info missing from request"); |
| 241 | C(DENIED,"Access denied"); |
| 242 | C(WRONG_MODE,"Request not allowed (wrong operation mode)"); |
| @@ -1322,11 +1322,11 @@ | |
| 1322 | ** response. In either case, onwership of payload is transfered to |
| 1323 | ** this function. |
| 1324 | ** |
| 1325 | ** pMsg is an optional message string property (resultText) of the |
| 1326 | ** response. If resultCode is non-0 and pMsg is NULL then |
| 1327 | ** json_err_cstr() is used to get the error string. The caller may |
| 1328 | ** provide his own or may use an empty string to suppress the |
| 1329 | ** resultText property. |
| 1330 | ** |
| 1331 | */ |
| 1332 | cson_value * json_create_response( int resultCode, |
| @@ -1358,11 +1358,11 @@ | |
| 1358 | |
| 1359 | if( 0 != resultCode ){ |
| 1360 | if( ! pMsg ){ |
| 1361 | pMsg = g.zErrMsg; |
| 1362 | if(!pMsg){ |
| 1363 | pMsg = json_err_cstr(resultCode); |
| 1364 | } |
| 1365 | } |
| 1366 | tmp = json_new_string(json_rc_cstr(resultCode)); |
| 1367 | SET(FossilJsonKeys.resultCode); |
| 1368 | } |
| @@ -1454,11 +1454,11 @@ | |
| 1454 | ** !g.isHTTP then alsoOutput is ignored and all output is sent to |
| 1455 | ** stdout immediately. |
| 1456 | ** |
| 1457 | ** For generating the resultText property: if msg is not NULL then it |
| 1458 | ** is used as-is. If it is NULL then g.zErrMsg is checked, and if that |
| 1459 | ** is NULL then json_err_cstr(code) is used. |
| 1460 | */ |
| 1461 | void json_err( int code, char const * msg, char alsoOutput ){ |
| 1462 | int rc = code ? code : (g.json.resultCode |
| 1463 | ? g.json.resultCode |
| 1464 | : FSL_JSON_E_UNKNOWN); |
| @@ -1465,11 +1465,11 @@ | |
| 1465 | cson_value * resp = NULL; |
| 1466 | rc = json_dumbdown_rc(rc); |
| 1467 | if( rc && !msg ){ |
| 1468 | msg = g.zErrMsg; |
| 1469 | if(!msg){ |
| 1470 | msg = json_err_cstr(rc); |
| 1471 | } |
| 1472 | } |
| 1473 | resp = json_create_response(rc, msg, NULL); |
| 1474 | if(!resp){ |
| 1475 | /* about the only error case here is out-of-memory. DO NOT |
| @@ -1508,11 +1508,11 @@ | |
| 1508 | int json_set_err( int code, char const * fmt, ... ){ |
| 1509 | assert( (code>=1000) && (code<=9999) ); |
| 1510 | free(g.zErrMsg); |
| 1511 | g.json.resultCode = code; |
| 1512 | if(!fmt || !*fmt){ |
| 1513 | g.zErrMsg = mprintf("%s", json_err_cstr(code)); |
| 1514 | }else{ |
| 1515 | va_list vargs; |
| 1516 | va_start(vargs,fmt); |
| 1517 | char * msg = vmprintf(fmt, vargs); |
| 1518 | va_end(vargs); |
| @@ -1567,10 +1567,71 @@ | |
| 1567 | } |
| 1568 | free(tags); |
| 1569 | } |
| 1570 | return v; |
| 1571 | } |
| 1572 | |
| 1573 | /* |
| 1574 | ** Impl of /json/resultCodes |
| 1575 | ** |
| 1576 | */ |
| 1577 | cson_value * json_page_resultCodes(){ |
| 1578 | cson_value * listV = cson_value_new_array(); |
| 1579 | cson_array * list = cson_value_get_array(listV); |
| 1580 | cson_value * objV = NULL; |
| 1581 | cson_object * obj = NULL; |
| 1582 | int rc = cson_array_reserve( list, 35 ); |
| 1583 | if(rc){ |
| 1584 | assert( 0 && "Allocation error."); |
| 1585 | exit(1); |
| 1586 | } |
| 1587 | #define C(K) objV = cson_value_new_object(); obj = cson_value_get_object(objV); \ |
| 1588 | cson_object_set(obj, "resultCode", json_new_string(json_rc_cstr(FSL_JSON_E_##K)) ); \ |
| 1589 | cson_object_set(obj, "cSymbol", json_new_string("FSL_JSON_E_"#K) ); \ |
| 1590 | cson_object_set(obj, "number", cson_value_new_integer(FSL_JSON_E_##K) ); \ |
| 1591 | cson_object_set(obj, "description", json_new_string(json_err_cstr(FSL_JSON_E_##K))); \ |
| 1592 | cson_array_append( list, objV ); obj = NULL; objV = NULL |
| 1593 | |
| 1594 | C(GENERIC); |
| 1595 | C(INVALID_REQUEST); |
| 1596 | C(UNKNOWN_COMMAND); |
| 1597 | C(UNKNOWN); |
| 1598 | C(TIMEOUT); |
| 1599 | C(ASSERT); |
| 1600 | C(ALLOC); |
| 1601 | C(NYI); |
| 1602 | C(PANIC); |
| 1603 | C(MANIFEST_READ_FAILED); |
| 1604 | C(FILE_OPEN_FAILED); |
| 1605 | |
| 1606 | C(AUTH); |
| 1607 | C(MISSING_AUTH); |
| 1608 | C(DENIED); |
| 1609 | C(WRONG_MODE); |
| 1610 | C(LOGIN_FAILED); |
| 1611 | C(LOGIN_FAILED_NOSEED); |
| 1612 | C(LOGIN_FAILED_NONAME); |
| 1613 | C(LOGIN_FAILED_NOPW); |
| 1614 | C(LOGIN_FAILED_NOTFOUND); |
| 1615 | |
| 1616 | C(USAGE); |
| 1617 | C(INVALID_ARGS); |
| 1618 | C(MISSING_ARGS); |
| 1619 | C(AMBIGUOUS_UUID); |
| 1620 | C(UNRESOLVED_UUID); |
| 1621 | C(RESOURCE_ALREADY_EXISTS); |
| 1622 | C(RESOURCE_NOT_FOUND); |
| 1623 | |
| 1624 | C(DB); |
| 1625 | C(STMT_PREP); |
| 1626 | C(STMT_BIND); |
| 1627 | C(STMT_EXEC); |
| 1628 | C(DB_LOCKED); |
| 1629 | C(DB_NEEDS_REBUILD); |
| 1630 | #undef C |
| 1631 | return listV; |
| 1632 | } |
| 1633 | |
| 1634 | |
| 1635 | /* |
| 1636 | ** /json/version implementation. |
| 1637 | ** |
| @@ -1928,10 +1989,11 @@ | |
| 1989 | {"dir", json_page_nyi, 0}, |
| 1990 | {"HAI",json_page_version,0}, |
| 1991 | {"login",json_page_login,1}, |
| 1992 | {"logout",json_page_logout,1}, |
| 1993 | {"rebuild",json_page_rebuild,0}, |
| 1994 | {"resultCodes", json_page_resultCodes,0}, |
| 1995 | {"stat",json_page_stat,0}, |
| 1996 | {"tag", json_page_nyi,0}, |
| 1997 | {"ticket", json_page_nyi,0}, |
| 1998 | {"timeline", json_page_timeline,0}, |
| 1999 | {"user",json_page_user,0}, |
| 2000 |