2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: excutil.c /main/3 1996/04/08 15:51:03 cde-fuj $ */
25 * (c) Copyright 1995 FUJITSU LIMITED
26 * This is source code modified by FUJITSU LIMITED under the Joint
27 * Development Agreement for the CDEnext PST.
28 * This is unpublished proprietary source code of FUJITSU LIMITED
33 extern char *maintitle;
35 Widget excCreatePushButton(Widget parent, String name, String label,
36 XtCallbackProc callback_func,
37 XtPointer client_data)
45 xms = XmStringCreateLocalized(label);
46 XtSetArg(args[n], XmNlabelString, xms); n++;
47 widget = XmCreatePushButton(parent, name, args, n);
49 XtAddCallback(widget, XmNactivateCallback,
50 (XtCallbackProc) callback_func,
51 (XtPointer) client_data);
52 XtManageChild(widget);
57 void excerror(Exc_data * ed, int excerrno, char * funcname, char * func)
62 fprintf(stderr, "dtudcexch:memory allocation error\n");
66 fprintf(stderr, "dtudcexch:UDC is not defined in current locale\n");
72 void dialogokCB(Widget widget, int * ans, XtPointer call_data)
74 /* ok button pushed */
78 void dialogcancelCB(Widget widget, int * ans, XtPointer call_data)
80 /* cancel button pushed */
84 void AskUser(Widget parent, Exc_data * ed, char *msg, int *r, char * type)
85 /* If ok button pushed, *r = 1. */
86 /* If cancel button pushed(if exists), *r = 2. */
95 message = XmStringCreateLocalized(msg);
96 XtSetArg(args[n], XmNmessageString, message); n++;
97 XtSetArg(args[n], XmNtitle, maintitle); n++;
98 XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
99 if (strcmp(type, "warning") == 0) {
100 dialog = XmCreateWarningDialog(parent, type, args, n);
101 } else if (strcmp(type, "error") == 0) {
102 dialog = XmCreateErrorDialog(parent, type, args, n);
103 XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
104 } else if (strcmp(type, "information") == 0) {
105 dialog = XmCreateInformationDialog(parent, type, args, n);
106 XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
107 } else if (strcmp(type, "question") == 0) {
108 dialog = XmCreateQuestionDialog(parent, type, args, n);
110 fprintf(stderr, "error in AskUser\n");
112 XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
113 XmStringFree(message);
114 XtAddCallback(dialog, XmNokCallback, (XtCallbackProc) dialogokCB,
116 XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc) dialogcancelCB,
118 XtManageChild(dialog);
120 XtAppProcessEvent(ed->app, XtIMAll);
121 XSync(XtDisplay(dialog), 0);
124 XSync(XtDisplay(dialog), 0);
125 XmUpdateDisplay(dialog);
128 int beki(int n, int num)
133 for (i=0; i<num; i++)
144 if ((strlen(num)==6)&&(strncmp(num,"0x",2)==0))
151 if (('0'<= *c)&&(*c <= '9'))
152 n = n + ((*c - '0')*beki(16,i));
153 else if (('a' <= *c)&&(*c <= 'f'))
154 n = n + ((*c - 'a'+10)*beki(16,i));
156 Ecs("error in c2h.here");
164 char * renge2num(char * renge)
168 num = (char *) calloc(7, sizeof(char));
170 strncpy(num,renge,6);
175 void Ecs(char * string)
177 fprintf(stderr,"%s\n",string);
181 fprintf(stderr,"%d\n",data);
184 void freecsrec(UDCcsREC *rec)
186 if (rec->charset != NULL)
188 if (rec->udcrenge != NULL)
192 void freecslist(int n, UDCcsREC *rec)
198 for (i = 0; i < n; i++)
210 void freeExcdata(Exc_data *ed)
215 /* Don't free ed->toplevel */
217 if (ed->locale != NULL)
220 if (ed->cslist != NULL)
223 if (ed->xlfdname != NULL)
226 if (ed->style != NULL)
229 if (ed->size != NULL)
232 /* Don't free ed->fontfile */
234 if (ed->bdffile != NULL)
237 if (ed->udcrenge != NULL)
240 if (ed->gpf_code_list != NULL)
241 free(ed->gpf_code_list);
243 if (ed->bdf_code_list != NULL)
244 free(ed->bdf_code_list);
246 if (ed->comment_list != NULL)
247 free(ed->comment_list);
252 void Ecss(char * s1, char * s2)
254 fprintf(stderr,"%s is %s\n", s1, s2);
256 void Ecsd(char * s1, int i)
258 fprintf(stderr,"%s = %d\n", s1, i);
261 void checkdata(Exc_data *ed)
266 /* Don't free ed->toplevel */
268 if (ed->locale != NULL)
269 Ecss("ed->locale", ed->locale);
271 Ecsd("ed->csnum", ed->csnum);
273 if (ed->xlfdname != NULL)
274 Ecss("ed->xlfdname",ed->xlfdname);
276 if (ed->fontfile != NULL)
277 Ecss("ed->fontfile",ed->fontfile);
279 if (ed->bdffile != NULL)
280 Ecss("ed->bdffile",ed->bdffile);
282 if (ed->udcrenge != NULL)
283 Ecss("ed->udcrenge",ed->udcrenge);
285 Ecsd("ed->code_num", ed->code_num);
288 void excterminate(Exc_data * ed)
294 void excexit(Exc_data * ed)
299 void freeld(ListData *ld)
305 if (ld->allcode != NULL)
307 if (ld->existcode != NULL)
309 if (ld->existcode_c != NULL) {
310 cp = ld->existcode_c;
311 for (i = 0; i < ld->existcode_num; i++) {
316 free(ld->existcode_c);
322 int bigger(int num1, int num2)
330 int smaller(int num1, int num2)