]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | ||
3 | ||
4 | #include <iostream> | |
5 | #include <string.h> | |
6 | #include <stdlib.h> | |
7 | ||
8 | #include "objclass/objclass.h" | |
9 | ||
10 | CLS_VER(1,0) | |
11 | CLS_NAME(bar) | |
12 | ||
13 | cls_handle_t h_class; | |
14 | ||
15 | cls_method_handle_t h_foo; | |
16 | ||
17 | int foo_method(cls_method_context_t ctx, char *indata, int datalen, | |
18 | char **outdata, int *outdatalen) | |
19 | { | |
20 | int i; | |
21 | ||
22 | cls_log("hello world, this is bar"); | |
23 | cls_log("indata=%s", indata); | |
24 | ||
25 | *outdata = (char *)malloc(128); | |
26 | for (i=0; i<strlen(indata) + 1; i++) { | |
27 | if (indata[i] == '0') { | |
28 | (*outdata)[i] = '*'; | |
29 | } else { | |
30 | (*outdata)[i] = indata[i]; | |
31 | } | |
32 | } | |
33 | *outdatalen = strlen(*outdata) + 1; | |
34 | cls_log("outdata=%s", *outdata); | |
35 | ||
36 | return 0; | |
37 | } | |
38 | ||
39 | void class_init() | |
40 | { | |
41 | cls_log("Loaded bar class!"); | |
42 | ||
43 | cls_register("bar", &h_class); | |
44 | cls_register_method(h_class, "bar", foo_method, &h_foo); | |
45 | ||
46 | return; | |
47 | } | |
48 |