diff --git a/Makefile b/Makefile index 76334b5..f37342d 100755 --- a/Makefile +++ b/Makefile @@ -1,15 +1,10 @@ -CFLAGS = $(WARNINGS) $(DEFINES) $(INCLUDES) -WARNINGS = -W -Wall -#DEFINES = -D_XOPEN_SOURCE=600 -INCLUDES = -I$(LUA)/include - -LUA = /home/mark/src/lang/lua/lua-5.1-rc1 - -default:; echo Choose platform: mingw cygwin posix +default:; @echo Choose a platform: mingw cygwin linux all: mingw cygwin mingw:; $(MAKE) -C w32api ex.dll -cygwin:; $(MAKE) -C posix ex.dll -posix:; $(MAKE) -C posix ex.so +cygwin:; $(MAKE) -C posix T=ex.dll ex.dll +linux:; $(MAKE) -C posix ex.so -#"EX_LIB=ex.so" "DEFINES=-D_XOPEN_SOURCE=600" +clean: + $(MAKE) -C posix clean + $(MAKE) -C w32api clean diff --git a/README b/README index 0d7661a..1190dfb 100755 --- a/README +++ b/README @@ -1,3 +1,7 @@ +"ex" API implementation +http://lua-users.org/wiki/ExtensionProposal +Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + -- Environment os.getenv(name) -- get environment variable os.setenv(name, value) -- set/unset environment variable @@ -7,17 +11,18 @@ os.environ() -- returns a copy of the environment os.sleep(seconds) -- sleep for (floating) seconds -- File system -os.chdir(pathname) cwd = os.currentdir() +os.chdir(pathname) os.mkdir(pathname) +os.remove(pathname) -for stat in os.dir(pathname) do ; end -stat = os.stat(pathname) +for entry in os.dir(pathname) do ; end +entry = os.dirent(pathname) --[[ - stat is a table, containing at least the following keys: - name: the filename - type: "file" or "directory" or another implementation-defined string - size: the file size in bytes + entry is a table, containing at least the following keys: + name: the filename + type: "file" or "directory" or another implementation-defined string + size: the file size in bytes --]] -- Locking and pipes diff --git a/conf b/conf new file mode 100755 index 0000000..3b6b6b2 --- /dev/null +++ b/conf @@ -0,0 +1,17 @@ +### Change these to match your Lua installation +LUA= /home/medgar/src/lang/lua/lua-5.1.1 +LUAINC= -I$(LUA)/src +LUALIB= -L$(LUA)/src -llua51 + +#LUA= /home/mark/luabinaries/lua51 +#LUAINC= -I$(LUA)/include +#LUALIB= -L$(LUA) -llua5.1 + +### Comment these if your system actually has posix_spawn() +POSIX_SPAWN= -DMISSING_POSIX_SPAWN +EXTRA= posix_spawn.o + +### Change this if your system properly declares environ. +#ENVIRON= -DENVIRON_DECL= +ENVIRON= -DENVIRON_DECL="extern char **environ;" + diff --git a/posix/Makefile b/posix/Makefile index 1d5dfd9..b83c328 100755 --- a/posix/Makefile +++ b/posix/Makefile @@ -1,25 +1,18 @@ -CFLAGS = $(WARNINGS) $(DEFINES) $(INCLUDES) -DEFINES = $(DEBUG) -D_XOPEN_SOURCE=600 -DMISSING_POSIX_SPAWN -DENVIRON_DECL="extern char **environ;" -DEBUG= -D'debug(...)=fprintf(stderr,__VA_ARGS__)' -# -D_POSIX_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L \ - -U__STRICT_ANSI__ -D_GNU_SOURCE -INCLUDES = -I$(LUA)/include -I$(LUA)/src -WARNINGS = -W -Wall -#LUA = /home/mark/src/lang/lua/lua-5.1-rc2 -LUA = /home/medgar/src/lang/lua/lua-5.1.1 -#LUA = /home/medgar/src/lang/lua/lua5_1_1/cygw15 -LIBS = -L$(LUA)/src -llua5.1 +include ../conf -ex-OBJS = ex.o spawn.o +CFLAGS= $(WARNINGS) $(DEFINES) $(INCLUDES) +DEFINES= -D_XOPEN_SOURCE=600 $(POSIX_SPAWN) $(ENVIRON) +INCLUDES= $(LUAINC) +WARNINGS= -W -Wall +LIBS= $(LUALIB) -default: ex.so - -EXTRA = posix_spawn.o -ex.so: $(ex-OBJS) $(EXTRA); $(CC) -shared -o $@ $(ex-OBJS) $(EXTRA) $(LIBS) +T= ex.so +default: $(T) +OBJS= ex.o spawn.o $(EXTRA) +$(T): $(OBJS) $(EXTRA); $(CC) -shared -o $@ $(OBJS) $(LIBS) ex.o: ex.c spawn.h spawn.o: spawn.c spawn.h - posix_spawn.o: posix_spawn.c posix_spawn.h -clean:; rm -f *.o ex.dll ex.so ex.a +clean:; rm -f *.o ex.so ex.dll $(T) diff --git a/posix/ex.c b/posix/ex.c index 78b79ec..e602813 100755 --- a/posix/ex.c +++ b/posix/ex.c @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include #include #include diff --git a/posix/posix_spawn.c b/posix/posix_spawn.c index a1499b0..470a952 100755 --- a/posix/posix_spawn.c +++ b/posix/posix_spawn.c @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include #include #include diff --git a/posix/posix_spawn.h b/posix/posix_spawn.h index f4d576d..3e0bbd7 100755 --- a/posix/posix_spawn.h +++ b/posix/posix_spawn.h @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include #include #include diff --git a/posix/spawn.c b/posix/spawn.c index b39d53b..aaa5600 100755 --- a/posix/spawn.c +++ b/posix/spawn.c @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include ENVIRON_DECL #include diff --git a/posix/spawn.h b/posix/spawn.h index bb5df7c..3fddfb7 100755 --- a/posix/spawn.h +++ b/posix/spawn.h @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #ifndef SPAWN_H #define SPAWN_H diff --git a/w32api/Makefile b/w32api/Makefile index a752624..0f32736 100755 --- a/w32api/Makefile +++ b/w32api/Makefile @@ -1,17 +1,13 @@ -TARGET_ARCH = -mno-cygwin -CFLAGS = $(WARNINGS) $(DEFINES) $(INCLUDES) -DEFINES = -DWIN32_LEAN_AND_MEAN -INCLUDES = -I${LUA}/include -WARNINGS = -W -Wall -Wno-missing-braces -#LUA = /home/mark/src/lang/lua/lua-5.1-rc2 -#LUA = /home/mark/src/lang/lua/lua51 -LUA = /home/medgar/work/noom/lua/lua51 -LUALIBS = -L$(LUA) -llua5.1 +include ../conf -ex.dll-OBJS = ex.o spawn.o pusherror.o dirent.o -ex.dll-LIBS = $(LUALIBS) $(EXTRALIBS) -ex.dll: $(ex.dll-OBJS) - $(CC) $(TARGET_ARCH) -shared -o $@ $(ex.dll-OBJS) $(ex.dll-LIBS) -clean:; rm ex.dll *.o +TARGET_ARCH= -mno-cygwin +CFLAGS= $(WARNINGS) $(DEFINES) $(INCLUDES) +DEFINES= -DWIN32_LEAN_AND_MEAN -DNOGDI +INCLUDES= $(LUAINC) +WARNINGS= -W -Wall -Wno-missing-braces -wdir.o: wdir.c wdir.h +OBJS= ex.o spawn.o pusherror.o dirent.o +LIBS= $(LUALIB) +ex.dll: $(OBJS); $(CC) $(TARGET_ARCH) -shared -o $@ $(OBJS) $(LIBS) + +clean:; rm -f ex.dll *.o diff --git a/w32api/dirent.c b/w32api/dirent.c index cbce017..188590e 100755 --- a/w32api/dirent.c +++ b/w32api/dirent.c @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include #include #include "dirent.h" diff --git a/w32api/dirent.h b/w32api/dirent.h index b88825a..44c0c10 100755 --- a/w32api/dirent.h +++ b/w32api/dirent.h @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include typedef struct DIR_tag DIR; diff --git a/w32api/ex.c b/w32api/ex.c index 5e22fdf..d9c7295 100755 --- a/w32api/ex.c +++ b/w32api/ex.c @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include #include #include diff --git a/w32api/pusherror.c b/w32api/pusherror.c index 9b661b9..7ae7f5c 100755 --- a/w32api/pusherror.c +++ b/w32api/pusherror.c @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include /* sprintf() */ #include #define WIN32_LEAN_AND_MEAN 1 diff --git a/w32api/pusherror.h b/w32api/pusherror.h index 9105332..6d656de 100755 --- a/w32api/pusherror.h +++ b/w32api/pusherror.h @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #ifndef pusherror_h #define pusherror_h diff --git a/w32api/spawn.c b/w32api/spawn.c index 1f099c7..7c13c1f 100755 --- a/w32api/spawn.c +++ b/w32api/spawn.c @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #include #include #include diff --git a/w32api/spawn.h b/w32api/spawn.h index 30caf56..bff6feb 100755 --- a/w32api/spawn.h +++ b/w32api/spawn.h @@ -1,3 +1,8 @@ +/* + * "ex" API implementation + * http://lua-users.org/wiki/ExtensionProposal + * Copyright 2007 Mark Edgar < medgar at student gc maricopa edu > + */ #ifndef SPAWN_H #define SPAWN_H