Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
eaa0e26a
Commit
eaa0e26a
authored
Feb 06, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starting to rebuild chat example on Lua
parent
a3a63f7e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
390 deletions
+26
-390
Makefile
examples/Makefile
+13
-8
chat.c
examples/chat.c
+8
-379
mongoose.c
mongoose.c
+5
-3
No files found.
examples/Makefile
View file @
eaa0e26a
CFLAGS
=
-W
-Wall
-I
..
-pthread
-g
-pipe
$(CFLAGS_EXTRA)
CFLAGS
=
-W
-Wall
-I
..
-pthread
-g
-pipe
$(CFLAGS_EXTRA)
DLL_FLAGS
=
-DLUA_COMPAT_ALL
-I
../build
RM
=
rm
-rf
RM
=
rm
-rf
MSVC
=
../../vc6
CL
=
$(MSVC)
/bin/cl
CLFLAGS
=
/MD /TC /nologo
$(CFLAGS_EXTRA)
/W3
\
/I
$(MSVC)
/include /I.. /Dsnprintf
=
_snprintf
LFLAGS
=
/link /incremental:no /libpath:
$(MSVC)
/lib /machine:IX86
LUA_FLAGS
=
-I
/usr/local/include
-L
/usr/local/lib
-llua
ifeq
($(OS),Windows_NT)
RM
=
del /q /f
CC
=
$(MSVC)
/bin/cl
$(CLFLAGS)
else
UNAME_S
:=
$(
shell
uname
-s
)
DLL_FLAGS
+=
-shared
...
...
@@ -27,18 +35,15 @@ all: websocket_html.c
$(CC)
auth.c ../mongoose.c
-o
auth
$(CFLAGS)
$(CC)
server.c ../mongoose.c
-o
server
$(CFLAGS)
chat$(EXE_SUFFIX)
:
chat.c
$(CC)
chat.c ../mongoose.c
-DMONGOOSE_USE_LUA
-o
$@
$(CFLAGS)
$(LUA_FLAGS)
# $(CC) chat.c ../mongoose.c -o chat $(CFLAGS)
# $(CC) lua_dll.c ../build/lua_5.2.1.c -o $@.so $(CFLAGS) $(DLL_FLAGS)
websocket_html.c
:
websocket.html
perl mkdata.pl
$<
>
$@
MSVC
=
../../vc6
CL
=
$(MSVC)
/bin/cl
CLFLAGS
=
/MD /TC /nologo
$(DBG)
/W3
\
/I
$(MSVC)
/include /I.. /Dsnprintf
=
_snprintf
LFLAGS
=
/link /incremental:no /libpath:
$(MSVC)
/lib /machine:IX86
windows
:
websocket_html.c
$(CL)
hello.c ../mongoose.c
$(CLFLAGS)
$(LFLAGS)
$(CL)
websocket.c websocket_html.c ../mongoose.c
$(CLFLAGS)
$(LFLAGS)
...
...
examples/chat.c
View file @
eaa0e26a
This diff is collapsed.
Click to expand it.
mongoose.c
View file @
eaa0e26a
...
...
@@ -3290,7 +3290,9 @@ static void prepare_lua_environment(struct mg_connection *ri, lua_State *L) {
luaL_newmetatable
(
L
,
"luasocket"
);
lua_pushliteral
(
L
,
"__index"
);
luaL_newlib
(
L
,
luasocket_methods
);
lua_newtable
(
L
);
luaL_register
(
L
,
NULL
,
luasocket_methods
);
//luaL_newlib(L, luasocket_methods);
lua_rawset
(
L
,
-
3
);
lua_pop
(
L
,
1
);
lua_register
(
L
,
"connect"
,
lsp_connect
);
...
...
@@ -3357,7 +3359,7 @@ static void lsp(struct connection *conn, const char *p, int len, lua_State *L) {
for
(
j
=
i
+
1
;
j
<
len
;
j
++
)
{
if
(
p
[
j
]
==
'?'
&&
p
[
j
+
1
]
==
'>'
)
{
mg_write
(
&
conn
->
mg_conn
,
p
+
pos
,
i
-
pos
);
if
(
luaL_loadbuffer
(
L
,
p
+
(
i
+
2
),
j
-
(
i
+
2
),
""
)
==
LUA_OK
)
{
if
(
luaL_loadbuffer
(
L
,
p
+
(
i
+
2
),
j
-
(
i
+
2
),
""
)
==
0
)
{
lua_pcall
(
L
,
0
,
LUA_MULTRET
,
0
);
}
pos
=
j
+
2
;
...
...
@@ -3385,7 +3387,7 @@ static void handle_lsp_request(struct connection *conn, const char *path,
// We're not sending HTTP headers here, Lua page must do it.
prepare_lua_environment
(
&
conn
->
mg_conn
,
L
);
lua_pushcclosure
(
L
,
&
lua_error_handler
,
0
);
lua_push
globaltable
(
L
);
lua_push
value
(
L
,
LUA_GLOBALSINDEX
);
lsp
(
conn
,
p
,
(
int
)
st
->
st_size
,
L
);
close_local_endpoint
(
conn
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment