File: echo-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 (81 lines) | stat: -rw-r--r-- 1,730 bytes parent folder | download | duplicates (4)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include <stdlib.h>
#include <orb/orbit.h>

#include "echo.h"

Echo echo_client, bec;

#if 0
char theblah[4096];
#endif

int
main (int argc, char *argv[])
{
    CORBA_Environment ev;
    CORBA_ORB orb;
    CORBA_double 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]);

    echo_client = CORBA_ORB_string_to_object(orb, argv[1], &ev);
    if (!echo_client) {
	printf("Cannot bind to %s\n", argv[1]);
	return 1;
    }
#ifdef LOCATE_TEST
    ORBit_object_locate(echo_client, &ev);
    if(ev._major != CORBA_NO_EXCEPTION) {
    	printf("Couldn't locate that object! (Exception %d)\n", ev._major);
	return(1);
    }
#endif
    for(i = 0; i < niters; i++) {
	    g_snprintf(buf, sizeof(buf), "Hello, world [%d]", i);
	    bec = Echo_echoString(echo_client, buf, &rv, &ev);
	    if(ev._major != CORBA_NO_EXCEPTION) {
	      printf("we got exception %d from echoString!\n", ev._major);
	      return 1;
	    }

	    /* g_assert(echo_client == bec); */

	    CORBA_Object_release(echo_client, &ev);
	    if(ev._major != CORBA_NO_EXCEPTION) {
	      printf("we got exception %d from release!\n", ev._major);
	      return 1;
	    }
#if 0
	     else
	      g_message("[client] %g", rv);
#endif

	    echo_client = bec; bec = CORBA_OBJECT_NIL;
    }

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

    return 0;
}