home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume3 / xdbx / part03 / xdbx.c < prev   
Encoding:
C/C++ Source or Header  |  1989-03-14  |  6.1 KB  |  186 lines

  1. /****************************************************************************** 
  2.  *
  3.  *  xdbx - X Window System interface to dbx
  4.  *
  5.  *  Copyright 1989 The University of Texas at Austin
  6.  *
  7.  *  Author:    Po Cheung
  8.  *  Date:    March 10, 1989
  9.  *
  10.  *  Permission to use, copy, modify, and distribute this software and
  11.  *  its documentation for any purpose and without fee is hereby granted,
  12.  *  provided that the above copyright notice appear in all copies and that
  13.  *  both that copyright notice and this permission notice appear in
  14.  *  supporting documentation.  The University of Texas at Austin makes no 
  15.  *  representations about the suitability of this software for any purpose.  
  16.  *  It is provided "as is" without express or implied warranty.
  17.  *
  18.  ******************************************************************************/
  19.  
  20.  
  21. #include "global.h"
  22.  
  23. #define Offset(field) (XtOffset(XdbxResources *, field))
  24.  
  25. Widget  toplevel,         /* top level widget             */
  26.     vpane,             /* parent of all subwindows         */
  27.     titleBar,         /* label widget displaying title     */
  28.     fileWindow,         /* form widget containing :         */
  29.     fileLabel,         /*   file name of displayed text     */
  30.     lineLabel,         /*   line number of caret        */
  31.     sourceWidget,         /* form widget, parent of sourceWindow  */
  32.     sourceWindow,         /*   asciiString widget, source file    */
  33.     messageWindow,         /* label widget, execution status    */
  34.     commandWindow,         /* command panel, box widget         */
  35.     dialogWindow;        /* dialog window, asciiString widget    */
  36.  
  37. XdbxResources     app_resources;    /* application resources of xdbx     */
  38. char         *xdbxinit = "xdbx.XXXXXX";
  39. Boolean        Homedir;
  40.  
  41.  
  42. static XtResource resources[] = {
  43.     {"shellWidth", "ShellWidth", XtRDimension, sizeof(Dimension), 
  44.     Offset(shellWidth), XtRString, "550"},
  45.     {"lineLabelWidth", "LineLabelWidth", XtRDimension, sizeof(Dimension), 
  46.     Offset(lineLabelWidth), XtRString, "70"},
  47.     {"sourceHeight", "SourceHeight", XtRDimension, sizeof(Dimension), 
  48.     Offset(sourceHeight), XtRString, "320"},
  49.     {"leftMargin", "LeftMargin", XtRDimension, sizeof(Dimension), 
  50.     Offset(leftMargin), XtRString, "35"},
  51.     {"dialogHeight", "DialogHeight", XtRDimension, sizeof(Dimension), 
  52.     Offset(dialogHeight), XtRString, "200"},
  53.     {"dialogMinHeight", "DialogMinHeight", XtRDimension, sizeof(Dimension), 
  54.     Offset(dialogMinHeight), XtRString, "15"},
  55.     {"messageHeight", "MessageHeight", XtRDimension, sizeof(Dimension), 
  56.     Offset(messageHeight), XtRString, "30"},
  57.     {"buttonWidth", "ButtonWidth", XtRDimension, sizeof(Dimension), 
  58.     Offset(buttonWidth), XtRString, "50"},
  59.     {"commandHSpace", "CommandHSpace", XtRDimension, sizeof(Dimension), 
  60.     Offset(commandHSpace), XtRString, "14"},
  61.     {"commandVSpace", "CommandVSpace", XtRDimension, sizeof(Dimension), 
  62.     Offset(commandVSpace), XtRString, "10"},
  63.     {"commandMinHeight", "CommmandMinHeight", XtRDimension, sizeof(Dimension), 
  64.     Offset(commandMinHeight), XtRString, "70"},
  65.     {"commandMaxHeight", "CommandMaxHeight", XtRDimension, sizeof(Dimension), 
  66.     Offset(commandMaxHeight), XtRString, "120"},
  67.     {"columnSpacing", "ColumnSpacing", XtRDimension, sizeof(Dimension), 
  68.     Offset(columnSpacing), XtRString, "10"},
  69.     {"filesPerColumn", "FilesPerColumn", XtRInt, sizeof(int), 
  70.     Offset(filesPerColumn), XtRString, "10"},
  71.     {"noTitleBar", "NoTitleBar", XtRBoolean, sizeof(Boolean), 
  72.     Offset(noTitleBar), XtRImmediate, (caddr_t)False},
  73.     {"stopForeground", "StopForeground", XtRPixel, sizeof(Pixel), 
  74.     Offset(stopForeground), XtRString, "Red"},
  75.     {"arrowForeground", "ArrowForeground", XtRPixel, sizeof(Pixel), 
  76.     Offset(arrowForeground), XtRString, "Blue"},
  77.     {"updownForeground", "UpdownForeground", XtRPixel, sizeof(Pixel), 
  78.     Offset(updownForeground), XtRString, "Blue"},
  79. };
  80.  
  81. static XrmOptionDescRec options[] = {
  82.     {"-r",    "dbxopt_r",    XrmoptionNoArg, "True"},
  83.     {"-i",    "dbxopt_i",    XrmoptionNoArg, "True"},
  84.     {"-I",    "includeDir",    XrmoptionSepArg, NULL},
  85.     {"-k",    "dbxopt_k",    XrmoptionNoArg, "True"},
  86. #ifdef BSD   /* Berkeley dbx */
  87.     {"-c",    "cfile",    XrmoptionSepArg, NULL},
  88. #else         /* Sun Release 3.2 or 3.4 dbx */
  89.     {"-kbd",    "dbxopt_kbd",    XrmoptionNoArg, "True"},
  90. #endif
  91. #ifdef sparc /* SunOS 4.0 dbx */
  92.     {"-f",    "fcount",    XrmoptionSepArg, NULL},
  93.     {"-s",    "startup",    XrmoptionSepArg, NULL},
  94.     {"-sr",    "tstartup",    XrmoptionSepArg, NULL},
  95. #endif
  96. };
  97.  
  98.  
  99. static void Syntax(call)
  100. char *call;
  101. {
  102.     fprintf(stderr,
  103.         "Usage: %s [-toolkitoptions] [-dbxoptions] [objfile [corefile]]\n",
  104.         call);
  105. }
  106.  
  107.  
  108. static void Initialize()
  109. {
  110.     source_init();
  111.     signs_init();
  112.     parser_init();
  113.     if (!app_resources.noTitleBar) DisableWindowResize(titleBar);
  114.     DisableWindowResize(fileWindow);
  115.     mktemp(xdbxinit);
  116.     Homedir = False;
  117.     if (rename(".dbxinit", xdbxinit) == -1) {
  118.     rename("~/.dbxinit", xdbxinit);
  119.     Homedir = True;
  120.     }
  121. }
  122.  
  123.  
  124. int dbxoptions(argc, argv, app_resources)
  125.     int  argc;
  126.     char **argv;
  127.     XdbxResources app_resources;
  128. {
  129.     if (app_resources.dbxopt_r)
  130.     argv[argc++] = "-r";
  131.     if (app_resources.dbxopt_i)
  132.     argv[argc++] = "-i";
  133.     if (app_resources.includeDir) {
  134.     argv[argc++] = "-I";
  135.     strcpy(argv[argc++], app_resources.includeDir);
  136.     }
  137.     if (app_resources.dbxopt_k)
  138.     argv[argc++] = "-k";
  139.     if (app_resources.cfile) {
  140.     argv[argc++] = "-c";
  141.     strcpy(argv[argc++], app_resources.cfile);
  142.     }
  143.     if (app_resources.dbxopt_kbd)
  144.     argv[argc++] = "-kbd";
  145.     if (app_resources.fcount) {
  146.     argv[argc++] = "-f";
  147.     strcpy(argv[argc++], app_resources.fcount);
  148.     }
  149.     if (app_resources.startup) {
  150.     argv[argc++] = "-s";
  151.     strcpy(argv[argc++], app_resources.startup);
  152.     }
  153.     if (app_resources.tstartup) {
  154.     argv[argc++] = "-sr";
  155.     strcpy(argv[argc++], app_resources.tstartup);
  156.     }
  157.     argv[argc] = NULL;
  158.     return argc;
  159. }
  160.  
  161.  
  162. void main(argc, argv)
  163. unsigned int argc;
  164. char **argv;
  165. {
  166.     trap_signals();
  167.  
  168.     toplevel = XtInitialize("toplevel", "XDbx", options, XtNumber(options), 
  169.                 &argc, argv);
  170.  
  171.     if (argc > 3) Syntax(argv[0]);
  172.  
  173.     XtGetApplicationResources(toplevel, &app_resources, resources,
  174.                               XtNumber(resources), NULL, 0);
  175.  
  176.     CreateSubWindows(toplevel);
  177.  
  178.     XtRealizeWidget(toplevel);
  179.  
  180.     Initialize();
  181.     argc = dbxoptions(argc, argv, app_resources);
  182.     calldbx(argc, argv);
  183.  
  184.     XtMainLoop();
  185. }
  186.