2 * Asterisk -- A telephony toolkit for Linux.
6 * Copyright (C) <Year>, <Your Name Here>
8 * <Your Name Here> <<You Email Here>>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
14 #include <asterisk/file.h>
15 #include <asterisk/logger.h>
16 #include <asterisk/channel.h>
17 #include <asterisk/pbx.h>
18 #include <asterisk/module.h>
19 #include <asterisk/lock.h>
20 #include <asterisk/app.h>
25 static char *tdesc = "Trivial skeleton Application";
26 static char *app = "skel";
27 static char *synopsis =
28 " This is a skeleton application that shows you the basic structure to create your\n"
29 "own asterisk applications.\n";
31 #define OPTION_A (1 << 0) /* Option A */
32 #define OPTION_B (1 << 1) /* Option B(n) */
33 #define OPTION_C (1 << 2) /* Option C(str) */
34 #define OPTION_NULL (1 << 3) /* Dummy Termination */
36 AST_DECLARE_OPTIONS(app_opts,{
38 ['b'] = { OPTION_B, 1 },
39 ['c'] = { OPTION_C, 2 }
46 static int app_exec(struct ast_channel *chan, void *data)
49 struct ast_flags flags;
58 if (!(args = ast_strdupa((char *)data))) {
59 ast_log(LOG_ERROR, "Out of memory!\n");
64 ast_log(LOG_WARNING, "%s requires an argument (dummy|[options])\n",app);
69 if ((argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(char *)))) {
72 ast_parseoptions(app_opts, &flags, opts, options);
76 if (dummy && !ast_strlen_zero(dummy))
77 ast_log(LOG_NOTICE, "Dummy value is : %s\n", dummy);
79 if (ast_test_flag(&flags, OPTION_A))
80 ast_log(LOG_NOTICE, "Option A is set\n");
82 if (ast_test_flag(&flags, OPTION_B))
83 ast_log(LOG_NOTICE,"Option B is set with : %s\n", opts[0] ? opts[0] : "<unspecified>");
85 if (ast_test_flag(&flags, OPTION_C))
86 ast_log(LOG_NOTICE,"Option C is set with : %s\n", opts[1] ? opts[1] : "<unspecified>");
88 /* Do our thing here */
93 int unload_module(void)
95 STANDARD_HANGUP_LOCALUSERS;
96 return ast_unregister_application(app);
101 return ast_register_application(app, app_exec, tdesc, synopsis);
104 char *description(void)
112 STANDARD_USECOUNT(res);
118 return ASTERISK_GPL_KEY;