/* * oslec - Oslec Helper * Version 1.0 * * Copyright (c) 2007 Rowetel * * David Rowe * * Generated using Justin Tunney's mod generator, Thank you Justin! * * This program is free software, distributed under the terms of * the GNU General Public License version 2.0. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include static char *moddesc = "Oslec Helper"; STANDARD_LOCAL_USER; LOCAL_USER_DECL; static char *oslec_app = "oslec"; static char *oslec_synopsis = "Allows to invoke certain shell commands based on provided arguments"; static char *oslec_descrip = "" "oslec(options)\n" "\n" "Description:\n" " Oslec helper. More to be added later\n" "\n" "Options:\n" " R(...) - Recording\n" " N(...) - CNG toggle\n" ; #define OPT_OSLEC_RECORD (1 << 0) #define OPT_OSLEC_CNG (1 << 1) enum { OPT_ARG_OSLEC_RECORD = 0, OPT_ARG_OSLEC_CNG, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_OSLEC_ARRAY_SIZE } oslec_option_args; AST_APP_OPTIONS(oslec_options, { AST_APP_OPTION_ARG('R', OPT_OSLEC_RECORD, OPT_ARG_OSLEC_RECORD), AST_APP_OPTION_ARG('N', OPT_OSLEC_CNG, OPT_ARG_OSLEC_CNG), }); struct oslec_ops { int options; char *record; char *cng; }; /* * Put your application code in here! * * Returns: * -1 - error or hangup * 0 - success */ static int oslec_main(struct ast_channel *chan, struct oslec_ops *ops) { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Recording argument is %s and CNG flag is %s \n", ops->record, ops->cng); if (ops->record) //your system command here with ops->record as number of secs return 0; } static int oslec(struct ast_channel *chan, struct oslec_ops *ops) { int rc; struct localuser *u; LOCAL_USER_ADD(u); rc = oslec_main(chan, ops); LOCAL_USER_REMOVE(u); return rc; } static int oslec_app_exec(struct ast_channel *chan, void *data) { AST_DECLARE_APP_ARGS(args, AST_APP_ARG(options); ); char *parse; struct oslec_ops ops; struct ast_flags opts = { 0, }; char *opt_args[OPT_ARG_OSLEC_ARRAY_SIZE]; memset(&ops, 0, sizeof(ops)); if (!ast_strlen_zero(data)) { parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_app_parse_options(oslec_options, &opts, opt_args, args.options)) return -1; if (ast_test_flag(&opts, OPT_OSLEC_RECORD) && !ast_strlen_zero(opt_args[OPT_ARG_OSLEC_RECORD])) { ops.options |= OPT_OSLEC_RECORD; ops.record = opt_args[OPT_ARG_OSLEC_RECORD]; } if (ast_test_flag(&opts, OPT_OSLEC_CNG) && !ast_strlen_zero(opt_args[OPT_ARG_OSLEC_CNG])) { ops.options |= OPT_OSLEC_CNG; ops.cng = opt_args[OPT_ARG_OSLEC_CNG]; } } return oslec(chan, &ops); } int load_module(void) { return ast_register_application(oslec_app, oslec_app_exec, oslec_synopsis, oslec_descrip); } int unload_module(void) { int res; res = ast_unregister_application(oslec_app); STANDARD_HANGUP_LOCALUSERS; return res; } int reload(void) { return 0; } char *description(void) { return moddesc; } int usecount(void) { int res; STANDARD_USECOUNT(res); return res; } char *key() { return ASTERISK_GPL_KEY; }