home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * xdbx - X Window System interface to dbx
- *
- * Copyright 1989 The University of Texas at Austin
- *
- * Author: Po Cheung
- * Date: March 10, 1989
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation. The University of Texas at Austin makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- ******************************************************************************/
-
-
- #include "global.h"
-
- #define Offset(field) (XtOffset(XdbxResources *, field))
-
- Widget toplevel, /* top level widget */
- vpane, /* parent of all subwindows */
- titleBar, /* label widget displaying title */
- fileWindow, /* form widget containing : */
- fileLabel, /* file name of displayed text */
- lineLabel, /* line number of caret */
- sourceWidget, /* form widget, parent of sourceWindow */
- sourceWindow, /* asciiString widget, source file */
- messageWindow, /* label widget, execution status */
- commandWindow, /* command panel, box widget */
- dialogWindow; /* dialog window, asciiString widget */
-
- XdbxResources app_resources; /* application resources of xdbx */
- char *xdbxinit = "xdbx.XXXXXX";
- Boolean Homedir;
-
-
- static XtResource resources[] = {
- {"shellWidth", "ShellWidth", XtRDimension, sizeof(Dimension),
- Offset(shellWidth), XtRString, "550"},
- {"lineLabelWidth", "LineLabelWidth", XtRDimension, sizeof(Dimension),
- Offset(lineLabelWidth), XtRString, "70"},
- {"sourceHeight", "SourceHeight", XtRDimension, sizeof(Dimension),
- Offset(sourceHeight), XtRString, "320"},
- {"leftMargin", "LeftMargin", XtRDimension, sizeof(Dimension),
- Offset(leftMargin), XtRString, "35"},
- {"dialogHeight", "DialogHeight", XtRDimension, sizeof(Dimension),
- Offset(dialogHeight), XtRString, "200"},
- {"dialogMinHeight", "DialogMinHeight", XtRDimension, sizeof(Dimension),
- Offset(dialogMinHeight), XtRString, "15"},
- {"messageHeight", "MessageHeight", XtRDimension, sizeof(Dimension),
- Offset(messageHeight), XtRString, "30"},
- {"buttonWidth", "ButtonWidth", XtRDimension, sizeof(Dimension),
- Offset(buttonWidth), XtRString, "50"},
- {"commandHSpace", "CommandHSpace", XtRDimension, sizeof(Dimension),
- Offset(commandHSpace), XtRString, "14"},
- {"commandVSpace", "CommandVSpace", XtRDimension, sizeof(Dimension),
- Offset(commandVSpace), XtRString, "10"},
- {"commandMinHeight", "CommmandMinHeight", XtRDimension, sizeof(Dimension),
- Offset(commandMinHeight), XtRString, "70"},
- {"commandMaxHeight", "CommandMaxHeight", XtRDimension, sizeof(Dimension),
- Offset(commandMaxHeight), XtRString, "120"},
- {"columnSpacing", "ColumnSpacing", XtRDimension, sizeof(Dimension),
- Offset(columnSpacing), XtRString, "10"},
- {"filesPerColumn", "FilesPerColumn", XtRInt, sizeof(int),
- Offset(filesPerColumn), XtRString, "10"},
- {"noTitleBar", "NoTitleBar", XtRBoolean, sizeof(Boolean),
- Offset(noTitleBar), XtRImmediate, (caddr_t)False},
- {"stopForeground", "StopForeground", XtRPixel, sizeof(Pixel),
- Offset(stopForeground), XtRString, "Red"},
- {"arrowForeground", "ArrowForeground", XtRPixel, sizeof(Pixel),
- Offset(arrowForeground), XtRString, "Blue"},
- {"updownForeground", "UpdownForeground", XtRPixel, sizeof(Pixel),
- Offset(updownForeground), XtRString, "Blue"},
- };
-
- static XrmOptionDescRec options[] = {
- {"-r", "dbxopt_r", XrmoptionNoArg, "True"},
- {"-i", "dbxopt_i", XrmoptionNoArg, "True"},
- {"-I", "includeDir", XrmoptionSepArg, NULL},
- {"-k", "dbxopt_k", XrmoptionNoArg, "True"},
- #ifdef BSD /* Berkeley dbx */
- {"-c", "cfile", XrmoptionSepArg, NULL},
- #else /* Sun Release 3.2 or 3.4 dbx */
- {"-kbd", "dbxopt_kbd", XrmoptionNoArg, "True"},
- #endif
- #ifdef sparc /* SunOS 4.0 dbx */
- {"-f", "fcount", XrmoptionSepArg, NULL},
- {"-s", "startup", XrmoptionSepArg, NULL},
- {"-sr", "tstartup", XrmoptionSepArg, NULL},
- #endif
- };
-
-
- static void Syntax(call)
- char *call;
- {
- fprintf(stderr,
- "Usage: %s [-toolkitoptions] [-dbxoptions] [objfile [corefile]]\n",
- call);
- }
-
-
- static void Initialize()
- {
- source_init();
- signs_init();
- parser_init();
- if (!app_resources.noTitleBar) DisableWindowResize(titleBar);
- DisableWindowResize(fileWindow);
- mktemp(xdbxinit);
- Homedir = False;
- if (rename(".dbxinit", xdbxinit) == -1) {
- rename("~/.dbxinit", xdbxinit);
- Homedir = True;
- }
- }
-
-
- int dbxoptions(argc, argv, app_resources)
- int argc;
- char **argv;
- XdbxResources app_resources;
- {
- if (app_resources.dbxopt_r)
- argv[argc++] = "-r";
- if (app_resources.dbxopt_i)
- argv[argc++] = "-i";
- if (app_resources.includeDir) {
- argv[argc++] = "-I";
- strcpy(argv[argc++], app_resources.includeDir);
- }
- if (app_resources.dbxopt_k)
- argv[argc++] = "-k";
- if (app_resources.cfile) {
- argv[argc++] = "-c";
- strcpy(argv[argc++], app_resources.cfile);
- }
- if (app_resources.dbxopt_kbd)
- argv[argc++] = "-kbd";
- if (app_resources.fcount) {
- argv[argc++] = "-f";
- strcpy(argv[argc++], app_resources.fcount);
- }
- if (app_resources.startup) {
- argv[argc++] = "-s";
- strcpy(argv[argc++], app_resources.startup);
- }
- if (app_resources.tstartup) {
- argv[argc++] = "-sr";
- strcpy(argv[argc++], app_resources.tstartup);
- }
- argv[argc] = NULL;
- return argc;
- }
-
-
- void main(argc, argv)
- unsigned int argc;
- char **argv;
- {
- trap_signals();
-
- toplevel = XtInitialize("toplevel", "XDbx", options, XtNumber(options),
- &argc, argv);
-
- if (argc > 3) Syntax(argv[0]);
-
- XtGetApplicationResources(toplevel, &app_resources, resources,
- XtNumber(resources), NULL, 0);
-
- CreateSubWindows(toplevel);
-
- XtRealizeWidget(toplevel);
-
- Initialize();
- argc = dbxoptions(argc, argv, app_resources);
- calldbx(argc, argv);
-
- XtMainLoop();
- }
-