aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_math.c
diff options
context:
space:
mode:
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2007-01-21 06:19:40 +0000
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2007-01-21 06:19:40 +0000
commit4be3c7e95f1f6c9bb4b172fdc1d833e9333f7cf5 (patch)
tree60827903a3eb045b8406d2a16d365f9cdccb6a1c /plugin_math.c
parent0f7cd40f369ec05a2fe8f829fa357217ca5eefb9 (diff)
downloadlcd4linux-4be3c7e95f1f6c9bb4b172fdc1d833e9333f7cf5.tar.gz
new function 'decode()'
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@754 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_math.c')
-rw-r--r--plugin_math.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/plugin_math.c b/plugin_math.c
index b74f188..c3748e1 100644
--- a/plugin_math.c
+++ b/plugin_math.c
@@ -114,6 +114,26 @@ static void my_ceil(RESULT * result, RESULT * arg)
SetResult(&result, R_NUMBER, &value);
}
+static void my_decode(RESULT * result, int argc, RESULT * argv[])
+{
+ int index;
+
+ if (argc < 2) {
+ error("decode(): wrong number of parameters");
+ SetResult(&result, R_STRING, "");
+ return;
+ }
+
+ index = R2N(argv[0]);
+
+ if (index < 0 || index >= argc-1) {
+ SetResult(&result, R_STRING, "");
+ return;
+ }
+
+ CopyResult (&result, argv[index+1]);
+}
+
int plugin_init_math(void)
{
@@ -138,6 +158,9 @@ int plugin_init_math(void)
AddFunction("floor", 1, my_floor);
AddFunction("ceil", 1, my_ceil);
+ /* decode */
+ AddFunction("decode", -1, my_decode);
+
return 0;
}