~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/barclass.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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