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

Dialplan context include routines. More...

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

Go to the source code of this file.

Data Structures

struct  ast_include
 ast_include: include= support in extensions.conf More...
 

Functions

const char * ast_get_include_name (const struct ast_include *inc)
 
const char * ast_get_include_registrar (const struct ast_include *inc)
 
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)
 

Detailed Description

Dialplan context include routines.

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

Definition in file pbx_include.c.

Function Documentation

◆ ast_get_include_name()

const char* ast_get_include_name ( const struct ast_include inc)

◆ ast_get_include_registrar()

const char* ast_get_include_registrar ( const struct ast_include inc)

◆ 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