Skip to content

Commit

Permalink
math: new module to collect math functions
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Apr 14, 2023
1 parent ab67d11 commit 2cf7d05
Show file tree
Hide file tree
Showing 6 changed files with 416 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/modules/math/Makefile
@@ -0,0 +1,9 @@
#
# WARNING: do not run this directly, it should be run by the main Makefile

include ../../Makefile.defs
auto_gen=
NAME=math.so
LIBS=

include ../../Makefile.modules
106 changes: 106 additions & 0 deletions src/modules/math/README
@@ -0,0 +1,106 @@
MATH Module

Daniel-Constantin Mierla

<miconda@gmail.com>

Edited by

Daniel-Constantin Mierla

<miconda@gmail.com>

Copyright � 2023 asipto.com
__________________________________________________________________

Table of Contents

1. Admin Guide

1. Overview
2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

3. Functions

3.1. pow(base, power, res)
3.2. log(x, res)

List of Examples

1.1. pow usage
1.2. log usage

Chapter 1. Admin Guide

Table of Contents

1. Overview
2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

3. Functions

3.1. pow(base, power, res)
3.2. log(x, res)

1. Overview

This module provides a collection of functions for math operations.

Note that the result values are casted to intger (long value), being
the type supported by the config variables.

2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

2.1. Kamailio Modules

The following modules must be loaded before this module:
* none

2.2. External Libraries or Applications

The following libraries or applications must be installed before
running Kamailio with this module loaded:
* none

3. Functions

3.1. pow(base, power, res)
3.2. log(x, res)

3.1. pow(base, power, res)

The exponentiation function, computing the base raised to power,
storing in res.

This function can be used from ANY_ROUTE.

Example 1.1. pow usage
...
pow("2", "10", "$var(res)");
$var(base) = 2;
$var(power) = 10;
pow("$var(base)", "$var(power)", "$var(res)");
...

3.2. log(x, res)

The function computes the natural logarithm of x and stores the result
in res.

This function can be used from ANY_ROUTE.

Example 1.2. log usage
...
log("10", "$var(res)");
$var(x) = 10;
pow("$var(x)", "$var(res)");
...
4 changes: 4 additions & 0 deletions src/modules/math/doc/Makefile
@@ -0,0 +1,4 @@
docs = math.xml

docbook_dir = ../../../../doc/docbook
include $(docbook_dir)/Makefile.module
36 changes: 36 additions & 0 deletions src/modules/math/doc/math.xml
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;

]>

<book>
<bookinfo>
<title>MATH Module</title>
<productname class="trade">kamailio.org</productname>
<authorgroup>
<author>
<firstname>Daniel-Constantin</firstname>
<surname>Mierla</surname>
<email>miconda@gmail.com</email>
</author>
<editor>
<firstname>Daniel-Constantin</firstname>
<surname>Mierla</surname>
<email>miconda@gmail.com</email>
</editor>
</authorgroup>
<copyright>
<year>2023</year>
<holder>asipto.com</holder>
</copyright>
</bookinfo>
<toc></toc>

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="math_admin.xml"/>

</book>
106 changes: 106 additions & 0 deletions src/modules/math/doc/math_admin.xml
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;

]>
<!-- Module User's Guide -->

<chapter>

<title>&adminguide;</title>

<section>
<title>Overview</title>
<para>
This module provides a collection of functions for math operations.
</para>
<para>
Note that the result values are casted to intger (long value), being
the type supported by the config variables.
</para>
</section>

<section>
<title>Dependencies</title>
<section>
<title>&kamailio; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>none</emphasis>
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed before running
&kamailio; with this module loaded:
<itemizedlist>
<listitem>
<para>
<emphasis>none</emphasis>
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>

<section>
<title>Functions</title>
<section id="math.f.pow">
<title>
<function moreinfo="none">pow(base, power, res)</function>
</title>
<para>
The exponentiation function, computing the base raised to power, storing
in res.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>pow</function> usage</title>
<programlisting format="linespecific">
...
pow("2", "10", "$var(res)");
$var(base) = 2;
$var(power) = 10;
pow("$var(base)", "$var(power)", "$var(res)");
...
</programlisting>
</example>
</section>
<section id="math.f.log">
<title>
<function moreinfo="none">log(x, res)</function>
</title>
<para>
The function computes the natural logarithm of x and stores the result
in res.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>log</function> usage</title>
<programlisting format="linespecific">
...
log("10", "$var(res)");
$var(x) = 10;
pow("$var(x)", "$var(res)");
...
</programlisting>
</example>
</section>
</section>
</chapter>

0 comments on commit 2cf7d05

Please sign in to comment.