diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/test/testclass.cc | |
parent | Initial commit. (diff) | |
download | ceph-upstream/16.2.11+ds.tar.xz ceph-upstream/16.2.11+ds.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/testclass.cc')
-rw-r--r-- | src/test/testclass.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/testclass.cc b/src/test/testclass.cc new file mode 100644 index 000000000..22a97be6d --- /dev/null +++ b/src/test/testclass.cc @@ -0,0 +1,57 @@ + + + +#include <iostream> +#include <string.h> +#include <stdlib.h> + +#include "objclass/objclass.h" + +CLS_VER(1,0) +CLS_NAME(test) + +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, r; + + cls_log("hello world"); + cls_log("indata=%s", indata); + + *outdata = (char *)cls_alloc(128); + for (i=0; i<strlen(indata) + 1; i++) { + if (indata[i] == '0') { + (*outdata)[i] = '*'; + } else { + (*outdata)[i] = indata[i]; + } + } + *outdatalen = strlen(*outdata) + 1; + cls_log("outdata=%s", *outdata); + + r = cls_call(ctx, "foo", "foo", *outdata, *outdatalen, outdata, outdatalen); + + return r; +} + +static cls_deps_t depend[] = {{"foo", "1.0"}, {"bar", "1.0"}, {NULL, NULL}}; + +extern "C" cls_deps_t *class_deps() +{ + return depend; +}; + +void class_init() +{ + cls_log("Loaded class test!"); + + cls_register("test", &h_class); + cls_register_method(h_class, "foo", foo_method, &h_foo); + + return; +} + |