From 6e5aa0ddcf503bfd84969951c8e15e4ca667e89b Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Sun, 30 Jul 2017 01:00:36 +0200 Subject: [PATCH] fix mac os linker problem --- Makefile | 7 +++---- http_server.c | 3 --- http_server.h | 7 ++++++- httpd.c | 1 + plugin_manager.c | 1 + plugins/plugin.c | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 873c50d..19cb4ca 100644 --- a/Makefile +++ b/Makefile @@ -30,11 +30,10 @@ CFLAGS= -W -Wall -g -std=c99 -D DEBUG $(DB_FLAG) $(PF_FLAG) LIB_PATH=$(BUILDIRD)/plugins LIB_NAME=libantd LIB_FLAG= $(LIB_NAME).$(EXT) -SERVERLIB=-lpthread -ldl $(LIB_FLAG) +SERVERLIB= -ldl $(LIB_FLAG) SERVER_O=plugin_manager.o \ - http_server.o \ - httpd.o + http_server.o #-lsocket PLUGINS= dummy.$(EXT) fileman.$(EXT) pluginsman.$(EXT) wterm.$(EXT) nodedaemon.$(EXT) cookiex.$(EXT) wsimg.$(EXT) @@ -55,7 +54,7 @@ main: httpd plugins httpd: lib $(SERVER_O) - $(CC) $(CFLAGS) $(SERVER_O) $(SERVERLIB) -o $(BUILDIRD)/httpd + $(CC) $(CFLAGS) $(SERVER_O) $(SERVERLIB) -o $(BUILDIRD)/httpd httpd.c cp antd $(BUILDIRD) lib: $(LIBOBJS) diff --git a/http_server.c b/http_server.c index 3247bd5..78ba035 100644 --- a/http_server.c +++ b/http_server.c @@ -17,7 +17,6 @@ void accept_request(int client) char *query_string = NULL; numchars = get_line(client, buf, sizeof(buf)); - //printf("%s\n", buf); i = 0; j = 0; while (!ISspace(buf[j]) && (i < sizeof(method) - 1)) { @@ -60,11 +59,9 @@ void accept_request(int client) sprintf(path, server_config.htdocs); strcat(path, url); - //LOG("Path %s\n", path); if (path[strlen(path) - 1] == '/') strcat(path, "index.html"); if (stat(path, &st) == -1) { - if(execute_plugin(client,url,method,query_string) < 0) not_found(client); } diff --git a/http_server.h b/http_server.h index 91e3bc8..b5d7978 100644 --- a/http_server.h +++ b/http_server.h @@ -1,3 +1,5 @@ +#ifndef HTTP_SERVER +#define HTTP_SERVER #include #include #include @@ -6,6 +8,7 @@ #include #include #include "plugins/dictionary.h" +#include "plugins/handle.h" #include "plugin_manager.h" #define FORM_URL_ENCODE "application/x-www-form-urlencoded" @@ -38,4 +41,6 @@ dictionary decode_cookie(const char*); char* json_data_decode(int,int); int execute_plugin(int client, const char *path, - const char *method, const char *query_string); \ No newline at end of file + const char *method, const char *query_string); + +#endif \ No newline at end of file diff --git a/httpd.c b/httpd.c index 34ead3f..7801b47 100644 --- a/httpd.c +++ b/httpd.c @@ -100,6 +100,7 @@ int main(int argc, char* argv[]) continue; } /* accept_request(client_sock); */ + if (pthread_create(&newthread , NULL,(void *(*)(void *))accept_request, (void *)client_sock) != 0) perror("pthread_create"); else diff --git a/plugin_manager.c b/plugin_manager.c index 20fd410..62aa5d8 100644 --- a/plugin_manager.c +++ b/plugin_manager.c @@ -68,6 +68,7 @@ void * plugin_from_file(char* name) LOG("Problem when setting data path for %s : %s \n", name,error); else (*fn)(name,server_config.db_path, server_config.htdocs,server_config.plugins_dir,server_config.port); + if(path) free(path); return lib_handle; } diff --git a/plugins/plugin.c b/plugins/plugin.c index 01cc402..307464b 100644 --- a/plugins/plugin.c +++ b/plugins/plugin.c @@ -27,7 +27,7 @@ sqldb __getdb(char *name) } sqldb getdb() { - return getdb(__plugin__.name); + return __getdb(__plugin__.name); } #endif