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 #include "asterisk.h"
00037
00038 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 200656 $")
00039
00040 #include "asterisk/file.h"
00041 #include "asterisk/channel.h"
00042 #include "asterisk/pbx.h"
00043 #include "asterisk/module.h"
00044 #include "asterisk/lock.h"
00045 #include "asterisk/app.h"
00046
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 static char *app = "Skel";
00076
00077 enum option_flags {
00078 OPTION_A = (1 << 0),
00079 OPTION_B = (1 << 1),
00080 OPTION_C = (1 << 2),
00081 };
00082
00083 enum option_args {
00084 OPTION_ARG_B = 0,
00085 OPTION_ARG_C = 1,
00086
00087 OPTION_ARG_ARRAY_SIZE = 2,
00088 };
00089
00090 AST_APP_OPTIONS(app_opts,{
00091 AST_APP_OPTION('a', OPTION_A),
00092 AST_APP_OPTION_ARG('b', OPTION_B, OPTION_ARG_B),
00093 AST_APP_OPTION_ARG('c', OPTION_C, OPTION_ARG_C),
00094 });
00095
00096
00097 static int app_exec(struct ast_channel *chan, const char *data)
00098 {
00099 int res = 0;
00100 struct ast_flags flags;
00101 char *parse, *opts[OPTION_ARG_ARRAY_SIZE];
00102 AST_DECLARE_APP_ARGS(args,
00103 AST_APP_ARG(dummy);
00104 AST_APP_ARG(options);
00105 );
00106
00107 if (ast_strlen_zero(data)) {
00108 ast_log(LOG_WARNING, "%s requires an argument (dummy[,options])\n", app);
00109 return -1;
00110 }
00111
00112
00113
00114
00115 parse = ast_strdupa(data);
00116
00117 AST_STANDARD_APP_ARGS(args, parse);
00118
00119 if (args.argc == 2) {
00120 ast_app_parse_options(app_opts, &flags, opts, args.options);
00121 }
00122
00123 if (!ast_strlen_zero(args.dummy)) {
00124 ast_log(LOG_NOTICE, "Dummy value is : %s\n", args.dummy);
00125 }
00126
00127 if (ast_test_flag(&flags, OPTION_A)) {
00128 ast_log(LOG_NOTICE, "Option A is set\n");
00129 }
00130
00131 if (ast_test_flag(&flags, OPTION_B)) {
00132 ast_log(LOG_NOTICE, "Option B is set with : %s\n", opts[OPTION_ARG_B] ? opts[OPTION_ARG_B] : "<unspecified>");
00133 }
00134
00135 if (ast_test_flag(&flags, OPTION_C)) {
00136 ast_log(LOG_NOTICE, "Option C is set with : %s\n", opts[OPTION_ARG_C] ? opts[OPTION_ARG_C] : "<unspecified>");
00137 }
00138
00139 return res;
00140 }
00141
00142 static int unload_module(void)
00143 {
00144 return ast_unregister_application(app);
00145 }
00146
00147 static int load_module(void)
00148 {
00149 return ast_register_application_xml(app, app_exec) ?
00150 AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
00151 }
00152
00153 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Skeleton (sample) Application");