summaryrefslogtreecommitdiffhomepage
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/main.c b/main.c
index 950aa03..94b8bde 100644
--- a/main.c
+++ b/main.c
@@ -50,28 +50,26 @@ int main(int argc, char ** argv)
}
}
- const char * handler_path = PLOP_DEFAULT_HANDLER;
-
if (optind < argc)
{
- handler_path = argv[optind];
+ plop.handler = argv[optind];
}
- lua_State * L = plop_initialize_lua();
+ plop.L = plop_initialize_lua();
- if (NULL == L)
+ if (NULL == plop.L)
{
return 9;
}
- if (LUA_OK != plop_load_handler(L, handler_path))
+ if (LUA_OK != plop_load_handler(plop.L, plop.handler))
{
return 2;
}
- const int efd = epoll_create1(0);
+ plop.efd = epoll_create1(0);
- if (-1 == efd)
+ if (-1 == plop.efd)
{
return 3;
}
@@ -81,7 +79,7 @@ int main(int argc, char ** argv)
e.data.ptr = NULL; // TODO: Consider putting server's Lua state in here?
const int server = open_server(NULL, service); // TODO: Check server's fd before ctl?
- if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, server, &e))
+ if (-1 == epoll_ctl(plop.efd, EPOLL_CTL_ADD, server, &e))
{
return 4;
}
@@ -91,7 +89,7 @@ int main(int argc, char ** argv)
while (1)
{
- int evc = epoll_wait(efd, events, MAX_EVENTS, -1);
+ int evc = epoll_wait(plop.efd, events, MAX_EVENTS, -1);
if (-1 == evc)
{
@@ -102,14 +100,14 @@ int main(int argc, char ** argv)
{
if (NULL == events[i].data.ptr)
{
- if (-1 == plop_handle_server(L, efd, server))
+ if (-1 == plop_handle_server(plop.L, plop.efd, server))
{
return 6;
}
}
else
{
- if (-1 == plop_handle_client(L, &events[i]))
+ if (-1 == plop_handle_client(plop.L, &events[i]))
{
return 7;
}