mirror of
https://github.com/lxsang/ant-http
synced 2024-12-26 16:58:22 +01:00
fix mac os linker problem
This commit is contained in:
parent
41bce4f5e8
commit
6e5aa0ddcf
7
Makefile
7
Makefile
@ -30,11 +30,10 @@ CFLAGS= -W -Wall -g -std=c99 -D DEBUG $(DB_FLAG) $(PF_FLAG)
|
|||||||
LIB_PATH=$(BUILDIRD)/plugins
|
LIB_PATH=$(BUILDIRD)/plugins
|
||||||
LIB_NAME=libantd
|
LIB_NAME=libantd
|
||||||
LIB_FLAG= $(LIB_NAME).$(EXT)
|
LIB_FLAG= $(LIB_NAME).$(EXT)
|
||||||
SERVERLIB=-lpthread -ldl $(LIB_FLAG)
|
SERVERLIB= -ldl $(LIB_FLAG)
|
||||||
|
|
||||||
SERVER_O=plugin_manager.o \
|
SERVER_O=plugin_manager.o \
|
||||||
http_server.o \
|
http_server.o
|
||||||
httpd.o
|
|
||||||
#-lsocket
|
#-lsocket
|
||||||
PLUGINS= dummy.$(EXT) fileman.$(EXT) pluginsman.$(EXT) wterm.$(EXT) nodedaemon.$(EXT) cookiex.$(EXT) wsimg.$(EXT)
|
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)
|
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)
|
cp antd $(BUILDIRD)
|
||||||
|
|
||||||
lib: $(LIBOBJS)
|
lib: $(LIBOBJS)
|
||||||
|
@ -17,7 +17,6 @@ void accept_request(int client)
|
|||||||
char *query_string = NULL;
|
char *query_string = NULL;
|
||||||
|
|
||||||
numchars = get_line(client, buf, sizeof(buf));
|
numchars = get_line(client, buf, sizeof(buf));
|
||||||
//printf("%s\n", buf);
|
|
||||||
i = 0; j = 0;
|
i = 0; j = 0;
|
||||||
while (!ISspace(buf[j]) && (i < sizeof(method) - 1))
|
while (!ISspace(buf[j]) && (i < sizeof(method) - 1))
|
||||||
{
|
{
|
||||||
@ -60,11 +59,9 @@ void accept_request(int client)
|
|||||||
|
|
||||||
sprintf(path, server_config.htdocs);
|
sprintf(path, server_config.htdocs);
|
||||||
strcat(path, url);
|
strcat(path, url);
|
||||||
//LOG("Path %s\n", path);
|
|
||||||
if (path[strlen(path) - 1] == '/')
|
if (path[strlen(path) - 1] == '/')
|
||||||
strcat(path, "index.html");
|
strcat(path, "index.html");
|
||||||
if (stat(path, &st) == -1) {
|
if (stat(path, &st) == -1) {
|
||||||
|
|
||||||
if(execute_plugin(client,url,method,query_string) < 0)
|
if(execute_plugin(client,url,method,query_string) < 0)
|
||||||
not_found(client);
|
not_found(client);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#ifndef HTTP_SERVER
|
||||||
|
#define HTTP_SERVER
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@ -6,6 +8,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include "plugins/dictionary.h"
|
#include "plugins/dictionary.h"
|
||||||
|
#include "plugins/handle.h"
|
||||||
#include "plugin_manager.h"
|
#include "plugin_manager.h"
|
||||||
|
|
||||||
#define FORM_URL_ENCODE "application/x-www-form-urlencoded"
|
#define FORM_URL_ENCODE "application/x-www-form-urlencoded"
|
||||||
@ -38,4 +41,6 @@ dictionary decode_cookie(const char*);
|
|||||||
char* json_data_decode(int,int);
|
char* json_data_decode(int,int);
|
||||||
|
|
||||||
int execute_plugin(int client, const char *path,
|
int execute_plugin(int client, const char *path,
|
||||||
const char *method, const char *query_string);
|
const char *method, const char *query_string);
|
||||||
|
|
||||||
|
#endif
|
1
httpd.c
1
httpd.c
@ -100,6 +100,7 @@ int main(int argc, char* argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* accept_request(client_sock); */
|
/* accept_request(client_sock); */
|
||||||
|
|
||||||
if (pthread_create(&newthread , NULL,(void *(*)(void *))accept_request, (void *)client_sock) != 0)
|
if (pthread_create(&newthread , NULL,(void *(*)(void *))accept_request, (void *)client_sock) != 0)
|
||||||
perror("pthread_create");
|
perror("pthread_create");
|
||||||
else
|
else
|
||||||
|
@ -68,6 +68,7 @@ void * plugin_from_file(char* name)
|
|||||||
LOG("Problem when setting data path for %s : %s \n", name,error);
|
LOG("Problem when setting data path for %s : %s \n", name,error);
|
||||||
else
|
else
|
||||||
(*fn)(name,server_config.db_path, server_config.htdocs,server_config.plugins_dir,server_config.port);
|
(*fn)(name,server_config.db_path, server_config.htdocs,server_config.plugins_dir,server_config.port);
|
||||||
|
if(path)
|
||||||
free(path);
|
free(path);
|
||||||
return lib_handle;
|
return lib_handle;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ sqldb __getdb(char *name)
|
|||||||
}
|
}
|
||||||
sqldb getdb()
|
sqldb getdb()
|
||||||
{
|
{
|
||||||
return getdb(__plugin__.name);
|
return __getdb(__plugin__.name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user