1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ |
---|
2 | #include <stdio.h> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <string.h> |
---|
5 | #include "empty.h" |
---|
6 | #include <bonobo-activation/bonobo-activation.h> |
---|
7 | |
---|
8 | int |
---|
9 | main (int argc, char *argv[]) |
---|
10 | { |
---|
11 | Bonobo_ServerInfoList *result; |
---|
12 | CORBA_Environment ev; |
---|
13 | char *query; |
---|
14 | char **sort_criteria; |
---|
15 | int i; |
---|
16 | |
---|
17 | CORBA_exception_init (&ev); |
---|
18 | bonobo_activation_init (argc, argv); |
---|
19 | |
---|
20 | sort_criteria = NULL; |
---|
21 | |
---|
22 | if (argc > 1) { |
---|
23 | query = argv[1]; |
---|
24 | if (argc > 2) { |
---|
25 | int i; |
---|
26 | int num_conditions; |
---|
27 | |
---|
28 | num_conditions = argc - 2; |
---|
29 | |
---|
30 | printf ("Number of sort criteria: %d\n", |
---|
31 | num_conditions); |
---|
32 | |
---|
33 | sort_criteria = |
---|
34 | g_malloc (sizeof (char *) * |
---|
35 | (num_conditions + 1)); |
---|
36 | |
---|
37 | for (i = 0; i < num_conditions; i++) { |
---|
38 | sort_criteria[i] = g_strdup (argv[i + 2]); |
---|
39 | puts (sort_criteria[i]); |
---|
40 | } |
---|
41 | |
---|
42 | sort_criteria[num_conditions] = NULL; |
---|
43 | } |
---|
44 | } else { |
---|
45 | query = "repo_ids.has('IDL:Empty:1.0')"; |
---|
46 | } |
---|
47 | |
---|
48 | /* putenv("Bonobo_BARRIER_INIT=1"); */ |
---|
49 | result = bonobo_activation_query (query, sort_criteria, &ev); |
---|
50 | |
---|
51 | /* result = bonobo_activation_query ("iid == 'OAFIID:Empty:19991025'", NULL, &ev); */ |
---|
52 | |
---|
53 | if (ev._major != CORBA_NO_EXCEPTION) { |
---|
54 | if (ev._major == CORBA_USER_EXCEPTION) { |
---|
55 | if (!strcmp (ev._id, ex_Bonobo_GeneralError)) { |
---|
56 | Bonobo_GeneralError *err = CORBA_exception_value (&ev); |
---|
57 | printf ("An exception '%s' occured\n", err->description); |
---|
58 | } else { |
---|
59 | printf ("An unknown user exception ('%s') " |
---|
60 | "occured\n", ev._id); |
---|
61 | } |
---|
62 | } else if (ev._major == CORBA_SYSTEM_EXCEPTION) { |
---|
63 | printf ("A system exception ('%s') occured\n", ev._id); |
---|
64 | } else { |
---|
65 | g_assert_not_reached (); |
---|
66 | } |
---|
67 | } else if (result == NULL) { |
---|
68 | puts ("NULL result failed"); |
---|
69 | } else { |
---|
70 | printf ("number of results: %d\n", result->_length); |
---|
71 | |
---|
72 | for (i = 0; i < result->_length; i++) { |
---|
73 | puts ((result->_buffer[i]).iid); |
---|
74 | } |
---|
75 | CORBA_free (result); |
---|
76 | } |
---|
77 | |
---|
78 | CORBA_exception_free (&ev); |
---|
79 | |
---|
80 | if (bonobo_activation_debug_shutdown ()) { |
---|
81 | return 0; |
---|
82 | } else { |
---|
83 | return 1; |
---|
84 | } |
---|
85 | } |
---|