This file is indexed.

/usr/share/doc/xviewg/examples/color/example2.c is in xview-examples 3.2p1.4-28.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
309
310
311
312
313
314
315
316
317
318
319
/*
 * xv_color.c
 *    This program demonstrates the use of color in XView. It allows the
 *    user to choose the foreground and background colors of the various
 *    objects in an interactive manner.
 *
 */
#include <xview/xview.h>
#include <xview/textsw.h>
#include <xview/panel.h>
#include <xview/icon.h>
#include <xview/cms.h>
#include <xview/svrimage.h>

#define WHITE           0
#define RED             1
#define GREEN           2
#define BLUE            3
#define YELLOW          4
#define PINK            5
#define GRAY            6
#define BLACK           7
#define NUM_COLORS      8

#define HEIGHT          500
#define WIDTH           500

#define CHIP_HEIGHT     16
#define CHIP_WIDTH      16

#define SELECT_TEXTSW           0
#define SELECT_TEXTSW_VIEW      1
#define SELECT_ICON             2

/* Icon data */
static unsigned short icon_bits[]={
#include <images/cardback.icon>
};
mpr_static(icon_image, ICON_DEFAULT_WIDTH, ICON_DEFAULT_HEIGHT, 1,
icon_bits);

static unsigned short black_data[] = {
#include <images/black.cursor>
};

/* object currently selected for color change */
int             current_selection = SELECT_TEXTSW;

/* flag to indicate if foreground or background is to be changed */
int             fg = TRUE;
Textsw          textsw;
Panel     	panel;
Icon            icon;

/*
 *              main()
 *    Create a panel and panel items. The application uses panel items
 *    to choose a particular object and change its foreground and background
 *    colors in an interactive manner. Create a textsw. Create an icon.
 *    All the objects share the same colormap segment.
 */
main(argc,argv)
    int         argc;
    char        *argv[];
{
	Frame          	frame;
	Cms		control_cms, plain_cms;
	Server_image	choice_image;
	Xv_Singlecolor	cms_colors[NUM_COLORS];
	Panel_item	panel_palette, panel_fg_bg, panel_object;
	int            	textsw_width;
	void            color_notify(), fg_bg_notify(), object_notify();

	xv_init(XV_INIT_ARGS, argc, argv, 0);

	frame = xv_create(XV_NULL, FRAME,
			  FRAME_LABEL,"xv_color",
			  0);

	/* 
	 * Create a colormap segment with the required colors for 
	 * the color palette. Set it to be a control colormap segment
	 * to enable the panel to be painted using the 3D look.
	 */
	initialize_cms_colors(cms_colors);
	control_cms = xv_create(XV_NULL, CMS,
			CMS_SIZE, NUM_COLORS + CMS_CONTROL_COLORS,
			CMS_COLORS, cms_colors,
			CMS_CONTROL_CMS, TRUE,
			0);

	plain_cms = xv_create(XV_NULL, CMS,
			CMS_SIZE, NUM_COLORS,
			CMS_COLORS, cms_colors,
			0);

	/* Create a server image to use for colored panel choice images */
	choice_image = (Server_image) xv_create(XV_NULL, SERVER_IMAGE,
                                          XV_WIDTH, CHIP_WIDTH,
                                          XV_HEIGHT, CHIP_HEIGHT,
                                          SERVER_IMAGE_DEPTH, 1,
                                          SERVER_IMAGE_BITS, black_data,
                                          0);

	/* Create panel and set the colormap segment on the panel */
	panel = xv_create(frame, PANEL,
			  PANEL_LAYOUT, PANEL_HORIZONTAL,
			  WIN_CMS, control_cms,	
			  0);

	/* Create panel items */
	panel_object = xv_create(panel, PANEL_CHOICE_STACK,
				PANEL_LABEL_STRING, "Object",
				PANEL_LABEL_BOLD, TRUE,
				PANEL_CHOICE_STRINGS,
				    "Textsw",
				    "Textsw View",
				    "Icon",
				    0,
				PANEL_NOTIFY_PROC, object_notify,
				0);

	panel_fg_bg = xv_create(panel, PANEL_CHOICE,
				PANEL_LABEL_STRING, "Fg/Bg",
				PANEL_LABEL_BOLD, TRUE,
				PANEL_CHOICE_STRINGS,
				    "Foreground",
				    "Background",
				    0,
				PANEL_NOTIFY_PROC, fg_bg_notify,
				0);


	panel_palette = xv_create(panel, PANEL_CHOICE,
				  PANEL_LABEL_STRING, "Colors",
				  PANEL_LABEL_BOLD, TRUE,
				  XV_X, (int)xv_get(panel_fg_bg, XV_X),
				  PANEL_NEXT_ROW, 15,
				  PANEL_CHOICE_IMAGES,
					choice_image,
					choice_image,
					choice_image,
					choice_image,
					choice_image,
					choice_image,
					choice_image,
					choice_image,
				      0,
				PANEL_CHOICE_COLOR, 0, CMS_CONTROL_COLORS + WHITE,
           			PANEL_CHOICE_COLOR, 1, CMS_CONTROL_COLORS + RED,
           			PANEL_CHOICE_COLOR, 2, CMS_CONTROL_COLORS + GREEN,
           			PANEL_CHOICE_COLOR, 3, CMS_CONTROL_COLORS + BLUE,
           			PANEL_CHOICE_COLOR, 4, CMS_CONTROL_COLORS + YELLOW,
           			PANEL_CHOICE_COLOR, 5, CMS_CONTROL_COLORS + PINK,
           			PANEL_CHOICE_COLOR, 6, CMS_CONTROL_COLORS + GRAY,
           			PANEL_CHOICE_COLOR, 7, CMS_CONTROL_COLORS + BLACK,
				PANEL_NOTIFY_PROC, color_notify,
				0);

	(void)window_fit_height(panel);

	/* create textsw and set the colormap segment for it */
	textsw = xv_create(frame, TEXTSW,
			   WIN_CMS, plain_cms,	
			   WIN_BELOW, panel,
			   WIN_ROWS, 45,
			   WIN_COLUMNS, 80,
			   0);

	/* adjust panel dimensions */
	textsw_width = (int)xv_get(textsw, WIN_WIDTH);
	(void)xv_set(panel, WIN_WIDTH, textsw_width, 0);

	/* associate icon with the base frame */
	icon = xv_create(XV_NULL, ICON,
			 ICON_IMAGE, &icon_image,
			 WIN_CMS, plain_cms,
			 0);
	xv_set(frame, FRAME_ICON, icon, 0);

	window_fit(frame);

	/* Start event loop */
	xv_main_loop(frame);
	return(0);
}

/*
 *		initialize_cms_colors()
 *  Initialize the required RGB values.
 */
initialize_cms_colors(colors)
    Xv_Singlecolor	*colors;
{
    colors[WHITE].red = 255;       
    colors[WHITE].green = 255;       
    colors[WHITE].blue = 255;

    colors[RED].red = 255;         
    colors[RED].green = 0;
    colors[RED].blue = 0;

    colors[GREEN].red = 0;
    colors[GREEN].green = 255; 
    colors[GREEN].blue = 0;

    colors[BLUE].red = 0;
    colors[BLUE].green = 0;
    colors[BLUE].blue = 255;

    colors[YELLOW].red = 255;      
    colors[YELLOW].green = 255;
    colors[YELLOW].blue = 0;

    colors[PINK].red = 188; 
    colors[PINK].green = 143;
    colors[PINK].blue = 143;

    colors[GRAY].red = 220;
    colors[GRAY].green = 220;
    colors[GRAY].blue = 220;

    colors[BLACK].red = 0;
    colors[BLACK].green = 0;
    colors[BLACK].blue = 0;
}


/*
 *              color_notify()
 *    This routine gets called when a color selection is made.
 *    Set the foreground or background on the currently selected object.
 *    WIN_FOREGROUND_COLOR & WIN_BACKGROUND_COLOR allow the application
 *    to specify indices into the colormap segment as the foreground and
 *    background values.
 */
void
color_notify(panel_item, event)
    Panel_item      panel_item;
    Event           *event;
{
    int         choice;
    Xv_opaque   current_object, get_current_object();

    current_object = (Xv_opaque)get_current_object();

    choice = (int) xv_get(panel_item, PANEL_VALUE);
    if (fg) {
	xv_set(current_object, WIN_FOREGROUND_COLOR, choice, 0);
    } else {
	xv_set(current_object, WIN_BACKGROUND_COLOR, choice, 0);
    }
}

/*
 *              fg_bg_notify()
 *    This routine gets called when a foreground/background selection
 *    is made.
 */
void
fg_bg_notify(panel_item, event)
    Panel_item      panel_item;
    Event           *event;
{
    int         choice;

    choice = (int) xv_get(panel_item, PANEL_VALUE);
    if (choice == 0) {
	fg = TRUE;
    } else {
	fg = FALSE;
    }
}

/*
 *              object_notify()
 *    This routine gets called when an object selction is made.
 *    Store this selection as the current object.
 */


void
object_notify(panel_item, event)
    Panel_item      panel_item;
    Event           *event;
{
    current_selection = (int) xv_get(panel_item, PANEL_VALUE);
}

/*
 *              get_current_object()
 *    This routine returns the XView handle to the currently selected
 *    object.
 */
Xv_opaque
get_current_object()
{
    Xv_opaque   current_object;

    switch(current_selection) {
	case SELECT_TEXTSW:
	    current_object = (Xv_opaque)textsw;
	    break;

	case SELECT_TEXTSW_VIEW:
	    current_object =
		(Xv_opaque)xv_get(textsw, OPENWIN_NTH_VIEW, 0);
	    break;

	case SELECT_ICON:
	    current_object = (Xv_opaque)icon;
	    break;

	default:
	    current_object = (Xv_opaque)textsw;
	    break;
    }
    return(current_object);
}