ant-http/plugins/plugin.h

63 lines
1.4 KiB
C
Raw Normal View History

2015-10-22 11:39:11 +02:00
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef USE_DB
2015-10-22 11:39:11 +02:00
#include "dbhelper.h"
#endif
2015-10-22 11:39:11 +02:00
#include "dictionary.h"
#include "list.h"
2016-02-29 22:48:22 +01:00
#include "ini.h"
2015-10-22 11:39:11 +02:00
2016-02-29 22:48:22 +01:00
#define SERVER_NAME "antd"
2015-10-22 11:39:11 +02:00
#define IS_POST(method) (strcmp(method,"POST")== 0)
#define IS_GET(method) (strcmp(method,"GET")== 0)
2015-11-24 17:58:32 +01:00
#define R_STR(d,k) ((char*)dvalue(d,k))
2015-12-02 13:46:11 +01:00
#define R_INT(d,k) (atoi(dvalue(d,k)))
#define R_FLOAT(d,k) ((double)atof(dvalue(d,k)))
2015-11-24 17:58:32 +01:00
#define R_PTR(d,k) (dvalue(d,k))
2015-10-22 11:39:11 +02:00
#define __RESULT__ "{\"result\":%d,\"msg\":\"%s\"}"
typedef struct {
char *name;
char *dbpath;
char * htdocs;
char*pdir;
2016-03-04 11:38:08 +01:00
int *sport;
2015-10-22 11:39:11 +02:00
} plugin_header;
typedef void(*call)();
#ifdef USE_DB
2015-10-22 11:39:11 +02:00
typedef sqlite3* sqldb;
#endif
2015-10-22 11:39:11 +02:00
extern plugin_header __plugin__;
extern call __init__;
2015-11-24 17:58:32 +01:00
int response(int, const char*);
2015-10-22 11:39:11 +02:00
void header_base(int);
void header(int,const char*);
void redirect(int,const char*);
void html(int);
void text(int);
void json(int);
void jpeg(int);
2015-11-24 17:58:32 +01:00
void octstream(int, char*);
void textstream(int);
int __ti(int,int);
int __t(int, const char*,...);
int __b(int, const unsigned char*, int);
int __f(int, const char*);
int __fb(int, const char*);
2015-10-22 11:39:11 +02:00
int upload(const char*, const char*);
2016-03-04 11:38:08 +01:00
char* config_dir();
2015-10-22 11:39:11 +02:00
char* route(const char*);
char* htdocs(const char*);
#ifdef USE_DB
2015-10-22 11:39:11 +02:00
sqldb getdb();
#endif
2015-10-22 11:39:11 +02:00
void set_cookie(int,dictionary);
/*Default function for plugin*/
void execute(int, const char*,dictionary);