1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ |
---|
2 | /* |
---|
3 | * bonobo_activation |
---|
4 | * |
---|
5 | * Copyright (C) 2000 Eazel, Inc. |
---|
6 | * |
---|
7 | * This library is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU General Public License as |
---|
9 | * published by the Free Software Foundation; either version 2 of the |
---|
10 | * License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This library is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | * General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this library; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
20 | * |
---|
21 | * Authors: Maciej Stachowiak <mjs@eazel.com> |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
25 | /* bonobo-activation-corba-extensions.c - CORBA utility functions |
---|
26 | */ |
---|
27 | |
---|
28 | #include <config.h> |
---|
29 | #include <stdio.h> |
---|
30 | #include <string.h> |
---|
31 | |
---|
32 | #include "server.h" |
---|
33 | |
---|
34 | #include "activation-server-corba-extensions.h" |
---|
35 | #include <bonobo-activation/bonobo-activation-i18n.h> |
---|
36 | |
---|
37 | char * |
---|
38 | activation_server_CORBA_Context_get_value (CORBA_Context ctx, |
---|
39 | const char *propname, |
---|
40 | const CORBA_char *exception_if_fail, |
---|
41 | CORBA_Environment *ev) |
---|
42 | { |
---|
43 | CORBA_NVList nvout; |
---|
44 | char *retval; |
---|
45 | CORBA_Environment local_ev; |
---|
46 | |
---|
47 | CORBA_exception_init (&local_ev); |
---|
48 | |
---|
49 | retval = NULL; |
---|
50 | |
---|
51 | CORBA_Context_get_values (ctx, NULL, 0, (char *) propname, &nvout, &local_ev); |
---|
52 | |
---|
53 | if (local_ev._major == CORBA_NO_EXCEPTION) { |
---|
54 | if (nvout->list->len > 0) { |
---|
55 | CORBA_NamedValue *nv; |
---|
56 | int i; |
---|
57 | |
---|
58 | nv = NULL; |
---|
59 | |
---|
60 | for (i = 0; i < nvout->list->len; i++) { |
---|
61 | nv = &g_array_index (nvout->list, |
---|
62 | CORBA_NamedValue, i); |
---|
63 | if (!strcmp (nv->name, propname)) break; |
---|
64 | } |
---|
65 | |
---|
66 | if (i < nvout->list->len) |
---|
67 | retval = g_strdup (*(char **) nv->argument._value); |
---|
68 | } |
---|
69 | |
---|
70 | CORBA_NVList_free (nvout, &local_ev); |
---|
71 | } else { |
---|
72 | if (exception_if_fail != NULL) { |
---|
73 | CORBA_exception_set (ev, |
---|
74 | CORBA_USER_EXCEPTION, |
---|
75 | exception_if_fail, |
---|
76 | NULL); |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | CORBA_exception_free (&local_ev); |
---|
81 | |
---|
82 | return retval; |
---|
83 | } |
---|
84 | |
---|
85 | |
---|