2022-03-22 02:31:03 +00:00
|
|
|
#ifndef COSMOPOLITAN_THIRD_PARTY_LUA_COSMO_H_
|
|
|
|
#define COSMOPOLITAN_THIRD_PARTY_LUA_COSMO_H_
|
|
|
|
#include "net/http/http.h"
|
|
|
|
#include "net/http/url.h"
|
|
|
|
#include "third_party/lua/lauxlib.h"
|
2022-07-22 17:10:33 +00:00
|
|
|
#include "third_party/lua/visitor.h"
|
2022-03-22 02:31:03 +00:00
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
2022-07-22 17:10:33 +00:00
|
|
|
struct EncoderConfig {
|
|
|
|
short maxdepth;
|
|
|
|
bool sorted;
|
|
|
|
bool pretty;
|
|
|
|
const char *indent;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Serializer {
|
|
|
|
struct LuaVisited visited;
|
|
|
|
struct EncoderConfig conf;
|
|
|
|
const char *reason;
|
|
|
|
char *strbuf;
|
|
|
|
size_t strbuflen;
|
2024-06-21 03:46:42 +00:00
|
|
|
uintptr_t bsp;
|
2022-07-22 17:10:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool LuaHasMultipleItems(lua_State *);
|
2023-09-06 10:54:42 +00:00
|
|
|
char *LuaFormatStack(lua_State *) __wur;
|
2022-03-22 02:31:03 +00:00
|
|
|
int LuaCallWithTrace(lua_State *, int, int, lua_State *);
|
2022-07-22 17:10:33 +00:00
|
|
|
int LuaEncodeJsonData(lua_State *, char **, int, struct EncoderConfig);
|
|
|
|
int LuaEncodeLuaData(lua_State *, char **, int, struct EncoderConfig);
|
2022-03-22 02:31:03 +00:00
|
|
|
int LuaEncodeUrl(lua_State *);
|
|
|
|
int LuaParseUrl(lua_State *);
|
2023-09-02 03:49:13 +00:00
|
|
|
int LuaPushHeader(lua_State *, struct HttpMessage *, const char *, int);
|
2022-03-22 02:31:03 +00:00
|
|
|
int LuaPushHeaders(lua_State *, struct HttpMessage *, const char *);
|
2022-04-29 13:06:23 +00:00
|
|
|
void LuaPrintStack(lua_State *);
|
2022-03-22 02:31:03 +00:00
|
|
|
void LuaPushLatin1(lua_State *, const char *, size_t);
|
2022-04-24 16:59:22 +00:00
|
|
|
void LuaPushUrlParams(lua_State *, struct UrlParams *);
|
2022-07-22 17:10:33 +00:00
|
|
|
int SerializeObjectStart(char **, struct Serializer *, int, bool);
|
|
|
|
int SerializeObjectEnd(char **, struct Serializer *, int, bool);
|
|
|
|
int SerializeObjectIndent(char **, struct Serializer *, int);
|
2022-03-22 02:31:03 +00:00
|
|
|
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* COSMOPOLITAN_THIRD_PARTY_LUA_COSMO_H_ */
|