1
0
mirror of https://github.com/lxsang/ant-http synced 2024-07-01 12:59:47 +02:00

fix mac os linker problem

This commit is contained in:
Xuan Sang LE 2017-07-30 01:00:36 +02:00
parent 41bce4f5e8
commit 6e5aa0ddcf
6 changed files with 12 additions and 9 deletions

View File

@ -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)

View File

@ -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);
}

View File

@ -1,3 +1,5 @@
#ifndef HTTP_SERVER
#define HTTP_SERVER
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ -6,6 +8,7 @@
#include <signal.h>
#include <sys/socket.h>
#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);
const char *method, const char *query_string);
#endif

View File

@ -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

View File

@ -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;
}

View File

@ -27,7 +27,7 @@ sqldb __getdb(char *name)
}
sqldb getdb()
{
return getdb(__plugin__.name);
return __getdb(__plugin__.name);
}
#endif