Files
selfcare/proxy_c/selfcare_res.h
2025-03-03 11:40:37 +08:00

67 lines
1.3 KiB
C

#ifndef __SELFCARE_RES_H__
#define __SELFCARE_RES_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "selfcare_httpsrv.h"
#include "selfcare_config.h"
typedef enum _selfcare_state_e
{
SELFCARE_IDLE = 0,
SELFCARE_WAIT_SELFCARE_REQ,
SELFCARE_WAIT_SEND2OCS_REQ,
SELFCARE_WAIT_OCS_RESP,
SELFCARE_WAIT_SEND2SELFCARE_RESP,
SELFCARE_LOCAL_INIT_REQ,
SELFCARE_LOCAL_INIT_RESP,
SELFCARE_RELEASE,
SELFCARE_STATE_MAX,
}selfcare_state_e;
#define SELFCARE_RES_NUM (1024)
typedef struct _selfcare_res_s
{
int id;
unsigned int timer;
selfcare_state_e state; /* 状态 */
struct evhttp_request *req; /* selfcare 发过来的请求指针 */
char *arg; /* libevent 回调参数 */
SELFCARE_URL_E req_type; /* 请求类型 */
_rest_msg_s resp; /* OCS 回复的udp消息 */
int local_init_flag;
int local_init_oc;
int local_init_db_key;
}selfcare_res_s;
extern selfcare_res_s g_res_arr[SELFCARE_RES_NUM];
/* 申请资源id */
int selfcare_res_get(int *res_id);
/* 释放id */
int selfcare_res_release(const int res_id);
const char *selfcare_res_stateprint(selfcare_state_e state);
/* 初始化 */
int selfcare_res_init(int argc, char **argv);
/* 反初始化 */
void selfcare_res_uninit(void);
#ifdef __cplusplus
}
#endif
#endif /* __SELFCARE_RES_H__ */