Software /
code /
prosody
Comparison
util-src/pposix.c @ 2441:d72078946a16
util.pposix: Replace the unwieldy module table generation with luaL_register() call - side effect - it now sets the pposix global to the module table
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 10 Jan 2010 22:43:28 +0000 |
parent | 2438:819ba949c7bc |
child | 2443:b335ae55af77 |
comparison
equal
deleted
inserted
replaced
2440:11e3d16a128f | 2441:d72078946a16 |
---|---|
484 | 484 |
485 /* Register functions */ | 485 /* Register functions */ |
486 | 486 |
487 int luaopen_util_pposix(lua_State *L) | 487 int luaopen_util_pposix(lua_State *L) |
488 { | 488 { |
489 lua_newtable(L); | 489 luaL_Reg exports[] = { |
490 | 490 { "abort", lc_abort }, |
491 lua_pushcfunction(L, lc_abort); | 491 |
492 lua_setfield(L, -2, "abort"); | 492 { "daemonize", lc_daemonize }, |
493 | 493 |
494 lua_pushcfunction(L, lc_daemonize); | 494 { "syslog_open", lc_syslog_open }, |
495 lua_setfield(L, -2, "daemonize"); | 495 { "syslog_close", lc_syslog_close }, |
496 | 496 { "syslog_log", lc_syslog_log }, |
497 lua_pushcfunction(L, lc_syslog_open); | 497 { "syslog_setminlevel", lc_syslog_setmask }, |
498 lua_setfield(L, -2, "syslog_open"); | 498 |
499 | 499 { "getpid", lc_getpid }, |
500 lua_pushcfunction(L, lc_syslog_close); | 500 { "getuid", lc_getuid }, |
501 lua_setfield(L, -2, "syslog_close"); | 501 { "getgid", lc_getgid }, |
502 | 502 |
503 lua_pushcfunction(L, lc_syslog_log); | 503 { "setuid", lc_setuid }, |
504 lua_setfield(L, -2, "syslog_log"); | 504 { "setgid", lc_setgid }, |
505 | 505 |
506 lua_pushcfunction(L, lc_syslog_setmask); | 506 { "umask", lc_umask }, |
507 lua_setfield(L, -2, "syslog_setminlevel"); | 507 |
508 | 508 { "setrlimit", lc_setrlimit }, |
509 lua_pushcfunction(L, lc_getpid); | 509 { "getrlimit", lc_getrlimit }, |
510 lua_setfield(L, -2, "getpid"); | 510 |
511 | 511 { NULL, NULL } |
512 lua_pushcfunction(L, lc_getuid); | 512 }; |
513 lua_setfield(L, -2, "getuid"); | 513 |
514 lua_pushcfunction(L, lc_getgid); | 514 luaL_register(L, "pposix", exports); |
515 lua_setfield(L, -2, "getgid"); | |
516 | |
517 lua_pushcfunction(L, lc_setuid); | |
518 lua_setfield(L, -2, "setuid"); | |
519 lua_pushcfunction(L, lc_setgid); | |
520 lua_setfield(L, -2, "setgid"); | |
521 | |
522 lua_pushcfunction(L, lc_umask); | |
523 lua_setfield(L, -2, "umask"); | |
524 | |
525 lua_pushcfunction(L, lc_setrlimit); | |
526 lua_setfield(L, -2, "setrlimit"); | |
527 | |
528 lua_pushcfunction(L, lc_getrlimit); | |
529 lua_setfield(L, -2, "getrlimit"); | |
530 | 515 |
531 lua_pushliteral(L, "pposix"); | 516 lua_pushliteral(L, "pposix"); |
532 lua_setfield(L, -2, "_NAME"); | 517 lua_setfield(L, -2, "_NAME"); |
533 | 518 |
534 lua_pushliteral(L, MODULE_VERSION); | 519 lua_pushliteral(L, MODULE_VERSION); |