1 
2 /*
3    Header for all files in xreduce source.
4 */
5 
6 
7 /* I am assuming that X11R4 or newer is present */
8 
9 #include <ctype.h>
10 #include <stdio.h>
11 #include <signal.h>
12 #include <fcntl.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <stdlib.h>
16 #include <unistd.h>
17 #include <sys/types.h>
18 #include <sys/socket.h>
19 #include <sys/uio.h>
20 #include <sys/stat.h>
21 #include <sys/wait.h>
22 
23 #include <X11/Intrinsic.h>
24 #include <X11/StringDefs.h>
25 #include <X11/Shell.h>
26 #include <X11/Core.h>
27 #include <X11/Xutil.h>
28 
29 #include <X11/cursorfont.h>
30 
31 #include <X11/Xaw/AsciiText.h>
32 #include <X11/Xaw/Box.h>
33 #include <X11/Xaw/Command.h>
34 #include <X11/Xaw/Dialog.h>
35 #include <X11/Xaw/Form.h>
36 #include <X11/Xaw/Label.h>
37 #include <X11/Xaw/List.h>
38 #include <X11/Xaw/Paned.h>
39 #include <X11/Xaw/Scrollbar.h>
40 #include <X11/Xaw/Text.h>
41 #include <X11/Xaw/Toggle.h>
42 #include <X11/Xaw/Viewport.h>
43 
44 #ifdef EXPLICIT_EDITRES
45 #include <X11/Xmu/Editres.h>	/* Our X11R5 doesn't support editres by */
46 #endif				/* default -- dunno why -- so you have  */
47 				/* to do it by hand                     */
48 #include "xredres.h"
49 
50 /*
51    Default constants.  Some of these are also parameterised as defaults in
52    xredres.h; the others probably should be (most notably the buffer-length
53    constants).
54 */
55 
56 #define END_OF_LINE                 10     /* ASCII eol                      */
57 #define REDUCE_HISTORY_MIN_MAX      1      /* Min hist-length for X default  */
58 #define REDUCE_HISTORY_MAX_MAX      1000   /* Max likewise                   */
59 #define REDUCE_HISTORY_MIN_EXCESS   1      /* Excess is how far hist can grow*/
60 #define REDUCE_HISTORY_MAX_EXCESS   200	   /* beyond max before it's clipped */
61 #define REDUCE_WIDNAME_LENGTH       20     /* For names of history widgets   */
62 #define REDUCE_INPUT_BUFFER_LENGTH  500000
63 #define REDUCE_OUTPUT_BUFFER_LENGTH 8000   /* Reduce to Me communication     */
64 #define REDUCE_PATH                 "/bin/redu35"
65 #define REDUCE_NAME                 "redu35"
66 #define REDUCE_TEX_ON               16	   /* Char Reduce outputs to indicate*/
67 #define REDUCE_TEX_OFF              17     /* beginning and end of graphics  */
68 #define INPUT_ESCAPE_CHAR 0x2
69 
70 
71 /*
72    Some types.  EltType is used to indicate difference between textual and
73    graphical widgets; the HistList is the structure that stores all the
74    Reduce output widgets.
75 */
76 
77 
78 /* Enumerate possibilities for current state of output stream */
79 
80 typedef enum { ReduceVerbal, ReduceGraphical, ReduceMessage } EltType;
81 
82 
83 /* Type for blocks to be displayed in Reduce output widget box.  Each  */
84 /* contains a widget, to be managed, and various pieces of information */
85 /* about its content and how to manage it.                             */
86 /* There are three blocks: information for all widgets, for verbals    */
87 /* only, and for graphicals only.  I could conceivably use a union for */
88 /* these, but I don't think there's enough wasted memory to warrant it */
89 
90 typedef struct _HistList {
91   EltType           flavour;	/* Verbal or Graphical?                      */
92   unsigned long     histNo;	/* Value of Reduce History Number at start   */
93   Boolean           managed;	/* Currently displayed? (Or awaiting page?)  */
94   Dimension         width;	/* Pixel width of widget                     */
95   Dimension         height;	/* Pixel height of widget                    */
96   Widget            widget;	/* The actual Widget to be displayed         */
97   struct _HistList *next;	/* It's a simple linked list                 */
98 
99   /* These are for Verbals only: */
100 
101   int               nLines;	/* Number of lines of text on verbal         */
102   int               textLength;	/* Chars total in current verbal             */
103   int               usedOnLine;	/* Chars drawn on current line               */
104 
105   /* These are for Graphicals only: */
106 
107   Dimension         pMapWidth;	/* Pixel width of pixmap                     */
108   Dimension         pMapHeight;	/* Pixel height of pixmap                    */
109   Pixmap            pMap;	/* Pixmap itself, Graphical only             */
110 
111 } HistList;
112 
113 
114 /* Type for pixmaps awaiting assemblage into a single output block. */
115 
116 typedef struct _OutputPixmapList {
117   Pixmap                    pMap;
118   Dimension                 width;
119   Dimension                 height;
120   struct _OutputPixmapList *next;
121 } OutputPixmapList;
122 
123 
124 /* Type for lines of user input awaiting a prompt so they can be sent */
125 /* to Reduce.                                                         */
126 
127 typedef struct _PendingInputList {
128   char                     *text;
129   char                     *stxt;
130   Boolean                   show;
131   struct _PendingInputList *next;
132 } PendingInputList;
133 
134 
135 /* Types for Option and File boxes. */
136 
137 typedef struct _OptToggleSet {
138   Widget         form;
139   Widget         label;
140   Widget         toggle;
141   Boolean        datumP;
142   char         * datum;
143   XtCallbackProc callback;
144 } OptToggleSet;
145 
146 typedef struct _OptToggleDesc {
147   char         * name;
148   XtCallbackProc callback;
149 } OptToggleDesc;
150 
151 typedef struct _nhelpToggleSet {
152   Widget         form;
153   Widget         label;
154   Widget         toggle;
155   Boolean        datumP;
156   char         * datum;
157   XtCallbackProc callback;
158 } nhelpToggleSet;
159 
160 typedef struct _nhelpToggleDesc {
161   char         * name;
162   XtCallbackProc callback;
163 } nhelpToggleDesc;
164 
165 
166