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

« back to all changes in this revision

Viewing changes to test/typelib-dump.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 <string.h>
 
4
#include <sys/types.h>
 
5
#include <dirent.h>
 
6
 
 
7
#include <orbit/orbit.h>
 
8
 
 
9
#include "../src/orb/orb-core/orb-core-private.h"
 
10
 
 
11
static void
 
12
dump_tc (CORBA_TypeCode tc, int ident)
 
13
{
 
14
        char *id_str;
 
15
 
 
16
        id_str = g_new (char, ident + 1);
 
17
        memset (id_str, ' ', ident);
 
18
        id_str [ident] = '\0';
 
19
 
 
20
        printf ("%sType %12s: '%s'\n",
 
21
                id_str, TC_CORBA_TCKind->subnames [tc->kind],
 
22
                tc->repo_id);
 
23
}
 
24
 
 
25
static void
 
26
dump_iface (ORBit_IInterface *iface)
 
27
{
 
28
        int i;
 
29
 
 
30
        printf ("Interface '%s', %d methods\n",
 
31
                iface->tc->repo_id, iface->methods._length);
 
32
 
 
33
        for (i = 0; i < iface->base_interfaces._length; i++) {
 
34
                int j;
 
35
 
 
36
                printf ("  ");
 
37
                for (j = 0; j < i + 1; j++)
 
38
                        printf ("  ");
 
39
 
 
40
                printf ("%s\n", iface->base_interfaces._buffer [i]);
 
41
        }
 
42
 
 
43
        printf ("\n");
 
44
 
 
45
        if (iface->methods._length > 0) {
 
46
                for (i = 0; i < iface->methods._length; i++) {
 
47
                        ORBit_IMethod *m = &iface->methods._buffer [i];
 
48
                        
 
49
                        printf ("  %s (%d args, %s) %s%s\n",
 
50
                                m->name, m->arguments._length,
 
51
                                m->contexts._length ? "has context," : "",
 
52
                                m->ret ? "returns " : "",
 
53
                                m->ret ? m->ret->repo_id : "");
 
54
                }
 
55
        } else
 
56
                printf ("No methods\n");
 
57
 
 
58
        printf ("\n\n");
 
59
}
 
60
 
 
61
static void
 
62
list_libs (void)
 
63
{
 
64
        int    i;
 
65
        char **paths;
 
66
 
 
67
        printf ("Installed type libraries:\n\n");
 
68
 
 
69
        paths = ORBit_get_typelib_paths ();
 
70
 
 
71
        for (i = 0; paths && paths [i]; i++) {
 
72
                DIR *dh;
 
73
                struct dirent *de;
 
74
 
 
75
                dh = opendir (paths [i]);
 
76
 
 
77
                if (!dh)
 
78
                        continue;
 
79
 
 
80
                printf ("%s:\n\n", paths [i]);
 
81
        
 
82
                for (de = readdir (dh); de; de = readdir (dh)) {
 
83
                        char *p, *str = g_strdup (de->d_name);
 
84
                        if ((p = strstr (str, "_module.la"))) {
 
85
                                *p = '\0';
 
86
                                printf ("\t%s\n", str);
 
87
                        }
 
88
                        g_free (str);
 
89
                }
 
90
 
 
91
                closedir (dh);
 
92
        }
 
93
 
 
94
        g_strfreev (paths);
 
95
}
 
96
 
 
97
int
 
98
main (int argc, char *argv [])
 
99
{
 
100
        int                              i;
 
101
        const char                      *name;
 
102
        CORBA_sequence_CORBA_TypeCode   *tcs;
 
103
        CORBA_sequence_ORBit_IInterface *ifaces;
 
104
 
 
105
        if (argc < 2) {
 
106
                list_libs ();
 
107
                return 0;
 
108
        }
 
109
 
 
110
        name = argv [argc - 1];
 
111
 
 
112
        if (!ORBit_small_load_typelib (name))
 
113
                g_error ("Can't find typelib of name '%s' in path", name);
 
114
 
 
115
        tcs = ORBit_small_get_types (name);
 
116
 
 
117
        if (!tcs || tcs->_length == 0)
 
118
                printf ("No types\n");
 
119
        else {
 
120
                printf ("%d types:\n", tcs->_length);
 
121
                for (i = 0; i < tcs->_length; i++)
 
122
                        dump_tc (tcs->_buffer [i], 0);
 
123
        }
 
124
 
 
125
        ifaces = ORBit_small_get_iinterfaces (name);
 
126
        if (!ifaces || ifaces->_length == 0)
 
127
                printf ("No IInterfaces\n");
 
128
        else {
 
129
                printf ("%d interfaces:\n", ifaces->_length);
 
130
                for (i = 0; i < ifaces->_length; i++)
 
131
                        dump_iface (&ifaces->_buffer [i]);
 
132
        }
 
133
 
 
134
        return 0;
 
135
}