Debian Codegraph @

src/modules/frontend/corba/dcf-textimpl.c

raw
1 /*
2 * cdebconf frontend, corba servant, text frontend implementation
3 */
4
5 #include "common.h"
6 #include "template.h"
7 #include "question.h"
8 #include "frontend.h"
9 #include "database.h"
10 #include "strutl.h"
11
12 #include <ctype.h>
13 #include <fcntl.h>
14 #include <signal.h>
15 #include <string.h>
16 #include <termios.h>
17 #include <unistd.h>
18 #include <sys/ioctl.h>
19 #include <sys/stat.h>
20 #include <sys/types.h>
21
22 #include <ORBitservices/CosNaming.h>
23 #include <libgnorba/gnorba.h>
24 #include <gnome.h>
25
26 #include "dcf.h"
27
28 /*** App-specific servant structures ***/
29
30 typedef struct {
31 POA_Debconf_Frontend servant;
32 PortableServer_POA poa;
33
34 } impl_POA_Debconf_Frontend;
35
36 /*** Implementation stub prototypes ***/
37
38 static void impl_Debconf_Frontend__destroy(impl_POA_Debconf_Frontend *
39 servant, CORBA_Environment * ev);
40
41 static CORBA_boolean
42 impl_Debconf_Frontend_Boolean(impl_POA_Debconf_Frontend * servant,
43 CORBA_char * prompt, CORBA_Environment * ev);
44
45 static CORBA_unsigned_long_long
46 impl_Debconf_Frontend_Multiselect(impl_POA_Debconf_Frontend * servant,
47 CORBA_unsigned_short count,
48 Debconf_Frontend_selects * choices,
49 CORBA_Environment * ev);
50
51 static void
52 impl_Debconf_Frontend_Note(impl_POA_Debconf_Frontend * servant,
53 CORBA_char * note, CORBA_Environment * ev);
54
55 static CORBA_char *impl_Debconf_Frontend_Password(impl_POA_Debconf_Frontend *
56 servant,
57 CORBA_char * prompt,
58 CORBA_Environment * ev);
59
60 static CORBA_unsigned_short
61 impl_Debconf_Frontend_Select(impl_POA_Debconf_Frontend * servant,
62 CORBA_unsigned_short count,
63 Debconf_Frontend_selects * choices,
64 CORBA_Environment * ev);
65
66 static CORBA_char *impl_Debconf_Frontend_String(impl_POA_Debconf_Frontend *
67 servant, CORBA_char * prompt,
68 CORBA_Environment * ev);
69
70 static CORBA_char *impl_Debconf_Frontend_Text(impl_POA_Debconf_Frontend *
71 servant, CORBA_char * prompt,
72 CORBA_Environment * ev);
73
74 /*** epv structures ***/
75
76 static PortableServer_ServantBase__epv impl_Debconf_Frontend_base_epv = {
77 NULL, /* _private data */
78 NULL, /* finalize routine */
79 NULL, /* default_POA routine */
80 };
81 static POA_Debconf_Frontend__epv impl_Debconf_Frontend_epv = {
82 NULL, /* _private */
83
84 (gpointer) & impl_Debconf_Frontend_Boolean,
85
86 (gpointer) & impl_Debconf_Frontend_Multiselect,
87
88 (gpointer) & impl_Debconf_Frontend_Note,
89
90 (gpointer) & impl_Debconf_Frontend_Password,
91
92 (gpointer) & impl_Debconf_Frontend_Select,
93
94 (gpointer) & impl_Debconf_Frontend_String,
95
96 (gpointer) & impl_Debconf_Frontend_Text,
97
98 };
99
100 /*** vepv structures ***/
101
102 static POA_Debconf_Frontend__vepv impl_Debconf_Frontend_vepv = {
103 &impl_Debconf_Frontend_base_epv,
104 &impl_Debconf_Frontend_epv,
105 };
106
107 /*** Stub implementations ***/
108
109 static Debconf_Frontend
110 impl_Debconf_Frontend__create(PortableServer_POA poa, CORBA_Environment * ev)
111 {
112 Debconf_Frontend retval;
113 impl_POA_Debconf_Frontend *newservant;
114 PortableServer_ObjectId *objid;
115
116 newservant = g_new0(impl_POA_Debconf_Frontend, 1);
117 newservant->servant.vepv = &impl_Debconf_Frontend_vepv;
118 newservant->poa = poa;
119 POA_Debconf_Frontend__init((PortableServer_Servant) newservant, ev);
120 objid = PortableServer_POA_activate_object(poa, newservant, ev);
121 CORBA_free(objid);
122 retval = PortableServer_POA_servant_to_reference(poa, newservant, ev);
123
124 return retval;
125 }
126
127 static void
128 impl_Debconf_Frontend__destroy(impl_POA_Debconf_Frontend * servant,
129 CORBA_Environment * ev)
130 {
131 PortableServer_ObjectId *objid;
132
133 objid = PortableServer_POA_servant_to_id(servant->poa, servant, ev);
134 PortableServer_POA_deactivate_object(servant->poa, objid, ev);
135 CORBA_free(objid);
136
137 POA_Debconf_Frontend__fini((PortableServer_Servant) servant, ev);
138 g_free(servant);
139 }
140
141 static CORBA_boolean
142 impl_Debconf_Frontend_Boolean(impl_POA_Debconf_Frontend * servant,
143 CORBA_char * prompt, CORBA_Environment * ev)
144 {
145 CORBA_boolean retval;
146
147 return retval;
148 }
149
150 static CORBA_unsigned_long_long
151 impl_Debconf_Frontend_Multiselect(impl_POA_Debconf_Frontend * servant,
152 CORBA_unsigned_short count,
153 Debconf_Frontend_selects * choices,
154 CORBA_Environment * ev)
155 {
156 CORBA_unsigned_long_long retval;
157
158 return retval;
159 }
160
161 static void
162 impl_Debconf_Frontend_Note(impl_POA_Debconf_Frontend * servant,
163 CORBA_char * note, CORBA_Environment * ev)
164 {
165 }
166
167 static CORBA_char *
168 impl_Debconf_Frontend_Password(impl_POA_Debconf_Frontend * servant,
169 CORBA_char * prompt, CORBA_Environment * ev)
170 {
171 CORBA_char *retval;
172
173 return retval;
174 }
175
176 static CORBA_unsigned_short
177 impl_Debconf_Frontend_Select(impl_POA_Debconf_Frontend * servant,
178 CORBA_unsigned_short count,
179 Debconf_Frontend_selects * choices,
180 CORBA_Environment * ev)
181 {
182 CORBA_unsigned_short retval;
183
184 return retval;
185 }
186
187 static CORBA_char *
188 impl_Debconf_Frontend_String(impl_POA_Debconf_Frontend * servant,
189 CORBA_char * prompt, CORBA_Environment * ev)
190 {
191 CORBA_char *retval;
192
193 return retval;
194 }
195
196 static CORBA_char *
197 impl_Debconf_Frontend_Text(impl_POA_Debconf_Frontend * servant,
198 CORBA_char * prompt, CORBA_Environment * ev)
199 {
200 CORBA_char *retval;
201 char *out = '\0';
202 char buf[1024];
203 int sz = 1;
204
205 printf(_("Enter . on a line by itself when you are done\n"));
206 while (fgets(buf, sizeof(buf), stdin)) {
207 if (strcmp(buf, ".\n") == 0) break;
208 sz += strlen(buf);
209 out = (char *) realloc(out, sz);
210 memcpy(out + sz - strlen(buf) - 1, buf, strlen(buf));
211 }
212 out[sz-1] = 0;
213 retval = CORBA_string_dup((CORBA_char *) out);
214 free(out);
215
216 return retval;
217 }