File: empty-client.c

package info (click to toggle)
orbit 0.5.0-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,604 kB
  • ctags: 4,626
  • sloc: ansic: 37,930; sh: 7,508; yacc: 1,750; makefile: 877; lex: 366
file content (61 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdlib.h>
#include <orb/orbit.h>

#include "empty.h"

Empty empty_client;

int
main (int argc, char *argv[])
{
    CORBA_Environment ev;
    CORBA_ORB orb;
    CORBA_long rv;
    char buf[30];
    int i;

    int niters = 100;

    CORBA_exception_init(&ev);
    orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);

#if 0
    for(i = 0; i < (sizeof(theblah) - 1); i++)
	theblah[i] = 'a';
    theblah[sizeof(theblah) - 1] = '\0';
#endif

    if(argc < 2)
      {
	printf("Need a binding ID thing as argv[1]\n");
	return 1;
      }

    if(argc == 3)
	niters = atoi(argv[2]);

    empty_client = CORBA_ORB_string_to_object(orb, argv[1], &ev);
    if (!empty_client) {
	printf("Cannot bind to %s\n", argv[1]);
	return 1;
    }

    printf("corba = %d, empty = %d, foobar = %d\n",
	CORBA_Object_is_a(empty_client, "IDL:CORBA/Object:1.0", &ev),
	CORBA_Object_is_a(empty_client, "IDL:Empty:1.0", &ev),
	CORBA_Object_is_a(empty_client, "IDL:Foo/Bar:1.0", &ev));

    for(i = 0; i < niters; i++) {
	    Empty_doNothing(empty_client, &ev);
	    if(ev._major != CORBA_NO_EXCEPTION) {
	      printf("we got exception %d from doNothing!\n", ev._major);
	      return 1;
	    }
    }

    CORBA_Object_release(empty_client, &ev);
    CORBA_Object_release((CORBA_Object)orb, &ev);

    return 0;
}