Asterisk - The Open Source Telephony Project GIT-master-a358458
Macros | Functions
pbx_private.h File Reference

Private include file for pbx. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VAR_BUF_SIZE   4096
 

Functions

const char * app_name (struct ast_app *app)
 
 AST_VECTOR (ast_ignorepats, struct ast_ignorepat *)
 
 AST_VECTOR (ast_includes, struct ast_include *)
 
 AST_VECTOR (ast_sws, struct ast_sw *)
 
struct ast_ignorepatignorepat_alloc (const char *value, const char *registrar)
 
void ignorepat_free (struct ast_ignorepat *ip)
 
struct ast_includeinclude_alloc (const char *value, const char *registrar)
 
void include_free (struct ast_include *inc)
 
const char * include_rname (const struct ast_include *inc)
 
int include_valid (const struct ast_include *inc)
 
int indicate_busy (struct ast_channel *, const char *)
 
int indicate_congestion (struct ast_channel *, const char *)
 
struct ast_switchpbx_findswitch (const char *sw)
 
int raise_exception (struct ast_channel *chan, const char *reason, int priority)
 
void set_ext_pri (struct ast_channel *c, const char *exten, int pri)
 
struct ast_swsw_alloc (const char *value, const char *data, int eval, const char *registrar)
 
void sw_free (struct ast_sw *sw)
 
void unreference_cached_app (struct ast_app *app)
 
void wait_for_hangup (struct ast_channel *chan, const void *data)
 

Detailed Description

Private include file for pbx.

Definition in file pbx_private.h.

Macro Definition Documentation

◆ VAR_BUF_SIZE

#define VAR_BUF_SIZE   4096

Definition at line 68 of file pbx_private.h.

Function Documentation

◆ app_name()

const char * app_name ( struct ast_app app)

◆ AST_VECTOR() [1/3]

AST_VECTOR ( ast_ignorepats  ,
struct ast_ignorepat  
)

◆ AST_VECTOR() [2/3]

AST_VECTOR ( ast_includes  ,
struct ast_include  
)

◆ AST_VECTOR() [3/3]

AST_VECTOR ( ast_sws  ,
struct ast_sw  
)

◆ ignorepat_alloc()

struct ast_ignorepat * ignorepat_alloc ( const char *  value,
const char *  registrar 
)

Definition at line 52 of file pbx_ignorepat.c.

53{
54 struct ast_ignorepat *ignorepat;
55 int length = strlen(value) + 1;
56 char *pattern;
57
58 /* allocate new include structure ... */
59 ignorepat = ast_calloc(1, sizeof(*ignorepat) + length);
60 if (!ignorepat) {
61 return NULL;
62 }
63
64 /* The cast to char * is because we need to write the initial value.
65 * The field is not supposed to be modified otherwise. Also, gcc 4.2
66 * sees the cast as dereferencing a type-punned pointer and warns about
67 * it. This is the workaround (we're telling gcc, yes, that's really
68 * what we wanted to do).
69 */
70 pattern = (char *) ignorepat->pattern;
71 strcpy(pattern, value);
72 ignorepat->registrar = registrar;
73
74 return ignorepat;
75}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
static char * registrar
Definition: pbx_ael.c:78
#define NULL
Definition: resample.c:96
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37
const char pattern[0]
Definition: pbx_ignorepat.c:39
const char * registrar
Definition: pbx_ignorepat.c:38
int value
Definition: syslog.c:37

References ast_calloc, NULL, ast_ignorepat::pattern, ast_ignorepat::registrar, registrar, and value.

Referenced by ast_context_add_ignorepat2().

◆ ignorepat_free()

void ignorepat_free ( struct ast_ignorepat ip)

Definition at line 77 of file pbx_ignorepat.c.

78{
79 ast_free(ip);
80}
#define ast_free(a)
Definition: astmm.h:180

References ast_free.

Referenced by __ast_context_destroy(), __ast_internal_context_destroy(), ast_context_add_ignorepat2(), and ast_context_remove_ignorepat2().

◆ include_alloc()

struct ast_include * include_alloc ( const char *  value,
const char *  registrar 
)

Allocate and initialize an ast_include.

Definition at line 74 of file pbx_include.c.

75{
76 struct ast_include *new_include;
77 char *c;
78 int valuebufsz = strlen(value) + 1;
79 char *p;
80
81 /* allocate new include structure ... */
82 new_include = ast_calloc(1, sizeof(*new_include) + (valuebufsz * 2));
83 if (!new_include) {
84 return NULL;
85 }
86
87 /* Fill in this structure. Use 'p' for assignments, as the fields
88 * in the structure are 'const char *'
89 */
90 p = new_include->stuff;
91 new_include->name = p;
92 strcpy(p, value);
93 p += valuebufsz;
94 new_include->rname = p;
95 strcpy(p, value);
96 /* Strip off timing info, and process if it is there */
97 if ( (c = strchr(p, '|')) || (c = strchr(p, ',')) ) {
98 *c++ = '\0';
99 new_include->hastime = ast_build_timing(&(new_include->timing), c);
100 }
101 new_include->registrar = registrar;
102
103 return new_include;
104}
int ast_build_timing(struct ast_timing *i, const char *info_in)
Construct a timing bitmap, for use in time-based conditionals.
Definition: extconf.c:3806
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
struct ast_timing timing
Definition: pbx_include.c:46
const char * rname
Definition: pbx_include.c:40
char stuff[0]
Definition: pbx_include.c:47
const char * registrar
Definition: pbx_include.c:42
const char * name
Definition: pbx_include.c:38
static struct test_val c

References ast_build_timing(), ast_calloc, c, ast_include::hastime, ast_include::name, NULL, ast_include::registrar, registrar, ast_include::rname, ast_include::stuff, ast_include::timing, and value.

Referenced by ast_context_add_include2().

◆ include_free()

void include_free ( struct ast_include inc)

Free an ast_include and associated data.

Definition at line 106 of file pbx_include.c.

107{
108 ast_destroy_timing(&(inc->timing));
109 ast_free(inc);
110}
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
Definition: pbx_timing.c:279

References ast_destroy_timing(), ast_free, and ast_include::timing.

Referenced by __ast_context_destroy(), __ast_internal_context_destroy(), ast_context_add_include2(), and ast_context_remove_include2().

◆ include_rname()

const char * include_rname ( const struct ast_include inc)

Definition at line 55 of file pbx_include.c.

56{
57 return inc ? inc->rname : NULL;
58}

References NULL, and ast_include::rname.

Referenced by ast_context_verify_includes(), and pbx_find_extension().

◆ include_valid()

int include_valid ( const struct ast_include inc)

Definition at line 65 of file pbx_include.c.

66{
67 if (!inc->hastime) {
68 return 1;
69 }
70
71 return ast_check_timing(&(inc->timing));
72}
int ast_check_timing(const struct ast_timing *i)
Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified.
Definition: extconf.c:4000

References ast_check_timing(), ast_include::hastime, and ast_include::timing.

Referenced by pbx_find_extension().

◆ pbx_findswitch()

struct ast_switch * pbx_findswitch ( const char *  sw)

pbx_switch.c functions needed by pbx.c

Definition at line 40 of file pbx_switch.c.

41{
42 struct ast_switch *asw;
43
46 if (!strcasecmp(asw->name, sw))
47 break;
48 }
50
51 return asw;
52}
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:494
struct ast_switch::@241 list
const char * name
Definition: pbx.h:162

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_switch::list, and ast_switch::name.

Referenced by pbx_find_extension().

◆ raise_exception()

int raise_exception ( struct ast_channel chan,
const char *  reason,
int  priority 
)

pbx.c functions needed by pbx_builtins.c

Definition at line 2806 of file pbx.c.

2807{
2809 struct pbx_exception *exception = NULL;
2810
2811 if (!ds) {
2813 if (!ds)
2814 return -1;
2815 if (!(exception = ast_calloc_with_stringfields(1, struct pbx_exception, 128))) {
2817 return -1;
2818 }
2819 ds->data = exception;
2820 ast_channel_datastore_add(chan, ds);
2821 } else
2822 exception = ds->data;
2823
2824 ast_string_field_set(exception, reason, reason);
2826 ast_string_field_set(exception, exten, ast_channel_exten(chan));
2827 exception->priority = ast_channel_priority(chan);
2828 set_ext_pri(chan, "e", priority);
2829 return 0;
2830}
static int priority
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2385
int ast_channel_priority(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_exten(const struct ast_channel *chan)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2399
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:85
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:68
static const struct ast_datastore_info exception_store_info
Definition: pbx.c:2790
void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
Definition: pbx.c:4264
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
Definition: stringfields.h:432
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
Structure for a data store object.
Definition: datastore.h:64
void * data
Definition: datastore.h:66
const ast_string_field exten
Definition: pbx.c:630
int priority
Definition: pbx.c:632
const ast_string_field reason
Definition: pbx.c:630

References ast_calloc_with_stringfields, ast_channel_context(), ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_exten(), ast_channel_priority(), ast_datastore_alloc, ast_datastore_free(), ast_string_field_set, voicemailpwcheck::context, ast_datastore::data, exception_store_info, pbx_exception::exten, NULL, priority, pbx_exception::priority, pbx_exception::reason, and set_ext_pri().

Referenced by __ast_pbx_run(), pbx_builtin_raise_exception(), and pbx_builtin_waitexten().

◆ set_ext_pri()

void set_ext_pri ( struct ast_channel c,
const char *  exten,
int  pri 
)

helper function to set extension and priority

Definition at line 4264 of file pbx.c.

4265{
4267 ast_channel_exten_set(c, exten);
4270}
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
#define ast_channel_lock(chan)
Definition: channel.h:2922
void ast_channel_priority_set(struct ast_channel *chan, int value)
#define ast_channel_unlock(chan)
Definition: channel.h:2923

References ast_channel_exten_set(), ast_channel_lock, ast_channel_priority_set(), ast_channel_unlock, c, and ast_exten::exten.

Referenced by __ast_pbx_run(), pbx_builtin_waitexten(), and raise_exception().

◆ sw_alloc()

struct ast_sw * sw_alloc ( const char *  value,
const char *  data,
int  eval,
const char *  registrar 
)

Definition at line 68 of file pbx_sw.c.

69{
70 struct ast_sw *new_sw;
71 int length;
72 char *p;
73
74 if (!data) {
75 data = "";
76 }
77 length = sizeof(struct ast_sw);
78 length += strlen(value) + 1;
79 length += strlen(data) + 1;
80
81 /* allocate new sw structure ... */
82 if (!(new_sw = ast_calloc(1, length))) {
83 return NULL;
84 }
85
86 /* ... fill in this structure ... */
87 p = new_sw->stuff;
88 new_sw->name = p;
89 strcpy(p, value);
90
91 p += strlen(value) + 1;
92 new_sw->data = p;
93 strcpy(p, data);
94
95 new_sw->eval = eval;
96 new_sw->registrar = registrar;
97
98 return new_sw;
99}
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37
char stuff[0]
Definition: pbx_sw.c:45
int eval
Definition: pbx_sw.c:43
const char * registrar
Definition: pbx_sw.c:40
const char * data
Definition: pbx_sw.c:42
const char * name
Definition: pbx_sw.c:38

References ast_calloc, ast_sw::data, ast_sw::eval, ast_sw::name, NULL, ast_sw::registrar, registrar, ast_sw::stuff, and value.

Referenced by ast_context_add_switch2().

◆ sw_free()

void sw_free ( struct ast_sw sw)

Definition at line 101 of file pbx_sw.c.

102{
103 ast_free(sw);
104}

References ast_free.

Referenced by __ast_context_destroy(), __ast_internal_context_destroy(), ast_context_add_switch2(), and ast_context_remove_switch2().

◆ unreference_cached_app()

void unreference_cached_app ( struct ast_app app)

pbx.c function needed by pbx_app.c

Definition at line 6130 of file pbx.c.

6131{
6132 struct ast_context *context = NULL;
6133 struct ast_exten *eroot = NULL, *e = NULL;
6134
6136 while ((context = ast_walk_contexts(context))) {
6137 while ((eroot = ast_walk_context_extensions(context, eroot))) {
6138 while ((e = ast_walk_extension_priorities(eroot, e))) {
6139 if (e->cached_app == app)
6140 e->cached_app = NULL;
6141 }
6142 }
6143 }
6145
6146 return;
6147}
struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: pbx.c:8591
int ast_rdlock_contexts(void)
Read locks the context list.
Definition: pbx.c:8468
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: pbx.c:8644
int ast_unlock_contexts(void)
Unlocks contexts.
Definition: pbx.c:8473
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
Definition: pbx.c:8596
ast_context: An extension context
Definition: pbx.c:284
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
Definition: pbx.c:237

References app, ast_rdlock_contexts(), ast_unlock_contexts(), ast_walk_context_extensions(), ast_walk_contexts(), ast_walk_extension_priorities(), voicemailpwcheck::context, and NULL.

Referenced by ast_unregister_application().

◆ wait_for_hangup()

void wait_for_hangup ( struct ast_channel chan,
const void *  data 
)

Definition at line 8228 of file pbx.c.

8229{
8230 int res;
8231 struct ast_frame *f;
8232 double waitsec;
8233 int waittime;
8234
8235 if (ast_strlen_zero(data) || (sscanf(data, "%30lg", &waitsec) != 1) || (waitsec < 0))
8236 waitsec = -1;
8237 if (waitsec > -1) {
8238 waittime = waitsec * 1000.0;
8239 ast_safe_sleep_without_silence(chan, waittime);
8240 } else do {
8241 res = ast_waitfor(chan, -1);
8242 if (res < 0)
8243 return;
8244 f = ast_read(chan);
8245 if (f)
8246 ast_frfree(f);
8247 } while(f);
8248}
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3162
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups, and do not generate silence.
Definition: channel.c:1579
#define ast_frfree(fr)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Data structure associated with a single frame of data.
union ast_frame::@226 data

References ast_frfree, ast_read(), ast_safe_sleep_without_silence(), ast_strlen_zero(), ast_waitfor(), and ast_frame::data.

Referenced by indicate_busy(), and indicate_congestion().