Line data Source code
1 : /*****************************************************************************
2 : *
3 : * This module has a number of additions and improvements over the original
4 : * implementation to be suitable for usage in GDAL HDF driver.
5 : *
6 : * Andrey Kiselev <dron@ak4719.spb.edu> is responsible for all the changes.
7 : ****************************************************************************/
8 :
9 : /*
10 : Copyright (C) 1996 Hughes and Applied Research Corporation
11 :
12 : Permission to use, modify, and distribute this software and its documentation
13 : for any purpose without fee is hereby granted, provided that the above
14 : copyright notice appear in all copies and that both that copyright notice and
15 : this permission notice appear in supporting documentation.
16 : */
17 :
18 : #include "cpl_port.h"
19 : #include <errno.h>
20 : #include <limits.h>
21 : #include "mfhdf.h"
22 : #include "HdfEosDef.h"
23 :
24 : /* Set maximum number of HDF-EOS files to HDF limit (MAX_FILE) */
25 : #define NEOSHDF MAX_FILE
26 : static intn EHXmaxfilecount = 0;
27 : static uint8 *EHXtypeTable = NULL;
28 : static uint8 *EHXacsTable = NULL;
29 : static int32 *EHXfidTable = NULL;
30 : static int32 *EHXsdTable = NULL;
31 :
32 : /* define a macro for the string size of the utility strings and some dimension
33 : list strings. The value in previous versions of this code may not be
34 : enough in some cases. The length now is 512 which seems to be more than
35 : enough to hold larger strings. */
36 :
37 : #define UTLSTR_MAX_SIZE 512
38 : #define UTLSTRSIZE 32000
39 :
40 : #define EHIDOFFSET 524288
41 :
42 : #define HDFEOSVERSION 2.12
43 : #define HDFEOSVERSION1 "2.12"
44 : #include "HDFEOSVersion.h"
45 :
46 : #define MAX_RETRIES 10
47 :
48 : /* Function Prototypes */
49 : static intn EHreset_maxopenfiles(intn);
50 : static intn EHget_maxopenfiles(intn *, intn *);
51 : static intn EHget_numfiles(void);
52 :
53 : /*----------------------------------------------------------------------------|
54 : | BEGIN_PROLOG |
55 : | |
56 : | FUNCTION: EHopen |
57 : | |
58 : | DESCRIPTION: Opens HDF-EOS file and returns file handle |
59 : | |
60 : | |
61 : | Return Value Type Units Description |
62 : | ============ ====== ========= ===================================== |
63 : | fid int32 HDF-EOS file ID |
64 : | |
65 : | INPUTS: |
66 : | filename char Filename |
67 : | access intn HDF access code |
68 : | |
69 : | OUTPUTS: |
70 : | None |
71 : | |
72 : | NOTES: |
73 : | |
74 : | |
75 : | Date Programmer Description |
76 : | ====== ============ ================================================= |
77 : | Jun 96 Joel Gales Original Programmer |
78 : | Jul 96 Joel Gales Add file id offset EHIDOFFSET |
79 : | Aug 96 Joel Gales Add "END" statement to structural metadata |
80 : | Sep 96 Joel Gales Reverse order of Hopen and SDstart statements |
81 : | for RDWR and READ access |
82 : | Oct 96 Joel Gales Trap CREATE & RDWR (no write permission) |
83 : | access errors |
84 : | Apr 97 Joel Gales Fix problem with RDWR open when file previously |
85 : | open for READONLY access |
86 : | |
87 : | END_PROLOG |
88 : -----------------------------------------------------------------------------*/
89 : int32
90 46 : EHopen(const char *filename, intn access)
91 :
92 : {
93 : intn i; /* Loop index */
94 46 : intn status = 0; /* routine return status variable */
95 : intn dum; /* Dummy variable */
96 46 : intn curr_max = 0; /* maximum # of HDF files to open */
97 46 : intn sys_limit = 0; /* OS limit for maximum # of opened files */
98 :
99 46 : int32 HDFfid = 0; /* HDF file ID */
100 46 : int32 fid = -1; /* HDF-EOS file ID */
101 46 : int32 sdInterfaceID = 0; /* HDF SDS interface ID */
102 : int32 attrIndex; /* Structural Metadata attribute index */
103 :
104 46 : uint8 acs = 0; /* Read (0) / Write (1) access code */
105 :
106 : char *testname; /* Test filename */
107 : char errbuf[256];/* Error report buffer */
108 : char *metabuf; /* Pointer to structural metadata buffer */
109 : char hdfeosVersion[32]; /* HDFEOS version string */
110 :
111 : intn retryCount;
112 :
113 : /* Request the system allowed number of opened files */
114 : /* and increase HDFEOS file tables to the same size */
115 : /* ------------------------------------------------- */
116 46 : if (EHget_maxopenfiles(&curr_max, &sys_limit) >= 0
117 46 : && curr_max < sys_limit)
118 : {
119 40 : if (EHreset_maxopenfiles(sys_limit) < 0)
120 : {
121 0 : HEpush(DFE_ALROPEN, "EHopen", __FILE__, __LINE__);
122 0 : HEreport("Can't set maximum opened files number to \"%d\".\n", curr_max);
123 0 : return -1;
124 : }
125 : }
126 :
127 : /* Setup file interface */
128 : /* -------------------- */
129 46 : if (EHget_numfiles() < EHXmaxfilecount)
130 : {
131 :
132 : /*
133 : * Check that file has not been previously opened for write access if
134 : * current open request is not READONLY
135 : */
136 46 : if (access != DFACC_READ)
137 : {
138 : /* Loop through all files */
139 : /* ---------------------- */
140 0 : for (i = 0; i < EHXmaxfilecount; i++)
141 : {
142 : /* if entry is active file opened for write access ... */
143 : /* --------------------------------------------------- */
144 0 : if (EHXtypeTable[i] != 0 && EHXacsTable[i] == 1)
145 : {
146 : /* Get filename (testname) */
147 : /* ----------------------- */
148 0 : Hfidinquire(EHXfidTable[i], &testname, &dum, &dum);
149 :
150 :
151 : /* if same as filename then report error */
152 : /* ------------------------------------- */
153 0 : if (strcmp(testname, filename) == 0)
154 : {
155 0 : status = -1;
156 0 : fid = -1;
157 0 : HEpush(DFE_ALROPEN, "EHopen", __FILE__, __LINE__);
158 0 : HEreport("\"%s\" already open.\n", filename);
159 0 : break;
160 : }
161 : }
162 : }
163 : }
164 46 : if (status == 0)
165 : {
166 : /* Create HDF-EOS file */
167 : /* ------------------- */
168 46 : switch (access)
169 : {
170 0 : case DFACC_CREATE:
171 :
172 : /* Get SDS interface ID */
173 : /* -------------------- */
174 0 : sdInterfaceID = SDstart(filename, DFACC_CREATE);
175 :
176 : /* If SDstart successful ... */
177 : /* ------------------------- */
178 0 : if (sdInterfaceID != -1)
179 : {
180 : /* Set HDFEOS version number in file */
181 : /* --------------------------------- */
182 0 : snprintf(hdfeosVersion, sizeof(hdfeosVersion), "%s%s", "HDFEOS_V",
183 : HDFEOSVERSION1);
184 0 : SDsetattr(sdInterfaceID, "HDFEOSVersion", DFNT_CHAR8,
185 0 : (int)strlen(hdfeosVersion), hdfeosVersion);
186 :
187 :
188 : /* Get HDF file ID */
189 : /* --------------- */
190 0 : HDFfid = Hopen(filename, DFACC_RDWR, 0);
191 :
192 : /* Set open access to write */
193 : /* ------------------------ */
194 0 : acs = 1;
195 :
196 : /* Setup structural metadata */
197 : /* ------------------------- */
198 0 : metabuf = (char *) calloc(UTLSTRSIZE, 1);
199 0 : if(metabuf == NULL)
200 : {
201 0 : HEpush(DFE_NOSPACE,"EHopen", __FILE__, __LINE__);
202 0 : return(-1);
203 : }
204 :
205 0 : strcpy(metabuf, "GROUP=SwathStructure\n");
206 0 : strcat(metabuf, "END_GROUP=SwathStructure\n");
207 0 : strcat(metabuf, "GROUP=GridStructure\n");
208 0 : strcat(metabuf, "END_GROUP=GridStructure\n");
209 0 : strcat(metabuf, "GROUP=PointStructure\n");
210 0 : strcat(metabuf, "END_GROUP=PointStructure\n");
211 0 : strcat(metabuf, "END\n");
212 :
213 : /* Write Structural metadata */
214 : /* ------------------------- */
215 0 : SDsetattr(sdInterfaceID, "StructMetadata.0",
216 : DFNT_CHAR8, UTLSTRSIZE, metabuf);
217 0 : free(metabuf);
218 : } else
219 : {
220 : /* If error in SDstart then report */
221 : /* ------------------------------- */
222 0 : fid = -1;
223 0 : status = -1;
224 0 : HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__);
225 0 : snprintf(errbuf, sizeof(errbuf), "%s%s%s", "\"", filename,
226 : "\" cannot be created.");
227 0 : HEreport("%s\n", errbuf);
228 : }
229 :
230 0 : break;
231 :
232 : /* Open existing HDF-EOS file for read/write access */
233 : /* ------------------------------------------------ */
234 0 : case DFACC_RDWR:
235 :
236 : /* Get HDF file ID */
237 : /* --------------- */
238 : #ifndef _PGS_OLDNFS
239 : /* The following loop around the function Hopen is intended to deal with the NFS cache
240 : problem when opening file fails with errno = 150 or 151. When NFS cache is updated,
241 : this part of change is no longer necessary. 10/18/1999 */
242 0 : retryCount = 0;
243 0 : HDFfid = -1;
244 0 : while ((HDFfid == -1) && (retryCount < MAX_RETRIES))
245 : {
246 0 : HDFfid = Hopen(filename, DFACC_RDWR, 0);
247 0 : if((HDFfid == -1) && (errno == 150 || errno == 151))
248 : {
249 0 : HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__);
250 0 : snprintf(errbuf, sizeof(errbuf), "\"%s\" cannot be opened for READ/WRITE access, will retry %d times.", filename, (MAX_RETRIES - retryCount - 1));
251 0 : HEreport("%s\n", errbuf);
252 : }
253 0 : retryCount++;
254 : }
255 : #else
256 : HDFfid = Hopen(filename, DFACC_RDWR, 0);
257 : #endif
258 :
259 : /* If Hopen successful ... */
260 : /* ----------------------- */
261 0 : if (HDFfid != -1)
262 : {
263 : /* Get SDS interface ID */
264 : /* -------------------- */
265 0 : sdInterfaceID = SDstart(filename, DFACC_RDWR);
266 :
267 : /* If SDstart successful ... */
268 : /* ------------------------- */
269 0 : if (sdInterfaceID != -1)
270 : {
271 : /* Set HDFEOS version number in file */
272 : /* --------------------------------- */
273 :
274 0 : attrIndex = SDfindattr(sdInterfaceID, "HDFEOSVersion");
275 0 : if (attrIndex == -1)
276 : {
277 0 : snprintf(hdfeosVersion, sizeof(hdfeosVersion), "%s%s", "HDFEOS_V",
278 : HDFEOSVERSION1);
279 0 : SDsetattr(sdInterfaceID, "HDFEOSVersion", DFNT_CHAR8,
280 0 : (int)strlen(hdfeosVersion), hdfeosVersion);
281 : }
282 : /* Set open access to write */
283 : /* ------------------------ */
284 0 : acs = 1;
285 :
286 : /* Get structural metadata attribute ID */
287 : /* ------------------------------------ */
288 0 : attrIndex = SDfindattr(sdInterfaceID, "StructMetadata.0");
289 :
290 : /* Write structural metadata if it doesn't exist */
291 : /* --------------------------------------------- */
292 0 : if (attrIndex == -1)
293 : {
294 0 : metabuf = (char *) calloc(UTLSTRSIZE, 1);
295 0 : if(metabuf == NULL)
296 : {
297 0 : HEpush(DFE_NOSPACE,"EHopen", __FILE__, __LINE__);
298 0 : return(-1);
299 : }
300 :
301 0 : strcpy(metabuf, "GROUP=SwathStructure\n");
302 0 : strcat(metabuf, "END_GROUP=SwathStructure\n");
303 0 : strcat(metabuf, "GROUP=GridStructure\n");
304 0 : strcat(metabuf, "END_GROUP=GridStructure\n");
305 0 : strcat(metabuf, "GROUP=PointStructure\n");
306 0 : strcat(metabuf, "END_GROUP=PointStructure\n");
307 0 : strcat(metabuf, "END\n");
308 :
309 0 : SDsetattr(sdInterfaceID, "StructMetadata.0",
310 : DFNT_CHAR8, UTLSTRSIZE, metabuf);
311 0 : free(metabuf);
312 : }
313 : } else
314 : {
315 : /* If error in SDstart then report */
316 : /* ------------------------------- */
317 0 : fid = -1;
318 0 : status = -1;
319 0 : HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__);
320 0 : snprintf(errbuf, sizeof(errbuf), "%s%s%s", "\"", filename,
321 : "\" cannot be opened for read/write access.");
322 0 : HEreport("%s\n", errbuf);
323 : }
324 : } else
325 : {
326 : /* If error in Hopen then report */
327 : /* ----------------------------- */
328 0 : fid = -1;
329 0 : status = -1;
330 0 : HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__);
331 0 : snprintf(errbuf, sizeof(errbuf), "%s%s%s", "\"", filename,
332 : "\" cannot be opened for RDWR access.");
333 0 : HEreport("%s\n", errbuf);
334 : }
335 :
336 0 : break;
337 :
338 :
339 : /* Open existing HDF-EOS file for read-only access */
340 : /* ----------------------------------------------- */
341 46 : case DFACC_READ:
342 :
343 : /* Get HDF file ID */
344 : /* --------------- */
345 : #ifndef _PGS_OLDNFS
346 : /* The following loop around the function Hopen is intended to deal with the NFS cache
347 : problem when opening file fails with errno = 150 or 151. When NFS cache is updated,
348 : this part of change is no longer necessary. 10/18/1999 */
349 46 : retryCount = 0;
350 46 : HDFfid = -1;
351 92 : while ((HDFfid == -1) && (retryCount < MAX_RETRIES))
352 : {
353 46 : HDFfid = Hopen(filename, DFACC_READ, 0);
354 46 : if((HDFfid == -1) && (errno == 150 || errno == 151))
355 : {
356 0 : HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__);
357 0 : snprintf(errbuf, sizeof(errbuf), "\"%s\" cannot be opened for READONLY access, will retry %d times.", filename, (MAX_RETRIES - retryCount - 1));
358 0 : HEreport("%s\n", errbuf);
359 : }
360 46 : retryCount++;
361 : }
362 : #else
363 : HDFfid = Hopen(filename, DFACC_READ, 0);
364 : #endif
365 :
366 : /* If file does not exist report error */
367 : /* ----------------------------------- */
368 46 : if (HDFfid == -1)
369 : {
370 0 : fid = -1;
371 0 : status = -1;
372 0 : HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__);
373 0 : snprintf(errbuf, sizeof(errbuf), "\"%s\" (opened for READONLY access) does not exist.", filename);
374 0 : HEreport("%s\n", errbuf);
375 : } else
376 : {
377 : /* If file exists then get SD interface ID */
378 : /* --------------------------------------- */
379 46 : sdInterfaceID = SDstart(filename, DFACC_RDONLY);
380 :
381 : /* If SDstart successful ... */
382 : /* ------------------------- */
383 46 : if (sdInterfaceID != -1)
384 : {
385 :
386 : /* Set open access to read-only */
387 : /* ---------------------------- */
388 46 : acs = 0;
389 : } else
390 : {
391 : /* If error in SDstart then report */
392 : /* ------------------------------- */
393 0 : fid = -1;
394 0 : status = -1;
395 0 : HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__);
396 0 : snprintf(errbuf, sizeof(errbuf), "%s%s%s", "\"", filename,
397 : "\" cannot be opened for read access.");
398 0 : HEreport("%s\n", errbuf);
399 : }
400 : }
401 :
402 46 : break;
403 :
404 0 : default:
405 : /* Invalid Access Code */
406 : /* ------------------- */
407 0 : fid = -1;
408 0 : status = -1;
409 0 : HEpush(DFE_BADACC, "EHopen", __FILE__, __LINE__);
410 0 : HEreport("Access Code: %d (%s).\n", access, filename);
411 : }
412 :
413 0 : }
414 : } else
415 : {
416 : /* Too many files opened */
417 : /* --------------------- */
418 0 : status = -1;
419 0 : fid = -1;
420 0 : HEpush(DFE_TOOMANY, "EHopen", __FILE__, __LINE__);
421 0 : HEreport("No more than %d files may be open simultaneously (%s).\n",
422 : EHXmaxfilecount, filename);
423 : }
424 :
425 :
426 :
427 :
428 46 : if (status == 0)
429 : {
430 : /* Initialize Vgroup Access */
431 : /* ------------------------ */
432 46 : Vstart(HDFfid);
433 :
434 :
435 : /* Assign HDFEOS fid # & Load HDF fid and sdInterfaceID tables */
436 : /* ----------------------------------------------------------- */
437 52 : for (i = 0; i < EHXmaxfilecount; i++)
438 : {
439 52 : if (EHXtypeTable[i] == 0)
440 : {
441 46 : fid = i + EHIDOFFSET;
442 46 : EHXacsTable[i] = acs;
443 46 : EHXtypeTable[i] = 1;
444 46 : EHXfidTable[i] = HDFfid;
445 46 : EHXsdTable[i] = sdInterfaceID;
446 46 : break;
447 : }
448 : }
449 :
450 : }
451 46 : return (fid);
452 : }
453 :
454 :
455 :
456 :
457 : /*----------------------------------------------------------------------------|
458 : | BEGIN_PROLOG |
459 : | |
460 : | FUNCTION: EHchkfid |
461 : | |
462 : | DESCRIPTION: Checks for valid file id and returns HDF file ID and |
463 : | SD interface ID |
464 : | |
465 : | |
466 : | Return Value Type Units Description |
467 : | ============ ====== ========= ===================================== |
468 : | status intn return status (0) SUCCEED, (-1) FAIL |
469 : | |
470 : | INPUTS: |
471 : | fid int32 HDF-EOS file ID |
472 : | name char Structure name |
473 : | |
474 : | OUTPUTS: |
475 : | HDFfid int32 HDF File ID |
476 : | sdInterfaceID int32 SDS interface ID |
477 : | access uint8 access code |
478 : | |
479 : | NOTES: |
480 : | |
481 : | |
482 : | Date Programmer Description |
483 : | ====== ============ ================================================= |
484 : | Jun 96 Joel Gales Original Programmer |
485 : | Jul 96 Joel Gales set status=-1 if failure |
486 : | Jul 96 Joel Gales Add file id offset EHIDOFFSET |
487 : | |
488 : | END_PROLOG |
489 : -----------------------------------------------------------------------------*/
490 : intn
491 318 : EHchkfid(int32 fid, const char *name, int32 * HDFfid, int32 * sdInterfaceID,
492 : uint8 * access)
493 :
494 : {
495 318 : intn status = 0; /* routine return status variable */
496 : intn fid0; /* HDFEOS file ID - Offset */
497 :
498 :
499 : /* Check for valid HDFEOS file ID range */
500 : /* ------------------------------------ */
501 318 : if (fid < EHIDOFFSET || fid > EHXmaxfilecount + EHIDOFFSET)
502 : {
503 0 : status = -1;
504 0 : HEpush(DFE_RANGE, "EHchkfid", __FILE__, __LINE__);
505 0 : HEreport("Invalid file id: %d. ID must be >= %d and < %d (%s).\n",
506 : fid, EHIDOFFSET, EHXmaxfilecount + EHIDOFFSET, name);
507 : } else
508 : {
509 : /* Compute "reduced" file ID */
510 : /* ------------------------- */
511 318 : fid0 = fid % EHIDOFFSET;
512 :
513 :
514 : /* Check that HDFEOS file ID is active */
515 : /* ----------------------------------- */
516 318 : if (EHXtypeTable[fid0] == 0)
517 : {
518 0 : status = -1;
519 0 : HEpush(DFE_GENAPP, "EHchkfid", __FILE__, __LINE__);
520 0 : HEreport("File id %d not active (%s).\n", fid, name);
521 : } else
522 : {
523 : /*
524 : * Get HDF file ID, SD interface ID and file access from external
525 : * arrays
526 : */
527 318 : *HDFfid = EHXfidTable[fid0];
528 318 : *sdInterfaceID = EHXsdTable[fid0];
529 318 : *access = EHXacsTable[fid0];
530 : }
531 : }
532 :
533 318 : return (status);
534 : }
535 :
536 :
537 :
538 :
539 : /*----------------------------------------------------------------------------|
540 : | BEGIN_PROLOG |
541 : | |
542 : | FUNCTION: EHidinfo |
543 : | |
544 : | DESCRIPTION: Gets Hopen and SD interface IDs from HDF-EOS id |
545 : | |
546 : | |
547 : | Return Value Type Units Description |
548 : | ============ ====== ========= ===================================== |
549 : | status intn return status (0) SUCCEED, (-1) FAIL |
550 : | |
551 : | INPUTS: |
552 : | fid int32 HDF-EOS file ID |
553 : | |
554 : | OUTPUTS: |
555 : | HDFfid int32 HDF File ID |
556 : | sdInterfaceID int32 SDS interface ID |
557 : | |
558 : | NOTES: |
559 : | |
560 : | |
561 : | Date Programmer Description |
562 : | ====== ============ ================================================= |
563 : | Jul 96 Joel Gales Original Programmer |
564 : | |
565 : | END_PROLOG |
566 : -----------------------------------------------------------------------------*/
567 : intn
568 1 : EHidinfo(int32 fid, int32 * HDFfid, int32 * sdInterfaceID)
569 :
570 : {
571 1 : intn status = 0; /* routine return status variable */
572 : uint8 dum; /* Dummy variable */
573 :
574 : /* Call EHchkfid to get HDF and SD interface IDs */
575 : /* --------------------------------------------- */
576 1 : status = EHchkfid(fid, "EHidinfo", HDFfid, sdInterfaceID, &dum);
577 :
578 1 : return (status);
579 : }
580 :
581 : /*----------------------------------------------------------------------------|
582 : | BEGIN_PROLOG |
583 : | |
584 : | FUNCTION: EHparsestr |
585 : | |
586 : | DESCRIPTION: String Parser Utility |
587 : | |
588 : | |
589 : | Return Value Type Units Description |
590 : | ============ ====== ========= ===================================== |
591 : | count int32 Number of string entries |
592 : | |
593 : | INPUTS: |
594 : | instring const char Input string |
595 : | delim const char string delimiter |
596 : | |
597 : | OUTPUTS: |
598 : | pntr char * Pointer array to beginning of each |
599 : | string entry |
600 : | len int32 Array of string entry lengths |
601 : | |
602 : | NOTES: |
603 : | |
604 : | |
605 : | Date Programmer Description |
606 : | ====== ============ ================================================= |
607 : | Jun 96 Joel Gales Original Programmer |
608 : | Aug 96 Joel Gales NULL pointer array returns count only |
609 : | |
610 : | END_PROLOG |
611 : -----------------------------------------------------------------------------*/
612 : int32
613 128 : EHparsestr(const char *instring, const char delim,
614 : char *pntr[], size_t pntrsize,
615 : int32 len[], size_t lensize)
616 : {
617 : size_t i; /* Loop index */
618 128 : size_t prevDelimPos = 0; /* Previous delimiter position */
619 : size_t count; /* Number of elements in string list */
620 : size_t slen; /* String length */
621 :
622 : char *delimitor; /* Pointer to delimiter */
623 :
624 :
625 : /* Get length of input string list & Point to first delimiter */
626 : /* ---------------------------------------------------------- */
627 128 : slen = (int)strlen(instring);
628 128 : delimitor = strchr(instring, delim);
629 :
630 : /* If NULL string set count to zero otherwise set to 1 */
631 : /* --------------------------------------------------- */
632 128 : count = (slen == 0) ? 0 : 1;
633 :
634 :
635 : /* if string pointers are requested set first one to beginning of string */
636 : /* --------------------------------------------------------------------- */
637 128 : if (pntr != NULL && pntrsize)
638 : {
639 120 : pntr[0] = (char *)instring;
640 : }
641 : /* If delimiter not found ... */
642 : /* ---------------------------- */
643 128 : if (delimitor == NULL)
644 : {
645 : /* if string length requested then set to input string length */
646 : /* ---------------------------------------------------------- */
647 17 : if (len != NULL && lensize)
648 : {
649 9 : len[0] = (int32)slen;
650 : }
651 : } else
652 : /* Delimiters Found */
653 : /* ---------------- */
654 : {
655 : /* Loop through all characters in string */
656 : /* ------------------------------------- */
657 1673 : for (i = 1; i < slen; i++)
658 : {
659 : /* If character is a delimiter ... */
660 : /* ------------------------------- */
661 1562 : if (instring[i] == delim)
662 : {
663 :
664 : /* If string pointer requested */
665 : /* --------------------------- */
666 111 : if (pntr != NULL)
667 : {
668 : /* if requested then compute string length of entry */
669 : /* ------------------------------------------------ */
670 111 : if (len != NULL)
671 : {
672 111 : if (count - 1 >= lensize)
673 0 : return -1;
674 111 : len[count - 1] = (int32)(i - prevDelimPos);
675 : }
676 : /* Point to beginning of string entry */
677 : /* ---------------------------------- */
678 111 : if (count >= pntrsize)
679 0 : return -1;
680 111 : pntr[count] = (char *)instring + i + 1;
681 : }
682 : /* Reset previous delimiter position and increment counter */
683 : /* ------------------------------------------------------- */
684 111 : prevDelimPos = i + 1;
685 111 : count++;
686 : }
687 : }
688 :
689 : /* Compute string length of last entry */
690 : /* ----------------------------------- */
691 111 : if (pntr != NULL && len != NULL)
692 : {
693 111 : if (count == 0 || (size_t)(count - 1) >= lensize)
694 0 : return -1;
695 111 : len[count - 1] = (int32)(i - prevDelimPos);
696 : }
697 : }
698 :
699 128 : return (int32)(count);
700 : }
701 :
702 :
703 :
704 :
705 : /*----------------------------------------------------------------------------|
706 : | BEGIN_PROLOG |
707 : | |
708 : | FUNCTION: EHstrwithin |
709 : | |
710 : | DESCRIPTION: Searches for string within target string |
711 : | |
712 : | |
713 : | Return Value Type Units Description |
714 : | ============ ====== ========= ===================================== |
715 : | indx int32 Element index (0 - based) |
716 : | |
717 : | INPUTS: |
718 : | target const char Target string |
719 : | search const char Search string |
720 : | delim const char Delimiter |
721 : | |
722 : | OUTPUTS: |
723 : | None |
724 : | |
725 : | NOTES: |
726 : | |
727 : | |
728 : | Date Programmer Description |
729 : | ====== ============ ================================================= |
730 : | Jun 96 Joel Gales Original Programmer |
731 : | Jan 97 Joel Gales Change ptr & slen to dynamic arrays |
732 : | |
733 : | END_PROLOG |
734 : -----------------------------------------------------------------------------*/
735 : int32
736 8 : EHstrwithin(const char *target, const char *search, const char delim)
737 : {
738 8 : intn found = 0; /* Target string found flag */
739 :
740 : int32 indx; /* Loop index */
741 : int32 nentries; /* Number of entries in search string */
742 : int32 *slen; /* Pointer to string length array */
743 :
744 : char **ptr; /* Pointer to string pointer array */
745 : char buffer[128];/* Buffer to hold "test" string entry */
746 :
747 :
748 : /* Count number of entries in search string list */
749 : /* --------------------------------------------- */
750 8 : nentries = EHparsestr(search, delim, NULL, 0, NULL, 0);
751 8 : if (nentries == 0)
752 8 : return -1;
753 :
754 :
755 : /* Allocate string pointer and length arrays */
756 : /* ----------------------------------------- */
757 0 : ptr = (char **) calloc(nentries, sizeof(char *));
758 0 : if(ptr == NULL)
759 : {
760 0 : HEpush(DFE_NOSPACE,"EHstrwithin", __FILE__, __LINE__);
761 0 : return(-1);
762 : }
763 0 : slen = (int32 *) calloc(nentries, sizeof(int32));
764 0 : if(slen == NULL)
765 : {
766 0 : HEpush(DFE_NOSPACE,"EHstrwithin", __FILE__, __LINE__);
767 0 : free(ptr);
768 0 : return(-1);
769 : }
770 :
771 :
772 : /* Parse search string */
773 : /* ------------------- */
774 0 : nentries = EHparsestr(search, delim, ptr, nentries, slen, nentries);
775 0 : if (nentries < 0)
776 : {
777 0 : free(ptr);
778 0 : free(slen);
779 0 : HEpush(DFE_NOSPACE,"EHstrwithin", __FILE__, __LINE__);
780 0 : return(-1);
781 : }
782 :
783 :
784 : /* Loop through all elements in search string list */
785 : /* ----------------------------------------------- */
786 0 : for (indx = 0; indx < nentries; indx++)
787 : {
788 : /* Copy string entry into buffer */
789 : /* ----------------------------- */
790 0 : memcpy(buffer, ptr[indx], slen[indx]);
791 0 : buffer[slen[indx]] = 0;
792 :
793 :
794 : /* Compare target string with string entry */
795 : /* --------------------------------------- */
796 0 : if (strcmp(target, buffer) == 0)
797 : {
798 0 : found = 1;
799 0 : break;
800 : }
801 : }
802 :
803 : /* If not found set return to -1 */
804 : /* ----------------------------- */
805 0 : if (found == 0)
806 : {
807 0 : indx = -1;
808 : }
809 0 : free(slen);
810 0 : free(ptr);
811 :
812 0 : return (indx);
813 : }
814 :
815 :
816 :
817 :
818 : /*----------------------------------------------------------------------------|
819 : | BEGIN_PROLOG |
820 : | |
821 : | FUNCTION: EHgetid |
822 : | |
823 : | DESCRIPTION: Get Vgroup/Vdata ID from name |
824 : | |
825 : | |
826 : | Return Value Type Units Description |
827 : | ============ ====== ========= ===================================== |
828 : | outID int32 Output ID |
829 : | |
830 : | INPUTS: |
831 : | fid int32 HDF-EOS file ID |
832 : | vgid int32 Vgroup ID |
833 : | objectname const char object name |
834 : | code intn object code (0 - Vgroup, 1 - Vdata) |
835 : | access const char access ("w/r") |
836 : | |
837 : | |
838 : | OUTPUTS: |
839 : | None |
840 : | |
841 : | NOTES: |
842 : | |
843 : | |
844 : | Date Programmer Description |
845 : | ====== ============ ================================================= |
846 : | Jun 96 Joel Gales Original Programmer |
847 : | |
848 : | END_PROLOG |
849 : -----------------------------------------------------------------------------*/
850 : int32
851 1 : EHgetid(int32 fid, int32 vgid, const char *objectname, intn code,
852 : const char *access)
853 : {
854 : intn i; /* Loop index */
855 :
856 : int32 nObjects; /* # of objects in Vgroup */
857 : int32 *tags; /* Pnt to Vgroup object tags array */
858 : int32 *refs; /* Pnt to Vgroup object refs array */
859 : int32 id; /* Object ID */
860 1 : int32 outID = -1; /* Desired object ID */
861 :
862 : char name[128]; /* Object name */
863 :
864 :
865 : /* Get Number of objects */
866 : /* --------------------- */
867 1 : nObjects = Vntagrefs(vgid);
868 :
869 : /* If objects exist ... */
870 : /* -------------------- */
871 1 : if (nObjects != 0)
872 : {
873 :
874 : /* Get tags and references of objects */
875 : /* ---------------------------------- */
876 0 : tags = (int32 *) malloc(sizeof(int32) * nObjects);
877 0 : if(tags == NULL)
878 : {
879 0 : HEpush(DFE_NOSPACE,"EHgetid", __FILE__, __LINE__);
880 0 : return(-1);
881 : }
882 0 : refs = (int32 *) malloc(sizeof(int32) * nObjects);
883 0 : if(refs == NULL)
884 : {
885 0 : HEpush(DFE_NOSPACE,"EHgetid", __FILE__, __LINE__);
886 0 : free(tags);
887 0 : return(-1);
888 : }
889 :
890 0 : Vgettagrefs(vgid, tags, refs, nObjects);
891 :
892 :
893 : /* Vgroup ID Section */
894 : /* ----------------- */
895 0 : if (code == 0)
896 : {
897 : /* Loop through objects */
898 : /* -------------------- */
899 0 : for (i = 0; i < nObjects; i++)
900 : {
901 :
902 : /* If object is Vgroup ... */
903 : /* ----------------------- */
904 0 : if (*(tags + i) == DFTAG_VG)
905 : {
906 :
907 : /* Get ID and name */
908 : /* --------------- */
909 0 : id = Vattach(fid, *(refs + i), access);
910 0 : VgetnameSafe(id, name, sizeof(name));
911 :
912 : /* If name equals desired object name get ID */
913 : /* ----------------------------------------- */
914 0 : if (strcmp(name, objectname) == 0)
915 : {
916 0 : outID = id;
917 0 : break;
918 : }
919 : /* If not desired object then detach */
920 : /* --------------------------------- */
921 0 : Vdetach(id);
922 : }
923 : }
924 0 : } else if (code == 1)
925 : {
926 :
927 : /* Loop through objects */
928 : /* -------------------- */
929 0 : for (i = 0; i < nObjects; i++)
930 : {
931 :
932 : /* If object is Vdata ... */
933 : /* ---------------------- */
934 0 : if (*(tags + i) == DFTAG_VH)
935 : {
936 :
937 : /* Get ID and name */
938 : /* --------------- */
939 0 : id = VSattach(fid, *(refs + i), access);
940 0 : VSgetname(id, name);
941 :
942 : /* If name equals desired object name get ID */
943 : /* ----------------------------------------- */
944 0 : if (EHstrwithin(objectname, name, ',') != -1)
945 : {
946 0 : outID = id;
947 0 : break;
948 : }
949 : /* If not desired object then detach */
950 : /* --------------------------------- */
951 0 : VSdetach(id);
952 : }
953 : }
954 : }
955 0 : free(tags);
956 0 : free(refs);
957 : }
958 1 : return (outID);
959 : }
960 :
961 :
962 :
963 :
964 : /*----------------------------------------------------------------------------|
965 : | BEGIN_PROLOG |
966 : | |
967 : | FUNCTION: EHgetmetavalue |
968 : | |
969 : | DESCRIPTION: Returns metadata value |
970 : | |
971 : | |
972 : | Return Value Type Units Description |
973 : | ============ ====== ========= ===================================== |
974 : | status intn return status (0) SUCCEED, (-1) FAIL |
975 : | |
976 : | INPUTS: |
977 : | metaptrs char Begin and end of metadata section |
978 : | parameter char parameter to access |
979 : | |
980 : | OUTPUTS: |
981 : | metaptr char Ptr to (updated) beginning of metadata |
982 : | retstr char return string containing value |
983 : | |
984 : | NOTES: |
985 : | |
986 : | |
987 : | Date Programmer Description |
988 : | ====== ============ ================================================= |
989 : | Jun 96 Joel Gales Original Programmer |
990 : | Jan 97 Joel Gales Check string pointer against end of meta section |
991 : | |
992 : | END_PROLOG |
993 : -----------------------------------------------------------------------------*/
994 : intn
995 942 : EHgetmetavalue(char *metaptrs[], const char *parameter, char *retstr)
996 : {
997 942 : intn status = 0; /* routine return status variable */
998 :
999 : int32 slen; /* String length */
1000 : char *newline; /* Position of new line character */
1001 : char *sptr; /* string pointer within metadata */
1002 :
1003 :
1004 : /* Get string length of parameter string + 1 */
1005 : /* ----------------------------------------- */
1006 942 : slen = (int)strlen(parameter) + 1;
1007 :
1008 :
1009 : /* Build search string (parameter string + "=") */
1010 : /* -------------------------------------------- */
1011 942 : strcpy(retstr, parameter);
1012 942 : strcat(retstr, "=");
1013 :
1014 :
1015 : /* Search for string within metadata (beginning at metaptrs[0]) */
1016 : /* ------------------------------------------------------------ */
1017 942 : sptr = strstr(metaptrs[0], retstr);
1018 :
1019 :
1020 : /* If string found within desired section ... */
1021 : /* ------------------------------------------ */
1022 942 : if (sptr != NULL && sptr < metaptrs[1])
1023 : {
1024 : /* Store position of string within metadata */
1025 : /* ---------------------------------------- */
1026 942 : metaptrs[0] = sptr;
1027 :
1028 : /* Find newline "\n" character */
1029 : /* --------------------------- */
1030 942 : newline = strchr(metaptrs[0], '\n');
1031 942 : if (newline == NULL)
1032 : {
1033 0 : retstr[0] = 0;
1034 0 : return -1;
1035 : }
1036 :
1037 : /* Copy from "=" to "\n" (exclusive) into return string */
1038 : /* ---------------------------------------------------- */
1039 942 : memcpy(retstr, metaptrs[0] + slen, newline - metaptrs[0] - slen);
1040 :
1041 : /* Terminate return string with null */
1042 : /* --------------------------------- */
1043 942 : retstr[newline - metaptrs[0] - slen] = 0;
1044 : } else
1045 : {
1046 : /*
1047 : * if parameter string not found within section, null return string
1048 : * and set status to -1.
1049 : */
1050 0 : retstr[0] = 0;
1051 0 : status = -1;
1052 : }
1053 :
1054 942 : return (status);
1055 : }
1056 :
1057 :
1058 :
1059 :
1060 : /*----------------------------------------------------------------------------|
1061 : | BEGIN_PROLOG |
1062 : | |
1063 : | FUNCTION: EHmetagroup |
1064 : | |
1065 : | DESCRIPTION: Returns pointers to beginning and end of metadata group |
1066 : | |
1067 : | |
1068 : | Return Value Type Units Description |
1069 : | ============ ====== ========= ===================================== |
1070 : | metabuf char Pointer to HDF-EOS object in metadata |
1071 : | |
1072 : | INPUTS: |
1073 : | sdInterfaceID int32 SDS interface ID |
1074 : | structname char HDF-EOS structure name |
1075 : | structcode char Structure code ("s/g/p") |
1076 : | groupname char Metadata group name |
1077 : | |
1078 : | OUTPUTS: |
1079 : | metaptrs char pointers to begin and end of metadata |
1080 : | |
1081 : | NOTES: |
1082 : | |
1083 : | |
1084 : | Date Programmer Description |
1085 : | ====== ============ ================================================= |
1086 : | Jun 96 Joel Gales Original Programmer |
1087 : | Aug 96 Joel Gales Make metadata ODL compliant |
1088 : | |
1089 : | END_PROLOG |
1090 : -----------------------------------------------------------------------------*/
1091 : char *
1092 245 : EHmetagroup(int32 sdInterfaceID, const char *structname, const char *structcode,
1093 : const char *groupname, char *metaptrs[])
1094 : {
1095 : intn i; /* Loop index */
1096 :
1097 : int32 attrIndex; /* Structural metadata attribute index */
1098 : int32 nmeta; /* Number of UTLSTRSIZE byte metadata sections */
1099 :
1100 : char *metabuf; /* Pointer (handle) to structural metadata */
1101 245 : char *endptr = NULL; /* Pointer to end of metadata section */
1102 : char *metaptr; /* Metadata pointer */
1103 : char *prevmetaptr;/* Previous position of metadata pointer */
1104 : char *utlstr; /* Utility string */
1105 :
1106 :
1107 :
1108 : /* Allocate memory for utility string */
1109 : /* ---------------------------------- */
1110 245 : utlstr = (char *) calloc(UTLSTR_MAX_SIZE,sizeof(char));
1111 245 : if(utlstr == NULL)
1112 : {
1113 0 : HEpush(DFE_NOSPACE,"EHEHmetagroup", __FILE__, __LINE__);
1114 :
1115 0 : return( NULL);
1116 : }
1117 : /* Determine number of structural metadata "sections" */
1118 : /* -------------------------------------------------- */
1119 245 : nmeta = 0;
1120 : while (1)
1121 : {
1122 : /* Search for "StructMetadata.x" attribute */
1123 : /* --------------------------------------- */
1124 490 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%d", "StructMetadata.", (int)nmeta);
1125 490 : attrIndex = SDfindattr(sdInterfaceID, utlstr);
1126 :
1127 :
1128 : /* If found then increment metadata section counter else exit loop */
1129 : /* --------------------------------------------------------------- */
1130 490 : if (attrIndex != -1)
1131 : {
1132 245 : nmeta++;
1133 : } else
1134 : {
1135 245 : break;
1136 : }
1137 : }
1138 :
1139 245 : if (nmeta > INT_MAX / UTLSTRSIZE )
1140 : {
1141 0 : HEpush(DFE_NOSPACE,"EHEHmetagroup", __FILE__, __LINE__);
1142 :
1143 0 : return( NULL);
1144 : }
1145 :
1146 : /* Allocate space for metadata (in units of UTLSTRSIZE bytes) */
1147 : /* ----------------------------------------------------- */
1148 245 : metabuf = (char *) calloc(UTLSTRSIZE * nmeta, 1);
1149 :
1150 245 : if(metabuf == NULL)
1151 : {
1152 0 : HEpush(DFE_NOSPACE,"EHmetagroup", __FILE__, __LINE__);
1153 0 : free(utlstr);
1154 0 : return(metabuf);
1155 : }
1156 :
1157 :
1158 : /* Read structural metadata */
1159 : /* ------------------------ */
1160 490 : for (i = 0; i < nmeta; i++)
1161 : {
1162 245 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%d", "StructMetadata.", i);
1163 245 : attrIndex = SDfindattr(sdInterfaceID, utlstr);
1164 245 : int metalen = (int)strlen(metabuf);
1165 245 : SDreadattr(sdInterfaceID, attrIndex, metabuf + metalen);
1166 : }
1167 :
1168 : /* Find HDF-EOS structure "root" group in metadata */
1169 : /* ----------------------------------------------- */
1170 :
1171 : /* Setup proper search string */
1172 : /* -------------------------- */
1173 245 : if (strcmp(structcode, "s") == 0)
1174 : {
1175 49 : strcpy(utlstr, "GROUP=SwathStructure");
1176 196 : } else if (strcmp(structcode, "g") == 0)
1177 : {
1178 196 : strcpy(utlstr, "GROUP=GridStructure");
1179 0 : } else if (strcmp(structcode, "p") == 0)
1180 : {
1181 0 : strcpy(utlstr, "GROUP=PointStructure");
1182 : }
1183 : /* Use string search routine (strstr) to move through metadata */
1184 : /* ----------------------------------------------------------- */
1185 245 : metaptr = strstr(metabuf, utlstr);
1186 :
1187 :
1188 :
1189 : /* Save current metadata pointer */
1190 : /* ----------------------------- */
1191 245 : prevmetaptr = metaptr;
1192 :
1193 :
1194 : /* First loop for "old-style" (non-ODL) metadata string */
1195 : /* ---------------------------------------------------- */
1196 245 : if (strcmp(structcode, "s") == 0)
1197 : {
1198 49 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%s", "SwathName=\"", structname);
1199 196 : } else if (strcmp(structcode, "g") == 0)
1200 : {
1201 196 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%s", "GridName=\"", structname);
1202 0 : } else if (strcmp(structcode, "p") == 0)
1203 : {
1204 0 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%s", "PointName=\"", structname);
1205 : }
1206 : /* Do string search */
1207 : /* ---------------- */
1208 245 : if (metaptr)
1209 245 : metaptr = strstr(metaptr, utlstr);
1210 :
1211 :
1212 : /*
1213 : * If not found then return to previous position in metadata and look for
1214 : * "new-style" (ODL) metadata string
1215 : */
1216 245 : if (metaptr == NULL && prevmetaptr)
1217 : {
1218 0 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%s", "GROUP=\"", structname);
1219 0 : metaptr = strstr(prevmetaptr, utlstr);
1220 : }
1221 : /* Find group within structure */
1222 : /* --------------------------- */
1223 245 : if (metaptr && groupname != NULL)
1224 : {
1225 229 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%s", "GROUP=", groupname);
1226 229 : metaptr = strstr(metaptr, utlstr);
1227 :
1228 229 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%s", "\t\tEND_GROUP=", groupname);
1229 229 : if (metaptr)
1230 223 : endptr = strstr(metaptr, utlstr);
1231 : else
1232 6 : endptr = NULL;
1233 16 : } else if (metaptr)
1234 : {
1235 : /* If groupname == NULL then find end of structure in metadata */
1236 : /* ----------------------------------------------------------- */
1237 16 : snprintf(utlstr, UTLSTR_MAX_SIZE, "%s", "\n\tEND_GROUP=");
1238 16 : endptr = strstr(metaptr, utlstr);
1239 : }
1240 :
1241 :
1242 : /* Return beginning and ending pointers */
1243 : /* ------------------------------------ */
1244 245 : metaptrs[0] = metaptr;
1245 245 : metaptrs[1] = endptr;
1246 :
1247 245 : free(utlstr);
1248 :
1249 245 : return (metabuf);
1250 : }
1251 :
1252 :
1253 : /*----------------------------------------------------------------------------|
1254 : | BEGIN_PROLOG |
1255 : | |
1256 : | FUNCTION: EHattr |
1257 : | |
1258 : | DESCRIPTION: Reads/Writes attributes for HDF-EOS structures |
1259 : | |
1260 : | |
1261 : | Return Value Type Units Description |
1262 : | ============ ====== ========= ===================================== |
1263 : | status intn return status (0) SUCCEED, (-1) FAIL |
1264 : | |
1265 : | INPUTS: |
1266 : | fid int32 HDF-EOS file ID |
1267 : | attrVgrpID int32 Attribute Vgroup ID |
1268 : | attrname char attribute name |
1269 : | numbertype int32 attribute HDF numbertype |
1270 : | count int32 Number of attribute elements |
1271 : | wrcode char Read/Write Code "w/r" |
1272 : | datbuf void I/O buffer |
1273 : | |
1274 : | |
1275 : | OUTPUTS: |
1276 : | datbuf void I/O buffer |
1277 : | |
1278 : | NOTES: |
1279 : | |
1280 : | |
1281 : | Date Programmer Description |
1282 : | ====== ============ ================================================= |
1283 : | Jun 96 Joel Gales Original Programmer |
1284 : | Oct 96 Joel Gales Pass Vgroup id as routine parameter |
1285 : | Oct 96 Joel Gales Remove Vdetach call |
1286 : | |
1287 : | END_PROLOG |
1288 : -----------------------------------------------------------------------------*/
1289 : intn
1290 1 : EHattr(int32 fid, int32 attrVgrpID, const char *attrname, int32 numbertype,
1291 : int32 count, const char *wrcode, VOIDP datbuf)
1292 :
1293 : {
1294 1 : intn status = 0; /* routine return status variable */
1295 : int32 vdataID; /* Attribute Vdata ID */
1296 :
1297 : /*
1298 : * Attributes are stored as Vdatas with name given by the user, class:
1299 : * "Attr0.0" and fieldname: "AttrValues"
1300 : */
1301 :
1302 :
1303 : /* Get Attribute Vdata ID and "open" with appropriate I/O code */
1304 : /* ----------------------------------------------------------- */
1305 1 : vdataID = EHgetid(fid, attrVgrpID, attrname, 1, wrcode);
1306 :
1307 : /* Write Attribute Section */
1308 : /* ----------------------- */
1309 1 : if (strcmp(wrcode, "w") == 0)
1310 : {
1311 : /* Create Attribute Vdata (if it doesn't exist) */
1312 : /* -------------------------------------------- */
1313 0 : if (vdataID == -1)
1314 : {
1315 0 : vdataID = VSattach(fid, -1, "w");
1316 0 : VSsetname(vdataID, attrname);
1317 0 : VSsetclass(vdataID, "Attr0.0");
1318 :
1319 0 : VSfdefine(vdataID, "AttrValues", numbertype, count);
1320 0 : Vinsert(attrVgrpID, vdataID);
1321 : }
1322 : /* Write Attribute */
1323 : /* --------------- */
1324 0 : VSsetfields(vdataID, "AttrValues");
1325 0 : (void) VSsizeof(vdataID, (char*) "AttrValues");
1326 0 : VSwrite(vdataID, datbuf, 1, FULL_INTERLACE);
1327 :
1328 0 : VSdetach(vdataID);
1329 : }
1330 : /* Read Attribute Section */
1331 : /* ---------------------- */
1332 1 : if (strcmp(wrcode, "r") == 0)
1333 : {
1334 : /* If attribute doesn't exist report error */
1335 : /* --------------------------------------- */
1336 1 : if (vdataID == -1)
1337 : {
1338 1 : status = -1;
1339 1 : HEpush(DFE_GENAPP, "EHattr", __FILE__, __LINE__);
1340 1 : HEreport("Attribute %s not defined.\n", attrname);
1341 : } else
1342 : {
1343 0 : VSsetfields(vdataID, "AttrValues");
1344 0 : (void) VSsizeof(vdataID, (char*) "AttrValues");
1345 0 : VSread(vdataID, datbuf, 1, FULL_INTERLACE);
1346 0 : VSdetach(vdataID);
1347 : }
1348 : }
1349 1 : return (status);
1350 : }
1351 :
1352 :
1353 :
1354 :
1355 : /*----------------------------------------------------------------------------|
1356 : | BEGIN_PROLOG |
1357 : | |
1358 : | FUNCTION: EHattrinfo |
1359 : | |
1360 : | DESCRIPTION: Returns numbertype and count of given HDF-EOS attribute |
1361 : | |
1362 : | |
1363 : | Return Value Type Units Description |
1364 : | ============ ====== ========= ===================================== |
1365 : | status intn return status (0) SUCCEED, (-1) FAIL |
1366 : | |
1367 : | INPUTS: |
1368 : | fid int32 HDF-EOS file ID |
1369 : | attrVgrpID int32 Attribute Vgroup ID |
1370 : | attrname char attribute name |
1371 : | |
1372 : | OUTPUTS: |
1373 : | numbertype int32 attribute HDF numbertype |
1374 : | count int32 Number of attribute elements |
1375 : | |
1376 : | NOTES: |
1377 : | |
1378 : | |
1379 : | Date Programmer Description |
1380 : | ====== ============ ================================================= |
1381 : | Jun 96 Joel Gales Original Programmer |
1382 : | Oct 96 Joel Gales Pass Vgroup id as routine parameter |
1383 : | Oct 96 Joel Gales Remove Vdetach call |
1384 : | |
1385 : | END_PROLOG |
1386 : -----------------------------------------------------------------------------*/
1387 : intn
1388 0 : EHattrinfo(int32 fid, int32 attrVgrpID, const char *attrname, int32 * numbertype,
1389 : int32 * count)
1390 :
1391 : {
1392 0 : intn status = 0; /* routine return status variable */
1393 : int32 vdataID; /* Attribute Vdata ID */
1394 :
1395 : /* Get Attribute Vdata ID */
1396 : /* ---------------------- */
1397 0 : vdataID = EHgetid(fid, attrVgrpID, attrname, 1, "r");
1398 :
1399 : /* If attribute not defined then report error */
1400 : /* ------------------------------------------ */
1401 0 : if (vdataID == -1)
1402 : {
1403 0 : status = -1;
1404 0 : HEpush(DFE_GENAPP, "EHattr", __FILE__, __LINE__);
1405 0 : HEreport("Attribute %s not defined.\n", attrname);
1406 : } else
1407 : {
1408 : /* Get attribute info */
1409 : /* ------------------ */
1410 0 : VSsetfields(vdataID, "AttrValues");
1411 0 : *count = VSsizeof(vdataID, (char*) "AttrValues");
1412 0 : *numbertype = VFfieldtype(vdataID, 0);
1413 0 : VSdetach(vdataID);
1414 : }
1415 :
1416 0 : return (status);
1417 : }
1418 :
1419 :
1420 :
1421 :
1422 :
1423 : /*----------------------------------------------------------------------------|
1424 : | BEGIN_PROLOG |
1425 : | |
1426 : | FUNCTION: EHattrcat |
1427 : | |
1428 : | DESCRIPTION: Returns a listing of attributes within an HDF-EOS structure |
1429 : | |
1430 : | |
1431 : | Return Value Type Units Description |
1432 : | ============ ====== ========= ===================================== |
1433 : | nattr int32 Number of attributes in swath struct |
1434 : | |
1435 : | INPUTS: |
1436 : | fid int32 HDF-EOS file ID |
1437 : | attrVgrpID int32 Attribute Vgroup ID |
1438 : | structcode char Structure Code ("s/g/p") |
1439 : | |
1440 : | OUTPUTS: |
1441 : | attrnames char Attribute names in swath struct |
1442 : | (Comma-separated list) |
1443 : | strbufsize int32 Attributes name list string length |
1444 : | |
1445 : | NOTES: |
1446 : | |
1447 : | |
1448 : | Date Programmer Description |
1449 : | ====== ============ ================================================= |
1450 : | Jun 96 Joel Gales Original Programmer |
1451 : | Oct 96 Joel Gales Pass Vgroup id as routine parameter |
1452 : | Oct 96 Joel Gales Remove Vdetach call |
1453 : | |
1454 : | END_PROLOG |
1455 : -----------------------------------------------------------------------------*/
1456 : int32
1457 7 : EHattrcat(int32 fid, int32 attrVgrpID, char *attrnames, int32 * strbufsize)
1458 : {
1459 : intn i; /* Loop index */
1460 :
1461 : int32 nObjects; /* # of objects in Vgroup */
1462 : int32 *tags; /* Pnt to Vgroup object tags array */
1463 : int32 *refs; /* Pnt to Vgroup object refs array */
1464 : int32 vdataID; /* Attribute Vdata ID */
1465 :
1466 7 : int32 nattr = 0; /* Number of attributes */
1467 : int32 slen; /* String length */
1468 :
1469 : char name[80]; /* Attribute name */
1470 : static const char indxstr[] = "INDXMAP:"; /* Index Mapping reserved
1471 : string */
1472 : static const char fvstr[] = "_FV_"; /* Flag Value reserved string */
1473 : static const char bsom[] = "_BLKSOM:";/* Block SOM Offset reserved string */
1474 :
1475 :
1476 : /* Set string buffer size to 0 */
1477 : /* --------------------------- */
1478 7 : *strbufsize = 0;
1479 :
1480 :
1481 : /* Get number of attributes within Attribute Vgroup */
1482 : /* ------------------------------------------------ */
1483 7 : nObjects = Vntagrefs(attrVgrpID);
1484 :
1485 :
1486 : /* If attributes exist ... */
1487 : /* ----------------------- */
1488 7 : if (nObjects > 0)
1489 : {
1490 : /* Get tags and references of attribute Vdatas */
1491 : /* ------------------------------------------- */
1492 0 : tags = (int32 *) malloc(sizeof(int32) * nObjects);
1493 0 : if(tags == NULL)
1494 : {
1495 0 : HEpush(DFE_NOSPACE,"EHattrcat", __FILE__, __LINE__);
1496 0 : return(-1);
1497 : }
1498 0 : refs = (int32 *) malloc(sizeof(int32) * nObjects);
1499 0 : if(refs == NULL)
1500 : {
1501 0 : HEpush(DFE_NOSPACE,"EHattrcat", __FILE__, __LINE__);
1502 0 : free(tags);
1503 0 : return(-1);
1504 : }
1505 :
1506 0 : Vgettagrefs(attrVgrpID, tags, refs, nObjects);
1507 :
1508 : /* Get attribute vdata IDs and names */
1509 : /* --------------------------------- */
1510 0 : for (i = 0; i < nObjects; i++)
1511 : {
1512 0 : vdataID = VSattach(fid, *(refs + i), "r");
1513 0 : VSgetname(vdataID, name);
1514 :
1515 : /*
1516 : * Don't return fill value, index mapping & block SOM attributes
1517 : */
1518 0 : if (memcmp(name, indxstr, strlen(indxstr)) != 0 &&
1519 0 : memcmp(name, fvstr, strlen(fvstr)) != 0 &&
1520 0 : memcmp(name, bsom, strlen(bsom)) != 0)
1521 : {
1522 : /* Increment attribute counter and add name to list */
1523 : /* ------------------------------------------------ */
1524 0 : nattr++;
1525 0 : if (attrnames != NULL)
1526 : {
1527 0 : if (nattr == 1)
1528 : {
1529 0 : strcpy(attrnames, name);
1530 : } else
1531 : {
1532 0 : strcat(attrnames, ",");
1533 0 : strcat(attrnames, name);
1534 : }
1535 : }
1536 : /* Increment attribute names string length */
1537 : /* --------------------------------------- */
1538 0 : slen = (nattr == 1) ? (int)strlen(name) : (int)strlen(name) + 1;
1539 0 : *strbufsize += slen;
1540 : }
1541 0 : VSdetach(vdataID);
1542 : }
1543 0 : free(tags);
1544 0 : free(refs);
1545 : }
1546 7 : return (nattr);
1547 : }
1548 :
1549 :
1550 :
1551 : /*----------------------------------------------------------------------------|
1552 : | BEGIN_PROLOG |
1553 : | |
1554 : | FUNCTION: EHinquire |
1555 : | |
1556 : | DESCRIPTION: Returns number and names of HDF-EOS structures in file |
1557 : | |
1558 : | |
1559 : | Return Value Type Units Description |
1560 : | ============ ====== ========= ===================================== |
1561 : | nobj int32 Number of HDF-EOS structures in file |
1562 : | |
1563 : | INPUTS: |
1564 : | filename char HDF-EOS filename |
1565 : | type char Object Type ("SWATH/GRID/POINT") |
1566 : | |
1567 : | OUTPUTS: |
1568 : | objectlist char List of object names (comma-separated) |
1569 : | strbufsize int32 Length of objectlist |
1570 : | |
1571 : | NOTES: |
1572 : | |
1573 : | |
1574 : | Date Programmer Description |
1575 : | ====== ============ ================================================= |
1576 : | Jun 96 Joel Gales Original Programmer |
1577 : | |
1578 : | END_PROLOG |
1579 : -----------------------------------------------------------------------------*/
1580 : int32
1581 50 : EHinquire(const char *filename, const char *type, char *objectlist, int32 * strbufsize)
1582 : {
1583 : int32 HDFfid; /* HDF file ID */
1584 : int32 vgRef; /* Vgroup reference number */
1585 : int32 vGrpID; /* Vgroup ID */
1586 50 : int32 nobj = 0; /* Number of HDFEOS objects in file */
1587 : int32 slen; /* String length */
1588 :
1589 : char name[512]; /* Object name */
1590 : char class[80]; /* Object class */
1591 :
1592 :
1593 : /* Open HDFEOS file of read-only access */
1594 : /* ------------------------------------ */
1595 50 : HDFfid = Hopen(filename, DFACC_READ, 0);
1596 :
1597 :
1598 : /* Start Vgroup Interface */
1599 : /* ---------------------- */
1600 50 : Vstart(HDFfid);
1601 :
1602 :
1603 : /* If string buffer size is requested then zero out counter */
1604 : /* -------------------------------------------------------- */
1605 50 : if (strbufsize != NULL)
1606 : {
1607 50 : *strbufsize = 0;
1608 : }
1609 : /* Search for objects from beginning of HDF file */
1610 : /* -------------------------------------------- */
1611 50 : vgRef = -1;
1612 :
1613 : /* Loop through all objects */
1614 : /* ------------------------ */
1615 : while (1)
1616 : {
1617 : /* Get Vgroup reference number */
1618 : /* --------------------------- */
1619 309 : vgRef = Vgetid(HDFfid, vgRef);
1620 :
1621 : /* If no more then exist search loop */
1622 : /* --------------------------------- */
1623 309 : if (vgRef == -1)
1624 : {
1625 50 : break;
1626 : }
1627 : /* Get Vgroup ID, name, and class */
1628 : /* ------------------------------ */
1629 259 : vGrpID = Vattach(HDFfid, vgRef, "r");
1630 259 : VgetnameSafe(vGrpID, name, sizeof(name));
1631 259 : Vgetclass(vGrpID, class);
1632 :
1633 :
1634 : /* If object of desired type (SWATH, POINT, GRID) ... */
1635 : /* -------------------------------------------------- */
1636 259 : if (strcmp(class, type) == 0)
1637 : {
1638 :
1639 : /* Increment counter */
1640 : /* ----------------- */
1641 30 : nobj++;
1642 :
1643 :
1644 : /* If object list requested add name to list */
1645 : /* ----------------------------------------- */
1646 30 : if (objectlist != NULL)
1647 : {
1648 12 : if (nobj == 1)
1649 : {
1650 12 : strcpy(objectlist, name);
1651 : } else
1652 : {
1653 0 : strcat(objectlist, ",");
1654 0 : strcat(objectlist, name);
1655 : }
1656 : }
1657 : /* Compute string length of object entry */
1658 : /* ------------------------------------- */
1659 30 : slen = (nobj == 1) ? (int)strlen(name) : (int)strlen(name) + 1;
1660 :
1661 :
1662 : /* If string buffer size is requested then increment buffer size */
1663 : /* ------------------------------------------------------------- */
1664 30 : if (strbufsize != NULL)
1665 : {
1666 30 : *strbufsize += slen;
1667 : }
1668 : }
1669 : /* Detach Vgroup */
1670 : /* ------------- */
1671 259 : Vdetach(vGrpID);
1672 : }
1673 :
1674 : /* "Close" Vgroup interface and HDFEOS file */
1675 : /* ---------------------------------------- */
1676 50 : Vend(HDFfid);
1677 50 : Hclose(HDFfid);
1678 :
1679 50 : return (nobj);
1680 : }
1681 :
1682 :
1683 :
1684 : /*----------------------------------------------------------------------------|
1685 : | BEGIN_PROLOG |
1686 : | |
1687 : | FUNCTION: EHclose |
1688 : | |
1689 : | DESCRIPTION: Closes HDF-EOS file |
1690 : | |
1691 : | |
1692 : | Return Value Type Units Description |
1693 : | ============ ====== ========= ===================================== |
1694 : | status intn return status (0) SUCCEED, (-1) FAIL |
1695 : | |
1696 : | INPUTS: |
1697 : | fid int32 HDF-EOS File ID |
1698 : | |
1699 : | OUTPUTS: |
1700 : | None |
1701 : | |
1702 : | NOTES: |
1703 : | |
1704 : | |
1705 : | Date Programmer Description |
1706 : | ====== ============ ================================================= |
1707 : | Jun 96 Joel Gales Original Programmer |
1708 : | Jul 96 Joel Gales Add file id offset EHIDOFFSET |
1709 : | Aug 96 Joel Gales Add HE error report if file id out of bounds |
1710 : | Nov 96 Joel Gales Add EHXacsTable array to "garbage collection" |
1711 : | |
1712 : | END_PROLOG |
1713 : -----------------------------------------------------------------------------*/
1714 : intn
1715 46 : EHclose(int32 fid)
1716 : {
1717 46 : intn status = 0; /* routine return status variable */
1718 :
1719 : int32 HDFfid; /* HDF file ID */
1720 : int32 sdInterfaceID; /* HDF SDS interface ID */
1721 : int32 fid0; /* HDF EOS file id - offset */
1722 :
1723 :
1724 : /* Check for valid HDFEOS file ID range */
1725 : /* ------------------------------------ */
1726 46 : if (fid >= EHIDOFFSET && fid < EHXmaxfilecount + EHIDOFFSET)
1727 : {
1728 : /* Compute "reduced" file ID */
1729 : /* ------------------------- */
1730 46 : fid0 = fid % EHIDOFFSET;
1731 :
1732 :
1733 : /* Get HDF file ID and SD interface ID */
1734 : /* ----------------------------------- */
1735 46 : HDFfid = EHXfidTable[fid0];
1736 46 : sdInterfaceID = EHXsdTable[fid0];
1737 :
1738 : /* "Close" SD interface, Vgroup interface, and HDF file */
1739 : /* ---------------------------------------------------- */
1740 46 : status = SDend(sdInterfaceID);
1741 46 : if (Vend(HDFfid) < 0)
1742 0 : status = -1;
1743 46 : if (Hclose(HDFfid) < 0)
1744 0 : status = -1;
1745 :
1746 : /* Clear out external array entries */
1747 : /* -------------------------------- */
1748 46 : EHXtypeTable[fid0] = 0;
1749 46 : EHXacsTable[fid0] = 0;
1750 46 : EHXfidTable[fid0] = 0;
1751 46 : EHXsdTable[fid0] = 0;
1752 46 : if (EHget_numfiles() == 0)
1753 : {
1754 40 : free(EHXtypeTable);
1755 40 : EHXtypeTable = NULL;
1756 40 : free(EHXacsTable);
1757 40 : EHXacsTable = NULL;
1758 40 : free(EHXfidTable);
1759 40 : EHXfidTable = NULL;
1760 40 : free(EHXsdTable);
1761 40 : EHXsdTable = NULL;
1762 40 : EHXmaxfilecount = 0;
1763 : }
1764 : } else
1765 : {
1766 0 : status = -1;
1767 0 : HEpush(DFE_RANGE, "EHclose", __FILE__, __LINE__);
1768 0 : HEreport("Invalid file id: %d. ID must be >= %d and < %d.\n",
1769 : fid, EHIDOFFSET, EHXmaxfilecount + EHIDOFFSET);
1770 : }
1771 :
1772 46 : return (status);
1773 : }
1774 :
1775 : /*----------------------------------------------------------------------------|
1776 : | BEGIN_PROLOG |
1777 : | |
1778 : | FUNCTION: EHnumstr |
1779 : | |
1780 : | DESCRIPTION: Returns numerical type code of the given string |
1781 : | representation. |
1782 : | |
1783 : | |
1784 : | Return Value Type Units Description |
1785 : | ============ ====== ========= ===================================== |
1786 : | numbertype int32 numerical type code |
1787 : | |
1788 : | INPUTS: |
1789 : | strcode const char string representation of the type code |
1790 : | |
1791 : | |
1792 : | OUTPUTS: |
1793 : | None |
1794 : | |
1795 : | NOTES: |
1796 : | |
1797 : | |
1798 : | Date Programmer Description |
1799 : | ====== ============ ================================================= |
1800 : | Nov 07 Andrey Kiselev Original Programmer |
1801 : | |
1802 : | END_PROLOG |
1803 : -----------------------------------------------------------------------------*/
1804 : int32
1805 120 : EHnumstr(const char *strcode)
1806 : {
1807 120 : if (strcmp(strcode, "DFNT_UCHAR8") == 0)
1808 0 : return DFNT_UCHAR8;
1809 120 : else if (strcmp(strcode, "DFNT_CHAR8") == 0)
1810 0 : return DFNT_CHAR8;
1811 120 : else if (strcmp(strcode, "DFNT_FLOAT32") == 0)
1812 120 : return DFNT_FLOAT32;
1813 0 : else if (strcmp(strcode, "DFNT_FLOAT64") == 0)
1814 0 : return DFNT_FLOAT64;
1815 0 : else if (strcmp(strcode, "DFNT_INT8") == 0)
1816 0 : return DFNT_INT8;
1817 0 : else if (strcmp(strcode, "DFNT_UINT8") == 0)
1818 0 : return DFNT_UINT8;
1819 0 : else if (strcmp(strcode, "DFNT_INT16") == 0)
1820 0 : return DFNT_INT16;
1821 0 : else if (strcmp(strcode, "DFNT_UINT16") == 0)
1822 0 : return DFNT_UINT16;
1823 0 : else if (strcmp(strcode, "DFNT_INT32") == 0)
1824 0 : return DFNT_INT32;
1825 0 : else if (strcmp(strcode, "DFNT_UINT32") == 0)
1826 0 : return DFNT_UINT32;
1827 : else
1828 0 : return DFNT_NONE;
1829 : }
1830 :
1831 : /*----------------------------------------------------------------------------|
1832 : | BEGIN_PROLOG |
1833 : | |
1834 : | FUNCTION: EHreset_maxopenfiles |
1835 : | |
1836 : | DESCRIPTION: Change the allowed number of opened HDFEOS files. |
1837 : | |
1838 : | |
1839 : | Return Value Type Units Description |
1840 : | ============ ====== ========= ===================================== |
1841 : | numbertype intn The current maximum number of opened |
1842 : | files allowed, or -1, if unable |
1843 : | to reset it. |
1844 : | |
1845 : | INPUTS: |
1846 : | strcode intn Requested number of opened files. |
1847 : | |
1848 : | |
1849 : | OUTPUTS: |
1850 : | None |
1851 : | |
1852 : | NOTES: |
1853 : | |
1854 : | |
1855 : | Date Programmer Description |
1856 : | ========== ============ ============================================== |
1857 : | 2013.04.03 Andrey Kiselev Original Programmer |
1858 : | |
1859 : | END_PROLOG |
1860 : -----------------------------------------------------------------------------*/
1861 : static intn
1862 40 : EHreset_maxopenfiles(intn req_max)
1863 : {
1864 : intn ret_value;
1865 :
1866 40 : if (req_max <= EHXmaxfilecount)
1867 0 : return EHXmaxfilecount;
1868 :
1869 : /* Fallback to built-in NEOSHDF constant if */
1870 : /* SDreset_maxopenfiles() interface is not available */
1871 : /* ------------------------------------------------- */
1872 : #ifdef HDF4_HAS_MAXOPENFILES
1873 40 : ret_value = SDreset_maxopenfiles(req_max);
1874 : #else
1875 : ret_value = NEOSHDF;
1876 : #endif /* HDF4_HAS_MAXOPENFILES */
1877 :
1878 40 : if (ret_value > 0)
1879 : {
1880 40 : EHXtypeTable = realloc(EHXtypeTable, ret_value * sizeof(*EHXtypeTable));
1881 40 : memset(EHXtypeTable + EHXmaxfilecount, 0,
1882 40 : (ret_value - EHXmaxfilecount) * sizeof(*EHXtypeTable));
1883 40 : EHXacsTable = realloc(EHXacsTable, ret_value * sizeof(*EHXacsTable));
1884 40 : memset(EHXacsTable + EHXmaxfilecount, 0,
1885 40 : (ret_value - EHXmaxfilecount) * sizeof(*EHXacsTable));
1886 40 : EHXfidTable = realloc(EHXfidTable, ret_value * sizeof(*EHXfidTable));
1887 40 : memset(EHXfidTable + EHXmaxfilecount, 0,
1888 40 : (ret_value - EHXmaxfilecount) * sizeof(*EHXfidTable));
1889 40 : EHXsdTable = realloc(EHXsdTable, ret_value * sizeof(*EHXsdTable));
1890 40 : memset(EHXsdTable + EHXmaxfilecount, 0,
1891 40 : (ret_value - EHXmaxfilecount) * sizeof(*EHXsdTable));
1892 40 : EHXmaxfilecount = ret_value;
1893 : }
1894 :
1895 40 : return ret_value;
1896 : }
1897 :
1898 : /*----------------------------------------------------------------------------|
1899 : | BEGIN_PROLOG |
1900 : | |
1901 : | FUNCTION: EHget_maxopenfiles |
1902 : | |
1903 : | DESCRIPTION: Request the allowed number of opened HDFEOS files and maximum |
1904 : | number of opened files allowed in the system. |
1905 : | |
1906 : | |
1907 : | Return Value Type Units Description |
1908 : | ============ ====== ========= ===================================== |
1909 : | status intn return status (0) SUCCEED, (-1) FAIL |
1910 : | |
1911 : | INPUTS: |
1912 : | None |
1913 : | |
1914 : | |
1915 : | OUTPUTS: |
1916 : | curr_max intn Current number of open files allowed. |
1917 : | sys_limit intn Maximum number of open files allowed |
1918 : | in the system. |
1919 : | |
1920 : | NOTES: |
1921 : | |
1922 : | |
1923 : | Date Programmer Description |
1924 : | ========== ============ ============================================== |
1925 : | 2013.04.03 Andrey Kiselev Original Programmer |
1926 : | |
1927 : | END_PROLOG |
1928 : -----------------------------------------------------------------------------*/
1929 : static intn
1930 46 : EHget_maxopenfiles(intn *curr_max,
1931 : intn *sys_limit)
1932 : {
1933 46 : intn ret_value = 0;
1934 :
1935 : #ifdef HDF4_HAS_MAXOPENFILES
1936 46 : ret_value = SDget_maxopenfiles(curr_max, sys_limit);
1937 : #else
1938 : *sys_limit = NEOSHDF;
1939 : #endif /* HDF4_HAS_MAXOPENFILES */
1940 :
1941 46 : *curr_max = EHXmaxfilecount;
1942 :
1943 46 : return ret_value;
1944 : }
1945 :
1946 : /*----------------------------------------------------------------------------|
1947 : | BEGIN_PROLOG |
1948 : | |
1949 : | FUNCTION: EHget_numfiles |
1950 : | |
1951 : | DESCRIPTION: Request the number of HDFEOS files currently opened. |
1952 : | |
1953 : | |
1954 : | Return Value Type Units Description |
1955 : | ============ ====== ========= ===================================== |
1956 : | nfileopen intn Number of HDFEOS files already opened. |
1957 : | |
1958 : | INPUTS: |
1959 : | None |
1960 : | |
1961 : | |
1962 : | OUTPUTS: |
1963 : | None |
1964 : | in the system. |
1965 : | |
1966 : | NOTES: |
1967 : | |
1968 : | |
1969 : | Date Programmer Description |
1970 : | ========== ============ ============================================== |
1971 : | 2013.04.03 Andrey Kiselev Original Programmer |
1972 : | |
1973 : | END_PROLOG |
1974 : -----------------------------------------------------------------------------*/
1975 : static intn
1976 92 : EHget_numfiles()
1977 : {
1978 : intn i; /* Loop index */
1979 92 : intn nfileopen = 0; /* # of HDF files open */
1980 :
1981 92 : if (EHXtypeTable)
1982 : {
1983 : /* Determine number of files currently opened */
1984 : /* ------------------------------------------ */
1985 1840090 : for (i = 0; i < EHXmaxfilecount; i++)
1986 : {
1987 1840000 : nfileopen += EHXtypeTable[i];
1988 : }
1989 : }
1990 :
1991 92 : return nfileopen;
1992 : }
|