00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "asterisk.h"
00038
00039 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328209 $")
00040
00041 #include "asterisk/file.h"
00042 #include "asterisk/channel.h"
00043 #include "asterisk/pbx.h"
00044 #include "asterisk/module.h"
00045 #include "asterisk/lock.h"
00046 #include "asterisk/app.h"
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 static char *app = "Skel";
00077
00078 enum option_flags {
00079 OPTION_A = (1 << 0),
00080 OPTION_B = (1 << 1),
00081 OPTION_C = (1 << 2),
00082 };
00083
00084 enum option_args {
00085 OPTION_ARG_B = 0,
00086 OPTION_ARG_C = 1,
00087
00088 OPTION_ARG_ARRAY_SIZE = 2,
00089 };
00090
00091 AST_APP_OPTIONS(app_opts,{
00092 AST_APP_OPTION('a', OPTION_A),
00093 AST_APP_OPTION_ARG('b', OPTION_B, OPTION_ARG_B),
00094 AST_APP_OPTION_ARG('c', OPTION_C, OPTION_ARG_C),
00095 });
00096
00097
00098 static int app_exec(struct ast_channel *chan, const char *data)
00099 {
00100 int res = 0;
00101 struct ast_flags flags;
00102 char *parse, *opts[OPTION_ARG_ARRAY_SIZE];
00103 AST_DECLARE_APP_ARGS(args,
00104 AST_APP_ARG(dummy);
00105 AST_APP_ARG(options);
00106 );
00107
00108 if (ast_strlen_zero(data)) {
00109 ast_log(LOG_WARNING, "%s requires an argument (dummy[,options])\n", app);
00110 return -1;
00111 }
00112
00113
00114
00115
00116 parse = ast_strdupa(data);
00117
00118 AST_STANDARD_APP_ARGS(args, parse);
00119
00120 if (args.argc == 2) {
00121 ast_app_parse_options(app_opts, &flags, opts, args.options);
00122 }
00123
00124 if (!ast_strlen_zero(args.dummy)) {
00125 ast_log(LOG_NOTICE, "Dummy value is : %s\n", args.dummy);
00126 }
00127
00128 if (ast_test_flag(&flags, OPTION_A)) {
00129 ast_log(LOG_NOTICE, "Option A is set\n");
00130 }
00131
00132 if (ast_test_flag(&flags, OPTION_B)) {
00133 ast_log(LOG_NOTICE, "Option B is set with : %s\n", opts[OPTION_ARG_B] ? opts[OPTION_ARG_B] : "<unspecified>");
00134 }
00135
00136 if (ast_test_flag(&flags, OPTION_C)) {
00137 ast_log(LOG_NOTICE, "Option C is set with : %s\n", opts[OPTION_ARG_C] ? opts[OPTION_ARG_C] : "<unspecified>");
00138 }
00139
00140 return res;
00141 }
00142
00143 static int unload_module(void)
00144 {
00145 return ast_unregister_application(app);
00146 }
00147
00148 static int load_module(void)
00149 {
00150 return ast_register_application_xml(app, app_exec) ?
00151 AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
00152 }
00153
00154 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Skeleton (sample) Application");