Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Functions
pbx_sw.c File Reference

Dialplan switch routines. More...

#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/pbx.h"
#include "pbx_private.h"
Include dependency graph for pbx_sw.c:

Go to the source code of this file.

Data Structures

struct  ast_sw
 ast_sw: Switch statement in extensions.conf More...
 

Functions

const char * ast_get_switch_data (const struct ast_sw *sw)
 
int ast_get_switch_eval (const struct ast_sw *sw)
 
const char * ast_get_switch_name (const struct ast_sw *sw)
 
const char * ast_get_switch_registrar (const struct ast_sw *sw)
 
struct ast_swsw_alloc (const char *value, const char *data, int eval, const char *registrar)
 
void sw_free (struct ast_sw *sw)
 

Detailed Description

Dialplan switch routines.

Author
Corey Farrell git@c.nosp@m.fwar.nosp@m.e.com

Definition in file pbx_sw.c.

Function Documentation

◆ ast_get_switch_data()

const char* ast_get_switch_data ( const struct ast_sw sw)

◆ ast_get_switch_eval()

int ast_get_switch_eval ( const struct ast_sw sw)

Definition at line 58 of file pbx_sw.c.

References ast_sw::eval.

Referenced by context_merge_incls_swits_igps_other_registrars(), and pbx_find_extension().

59 {
60  return sw->eval;
61 }
int eval
Definition: pbx_sw.c:43

◆ ast_get_switch_name()

const char* ast_get_switch_name ( const struct ast_sw sw)

◆ ast_get_switch_registrar()

const char* ast_get_switch_registrar ( const struct ast_sw sw)

◆ 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