Asterisk - The Open Source Telephony Project GIT-master-f36a736
pbx_ignorepat.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2016, CFWare, LLC
5 *
6 * Corey Farrell <git@cfware.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*! \file
20 *
21 * \brief Dialplan context ignorepat routines.
22 *
23 * \author Corey Farrell <git@cfware.com>
24 */
25
26/*** MODULEINFO
27 <support_level>core</support_level>
28 ***/
29
30#include "asterisk.h"
31
32#include "asterisk/_private.h"
33#include "asterisk/pbx.h"
34#include "pbx_private.h"
35
36/*! \brief ast_ignorepat: Ignore patterns in dial plan */
38 const char *registrar;
39 const char pattern[0];
40};
41
42const char *ast_get_ignorepat_name(const struct ast_ignorepat *ip)
43{
44 return ip ? ip->pattern : NULL;
45}
46
47const char *ast_get_ignorepat_registrar(const struct ast_ignorepat *ip)
48{
49 return ip ? ip->registrar : NULL;
50}
51
52struct ast_ignorepat *ignorepat_alloc(const char *value, const char *registrar)
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}
76
78{
79 ast_free(ip);
80}
Prototypes for public functions only of internal interest,.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_free(a)
Definition: astmm.h:180
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
Core PBX routines and definitions.
static char * registrar
Definition: pbx_ael.c:78
const char * ast_get_ignorepat_registrar(const struct ast_ignorepat *ip)
Definition: pbx_ignorepat.c:47
void ignorepat_free(struct ast_ignorepat *ip)
Definition: pbx_ignorepat.c:77
struct ast_ignorepat * ignorepat_alloc(const char *value, const char *registrar)
Definition: pbx_ignorepat.c:52
const char * ast_get_ignorepat_name(const struct ast_ignorepat *ip)
Definition: pbx_ignorepat.c:42
Private include file for pbx.
#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