Annotation of OpenXM_contrib2/asir2018/parse/xdeb.c, Revision 1.2
1.1 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.2 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2018/parse/xdeb.c,v 1.1 2018/09/19 05:45:08 noro Exp $
1.1 noro 49: */
50: #if defined(VISUAL) || defined(__MINGW32__)
51: #if defined(VISUAL_LIB)
52: #include <stdio.h>
53: #include <stdlib.h>
54: #include <windows.h>
55: #include <signal.h>
56: #include <process.h>
57:
58: #define FROMASIR_EXIT 0
59: #define FROMASIR_TEXT 1
60: #define FROMASIR_HEAPSIZE 2
61: #define FROMASIR_SHOW 3
62: #define FROMASIR_HIDE 4
63:
64: void show_debug_window(int);
65: int create_debug_gui();
66: void set_debug_handles(int);
67: void get_rootdir(char *,int);
68:
69: void show_debug_window(int on)
70: {
71: static int debug_gui_invoked = 0;
72:
73: /* debug_gui_invoked < 0 : failed to invoke debug GUI */
74: if ( debug_gui_invoked < 0 )
75: return;
76: if ( !debug_gui_invoked ) {
77: if ( !on )
78: return;
79: else if ( create_debug_gui() < 0 ) {
80: debug_gui_invoked = -1;
81: return;
82: }
83: debug_gui_invoked = 1;
84: }
85: set_debug_handles(on);
86: }
87:
88: #else /* VISUAL_LIB */
89: void show_debug_window(int on)
90: {}
91: #endif
92: #else /* VISUAL */
93: #if defined(DO_PLOT)
94: /*
95: * xdeb.c --- Asir Debug interface.
96: *
97: * akashi@sy.ssl.fujitsu.co.jp
98: */
99: #include <X11/Intrinsic.h>
100: #include <X11/StringDefs.h>
101: #include <X11/Shell.h>
102: #include <X11/Xaw/Dialog.h>
103: #include <stdio.h>
104: #include <stdlib.h>
105: #include <unistd.h>
106:
107: static XrmOptionDescRec options[] = {
108: {"-reverse","*reverse",XrmoptionNoArg,"on"},
109: {"-fg","*foreground",XrmoptionSepArg,NULL},
110: {"-bg","*background",XrmoptionSepArg,NULL},
111: };
112:
113: static String fallback[] = {
114: "*Dialog*baseTranslations:#override <Key>Return: done()",
115: NULL
116: };
117:
118: static void Done();
119: static void Quit();
120: static void SetSelected();
121: static void SetDismiss();
122:
123: static XtActionsRec actions_table[] = {
124: {"done",Done},
125: {"quit",Quit},
126: };
127:
128: char debug_cmd[BUFSIZ];
129:
130: static Widget toplevel, mainwin, cmdwin;
131: static XtAppContext app_con;
132: static int done;
133: static Display *display;
134:
135: void get_cmd();
136:
137: static void Done(Widget w,XEvent *e,String *p,Cardinal *n)
138: {
139: SetSelected(w,0,0);
140: }
141:
142: static void SetSelected(Widget w,XtPointer cld,XtPointer cad)
143: {
144: Arg arg[5];
145: char *cmd;
146:
147: done = 1;
148: cmd = XawDialogGetValueString(cmdwin);
149: strcpy(debug_cmd,cmd);
150: XtSetArg(arg[0], XtNvalue, "");
151: XtSetValues(cmdwin, arg, 1);
152: }
153:
154: static void SetDismiss(Widget w,XtPointer cld,XtPointer cad)
155: {
156: Arg arg[5];
157: char *cmd;
158:
159: done = 1;
160: cmd = XawDialogGetValueString(cmdwin);
161: strcpy(debug_cmd,"quit");
162: XtSetArg(arg[0], XtNvalue, "");
163: XtSetValues(cmdwin, arg, 1);
164: }
165:
166: static Atom wm_delete_window;
167: static void Quit(Widget w, XEvent *ev, String *params,Cardinal *nparams)
168: {
169: XBell(XtDisplay(w),0);
170: }
171:
172: void init_cmdwin()
173: {
174: Arg arg[5];
175: int argc=0;
176: char *argv[1];
177: int n;
178: char *d;
179: char hostname[BUFSIZ],title[BUFSIZ];
180: extern char displayname[];
181: extern int do_server_in_X11;
182: static int is_init = 0;
183:
184: if ( is_init )
185: return;
186: if ( !displayname[0] ) {
187: d = (char *)getenv("DISPLAY");
188: if ( d )
189: strcpy(displayname,d);
190: else
191: do_server_in_X11 = 0;
192: }
193: gethostname(hostname, BUFSIZ);
194: sprintf(title,"Asir debugger:%s",hostname);
195: if ( displayname[0] ) {
196: argv[0] = 0;
197: XtToolkitInitialize();
198: app_con = XtCreateApplicationContext();
199: XtAppAddActions(app_con,actions_table, XtNumber(actions_table));
200: XtAppSetFallbackResources(app_con,fallback);
201: display = XtOpenDisplay(app_con,displayname,title,title,
202: options,XtNumber(options),&argc,argv);
203: toplevel = XtAppCreateShell(0,title,applicationShellWidgetClass,
204: display,0,0);
205: n = 0;
206: wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
207: False);
208:
209: XtSetArg(arg[n],XtNiconName,title); n++;
210: XtSetArg(arg[n], XtNwidth, 360); n++;
211: mainwin = XtCreatePopupShell("shell",topLevelShellWidgetClass,
212: toplevel,arg,n);
213: XtOverrideTranslations(mainwin,
214: XtParseTranslationTable("<Message>WM_PROTOCOLS: quit()"));
215: /*
216: * Command line
217: */
218: cmdwin = XtCreateManagedWidget("cmdwin", dialogWidgetClass,
219: mainwin, NULL, 0);
220: XawDialogAddButton(cmdwin,"Execute",SetSelected,"Execute");
221: XawDialogAddButton(cmdwin,"Dismiss",SetDismiss,"Dismiss");
222: n = 0;
223: XtSetArg(arg[n], XtNlabel, "Command : "); n++;
224: XtSetArg(arg[n], XtNvalue, ""); n++;
225: XtSetValues(cmdwin, arg, n);
226: XtRealizeWidget(mainwin);
227: XSetWMProtocols(XtDisplay(mainwin),XtWindow(mainwin),
228: &wm_delete_window,1);
229: }
230: is_init = 1;
231: }
232:
233: void show_debug_window(int on)
234: {
235: XEvent ev;
236:
237: init_cmdwin();
238: if ( mainwin ) {
239: if ( on )
240: XtPopup(mainwin,XtGrabNone);
241: else
242: XtPopdown(mainwin);
243: XFlush(display);
244: while ( XtAppPending(app_con) ) {
245: XtAppNextEvent(app_con,&ev);
246: XtDispatchEvent(&ev);
247: }
248: }
249: }
250:
1.2 ! noro 251: void xget_line(char *buf)
1.1 noro 252: {
253: XEvent ev;
254:
255: done = 0;
256: while ( !done ) {
257: XtAppNextEvent(app_con,&ev);
258: XtDispatchEvent(&ev);
259: }
260: strcpy(buf,debug_cmd);
261: }
262: #else /* DO_PLOT */
263: void init_cmdwin() {}
264:
265: void show_debug_window(int on)
266: {}
267:
1.2 ! noro 268: void xget_line(buf)
1.1 noro 269: char *buf;
270: {}
271: #endif /* DO_PLOT */
272: #endif /* VISUAL */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>