2017-07-29 22:00:34 +02:00
|
|
|
#ifndef HANDLE_H
|
|
|
|
#define HANDLE_H
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
2018-02-10 11:22:41 +01:00
|
|
|
//open ssl
|
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
#include <openssl/ssl.h>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
#endif
|
2017-07-29 22:00:34 +02:00
|
|
|
#ifdef USE_DB
|
|
|
|
#include "dbhelper.h"
|
|
|
|
#endif
|
|
|
|
#include "dictionary.h"
|
|
|
|
#include "list.h"
|
|
|
|
#include "ini.h"
|
|
|
|
|
|
|
|
#define SERVER_NAME "antd"
|
|
|
|
#define IS_POST(method) (strcmp(method,"POST")== 0)
|
|
|
|
#define IS_GET(method) (strcmp(method,"GET")== 0)
|
|
|
|
#define R_STR(d,k) ((char*)dvalue(d,k))
|
|
|
|
#define R_INT(d,k) (atoi(dvalue(d,k)))
|
|
|
|
#define R_FLOAT(d,k) ((double)atof(dvalue(d,k)))
|
|
|
|
#define R_PTR(d,k) (dvalue(d,k))
|
|
|
|
#define __RESULT__ "{\"result\":%d,\"msg\":\"%s\"}"
|
|
|
|
|
|
|
|
|
2018-02-10 11:22:41 +01:00
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
int __attribute__((weak)) usessl();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int port;
|
|
|
|
char *plugins_dir;
|
|
|
|
char *plugins_ext;
|
|
|
|
char *db_path;
|
|
|
|
char* htdocs;
|
|
|
|
char* tmpdir;
|
2018-02-23 19:54:16 +01:00
|
|
|
list rules;
|
2018-02-20 19:02:31 +01:00
|
|
|
dictionary handlers;
|
2018-02-10 11:22:41 +01:00
|
|
|
int backlog;
|
2018-03-08 11:39:44 +01:00
|
|
|
int maxcon;
|
|
|
|
int connection;
|
2018-02-10 11:22:41 +01:00
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
int usessl;
|
|
|
|
char* sslcert;
|
|
|
|
char* sslkey;
|
|
|
|
#endif
|
|
|
|
}config_t;
|
2018-03-08 22:59:04 +01:00
|
|
|
//extern config_t server_config;
|
2018-02-10 11:22:41 +01:00
|
|
|
typedef struct{
|
|
|
|
int sock;
|
|
|
|
void* ssl;
|
2018-09-12 11:06:19 +02:00
|
|
|
char* ip;
|
2018-02-10 11:22:41 +01:00
|
|
|
} antd_client_t;
|
2017-07-29 22:00:34 +02:00
|
|
|
|
2018-02-10 11:22:41 +01:00
|
|
|
int response(void*, const char*);
|
|
|
|
void ctype(void*,const char*);
|
|
|
|
void redirect(void*,const char*);
|
|
|
|
void html(void*);
|
|
|
|
void text(void*);
|
|
|
|
void json(void*);
|
|
|
|
void jpeg(void*);
|
|
|
|
void octstream(void*, char*);
|
|
|
|
void textstream(void*);
|
|
|
|
int __ti(void*,int);
|
|
|
|
int __t(void*, const char*,...);
|
|
|
|
int __b(void*, const unsigned char*, int);
|
|
|
|
int __f(void*, const char*);
|
|
|
|
int __fb(void*, const char*);
|
2017-07-29 22:00:34 +02:00
|
|
|
int upload(const char*, const char*);
|
|
|
|
|
2018-02-10 11:22:41 +01:00
|
|
|
void set_cookie(void*, const char*,dictionary,const char*);
|
|
|
|
void set_status(void*,int,const char*);
|
|
|
|
void clear_cookie(void*, dictionary);
|
2017-07-29 22:00:34 +02:00
|
|
|
/*Default function for plugin*/
|
2018-02-10 11:22:41 +01:00
|
|
|
void unknow(void*);
|
2017-07-29 22:00:34 +02:00
|
|
|
int ws_enable(dictionary);
|
2018-02-10 11:22:41 +01:00
|
|
|
char* read_line(void* sock);
|
|
|
|
int read_buf(void* sock,char* buf,int i);
|
2018-05-03 15:10:44 +02:00
|
|
|
int antd_send( void *source, const void* data, int len);
|
|
|
|
int antd_recv( void *source, void* data, int len);
|
2018-02-10 11:22:41 +01:00
|
|
|
int antd_close(void* source);
|
2017-07-29 22:00:34 +02:00
|
|
|
#endif
|