1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2024-12-27 09:58:21 +01:00

Merge pull request #1 from lxsang/multiple_port

clean up
This commit is contained in:
Xuan Sang LE 2020-01-02 17:56:24 +01:00 committed by GitHub
commit 53a4022db5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
110 changed files with 331 additions and 1307 deletions

View File

@ -1,7 +0,0 @@
EXTRA_DIST = lua-5.3.4/*.c lua-5.3.4/*.h lua-5.3.4/Makefile
all:
cd $(top_srcdir)/3rd/lua-5.3.4 && make linux
clean-local:
cd $(top_srcdir)/3rd/lua-5.3.4 && make clean

View File

@ -1,41 +0,0 @@
# You can put your build options here
-include config.mk
all: libjsmn.a
libjsmn.a: jsmn.o
$(AR) rc $@ $^
%.o: %.c jsmn.h
$(CC) -c $(CFLAGS) $< -o $@
test: test_default test_strict test_links test_strict_links
test_default: test/tests.c
$(CC) $(CFLAGS) $(LDFLAGS) $< -o test/$@
./test/$@
test_strict: test/tests.c
$(CC) -DJSMN_STRICT=1 $(CFLAGS) $(LDFLAGS) $< -o test/$@
./test/$@
test_links: test/tests.c
$(CC) -DJSMN_PARENT_LINKS=1 $(CFLAGS) $(LDFLAGS) $< -o test/$@
./test/$@
test_strict_links: test/tests.c
$(CC) -DJSMN_STRICT=1 -DJSMN_PARENT_LINKS=1 $(CFLAGS) $(LDFLAGS) $< -o test/$@
./test/$@
jsmn_test.o: jsmn_test.c libjsmn.a
simple_example: example/simple.o libjsmn.a
$(CC) $(LDFLAGS) $^ -o $@
jsondump: example/jsondump.o libjsmn.a
$(CC) $(LDFLAGS) $^ -o $@
clean:
rm -f *.o example/*.o
rm -f *.a *.so
rm -f simple_example
rm -f jsondump
.PHONY: all clean test

View File

@ -1,204 +0,0 @@
# Makefile for building Lua
# See ../doc/readme.html for installation and customization instructions.
# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
# Your platform. See PLATS for possible values.
PLAT= none
CC= gcc -std=gnu99
CFLAGS= -O2 -g -Wall -Wextra -DLUA_COMPAT_5_2 -fPIC $(SYSCFLAGS) $(MYCFLAGS)
LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
LIBS= -lm $(SYSLIBS) $(MYLIBS)
AR= ar rcu
RANLIB= ranlib
RM= rm -f
SYSCFLAGS=
SYSLDFLAGS=
SYSLIBS=
MYCFLAGS=
MYLDFLAGS=
MYLIBS=
MYOBJS=
# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
LUA_SO = core.so
LUA_A= liblua.a
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
ltm.o lundump.o lvm.o lzio.o
LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o
BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
LUA_T= lua
LUA_O= lua.o
LUAC_T= luac
LUAC_O= luac.o
ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
ALL_A= $(LUA_A) $(LUA_SO)
# Targets start here.
default: $(PLAT)
all: $(ALL_T)
o: $(ALL_O)
a: $(ALL_A)
$(LUA_A): $(BASE_O)
$(AR) $@ $(BASE_O)
$(RANLIB) $@
$(LUA_SO): $(BASE_O)
gcc -shared $(BASE_O) -o $@ -ldl -lm
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
clean:
$(RM) $(ALL_T) $(ALL_O)
depend:
@$(CC) $(CFLAGS) -MM l*.c
distdir:
install:
echo:
@echo "PLAT= $(PLAT)"
@echo "CC= $(CC)"
@echo "CFLAGS= $(CFLAGS)"
@echo "LDFLAGS= $(SYSLDFLAGS)"
@echo "LIBS= $(LIBS)"
@echo "AR= $(AR)"
@echo "RANLIB= $(RANLIB)"
@echo "RM= $(RM)"
# Convenience targets for popular platforms
ALL= all
none:
@echo "Please do 'make PLATFORM' where PLATFORM is one of these:"
@echo " $(PLATS)"
aix:
$(MAKE) $(ALL) CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" SYSLDFLAGS="-brtl -bexpall"
bsd:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-Wl,-E"
c89:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_C89" CC="gcc -std=c89"
@echo ''
@echo '*** C89 does not guarantee 64-bit integers for Lua.'
@echo ''
freebsd:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -lreadline"
generic: $(ALL)
linux:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
macosx:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline" CC=cc
mingw:
$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
$(MAKE) "LUAC_T=luac.exe" luac.exe
posix:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX"
solaris:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_REENTRANT" SYSLIBS="-ldl"
# list targets that do not create files (but not all makes understand .PHONY)
.PHONY: all $(PLATS) default o a clean depend echo none
# DO NOT DELETE
lapi.o: lapi.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lstring.h \
ltable.h lundump.h lvm.h
lauxlib.o: lauxlib.c lprefix.h lua.h luaconf.h lauxlib.h
lbaselib.o: lbaselib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lbitlib.o: lbitlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lcode.o: lcode.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \
llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \
ldo.h lgc.h lstring.h ltable.h lvm.h
lcorolib.o: lcorolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lctype.o: lctype.c lprefix.h lctype.h lua.h luaconf.h llimits.h
ldblib.o: ldblib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
ldebug.o: ldebug.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
lobject.h ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h \
ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lvm.h
ldo.o: ldo.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lopcodes.h \
lparser.h lstring.h ltable.h lundump.h lvm.h
ldump.o: ldump.c lprefix.h lua.h luaconf.h lobject.h llimits.h lstate.h \
ltm.h lzio.h lmem.h lundump.h
lfunc.o: lfunc.c lprefix.h lua.h luaconf.h lfunc.h lobject.h llimits.h \
lgc.h lstate.h ltm.h lzio.h lmem.h
lgc.o: lgc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h
linit.o: linit.c lprefix.h lua.h luaconf.h lualib.h lauxlib.h
liolib.o: liolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
llex.o: llex.c lprefix.h lua.h luaconf.h lctype.h llimits.h ldebug.h \
lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lgc.h llex.h lparser.h \
lstring.h ltable.h
lmathlib.o: lmathlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lmem.o: lmem.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h
loadlib.o: loadlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lobject.o: lobject.c lprefix.h lua.h luaconf.h lctype.h llimits.h \
ldebug.h lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h \
lvm.h
lopcodes.o: lopcodes.c lprefix.h lopcodes.h llimits.h lua.h luaconf.h
loslib.o: loslib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lparser.o: lparser.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \
llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \
ldo.h lfunc.h lstring.h lgc.h ltable.h
lstate.o: lstate.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h llex.h \
lstring.h ltable.h
lstring.o: lstring.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h
lstrlib.o: lstrlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
ltable.o: ltable.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h
ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h ltable.h lvm.h
lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h lobject.h llimits.h \
lstate.h ltm.h lzio.h lmem.h lundump.h ldebug.h lopcodes.h
lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \
lundump.h
lutf8lib.o: lutf8lib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
lvm.o: lvm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h \
ltable.h lvm.h
lzio.o: lzio.c lprefix.h lua.h luaconf.h llimits.h lmem.h lstate.h \
lobject.h ltm.h lzio.h
# (end of Makefile)

View File

@ -3,6 +3,8 @@ __ROOT__ = __api__.root
-- set require path
package.path = __ROOT__ .. '/?.lua;'..__api__.apiroot..'/?.lua'
package.cpath = __api__.apiroot..'/?.so'
require("antd")
require("std")
require("utils")
require("extra_mime")

View File

@ -1,4 +1,4 @@
sqlite = modules.sqlite()
sqlite = modules.sqlite()
if sqlite == nil then return 0 end
require("OOP")

View File

@ -1,6 +1,17 @@
std = modules.std()
bytes = modules.bytes()
array = modules.array()
modules.sqlite = function()
if not sqlite then
sqlite = require("sqlitedb")
sqlite.getdb = function(s)
return sqlite._getdb(__api__.dbpath.."/"..s..".db")
end
end
return sqlite
end
RESPONSE_HEADER = {
status = 200,
header = {},

View File

@ -83,7 +83,7 @@ function utils.url_parser(uri)
return obj
end
JSON = modules.JSON()
JSON = require("json")
function JSON.encode(obj)
local t = type(obj)

View File

@ -16,22 +16,14 @@ AM_CPPFLAGS += -W -Wall -g -std=c99 -fPIC
# main plugin
lib_LTLIBRARIES = lua.la
lua_la_LDFLAGS = -module -avoid-version -shared
lua_la_SOURCES = plugin-wrapper.c\
3rd/jsmn/jsmn.c \
array-wrapper.c \
json-wrapper.c \
lua-api.c
lua_la_SOURCES = lua-api.c
# lua libraris & modules
SUBDIRS = 3rd . lib
SUBDIRS = . lib
if DB
lua_la_SOURCES += db-wrapper.c
endif
EXTRA_DIST = README.md 3rd/jsmn/jsmn.h APIs lua-api.h
EXTRA_DIST = README.md APIs
install-data-local:
mkdir -p $(prefix)/lib/lua
cp -v APIs/* $(prefix)/lib/lua
cp -v 3rd/lua-5.3.4/core.so $(prefix)/lib/lua
cp -v lib/core/lua-5.3.4/core.so $(prefix)/lib/lua

View File

@ -1,191 +0,0 @@
#include "lua-api.h"
// add a length field, and
void lua_new_byte_array(lua_State*L, int n)
{
size_t nbytes = sizeof(byte_array_t) + (n-1)*sizeof(unsigned char);
byte_array_t *a = (byte_array_t *)lua_newuserdata(L, nbytes);
luaL_getmetatable(L, BYTEARRAY);
lua_setmetatable(L, -2);
a->size = n;
}
static int l_new_barray (lua_State *L) {
int n = luaL_checknumber(L, 1);
lua_new_byte_array(L,n);
return 1; /* new userdatum is already on the stack */
}
byte_array_t *l_check_barray (lua_State *L,int idx) {
void *ud = luaL_checkudata(L, idx, BYTEARRAY);
luaL_argcheck(L, ud != NULL, idx, "`byte array' expected");
return (byte_array_t *)ud;
}
static unsigned char *get_bel(lua_State *L) {
byte_array_t *a = l_check_barray(L,1);
int index = luaL_checknumber(L, 2);
luaL_argcheck(L, 1 <= index && index <= a->size, 2,
"index out of range");
/* return element address */
return &a->data[index - 1];
}
static int l_set_barray (lua_State *L) {
unsigned char value = luaL_checknumber(L, 3);
*get_bel(L) = value;
return 0;
}
static int l_get_barray (lua_State *L) {
lua_pushnumber(L, *get_bel(L));
return 1;
}
static int l_get_barray_size (lua_State *L) {
byte_array_t *a = l_check_barray(L,1);
lua_pushnumber(L, a->size);
return 1;
}
static int l_barray_to_string (lua_State *L) {
byte_array_t *a = l_check_barray(L,1);
char * d = (char*) malloc(a->size+1);
memcpy(d, a->data, a->size);
d[a->size] = '\0';
lua_pushstring(L, d);
if(d)
free(d);
return 1;
}
static int l_barray_write(lua_State* L)
{
byte_array_t *a = l_check_barray(L,1);
const char* f = luaL_checkstring(L,2);
FILE *fp;
fp = fopen(f,"wb");
if(!fp)
lua_pushboolean(L,0);
else
{
fwrite(a->data ,1, a->size ,fp);
lua_pushboolean(L,1);
fclose(fp);
}
return 1;
}
static const struct luaL_Reg barraylib[] = {
{"new", l_new_barray},
{"set", l_set_barray},
{"get", l_get_barray},
{"size",l_get_barray_size},
{"__tostring", l_barray_to_string},
{"write", l_barray_write},
{NULL, NULL}
};
// ARRAY
void lua_new_array(lua_State*L, int n)
{
size_t nbytes = sizeof(array_t) + (n-1)*sizeof(double);
array_t *a = (array_t *)lua_newuserdata(L, nbytes);
luaL_getmetatable(L, ARRAY);
lua_setmetatable(L, -2);
a->size = n;
}
static int l_new_array (lua_State *L) {
int n = luaL_checknumber(L, 1);
lua_new_array(L,n);
return 1; /* new userdatum is already on the stack */
}
array_t *l_check_array (lua_State *L, int idx) {
void *ud = luaL_checkudata(L, idx, ARRAY);
luaL_argcheck(L, ud != NULL, idx, "`array' expected");
return (array_t *)ud;
}
static double *get_el(lua_State *L) {
array_t *a = l_check_array(L,1);
int index = luaL_checknumber(L, 2);
luaL_argcheck(L, 1 <= index && index <= a->size, 2,
"index out of range");
/* return element address */
return &a->data[index - 1];
}
static int l_set_array (lua_State *L) {
double value = luaL_checknumber(L, 3);
*get_el(L) = value;
return 0;
}
static int l_get_array (lua_State *L) {
lua_pushnumber(L, *get_el(L));
return 1;
}
static int l_get_array_size (lua_State *L) {
array_t *a = l_check_array(L,1);
lua_pushnumber(L, a->size);
return 1;
}
static int l_array_to_string (lua_State *L) {
array_t *a = l_check_array(L,1);
lua_pushfstring(L, "number array(%d)", a->size);
return 1;
}
static const struct luaL_Reg arraylib [] = {
{"new", l_new_array},
{"set", l_set_array},
{"get", l_get_array},
{"size",l_get_array_size},
{"__tostring", l_array_to_string},
{NULL, NULL}
};
int luaopen_array (lua_State *L) {
luaL_newmetatable(L, ARRAY);
luaL_newlib(L, arraylib);
lua_pushstring(L, "__index");
lua_pushstring(L, "get");
lua_gettable(L, 2); /* get array.get */
lua_settable(L, 1); /* metatable.__index = array.get */
lua_pushstring(L, "__newindex");
lua_pushstring(L, "set");
lua_gettable(L, 2); /* get array.set */
lua_settable(L, 1); /* metatable.__newindex = array.set */
//lua_pushstring(L, "__index");
//lua_pushvalue(L, -2); /* pushes the metatable */
//lua_settable(L, -3); /* metatable.__index = metatable */
// luaL_setfuncs(L, arraylib_m, 0);
// luaL_openlib(L, NULL, arraylib_m, 0);
// luaL_newlib(L, arraylib_f);
return 1;
}
int luaopen_barray (lua_State *L) {
luaL_newmetatable(L, BYTEARRAY);
luaL_newlib(L, barraylib);
lua_pushstring(L, "__index");
lua_pushstring(L, "get");
lua_gettable(L, 2); /* get array.get */
lua_settable(L, 1); /* metatable.__index = array.get */
lua_pushstring(L, "__newindex");
lua_pushstring(L, "set");
lua_gettable(L, 2); /* get array.set */
lua_settable(L, 1);
//lua_pushstring(L, "__index");
//lua_pushvalue(L, -2); /* pushes the metatable */
//lua_settable(L, -3); /* metatable.__index = metatable */
//luaL_setfuncs(L, barraylib_m, 0);
//luaL_openlib(L, NULL, barraylib_m, 0);
//luaL_newlib(L, barraylib_f);
return 1;
}

View File

@ -124,18 +124,12 @@ AM_CONDITIONAL([HAS_FFI], [test "$use_ffi" = "yes"])
AM_CONDITIONAL([HAS_CMAKE], [test "$has_cmake" = "yes"])
# find all config files
AC_CONFIG_FILES([
3rd/Makefile
Makefile
lib/Makefile
lib/ulib/Makefile
lib/wurl/Makefile
lib/stmr/Makefile
lib/core/Makefile
lib/asl/Makefile
])
if test "$use_ffi" = "yes"; then
AC_CONFIG_FILES([lib/ffi/Makefile])
fi
if test x"${has_cmake}" == x"yes" ; then
AC_CONFIG_FILES([lib/ann/Makefile lib/ann/fann/Makefile])
fi

BIN
dist/lua-0.5.2b.tar.gz vendored

Binary file not shown.

View File

@ -1,7 +1,4 @@
SUBDIRS = ulib wurl stmr
if HAS_FFI
SUBDIRS += ffi
endif
SUBDIRS = core asl
if HAS_CMAKE
SUBDIRS += ann
endif

View File

@ -240,14 +240,14 @@ am__relativize = \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
ACLOCAL = ${SHELL} /src/cwp/ant-plugins/antd-lua-plugin/missing aclocal-1.15
ACLOCAL = ${SHELL} /home/mrsang/build/antd-lua-plugin/missing aclocal-1.15
AMTAR = $${TAR-tar}
AM_DEFAULT_VERBOSITY = 1
AR = ar
AUTOCONF = ${SHELL} /src/cwp/ant-plugins/antd-lua-plugin/missing autoconf
AUTOHEADER = ${SHELL} /src/cwp/ant-plugins/antd-lua-plugin/missing autoheader
AUTOMAKE = ${SHELL} /src/cwp/ant-plugins/antd-lua-plugin/missing automake-1.15
AWK = mawk
AUTOCONF = ${SHELL} /home/mrsang/build/antd-lua-plugin/missing autoconf
AUTOHEADER = ${SHELL} /home/mrsang/build/antd-lua-plugin/missing autoheader
AUTOMAKE = ${SHELL} /home/mrsang/build/antd-lua-plugin/missing automake-1.15
AWK = gawk
CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2
@ -280,7 +280,7 @@ LIPO =
LN_S = ln -s
LTLIBOBJS =
LT_SYS_LIBRARY_PATH =
MAKEINFO = ${SHELL} /src/cwp/ant-plugins/antd-lua-plugin/missing makeinfo
MAKEINFO = ${SHELL} /home/mrsang/build/antd-lua-plugin/missing makeinfo
MANIFEST_TOOL = :
MKDIR_P = /bin/mkdir -p
NM = /usr/bin/nm -B
@ -300,13 +300,13 @@ PATH_SEPARATOR = :
RANLIB = ranlib
SED = /bin/sed
SET_MAKE =
SHELL = /bin/sh
SHELL = /bin/bash
STRIP = strip
VERSION = 0.5.2b
abs_builddir = /src/cwp/ant-plugins/antd-lua-plugin/lib/ann
abs_srcdir = /src/cwp/ant-plugins/antd-lua-plugin/lib/ann
abs_top_builddir = /src/cwp/ant-plugins/antd-lua-plugin
abs_top_srcdir = /src/cwp/ant-plugins/antd-lua-plugin
abs_builddir = /home/mrsang/build/antd-lua-plugin/lib/ann
abs_srcdir = /home/mrsang/build/antd-lua-plugin/lib/ann
abs_top_builddir = /home/mrsang/build/antd-lua-plugin
abs_top_srcdir = /home/mrsang/build/antd-lua-plugin
ac_ct_AR = ar
ac_ct_CC = gcc
ac_ct_DUMPBIN =
@ -336,7 +336,7 @@ host_vendor = pc
htmldir = ${docdir}
includedir = ${prefix}/include
infodir = ${datarootdir}/info
install_sh = ${SHELL} /src/cwp/ant-plugins/antd-lua-plugin/install-sh
install_sh = ${SHELL} /home/mrsang/build/antd-lua-plugin/install-sh
libdir = $(prefix)/lib/lua/
libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale
@ -345,7 +345,7 @@ mandir = ${datarootdir}/man
mkdir_p = $(MKDIR_P)
oldincludedir = /usr/include
pdfdir = ${docdir}
prefix = /src/www
prefix = /opt/www
program_transform_name = s,x,x,
psdir = ${docdir}
runstatedir = ${localstatedir}/run

View File

@ -26,7 +26,7 @@
#include <doublefann.h>
#include "../lualib.h"
#include "../../lua-api.h"
//#include "../../lua-api.h"
#define LIB_NAME "ann"

38
lib/asl/Makefile.am Normal file
View File

@ -0,0 +1,38 @@
lib_LTLIBRARIES = ulib.la
ulib_la_LDFLAGS = -module -avoid-version -shared
ulib_la_SOURCES = 3rd/zip/zip.c ulib.c
lib_LTLIBRARIES += antd.la
antd_la_LDFLAGS = -module -avoid-version -shared
antd_la_SOURCES = antd.c
lib_LTLIBRARIES += stmr.la
stmr_la_LDFLAGS = -module -avoid-version -shared
stmr_la_SOURCES = stmr.c
lib_LTLIBRARIES += json.la
json_la_LDFLAGS = -module -avoid-version -shared
json_la_SOURCES = 3rd/jsmn/jsmn.c json.c
lib_LTLIBRARIES += wurl.la
wurl_la_LDFLAGS = -module -avoid-version -shared
wurl_la_SOURCES = wurl.c
if HAS_FFI
lib_LTLIBRARIES += ffi.la
ffi_la_LDFLAGS = -module -avoid-version -shared -lffi
ffi_la_SOURCES = ffi.c
endif
if DB
lib_LTLIBRARIES += sqlitedb.la
sqlitedb_la_LDFLAGS = -module -avoid-version -shared
sqlitedb_la_SOURCES = sqlitedb.c
endif
libdir=$(prefix)/lib/lua/
EXTRA_DIST = 3rd/zip/miniz.c 3rd/zip/zip.h 3rd/jsmn/jsmn.h

View File

@ -1,75 +1,196 @@
#include <antd/ws.h>
#include "lua-api.h"
//void header(int,const char*);
/*
static int l_header (lua_State *L) {
//int client = (int)luaL_checknumber(L, 1);
void* client = lua_touserdata (L, 1);
const char* s = luaL_checkstring(L,2);
ctype(client,s);
return 0;
#include "../lualib.h"
// add a length field, and
void lua_new_byte_array(lua_State*L, int n)
{
size_t nbytes = sizeof(byte_array_t) + (n-1)*sizeof(unsigned char);
byte_array_t *a = (byte_array_t *)lua_newuserdata(L, nbytes);
luaL_getmetatable(L, BYTEARRAY);
lua_setmetatable(L, -2);
a->size = n;
}
*/
//void redirect(int,const char*);
/*
static int l_redirect (lua_State *L) {
void* client = lua_touserdata (L, 1);
const char* s = luaL_checkstring(L,2);
redirect(client,s);
return 0;
}*/
/*
static int l_html (lua_State *L) {
void* client = lua_touserdata (L, 1);
html(client);
return 0;
static int l_new_barray (lua_State *L) {
int n = luaL_checknumber(L, 1);
lua_new_byte_array(L,n);
return 1; /* new userdatum is already on the stack */
}
*/
//void text(int);
/*
static int l_text (lua_State *L) {
void* client = lua_touserdata (L, 1);
text(client);
return 0;
byte_array_t *l_check_barray (lua_State *L,int idx) {
void *ud = luaL_checkudata(L, idx, BYTEARRAY);
luaL_argcheck(L, ud != NULL, idx, "`byte array' expected");
return (byte_array_t *)ud;
}
*/
//void json(int);
/*
static int l_json (lua_State *L) {
void* client = lua_touserdata (L, 1);
json(client);
return 0;
}*/
static unsigned char *get_bel(lua_State *L) {
byte_array_t *a = l_check_barray(L,1);
int index = luaL_checknumber(L, 2);
luaL_argcheck(L, 1 <= index && index <= a->size, 2,
"index out of range");
/* return element address */
return &a->data[index - 1];
}
static int l_set_barray (lua_State *L) {
unsigned char value = luaL_checknumber(L, 3);
*get_bel(L) = value;
return 0;
}
//void jpeg(int);
/*
static int l_jpeg (lua_State *L) {
void* client = lua_touserdata (L, 1);
jpeg(client);
return 0;
}*/
static int l_get_barray (lua_State *L) {
lua_pushnumber(L, *get_bel(L));
return 1;
}
static int l_get_barray_size (lua_State *L) {
byte_array_t *a = l_check_barray(L,1);
lua_pushnumber(L, a->size);
return 1;
}
static int l_barray_to_string (lua_State *L) {
byte_array_t *a = l_check_barray(L,1);
char * d = (char*) malloc(a->size+1);
memcpy(d, a->data, a->size);
d[a->size] = '\0';
lua_pushstring(L, d);
if(d)
free(d);
return 1;
}
static int l_barray_write(lua_State* L)
{
byte_array_t *a = l_check_barray(L,1);
const char* f = luaL_checkstring(L,2);
FILE *fp;
fp = fopen(f,"wb");
if(!fp)
lua_pushboolean(L,0);
else
{
fwrite(a->data ,1, a->size ,fp);
lua_pushboolean(L,1);
fclose(fp);
}
return 1;
}
static const struct luaL_Reg barraylib[] = {
{"new", l_new_barray},
{"set", l_set_barray},
{"get", l_get_barray},
{"size",l_get_barray_size},
{"__tostring", l_barray_to_string},
{"write", l_barray_write},
{NULL, NULL}
};
int luaopen_bytes (lua_State *L) {
luaL_newmetatable(L, BYTEARRAY);
luaL_newlib(L, barraylib);
lua_pushstring(L, "__index");
lua_pushstring(L, "get");
lua_gettable(L, 2); /* get array.get */
lua_settable(L, 1); /* metatable.__index = array.get */
lua_pushstring(L, "__newindex");
lua_pushstring(L, "set");
lua_gettable(L, 2); /* get array.set */
lua_settable(L, 1);
//lua_pushstring(L, "__index");
//lua_pushvalue(L, -2); /* pushes the metatable */
//lua_settable(L, -3); /* metatable.__index = metatable */
//luaL_setfuncs(L, barraylib_m, 0);
//luaL_openlib(L, NULL, barraylib_m, 0);
//luaL_newlib(L, barraylib_f);
return 1;
}
// ARRAY
void lua_new_array(lua_State*L, int n)
{
size_t nbytes = sizeof(array_t) + (n-1)*sizeof(double);
array_t *a = (array_t *)lua_newuserdata(L, nbytes);
luaL_getmetatable(L, ARRAY);
lua_setmetatable(L, -2);
a->size = n;
}
static int l_new_array (lua_State *L) {
int n = luaL_checknumber(L, 1);
lua_new_array(L,n);
return 1; /* new userdatum is already on the stack */
}
array_t *l_check_array (lua_State *L, int idx) {
void *ud = luaL_checkudata(L, idx, ARRAY);
luaL_argcheck(L, ud != NULL, idx, "`array' expected");
return (array_t *)ud;
}
static double *get_el(lua_State *L) {
array_t *a = l_check_array(L,1);
int index = luaL_checknumber(L, 2);
luaL_argcheck(L, 1 <= index && index <= a->size, 2,
"index out of range");
/* return element address */
return &a->data[index - 1];
}
static int l_set_array (lua_State *L) {
double value = luaL_checknumber(L, 3);
*get_el(L) = value;
return 0;
}
static int l_get_array (lua_State *L) {
lua_pushnumber(L, *get_el(L));
return 1;
}
static int l_get_array_size (lua_State *L) {
array_t *a = l_check_array(L,1);
lua_pushnumber(L, a->size);
return 1;
}
static int l_array_to_string (lua_State *L) {
array_t *a = l_check_array(L,1);
lua_pushfstring(L, "number array(%d)", a->size);
return 1;
}
static const struct luaL_Reg arraylib [] = {
{"new", l_new_array},
{"set", l_set_array},
{"get", l_get_array},
{"size",l_get_array_size},
{"__tostring", l_array_to_string},
{NULL, NULL}
};
int luaopen_array (lua_State *L) {
luaL_newmetatable(L, ARRAY);
luaL_newlib(L, arraylib);
lua_pushstring(L, "__index");
lua_pushstring(L, "get");
lua_gettable(L, 2); /* get array.get */
lua_settable(L, 1); /* metatable.__index = array.get */
lua_pushstring(L, "__newindex");
lua_pushstring(L, "set");
lua_gettable(L, 2); /* get array.set */
lua_settable(L, 1); /* metatable.__newindex = array.set */
//lua_pushstring(L, "__index");
//lua_pushvalue(L, -2); /* pushes the metatable */
//lua_settable(L, -3); /* metatable.__index = metatable */
// luaL_setfuncs(L, arraylib_m, 0);
// luaL_openlib(L, NULL, arraylib_m, 0);
// luaL_newlib(L, arraylib_f);
return 1;
}
//void octstream(int, char*);
/*
static int l_octstream (lua_State *L) {
void* client = lua_touserdata (L, 1);
const char* s = luaL_checkstring(L,2);
octstream(client,(char*)s);
return 0;
}*/
//void textstream(int);
/*
static int l_textstream (lua_State *L) {
void* client = lua_touserdata (L, 1);
textstream(client);
return 0;
}*/
// int mime
static int l_mime(lua_State* L)
{
@ -146,11 +267,12 @@ static int l_upload (lua_State *L) {
}
//char* route(const char*);
/*
static int l_route (lua_State *L) {
const char* s = luaL_checkstring(L, 1);
lua_pushstring(L, route(s));
return 1;
}
}*/
//char* htdocs(const char*);
//#ifdef USE_DB
@ -565,7 +687,7 @@ static const struct luaL_Reg standard [] = {
{"_b", l_b} ,
{"trim", l_trim},
{"upload", l_upload} ,
{"route", l_route} ,
//{"route", l_route} ,
{"mime", l_mime} ,
//{"is_bin", l_is_bin} ,
//{"_unknow", l_unknow} ,
@ -586,8 +708,26 @@ static const struct luaL_Reg standard [] = {
{NULL,NULL}
};
int luaopen_standard(lua_State *L)
int luaopen_std(lua_State *L)
{
luaL_newlib(L, standard);
return 1;
}
static const struct luaL_Reg modules [] = {
{"bytes",luaopen_bytes},
{"array",luaopen_array},
{"std", luaopen_std},
{NULL,NULL}
};
int luaopen_antd(lua_State *L)
{
luaL_newlib(L, modules);
lua_setglobal(L, "modules");
return 1;
}

View File

@ -4,7 +4,7 @@
*/
#include "../lualib.h"
#include "../../lua-api.h"
//#include "../../lua-api.h"
#include <antd/utils.h>

View File

@ -1,4 +1,4 @@
#include "lua-api.h"
#include "../lualib.h"
#include "3rd/jsmn/jsmn.h"
#define MAXTOKEN 1024

View File

@ -1,5 +1,5 @@
#include <antd/dbhelper.h>
#include "lua-api.h"
#include "../lualib.h"
typedef sqlite3* sqldb;
//sqldb db = NULL;
@ -8,7 +8,7 @@ static int l_getdb (lua_State *L) {
// if(db)
// dbclose(db);
//printf("OPEN: %s\n",s);
sqldb db = __getdb((char*)s);
sqldb db = (sqldb)database(s);
if(db)
lua_pushlightuserdata(L, db);
else
@ -98,7 +98,7 @@ static int l_hastable(lua_State *L)
return 1;
}
static const struct luaL_Reg sqlite [] = {
{"getdb", l_getdb},
{"_getdb", l_getdb},
{"dbclose", l_db_close},
{"query", l_db_query},
{"lastInsertID", l_db_lastid},
@ -107,7 +107,7 @@ static const struct luaL_Reg sqlite [] = {
{NULL,NULL}
};
int luaopen_sqlite(lua_State *L)
int luaopen_sqlitedb(lua_State *L)
{
luaL_newlib(L, sqlite);
return 1;

View File

@ -16,7 +16,7 @@
#include <libgen.h>
#include "../lualib.h"
#include "../../lua-api.h"
//#include "../../lua-api.h"
#include <antd/utils.h>
#define CLIENT_NAME "wurl"

7
lib/core/Makefile.am Normal file
View File

@ -0,0 +1,7 @@
EXTRA_DIST = lua-5.3.4/*.c lua-5.3.4/*.h lua-5.3.4/Makefile
all:
cd $(top_srcdir)/lib/core/lua-5.3.4 && make linux
clean-local:
cd $(top_srcdir)/lib/core/lua-5.3.4 && make clean

BIN
lib/curl

Binary file not shown.

View File

@ -1,4 +0,0 @@
lib_LTLIBRARIES = ffi.la
ffi_la_LDFLAGS = -module -avoid-version -shared -lffi
ffi_la_SOURCES = ffi.c
libdir=$(prefix)/lib/lua/

Some files were not shown because too many files have changed in this diff Show More