diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/test/fooclass.cc | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/fooclass.cc')
-rw-r--r-- | src/test/fooclass.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/test/fooclass.cc b/src/test/fooclass.cc new file mode 100644 index 000000000..2db2d815b --- /dev/null +++ b/src/test/fooclass.cc @@ -0,0 +1,48 @@ + + + +#include <iostream> +#include <string.h> +#include <stdlib.h> + +#include "objclass/objclass.h" + +CLS_VER(1,0) +CLS_NAME(foo) + +cls_handle_t h_class; + +cls_method_handle_t h_foo; + +int foo_method(cls_method_context_t ctx, char *indata, int datalen, + char **outdata, int *outdatalen) +{ + int i; + + cls_log("hello world, this is foo"); + cls_log("indata=%s", indata); + + *outdata = (char *)malloc(128); + for (i=0; i<strlen(indata) + 1; i++) { + if (indata[i] == '1') { + (*outdata)[i] = 'I'; + } else { + (*outdata)[i] = indata[i]; + } + } + *outdatalen = strlen(*outdata) + 1; + cls_log("outdata=%s", *outdata); + + return 0; +} + +void class_init() +{ + cls_log("Loaded foo class!"); + + cls_register("foo", &h_class); + cls_register_method(h_class, "foo", foo_method, &h_foo); + + return; +} + |