]> git.webhop.me Git - lcd4linux.git/commitdiff
new function 'decode()'
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 21 Jan 2007 06:19:40 +0000 (06:19 +0000)
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 21 Jan 2007 06:19:40 +0000 (06:19 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@754 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

evaluator.c
evaluator.h
plugin_math.c

index e2b103f08abf594f179bb98bd38d76ca0fe7ab96..aaebee971308c0d094550723eea12da2e2349470 100644 (file)
@@ -274,7 +274,7 @@ RESULT *SetResult(RESULT ** result, const int type, const void *value)
 }
 
 
-static RESULT *CopyResult(RESULT ** result, RESULT * value)
+RESULT *CopyResult(RESULT ** result, RESULT * value)
 {
     if (*result == NULL) {
        if ((*result = NewResult()) == NULL)
index 6b4cbca3edfb7bc69c48f264d9abc1950a68fd20..412aeec507fc58d93b07b76858584a76c1ec7fd1 100644 (file)
@@ -51,6 +51,7 @@ void DeleteFunctions(void);
 
 void DelResult(RESULT * result);
 RESULT *SetResult(RESULT ** result, const int type, const void *value);
+RESULT *CopyResult(RESULT ** result, RESULT * value);
 
 double R2N(RESULT * result);
 char *R2S(RESULT * result);
index b74f188f6d55e52c61d1ce9cef90e9a566bcc8a4..c3748e145ed596585e92c7c09fbd8e636307a380 100644 (file)
@@ -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;
 }