Asterisk - The Open Source Telephony Project GIT-master-a358458
Enumerations | Functions | Variables
func_math.c File Reference

Math related dialplan function. More...

#include "asterisk.h"
#include <math.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/conversions.h"
#include "asterisk/app.h"
#include "asterisk/config.h"
#include "asterisk/test.h"
Include dependency graph for func_math.c:

Go to the source code of this file.

Enumerations

enum  TypeOfFunctions {
  ADDFUNCTION , DIVIDEFUNCTION , MULTIPLYFUNCTION , SUBTRACTFUNCTION ,
  MODULUSFUNCTION , POWFUNCTION , SHLEFTFUNCTION , SHRIGHTFUNCTION ,
  BITWISEANDFUNCTION , BITWISEXORFUNCTION , BITWISEORFUNCTION , GTFUNCTION ,
  LTFUNCTION , GTEFUNCTION , LTEFUNCTION , EQFUNCTION
}
 
enum  TypeOfResult { FLOAT_RESULT , INT_RESULT , HEX_RESULT , CHAR_RESULT }
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int acf_abs_exec (struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
 
static int acf_max_exec (struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
 
static int acf_min_exec (struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int crement_function_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int load_module (void)
 
static int math (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Mathematical dialplan function" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static struct ast_custom_function acf_abs
 
static struct ast_custom_function acf_max
 
static struct ast_custom_function acf_min
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_custom_function decrement_function
 
static struct ast_custom_function increment_function
 
static struct ast_custom_function math_function
 

Detailed Description

Math related dialplan function.

Author
Andy Powell
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Nir Simionovich nirs@.nosp@m.gree.nosp@m.nfiel.nosp@m.dtec.nosp@m.h.net
Naveen Albert aster.nosp@m.isk@.nosp@m.phrea.nosp@m.knet.nosp@m..org

Definition in file func_math.c.

Enumeration Type Documentation

◆ TypeOfFunctions

Enumerator
ADDFUNCTION 
DIVIDEFUNCTION 
MULTIPLYFUNCTION 
SUBTRACTFUNCTION 
MODULUSFUNCTION 
POWFUNCTION 
SHLEFTFUNCTION 
SHRIGHTFUNCTION 
BITWISEANDFUNCTION 
BITWISEXORFUNCTION 
BITWISEORFUNCTION 
GTFUNCTION 
LTFUNCTION 
GTEFUNCTION 
LTEFUNCTION 
EQFUNCTION 

Definition at line 176 of file func_math.c.

176 {
193};
@ EQFUNCTION
Definition: func_math.c:192
@ BITWISEORFUNCTION
Definition: func_math.c:187
@ BITWISEANDFUNCTION
Definition: func_math.c:185
@ LTEFUNCTION
Definition: func_math.c:191
@ SHRIGHTFUNCTION
Definition: func_math.c:184
@ POWFUNCTION
Definition: func_math.c:182
@ MODULUSFUNCTION
Definition: func_math.c:181
@ ADDFUNCTION
Definition: func_math.c:177
@ SHLEFTFUNCTION
Definition: func_math.c:183
@ GTEFUNCTION
Definition: func_math.c:190
@ BITWISEXORFUNCTION
Definition: func_math.c:186
@ DIVIDEFUNCTION
Definition: func_math.c:178
@ MULTIPLYFUNCTION
Definition: func_math.c:179
@ GTFUNCTION
Definition: func_math.c:188
@ LTFUNCTION
Definition: func_math.c:189
@ SUBTRACTFUNCTION
Definition: func_math.c:180

◆ TypeOfResult

Enumerator
FLOAT_RESULT 
INT_RESULT 
HEX_RESULT 
CHAR_RESULT 

Definition at line 195 of file func_math.c.

195 {
200};
@ CHAR_RESULT
Definition: func_math.c:199
@ INT_RESULT
Definition: func_math.c:197
@ FLOAT_RESULT
Definition: func_math.c:196
@ HEX_RESULT
Definition: func_math.c:198

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 745 of file func_math.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 745 of file func_math.c.

◆ acf_abs_exec()

static int acf_abs_exec ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buffer,
size_t  buflen 
)
static

Definition at line 605 of file func_math.c.

607{
608 double num1, response_num;
610 AST_APP_ARG(num1);
611 );
612
614
615 if (ast_strlen_zero(args.num1) || sscanf(args.num1, "%30lf", &num1) != 1) {
616 ast_log(LOG_WARNING, "Bad or missing argument for number: %s", args.num1);
617 return -1;
618 }
619
620 response_num = fabs(num1);
621 ast_debug(1, "%f is the absolute value of %f\n", response_num, num1);
622 if ((int) response_num == response_num) {
623 snprintf(buffer, buflen, "%d", (int) response_num);
624 } else {
625 snprintf(buffer, buflen, "%f", response_num);
626 }
627
628 return 0;
629}
#define ast_log
Definition: astobj2.c:42
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
const char * args

References args, AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strlen_zero(), and LOG_WARNING.

◆ acf_max_exec()

static int acf_max_exec ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buffer,
size_t  buflen 
)
static

Definition at line 559 of file func_math.c.

561{
562 double num1, num2, response_num = 0;
564 AST_APP_ARG(num1);
565 AST_APP_ARG(num2);
566 );
567
569
570 if (ast_strlen_zero(args.num1) && ast_strlen_zero(args.num2)) {
571 ast_log(LOG_ERROR, "Missing argument for number(s).");
572 return -1;
573 }
574
575 if (ast_strlen_zero(args.num1)) {
576 response_num = -1; /* couldn't read num1 successfully */
577 } else if (sscanf(args.num1, "%30lf", &num1) != 1) {
578 ast_log(LOG_WARNING, "'%s' is not a valid number\n", args.num1);
579 return -1;
580 }
581
582 if (ast_strlen_zero(args.num2)) {
583 num2 = num1; /* num1 must be a valid integer here */
584 } else if (sscanf(args.num2, "%30lf", &num2) != 1) {
585 ast_log(LOG_WARNING, "'%s' is not a valid number\n", args.num2);
586 return -1;
587 }
588
589 if (response_num == -1) { /* could only read num2 */
590 response_num = num2;
591 } else {
592 response_num = (num1 < num2) ? num2 : num1;
593 }
594
595 ast_debug(1, "%f is the maximum of [%f,%f]\n", response_num, num1, num2);
596 if ((int) response_num == response_num) {
597 snprintf(buffer, buflen, "%d", (int) response_num);
598 } else {
599 snprintf(buffer, buflen, "%f", response_num);
600 }
601
602 return 0;
603}
#define LOG_ERROR

References args, AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strlen_zero(), LOG_ERROR, and LOG_WARNING.

◆ acf_min_exec()

static int acf_min_exec ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buffer,
size_t  buflen 
)
static

Definition at line 513 of file func_math.c.

515{
516 double num1, num2, response_num = 0;
518 AST_APP_ARG(num1);
519 AST_APP_ARG(num2);
520 );
521
523
524 if (ast_strlen_zero(args.num1) && ast_strlen_zero(args.num2)) {
525 ast_log(LOG_ERROR, "Missing argument for number(s).");
526 return -1;
527 }
528
529 if (ast_strlen_zero(args.num1)) {
530 response_num = -1; /* couldn't read num1 successfully */
531 } else if (sscanf(args.num1, "%30lf", &num1) != 1) {
532 ast_log(LOG_WARNING, "'%s' is not a valid number\n", args.num1);
533 return -1;
534 }
535
536 if (ast_strlen_zero(args.num2)) {
537 num2 = num1; /* num1 must be a valid integer here */
538 } else if (sscanf(args.num2, "%30lf", &num2) != 1) {
539 ast_log(LOG_WARNING, "'%s' is not a valid number\n", args.num2);
540 return -1;
541 }
542
543 if (response_num == -1) { /* could only read num2 */
544 response_num = num2;
545 } else {
546 response_num = (num1 > num2) ? num2 : num1;
547 }
548
549 ast_debug(1, "%f is the minimum of [%f,%f]\n", response_num, num1, num2);
550 if ((int) response_num == response_num) {
551 snprintf(buffer, buflen, "%d", (int) response_num);
552 } else {
553 snprintf(buffer, buflen, "%f", response_num);
554 }
555
556 return 0;
557}

References args, AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strlen_zero(), LOG_ERROR, and LOG_WARNING.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 745 of file func_math.c.

◆ crement_function_read()

static int crement_function_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 445 of file func_math.c.

447{
448 int ret = -1;
449 int int_value = 0;
450 int modify_orig = 0;
451 const char *var;
452 char endchar = 0, returnvar[12]; /* If you need a variable longer than 11 digits - something is way wrong */
453
454 if (ast_strlen_zero(data)) {
455 ast_log(LOG_WARNING, "Syntax: %s(<data>) - missing argument!\n", cmd);
456 return -1;
457 }
458
459 if (!chan) {
460 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
461 return -1;
462 }
463
464 ast_channel_lock(chan);
465
466 if (!(var = pbx_builtin_getvar_helper(chan, data))) {
467 ast_log(LOG_NOTICE, "Failed to obtain variable %s, bailing out\n", data);
468 ast_channel_unlock(chan);
469 return -1;
470 }
471
472 if (ast_strlen_zero(var)) {
473 ast_log(LOG_NOTICE, "Variable %s doesn't exist - are you sure you wrote it correctly?\n", data);
474 ast_channel_unlock(chan);
475 return -1;
476 }
477
478 if (sscanf(var, "%30d%1c", &int_value, &endchar) == 0 || endchar != 0) {
479 ast_log(LOG_NOTICE, "The content of ${%s} is not a numeric value - bailing out!\n", data);
480 ast_channel_unlock(chan);
481 return -1;
482 }
483
484 /* now we'll actually do something useful */
485 if (!strcasecmp(cmd, "INC")) { /* Increment variable */
486 int_value++;
487 modify_orig = 1;
488 } else if (!strcasecmp(cmd, "DEC")) { /* Decrement variable */
489 int_value--;
490 modify_orig = 1;
491 }
492
493 if (snprintf(returnvar, sizeof(returnvar), "%d", int_value) > 0) {
494 pbx_builtin_setvar_helper(chan, data, returnvar);
495 if (modify_orig) {
496 ast_copy_string(buf, returnvar, len);
497 }
498 ret = 0;
499 } else {
500 pbx_builtin_setvar_helper(chan, data, "0");
501 if (modify_orig) {
502 ast_copy_string(buf, "0", len);
503 }
504 ast_log(LOG_NOTICE, "Variable %s refused to be %sREMENTED, setting value to 0", data, cmd);
505 ret = 0;
506 }
507
508 ast_channel_unlock(chan);
509
510 return ret;
511}
#define var
Definition: ast_expr2f.c:605
#define ast_channel_lock(chan)
Definition: channel.h:2922
#define ast_channel_unlock(chan)
Definition: channel.h:2923
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define LOG_NOTICE
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

References ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_log, ast_strlen_zero(), buf, len(), LOG_NOTICE, LOG_WARNING, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), and var.

◆ load_module()

static int load_module ( void  )
static

Definition at line 730 of file func_math.c.

731{
732 int res = 0;
733
740 AST_TEST_REGISTER(test_MATH_function);
741
742 return res;
743}
static struct ast_custom_function increment_function
Definition: func_math.c:636
static struct ast_custom_function math_function
Definition: func_math.c:631
static struct ast_custom_function decrement_function
Definition: func_math.c:641
static struct ast_custom_function acf_min
Definition: func_math.c:646
static struct ast_custom_function acf_abs
Definition: func_math.c:658
static struct ast_custom_function acf_max
Definition: func_math.c:652
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558
#define AST_TEST_REGISTER(cb)
Definition: test.h:127

References acf_abs, acf_max, acf_min, ast_custom_function_register, AST_TEST_REGISTER, decrement_function, increment_function, and math_function.

◆ math()

static int math ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buf,
size_t  len 
)
static

Definition at line 202 of file func_math.c.

204{
205 double fnum1;
206 double fnum2;
207 double ftmp = 0;
208 char *op;
209 int iaction = -1;
210 int type_of_result = FLOAT_RESULT;
211 char *mvalue1, *mvalue2 = NULL, *mtype_of_result;
212 int negvalue1 = 0;
214 AST_APP_ARG(argv0);
215 AST_APP_ARG(argv1);
216 );
217
218 if (ast_strlen_zero(parse)) {
219 ast_log(LOG_WARNING, "Syntax: MATH(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
220 return -1;
221 }
222
224
225 if (args.argc < 1) {
226 ast_log(LOG_WARNING, "Syntax: MATH(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
227 return -1;
228 }
229
230 mvalue1 = args.argv0;
231
232 if (mvalue1[0] == '-') {
233 negvalue1 = 1;
234 mvalue1++;
235 }
236
237 if ((op = strchr(mvalue1, '*'))) {
238 iaction = MULTIPLYFUNCTION;
239 *op = '\0';
240 } else if ((op = strchr(mvalue1, '/'))) {
241 iaction = DIVIDEFUNCTION;
242 *op = '\0';
243 } else if ((op = strchr(mvalue1, '%'))) {
244 iaction = MODULUSFUNCTION;
245 *op = '\0';
246 } else if ((op = strchr(mvalue1, '^'))) {
247 iaction = POWFUNCTION;
248 *op = '\0';
249 } else if ((op = strstr(mvalue1, "AND"))) {
250 iaction = BITWISEANDFUNCTION;
251 *op = '\0';
252 op += 2;
253 } else if ((op = strstr(mvalue1, "XOR"))) {
254 iaction = BITWISEXORFUNCTION;
255 *op = '\0';
256 op += 2;
257 } else if ((op = strstr(mvalue1, "OR"))) {
258 iaction = BITWISEORFUNCTION;
259 *op = '\0';
260 ++op;
261 } else if ((op = strchr(mvalue1, '>'))) {
262 iaction = GTFUNCTION;
263 *op = '\0';
264 if (*(op + 1) == '=') {
265 iaction = GTEFUNCTION;
266 ++op;
267 } else if (*(op + 1) == '>') {
268 iaction = SHRIGHTFUNCTION;
269 ++op;
270 }
271 } else if ((op = strchr(mvalue1, '<'))) {
272 iaction = LTFUNCTION;
273 *op = '\0';
274 if (*(op + 1) == '=') {
275 iaction = LTEFUNCTION;
276 ++op;
277 } else if (*(op + 1) == '<') {
278 iaction = SHLEFTFUNCTION;
279 ++op;
280 }
281 } else if ((op = strchr(mvalue1, '='))) {
282 *op = '\0';
283 if (*(op + 1) == '=') {
284 iaction = EQFUNCTION;
285 ++op;
286 } else
287 op = NULL;
288 } else if ((op = strchr(mvalue1, '+'))) {
289 iaction = ADDFUNCTION;
290 *op = '\0';
291 } else if ((op = strchr(mvalue1, '-'))) { /* subtraction MUST always be last, in case we have a negative second number */
292 iaction = SUBTRACTFUNCTION;
293 *op = '\0';
294 }
295
296 if (op)
297 mvalue2 = op + 1;
298
299 /* detect wanted type of result */
300 mtype_of_result = args.argv1;
301 if (mtype_of_result) {
302 if (!strcasecmp(mtype_of_result, "float")
303 || !strcasecmp(mtype_of_result, "f"))
304 type_of_result = FLOAT_RESULT;
305 else if (!strcasecmp(mtype_of_result, "int")
306 || !strcasecmp(mtype_of_result, "i"))
307 type_of_result = INT_RESULT;
308 else if (!strcasecmp(mtype_of_result, "hex")
309 || !strcasecmp(mtype_of_result, "h"))
310 type_of_result = HEX_RESULT;
311 else if (!strcasecmp(mtype_of_result, "char")
312 || !strcasecmp(mtype_of_result, "c"))
313 type_of_result = CHAR_RESULT;
314 else {
315 ast_log(LOG_WARNING, "Unknown type of result requested '%s'.\n",
316 mtype_of_result);
317 return -1;
318 }
319 }
320
321 if (!mvalue2) {
323 "Supply all the parameters - just this once, please\n");
324 return -1;
325 }
326
327 if (sscanf(mvalue1, "%30lf", &fnum1) != 1) {
328 ast_log(LOG_WARNING, "'%s' is not a valid number\n", mvalue1);
329 return -1;
330 }
331
332 if (sscanf(mvalue2, "%30lf", &fnum2) != 1) {
333 ast_log(LOG_WARNING, "'%s' is not a valid number\n", mvalue2);
334 return -1;
335 }
336
337 if (negvalue1)
338 fnum1 = 0 - fnum1;
339
340 switch (iaction) {
341 case ADDFUNCTION:
342 ftmp = fnum1 + fnum2;
343 break;
344 case DIVIDEFUNCTION:
345 if (fnum2 <= 0)
346 ftmp = 0; /* can't do a divide by 0 */
347 else
348 ftmp = (fnum1 / fnum2);
349 break;
350 case MULTIPLYFUNCTION:
351 ftmp = (fnum1 * fnum2);
352 break;
353 case SUBTRACTFUNCTION:
354 ftmp = (fnum1 - fnum2);
355 break;
356 case MODULUSFUNCTION:
357 {
358 int inum1 = fnum1;
359 int inum2 = fnum2;
360
361 if (inum2 == 0) {
362 ftmp = 0;
363 } else {
364 ftmp = (inum1 % inum2);
365 }
366
367 break;
368 }
369 case POWFUNCTION:
370 ftmp = pow(fnum1, fnum2);
371 break;
372 case SHLEFTFUNCTION:
373 {
374 int inum1 = fnum1;
375 int inum2 = fnum2;
376
377 ftmp = (inum1 << inum2);
378 break;
379 }
380 case SHRIGHTFUNCTION:
381 {
382 int inum1 = fnum1;
383 int inum2 = fnum2;
384
385 ftmp = (inum1 >> inum2);
386 break;
387 }
389 {
390 int inum1 = fnum1;
391 int inum2 = fnum2;
392 ftmp = (inum1 & inum2);
393 break;
394 }
396 {
397 int inum1 = fnum1;
398 int inum2 = fnum2;
399 ftmp = (inum1 ^ inum2);
400 break;
401 }
403 {
404 int inum1 = fnum1;
405 int inum2 = fnum2;
406 ftmp = (inum1 | inum2);
407 break;
408 }
409 case GTFUNCTION:
410 ast_copy_string(buf, (fnum1 > fnum2) ? "TRUE" : "FALSE", len);
411 break;
412 case LTFUNCTION:
413 ast_copy_string(buf, (fnum1 < fnum2) ? "TRUE" : "FALSE", len);
414 break;
415 case GTEFUNCTION:
416 ast_copy_string(buf, (fnum1 >= fnum2) ? "TRUE" : "FALSE", len);
417 break;
418 case LTEFUNCTION:
419 ast_copy_string(buf, (fnum1 <= fnum2) ? "TRUE" : "FALSE", len);
420 break;
421 case EQFUNCTION:
422 ast_copy_string(buf, (fnum1 == fnum2) ? "TRUE" : "FALSE", len);
423 break;
424 default:
426 "Something happened that neither of us should be proud of %d\n",
427 iaction);
428 return -1;
429 }
430
431 if (iaction < GTFUNCTION || iaction > EQFUNCTION) {
432 if (type_of_result == FLOAT_RESULT)
433 snprintf(buf, len, "%f", ftmp);
434 else if (type_of_result == INT_RESULT)
435 snprintf(buf, len, "%i", (int) ftmp);
436 else if (type_of_result == HEX_RESULT)
437 snprintf(buf, len, "%x", (unsigned int) ftmp);
438 else if (type_of_result == CHAR_RESULT)
439 snprintf(buf, len, "%c", (unsigned char) ftmp);
440 }
441
442 return 0;
443}
#define NULL
Definition: resample.c:96

References ADDFUNCTION, args, AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strlen_zero(), BITWISEANDFUNCTION, BITWISEORFUNCTION, BITWISEXORFUNCTION, buf, CHAR_RESULT, DIVIDEFUNCTION, EQFUNCTION, FLOAT_RESULT, GTEFUNCTION, GTFUNCTION, HEX_RESULT, INT_RESULT, len(), LOG_WARNING, LTEFUNCTION, LTFUNCTION, MODULUSFUNCTION, MULTIPLYFUNCTION, NULL, POWFUNCTION, SHLEFTFUNCTION, SHRIGHTFUNCTION, and SUBTRACTFUNCTION.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 715 of file func_math.c.

716{
717 int res = 0;
718
725 AST_TEST_UNREGISTER(test_MATH_function);
726
727 return res;
728}
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128

References acf_abs, acf_max, acf_min, ast_custom_function_unregister(), AST_TEST_UNREGISTER, decrement_function, increment_function, and math_function.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Mathematical dialplan function" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 745 of file func_math.c.

◆ acf_abs

struct ast_custom_function acf_abs
static
Initial value:
= {
.name = "ABS",
.read = acf_abs_exec,
.read_max = 12,
}
static int acf_abs_exec(struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
Definition: func_math.c:605

Definition at line 658 of file func_math.c.

Referenced by load_module(), and unload_module().

◆ acf_max

struct ast_custom_function acf_max
static
Initial value:
= {
.name = "MAX",
.read = acf_max_exec,
.read_max = 12,
}
static int acf_max_exec(struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
Definition: func_math.c:559

Definition at line 652 of file func_math.c.

Referenced by load_module(), and unload_module().

◆ acf_min

struct ast_custom_function acf_min
static
Initial value:
= {
.name = "MIN",
.read = acf_min_exec,
.read_max = 12,
}
static int acf_min_exec(struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
Definition: func_math.c:513

Definition at line 646 of file func_math.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 745 of file func_math.c.

◆ decrement_function

struct ast_custom_function decrement_function
static
Initial value:
= {
.name = "DEC",
}
static int crement_function_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Definition: func_math.c:445

Definition at line 641 of file func_math.c.

Referenced by load_module(), and unload_module().

◆ increment_function

struct ast_custom_function increment_function
static
Initial value:
= {
.name = "INC",
}

Definition at line 636 of file func_math.c.

Referenced by load_module(), and unload_module().

◆ math_function

struct ast_custom_function math_function
static
Initial value:
= {
.name = "MATH",
.read = math
}
static int math(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_math.c:202

Definition at line 631 of file func_math.c.

Referenced by load_module(), and unload_module().