Fri Jun 19 12:10:05 2009

Asterisk developer's documentation


app_waitforring.c File Reference

Wait for Ring Application. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.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 , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, }
static char * app = "WaitForRing"
static struct ast_module_infoast_module_info = &__mod_info
static char * desc
static char * synopsis = "Wait for Ring Application"


Detailed Description

Wait for Ring Application.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_waitforring.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 117 of file app_waitforring.c.

static void __unreg_module ( void   )  [static]

Definition at line 117 of file app_waitforring.c.

static int load_module ( void   )  [static]

Definition at line 112 of file app_waitforring.c.

References ast_register_application, and waitforring_exec().

00113 {
00114    return ast_register_application(app, waitforring_exec, synopsis, desc);
00115 }

static int unload_module ( void   )  [static]

Definition at line 107 of file app_waitforring.c.

References ast_unregister_application().

00108 {
00109    return ast_unregister_application(app);
00110 }

static int waitforring_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 48 of file app_waitforring.c.

References AST_CONTROL_RING, AST_FRAME_CONTROL, ast_frfree, ast_log(), ast_read(), ast_verb, ast_waitfor(), chan, f, LOG_WARNING, and s.

Referenced by load_module().

00049 {
00050    struct ast_frame *f;
00051    int res = 0;
00052    double s;
00053    int ms;
00054 
00055    if (!data || (sscanf(data, "%lg", &s) != 1)) {
00056       ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n");
00057       return 0;
00058    }
00059 
00060    ms = s * 1000.0;
00061    while (ms > 0) {
00062       ms = ast_waitfor(chan, ms);
00063       if (ms < 0) {
00064          res = ms;
00065          break;
00066       }
00067       if (ms > 0) {
00068          f = ast_read(chan);
00069          if (!f) {
00070             res = -1;
00071             break;
00072          }
00073          if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) {
00074             ast_verb(3, "Got a ring but still waiting for timeout\n");
00075          }
00076          ast_frfree(f);
00077       }
00078    }
00079    /* Now we're really ready for the ring */
00080    if (!res) {
00081       ms = 99999999;
00082       while(ms > 0) {
00083          ms = ast_waitfor(chan, ms);
00084          if (ms < 0) {
00085             res = ms;
00086             break;
00087          }
00088          if (ms > 0) {
00089             f = ast_read(chan);
00090             if (!f) {
00091                res = -1;
00092                break;
00093             }
00094             if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) {
00095                ast_verb(3, "Got a ring after the timeout\n");
00096                ast_frfree(f);
00097                break;
00098             }
00099             ast_frfree(f);
00100          }
00101       }
00102    }
00103 
00104    return res;
00105 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static]

Definition at line 117 of file app_waitforring.c.

char* app = "WaitForRing" [static]

Definition at line 45 of file app_waitforring.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 117 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 40 of file app_waitforring.c.

char* synopsis = "Wait for Ring Application" [static]

Definition at line 38 of file app_waitforring.c.


Generated on Fri Jun 19 12:10:05 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7