[BACK]Return to xdeb.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / parse

Annotation of OpenXM_contrib2/asir2000/parse/xdeb.c, Revision 1.17

1.3       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
1.4       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.3       noro       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.17    ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/parse/xdeb.c,v 1.16 2016/08/24 00:52:51 noro Exp $
1.3       noro       49: */
1.15      fujimoto   50: #if defined(VISUAL) || defined(__MINGW32__)
1.1       noro       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: {
1.17    ! noro       71:   static int debug_gui_invoked = 0;
1.1       noro       72:
1.17    ! noro       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);
1.1       noro       86: }
                     87:
                     88: #else /* VISUAL_LIB */
                     89: void show_debug_window(int on)
                     90: {}
                     91: #endif
                     92: #else /* VISUAL */
1.11      noro       93: #if defined(DO_PLOT)
1.1       noro       94: /*
1.17    ! noro       95:  *  xdeb.c --- Asir Debug interface.
1.1       noro       96:  *
1.17    ! noro       97:  *    akashi@sy.ssl.fujitsu.co.jp
1.1       noro       98:  */
                     99: #include <X11/Intrinsic.h>
                    100: #include <X11/StringDefs.h>
                    101: #include <X11/Shell.h>
                    102: #include <X11/Xaw/Dialog.h>
1.17    ! noro      103: #include  <stdio.h>
1.16      noro      104: #include <stdlib.h>
1.1       noro      105:
                    106: static XrmOptionDescRec options[] = {
1.17    ! noro      107:   {"-reverse","*reverse",XrmoptionNoArg,"on"},
        !           108:   {"-fg","*foreground",XrmoptionSepArg,NULL},
        !           109:   {"-bg","*background",XrmoptionSepArg,NULL},
1.1       noro      110: };
                    111:
                    112: static String fallback[] = {
1.17    ! noro      113:   "*Dialog*baseTranslations:#override <Key>Return: done()",
        !           114:   NULL
1.1       noro      115: };
                    116:
                    117: static void Done();
1.13      noro      118: static void Quit();
1.1       noro      119: static void SetSelected();
1.5       noro      120: static void SetDismiss();
1.1       noro      121:
                    122: static XtActionsRec actions_table[] = {
1.17    ! noro      123:   {"done",Done},
        !           124:   {"quit",Quit},
1.1       noro      125: };
                    126:
                    127: char debug_cmd[BUFSIZ];
                    128:
1.17    ! noro      129: static Widget    toplevel, mainwin, cmdwin;
        !           130: static XtAppContext  app_con;
1.1       noro      131: static int done;
                    132: static Display *display;
                    133:
                    134: void get_cmd();
                    135:
1.8       noro      136: static void Done(Widget w,XEvent *e,String *p,Cardinal *n)
1.1       noro      137: {
1.17    ! noro      138:   SetSelected(w,0,0);
1.1       noro      139: }
                    140:
1.8       noro      141: static void SetSelected(Widget w,XtPointer cld,XtPointer cad)
1.1       noro      142: {
1.17    ! noro      143:   Arg    arg[5];
        !           144:   char *cmd;
1.1       noro      145:
1.17    ! noro      146:   done = 1;
        !           147:   cmd = XawDialogGetValueString(cmdwin);
        !           148:   strcpy(debug_cmd,cmd);
        !           149:   XtSetArg(arg[0], XtNvalue, "");
        !           150:   XtSetValues(cmdwin, arg, 1);
1.1       noro      151: }
                    152:
1.8       noro      153: static void SetDismiss(Widget w,XtPointer cld,XtPointer cad)
1.5       noro      154: {
1.17    ! noro      155:   Arg    arg[5];
        !           156:   char *cmd;
1.5       noro      157:
1.17    ! noro      158:   done = 1;
        !           159:   cmd = XawDialogGetValueString(cmdwin);
        !           160:   strcpy(debug_cmd,"quit");
        !           161:   XtSetArg(arg[0], XtNvalue, "");
        !           162:   XtSetValues(cmdwin, arg, 1);
1.5       noro      163: }
                    164:
1.12      noro      165: static Atom wm_delete_window;
1.13      noro      166: static void Quit(Widget w, XEvent *ev, String *params,Cardinal *nparams)
1.12      noro      167: {
1.17    ! noro      168:   XBell(XtDisplay(w),0);
1.12      noro      169: }
                    170:
1.8       noro      171: void init_cmdwin()
1.1       noro      172: {
1.17    ! noro      173:   Arg    arg[5];
        !           174:   int argc=0;
        !           175:   char *argv[1];
        !           176:   int n;
        !           177:   char *d;
        !           178:   char hostname[BUFSIZ],title[BUFSIZ];
        !           179:   extern char displayname[];
        !           180:   extern int do_server_in_X11;
        !           181:   static int is_init = 0;
        !           182:
        !           183:   if ( is_init )
        !           184:     return;
        !           185:   if ( !displayname[0] ) {
        !           186:     d = (char *)getenv("DISPLAY");
        !           187:     if ( d )
        !           188:       strcpy(displayname,d);
        !           189:     else
        !           190:       do_server_in_X11 = 0;
        !           191:   }
        !           192:   gethostname(hostname, BUFSIZ);
        !           193:   sprintf(title,"Asir debugger:%s",hostname);
        !           194:   if ( displayname[0] ) {
        !           195:     argv[0] = 0;
        !           196:     XtToolkitInitialize();
        !           197:     app_con = XtCreateApplicationContext();
        !           198:     XtAppAddActions(app_con,actions_table, XtNumber(actions_table));
        !           199:     XtAppSetFallbackResources(app_con,fallback);
        !           200:     display = XtOpenDisplay(app_con,displayname,title,title,
        !           201:       options,XtNumber(options),&argc,argv);
        !           202:     toplevel = XtAppCreateShell(0,title,applicationShellWidgetClass,
        !           203:       display,0,0);
        !           204:     n = 0;
        !           205:     wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
        !           206:       False);
        !           207:
        !           208:     XtSetArg(arg[n],XtNiconName,title); n++;
        !           209:     XtSetArg(arg[n], XtNwidth, 360); n++;
        !           210:     mainwin = XtCreatePopupShell("shell",topLevelShellWidgetClass,
        !           211:       toplevel,arg,n);
        !           212:     XtOverrideTranslations(mainwin,
        !           213:           XtParseTranslationTable("<Message>WM_PROTOCOLS: quit()"));
        !           214:   /*
        !           215:    *  Command line
        !           216:    */
        !           217:     cmdwin = XtCreateManagedWidget("cmdwin", dialogWidgetClass,
        !           218:       mainwin, NULL, 0);
        !           219:     XawDialogAddButton(cmdwin,"Execute",SetSelected,"Execute");
        !           220:     XawDialogAddButton(cmdwin,"Dismiss",SetDismiss,"Dismiss");
        !           221:     n = 0;
        !           222:     XtSetArg(arg[n], XtNlabel, "Command : "); n++;
        !           223:     XtSetArg(arg[n], XtNvalue, ""); n++;
        !           224:     XtSetValues(cmdwin, arg, n);
        !           225:     XtRealizeWidget(mainwin);
        !           226:     XSetWMProtocols(XtDisplay(mainwin),XtWindow(mainwin),
        !           227:       &wm_delete_window,1);
        !           228:   }
        !           229:   is_init = 1;
1.1       noro      230: }
                    231:
1.8       noro      232: void show_debug_window(int on)
1.1       noro      233: {
1.17    ! noro      234:   XEvent ev;
1.1       noro      235:
1.17    ! noro      236:   init_cmdwin();
        !           237:   if ( mainwin ) {
        !           238:     if ( on )
        !           239:       XtPopup(mainwin,XtGrabNone);
        !           240:     else
        !           241:       XtPopdown(mainwin);
        !           242:     XFlush(display);
        !           243:     while ( XtAppPending(app_con) ) {
        !           244:       XtAppNextEvent(app_con,&ev);
        !           245:       XtDispatchEvent(&ev);
        !           246:     }
        !           247:   }
1.1       noro      248: }
                    249:
1.8       noro      250: void get_line(char *buf)
1.1       noro      251: {
1.17    ! noro      252:   XEvent ev;
1.1       noro      253:
1.17    ! noro      254:   done = 0;
        !           255:   while ( !done ) {
        !           256:     XtAppNextEvent(app_con,&ev);
        !           257:     XtDispatchEvent(&ev);
        !           258:   }
        !           259:   strcpy(buf,debug_cmd);
1.1       noro      260: }
1.2       noro      261: #else /* DO_PLOT */
1.8       noro      262: void init_cmdwin() {}
1.2       noro      263:
1.8       noro      264: void show_debug_window(int on)
1.2       noro      265: {}
                    266:
1.8       noro      267: void get_line(buf)
1.2       noro      268: char *buf;
                    269: {}
                    270: #endif /* DO_PLOT */
1.1       noro      271: #endif /* VISUAL */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>