mirror of
https://github.com/lxsang/ant-http
synced 2024-12-26 16:58:22 +01:00
add flexible compilation, allow to select sqlite support or not
This commit is contained in:
parent
d14351de2c
commit
e75303b2e1
4
Makefile
4
Makefile
@ -1,5 +1,5 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-W -Wall -g -std=c99 -D DEBUG
|
CFLAGS=-W -Wall -g -std=c99 -D DEBUG -D USE_DB
|
||||||
EXT=dylib
|
EXT=dylib
|
||||||
SERVER=plugin_manager.o ini.o http_server.o plugins/dictionary.o plugins/utils.o
|
SERVER=plugin_manager.o ini.o http_server.o plugins/dictionary.o plugins/utils.o
|
||||||
SERVERLIB=-lpthread -ldl
|
SERVERLIB=-lpthread -ldl
|
||||||
@ -8,7 +8,7 @@ ifeq ($(UNAME_S),Linux)
|
|||||||
BUILDIRD=/root/antd
|
BUILDIRD=/root/antd
|
||||||
endif
|
endif
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
BUILDIRD=../build
|
BUILDIRD=./build
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#-lsocket
|
#-lsocket
|
||||||
|
BIN
build/httpd
BIN
build/httpd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -12,7 +12,7 @@ config_t server_config;
|
|||||||
*/
|
*/
|
||||||
char* post_url_decode(int client,int len)
|
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++) {
|
for (int i = 0; i < len; i++) {
|
||||||
recv(client, (query+i), 1, 0);
|
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);
|
void (*fn)(int, const char*,dictionary);
|
||||||
struct plugin_entry *plugin ;
|
struct plugin_entry *plugin ;
|
||||||
int plen = strlen(path);
|
int plen = strlen(path);
|
||||||
char * rpath = (char*) malloc(plen*sizeof(char));
|
char * rpath = (char*) malloc((plen+1)*sizeof(char));
|
||||||
char *error;
|
char *error;
|
||||||
memcpy(rpath,path+1,plen);
|
memcpy(rpath,path+1,plen);
|
||||||
rpath[plen] = '\0';
|
rpath[plen] = '\0';
|
||||||
|
Binary file not shown.
@ -11,6 +11,7 @@ void __init_plugin__(const char* pl,const char*ph,const char* htdocs, const char
|
|||||||
__plugin__.pdir = strdup(pdir);
|
__plugin__.pdir = strdup(pdir);
|
||||||
if(__init__ != NULL) __init__();
|
if(__init__ != NULL) __init__();
|
||||||
};
|
};
|
||||||
|
#ifdef USE_DB
|
||||||
sqldb getdb()
|
sqldb getdb()
|
||||||
{
|
{
|
||||||
int plen = strlen(__plugin__.name)+strlen(__plugin__.dbpath)+4;
|
int plen = strlen(__plugin__.name)+strlen(__plugin__.dbpath)+4;
|
||||||
@ -22,6 +23,7 @@ sqldb getdb()
|
|||||||
free(path);
|
free(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
void header_base(int client)
|
void header_base(int client)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#ifdef USE_DB
|
||||||
#include "dbhelper.h"
|
#include "dbhelper.h"
|
||||||
|
#endif
|
||||||
#include "dictionary.h"
|
#include "dictionary.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
@ -24,9 +26,9 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
typedef void(*call)();
|
typedef void(*call)();
|
||||||
|
#ifdef USE_DB
|
||||||
typedef sqlite3* sqldb;
|
typedef sqlite3* sqldb;
|
||||||
|
#endif
|
||||||
extern plugin_header __plugin__;
|
extern plugin_header __plugin__;
|
||||||
extern call __init__;
|
extern call __init__;
|
||||||
|
|
||||||
@ -48,8 +50,9 @@ int __fb(int, const char*);
|
|||||||
int upload(const char*, const char*);
|
int upload(const char*, const char*);
|
||||||
char* route(const char*);
|
char* route(const char*);
|
||||||
char* htdocs(const char*);
|
char* htdocs(const char*);
|
||||||
|
#ifdef USE_DB
|
||||||
sqldb getdb();
|
sqldb getdb();
|
||||||
void dbclose(sqldb);
|
#endif
|
||||||
void set_cookie(int,dictionary);
|
void set_cookie(int,dictionary);
|
||||||
|
|
||||||
/*Default function for plugin*/
|
/*Default function for plugin*/
|
||||||
|
Binary file not shown.
@ -40,6 +40,7 @@ THE SOFTWARE.
|
|||||||
#define IEQU(a,b) (strcasecmp(a,b) == 0)
|
#define IEQU(a,b) (strcasecmp(a,b) == 0)
|
||||||
#define IS_INT(a) (match_int(a))
|
#define IS_INT(a) (match_int(a))
|
||||||
#define IS_FLOAT(a) (match_float(a))
|
#define IS_FLOAT(a) (match_float(a))
|
||||||
|
#define FILE_OK(f) ( access( f, F_OK ) != -1 )
|
||||||
#define DIR_SEP "/"
|
#define DIR_SEP "/"
|
||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
|
Loading…
Reference in New Issue
Block a user