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

add flexible compilation, allow to select sqlite support or not

This commit is contained in:
lxsang 2016-02-26 14:32:13 +01:00
parent d14351de2c
commit e75303b2e1
14 changed files with 16 additions and 10 deletions

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

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

Binary file not shown.

View File

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

View File

@ -1,7 +1,9 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#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*/

Binary file not shown.

View File

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

View File

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