From 1b3a1b74ac3ed64d4e828e97e8da1e7c7df11cde Mon Sep 17 00:00:00 2001 From: Jurie Horneman Date: Sun, 9 Mar 2014 21:09:29 +0100 Subject: [PATCH 1/2] Exposed Lua support functions. --- mongoose.c | 6 +++--- mongoose.h | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mongoose.c b/mongoose.c index 1d51e86c..7c22ae9f 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3704,19 +3704,19 @@ static void *mmap(void *addr, int64_t len, int prot, int flags, int fd, #include #endif -static void reg_string(struct lua_State *L, const char *name, const char *val) { +void reg_string(struct lua_State *L, const char *name, const char *val) { lua_pushstring(L, name); lua_pushstring(L, val); lua_rawset(L, -3); } -static void reg_int(struct lua_State *L, const char *name, int val) { +void reg_int(struct lua_State *L, const char *name, int val) { lua_pushstring(L, name); lua_pushinteger(L, val); lua_rawset(L, -3); } -static void reg_function(struct lua_State *L, const char *name, +void reg_function(struct lua_State *L, const char *name, lua_CFunction func, struct mg_connection *conn) { lua_pushstring(L, name); lua_pushlightuserdata(L, conn); diff --git a/mongoose.h b/mongoose.h index afde089d..3ac824f9 100644 --- a/mongoose.h +++ b/mongoose.h @@ -112,6 +112,14 @@ void *mg_start_thread(void *(*func)(void *), void *param); char *mg_md5(char buf[33], ...); int mg_authorize_digest(struct mg_connection *c, FILE *fp); +// Lua utility functions +#ifdef MONGOOSE_USE_LUA +static void reg_string(struct lua_State *L, const char *name, const char *val); +static void reg_int(struct lua_State *L, const char *name, int val); +static void reg_function(struct lua_State *L, const char *name, + lua_CFunction func, struct mg_connection *conn); +#endif + #ifdef __cplusplus } #endif // __cplusplus From d5a78fb6643e23e030bf46df99f46ae7570a6f4e Mon Sep 17 00:00:00 2001 From: Jurie Horneman Date: Sun, 9 Mar 2014 21:12:34 +0100 Subject: [PATCH 2/2] Fixed bug. --- mongoose.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mongoose.h b/mongoose.h index 3ac824f9..dfece930 100644 --- a/mongoose.h +++ b/mongoose.h @@ -114,9 +114,9 @@ int mg_authorize_digest(struct mg_connection *c, FILE *fp); // Lua utility functions #ifdef MONGOOSE_USE_LUA -static void reg_string(struct lua_State *L, const char *name, const char *val); -static void reg_int(struct lua_State *L, const char *name, int val); -static void reg_function(struct lua_State *L, const char *name, +void reg_string(struct lua_State *L, const char *name, const char *val); +void reg_int(struct lua_State *L, const char *name, int val); +void reg_function(struct lua_State *L, const char *name, lua_CFunction func, struct mg_connection *conn); #endif