prosody: Fixed a possible nil concatenation.
[prosody.git] / util-src / pposix.c
index 993e6e876becf361d6f098382c20700fc6078d55..94086ed64dc3ca24e77e7e8faec8a24dcecd7d96 100644 (file)
@@ -13,7 +13,7 @@
 * POSIX support functions for Lua
 */
 
-#define MODULE_VERSION "0.3.0"
+#define MODULE_VERSION "0.3.1"
 
 #include <stdlib.h>
 #include <unistd.h>
@@ -91,10 +91,14 @@ static int lc_daemonize(lua_State *L)
 
 const char * const facility_strings[] = {
                                        "auth",
+#if !(defined(sun) || defined(__sun))
                                        "authpriv",
+#endif
                                        "cron",
                                        "daemon",
+#if !(defined(sun) || defined(__sun))
                                        "ftp",
+#endif
                                        "kern",
                                        "local0",
                                        "local1",
@@ -113,10 +117,14 @@ const char * const facility_strings[] = {
                                };
 int facility_constants[] =     {
                                        LOG_AUTH,
+#if !(defined(sun) || defined(__sun))
                                        LOG_AUTHPRIV,
+#endif
                                        LOG_CRON,
                                        LOG_DAEMON,
+#if !(defined(sun) || defined(__sun))
                                        LOG_FTP,
+#endif
                                        LOG_KERN,
                                        LOG_LOCAL0,
                                        LOG_LOCAL1,
@@ -365,11 +373,13 @@ int string2resource(const char *s) {
        if (!strcmp(s, "CPU")) return RLIMIT_CPU;
        if (!strcmp(s, "DATA")) return RLIMIT_DATA;
        if (!strcmp(s, "FSIZE")) return RLIMIT_FSIZE;
-       if (!strcmp(s, "MEMLOCK")) return RLIMIT_MEMLOCK;
        if (!strcmp(s, "NOFILE")) return RLIMIT_NOFILE;
+       if (!strcmp(s, "STACK")) return RLIMIT_STACK;
+#if !(defined(sun) || defined(__sun))
+       if (!strcmp(s, "MEMLOCK")) return RLIMIT_MEMLOCK;
        if (!strcmp(s, "NPROC")) return RLIMIT_NPROC;
        if (!strcmp(s, "RSS")) return RLIMIT_RSS;
-       if (!strcmp(s, "STACK")) return RLIMIT_STACK;
+#endif
        return -1;
 }
 
@@ -453,12 +463,20 @@ int lc_getrlimit(lua_State *L) {
        return 3;
 }
 
+void lc_abort(lua_State* L)
+{
+       abort();
+}
+
 /* Register functions */
 
 int luaopen_util_pposix(lua_State *L)
 {
        lua_newtable(L);
 
+       lua_pushcfunction(L, lc_abort);
+       lua_setfield(L, -2, "abort");
+
        lua_pushcfunction(L, lc_daemonize);
        lua_setfield(L, -2, "daemonize");