#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/lock.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 | unload_module (void) |
static int | waitforring_exec (struct ast_channel *chan, void *data) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Waits until first ring after time" , .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 = "6989f2ec67f8497e38c12890500c525b" , .load = load_module, .unload = unload_module, } |
static char * | app = "WaitForRing" |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static char * | desc |
static char * | synopsis = "Wait for Ring Application" |
Definition in file app_waitforring.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 136 of file app_waitforring.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 136 of file app_waitforring.c.
static int load_module | ( | void | ) | [static] |
Definition at line 131 of file app_waitforring.c.
References ast_register_application(), and waitforring_exec().
00132 { 00133 return ast_register_application(app, waitforring_exec, synopsis, desc); 00134 }
static int unload_module | ( | void | ) | [static] |
Definition at line 120 of file app_waitforring.c.
References ast_module_user_hangup_all, and ast_unregister_application().
00121 { 00122 int res; 00123 00124 res = ast_unregister_application(app); 00125 00126 ast_module_user_hangup_all(); 00127 00128 return res; 00129 }
static int waitforring_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 56 of file app_waitforring.c.
References AST_CONTROL_RING, AST_FRAME_CONTROL, ast_frfree, ast_log(), ast_module_user_add, ast_module_user_remove, ast_read(), ast_verbose(), ast_waitfor(), f, LOG_WARNING, option_verbose, and VERBOSE_PREFIX_3.
Referenced by load_module().
00057 { 00058 struct ast_module_user *u; 00059 struct ast_frame *f; 00060 int res = 0; 00061 int ms; 00062 00063 if (!data || (sscanf(data, "%30d", &ms) != 1)) { 00064 ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n"); 00065 return 0; 00066 } 00067 00068 u = ast_module_user_add(chan); 00069 00070 ms *= 1000; 00071 while(ms > 0) { 00072 ms = ast_waitfor(chan, ms); 00073 if (ms < 0) { 00074 res = ms; 00075 break; 00076 } 00077 if (ms > 0) { 00078 f = ast_read(chan); 00079 if (!f) { 00080 res = -1; 00081 break; 00082 } 00083 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { 00084 if (option_verbose > 2) 00085 ast_verbose(VERBOSE_PREFIX_3 "Got a ring but still waiting for timeout\n"); 00086 } 00087 ast_frfree(f); 00088 } 00089 } 00090 /* Now we're really ready for the ring */ 00091 if (!res) { 00092 ms = 99999999; 00093 while(ms > 0) { 00094 ms = ast_waitfor(chan, ms); 00095 if (ms < 0) { 00096 res = ms; 00097 break; 00098 } 00099 if (ms > 0) { 00100 f = ast_read(chan); 00101 if (!f) { 00102 res = -1; 00103 break; 00104 } 00105 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { 00106 if (option_verbose > 2) 00107 ast_verbose(VERBOSE_PREFIX_3 "Got a ring after the timeout\n"); 00108 ast_frfree(f); 00109 break; 00110 } 00111 ast_frfree(f); 00112 } 00113 } 00114 } 00115 ast_module_user_remove(u); 00116 00117 return res; 00118 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Waits until first ring after time" , .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 = "6989f2ec67f8497e38c12890500c525b" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 136 of file app_waitforring.c.
char* app = "WaitForRing" [static] |
Definition at line 53 of file app_waitforring.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 136 of file app_waitforring.c.
char* desc [static] |
Initial value:
" WaitForRing(timeout)\n" "Returns 0 after waiting at least timeout seconds. and\n" "only after the next ring has completed. Returns 0 on\n" "success or -1 on hangup\n"
Definition at line 48 of file app_waitforring.c.
char* synopsis = "Wait for Ring Application" [static] |
Definition at line 46 of file app_waitforring.c.