This file is indexed.

/usr/share/ncarg/hluex/xyplot/xy10c.c is in libncarg-data 6.1.2-7.

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
/*
**      $Id: xy10c.c,v 1.6 2010-03-15 22:49:25 haley Exp $
*/
/***********************************************************************
*                                                                      *
*                Copyright (C)  1995                                   *
*        University Corporation for Atmospheric Research               *
*                All Rights Reserved                                   *
*                                                                      *
***********************************************************************/
/*
**  File:       xy10c.c
**
**  Author:     Mary Haley
**          National Center for Atmospheric Research
**          PO 3000, Boulder, Colorado
**
**  Date:       Thu May  4 15:24:48 MDT 1995
**
** Description:    This example shows how to overlay an XyPlot
**                 on a MapPlot.
*/

#include <stdio.h>
#include <math.h>
#include <ncarg/hlu/hlu.h>
#include <ncarg/hlu/ResList.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/MapPlot.h>
#include <ncarg/hlu/CoordArrays.h>
#include <netcdf.h>

/*
 * Define the day and the hour for which we are getting data values.
 * (March 18, 1995, hour 0).
 */
char *file = "95031800_sao.cdf";

int main()
{
/*
 * Declare variables for the HLU routine calls.
 */
    int     appid, xworkid, xyid1, xyid2, mpid1, mpid2, dataid;
    int     rlist, i;
    float   *lat, *lon;
    float   special_value = -9999.;
/*
 * Declare variables for getting information from netCDF file.
 */
    int     ncid, latid, lonid, recid;
    int     ndims, nvars, ngatts;
    long    rec_len;
    long    start[1], count[1];
    char    filename[256], recname[50];
    const   char *dir = _NGGetNCARGEnv("data");

    char const *wks_type = "x11";
/*
 * Initialize the HLU library and set up resource template.
 */
    NhlInitialize();
    rlist = NhlRLCreate(NhlSETRL);
/*
 * Create Application object.  The Application object name is used to
 * determine the name of the resource file, which is "xy10.res" in
 * this case.
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNappDefaultParent,"True");
    NhlRLSetString(rlist,NhlNappUsrDir,"./");
    NhlCreate(&appid,"xy10",NhlappClass,NhlDEFAULT_APP,rlist);

    if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
/*
 * Create a meta file object.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkMetaName,"./xy10c.ncgm");
        NhlCreate(&xworkid,"xy10Work",NhlncgmWorkstationClass,
                  NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
/*
 * Create an X11 workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetInteger(rlist,NhlNwkPause,True);
        NhlCreate(&xworkid,"xy10Work",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,"./xy10c.ps");
        NhlCreate(&xworkid,"xy10Work",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,"./xy10c.pdf");
        NhlCreate(&xworkid,"xy10Work",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,"./xy10c");
        NhlRLSetString(rlist,NhlNwkFormat, (char*)wks_type);
        NhlCreate(&xworkid,"xy10Work",NhlcairoDocumentWorkstationClass,
                  NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
/*
 * Create a cairo PNG workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"./xy10c");
        NhlRLSetString(rlist,NhlNwkFormat, (char*)wks_type);
        NhlCreate(&xworkid,"xy10Work",NhlcairoImageWorkstationClass,
                  NhlDEFAULT_APP,rlist);
    }
/*
 * Open the netCDF file.
 */
    sprintf( filename, "%s/cdf/%s", dir, file );
/*
 * Open the netCDF file.
 */
    ncid = ncopen(filename,NC_NOWRITE);
/*
 * Get the record length and dimension name.
 */
    ncinquire(ncid, &ndims, &nvars, &ngatts, &recid);
    ncdiminq(ncid, recid, recname, &rec_len);
/*
 * Malloc space for lat/lon arrays.
 */
    lat = (float *)malloc(sizeof(float)*rec_len);
    lon = (float *)malloc(sizeof(float)*rec_len);
    if (lat == NULL || lon == NULL ) {
        NhlPError(NhlFATAL,NhlEUNKNOWN,
                  "Unable to malloc space for lat/lon arrays");
        exit(1);
    }
/*
 * Get the ids of the lat/lon arrays.
 */
    latid = ncvarid(ncid,"lat");
    lonid = ncvarid(ncid,"lon");
/*
 * Get lat/lon data values.
 */
    start[0] = 0; count[0] = rec_len;
    ncvarget(ncid,latid,(long const *)start,(long const *)count,lat);
    ncvarget(ncid,lonid,(long const *)start,(long const *)count,lon);
/*
 * Close the netCDF file.
 */
    ncclose(ncid);
/*
 * Throw out values that may be incorrect.
 */ 
    for( i = 0; i < rec_len; i++ ) {
        if( lat[i] <  -90. || lat[i] >  90.) lat[i] = special_value;
        if( lon[i] < -180. || lon[i] > 180.) lon[i] = special_value;
    }
/*
 * Define the Data object.
 */
    NhlRLClear(rlist);
    NhlRLSetFloatArray(rlist,NhlNcaXArray,lon,rec_len);
    NhlRLSetFloatArray(rlist,NhlNcaYArray,lat,rec_len);
    NhlCreate(&dataid,"xyData",NhlcoordArraysClass,
                  NhlDEFAULT_APP,rlist);
/*
 * The id for this Data object is now the resource value for
 * "xyCoordData".  Tweak some XyPlot resources in the resource file
 * ("xy10.res").
 */
    NhlRLClear(rlist);
    NhlRLSetInteger(rlist,NhlNxyCoordData,dataid);
    NhlCreate(&xyid1,"xyPlot1",NhlxyPlotClass,xworkid,rlist);
/*
 * Plot all of the station ids.
 */
    NhlDraw(xyid1);
    NhlFrame(xworkid);
/*
 * Create a second XyPlot object with a different name so we can
 * change the "tr" resources to limit the plot within the mainland
 * United States.
 */
    NhlRLClear(rlist);
    NhlRLSetInteger(rlist,NhlNxyCoordData,dataid);
    NhlCreate(&xyid2,"xyPlot2",NhlxyPlotClass,xworkid,rlist);
/*
 * Plot station ids over mainland United States only.  This is done
 * using resources in the "xy10.res" resource file.
 */
    NhlDraw(xyid2);
    NhlFrame(xworkid);
/*
 * Create two MapPlots, one of the world and one of the United States 
 * (projection parameters are set up in the "xy10.res" resource file).
 */
    NhlCreate(&mpid1,"mpPlot1",NhlmapPlotClass,xworkid,0);

    NhlCreate(&mpid2,"mpPlot2",NhlmapPlotClass,xworkid,0);
/*
 * Draw the two map plots. 
 */
    NhlDraw(mpid1);
    NhlFrame(xworkid);

    NhlDraw(mpid2);
    NhlFrame(xworkid);
/*
 * Overlay the first XyPlot object on the first MapPlot object.  This
 * will plot station ids over the world.
 */
    NhlAddOverlay(mpid1,xyid1,-1);
    NhlDraw(mpid1);
    NhlFrame(xworkid);
/*
 * Overlay the second XyPlot object on the second MapPlot object.  This
 * will plot station ids over mainland United States only.
 */
    NhlAddOverlay(mpid2,xyid2,-1);
    NhlDraw(mpid2);
    NhlFrame(xworkid);
/*
 * NhlDestroy destroys the given id and all of its children so
 * destroying "appid" will destroy "xworkid" which will also destroy
 * "xyid".
 */
    NhlRLDestroy(rlist);
    NhlDestroy(xworkid);
    NhlDestroy(appid);
/*
 * Restores state.
 */
    NhlClose();
    exit(0);
}