73 lines
1.4 KiB
C
73 lines
1.4 KiB
C
#ifndef FCGI_SERVER_H_INCLUDED
|
|
#define FCGI_SERVER_H_INCLUDED
|
|
|
|
#include <fcgiapp.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
typedef struct fcgi_server_s* HFcgi;
|
|
|
|
|
|
typedef enum fcgi_handler_status_e {
|
|
HANDLER_ERROR = -1,
|
|
HANDLER_SUCCESS = 0,
|
|
HANDLER_HTTP_OK = 200,
|
|
HANDLER_REDIRECT_TO_LOGIN = 302,
|
|
HANDLER_HTTP_BAD_REQUEST = 400,
|
|
HANDLER_HTTP_UNAUTHORIZED = 401,
|
|
HANDLER_HTTP_NOT_FOUND = 404,
|
|
HANDLER_HTTP_METHOD_NOT_ALLOWED = 405,
|
|
HANDLER_HTTP_NOT_ACCEPTABLE = 406,
|
|
HANDLER_HTTP_REQUEST_ENTITY_TOO_LARGE = 413,
|
|
HANDLER_HTTP_INTERNAL_SERVER_ERROR = 500,
|
|
} fcgi_handler_status_t;
|
|
|
|
|
|
typedef fcgi_handler_status_t (*handler_func)(FCGX_Request* request, void* ctx);
|
|
|
|
|
|
typedef struct fcgi_handler_s {
|
|
handler_func execute;
|
|
void *ctx;
|
|
|
|
} fcgi_handler_t;
|
|
|
|
|
|
typedef struct fcgi_tcp_s {
|
|
char *host;
|
|
int port;
|
|
|
|
} fcgi_tcp_t;
|
|
|
|
|
|
typedef struct fcgi_conf_s {
|
|
fcgi_tcp_t listen;
|
|
size_t thread_pool_size;
|
|
|
|
} fcgi_conf_t;
|
|
|
|
|
|
int fcgi_load_conf(const char* filename, fcgi_conf_t* conf);
|
|
void fcgi_clear_conf(fcgi_conf_t* conf);
|
|
|
|
HFcgi fcgi_create_server(const fcgi_conf_t* conf);
|
|
void fcgi_dispose_server(HFcgi);
|
|
|
|
int fcgi_register_handler(HFcgi hfcgi, char* path, fcgi_handler_t* handler);
|
|
|
|
int fcgi_run_server(HFcgi);
|
|
int fcgi_stop_server(HFcgi);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#endif /* FCGI_SERVER_H_INCLUDED */
|