#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <regex.h>
#include <ctype.h>
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/localtime.h"
Include dependency graph for func_strings.c:
Go to the source code of this file.
Defines | |
#define | SPRINTF_CONVERSION 4 |
#define | SPRINTF_FLAG 0 |
#define | SPRINTF_LENGTH 3 |
#define | SPRINTF_PRECISION 2 |
#define | SPRINTF_WIDTH 1 |
Functions | |
static int | acf_sprintf (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | acf_strftime (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len) |
static int | acf_strptime (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | array (struct ast_channel *chan, char *cmd, char *var, const char *value) |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"String handling dialplan functions") | |
static int | filter (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len) |
static int | function_eval (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | function_fieldqty (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len) |
static int | function_tolower (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | function_toupper (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | keypadhash (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | len (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | load_module (void) |
static int | quote (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | regex (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len) |
static int | unload_module (void) |
Variables | |
static struct ast_custom_function | array_function |
static struct ast_custom_function | eval_function |
static struct ast_custom_function | fieldqty_function |
static struct ast_custom_function | filter_function |
static struct ast_custom_function | keypadhash_function |
static struct ast_custom_function | len_function |
static struct ast_custom_function | quote_function |
static struct ast_custom_function | regex_function |
static struct ast_custom_function | sprintf_function |
static struct ast_custom_function | strftime_function |
static struct ast_custom_function | strptime_function |
static struct ast_custom_function | tolower_function |
static struct ast_custom_function | toupper_function |
Definition in file func_strings.c.
#define SPRINTF_CONVERSION 4 |
Referenced by acf_sprintf().
#define SPRINTF_FLAG 0 |
Referenced by acf_sprintf().
#define SPRINTF_LENGTH 3 |
Referenced by acf_sprintf().
#define SPRINTF_PRECISION 2 |
Referenced by acf_sprintf().
#define SPRINTF_WIDTH 1 |
Referenced by acf_sprintf().
static int acf_sprintf | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 246 of file func_strings.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, format, SPRINTF_CONVERSION, SPRINTF_FLAG, SPRINTF_LENGTH, SPRINTF_PRECISION, SPRINTF_WIDTH, and var.
00247 { 00248 #define SPRINTF_FLAG 0 00249 #define SPRINTF_WIDTH 1 00250 #define SPRINTF_PRECISION 2 00251 #define SPRINTF_LENGTH 3 00252 #define SPRINTF_CONVERSION 4 00253 int i, state = -1, argcount = 0; 00254 char *formatstart = NULL, *bufptr = buf; 00255 char formatbuf[256] = ""; 00256 int tmpi; 00257 double tmpd; 00258 AST_DECLARE_APP_ARGS(arg, 00259 AST_APP_ARG(format); 00260 AST_APP_ARG(var)[100]; 00261 ); 00262 00263 AST_STANDARD_APP_ARGS(arg, data); 00264 00265 /* Scan the format, converting each argument into the requisite format type. */ 00266 for (i = 0; arg.format[i]; i++) { 00267 switch (state) { 00268 case SPRINTF_FLAG: 00269 if (strchr("#0- +'I", arg.format[i])) 00270 break; 00271 state = SPRINTF_WIDTH; 00272 case SPRINTF_WIDTH: 00273 if (arg.format[i] >= '0' && arg.format[i] <= '9') 00274 break; 00275 00276 /* Next character must be a period to go into a precision */ 00277 if (arg.format[i] == '.') { 00278 state = SPRINTF_PRECISION; 00279 } else { 00280 state = SPRINTF_LENGTH; 00281 i--; 00282 } 00283 break; 00284 case SPRINTF_PRECISION: 00285 if (arg.format[i] >= '0' && arg.format[i] <= '9') 00286 break; 00287 state = SPRINTF_LENGTH; 00288 case SPRINTF_LENGTH: 00289 if (strchr("hl", arg.format[i])) { 00290 if (arg.format[i + 1] == arg.format[i]) 00291 i++; 00292 state = SPRINTF_CONVERSION; 00293 break; 00294 } else if (strchr("Lqjzt", arg.format[i])) { 00295 state = SPRINTF_CONVERSION; 00296 break; 00297 } 00298 state = SPRINTF_CONVERSION; 00299 case SPRINTF_CONVERSION: 00300 if (strchr("diouxXc", arg.format[i])) { 00301 /* Integer */ 00302 00303 /* Isolate this format alone */ 00304 ast_copy_string(formatbuf, formatstart, sizeof(formatbuf)); 00305 formatbuf[&arg.format[i] - formatstart + 1] = '\0'; 00306 00307 /* Convert the argument into the required type */ 00308 if (sscanf(arg.var[argcount++], "%d", &tmpi) != 1) { 00309 ast_log(LOG_ERROR, "Argument '%s' is not an integer number for format '%s'\n", arg.var[argcount - 1], formatbuf); 00310 goto sprintf_fail; 00311 } 00312 00313 /* Format the argument */ 00314 snprintf(bufptr, buf + len - bufptr, formatbuf, tmpi); 00315 00316 /* Update the position of the next parameter to print */ 00317 bufptr = strchr(buf, '\0'); 00318 } else if (strchr("eEfFgGaA", arg.format[i])) { 00319 /* Double */ 00320 00321 /* Isolate this format alone */ 00322 ast_copy_string(formatbuf, formatstart, sizeof(formatbuf)); 00323 formatbuf[&arg.format[i] - formatstart + 1] = '\0'; 00324 00325 /* Convert the argument into the required type */ 00326 if (sscanf(arg.var[argcount++], "%lf", &tmpd) != 1) { 00327 ast_log(LOG_ERROR, "Argument '%s' is not a floating point number for format '%s'\n", arg.var[argcount - 1], formatbuf); 00328 goto sprintf_fail; 00329 } 00330 00331 /* Format the argument */ 00332 snprintf(bufptr, buf + len - bufptr, formatbuf, tmpd); 00333 00334 /* Update the position of the next parameter to print */ 00335 bufptr = strchr(buf, '\0'); 00336 } else if (arg.format[i] == 's') { 00337 /* String */ 00338 00339 /* Isolate this format alone */ 00340 ast_copy_string(formatbuf, formatstart, sizeof(formatbuf)); 00341 formatbuf[&arg.format[i] - formatstart + 1] = '\0'; 00342 00343 /* Format the argument */ 00344 snprintf(bufptr, buf + len - bufptr, formatbuf, arg.var[argcount++]); 00345 00346 /* Update the position of the next parameter to print */ 00347 bufptr = strchr(buf, '\0'); 00348 } else if (arg.format[i] == '%') { 00349 /* Literal data to copy */ 00350 *bufptr++ = arg.format[i]; 00351 } else { 00352 /* Not supported */ 00353 00354 /* Isolate this format alone */ 00355 ast_copy_string(formatbuf, formatstart, sizeof(formatbuf)); 00356 formatbuf[&arg.format[i] - formatstart + 1] = '\0'; 00357 00358 ast_log(LOG_ERROR, "Format type not supported: '%s' with argument '%s'\n", formatbuf, arg.var[argcount++]); 00359 goto sprintf_fail; 00360 } 00361 state = -1; 00362 break; 00363 default: 00364 if (arg.format[i] == '%') { 00365 state = SPRINTF_FLAG; 00366 formatstart = &arg.format[i]; 00367 break; 00368 } else { 00369 /* Literal data to copy */ 00370 *bufptr++ = arg.format[i]; 00371 } 00372 } 00373 } 00374 return 0; 00375 sprintf_fail: 00376 return -1; 00377 }
static int acf_strftime | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | parse, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 440 of file func_strings.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_get_time_t(), ast_localtime(), ast_log(), AST_STANDARD_APP_ARGS, format, and LOG_WARNING.
00442 { 00443 AST_DECLARE_APP_ARGS(args, 00444 AST_APP_ARG(epoch); 00445 AST_APP_ARG(timezone); 00446 AST_APP_ARG(format); 00447 ); 00448 time_t epochi; 00449 struct tm tm; 00450 00451 buf[0] = '\0'; 00452 00453 AST_STANDARD_APP_ARGS(args, parse); 00454 00455 ast_get_time_t(args.epoch, &epochi, time(NULL), NULL); 00456 ast_localtime(&epochi, &tm, args.timezone); 00457 00458 if (!args.format) 00459 args.format = "%c"; 00460 00461 if (!strftime(buf, len, args.format, &tm)) 00462 ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n"); 00463 00464 buf[len - 1] = '\0'; 00465 00466 return 0; 00467 }
static int acf_strptime | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 476 of file func_strings.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_mktime(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), format, LOG_ERROR, and LOG_WARNING.
00478 { 00479 AST_DECLARE_APP_ARGS(args, 00480 AST_APP_ARG(timestring); 00481 AST_APP_ARG(timezone); 00482 AST_APP_ARG(format); 00483 ); 00484 struct tm time; 00485 00486 memset(&time, 0, sizeof(struct tm)); 00487 00488 buf[0] = '\0'; 00489 00490 if (!data) { 00491 ast_log(LOG_ERROR, 00492 "Asterisk function STRPTIME() requires an argument.\n"); 00493 return -1; 00494 } 00495 00496 AST_STANDARD_APP_ARGS(args, data); 00497 00498 if (ast_strlen_zero(args.format)) { 00499 ast_log(LOG_ERROR, 00500 "No format supplied to STRPTIME(<timestring>|<timezone>|<format>)"); 00501 return -1; 00502 } 00503 00504 if (!strptime(args.timestring, args.format, &time)) { 00505 ast_log(LOG_WARNING, "C function strptime() output nothing?!!\n"); 00506 } else { 00507 snprintf(buf, len, "%d", (int) ast_mktime(&time, args.timezone)); 00508 } 00509 00510 return 0; 00511 }
static int array | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | var, | |||
const char * | value | |||
) | [static] |
Definition at line 176 of file func_strings.c.
References AST_APP_ARG, ast_autoservice_start(), AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strdupa, LOG_DEBUG, option_debug, and pbx_builtin_setvar_helper().
00178 { 00179 AST_DECLARE_APP_ARGS(arg1, 00180 AST_APP_ARG(var)[100]; 00181 ); 00182 AST_DECLARE_APP_ARGS(arg2, 00183 AST_APP_ARG(val)[100]; 00184 ); 00185 char *value2; 00186 int i; 00187 00188 value2 = ast_strdupa(value); 00189 if (!var || !value2) 00190 return -1; 00191 00192 if (chan) 00193 ast_autoservice_start(chan); 00194 00195 /* The functions this will generally be used with are SORT and ODBC_*, which 00196 * both return comma-delimited lists. However, if somebody uses literal lists, 00197 * their commas will be translated to vertical bars by the load, and I don't 00198 * want them to be surprised by the result. Hence, we prefer commas as the 00199 * delimiter, but we'll fall back to vertical bars if commas aren't found. 00200 */ 00201 if (option_debug) 00202 ast_log(LOG_DEBUG, "array (%s=%s)\n", var, value2); 00203 if (strchr(var, ',')) 00204 AST_NONSTANDARD_APP_ARGS(arg1, var, ','); 00205 else 00206 AST_STANDARD_APP_ARGS(arg1, var); 00207 00208 if (strchr(value2, ',')) 00209 AST_NONSTANDARD_APP_ARGS(arg2, value2, ','); 00210 else 00211 AST_STANDARD_APP_ARGS(arg2, value2); 00212 00213 for (i = 0; i < arg1.argc; i++) { 00214 if (option_debug) 00215 ast_log(LOG_DEBUG, "array set value (%s=%s)\n", arg1.var[i], 00216 arg2.val[i]); 00217 if (i < arg2.argc) { 00218 pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]); 00219 } else { 00220 /* We could unset the variable, by passing a NULL, but due to 00221 * pushvar semantics, that could create some undesired behavior. */ 00222 pbx_builtin_setvar_helper(chan, arg1.var[i], ""); 00223 } 00224 } 00225 00226 if (chan) 00227 ast_autoservice_stop(chan); 00228 00229 return 0; 00230 }
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"String handling dialplan functions" | ||||
) |
static int filter | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | parse, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 94 of file func_strings.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, and LOG_ERROR.
00096 { 00097 AST_DECLARE_APP_ARGS(args, 00098 AST_APP_ARG(allowed); 00099 AST_APP_ARG(string); 00100 ); 00101 char *outbuf = buf; 00102 00103 AST_STANDARD_APP_ARGS(args, parse); 00104 00105 if (!args.string) { 00106 ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>|<string>)\n"); 00107 return -1; 00108 } 00109 00110 for (; *(args.string) && (buf + len - 1 > outbuf); (args.string)++) { 00111 if (strchr(args.allowed, *(args.string))) 00112 *outbuf++ = *(args.string); 00113 } 00114 *outbuf = '\0'; 00115 00116 return 0; 00117 }
static int function_eval | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 528 of file func_strings.c.
References ast_autoservice_start(), ast_autoservice_stop(), ast_log(), ast_strlen_zero(), LOG_WARNING, and pbx_substitute_variables_helper().
00530 { 00531 memset(buf, 0, len); 00532 00533 if (ast_strlen_zero(data)) { 00534 ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n"); 00535 return -1; 00536 } 00537 00538 if (chan) 00539 ast_autoservice_start(chan); 00540 pbx_substitute_variables_helper(chan, data, buf, len - 1); 00541 if (chan) 00542 ast_autoservice_stop(chan); 00543 00544 return 0; 00545 }
static int function_fieldqty | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | parse, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 48 of file func_strings.c.
References AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, pbx_retrieve_variable(), and strsep().
00050 { 00051 char *varsubst, varval[8192] = "", *varval2 = varval; 00052 int fieldcount = 0; 00053 AST_DECLARE_APP_ARGS(args, 00054 AST_APP_ARG(varname); 00055 AST_APP_ARG(delim); 00056 ); 00057 00058 if (chan) 00059 ast_autoservice_start(chan); 00060 00061 AST_STANDARD_APP_ARGS(args, parse); 00062 if (args.delim) { 00063 pbx_retrieve_variable(chan, args.varname, &varval, buf, len, NULL); 00064 if (args.delim[0] == '\\') { 00065 if (args.delim[1] == 'n') 00066 ast_copy_string(args.delim, "\n", 2); 00067 else if (args.delim[1] == 't') 00068 ast_copy_string(args.delim, "\t", 2); 00069 else if (args.delim[1]) 00070 ast_copy_string(args.delim, &args.delim[1], 2); 00071 else 00072 ast_copy_string(args.delim, "-", 2); 00073 } 00074 while (strsep(&varval, args.delim)) 00075 fieldcount++; 00076 } else { 00077 fieldcount = 1; 00078 } 00079 snprintf(buf, len, "%d", fieldcount); 00080 00081 if (chan) 00082 ast_autoservice_stop(chan); 00083 00084 return 0; 00085 }
static int function_tolower | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 610 of file func_strings.c.
00611 { 00612 int i = 0; 00613 00614 while (data[i]) { 00615 if (data[i] & 0x80) { 00616 unsigned char c = data[i]; 00617 if (c >= 192 && c <= 223) { 00618 c += 32; 00619 data[i] = (char) c; 00620 } 00621 } else { 00622 data[i] = tolower(data[i]); 00623 } 00624 i++; 00625 } 00626 ast_copy_string(buf, data, len); 00627 return 0; 00628 }
static int function_toupper | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 639 of file func_strings.c.
00640 { 00641 int i = 0; 00642 while (data[i]) { 00643 if (data[i] & 0x80) { 00644 unsigned char c = data[i]; 00645 if (c >= 224) { 00646 c -= 32; 00647 data[i] = (char)c; 00648 } 00649 } else { 00650 data[i] = toupper(data[i]); 00651 } 00652 i++; 00653 } 00654 ast_copy_string(buf, data, len); 00655 return 0; 00656 }
static int keypadhash | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 563 of file func_strings.c.
00564 { 00565 char *bufptr, *dataptr; 00566 00567 for (bufptr = buf, dataptr = data; bufptr < buf + len - 1; dataptr++) { 00568 if (*dataptr == '1') { 00569 *bufptr++ = '1'; 00570 } else if (strchr("AaBbCc2", *dataptr)) { 00571 *bufptr++ = '2'; 00572 } else if (strchr("DdEeFf3", *dataptr)) { 00573 *bufptr++ = '3'; 00574 } else if (strchr("GgHhIi4", *dataptr)) { 00575 *bufptr++ = '4'; 00576 } else if (strchr("JjKkLl5", *dataptr)) { 00577 *bufptr++ = '5'; 00578 } else if (strchr("MmNnOo6", *dataptr)) { 00579 *bufptr++ = '6'; 00580 } else if (strchr("PpQqRrSs7", *dataptr)) { 00581 *bufptr++ = '7'; 00582 } else if (strchr("TtUuVv8", *dataptr)) { 00583 *bufptr++ = '8'; 00584 } else if (strchr("WwXxYyZz9", *dataptr)) { 00585 *bufptr++ = '9'; 00586 } else if (*dataptr == '*') { 00587 *bufptr++ = '*'; 00588 } else if (*dataptr == '#') { 00589 *bufptr++ = '#'; 00590 } else if (*dataptr == '0') { 00591 *bufptr++ = '0'; 00592 } else if (*dataptr == '\0') { 00593 *bufptr++ = '\0'; 00594 break; 00595 } 00596 } 00597 buf[len - 1] = '\0'; 00598 00599 return 0; 00600 }
static int len | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 420 of file func_strings.c.
00422 { 00423 int length = 0; 00424 00425 if (data) 00426 length = strlen(data); 00427 00428 snprintf(buf, len, "%d", length); 00429 00430 return 0; 00431 }
static int load_module | ( | void | ) | [static] |
Definition at line 689 of file func_strings.c.
References array_function, ast_custom_function_register(), eval_function, fieldqty_function, filter_function, keypadhash_function, len_function, quote_function, regex_function, sprintf_function, strftime_function, strptime_function, tolower_function, and toupper_function.
00690 { 00691 int res = 0; 00692 00693 res |= ast_custom_function_register(&fieldqty_function); 00694 res |= ast_custom_function_register(&filter_function); 00695 res |= ast_custom_function_register(®ex_function); 00696 res |= ast_custom_function_register(&array_function); 00697 res |= ast_custom_function_register("e_function); 00698 res |= ast_custom_function_register(&len_function); 00699 res |= ast_custom_function_register(&strftime_function); 00700 res |= ast_custom_function_register(&strptime_function); 00701 res |= ast_custom_function_register(&eval_function); 00702 res |= ast_custom_function_register(&keypadhash_function); 00703 res |= ast_custom_function_register(&tolower_function); 00704 res |= ast_custom_function_register(&toupper_function); 00705 res |= ast_custom_function_register(&sprintf_function); 00706 00707 return res; 00708 }
static int quote | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 390 of file func_strings.c.
Referenced by ast_app_separate_args(), and make_email_file().
00391 { 00392 char *bufptr = buf, *dataptr = data; 00393 *bufptr++ = '"'; 00394 for (; bufptr < buf + len - 1; dataptr++) { 00395 if (*dataptr == '\\') { 00396 *bufptr++ = '\\'; 00397 *bufptr++ = '\\'; 00398 } else if (*dataptr == '"') { 00399 *bufptr++ = '\\'; 00400 *bufptr++ = '"'; 00401 } else if (*dataptr == '\0') { 00402 break; 00403 } else { 00404 *bufptr++ = *dataptr; 00405 } 00406 } 00407 *bufptr++ = '"'; 00408 *bufptr = '\0'; 00409 return 0; 00410 }
static int regex | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | parse, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 126 of file func_strings.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, LOG_DEBUG, LOG_ERROR, LOG_WARNING, and option_debug.
00128 { 00129 AST_DECLARE_APP_ARGS(args, 00130 AST_APP_ARG(null); 00131 AST_APP_ARG(reg); 00132 AST_APP_ARG(str); 00133 ); 00134 int errcode; 00135 regex_t regexbuf; 00136 00137 buf[0] = '\0'; 00138 00139 AST_NONSTANDARD_APP_ARGS(args, parse, '"'); 00140 00141 if (args.argc != 3) { 00142 ast_log(LOG_ERROR, "Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n"); 00143 return -1; 00144 } 00145 if ((*args.str == ' ') || (*args.str == '\t')) 00146 args.str++; 00147 00148 if (option_debug) 00149 ast_log(LOG_DEBUG, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str); 00150 00151 if ((errcode = regcomp(®exbuf, args.reg, REG_EXTENDED | REG_NOSUB))) { 00152 regerror(errcode, ®exbuf, buf, len); 00153 ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf); 00154 return -1; 00155 } 00156 00157 strcpy(buf, regexec(®exbuf, args.str, 0, NULL, 0) ? "0" : "1"); 00158 00159 regfree(®exbuf); 00160 00161 return 0; 00162 }
static int unload_module | ( | void | ) | [static] |
Definition at line 668 of file func_strings.c.
References array_function, ast_custom_function_unregister(), eval_function, fieldqty_function, filter_function, keypadhash_function, len_function, quote_function, regex_function, sprintf_function, strftime_function, strptime_function, tolower_function, and toupper_function.
00669 { 00670 int res = 0; 00671 00672 res |= ast_custom_function_unregister(&fieldqty_function); 00673 res |= ast_custom_function_unregister(&filter_function); 00674 res |= ast_custom_function_unregister(®ex_function); 00675 res |= ast_custom_function_unregister(&array_function); 00676 res |= ast_custom_function_unregister("e_function); 00677 res |= ast_custom_function_unregister(&len_function); 00678 res |= ast_custom_function_unregister(&strftime_function); 00679 res |= ast_custom_function_unregister(&strptime_function); 00680 res |= ast_custom_function_unregister(&eval_function); 00681 res |= ast_custom_function_unregister(&keypadhash_function); 00682 res |= ast_custom_function_unregister(&tolower_function); 00683 res |= ast_custom_function_unregister(&toupper_function); 00684 res |= ast_custom_function_unregister(&sprintf_function); 00685 00686 return res; 00687 }
struct ast_custom_function array_function [static] |
struct ast_custom_function eval_function [static] |
struct ast_custom_function fieldqty_function [static] |
struct ast_custom_function filter_function [static] |
struct ast_custom_function keypadhash_function [static] |
struct ast_custom_function len_function [static] |
struct ast_custom_function quote_function [static] |
struct ast_custom_function regex_function [static] |
struct ast_custom_function sprintf_function [static] |
struct ast_custom_function strftime_function [static] |
struct ast_custom_function strptime_function [static] |
struct ast_custom_function tolower_function [static] |
struct ast_custom_function toupper_function [static] |