This file is indexed.

/usr/share/ncarg/hluex/basic/basic05c.c is in libncarg-data 6.2.0-3.

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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
/*
 * $Id: basic05c.c,v 1.12 2010-03-15 22:49:23 haley Exp $
 */
/***********************************************************************
*                                                                      *
*                            Copyright (C)  1995                       *
*                 University Corporation for Atmospheric Research      *
*                            All Rights Reserved                       *
*                                                                      *
************************************************************************
*
*      File:            basic05c.c
*
*      Author:          Tim Scheitlin (converted by Ed Stautler)
*                       National Center for Atmospheric Research
*                       PO 3000, Boulder, Colorado
*
*      Date:            Fri Apr 28 12:26:32 MDT 1995
*
*      Description:     This example demonstrates how to read, display, and
*                       manipulate colormaps.
*
*             The NG 4.x HLU software supports several different predefined
*             colormaps of various sizes.  This example demonstrates how to
*             display each of those colormaps using the labelbar utility.
*             This example also shows how to change entries in a colormap
*             and create a completely new colormap.
*
*/

#include <ncarg/hlu/App.h>
#include <ncarg/hlu/ResList.h>
#include <ncarg/hlu/NcgmWorkstation.h>
#include <ncarg/hlu/PSWorkstation.h>
#include <ncarg/hlu/PDFWorkstation.h>
#include <ncarg/hlu/CairoWorkstation.h>
#include <ncarg/hlu/Workstation.h>
#include <ncarg/hlu/LabelBar.h>
#include <ncarg/hlu/hlu.h>


int main()
{
    int i;
    int appid,wks,lbar,rlist,glist,text;
    char *colorindices[255];
    int num_dims;
    ng_size_t *len_dims;
    float *cmap;
    float newcmap[100*3];
    char const *wks_type = "x11";
/*
 * Display the default colormap.
 *
 * Initialize labels for the color map entries
 */
    for(i=1; i<=255; i++) {
        colorindices[i-1] = (char*)malloc(4*sizeof(char));
        sprintf(colorindices[i-1],"%d",i);
    }
/*
 * Initialize libraries and create a resource list.
 */
    NhlInitialize();
    rlist = NhlRLCreate(NhlSETRL);

    NhlRLClear(rlist);
    NhlCreate(&appid,"appid",NhlappClass,NhlDEFAULT_APP,rlist);

    if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
/*
 * Create a meta file workstation.
 */
        NhlRLClear(rlist);
/*
 * Set Colormap to default. Note, this assignment is redundant
 */
        NhlRLSetString(rlist,NhlNwkMetaName,"./basic05c.ncgm");
        NhlCreate(&wks,"wks",NhlncgmWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
/*
 * Create an X workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,"wkPause","True");
/*
 * Set the colormode to private so there is no color contention
 */
/*      NhlRLSetString(rlist,"wkXColorMode","private"); */
        NhlCreate(&wks,"wks",NhlcairoWindowWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"oldps") || !strcmp(wks_type,"OLDPS")) {
/*
 * Create an older-style PostScript workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPSFileName,"./basic05c.ps");
        NhlCreate(&wks,"wks",NhlpsWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"oldpdf") || !strcmp(wks_type,"OLDPDF")) {
/*
 * Create an older-style PDF workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPDFFileName,"./basic05c.pdf");
        NhlCreate(&wks,"wks",NhlpdfWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"pdf") || !strcmp(wks_type,"PDF") ||
             !strcmp(wks_type,"ps") || !strcmp(wks_type,"PS")) {
/*
 * Create a cairo PS/PDF workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"./basic05c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlCreate(&wks,"wks",NhlcairoDocumentWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
/*
 * Create a cairo PNG workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"./basic05c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlCreate(&wks,"wks",NhlcairoImageWorkstationClass,NhlDEFAULT_APP,rlist);
    }

/*
 * Create a labelbar object. 
 */
    NhlRLClear(rlist);
/*
 * Assign the labels
 */
    NhlRLSetStringArray(rlist,"lbLabelStrings",colorindices,255);
/*
 * Label every 5th entry
 */
    NhlRLSetInteger(rlist,"lbLabelStride",5);
/*
 * Single pattern used for fill
 */
    NhlRLSetString(rlist,"lbMonoFillPattern","True");
/*
 * Set fill pattern to solid
 */
        NhlRLSetString(rlist,"lbFillPattern","SolidFill");
/*
 * No lines between colors
 */
        NhlRLSetString(rlist,"lbBoxLinesOn","False");
/*
 * Display 255 entries
 */
        NhlRLSetInteger(rlist,"lbBoxCount",255);
/*
 * Turn off labelbar perimeter
 */
        NhlRLSetString(rlist,"lbPerimOn","False");
/*
 * Plot title
 */
        NhlRLSetString(rlist,"lbTitleString","(New) Default Colormap");
/*
 * Title font
 */
        NhlRLSetString(rlist,"lbTitleFont","Helvetica-bold");
/*
 * Label font
 */
        NhlRLSetString(rlist,"lbLabelFont","Helvetica");
/*
 * Set viewport to max size
 */
        NhlRLSetFloat(rlist,"vpXF",0.0);
        NhlRLSetFloat(rlist,"vpYF",1.0);
        NhlRLSetFloat(rlist,"vpHeightF",1.0);
        NhlRLSetFloat(rlist,"vpWidthF",1.0);

        NhlCreate(&lbar,"lbar",NhllabelBarClass,wks,rlist);
/*
 *  Create a text label
 */
        NhlRLClear(rlist);
/*
 * Set font
 */
        NhlRLSetString(rlist,"txFont","Helvetica-bold");
/*
 * Set position and height
 */
        NhlRLSetFloat(rlist,"txPosXF",.5);
        NhlRLSetFloat(rlist,"txPosYF",.03);
        NhlRLSetFloat(rlist,"txFontHeightF",.035);
/*
 * Set the function code to the "*" character so that the 
 * default function code character, the colon, can be used
 * in the "txString" resource.
 */
        NhlRLSetString(rlist,"txFuncCode","*"); 
/*
 * Set the text value
 */
        NhlRLSetString(rlist,"txString","Note: Entry 0 is the background color");

        NhlCreate(&text,"text",NhltextItemClass,wks,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 *  Change the colormap to the old (pre V6.1.0) default color map
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","default");
    NhlSetValues(wks,rlist);

    NhlRLClear(rlist);
    NhlRLSetString(rlist,"lbTitleString","(Old) Default Colormap");
    NhlRLSetInteger(rlist,"lbBoxCount",31);
    NhlSetValues(lbar,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);

/*
 *  Change the colormap to one of the predefined colormaps
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","cyclic");
    NhlSetValues(wks,rlist);
/*
 *  Change the labelbar title, annotation, and number of entries.
 */
    NhlRLClear(rlist);
/*
 * Labelbar title
 */
    NhlRLSetString(rlist,"lbTitleString","Cyclic Colormap");
/*
 * Label every entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 1);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 7);
    NhlSetValues(lbar,rlist);
/*
 *
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 *  Change the colormap to one of the predefined colormaps
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","gscyclic");
    NhlSetValues(wks,rlist);
/*
 *  Change the labelbar title, annotation, and number of entries.
 */
    NhlRLClear(rlist);
/*
 * Labelbar title
 */
    NhlRLSetString(rlist,"lbTitleString","Gscyclic Colormap");
/*
 * Label every entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 1);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 7);

    NhlSetValues(lbar,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 *  Change the colormap to one of the predefined colormaps
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","gsltod");
    NhlSetValues(wks,rlist);
/*
 *  Change the labelbar title, annotation, and number of entries.
 */
    NhlRLClear(rlist);
/*
 * Labelbar title
 */
    NhlRLSetString(rlist,"lbTitleString","Gsltod Colormap");
/*
 * Label every other entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 2);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 32);

    NhlSetValues(lbar,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 *  Change the colormap to one of the predefined colormaps
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","gsdtol");
    NhlSetValues(wks,rlist);
/*
 *  Change the labelbar title, annotation, and number of entries.
 */
    NhlRLClear(rlist);
/*  
 * Labelbar title
 */
    NhlRLSetString(rlist,"lbTitleString","Gsdtol Colormap");
/*
 * Label every other entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 2);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 32);

    NhlSetValues(lbar,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 *  Change the colormap to one of the predefined colormaps
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","uniform");
    NhlSetValues(wks,rlist);
/*
 *  Change the labelbar title, annotation, and number of entries.
 */
    NhlRLClear(rlist);
/*
 * Labelbar title
 */
    NhlRLSetString(rlist,"lbTitleString","Uniform Colormap");
/*
 * Label every 10th entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 10);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 112);

    NhlSetValues(lbar,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 *  Change the colormap to one of the predefined colormaps
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","temp1");
    NhlSetValues(wks,rlist);
/*
 *  Change the labelbar title, annotation, and number of entries.
 */
    NhlRLClear(rlist);
/*
 * Labelbar title
 */
    NhlRLSetString(rlist,"lbTitleString","Temp1 Colormap");
/*
 * Label every 5th entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 5);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 62);

    NhlSetValues(lbar,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 *  Change the colormap to one of the predefined colormaps
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","psgcap");
    NhlSetValues(wks,rlist);
/*
 *  Change the labelbar title, annotation, and number of entries.
 */
    NhlRLClear(rlist);
/*
 * Labelbar title
 */
    NhlRLSetString(rlist,"lbTitleString","Psgcap Colormap");
/*
 * Label every 15th entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 15);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 230);

    NhlSetValues(lbar,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 *  Change the colormap to one of the predefined colormaps
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","example");
    NhlSetValues(wks,rlist);
/*
 *  Change the labelbar title, annotation, and number of entries.
 */
    NhlRLClear(rlist);
/*
 * Labelbar title
 */
    NhlRLSetString(rlist,"lbTitleString","Example Colormap");
/*
 * Label every 15th entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 10);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 114);

    NhlSetValues(lbar,rlist);
/*
 * Draw the labelbar displaying the default colormap and textual annotation
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 * This next example changes three entries in the colormap.  Changing the
 * first entry (colormap index 0) in the colormap, sets the background
 * color for a plot. The second entry (color index 1) sets the foreground
 * color for a plot.
 *
 * The colormap is stored in a 3xN variable where N is the length of
 * the colormap.  Each entry in the color map consists of a vector
 * of 3 normalized red-green-blue color values.
 *
 * Assign gray scale colormap
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,"wkColorMap","gscyclic");
    NhlSetValues(wks,rlist);
/*
 * Copy the colormap rgb values into the variable cmap
 */
    glist = NhlRLCreate(NhlGETRL);
    NhlRLClear(glist);
    NhlRLGetMDFloatArray(glist,"wkColorMap",&cmap,&num_dims,&len_dims);
    NhlGetValues(wks,glist);
/*
 * Change the first entry in the colormap array to blue, the
 * second to green, and the fourth to red..
 *
 * Background color
 */
    cmap[0*3 + 0] = 0.0;
    cmap[0*3 + 1] = 0.0;
    cmap[0*3 + 2] = 1.0;
/*
 * Foreground color
 */
    cmap[1*3 + 0] = 0.0;
    cmap[1*3 + 1] = 1.0;
    cmap[1*3 + 2] = 0.0;
/*
 * Colormap entry 3
 */
    cmap[3*3 + 0] = 1.0;
    cmap[3*3 + 1] = 0.0;
    cmap[3*3 + 2] = 0.0;
/*
 * Assign the new color map to the workstation object.
 */
    NhlRLClear(rlist);
    NhlRLSetMDFloatArray(rlist,"wkColorMap",cmap,num_dims,len_dims);
    NhlSetValues(wks,rlist);
/*
 * Add a different title.
 */
    NhlRLClear(rlist);
/*
 * Set the title for the labelbar
 */
    NhlRLSetString(rlist,"lbTitleString","Changing colormap entries");
/*
 * Label every entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 1);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 7);

    NhlSetValues(lbar,rlist);
/*
 * Change the textual annotation at bottom of frame
 */
    NhlRLClear(rlist);
/*
 * Set the title for the labelbar
 */
    NhlRLSetString(rlist,"txString","Entry 0 (background) set to Blue");

    NhlSetValues(text,rlist);
/*
 * Draw and frame the labelbar.
 */
    NhlDraw(lbar);
    NhlDraw(text);
    NhlFrame(wks);
/*
 * This next example demonstrates how to create and assign a new colormap.
 *
 * Create an array that will contain the new colormap.  For this example,
 * we are creating a colormap with 100 (arbitrary size) rgb entries.
 *
 * Assign new RGB values to each entry of the colormap.
 * The first entry (background color) is black.  The rest of
 * the colormap is a smooth table that ranges from red to blue.
 */
    newcmap[0*3 + 0] = 0.; /* red component */
    newcmap[0*3 + 1] = 0.; /* green component */
    newcmap[0*3 + 2] = 0.; /* blue component */

    for(i=1; i<100; i++) {
        newcmap[i*3 + 0] = 1.0-(i/99.0);
        newcmap[i*3 + 1] = i/99.0;
        newcmap[i*3 + 2] = i/99.0;
    }
/*
 * Assign the new color map to the workstation object.
 */
    NhlRLClear(rlist);
    num_dims=2;
    len_dims[0]=100;
    len_dims[1]=3;
    NhlRLSetMDFloatArray(rlist,"wkColorMap",newcmap,num_dims,len_dims);
    NhlSetValues(wks,rlist);
/*
 * Assign a new title.
 */
    NhlRLClear(rlist);
/*
 * Set the title for the labelbar
 */
    NhlRLSetString(rlist,"lbTitleString","New colormap");
/*
 * Label every entry
 */
    NhlRLSetInteger(rlist, "lbLabelStride", 10);                  
/*
 * Number of entries to display
 */
    NhlRLSetInteger(rlist, "lbBoxCount", 99);

    NhlSetValues(lbar,rlist);
/*
 * Draw and frame the labelbar
 */
    NhlDraw(lbar);
    NhlFrame(wks);
/* 
 * Clean up
 */
    NhlDestroy(lbar);
    NhlDestroy(text);
    NhlDestroy(wks);

    NhlClose();
    exit (0);
}