summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anylike.org>2009-12-25 11:10:56 +0000
committerChristian Pointner <equinox@anylike.org>2009-12-25 11:10:56 +0000
commit3dd2fe22eee718589104d58144be3e34aa8fd7cc (patch)
tree42d5329a12667a04b4b844ba028682e06eff3469
parentadded daemonizing (diff)
added initial crypt library for lua
-rw-r--r--src/Makefile1
-rw-r--r--src/anylike.c2
-rw-r--r--src/l_crypt.c45
-rw-r--r--src/l_crypt.h34
-rw-r--r--src/l_log.c3
-rw-r--r--src/main_loop.lua2
6 files changed, 85 insertions, 2 deletions
diff --git a/src/Makefile b/src/Makefile
index 1d63ea1..9b139bf 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -36,6 +36,7 @@ OBJ := log.o \
l_log.o \
options.o \
string_list.o \
+ l_crypt.o \
anylike.o
diff --git a/src/anylike.c b/src/anylike.c
index 1735631..09f488f 100644
--- a/src/anylike.c
+++ b/src/anylike.c
@@ -33,6 +33,7 @@
#include "options.h"
#include "log.h"
#include "l_log.h"
+#include "l_crypt.h"
#ifndef USE_SSL_CRYPTO
#include <gcrypt.h>
@@ -75,6 +76,7 @@ int main_loop(options_t* opt)
luaopen_base(L);
luaopen_string(L);
luaopen_log(L);
+ luaopen_crypt(L);
lua_dofile(L, "main_loop.lua");
diff --git a/src/l_crypt.c b/src/l_crypt.c
new file mode 100644
index 0000000..bdccaf5
--- /dev/null
+++ b/src/l_crypt.c
@@ -0,0 +1,45 @@
+/*
+ * anylike
+ *
+ * anylike is a ...
+ *
+ *
+ * Copyright (C) 2009-2010 Markus Grueneis <gimpf@anylike.org>
+ * Christian Pointner <equinox@anylike.org>
+ *
+ * This file is part of anylike.
+ *
+ * anylike is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * anylike is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with anylike. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <lua50/lua.h>
+
+#include "l_crypt.h"
+
+static int l_crypt_test(lua_State *L) {
+ lua_pushstring(L, "crypt test called");
+ return 1;
+}
+
+static const struct luaL_reg cryptlib [] = {
+ { "test", l_crypt_test },
+ { NULL, NULL }
+};
+
+
+LUALIB_API int luaopen_crypt(lua_State *L)
+{
+ luaL_openlib(L, "crypt", cryptlib, 0);
+ return 1;
+}
diff --git a/src/l_crypt.h b/src/l_crypt.h
new file mode 100644
index 0000000..591bfe4
--- /dev/null
+++ b/src/l_crypt.h
@@ -0,0 +1,34 @@
+/*
+ * anylike
+ *
+ * anylike is a ...
+ *
+ *
+ * Copyright (C) 2009-2010 Markus Grueneis <gimpf@anylike.org>
+ * Christian Pointner <equinox@anylike.org>
+ *
+ * This file is part of anylike.
+ *
+ * anylike is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * anylike is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with anylike. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ANYLIKE_l_crypt_h_INCLUDED
+#define ANYLIKE_l_crypt_h_INCLUDED
+
+#include <lua50/lua.h>
+#include <lua50/lauxlib.h>
+
+LUALIB_API int luaopen_crypt(lua_State *L);
+
+#endif
diff --git a/src/l_log.c b/src/l_log.c
index 8213751..8e95927 100644
--- a/src/l_log.c
+++ b/src/l_log.c
@@ -101,7 +101,8 @@ static const struct luaL_reg loglib [] = {
};
-LUALIB_API int luaopen_log (lua_State *L) {
+LUALIB_API int luaopen_log(lua_State *L)
+{
luaL_openlib(L, "log", loglib, 0);
return 1;
}
diff --git a/src/main_loop.lua b/src/main_loop.lua
index 9e9e0ae..d0783ca 100644
--- a/src/main_loop.lua
+++ b/src/main_loop.lua
@@ -29,4 +29,4 @@ log.print("DEBUG", "yet anoter message");
log.print("ERROR", "this is an error");
-
+log.print("NOTICE", crypt.test()); \ No newline at end of file