#include "asterisk.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/utils.h"
#include "asterisk/options.h"
#include "asterisk/app.h"
#include "asterisk/cli.h"
#include "asterisk/localtime.h"
#include "asterisk/say.h"

Go to the source code of this file.
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | load_module (void) |
| static int | playback_exec (struct ast_channel *chan, void *data) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Sound File Playback Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static char * | app = "Cycle" |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static int | counter = 0 |
| static char * | descrip = "\n" |
| static ast_mutex_t | lock |
| static char * | synopsis = "" |
Definition in file app_cycle.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 123 of file app_cycle.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 123 of file app_cycle.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 118 of file app_cycle.c.
References app, ast_register_application(), descrip, playback_exec(), and synopsis.
00119 { 00120 return ast_register_application(app, playback_exec, synopsis, descrip); 00121 }
| static int playback_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 37 of file app_cycle.c.
References ast_channel::_state, asprintf, ast_answer(), AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_module_user_add, ast_module_user_remove, ast_mutex_lock(), ast_mutex_unlock(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_waitstream(), counter, ast_channel::language, lock, LOG_ERROR, and pbx_builtin_setvar_helper().
Referenced by load_module().
00038 { 00039 int res = 0; 00040 struct ast_module_user *u; 00041 char *tmp; 00042 00043 ast_log(LOG_ERROR, "Cycle(%s)\n", (char*)data); 00044 00045 AST_DECLARE_APP_ARGS(args, 00046 AST_APP_ARG(fnprefix); 00047 AST_APP_ARG(maxnum); 00048 AST_APP_ARG(opts); 00049 ); 00050 00051 if (ast_strlen_zero(data)) { 00052 ast_log(LOG_ERROR, "Cycle requires 2 args: fnprefix and maxnum\n"); 00053 return -1; 00054 } 00055 00056 AST_STANDARD_APP_ARGS(args, data); 00057 00058 00059 if (args.fnprefix == NULL ) 00060 { 00061 ast_log(LOG_ERROR, "Cycle: fnprefix not set\n"); 00062 return -1; 00063 } 00064 00065 int maxnum = atoi(args.maxnum); 00066 00067 if (maxnum < 1) 00068 { 00069 ast_log(LOG_ERROR, "Cycle: maxnum must be integer >= 1, but set to '%d' ('%s')\n", maxnum, args.maxnum); 00070 return -1; 00071 } 00072 00073 tmp = ast_strdupa(data); 00074 u = ast_module_user_add(chan); 00075 00076 /* Answer if not answered before */ 00077 if (chan->_state != AST_STATE_UP) 00078 res = ast_answer(chan); 00079 if( res ) 00080 goto done; 00081 00082 if (!res) { 00083 char *str; /* filename for play */ 00084 char *cycle; /* CYCLE channel variable */ 00085 00086 ast_mutex_lock(&lock); 00087 { 00088 counter++; 00089 if (counter > maxnum) 00090 counter = 1; 00091 asprintf(&str, "%s%d", args.fnprefix, counter); 00092 asprintf(&cycle, "%d", counter); 00093 } 00094 ast_mutex_unlock(&lock); 00095 00096 ast_stopstream(chan); 00097 res = ast_streamfile(chan, str, chan->language); 00098 if (!res) { 00099 res = ast_waitstream(chan, ""); 00100 ast_stopstream(chan); 00101 } else 00102 res = 0; 00103 pbx_builtin_setvar_helper(chan, "CYCLE", cycle); 00104 } 00105 done: 00106 ast_module_user_remove(u); 00107 return res; 00108 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 110 of file app_cycle.c.
References app, ast_module_user_hangup_all, and ast_unregister_application().
00111 { 00112 int res; 00113 res = ast_unregister_application(app); 00114 ast_module_user_hangup_all(); 00115 return res; 00116 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Sound File Playback Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 123 of file app_cycle.c.
char* app = "Cycle" [static] |
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 123 of file app_cycle.c.
int counter = 0 [static] |
char* descrip = "\n" [static] |
ast_mutex_t lock [static] |
Definition at line 35 of file app_cycle.c.
char* synopsis = "" [static] |
1.5.9