~ubuntu-branches/ubuntu/natty/orbit2/natty

« back to all changes in this revision

Viewing changes to test/ior-decode.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Waters
  • Date: 2002-03-25 17:24:03 UTC
  • Revision ID: james.westby@ubuntu.com-20020325172403-8lexv63608acfqgt
Tags: upstream-2.3.107
ImportĀ upstreamĀ versionĀ 2.3.107

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "config.h"
 
2
#include <stdio.h>
 
3
#include <orbit/orbit.h>
 
4
#include <ctype.h>
 
5
 
 
6
#include "../src/orb/orb-core/iop-profiles.h"
 
7
 
 
8
static void
 
9
print_objkey (ORBit_ObjectKey *objkey)
 
10
{
 
11
        int i;
 
12
        GString *str = g_string_sized_new (objkey->_length * 2 + 8);
 
13
 
 
14
        for (i = 0; i < objkey->_length; i++)
 
15
                g_string_append_printf (str, "%02x", objkey->_buffer [i]);
 
16
 
 
17
        printf ("(%d) '%s'", objkey->_length, str->str);
 
18
 
 
19
        g_string_free (str, TRUE);
 
20
}
 
21
 
 
22
static void
 
23
print_components(CORBA_Object obj, GSList *components)
 
24
{
 
25
  GSList *ltmp;
 
26
  for(ltmp = components; ltmp; ltmp = ltmp->next)
 
27
    {
 
28
      IOP_Component_info *c = ltmp->data;
 
29
 
 
30
      switch(c->component_type)
 
31
        {
 
32
        case IOP_TAG_COMPLETE_OBJECT_KEY:
 
33
          {
 
34
            printf("    IOP_TAG_COMPLETE_OBJECT_KEY: object_key ");
 
35
            print_objkey(obj->object_key);
 
36
            printf("\n");
 
37
          }
 
38
          break;
 
39
        case IOP_TAG_SSL_SEC_TRANS:
 
40
          {
 
41
            IOP_TAG_SSL_SEC_TRANS_info *sst = ltmp->data;
 
42
            printf("    IOP_TAG_SSL_SEC_TRANS: %d:%d port %d\n",
 
43
                   sst->target_supports, sst->target_requires,
 
44
                   sst->port);
 
45
          }
 
46
          break;
 
47
        case IOP_TAG_GENERIC_SSL_SEC_TRANS:
 
48
          {
 
49
            IOP_TAG_GENERIC_SSL_SEC_TRANS_info *sst = ltmp->data;
 
50
            printf("    IOP_TAG_GENERIC_SSL_SEC_TRANS: service %s\n",
 
51
                   sst->service);
 
52
          }
 
53
          break;
 
54
        default:
 
55
          printf("    Unknown component %#x\n",
 
56
                 c->component_type);
 
57
          break;
 
58
        }
 
59
      printf("\n");
 
60
    }
 
61
}
 
62
 
 
63
static void
 
64
print_iiop_version(GIOPVersion ver)
 
65
{
 
66
  switch(ver)
 
67
    {
 
68
    case GIOP_1_0:
 
69
      printf("GIOP 1.0");
 
70
      break;
 
71
    case GIOP_1_1:
 
72
      printf("GIOP 1.1");
 
73
      break;
 
74
    case GIOP_1_2:
 
75
      printf("GIOP 1.2");
 
76
      break;
 
77
    default:
 
78
      g_assert_not_reached();
 
79
      break;
 
80
    }
 
81
}
 
82
int main(int argc, char *argv[])
 
83
{
 
84
  CORBA_ORB orb;
 
85
  CORBA_Object obj;
 
86
  CORBA_Environment ev;
 
87
  GSList *ltmp;
 
88
 
 
89
  CORBA_exception_init(&ev);
 
90
 
 
91
  if(argc != 2)
 
92
    {
 
93
      fprintf(stderr, "Usage: ior-decode <IOR>\n");
 
94
      return 1;
 
95
    }
 
96
 
 
97
  orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
 
98
 
 
99
  obj = CORBA_ORB_string_to_object(orb, argv[1], &ev);
 
100
  if(ev._major)
 
101
    {
 
102
      fprintf(stderr, "Couldn't do string_to_object: %s\n",
 
103
              CORBA_exception_id(&ev));
 
104
      return 2;
 
105
    }
 
106
  printf("Object ID: %s\n", g_quark_to_string (obj->type_qid));
 
107
  for(ltmp = obj->profile_list; ltmp; ltmp = ltmp->next)
 
108
    {
 
109
      IOP_Profile_info *pi = ltmp->data;
 
110
      switch(pi->profile_type)
 
111
        {
 
112
        case IOP_TAG_INTERNET_IOP:
 
113
          {
 
114
            IOP_TAG_INTERNET_IOP_info *iiop = ltmp->data;
 
115
 
 
116
            printf("IOP_TAG_INTERNET_IOP: ");
 
117
            print_iiop_version(iiop->iiop_version);
 
118
            printf(" %s:%d\n",
 
119
                   iiop->host, iiop->port);
 
120
            printf("    object_key ");
 
121
            print_objkey(obj->object_key);
 
122
            printf("\n");
 
123
            print_components(obj, iiop->components);
 
124
          }
 
125
          break;
 
126
        case IOP_TAG_GENERIC_IOP:
 
127
          {
 
128
            IOP_TAG_GENERIC_IOP_info *giop = ltmp->data;
 
129
            printf("IOP_TAG_GENERIC_IOP: ");
 
130
            print_iiop_version(giop->iiop_version);
 
131
            printf("[%s] %s:%s\n",
 
132
                   giop->proto,
 
133
                   giop->host, giop->service);
 
134
            print_components(obj, giop->components);
 
135
          }
 
136
          break;
 
137
        case IOP_TAG_MULTIPLE_COMPONENTS:
 
138
          {
 
139
            IOP_TAG_MULTIPLE_COMPONENTS_info *mci = ltmp->data;
 
140
            printf("IOP_TAG_MULTIPLE_COMPONENTS:\n");
 
141
            print_components(obj, mci->components);
 
142
          }
 
143
          break;
 
144
        case IOP_TAG_ORBIT_SPECIFIC:
 
145
          {
 
146
            IOP_TAG_ORBIT_SPECIFIC_info *osi = ltmp->data;
 
147
            printf("IOP_TAG_ORBIT_SPECIFIC: usock %s IPv6 port %d\n",
 
148
                   osi->unix_sock_path, osi->ipv6_port);
 
149
            printf("    object_key ");
 
150
            print_objkey(obj->object_key);
 
151
            printf("\n");
 
152
          }
 
153
          break;
 
154
        default:
 
155
          printf("Unknown profile type %#x\n", pi->profile_type);
 
156
          break;
 
157
        }
 
158
      printf("\n");
 
159
    }
 
160
  
 
161
  return 0;
 
162
}