summaryrefslogtreecommitdiff
path: root/service/include/sc_app.h
blob: b5cb9deeefc9123015e346b7658ebbb4bf14ff56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <common.h>
#include <netinet/in.h>
#include <sc_common.h>
#include <sys/queue.h>

struct app_main;
struct app;

struct app
{
    TAILQ_ENTRY(app) next;
    /* APP名称 */
    char symbol[MR_SYMBOL_MAX];
    /* 是否已经注册,(对于仅进行控制面操作的程序,不需要注册) */
    unsigned int registered;
    /* 进程号 */
    pid_t pid;
    /* 监控文件路径 */
    char mntfile[MR_STRING_MAX];
    /* 监控app是否存活*/
    int fd;
    uint8_t job_id_used;
    /* 虚设备管理模块在APP中的保存的上下文 */
    void * pme_vdev_main;
};
enum app_event_type
{
    APP_EV_TYPE_REGISTER = 0,
    APP_EV_TYPE_UNREGISTER = 1,
    APP_EV_TYPE_MAX
};

typedef void (*app_event_handler_t)(struct app_main *, struct app *, void *);

void app_event_handler_register(struct app_main * app_main, enum app_event_type event_type,
                                app_event_handler_t fn_handler, void * arg);

struct app * app_lookup_by_symbol(struct sc_main * sc, const char * appsym);
struct app * app_lookup_by_fd(struct sc_main * sc, int fd);
int app_main_init(struct sc_main * sc);