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\verbatim <Your Name Here> <<Your Email Here>> \endverbatim
25 * This is a skeleton for development of an Asterisk application
26 * \ingroup applications
30 <defaultenabled>no</defaultenabled>
35 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
37 #include "asterisk/file.h"
38 #include "asterisk/channel.h"
39 #include "asterisk/pbx.h"
40 #include "asterisk/module.h"
41 #include "asterisk/lock.h"
42 #include "asterisk/app.h"
44 static char *app
= "Skel";
45 static char *synopsis
=
46 "Skeleton application.";
47 static char *descrip
= "This application is a template to build other applications from.\n"
48 " It shows you the basic structure to create your own Asterisk applications.\n";
59 /* This *must* be the last value in this enum! */
60 OPTION_ARG_ARRAY_SIZE
= 2,
63 AST_APP_OPTIONS(app_opts
,{
64 AST_APP_OPTION('a', OPTION_A
),
65 AST_APP_OPTION_ARG('b', OPTION_B
, OPTION_ARG_B
),
66 AST_APP_OPTION_ARG('c', OPTION_C
, OPTION_ARG_C
),
70 static int app_exec(struct ast_channel
*chan
, void *data
)
73 struct ast_flags flags
;
74 char *parse
, *opts
[OPTION_ARG_ARRAY_SIZE
];
75 AST_DECLARE_APP_ARGS(args
,
80 if (ast_strlen_zero(data
)) {
81 ast_log(LOG_WARNING
, "%s requires an argument (dummy[,options])\n", app
);
85 /* Do our thing here */
87 /* We need to make a copy of the input string if we are going to modify it! */
88 parse
= ast_strdupa(data
);
90 AST_STANDARD_APP_ARGS(args
, parse
);
93 ast_app_parse_options(app_opts
, &flags
, opts
, args
.options
);
95 if (!ast_strlen_zero(args
.dummy
))
96 ast_log(LOG_NOTICE
, "Dummy value is : %s\n", args
.dummy
);
98 if (ast_test_flag(&flags
, OPTION_A
))
99 ast_log(LOG_NOTICE
, "Option A is set\n");
101 if (ast_test_flag(&flags
, OPTION_B
))
102 ast_log(LOG_NOTICE
, "Option B is set with : %s\n", opts
[OPTION_ARG_B
] ? opts
[OPTION_ARG_B
] : "<unspecified>");
104 if (ast_test_flag(&flags
, OPTION_C
))
105 ast_log(LOG_NOTICE
, "Option C is set with : %s\n", opts
[OPTION_ARG_C
] ? opts
[OPTION_ARG_C
] : "<unspecified>");
110 static int unload_module(void)
112 return ast_unregister_application(app
);
115 static int load_module(void)
117 return ast_register_application(app
, app_exec
, synopsis
, descrip
) ?
118 AST_MODULE_LOAD_DECLINE
: AST_MODULE_LOAD_SUCCESS
;
121 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Skeleton (sample) Application");