diff --git a/Makefile b/Makefile index 089817f..2922239 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-W -Wall -g -std=c99 -D DEBUG +CFLAGS=-W -Wall -g -std=c99 -D DEBUG -D USE_DB EXT=dylib SERVER=plugin_manager.o ini.o http_server.o plugins/dictionary.o plugins/utils.o SERVERLIB=-lpthread -ldl @@ -8,7 +8,7 @@ ifeq ($(UNAME_S),Linux) BUILDIRD=/root/antd endif ifeq ($(UNAME_S),Darwin) - BUILDIRD=../build + BUILDIRD=./build endif #-lsocket @@ -17,7 +17,7 @@ PLUGINS= dummy.$(EXT) fileman.$(EXT) pluginsman.$(EXT) wterm.$(EXT) PLUGINSDEP = plugins/plugin.o plugins/dbhelper.o plugins/dictionary.o plugins/utils.o plugins/list.o PLUGINLIBS = -lsqlite3 -main: httpd plugins +main: httpd plugins httpd:$(SERVER) @@ -29,7 +29,7 @@ plugins: $(PLUGINS) %.$(EXT): $(PLUGINSDEP) for file in $(wildcard plugins/$(basename $@)/*.c) ; do\ - $(CC) $(CFLAGS) -c $$file -o $$file.o; \ + $(CC) $(CFLAGS) -c $$file -o $$file.o; \ done $(CC) $(CFLAGS) $(PLUGINLIBS) -shared -o $(BUILDIRD)/plugins/$(basename $@).$(EXT) \ $(PLUGINSDEP) plugins/$(basename $@)/*.c.o diff --git a/build/httpd b/build/httpd index 1cdc37f..fa086d8 100755 Binary files a/build/httpd and b/build/httpd differ diff --git a/build/httpd.dSYM/Contents/Resources/DWARF/httpd b/build/httpd.dSYM/Contents/Resources/DWARF/httpd index 6c505f5..4ae4747 100644 Binary files a/build/httpd.dSYM/Contents/Resources/DWARF/httpd and b/build/httpd.dSYM/Contents/Resources/DWARF/httpd differ diff --git a/build/plugins/dummy.dylib b/build/plugins/dummy.dylib index 6ac1b7d..bfca39c 100755 Binary files a/build/plugins/dummy.dylib and b/build/plugins/dummy.dylib differ diff --git a/build/plugins/fileman.dylib b/build/plugins/fileman.dylib index 846c316..d122eb1 100755 Binary files a/build/plugins/fileman.dylib and b/build/plugins/fileman.dylib differ diff --git a/build/plugins/pluginsman.dylib b/build/plugins/pluginsman.dylib index 208c682..7a5c4fb 100755 Binary files a/build/plugins/pluginsman.dylib and b/build/plugins/pluginsman.dylib differ diff --git a/build/plugins/wterm.dylib b/build/plugins/wterm.dylib index b534109..5efd641 100755 Binary files a/build/plugins/wterm.dylib and b/build/plugins/wterm.dylib differ diff --git a/plugin_manager.c b/plugin_manager.c index 3109515..0a68b78 100644 --- a/plugin_manager.c +++ b/plugin_manager.c @@ -12,7 +12,7 @@ config_t server_config; */ char* post_url_decode(int client,int len) { - char *query = (char*) malloc(len*sizeof(char)); + char *query = (char*) malloc((len+1)*sizeof(char)); for (int i = 0; i < len; i++) { recv(client, (query+i), 1, 0); } @@ -465,7 +465,7 @@ int execute_plugin(int client, const char *path, const char *method, const char void (*fn)(int, const char*,dictionary); struct plugin_entry *plugin ; int plen = strlen(path); - char * rpath = (char*) malloc(plen*sizeof(char)); + char * rpath = (char*) malloc((plen+1)*sizeof(char)); char *error; memcpy(rpath,path+1,plen); rpath[plen] = '\0'; diff --git a/plugins/fileman/fileman.c.o b/plugins/fileman/fileman.c.o index f6b681d..e0b69de 100644 Binary files a/plugins/fileman/fileman.c.o and b/plugins/fileman/fileman.c.o differ diff --git a/plugins/plugin.c b/plugins/plugin.c index a36f975..f57fd0a 100644 --- a/plugins/plugin.c +++ b/plugins/plugin.c @@ -11,6 +11,7 @@ void __init_plugin__(const char* pl,const char*ph,const char* htdocs, const char __plugin__.pdir = strdup(pdir); if(__init__ != NULL) __init__(); }; +#ifdef USE_DB sqldb getdb() { int plen = strlen(__plugin__.name)+strlen(__plugin__.dbpath)+4; @@ -22,6 +23,7 @@ sqldb getdb() free(path); return ret; } +#endif void header_base(int client) { diff --git a/plugins/plugin.h b/plugins/plugin.h index ea4375a..0f02c5d 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -1,7 +1,9 @@ #include #include #include +#ifdef USE_DB #include "dbhelper.h" +#endif #include "dictionary.h" #include "list.h" @@ -24,9 +26,9 @@ typedef struct { typedef void(*call)(); - +#ifdef USE_DB typedef sqlite3* sqldb; - +#endif extern plugin_header __plugin__; extern call __init__; @@ -48,8 +50,9 @@ int __fb(int, const char*); int upload(const char*, const char*); char* route(const char*); char* htdocs(const char*); +#ifdef USE_DB sqldb getdb(); -void dbclose(sqldb); +#endif void set_cookie(int,dictionary); /*Default function for plugin*/ diff --git a/plugins/pluginsman/pluginsman.c.o b/plugins/pluginsman/pluginsman.c.o index bb80d10..7c26e86 100644 Binary files a/plugins/pluginsman/pluginsman.c.o and b/plugins/pluginsman/pluginsman.c.o differ diff --git a/plugins/utils.c b/plugins/utils.c index 469af6b..6ee596e 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -325,4 +325,4 @@ unsigned hash(const char* key, int hash_size) for (hashval = 0; *key != '\0'; key++) hashval = *key + 31 * hashval; return hashval % hash_size; -} +} \ No newline at end of file diff --git a/plugins/utils.h b/plugins/utils.h index e1d327f..6945b1c 100644 --- a/plugins/utils.h +++ b/plugins/utils.h @@ -40,6 +40,7 @@ THE SOFTWARE. #define IEQU(a,b) (strcasecmp(a,b) == 0) #define IS_INT(a) (match_int(a)) #define IS_FLOAT(a) (match_float(a)) +#define FILE_OK(f) ( access( f, F_OK ) != -1 ) #define DIR_SEP "/" #define true 1 #define false 0