]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/forb/src/forbrun/tests/test_obj.c
forb: Add tests for forbrun
[frescor/frsh-forb.git] / src / forb / src / forbrun / tests / test_obj.c
1 #include <forb.h>
2 #include "test_obj.h"
3 #include <forb/executor.h>
4 #include <forb/object.h>
5 #include <forb/iop.h>
6 #include <stdio.h>
7
8 static CORBA_long printmsg(test_obj obj, CORBA_Environment *ev)
9 {
10         char *msg = forb_object_instance_data(obj);
11         return printf("%s\n", msg);
12 }
13
14 static const struct forb_test_obj_impl test_obj_impl = {
15         .printmsg = printmsg,
16 };
17
18
19 int forb_main(forb_orb orb, int argc, char *argv[])
20 {
21         test_obj testobj;
22         int ret;
23
24         if (argc < 2) {
25                 fprintf(stderr, "Usage: %s <string>\n", argv[0]);
26                 return 1;
27         }
28
29         testobj = forb_test_obj_new(orb, &test_obj_impl, argv[1]);
30         if (!testobj)
31                 return 1;
32
33         ret = forb_register_reference(testobj, "mytestobj");
34         if (ret) {
35                 fprintf(stderr, "%s: forb_register_reference(\"mytestobj\") failed\n",
36                         argv[0]);
37                 return 1;
38         }
39
40         forb_execute_object(testobj);
41         return 0;
42 }