Asterisk - The Open Source Telephony Project  18.5.0
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

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.

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

Referenced by ast_context_add_ignorepat2().

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 }
const char pattern[0]
Definition: pbx_ignorepat.c:39
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
const char * registrar
Definition: pbx_ignorepat.c:38
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37
static char * registrar
Definition: pbx_ael.c:78
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204

◆ ignorepat_free()

void ignorepat_free ( struct ast_ignorepat ip)

Definition at line 77 of file pbx_ignorepat.c.

References ast_free.

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

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

◆ 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.

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

Referenced by ast_context_add_include2().

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, ',')) ) {
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 }
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37
static struct test_val c
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
char stuff[0]
Definition: pbx_include.c:47
struct ast_timing timing
Definition: pbx_include.c:46
static char * registrar
Definition: pbx_ael.c:78
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
const char * name
Definition: pbx_include.c:38
int ast_build_timing(struct ast_timing *i, const char *info)
Construct a timing bitmap, for use in time-based conditionals.
Definition: extconf.c:3808
const char * rname
Definition: pbx_include.c:40
const char * registrar
Definition: pbx_include.c:42

◆ 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.

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().

107 {
108  ast_destroy_timing(&(inc->timing));
109  ast_free(inc);
110 }
struct ast_timing timing
Definition: pbx_include.c:46
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
Definition: pbx_timing.c:285
#define ast_free(a)
Definition: astmm.h:182

◆ include_rname()

const char* include_rname ( const struct ast_include inc)

Definition at line 55 of file pbx_include.c.

References NULL, and ast_include::rname.

Referenced by ast_context_verify_includes(), and pbx_find_extension().

56 {
57  return inc ? inc->rname : NULL;
58 }
#define NULL
Definition: resample.c:96
const char * rname
Definition: pbx_include.c:40

◆ include_valid()

int include_valid ( const struct ast_include inc)

Definition at line 65 of file pbx_include.c.

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

Referenced by pbx_find_extension().

66 {
67  if (!inc->hastime) {
68  return 1;
69  }
70 
71  return ast_check_timing(&(inc->timing));
72 }
struct ast_timing timing
Definition: pbx_include.c:46
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:4002

◆ 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.

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

Referenced by ast_check_timing(), and pbx_find_extension().

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

◆ 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.

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, ast_datastore::data, ast_exten::exten, NULL, pbx_exception::priority, and set_ext_pri().

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

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))) {
2816  ast_datastore_free(ds);
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 char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
Definition: stringfields.h:426
Structure for a data store object.
Definition: datastore.h:68
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:2404
#define NULL
Definition: resample.c:96
static int priority
int ast_channel_priority(const struct ast_channel *chan)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:68
const ast_string_field reason
Definition: pbx.c:625
int priority
Definition: pbx.c:627
static const struct ast_datastore_info exception_store_info
Definition: pbx.c:2790
const char * ast_channel_exten(const struct ast_channel *chan)
void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
Definition: pbx.c:4268
void * data
Definition: datastore.h:70
const char * ast_channel_context(const struct ast_channel *chan)
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:89
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2390
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

◆ 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 4268 of file pbx.c.

References ast_channel_exten_set(), ast_channel_lock, ast_channel_priority_set(), and ast_channel_unlock.

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

4269 {
4270  ast_channel_lock(c);
4272  ast_channel_priority_set(c, pri);
4273  ast_channel_unlock(c);
4274 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
#define ast_channel_unlock(chan)
Definition: channel.h:2946
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
void ast_channel_priority_set(struct ast_channel *chan, int value)

◆ 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.

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

Referenced by ast_context_add_switch2().

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 }
const char * name
Definition: pbx_sw.c:38
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
const char * registrar
Definition: pbx_sw.c:40
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37
const char * data
Definition: pbx_sw.c:42
char stuff[0]
Definition: pbx_sw.c:45
int eval
Definition: pbx_sw.c:43
static char * registrar
Definition: pbx_ael.c:78
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204

◆ sw_free()

void sw_free ( struct ast_sw sw)

Definition at line 101 of file pbx_sw.c.

References ast_free.

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

102 {
103  ast_free(sw);
104 }
#define ast_free(a)
Definition: astmm.h:182

◆ unreference_cached_app()

void unreference_cached_app ( struct ast_app app)

pbx.c function needed by pbx_app.c

Definition at line 6179 of file pbx.c.

References ast_rdlock_contexts(), ast_unlock_contexts(), ast_walk_context_extensions(), ast_walk_contexts(), ast_walk_extension_priorities(), and NULL.

Referenced by ast_unregister_application().

6180 {
6181  struct ast_context *context = NULL;
6182  struct ast_exten *eroot = NULL, *e = NULL;
6183 
6185  while ((context = ast_walk_contexts(context))) {
6186  while ((eroot = ast_walk_context_extensions(context, eroot))) {
6187  while ((e = ast_walk_extension_priorities(eroot, e))) {
6188  if (e->cached_app == app)
6189  e->cached_app = NULL;
6190  }
6191  }
6192  }
6194 
6195  return;
6196 }
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
Definition: pbx.c:237
struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: pbx.c:8609
#define NULL
Definition: resample.c:96
int ast_rdlock_contexts(void)
Read locks the context list.
Definition: pbx.c:8507
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
Definition: pbx.c:8614
int ast_unlock_contexts(void)
Unlocks contexts.
Definition: pbx.c:8512
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: pbx.c:8662
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284

◆ wait_for_hangup()

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

Definition at line 8267 of file pbx.c.

References ast_frfree, ast_read(), ast_safe_sleep(), ast_strlen_zero, and ast_waitfor().

Referenced by indicate_busy(), and indicate_congestion().

8268 {
8269  int res;
8270  struct ast_frame *f;
8271  double waitsec;
8272  int waittime;
8273 
8274  if (ast_strlen_zero(data) || (sscanf(data, "%30lg", &waitsec) != 1) || (waitsec < 0))
8275  waitsec = -1;
8276  if (waitsec > -1) {
8277  waittime = waitsec * 1000.0;
8278  ast_safe_sleep(chan, waittime);
8279  } else do {
8280  res = ast_waitfor(chan, -1);
8281  if (res < 0)
8282  return;
8283  f = ast_read(chan);
8284  if (f)
8285  ast_frfree(f);
8286  } while(f);
8287 }
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1574
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4302
#define ast_strlen_zero(foo)
Definition: strings.h:52
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3171
#define ast_frfree(fr)
Data structure associated with a single frame of data.
union ast_frame::@263 data