Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00034 #ifndef _ACC_API_H_
00035 #define _ACC_API_H_
00036
00037 #include <stdio.h>
00038 #include <string.h>
00039
00040 #include "../../str.h"
00041 #include "../../dprint.h"
00042 #include "../../sr_module.h"
00043 #include "../../mem/mem.h"
00044
00045
00046 typedef struct acc_param {
00047 int code;
00048 str code_s;
00049 str reason;
00050 } acc_param_t;
00051
00052
00053 typedef struct acc_enviroment {
00054 unsigned int code;
00055 str code_s;
00056 str reason;
00057 struct hdr_field *to;
00058 str text;
00059 time_t ts;
00060 } acc_enviroment_t;
00061
00062
00063 typedef struct acc_extra {
00064 str name;
00065 pv_spec_t spec;
00066 struct acc_extra *next;
00067 } acc_extra_t;
00068
00069 typedef int (*core2strar_f)( struct sip_msg *req, str *c_vals,
00070 int *i_vals, char *t_vals);
00071 typedef int (*extra2strar_f)(struct acc_extra *extra, struct sip_msg *rq, str *val_arr,
00072 int *int_arr, char *type_arr);
00073 typedef int (*legs2strar_f)( struct acc_extra *legs, struct sip_msg *rq, str *val_arr,
00074 int *int_arr, char *type_arr, int start);
00075 typedef acc_extra_t* (*leg_info_f)(void);
00076
00077
00078 typedef struct acc_info {
00079 acc_enviroment_t *env;
00080 str *varr;
00081 int *iarr;
00082 char *tarr;
00083 acc_extra_t *leg_info;
00084 } acc_info_t;
00085
00086
00087 typedef struct acc_init_info {
00088 acc_extra_t *leg_info;
00089 } acc_init_info_t;
00090
00091 typedef int (*acc_init_f)(acc_init_info_t *inf);
00092 typedef int (*acc_req_f)(struct sip_msg *req, acc_info_t *data);
00093
00094
00095 typedef struct acc_engine {
00096 char name[16];
00097 int flags;
00098 int acc_flag;
00099 int missed_flag;
00100 acc_init_f acc_init;
00101 acc_req_f acc_req;
00102 struct acc_engine *next;
00103 } acc_engine_t;
00104
00105 #define MAX_ACC_EXTRA 64
00106 #define MAX_ACC_LEG 16
00107 #define ACC_CORE_LEN 6
00108
00109
00110 enum {TYPE_NULL = 0, TYPE_INT, TYPE_STR};
00111
00112
00113 typedef int (*register_engine_f)(acc_engine_t *eng);
00114 typedef int (*acc_api_exec_f)(struct sip_msg *rq, acc_engine_t *eng,
00115 acc_param_t* comment);
00116 typedef acc_extra_t* (*parse_extra_f)(char *extra_str);
00117
00118
00119 typedef struct acc_api {
00120 leg_info_f get_leg_info;
00121 core2strar_f get_core_attrs;
00122 extra2strar_f get_extra_attrs;
00123 legs2strar_f get_leg_attrs;
00124 parse_extra_f parse_extra;
00125 register_engine_f register_engine;
00126 acc_api_exec_f exec;
00127 } acc_api_t;
00128
00129 typedef int (*bind_acc_f)(acc_api_t* api);
00130
00131 int acc_run_engines(struct sip_msg *msg, int type, int *reset);
00132 acc_engine_t *acc_api_get_engines(void);
00133 void acc_api_set_arrays(acc_info_t *inf);
00134
00135
00139 static inline int acc_load_api(acc_api_t *accb)
00140 {
00141 bind_acc_f bindacc;
00142
00143 bindacc = (bind_acc_f)find_export("bind_acc", 0, 0);
00144 if (bindacc == 0) {
00145 LM_ERR("cannot find bind_acc\n");
00146 return -1;
00147 }
00148 if (bindacc(accb)==-1)
00149 {
00150 LM_ERR("cannot bind acc api\n");
00151 return -1;
00152 }
00153 return 0;
00154 }
00155
00156
00157 #endif