| 486 | } |
| 487 | |
| 488 | static int |
| 489 | ts_lua_base64_decode(lua_State *L) |
| 490 | { |
| 491 | u_char *src; |
| 492 | u_char *dst; |
| 493 | size_t slen; |
| 494 | size_t dlen; |
| 495 | |
| 496 | size_t length; |
| 497 | |
| 498 | if (lua_gettop(L) != 1) { |
| 499 | return luaL_error(L, "expecting one argument"); |
| 500 | } |
| 501 | |
| 502 | if (lua_isnil(L, 1)) { |
| 503 | src = (u_char *)""; |
| 504 | slen = 0; |
| 505 | } else { |
| 506 | src = (u_char *)luaL_checklstring(L, 1, &slen); |
| 507 | } |
| 508 | |
| 509 | dlen = TS_LUA_MAX_STR_LENGTH; |
| 510 | dst = static_cast<u_char *>(lua_newuserdata(L, dlen)); |
| 511 | |
| 512 | if (TS_SUCCESS == TSBase64Decode((const char *)src, slen, (unsigned char *)dst, dlen, &length)) { |
| 513 | lua_pushlstring(L, (char *)dst, length); |
| 514 | return 1; |
| 515 | } else { |
| 516 | return luaL_error(L, "base64 decoding error"); |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | static int |
| 521 | ts_lua_escape_uri(lua_State *L) |
nothing calls this directly
no test coverage detected