This file is indexed.

/usr/share/ncarg/hluex/basic/basic06c.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
/*************************************************************************
 *                                                                       *
 *                Copyright (C)  1995                                    *
 *        University Corporation for Atmospheric Research                *
 *                All Rights Reserved                                    *
 *                                                                       *
 *************************************************************************
 *
 *   File:         basic06c.c
 *
 *   Author:       Fred Clare
 *                 National Center for Atmospheric Research
 *                 PO 3000, Boulder, Colorado
 *
 *
 *   Date:         Wed May 24 12:54:47 MDT 1995
 *
 *   Description:  This C program demonstrates how to position 
 *                 objects on an output device and how to change 
 *                 their sizes.  A simple color table is also defined 
 *                 and used for changing the color of a curve in an 
 *                 XyPlot.  The script begins with two procedures - 
 *                 one for drawing plot objects and one for drawing 
 *                 text objects.
 */

#include <stdio.h>
#include <math.h>

#include <ncarg/hlu/App.h>
#include <ncarg/hlu/NcgmWorkstation.h>
#include <ncarg/hlu/PSWorkstation.h>
#include <ncarg/hlu/PDFWorkstation.h>
#include <ncarg/hlu/CairoWorkstation.h>
#include <ncarg/hlu/XyPlot.h>
#include <ncarg/hlu/CoordArrays.h>
#include <ncarg/hlu/TickMark.h>
#include <ncarg/hlu/TextItem.h>
#include <ncarg/hlu/DataComm.h>


void draw_plot();
void draw_text();

/*
 * Main program.
 */
int main()
{

    int appid,rlist;
    int xwork_id,text_id,box_id,data_id;
    int dataspec;
    int i;

    char text[6];

    float xdra[] = {0.0, 0.1, 0.5, 0.9, 1.0, 0.9, 0.5, 0.1, 0.0};
    float ydra[] = {0.5, 0.9, 1.0, 0.9, 0.5, 0.1, 0.0, 0.1, 0.5};
    float xpos,ypos;

/*
 * Define a simple color map (index 0 defines the background color).
 */
    float cmap[4][3] = { { 1.0, 1.0, 1.0 },
                 { 0.0, 0.0, 1.0 },
                 { 0.0, 1.0, 0.0 },
                 { 1.0, 0.0, 0.0 } };
    ng_size_t dims[] = {4,3};
/*
 * Set the display. Default is to display output to an X workstation.
 */
    char const *wks_type = "x11";

/*
 * Initialize the high level utility library and create application.
 */
    NhlInitialize();

        rlist = NhlRLCreate(NhlSETRL);
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNappUsrDir,"./");
        NhlCreate(&appid,"basic06",NhlappClass,NhlDEFAULT_APP,rlist);


    if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
    /*
     * Create a meta file workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkMetaName,"./basic06c.ncgm");
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlncgmWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
    /*
     * Create an X workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetInteger(rlist,NhlNwkPause,True);
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlcairoWindowWorkstationClass,
                          NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"oldps") || !strcmp(wks_type,"OLDPS")) {
    /*
     * Create a PS file workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPSFileName,"./basic06c.ps");
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlpsWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"oldpdf") || !strcmp(wks_type,"OLDPDF")) {
    /*
     * Create a PS file workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPDFFileName,"./basic06c.pdf");
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",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,"./basic06c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlcairoDocumentWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
    /*
     * Create a cairo PNG workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"./basic06c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlcairoImageWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }

/*
 * Create data object for an XyPlot
 */
    NhlRLClear(rlist);
    NhlRLSetFloatArray(rlist,NhlNcaXArray,xdra,NhlNumber(xdra));
    NhlRLSetFloatArray(rlist,NhlNcaYArray,ydra,NhlNumber(ydra));
    NhlCreate(&data_id,"xyData",NhlcoordArraysClass,NhlDEFAULT_APP,rlist);

/*
 * Create a simple XyPlot object with no labels or borders.  The
 * parent for this object is xwork_id, hence it will be sent to
 * the workstation identified by xwork_id when the draw procedure
 * is invoked on it.
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtmXBBorderOn,"False");
    NhlRLSetString(rlist,NhlNtmXTBorderOn,"False");
    NhlRLSetString(rlist,NhlNtmYLBorderOn,"False");
    NhlRLSetString(rlist,NhlNtmYRBorderOn,"False");
    NhlRLSetString(rlist,NhlNtmXBOn,"False");
    NhlRLSetString(rlist,NhlNtmXTOn,"False");
    NhlRLSetString(rlist,NhlNtmYLOn,"False");
    NhlRLSetString(rlist,NhlNtmYROn,"False");
    NhlRLSetFloat(rlist,NhlNvpXF,0.0);
    NhlRLSetFloat(rlist,NhlNvpYF,1.0);
    NhlRLSetFloat(rlist,NhlNvpWidthF,1.0);
    NhlRLSetFloat(rlist,NhlNvpHeightF,1.0);
    NhlCreate(&box_id,"Box",NhlxyPlotClass,xwork_id,rlist);

/*
 * Create a TextItem object.
 */
    NhlRLClear(rlist);
    NhlRLSetFloat(rlist,NhlNtxPosXF,0.5);
    NhlRLSetFloat(rlist,NhlNtxPosYF,0.5);
    NhlRLSetInteger(rlist,NhlNtxFont,26);
        NhlCreate(&text_id,"Text",NhltextItemClass,xwork_id,rlist);

/*
 * Add the data identified by data_id to the XyPlot.
 */
    dataspec = NhlAddData(box_id,"xyCoordData",data_id);

/*
 * Draw three labeled boxes at different sizes and in different positions
 * and with different colors.
 */
    for(i=1;i<=3;++i)
    {
        xpos = -0.05*i*i + 0.5*i - 0.20;
        ypos = 1.0-xpos;
        sprintf(text,"%s %d","Box",i);  

    /*
     * Specify a text string and its color.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNtxString,text);
        NhlRLSetInteger(rlist,NhlNtxFontColor,4-i);
        NhlSetValues(text_id,rlist);

    /*
     * Set the XyPlot curve color.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNxyMonoLineColor,"True");
        NhlRLSetInteger(rlist,NhlNxyLineColor,i);
        NhlSetValues(dataspec,rlist);

    /*
     * Draw box and text.
     */
        draw_plot(box_id, xpos, ypos, 0.36-0.09*(i-1));
        draw_text(text_id, xpos, ypos, 0.08-0.02*(i-1));
    }

    NhlFrame(xwork_id);

    NhlDestroy(xwork_id);
        NhlClose();
    exit (0);
}


void draw_plot(id,x,y,scale)
int id;
float x,y,scale;
{
/*
 * This procedure takes the plot object with identifier "id" and 
 * draws it centered at coordinate (x,y) and scaled by "scale".  
 * The original plot object is returned unchanged.
 */
    int rlist = NhlRLCreate(NhlSETRL);
    int grlist = NhlRLCreate(NhlGETRL);

    float x_ref,y_ref,width_ref,height_ref;

    NhlRLClear(grlist);
    NhlRLGetFloat(grlist,NhlNvpXF,&x_ref);
    NhlRLGetFloat(grlist,NhlNvpYF,&y_ref);
    NhlRLGetFloat(grlist,NhlNvpWidthF,&width_ref);
    NhlRLGetFloat(grlist,NhlNvpHeightF,&height_ref);
        NhlGetValues(id,grlist);

    NhlRLClear(rlist);
    NhlRLSetFloat(rlist,NhlNvpXF,x - 0.5*width_ref*scale);
    NhlRLSetFloat(rlist,NhlNvpYF,y + 0.5*height_ref*scale);
    NhlRLSetFloat(rlist,NhlNvpWidthF,width_ref*scale);
    NhlRLSetFloat(rlist,NhlNvpHeightF,height_ref*scale);
        NhlSetValues(id,rlist);

        NhlDraw(id);

    NhlRLClear(rlist);
    NhlRLSetFloat(rlist,NhlNvpXF,x_ref);
    NhlRLSetFloat(rlist,NhlNvpYF,y_ref);
    NhlRLSetFloat(rlist,NhlNvpWidthF,width_ref);
    NhlRLSetFloat(rlist,NhlNvpHeightF,height_ref);
        NhlSetValues(id,rlist);
}

void draw_text(id,x,y,height)
int id;
float x,y,height;
{
/*
 * This procedure takes the text string in the object identified by "id"
 * and draws it centered at coordinate (x,y) with a height of "height".
 */
    int rlist = NhlRLCreate(NhlSETRL);
    int grlist = NhlRLCreate(NhlGETRL);

    float xpos,ypos,fheight;

    NhlRLClear(grlist);
    NhlRLGetFloat(grlist,NhlNtxPosXF,&xpos);
    NhlRLGetFloat(grlist,NhlNtxPosYF,&ypos);
    NhlRLGetFloat(grlist,NhlNtxFontHeightF,&fheight);
        NhlGetValues(id,grlist);

    NhlRLClear(rlist);
    NhlRLSetFloat(rlist,NhlNtxPosXF,x);
    NhlRLSetFloat(rlist,NhlNtxPosYF,y);
    NhlRLSetFloat(rlist,NhlNtxFontHeightF,height);
        NhlSetValues(id,rlist);

        NhlDraw(id);

    NhlRLClear(rlist);
    NhlRLSetFloat(rlist,NhlNtxPosXF,xpos);
    NhlRLSetFloat(rlist,NhlNtxPosYF,ypos);
    NhlRLSetFloat(rlist,NhlNtxFontHeightF,fheight);
        NhlSetValues(id,rlist);
}