}
-static RESULT *CopyResult(RESULT ** result, RESULT * value)
+RESULT *CopyResult(RESULT ** result, RESULT * value)
{
if (*result == NULL) {
if ((*result = NewResult()) == NULL)
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);
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)
{
AddFunction("floor", 1, my_floor);
AddFunction("ceil", 1, my_ceil);
+ /* decode */
+ AddFunction("decode", -1, my_decode);
+
return 0;
}