-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp_my.c
89 lines (70 loc) · 1.9 KB
/
app_my.c
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* app_my: damn simple MySQL application for asterisk
* Copyright (C) 2010 - Steve Frécinaux
* Licensed under the GPL2+
*/
#include <asterisk.h>
#include <asterisk/cli.h>
#include <asterisk/module.h>
#include "config.h"
#include "database.h"
#include "query.h"
#include "auth.h"
static int load_module (void);
static int reload_module (void);
static int unload_module (void);
/*****************************************************************************
* CLI *
*****************************************************************************/
static int
handle_cli_my_reload (int fd,
int argc,
char **argv)
{
if (argc != 2)
return RESULT_SHOWUSAGE;
reload_module ();
return RESULT_SUCCESS;
}
static struct ast_cli_entry cli_entry = {
{ "my", "reload", NULL },
handle_cli_my_reload,
"Reload the mysql application"
};
/*****************************************************************************
* Module *
*****************************************************************************/
ASTERISK_FILE_VERSION (__FILE__, VERSION)
static int
load_module (void)
{
config_init ();
database_init ();
query_init (ast_module_info);
auth_init (ast_module_info);
ast_cli_register (&cli_entry);
return 0;
}
static int
reload_module (void)
{
config_reset ();
database_reset ();
return 0;
}
static int
unload_module (void)
{
auth_clean ();
query_clean ();
database_clean ();
config_clean ();
ast_cli_unregister (&cli_entry);
return 0;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY,
AST_MODFLAG_DEFAULT,
"BeIP MySQL Application",
.load = load_module,
.unload = unload_module,
.reload = reload_module);
/* ex:set ts=2 et sw=2 ai: */