#ifndef OBJECT_H
#define OBJECT_H
#include "../public/nsapi.h"
#include "pool.h"
#ifdef __cplusplus
extern "C" {
#endif
enum RequestStage {
NSAPIAuthTrans =
0,
NSAPINameTrans,
NSAPIPathCheck,
NSAPIObjectType,
NSAPIService,
NSAPIError,
NSAPIAddLog,
REQ_FINISH,
NUM_NSAPI_TYPES
};
typedef enum RequestStage RequestStage;
typedef struct Condition Condition;
typedef int8_t ConditionResult;
typedef struct Expression Expression;
typedef enum OperandType OperandType;
typedef enum Operator Operator;
typedef enum VarType VarType;
typedef struct NSAPIContext NSAPIContext;
typedef struct HTTPObjectConfig HTTPObjectConfig;
struct directive {
FuncStruct *func;
pblock *param;
Condition *cond;
};
struct dtable {
directive **dirs;
int ndir;
};
struct httpd_object {
pool_handle_t *pool;
char *name;
char *path;
dtable *dt;
int nd;
};
struct httpd_objset {
httpd_object **obj;
int pos;
};
struct Condition {
Condition *parent;
Expression *expression;
int index;
};
struct Expression {
int n;
};
struct NSAPIContext{
HTTPObjectConfig *conf;
ConditionResult **results;
int nres;
int nmaxres;
int last_req_code;
int objset_index;
int dtable_index;
};
struct HTTPObjectConfig {
httpd_object **objects;
int nobj;
pool_handle_t *pool;
uint32_t ref;
};
httpd_object* object_new(
pool_handle_t *pool,
char *name);
void object_free(httpd_object *obj);
void object_add_directive(httpd_object *obj, directive *dir,
int dt);
#define object_get_dtable(obj,type) &obj->dt[type];
httpd_objset* objset_create(
pool_handle_t *pool);
void objset_add_object(
pool_handle_t *p, httpd_objset *os, httpd_object *obj);
void httpobjconf_add_object(HTTPObjectConfig *conf, httpd_object *obj);
void nsapi_context_next_stage(NSAPIContext *context);
Condition* condition_from_str(
pool_handle_t *pool,
char *expr,
size_t len);
Expression* expression_from_str(
pool_handle_t *pool,
char *expr,
size_t len);
int condition_evaluate(Condition *condition, Session *sn, Request *rq);
#ifdef __cplusplus
}
#endif
#endif