Asterisk - The Open Source Telephony Project  GIT-master-a24979a
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.

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

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

◆ 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_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 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:4001

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::@269 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 2813 of file pbx.c.

2814 {
2816  struct pbx_exception *exception = NULL;
2817 
2818  if (!ds) {
2820  if (!ds)
2821  return -1;
2822  if (!(exception = ast_calloc_with_stringfields(1, struct pbx_exception, 128))) {
2823  ast_datastore_free(ds);
2824  return -1;
2825  }
2826  ds->data = exception;
2827  ast_channel_datastore_add(chan, ds);
2828  } else
2829  exception = ds->data;
2830 
2831  ast_string_field_set(exception, reason, reason);
2833  ast_string_field_set(exception, exten, ast_channel_exten(chan));
2834  exception->priority = ast_channel_priority(chan);
2835  set_ext_pri(chan, "e", priority);
2836  return 0;
2837 }
static int priority
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:122
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2384
const char * ast_channel_context(const struct ast_channel *chan)
int ast_channel_priority(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:2398
#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:2797
void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
Definition: pbx.c:4271
#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
int priority
Definition: pbx.c:625
const ast_string_field reason
Definition: pbx.c:623

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

Referenced by 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 4271 of file pbx.c.

4272 {
4277 }
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 exten.

Referenced by 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.

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

◆ unreference_cached_app()

void unreference_cached_app ( struct ast_app app)

pbx.c function needed by pbx_app.c

Referenced by ast_unregister_application().

◆ wait_for_hangup()

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