2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) <Year>, <Your Name Here>
6 * <Your Name Here> <<Your Email Here>>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief Skeleton application
23 * \author <Your Name Here> <<Your Email Here>>
25 * This is a skeleton for development of an Asterisk application
26 * \ingroup applications
30 <defaultenabled>no</defaultenabled>
35 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
42 #include "asterisk/file.h"
43 #include "asterisk/logger.h"
44 #include "asterisk/channel.h"
45 #include "asterisk/pbx.h"
46 #include "asterisk/module.h"
47 #include "asterisk/lock.h"
48 #include "asterisk/app.h"
50 static char *app
= "Skel";
51 static char *synopsis
=
52 "Skeleton application.";
53 static char *descrip
= "This application is a template to build other applications from.\n"
54 " It shows you the basic structure to create your own Asterisk applications.\n";
65 /* This *must* be the last value in this enum! */
66 OPTION_ARG_ARRAY_SIZE
= 2,
69 AST_APP_OPTIONS(app_opts
,{
70 AST_APP_OPTION('a', OPTION_A
),
71 AST_APP_OPTION_ARG('b', OPTION_B
, OPTION_ARG_B
),
72 AST_APP_OPTION_ARG('c', OPTION_C
, OPTION_ARG_C
),
76 static int app_exec(struct ast_channel
*chan
, void *data
)
79 struct ast_flags flags
;
80 struct ast_module_user
*u
;
81 char *parse
, *opts
[OPTION_ARG_ARRAY_SIZE
];
82 AST_DECLARE_APP_ARGS(args
,
87 if (ast_strlen_zero(data
)) {
88 ast_log(LOG_WARNING
, "%s requires an argument (dummy|[options])\n", app
);
92 u
= ast_module_user_add(chan
);
94 /* Do our thing here */
96 /* We need to make a copy of the input string if we are going to modify it! */
97 parse
= ast_strdupa(data
);
99 AST_STANDARD_APP_ARGS(args
, parse
);
102 ast_app_parse_options(app_opts
, &flags
, opts
, args
.options
);
104 if (!ast_strlen_zero(args
.dummy
))
105 ast_log(LOG_NOTICE
, "Dummy value is : %s\n", args
.dummy
);
107 if (ast_test_flag(&flags
, OPTION_A
))
108 ast_log(LOG_NOTICE
, "Option A is set\n");
110 if (ast_test_flag(&flags
, OPTION_B
))
111 ast_log(LOG_NOTICE
, "Option B is set with : %s\n", opts
[OPTION_ARG_B
] ? opts
[OPTION_ARG_B
] : "<unspecified>");
113 if (ast_test_flag(&flags
, OPTION_C
))
114 ast_log(LOG_NOTICE
, "Option C is set with : %s\n", opts
[OPTION_ARG_C
] ? opts
[OPTION_ARG_C
] : "<unspecified>");
116 ast_module_user_remove(u
);
121 static int unload_module(void)
124 res
= ast_unregister_application(app
);
128 static int load_module(void)
130 return ast_register_application(app
, app_exec
, synopsis
, descrip
);
133 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Skeleton (sample) Application");