Fri Aug 24 02:22:15 2007

Asterisk developer's documentation


func_strings.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2005-2006, Digium, Inc.
00005  * Portions Copyright (C) 2005, Tilghman Lesher.  All rights reserved.
00006  * Portions Copyright (C) 2005, Anthony Minessale II
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief String manipulation dialplan functions
00022  *
00023  * \author Tilghman Lesher
00024  * \author Anothony Minessale II 
00025  * \ingroup functions
00026  */
00027 
00028 #include "asterisk.h"
00029 
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
00031 
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <string.h>
00035 #include <sys/types.h>
00036 #include <regex.h>
00037 #include <ctype.h>
00038 
00039 #include "asterisk/module.h"
00040 #include "asterisk/options.h"
00041 #include "asterisk/channel.h"
00042 #include "asterisk/pbx.h"
00043 #include "asterisk/logger.h"
00044 #include "asterisk/utils.h"
00045 #include "asterisk/app.h"
00046 #include "asterisk/localtime.h"
00047 
00048 static int function_fieldqty(struct ast_channel *chan, char *cmd,
00049               char *parse, char *buf, size_t len)
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    AST_STANDARD_APP_ARGS(args, parse);
00059    if (args.delim) {
00060       pbx_retrieve_variable(chan, args.varname, &varval, buf, len, NULL);
00061       if (args.delim[0] == '\\') {
00062          if (args.delim[1] == 'n')
00063             ast_copy_string(args.delim, "\n", 2);
00064          else if (args.delim[1] == 't')
00065             ast_copy_string(args.delim, "\t", 2);
00066          else if (args.delim[1])
00067             ast_copy_string(args.delim, &args.delim[1], 2);
00068          else
00069             ast_copy_string(args.delim, "-", 2);
00070       }
00071       while (strsep(&varval, args.delim))
00072          fieldcount++;
00073    } else {
00074       fieldcount = 1;
00075    }
00076    snprintf(buf, len, "%d", fieldcount);
00077 
00078    return 0;
00079 }
00080 
00081 static struct ast_custom_function fieldqty_function = {
00082    .name = "FIELDQTY",
00083    .synopsis = "Count the fields, with an arbitrary delimiter",
00084    .syntax = "FIELDQTY(<varname>|<delim>)",
00085    .read = function_fieldqty,
00086 };
00087 
00088 static int filter(struct ast_channel *chan, char *cmd, char *parse, char *buf,
00089         size_t len)
00090 {
00091    AST_DECLARE_APP_ARGS(args,
00092               AST_APP_ARG(allowed);
00093               AST_APP_ARG(string);
00094    );
00095    char *outbuf = buf;
00096 
00097    AST_STANDARD_APP_ARGS(args, parse);
00098 
00099    if (!args.string) {
00100       ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>|<string>)\n");
00101       return -1;
00102    }
00103 
00104    for (; *(args.string) && (buf + len - 1 > outbuf); (args.string)++) {
00105       if (strchr(args.allowed, *(args.string)))
00106          *outbuf++ = *(args.string);
00107    }
00108    *outbuf = '\0';
00109 
00110    return 0;
00111 }
00112 
00113 static struct ast_custom_function filter_function = {
00114    .name = "FILTER",
00115    .synopsis = "Filter the string to include only the allowed characters",
00116    .syntax = "FILTER(<allowed-chars>|<string>)",
00117    .read = filter,
00118 };
00119 
00120 static int regex(struct ast_channel *chan, char *cmd, char *parse, char *buf,
00121        size_t len)
00122 {
00123    AST_DECLARE_APP_ARGS(args,
00124               AST_APP_ARG(null);
00125               AST_APP_ARG(reg);
00126               AST_APP_ARG(str);
00127    );
00128    int errcode;
00129    regex_t regexbuf;
00130 
00131    buf[0] = '\0';
00132 
00133    AST_NONSTANDARD_APP_ARGS(args, parse, '"');
00134 
00135    if (args.argc != 3) {
00136       ast_log(LOG_ERROR, "Unexpected arguments: should have been in the form '\"<regex>\" <string>'\n");
00137       return -1;
00138    }
00139    if ((*args.str == ' ') || (*args.str == '\t'))
00140       args.str++;
00141 
00142    if (option_debug)
00143       ast_log(LOG_DEBUG, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
00144 
00145    if ((errcode = regcomp(&regexbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
00146       regerror(errcode, &regexbuf, buf, len);
00147       ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf);
00148       return -1;
00149    }
00150    
00151    strcpy(buf, regexec(&regexbuf, args.str, 0, NULL, 0) ? "0" : "1");
00152 
00153    regfree(&regexbuf);
00154 
00155    return 0;
00156 }
00157 
00158 static struct ast_custom_function regex_function = {
00159    .name = "REGEX",
00160    .synopsis = "Regular Expression",
00161    .desc =  
00162       "Returns 1 if data matches regular expression, or 0 otherwise.\n"
00163       "Please note that the space following the double quotes separating the regex from the data\n"
00164       "is optional and if present, is skipped. If a space is desired at the beginning of the data,\n"
00165            "then put two spaces there; the second will not be skipped.\n",
00166    .syntax = "REGEX(\"<regular expression>\" <data>)",
00167    .read = regex,
00168 };
00169 
00170 static int array(struct ast_channel *chan, char *cmd, char *var,
00171        const char *value)
00172 {
00173    AST_DECLARE_APP_ARGS(arg1,
00174               AST_APP_ARG(var)[100];
00175    );
00176    AST_DECLARE_APP_ARGS(arg2,
00177               AST_APP_ARG(val)[100];
00178    );
00179    char *value2;
00180    int i;
00181 
00182    value2 = ast_strdupa(value);
00183    if (!var || !value2)
00184       return -1;
00185 
00186    /* The functions this will generally be used with are SORT and ODBC_*, which
00187     * both return comma-delimited lists.  However, if somebody uses literal lists,
00188     * their commas will be translated to vertical bars by the load, and I don't
00189     * want them to be surprised by the result.  Hence, we prefer commas as the
00190     * delimiter, but we'll fall back to vertical bars if commas aren't found.
00191     */
00192    if (option_debug)
00193       ast_log(LOG_DEBUG, "array (%s=%s)\n", var, value2);
00194    if (strchr(var, ','))
00195       AST_NONSTANDARD_APP_ARGS(arg1, var, ',');
00196    else
00197       AST_STANDARD_APP_ARGS(arg1, var);
00198 
00199    if (strchr(value2, ','))
00200       AST_NONSTANDARD_APP_ARGS(arg2, value2, ',');
00201    else
00202       AST_STANDARD_APP_ARGS(arg2, value2);
00203 
00204    for (i = 0; i < arg1.argc; i++) {
00205       if (option_debug)
00206          ast_log(LOG_DEBUG, "array set value (%s=%s)\n", arg1.var[i],
00207             arg2.val[i]);
00208       if (i < arg2.argc) {
00209          pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]);
00210       } else {
00211          /* We could unset the variable, by passing a NULL, but due to
00212           * pushvar semantics, that could create some undesired behavior. */
00213          pbx_builtin_setvar_helper(chan, arg1.var[i], "");
00214       }
00215    }
00216 
00217    return 0;
00218 }
00219 
00220 static struct ast_custom_function array_function = {
00221    .name = "ARRAY",
00222    .synopsis = "Allows setting multiple variables at once",
00223    .syntax = "ARRAY(var1[|var2[...][|varN]])",
00224    .write = array,
00225    .desc =
00226       "The comma-separated list passed as a value to which the function is set will\n"
00227       "be interpreted as a set of values to which the comma-separated list of\n"
00228       "variable names in the argument should be set.\n"
00229       "Hence, Set(ARRAY(var1|var2)=1\\,2) will set var1 to 1 and var2 to 2\n"
00230       "Note: remember to either backslash your commas in extensions.conf or quote the\n"
00231       "entire argument, since Set can take multiple arguments itself.\n",
00232 };
00233 
00234 static int acf_sprintf(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
00235 {
00236 #define SPRINTF_FLAG 0
00237 #define SPRINTF_WIDTH   1
00238 #define SPRINTF_PRECISION  2
00239 #define SPRINTF_LENGTH  3
00240 #define SPRINTF_CONVERSION 4
00241    int i, state = -1, argcount = 0;
00242    char *formatstart = NULL, *bufptr = buf;
00243    char formatbuf[256] = "";
00244    int tmpi;
00245    double tmpd;
00246    AST_DECLARE_APP_ARGS(arg,
00247             AST_APP_ARG(format);
00248             AST_APP_ARG(var)[100];
00249    );
00250 
00251    AST_STANDARD_APP_ARGS(arg, data);
00252 
00253    /* Scan the format, converting each argument into the requisite format type. */
00254    for (i = 0; arg.format[i]; i++) {
00255       switch (state) {
00256       case SPRINTF_FLAG:
00257          if (strchr("#0- +'I", arg.format[i]))
00258             break;
00259          state = SPRINTF_WIDTH;
00260       case SPRINTF_WIDTH:
00261          if (arg.format[i] >= '0' && arg.format[i] <= '9')
00262             break;
00263 
00264          /* Next character must be a period to go into a precision */
00265          if (arg.format[i] == '.') {
00266             state = SPRINTF_PRECISION;
00267          } else {
00268             state = SPRINTF_LENGTH;
00269             i--;
00270          }
00271          break;
00272       case SPRINTF_PRECISION:
00273          if (arg.format[i] >= '0' && arg.format[i] <= '9')
00274             break;
00275          state = SPRINTF_LENGTH;
00276       case SPRINTF_LENGTH:
00277          if (strchr("hl", arg.format[i])) {
00278             if (arg.format[i + 1] == arg.format[i])
00279                i++;
00280             state = SPRINTF_CONVERSION;
00281             break;
00282          } else if (strchr("Lqjzt", arg.format[i]))
00283             state = SPRINTF_CONVERSION;
00284             break;
00285          state = SPRINTF_CONVERSION;
00286       case SPRINTF_CONVERSION:
00287          if (strchr("diouxXc", arg.format[i])) {
00288             /* Integer */
00289 
00290             /* Isolate this format alone */
00291             ast_copy_string(formatbuf, formatstart, sizeof(formatbuf));
00292             formatbuf[&arg.format[i] - formatstart + 1] = '\0';
00293 
00294             /* Convert the argument into the required type */
00295             if (sscanf(arg.var[argcount++], "%d", &tmpi) != 1) {
00296                ast_log(LOG_ERROR, "Argument '%s' is not an integer number for format '%s'\n", arg.var[argcount - 1], formatbuf);
00297                goto sprintf_fail;
00298             }
00299 
00300             /* Format the argument */
00301             snprintf(bufptr, buf + len - bufptr, formatbuf, tmpi);
00302 
00303             /* Update the position of the next parameter to print */
00304             bufptr = strchr(buf, '\0');
00305          } else if (strchr("eEfFgGaA", arg.format[i])) {
00306             /* Double */
00307 
00308             /* Isolate this format alone */
00309             ast_copy_string(formatbuf, formatstart, sizeof(formatbuf));
00310             formatbuf[&arg.format[i] - formatstart + 1] = '\0';
00311 
00312             /* Convert the argument into the required type */
00313             if (sscanf(arg.var[argcount++], "%lf", &tmpd) != 1) {
00314                ast_log(LOG_ERROR, "Argument '%s' is not a floating point number for format '%s'\n", arg.var[argcount - 1], formatbuf);
00315                goto sprintf_fail;
00316             }
00317 
00318             /* Format the argument */
00319             snprintf(bufptr, buf + len - bufptr, formatbuf, tmpd);
00320 
00321             /* Update the position of the next parameter to print */
00322             bufptr = strchr(buf, '\0');
00323          } else if (arg.format[i] == 's') {
00324             /* String */
00325 
00326             /* Isolate this format alone */
00327             ast_copy_string(formatbuf, formatstart, sizeof(formatbuf));
00328             formatbuf[&arg.format[i] - formatstart + 1] = '\0';
00329 
00330             /* Format the argument */
00331             snprintf(bufptr, buf + len - bufptr, formatbuf, arg.var[argcount++]);
00332 
00333             /* Update the position of the next parameter to print */
00334             bufptr = strchr(buf, '\0');
00335          } else if (arg.format[i] == '%') {
00336             /* Literal data to copy */
00337             *bufptr++ = arg.format[i];
00338          } else {
00339             /* Not supported */
00340 
00341             /* Isolate this format alone */
00342             ast_copy_string(formatbuf, formatstart, sizeof(formatbuf));
00343             formatbuf[&arg.format[i] - formatstart + 1] = '\0';
00344 
00345             ast_log(LOG_ERROR, "Format type not supported: '%s' with argument '%s'\n", formatbuf, arg.var[argcount++]);
00346             goto sprintf_fail;
00347          }
00348          state = -1;
00349          break;
00350       default:
00351          if (arg.format[i] == '%') {
00352             state = SPRINTF_FLAG;
00353             formatstart = &arg.format[i];
00354             break;
00355          } else {
00356             /* Literal data to copy */
00357             *bufptr++ = arg.format[i];
00358          }
00359       }
00360    }
00361    return 0;
00362 sprintf_fail:
00363    return -1;
00364 }
00365 
00366 static struct ast_custom_function sprintf_function = {
00367    .name = "SPRINTF",
00368    .synopsis = "Format a variable according to a format string",
00369    .syntax = "SPRINTF(<format>|<arg1>[|...<argN>])",
00370    .read = acf_sprintf,
00371    .desc =
00372 "Parses the format string specified and returns a string matching that format.\n"
00373 "Supports most options supported by sprintf(3).  Returns a shortened string if\n"
00374 "a format specifier is not recognized.\n",
00375 };
00376 
00377 static int quote(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
00378 {
00379    char *bufptr = buf, *dataptr = data;
00380    *bufptr++ = '"';
00381    for (; bufptr < buf + len - 1; dataptr++) {
00382       if (*dataptr == '\\') {
00383          *bufptr++ = '\\';
00384          *bufptr++ = '\\';
00385       } else if (*dataptr == '"') {
00386          *bufptr++ = '\\';
00387          *bufptr++ = '"';
00388       } else if (*dataptr == '\0') {
00389          break;
00390       } else {
00391          *bufptr++ = *dataptr;
00392       }
00393    }
00394    *bufptr++ = '"';
00395    *bufptr = '\0';
00396    return 0;
00397 }
00398 
00399 static struct ast_custom_function quote_function = {
00400    .name = "QUOTE",
00401    .synopsis = "Quotes a given string, escaping embedded quotes as necessary",
00402    .syntax = "QUOTE(<string>)",
00403    .read = quote,
00404 };
00405 
00406 
00407 static int len(struct ast_channel *chan, char *cmd, char *data, char *buf,
00408           size_t len)
00409 {
00410    int length = 0;
00411 
00412    if (data)
00413       length = strlen(data);
00414 
00415    snprintf(buf, len, "%d", length);
00416 
00417    return 0;
00418 }
00419 
00420 static struct ast_custom_function len_function = {
00421    .name = "LEN",
00422    .synopsis = "Returns the length of the argument given",
00423    .syntax = "LEN(<string>)",
00424    .read = len,
00425 };
00426 
00427 static int acf_strftime(struct ast_channel *chan, char *cmd, char *parse,
00428          char *buf, size_t len)
00429 {
00430    AST_DECLARE_APP_ARGS(args,
00431               AST_APP_ARG(epoch);
00432               AST_APP_ARG(timezone);
00433               AST_APP_ARG(format);
00434    );
00435    time_t epochi;
00436    struct tm tm;
00437 
00438    buf[0] = '\0';
00439 
00440    AST_STANDARD_APP_ARGS(args, parse);
00441 
00442    ast_get_time_t(args.epoch, &epochi, time(NULL), NULL);
00443    ast_localtime(&epochi, &tm, args.timezone);
00444 
00445    if (!args.format)
00446       args.format = "%c";
00447 
00448    if (!strftime(buf, len, args.format, &tm))
00449       ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
00450 
00451    buf[len - 1] = '\0';
00452 
00453    return 0;
00454 }
00455 
00456 static struct ast_custom_function strftime_function = {
00457    .name = "STRFTIME",
00458    .synopsis = "Returns the current date/time in a specified format.",
00459    .syntax = "STRFTIME([<epoch>][|[timezone][|format]])",
00460    .read = acf_strftime,
00461 };
00462 
00463 static int acf_strptime(struct ast_channel *chan, char *cmd, char *data,
00464          char *buf, size_t len)
00465 {
00466    AST_DECLARE_APP_ARGS(args,
00467               AST_APP_ARG(timestring);
00468               AST_APP_ARG(timezone);
00469               AST_APP_ARG(format);
00470    );
00471    struct tm time;
00472 
00473    memset(&time, 0, sizeof(struct tm));
00474 
00475    buf[0] = '\0';
00476 
00477    if (!data) {
00478       ast_log(LOG_ERROR,
00479             "Asterisk function STRPTIME() requires an argument.\n");
00480       return -1;
00481    }
00482 
00483    AST_STANDARD_APP_ARGS(args, data);
00484 
00485    if (ast_strlen_zero(args.format)) {
00486       ast_log(LOG_ERROR,
00487             "No format supplied to STRPTIME(<timestring>|<timezone>|<format>)");
00488       return -1;
00489    }
00490 
00491    if (!strptime(args.timestring, args.format, &time)) {
00492       ast_log(LOG_WARNING, "C function strptime() output nothing?!!\n");
00493    } else {
00494       snprintf(buf, len, "%d", (int) ast_mktime(&time, args.timezone));
00495    }
00496 
00497    return 0;
00498 }
00499 
00500 static struct ast_custom_function strptime_function = {
00501    .name = "STRPTIME",
00502    .synopsis =
00503       "Returns the epoch of the arbitrary date/time string structured as described in the format.",
00504    .syntax = "STRPTIME(<datetime>|<timezone>|<format>)",
00505    .desc =
00506       "This is useful for converting a date into an EPOCH time, possibly to pass to\n"
00507       "an application like SayUnixTime or to calculate the difference between two\n"
00508       "date strings.\n"
00509       "\n"
00510       "Example:\n"
00511       "  ${STRPTIME(2006-03-01 07:30:35|America/Chicago|%Y-%m-%d %H:%M:%S)} returns 1141219835\n",
00512    .read = acf_strptime,
00513 };
00514 
00515 static int function_eval(struct ast_channel *chan, char *cmd, char *data,
00516           char *buf, size_t len)
00517 {
00518    memset(buf, 0, len);
00519 
00520    if (ast_strlen_zero(data)) {
00521       ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
00522       return -1;
00523    }
00524 
00525    pbx_substitute_variables_helper(chan, data, buf, len - 1);
00526 
00527    return 0;
00528 }
00529 
00530 static struct ast_custom_function eval_function = {
00531    .name = "EVAL",
00532    .synopsis = "Evaluate stored variables.",
00533    .syntax = "EVAL(<variable>)",
00534    .desc = "Using EVAL basically causes a string to be evaluated twice.\n"
00535       "When a variable or expression is in the dialplan, it will be\n"
00536       "evaluated at runtime. However, if the result of the evaluation\n"
00537       "is in fact a variable or expression, using EVAL will have it\n"
00538       "evaluated a second time. For example, if the variable ${MYVAR}\n"
00539       "contains \"${OTHERVAR}\", then the result of putting ${EVAL(${MYVAR})}\n"
00540       "in the dialplan will be the contents of the variable, OTHERVAR.\n"
00541       "Normally, by just putting ${MYVAR} in the dialplan, you would be\n"
00542       "left with \"${OTHERVAR}\".\n",
00543    .read = function_eval,
00544 };
00545 
00546 static int keypadhash(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
00547 {
00548    char *bufptr, *dataptr;
00549 
00550    for (bufptr = buf, dataptr = data; bufptr < buf + len - 1; dataptr++) {
00551       if (*dataptr == '1') {
00552          *bufptr++ = '1';
00553       } else if (strchr("AaBbCc2", *dataptr)) {
00554          *bufptr++ = '2';
00555       } else if (strchr("DdEeFf3", *dataptr)) {
00556          *bufptr++ = '3';
00557       } else if (strchr("GgHhIi4", *dataptr)) {
00558          *bufptr++ = '4';
00559       } else if (strchr("JjKkLl5", *dataptr)) {
00560          *bufptr++ = '5';
00561       } else if (strchr("MmNnOo6", *dataptr)) {
00562          *bufptr++ = '6';
00563       } else if (strchr("PpQqRrSs7", *dataptr)) {
00564          *bufptr++ = '7';
00565       } else if (strchr("TtUuVv8", *dataptr)) {
00566          *bufptr++ = '8';
00567       } else if (strchr("WwXxYyZz9", *dataptr)) {
00568          *bufptr++ = '9';
00569       } else if (*dataptr == '*') {
00570          *bufptr++ = '*';
00571       } else if (*dataptr == '#') {
00572          *bufptr++ = '#';
00573       } else if (*dataptr == '0') {
00574          *bufptr++ = '0';
00575       } else if (*dataptr == '\0') {
00576          *bufptr++ = '\0';
00577          break;
00578       }
00579    }
00580    buf[len - 1] = '\0';
00581 
00582    return 0;
00583 }
00584 
00585 static struct ast_custom_function keypadhash_function = {
00586    .name = "KEYPADHASH",
00587    .synopsis = "Hash the letters in the string into the equivalent keypad numbers.",
00588    .syntax = "KEYPADHASH(<string>)",
00589    .read = keypadhash,
00590    .desc = "Example:  ${KEYPADHASH(Les)} returns \"537\"\n",
00591 };
00592 
00593 static int function_tolower(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
00594 {
00595    int i = 0;
00596 
00597    while (data[i]) {
00598       if (data[i] & 0x80) {
00599          unsigned char c = data[i];
00600          if (c >= 192 && c <= 223) {
00601             c += 32;
00602             data[i] = (char) c;
00603          }
00604       } else {
00605          data[i] = tolower(data[i]);
00606       }
00607       i++;
00608    }
00609    ast_copy_string(buf, data, len);
00610    return 0;
00611 }
00612 
00613 static struct ast_custom_function tolower_function = {
00614    .name = "TOLOWER",
00615    .synopsis = "Returns the string in lowercase",
00616    .syntax = "TOLOWER(<string>)",
00617    .desc = "Using TOLOWER convert all ASCII characters from A to Z\n"
00618       "to lowercase a to z.\n",
00619    .read = function_tolower,
00620 };
00621 
00622 static int function_toupper(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
00623 {
00624    int i = 0;
00625    while (data[i]) {
00626       if (data[i] & 0x80) {
00627          unsigned char c = data[i];
00628          if (c >= 224) {
00629             c -= 32;
00630             data[i] = (char)c;
00631          }
00632       } else {
00633          data[i] = toupper(data[i]);
00634       }
00635       i++;
00636    }
00637    ast_copy_string(buf, data, len);
00638    return 0;
00639 }
00640 
00641 
00642 static struct ast_custom_function toupper_function = {
00643    .name = "TOUPPER",
00644    .synopsis = "Returns the string in uppercase",
00645    .syntax = "TOUPPER(<string>)",
00646    .desc = "Using TOUPPER convert all ASCII characters from a to z\n"
00647          "to uppercase A to Z.\n",
00648    .read = function_toupper,
00649 };
00650 
00651 static int unload_module(void)
00652 {
00653    int res = 0;
00654 
00655    res |= ast_custom_function_unregister(&fieldqty_function);
00656    res |= ast_custom_function_unregister(&filter_function);
00657    res |= ast_custom_function_unregister(&regex_function);
00658    res |= ast_custom_function_unregister(&array_function);
00659    res |= ast_custom_function_unregister(&quote_function);
00660    res |= ast_custom_function_unregister(&len_function);
00661    res |= ast_custom_function_unregister(&strftime_function);
00662    res |= ast_custom_function_unregister(&strptime_function);
00663    res |= ast_custom_function_unregister(&eval_function);
00664    res |= ast_custom_function_unregister(&keypadhash_function);
00665    res |= ast_custom_function_unregister(&tolower_function);
00666    res |= ast_custom_function_unregister(&toupper_function);
00667    res |= ast_custom_function_unregister(&sprintf_function);
00668 
00669    return res;
00670 }
00671 
00672 static int load_module(void)
00673 {
00674    int res = 0;
00675 
00676    res |= ast_custom_function_register(&fieldqty_function);
00677    res |= ast_custom_function_register(&filter_function);
00678    res |= ast_custom_function_register(&regex_function);
00679    res |= ast_custom_function_register(&array_function);
00680    res |= ast_custom_function_register(&quote_function);
00681    res |= ast_custom_function_register(&len_function);
00682    res |= ast_custom_function_register(&strftime_function);
00683    res |= ast_custom_function_register(&strptime_function);
00684    res |= ast_custom_function_register(&eval_function);
00685    res |= ast_custom_function_register(&keypadhash_function);
00686         res |= ast_custom_function_register(&tolower_function);
00687         res |= ast_custom_function_register(&toupper_function);
00688    res |= ast_custom_function_register(&sprintf_function);
00689 
00690    return res;
00691 }
00692 
00693 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "String handling dialplan functions");

Generated on Fri Aug 24 02:22:15 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1