Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 182 of file func_math.c.

182 {
199};
@ EQFUNCTION
Definition: func_math.c:198
@ BITWISEORFUNCTION
Definition: func_math.c:193
@ BITWISEANDFUNCTION
Definition: func_math.c:191
@ LTEFUNCTION
Definition: func_math.c:197
@ SHRIGHTFUNCTION
Definition: func_math.c:190
@ POWFUNCTION
Definition: func_math.c:188
@ MODULUSFUNCTION
Definition: func_math.c:187
@ ADDFUNCTION
Definition: func_math.c:183
@ SHLEFTFUNCTION
Definition: func_math.c:189
@ GTEFUNCTION
Definition: func_math.c:196
@ BITWISEXORFUNCTION
Definition: func_math.c:192
@ DIVIDEFUNCTION
Definition: func_math.c:184
@ MULTIPLYFUNCTION
Definition: func_math.c:185
@ GTFUNCTION
Definition: func_math.c:194
@ LTFUNCTION
Definition: func_math.c:195
@ SUBTRACTFUNCTION
Definition: func_math.c:186

◆ TypeOfResult

Enumerator
FLOAT_RESULT 
INT_RESULT 
HEX_RESULT 
CHAR_RESULT 

Definition at line 201 of file func_math.c.

201 {
206};
@ CHAR_RESULT
Definition: func_math.c:205
@ INT_RESULT
Definition: func_math.c:203
@ FLOAT_RESULT
Definition: func_math.c:202
@ HEX_RESULT
Definition: func_math.c:204

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 751 of file func_math.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 751 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 611 of file func_math.c.

613{
614 double num1, response_num;
616 AST_APP_ARG(num1);
617 );
618
620
621 if (ast_strlen_zero(args.num1) || sscanf(args.num1, "%30lf", &num1) != 1) {
622 ast_log(LOG_WARNING, "Bad or missing argument for number: %s", args.num1);
623 return -1;
624 }
625
626 response_num = fabs(num1);
627 ast_debug(1, "%f is the absolute value of %f\n", response_num, num1);
628 if ((int) response_num == response_num) {
629 snprintf(buffer, buflen, "%d", (int) response_num);
630 } else {
631 snprintf(buffer, buflen, "%f", response_num);
632 }
633
634 return 0;
635}
#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 565 of file func_math.c.

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

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

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 751 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 451 of file func_math.c.

453{
454 int ret = -1;
455 int int_value = 0;
456 int modify_orig = 0;
457 const char *var;
458 char endchar = 0, returnvar[12]; /* If you need a variable longer than 11 digits - something is way wrong */
459
460 if (ast_strlen_zero(data)) {
461 ast_log(LOG_WARNING, "Syntax: %s(<data>) - missing argument!\n", cmd);
462 return -1;
463 }
464
465 if (!chan) {
466 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
467 return -1;
468 }
469
470 ast_channel_lock(chan);
471
472 if (!(var = pbx_builtin_getvar_helper(chan, data))) {
473 ast_log(LOG_NOTICE, "Failed to obtain variable %s, bailing out\n", data);
474 ast_channel_unlock(chan);
475 return -1;
476 }
477
478 if (ast_strlen_zero(var)) {
479 ast_log(LOG_NOTICE, "Variable %s doesn't exist - are you sure you wrote it correctly?\n", data);
480 ast_channel_unlock(chan);
481 return -1;
482 }
483
484 if (sscanf(var, "%30d%1c", &int_value, &endchar) == 0 || endchar != 0) {
485 ast_log(LOG_NOTICE, "The content of ${%s} is not a numeric value - bailing out!\n", data);
486 ast_channel_unlock(chan);
487 return -1;
488 }
489
490 /* now we'll actually do something useful */
491 if (!strcasecmp(cmd, "INC")) { /* Increment variable */
492 int_value++;
493 modify_orig = 1;
494 } else if (!strcasecmp(cmd, "DEC")) { /* Decrement variable */
495 int_value--;
496 modify_orig = 1;
497 }
498
499 if (snprintf(returnvar, sizeof(returnvar), "%d", int_value) > 0) {
500 pbx_builtin_setvar_helper(chan, data, returnvar);
501 if (modify_orig) {
502 ast_copy_string(buf, returnvar, len);
503 }
504 ret = 0;
505 } else {
506 pbx_builtin_setvar_helper(chan, data, "0");
507 if (modify_orig) {
508 ast_copy_string(buf, "0", len);
509 }
510 ast_log(LOG_NOTICE, "Variable %s refused to be %sREMENTED, setting value to 0", data, cmd);
511 ret = 0;
512 }
513
514 ast_channel_unlock(chan);
515
516 return ret;
517}
#define var
Definition: ast_expr2f.c:605
#define ast_channel_lock(chan)
Definition: channel.h:2970
#define ast_channel_unlock(chan)
Definition: channel.h:2971
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 736 of file func_math.c.

737{
738 int res = 0;
739
746 AST_TEST_REGISTER(test_MATH_function);
747
748 return res;
749}
static struct ast_custom_function increment_function
Definition: func_math.c:642
static struct ast_custom_function math_function
Definition: func_math.c:637
static struct ast_custom_function decrement_function
Definition: func_math.c:647
static struct ast_custom_function acf_min
Definition: func_math.c:652
static struct ast_custom_function acf_abs
Definition: func_math.c:664
static struct ast_custom_function acf_max
Definition: func_math.c:658
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1559
#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 208 of file func_math.c.

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

722{
723 int res = 0;
724
731 AST_TEST_UNREGISTER(test_MATH_function);
732
733 return res;
734}
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 751 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:611

Definition at line 664 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:565

Definition at line 658 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:519

Definition at line 652 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 751 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:451

Definition at line 647 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 642 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:208

Definition at line 637 of file func_math.c.

Referenced by load_module(), and unload_module().