This file is indexed.

/usr/share/dx/samples/dxlink/demoapp.c is in dxsamples 4.2.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/* dx demo program - select dx visual program to run
 * by looking at thumbnail images of data.
 *
 */


#include <Xm/Xm.h> 
#include <Xm/Form.h> 
#include <Xm/Label.h>
#include <Xm/DrawingA.h>
#include <Xm/PushB.h>
#include <Xm/Text.h>
#include "dxl.h"

#include <stdio.h>
#include <stdlib.h>


static String DefaultResources[] =
{
    "*background:              #b4b4b4b4b4b4",
    "*foreground:              black",
#ifdef sgi
    "*fontList:                 -adobe-helvetica*bold-r*14*=bold\n\
                                -adobe-helvetica*medium-r*14*=normal\n\
                                -adobe-helvetica*medium-o*14*=oblique",
#else
    "*fontList:                 -adobe-helvetica*bold-r*14*=bold\
                                -adobe-helvetica*medium-r*14*=normal\
                                -adobe-helvetica*medium-o*14*=oblique",
#endif
   "*XmToggleButton.selectColor:            CadetBlue",
    "*XmText.shadowThickness:                1",
    NULL
};


#define MAXBUTTONS 40
#define NUMHIGH 2 
#define BUTTONSIZE 150
#define SHOWMESIZE 20
#define QUITSIZE 40 
DXLConnection   *conn;
DXLConnection   *bconn;

void button_CB(Widget, XtPointer, XtPointer);
void quitbutton_CB(Widget, XtPointer, XtPointer);

#define MAXLEN 1024
static int init_data(char *filename, int *numbuttons, char **programs, char **images);


main(argc, argv)
int argc;
char *argv[];
{
    Widget          toplevel, main_w;
    Widget          picture[MAXBUTTONS],button[MAXBUTTONS],quitbutton;
    XtAppContext    app;
    XmString        xms;
    int             numbuttons, i, row, column, numcolumns;
    char            buf[1024];
    char            *programs[MAXBUTTONS];
    char            *images[MAXBUTTONS];
    
    
    if (argc != 2) {
	fprintf(stderr, "usage: %s net_listfile\n", argv[0]);
	fprintf(stderr, "  where net_listfile contains lists of filenames, 2 per line\n");
	fprintf(stderr, "  the first is a .net file, and the second is an image file\n");
	fprintf(stderr, "  the image should be 150x150 in size.\n");
	exit (-1);
    }
    
    
    /* 
     *  Start the Data Explorer executive.
     */
    conn = DXLStartDX("dx -menubar -noMessageInfoOption -wizard -8bitcmap 1",NULL);
    if (!conn) {
	fprintf(stderr, "could not start dx");
	exit(0);
    }
    
    XtSetLanguageProc (NULL, NULL, NULL);
    
    toplevel = XtVaAppInitialize (&app, "Demos", 
				  NULL, 0, &argc, argv, 
				  DefaultResources, NULL);
    
    /* 
     * Create the user interface for this application
     */
    
    if (init_data(argv[1], &numbuttons, programs, images) < 0)
	exit (-1);
    
    
    numcolumns = (numbuttons-1)/NUMHIGH + 1;
    
    main_w = XtVaCreateManagedWidget("form",
		     xmFormWidgetClass, toplevel,
		     XmNwidth,    (BUTTONSIZE)*numcolumns,
		     XmNheight,   (BUTTONSIZE+SHOWMESIZE)*NUMHIGH +QUITSIZE,
		     XmNfractionBase, 5,
		     NULL);
    
    for (i=0; i<numbuttons; i++) {
	
	xms = XmStringCreateSimple("Show Me");
	if (i==0) {
	    picture[i] = XtVaCreateManagedWidget("draw", 
					 xmDrawingAreaWidgetClass, main_w,
					 XmNwidth, BUTTONSIZE,
					 XmNheight, BUTTONSIZE,
					 XmNlabelString, xms,
					 XmNtopAttachment, XmATTACH_FORM,
					 XmNleftAttachment, XmATTACH_FORM,
					 NULL);
	    button[i] = XtVaCreateManagedWidget("pushb", 
					xmPushButtonWidgetClass, main_w,
					XmNwidth, BUTTONSIZE,
					XmNheight, SHOWMESIZE,
					XmNlabelString, xms,
					XmNtopAttachment, XmATTACH_WIDGET,
					XmNtopWidget,picture[i],
					XmNleftAttachment, XmATTACH_FORM,
					NULL);
	}
	else {
	    column = i/NUMHIGH;
	    row = i-column*NUMHIGH;
	    if (row==0) { 
		picture[i] = XtVaCreateManagedWidget("draw", 
				     xmDrawingAreaWidgetClass, main_w,
				     XmNwidth, BUTTONSIZE,
				     XmNheight, BUTTONSIZE,
				     XmNlabelString, xms,
				     XmNtopAttachment, XmATTACH_FORM,
				     XmNleftAttachment, XmATTACH_WIDGET,
				     XmNleftWidget, picture[i-NUMHIGH],
				     NULL);
		button[i] = XtVaCreateManagedWidget("pushb", 
				    xmPushButtonWidgetClass, main_w,
				    XmNwidth, BUTTONSIZE,
				    XmNheight, SHOWMESIZE,
				    XmNlabelString, xms,
				    XmNtopAttachment, XmATTACH_WIDGET,
				    XmNtopWidget, picture[i],
				    XmNleftAttachment, XmATTACH_WIDGET,
				    XmNleftWidget, button[i-NUMHIGH],
				    NULL);
	    }
	    else {
		if (column==0) {
		    picture[i] = XtVaCreateManagedWidget("draw", 
					 xmDrawingAreaWidgetClass, main_w,
					 XmNwidth, BUTTONSIZE,
					 XmNheight, BUTTONSIZE,
					 XmNlabelString, xms,
					 XmNtopAttachment, XmATTACH_WIDGET,
					 XmNtopWidget, button[i-1],
					 XmNleftAttachment, XmATTACH_FORM,
					 NULL);
		    button[i] = XtVaCreateManagedWidget("pushb", 
					xmPushButtonWidgetClass, main_w,
					XmNwidth, BUTTONSIZE,
					XmNheight, SHOWMESIZE,
					XmNlabelString, xms,
					XmNtopAttachment, XmATTACH_WIDGET,
					XmNtopWidget, picture[i],
					XmNleftAttachment, XmATTACH_FORM,
					NULL);
		}
		else {
		    picture[i] = XtVaCreateManagedWidget("draw", 
					 xmDrawingAreaWidgetClass, main_w,
					 XmNwidth, BUTTONSIZE,
					 XmNheight, BUTTONSIZE,
					 XmNlabelString, xms,
					 XmNtopAttachment, XmATTACH_WIDGET,
					 XmNtopWidget, button[i-1],
					 XmNleftAttachment, XmATTACH_WIDGET,
					 XmNleftWidget, picture[i-NUMHIGH],
					 NULL);
		    button[i] = XtVaCreateManagedWidget("pushb", 
					xmPushButtonWidgetClass, main_w,
					XmNwidth, BUTTONSIZE,
					XmNheight, SHOWMESIZE,
					XmNlabelString, xms,
					XmNtopAttachment, XmATTACH_WIDGET,
					XmNtopWidget, picture[i],
					XmNleftAttachment, XmATTACH_WIDGET,
					XmNleftWidget, button[i-NUMHIGH],
					NULL);
		}
	    }
	}
	
	XtAddCallback(button[i], XmNactivateCallback,
		      (XtCallbackProc)button_CB,
		      programs[i]);
	
	XmStringFree(xms);
    }
    /* do the quit button */
    xms = XmStringCreateSimple("Quit");
    quitbutton = XtVaCreateManagedWidget("pushb", 
				xmPushButtonWidgetClass, main_w,
				XmNwidth, QUITSIZE,
				XmNheight, QUITSIZE,
				XmNlabelString, xms,
				XmNtopAttachment, XmATTACH_WIDGET,
				XmNtopWidget, button[NUMHIGH-1],
				XmNleftAttachment, XmATTACH_FORM,
				XmNrightAttachment, XmATTACH_FORM,
				NULL);
    XtAddCallback(quitbutton, XmNactivateCallback,
		      (XtCallbackProc)quitbutton_CB,
		      conn);
    XtRealizeWidget (toplevel);
 
    
    
    
    XSync(XtDisplay(toplevel), False);
    
    bconn = DXLStartDX("dx -execonly -8bitcmap 1",NULL);
    if (! bconn) {
	fprintf(stderr, "second dxlconn failed\n");
	exit(1);
    }
    
    exDXLLoadScript(bconn, "LoadImage.net");
    for (i=0; i<numbuttons; i++) {
	sprintf(buf, "X8,:0.0,#X%d", XtWindow(picture[i]));
	DXLSetString(bconn, "where", buf);
	DXLSetString(bconn, "img", images[i]);
	DXLExecuteOnce(bconn);
	DXLHandlePendingMessages(bconn);
    }
    
    DXLInitializeXMainLoop(app, conn);
    
    XtAppMainLoop (app);

}

/* open filename.  expects it to contain this format:
 *    .net name    image name
 *   etc
 *
 * the images should be 150x150 and should correspond to the result of running
 * the given .net file.
 */
static int init_data(char *filename, int *numbuttons, char **programs, char **images)
{
    FILE *fp;
    int i, len;
    char temp_prog[MAXLEN], temp_imag[MAXLEN];
    
    if ((fp = fopen(filename, "r")) == NULL) {
	fprintf(stderr, "cannot open '%s' for reading\n", filename);
	return -1;
    }

    *numbuttons = 0;
    i = 0;
    while (1) {
	if (fscanf(fp, "%s %s", temp_prog, temp_imag) != 2)
	    break;

	len = strlen(temp_prog);
	programs[i] = malloc(len + 1);
	if (!programs[i])
	    return -1;
	
	strcpy(programs[i], temp_prog);
	
	len = strlen(temp_imag);
	images[i] = malloc(len + 1);
	if (!images[i])
	    return -1;
	
	strcpy(images[i], temp_imag);
	i++;
    }
    
    *numbuttons = i;
    return 0;
}


/* 
 * The following are the callbacks for the buttons. 
 */
void button_CB(Widget w, XtPointer xp1, XtPointer xp2)
{
   DXLLoadVisualProgram(conn,(char *)xp1);
   DXLExecuteOnce(conn);
}

void quitbutton_CB(Widget w, XtPointer xp1, XtPointer xp2)
{
   DXLConnection *conn =  (DXLConnection *)xp1;
   DXLExitDX(conn);
   exit(1);
}