1 /******************************************************************************
2 *
3 *  NSSDC/CDF                                            CDFexport header file.
4 *
5 *  Version 1.2e, 14-Dec-97, Hughes STX.
6 *
7 *  Modification history:
8 *
9 *   V1.0  13-Sep-95, J Love     Original version.
10 *   V1.1  26-Aug-96, J Love     CDF V2.6.
11 *   V1.2  15-Nov-96, J Love     Added `simple' environment and batch mode.
12 *   V1.2a 15-Jan-97, J Love     Added prompts for settings file.  Added `help'
13 *                               qualifier.
14 *   V1.2b 21-Feb-97, J Love     Removed RICE.
15 *   V1.2c 31-Mar-97, J Love     Allow FieldWindow fields to exceed their
16 *                               on-screen width.
17 *   V1.2d 17-Nov-97, J Love	Windows NT/Visual C++.
18 *   V1.2e 14-Dec-97, J Love	Added ALPHAVMSi encoding.
19 *   V3.3  10-Apr-09, M Liu      Added Linux port on PPC.
20 *
21 ******************************************************************************/
22 
23 #if !defined(___cdfxport_h___)
24 #define ___cdfxport_h___
25 
26 /******************************************************************************
27 * Include files.
28 ******************************************************************************/
29 
30 #include "widgets.h"
31 
32 #if defined(mac)
33 #  include "cdfxp.rh"
34 #endif
35 
36 /******************************************************************************
37 * Parameters/qualifiers/options.
38 ******************************************************************************/
39 
40 #define CDFparm                 0
41 
42 #define INITIALqual             0
43 #define PROMPTqual              1
44 #define NOPROMPTqual            2
45 #define CACHEqual               3
46 #define ZMODEqual               4
47 #define NEG2POSFP0qual          5
48 #define NONEG2POSFP0qual        6
49 #define REPORTqual              7
50 #define STATSqual               8
51 #define NOSTATSqual             9
52 #define ABOUTqual               10
53 #define SIMPLEqual              11
54 #define NOSIMPLEqual            12
55 #define CDFqual                 13
56 #define TEXTqual                14
57 #define SETTINGSqual            15
58 #define BATCHqual               16
59 #define HELPqual                17
60 
61 #define FORMATopt               0
62 #define NOFORMATopt             1
63 #define FILTERopt               2
64 #define NOFILTERopt             3
65 #define FILLVALopt              4
66 #define NOFILLVALopt            5
67 #define SINGLEopt               6
68 #define MULTIopt                7
69 #define HOSTopt                 8
70 #define NETWORKopt              9
71 #define EPOCHopt                10
72 #define EPOCH1opt               11
73 #define EPOCH2opt               12
74 #define EPOCH3opt               13
75 #define EPOCHFopt               14
76 #define EPOCHXopt               15
77 #define HORIZONTALopt           16
78 #define VERTICALopt             17
79 #define RECORDopt               18
80 #define NORECORDopt             19
81 #define INDICESopt              20
82 #define NOINDICESopt            21
83 #define ROWopt                  22
84 #define COLUMNopt               23
85 #define VALIDMINopt             24
86 #define NOVALIDMINopt           25
87 #define MONOTONopt              26
88 #define NOMONOTONopt            27
89 #define VALIDMAXopt             28
90 #define NOVALIDMAXopt           29
91 #define FILLSopt                30
92 #define NOFILLSopt              31
93 #define EXCLUSIVEopt            32
94 #define NOEXCLUSIVEopt          33
95 #define OUTPUTopt               34
96 #define NOOUTPUTopt             35
97 #define DELETEopt               36
98 #define NODELETEopt             37
99 #define PREALLOCATEopt          38
100 #define NOPREALLOCATEopt        39
101 #define HEADINGopt              40
102 #define NOHEADINGopt            41
103 
104 /******************************************************************************
105 * Miscellaneous.
106 ******************************************************************************/
107 
108 #define CDFnameLEN              31
109 #define NUMscreenLINES          18
110 #define SCREENtextMAX           (NUMscreenLINES*(SCREEN_WIDTH-2+1))
111 #define MAXvalueLEN             150
112 #define MAXminMaxLEN            150
113 #define MAXfillLEN              150
114 #define MAXitemFieldLEN         150
115 #define MAXwidthLEN             5
116 #define MAXreserveLEN           7
117 #define MAXblockingLEN          8
118 #define MAXrecordNumberLEN      11
119 #define MAXdimensionIndexLEN    11
120 #define MAXgENTRYencodedLEN     150
121 
122 #define MAXwalkingVARs          13
123 
124 #define NOWAIT                  0
125 #define NOBEEPWAIT              -10
126 #define NOBEEPWAIT1             -1
127 #define NOBEEPWAIT2             -2
128 #define BEEPWAIT                10
129 #define BEEPWAIT1               1
130 #define BEEPWAIT2               2
131 
132 #define AMBIGUOUSopt            -1
133 #define UNKNOWNopt              -2
134 
135 #define RECORDt                 0
136 #define INDICESt                1
137 #define VARIABLEt               2
138 
139 #define MIN_RECORD_WIDTH        6
140 #define MIN_INDICES_WIDTH       11
141 #define MIN_VARIABLE_WIDTH      8
142 
143 #define NOminMax                (-1)
144 #define NA_RESERVE              (-1)
145 
146 #define PART_                   0       /* `Simple' mode. */
147 #define PART1                   1
148 #define PART2                   2
149 #define PART3                   3
150 #define PART4                   4
151 
152 #define MAX_ENCODING            ALPHAVMSi_ENCODING
153 #define MAX_COMPRESSION         GZIP_COMPRESSION
154 #define MAX_CHECKSUM            MD5_CHECKSUM
155 #define MAX_SETTINGS_LEN        200
156 
157 #define PASSED                  1
158 #define FAILED                  2
159 #define FATAL                   3
160 
161 #define SUCCESS                 1
162 #define FATALin                 2
163 #define FATALout                3
164 
165 #define EQsearch                0
166 #define LTsearch                1
167 #define LEsearch                2
168 #define GTsearch                3
169 #define GEsearch                4
170 
171 #define BLANKs255 "\
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 * `Batch' mode.
212 ******************************************************************************/
213 
214 #define noBATCH                 0
215 #define BATCHcdf                1
216 #define BATCHtext               2
217 
218 #define BATCH(mode) (mode != noBATCH)
219 
220 /******************************************************************************
221 * `Simple' mode.
222 ******************************************************************************/
223 
224 #define FORCEeachFilterSIMPLE           FALSE
225 #define FORCEoverallFilterSIMPLE        FALSE
226 #define FORCEfillsSIMPLE                FALSE
227 #define FORCEfillvalSIMPLE              FALSE
228 #define FORCEvalidminSIMPLE             FALSE
229 #define FORCEvalidmaxSIMPLE             FALSE
230 #define FORCEmonotonSIMPLE              FALSE
231 
232 #define NAsingleSIMPLE                  FALSE
233 #define NAnetworkSIMPLE                 FALSE
234 #define NAshowSIMPLE                    FALSE
235 #define NAexclusiveSIMPLE               FALSE
236 #define NAdeleteSIMPLE                  FALSE
237 #define NApreAllocateSIMPLE             FALSE
238 
239 #define SCREENkey_SIMPLE                KB_CTRL_A
240 #define FILEkey_SIMPLE                  KB_CTRL_B
241 #define SAVEkey_SIMPLE                  KB_CTRL_J
242 #define RESTOREkey_SIMPLE               KB_CTRL_L
243 
244 #if defined(alphaosf) || defined(IRIX64bit) || defined(SOLARIS64) || \
245     defined(__amd64) || defined(__x86_64__) || defined(__ia64__) || \
246     defined(__PPC64__) || defined(__ppc64__)
247 #  define Int32FORMATstandard     "%11d"
248 #  define Int32uFORMATstandard    "%10d"
249 #else
250 #  define Int32FORMATstandard     "%11ld"
251 #  define Int32uFORMATstandard    "%10ld"
252 #endif
253 
254 #define EPOCHx_FORMAT_STANDARD  "*Unsupported*"
255 
256 /******************************************************************************
257 * Field numbers/locations.
258 ******************************************************************************/
259 
260 #define CDFfn                   0
261 #define CDFfieldLINEn           0
262 #define CDFfieldCOLn            8
263 #define CDFfieldLEN             70
264 #define CDFfieldMAX             CDF_PATHNAME_LEN
265 #define CDFvarsRecsLINEn        1
266 
267 #define NAMEitemCOLnSIMPLE      0
268 #define NAMEitemLENsimple       71
269 #define OUTPUTitemCOLnSIMPLE    72
270 #define OUTPUTitemLENsimple     6
271 
272 #define NAMEitemCOLn            0
273 #define NAMEitemLEN             21
274 
275 #define SPECitemCOLn            22
276 #define SPECitemLEN             9
277 #define DIMENitemCOLn           32
278 #define DIMENitemLEN            27
279 #define VARYSitemCOLn           60
280 #define VARYSitemLEN            11
281 #define OUTPUTitemCOLn          72
282 #define OUTPUTitemLEN           6
283 
284 #define MINitemCOLn             22
285 #define MINitemLEN              24      /* Maximum of the possible styles. */
286 #define MAXitemCOLn             47
287 #define MAXitemLEN              24      /* Maximum of the possible styles. */
288 #define FILTERitemCOLn          72
289 #define FILTERitemLEN           6
290 
291 #define FILLitemCOLn            22
292 #define FILLitemLEN             26
293 #define MONOitemCOLn            49
294 #define MONOitemLEN             13
295 #define FORMATitemCOLn          63
296 #define FORMATitemLEN           9
297 #define WIDTHitemCOLn           73
298 #define WIDTHitemLEN            5
299 
300 #define SPARSEitemCOLn          22
301 #define SPARSEitemLEN           19
302 #define COMPRESSitemCOLn        42
303 #define COMPRESSitemLEN         19
304 #define RESERVEitemCOLn         62
305 #define RESERVEitemLEN          7
306 #define BLOCKINGitemCOLn        70
307 #define BLOCKINGitemLEN         8
308 
309 #define nSELWINDOWcolsMAX       5
310 #define nSELWINDOWcols1         5
311 #define nSELWINDOWcols2         4
312 #define nSELWINDOWcols3         5
313 #define nSELWINDOWcols4         5
314 #define nSELWINDOWcols_         2       /* `Simple' mode. */
315 
316 #define WALKleftLEN             21
317 #define WALKrightLEN            56
318 
319 /******************************************************************************
320 * Column numbers.
321 ******************************************************************************/
322 
323 #define NAMEcxSIMPLE            0
324 #define OUTPUTcxSIMPLE          1
325 
326 #define NAMEcx                  0
327 
328 #define SPECcx                  1
329 #define DIMENcx                 2
330 #define VARYScx                 3
331 #define OUTPUTcx                4
332 
333 #define MINcx                   1
334 #define MAXcx                   2
335 #define FILTERcx                3
336 
337 #define FILLcx                  1
338 #define MONOcx                  2
339 #define FORMATcx                3
340 #define WIDTHcx                 4
341 
342 #define SPARSEcx                1
343 #define COMPRESScx              2
344 #define RESERVEcx               3
345 #define BLOCKINGcx              4
346 
347 /******************************************************************************
348 * Row numbers.
349 ******************************************************************************/
350 
351 #define FILTERrx                0
352 #define FILLSrx                 1
353 #define CDFFORMATrx             2
354 #define ENCODINGrx              3
355 #define EPOCHrx                 4
356 #define hvMODErx                5
357 #define MAJORrx                 6
358 #define SHOWrx                  7
359 #define SPACINGrx               8
360 #define DELETErx                9
361 #define PREALLOCrx              10
362 #define HEADINGrx               11
363 
364 /******************************************************************************
365 * Item numbers.
366 ******************************************************************************/
367 
368 #define NONEin                  0
369 #define RLE0in                  1
370 #define HUFF0in                 2
371 #define AHUFF0in                3
372 #define GZIPin                  4
373 /* #define ZLIB0in                 5 */
374 
375 #define NOsRECORDSin            0
376 #define PADsRECORDSin           1
377 #define PREVsRECORDSin          2
378 
379 #define MD5in                   1
380 /******************************************************************************
381 * Actions.
382 ******************************************************************************/
383 
384 #define TOSCREENact             0
385 #define TOFILEact               1
386 #define TOCDFact                2
387 #define WALKact                 3
388 #define OUTPUTallITEMSact       4
389 #define OUTPUTnoITEMSact        5
390 #define FILTERallITEMSact       6
391 #define FILTERnoITEMSact        7
392 #define SETcdfCOMPRESSact       8
393 #define SETvarCOMPRESSact       9
394 #define SAVEact                 10
395 #define RESTOREact              11
396 #define SETMONOact              12
397 #define TOCDFv2act              13
398 #define SETcdfCHECKSUMact       14
399 
400 /******************************************************************************
401 * Help identifiers.
402 ******************************************************************************/
403 
404 #define CDFhelpID               1
405 #define CDFShelpID              2
406 #define VAR1helpID              3
407 #define VAR2helpID              4
408 #define VAR3helpID              5
409 #define ACTIONhelpID            6
410 #define OPTIONhelpID            7
411 #define MINmaxRECORDhelpID      8
412 #define MINmaxINDICEShelpID     9
413 #define MINmaxVALUEhelpID       10
414 #define FILLhelpID              11
415 #define FORMAThelpID            12
416 #define WIDTHhelpID             13
417 #define SCREENhelpID            14
418 #define oFILEhelpID             15
419 #define oCDFhelpID              16
420 #define VAR4helpID              17
421 #define BLOCKINGhelpID          18
422 #define COMPRESShelpID          19
423 #define SPARSEhelpID            20
424 #define RESERVEhelpID           21
425 #define GZIPhelpID              23
426 #define WALKriHelpID            24
427 #define WALKvarHelpID           25
428 #define RECORDhelpID            26
429 #define INDEXhelpID             27
430 #define VALUEhelpID             28
431 #define SEARCHTYPEhelpID        29
432 #define VARhelpID               30      /* `Simple' mode. */
433 #define SETFILEhelpID           31
434 #define ACTIONv32helpID         32
435 #define CHECKSUMhelpID          33
436 #define OLHhelpID               99
437 
438 /******************************************************************************
439 * Output types.
440 ******************************************************************************/
441 
442 #define OUTPUTtoSCREENh         1
443 #define OUTPUTtoSCREENv         2
444 #define OUTPUTtoFILEh           3
445 #define OUTPUTtoFILEv           4
446 #define OUTPUTtoCDF             5
447 
448 /******************************************************************************
449 * Monotonicities.
450 ******************************************************************************/
451 
452 #define NAmono                  (-1)
453 #define UNKNOWNmono             0
454 #define INCREASEmono            1
455 #define DECREASEmono            2
456 #define FALSEmono               3
457 
458 /******************************************************************************
459 * Filter status.
460 ******************************************************************************/
461 
462 #define PASSes          1
463 #define SHOWit          2
464 #define FAILline        3
465 #define FAILrecord      4
466 
467 #define SHOWline(status) (status == PASSes || status == SHOWit)
468 
469 /******************************************************************************
470 * NEWkeyDEFs.
471 ******************************************************************************/
472 
473 #define NEWkeyDEFS(EWkey,keyDefs,batchMode) \
474 if (!BATCH(batchMode)) { \
475   EWkey->eText = keyDefs; \
476   EditWindow (UPDATEew, EWkey, LogicalTRUE); \
477 }
478 
479 /******************************************************************************
480 * VALUEinBUFFER.
481 ******************************************************************************/
482 
483 #define VALUEinBUFFER(Var,valueN) \
484 (Var->buffer + (size_t) (valueN * Var->nValueBytes))
485 
486 /******************************************************************************
487 * MAJORITYtoOUT.
488 ******************************************************************************/
489 
490 #define MAJORITYtoOUT(outMajority,inMajority) \
491 BOO(outMajority == INPUT_MAJOR,inMajority,outMajority)
492 
493 /******************************************************************************
494 * RECORDfailedFILTER, INDICESfailedFILTER, and VARfailedFILTER.
495 ******************************************************************************/
496 
497 #define RECORDfailedFILTER(Item,recN) \
498 (Item->filter && \
499  (!RecordPassesMin(Item,recN) || !RecordPassesMax(Item,recN)))
500 
501 #define INDICESfailedFILTER(Item,indices) \
502 (Item->filter && \
503  (!IndicesPassMin(Item,indices) || !IndicesPassMax(Item,indices)))
504 
505 #define VARfailedFILTER(Item,value) \
506 (Item->filter && \
507  (!VarPassesMin(Item,value) || !VarPassesMax(Item,value)))
508 
509 /******************************************************************************
510 * SELECTcdf.
511 ******************************************************************************/
512 
513 #define SELECTcdf(id) CDFlib(SELECT_,CDF_,id,NULL_);
514 
515 /******************************************************************************
516 * MINorMAXexists.
517 ******************************************************************************/
518 
519 #define MINorMAXexists(Item) \
520 (Item->type == RECORDt && \
521  (Item->Record->min != NOminMax || \
522   Item->Record->max != NOminMax)) || \
523 (Item->type == INDICESt && \
524  (Item->Indices->minNumDims != NOminMax || \
525   Item->Indices->maxNumDims != NOminMax)) || \
526 (Item->type == VARIABLEt && \
527  (Item->Var->min != NULL || \
528   Item->Var->max != NULL))
529 
530 /******************************************************************************
531 * FILTER.
532 ******************************************************************************/
533 
534 #define FILTER(Item,opt) (opt.overallFilter && Item->filter)
535 
536 /******************************************************************************
537 * USEFILL.
538 ******************************************************************************/
539 
540 #define USEFILL(Var,opt) (opt.useFills && Var->fill != NULL)
541 
542 /******************************************************************************
543 * WRITEFILL.
544 ******************************************************************************/
545 
546 #define WRITEFILL(Var,opt) \
547 (USEFILL(Var,opt) && NEx(Var->fill,Var->pad,Var->dataType,Var->numElems))
548 
549 /******************************************************************************
550 * NRVtoOUTPUT.
551 ******************************************************************************/
552 
553 #define NRVtoOUTPUT(Item) \
554 (Item->output && !Item->Var->recVary)
555 
556 /******************************************************************************
557 * HYPERget/put and SINGLEget/put.
558 ******************************************************************************/
559 
560 #define SINGLEget(id,varN,zVar,recNumber,dimIndices,buffer) \
561 CDFlib (SELECT_, CDF_, id, \
562 		 BOO(zVar,zVAR_,rVAR_), varN, \
563 		 BOO(zVar,zVAR_RECNUMBER_,rVARs_RECNUMBER_), recNumber, \
564 		 BOO(zVar,zVAR_DIMINDICES_,rVARs_DIMINDICES_), dimIndices, \
565 	GET_, BOO(zVar,zVAR_DATA_,rVAR_DATA_), buffer, \
566 	NULL_)
567 
568 #define SINGLEput(id,varN,zVar,recNumber,dimIndices,buffer) \
569 CDFlib (SELECT_, CDF_, id, \
570 		 BOO(zVar,zVAR_,rVAR_), varN, \
571 		 BOO(zVar,zVAR_RECNUMBER_,rVARs_RECNUMBER_), recNumber, \
572 		 BOO(zVar,zVAR_DIMINDICES_,rVARs_DIMINDICES_), dimIndices, \
573 	PUT_, BOO(zVar,zVAR_DATA_,rVAR_DATA_), buffer, \
574 	NULL_)
575 
576 #define HYPERget(id,varN,zVar,recNumber,recCount,dimIndices,dimCounts,buffer) \
577 CDFlib (SELECT_, CDF_, id, \
578 		 BOO(zVar,zVAR_,rVAR_), varN, \
579 		 BOO(zVar,zVAR_RECNUMBER_,rVARs_RECNUMBER_), recNumber, \
580 		 BOO(zVar,zVAR_RECCOUNT_,rVARs_RECCOUNT_), recCount, \
581 		 BOO(zVar,zVAR_DIMINDICES_,rVARs_DIMINDICES_), dimIndices, \
582 		 BOO(zVar,zVAR_DIMCOUNTS_,rVARs_DIMCOUNTS_), dimCounts, \
583 	GET_, BOO(zVar,zVAR_HYPERDATA_,rVAR_HYPERDATA_), buffer, \
584 	NULL_)
585 
586 #define HYPERput(id,varN,zVar,recNumber,recCount,dimIndices,dimCounts,buffer) \
587 CDFlib (SELECT_, CDF_, id, \
588 		 BOO(zVar,zVAR_,rVAR_), varN, \
589 		 BOO(zVar,zVAR_RECNUMBER_,rVARs_RECNUMBER_), recNumber, \
590 		 BOO(zVar,zVAR_RECCOUNT_,rVARs_RECCOUNT_), recCount, \
591 		 BOO(zVar,zVAR_DIMINDICES_,rVARs_DIMINDICES_), dimIndices, \
592 		 BOO(zVar,zVAR_DIMCOUNTS_,rVARs_DIMCOUNTS_), dimCounts, \
593 	PUT_, BOO(zVar,zVAR_HYPERDATA_,rVAR_HYPERDATA_), buffer, \
594 	NULL_)
595 
596 /******************************************************************************
597 * Record structure.
598 ******************************************************************************/
599 
600 struct RecordStruct {
601   long min;
602   long max;
603 };
604 
605 /******************************************************************************
606 * Indices structure.
607 ******************************************************************************/
608 
609 struct IndicesStruct {
610   long numDims;
611   long dimSizes[CDF_MAX_DIMS];
612   long indices[CDF_MAX_DIMS];
613   long minNumDims;
614   long minIndices[CDF_MAX_DIMS];
615   long maxNumDims;
616   long maxIndices[CDF_MAX_DIMS];
617 };
618 
619 /******************************************************************************
620 * Variable structure.
621 ******************************************************************************/
622 
623 struct VarStruct {
624   long varN;            /* Number. */
625   long numDims;         /* Number of dimensions. */
626   long dimSizes[CDF_MAX_DIMS];
627 			/* Dimension sizes (conceptual). */
628   long nRecordValues;   /* Number of values per record (conceptual). */
629   long dataType;        /* Data type. */
630   long numElems;        /* Number of elements (of the data type) per value. */
631   long recVary;         /* Record variance. */
632   long dimVarys[CDF_MAX_DIMS];
633 			/* Dimension variances. */
634   long maxRec;          /* Maximum record written. */
635   long blocking;        /* Blocking factor. */
636   long reserve;         /* Reserve percentage. */
637   long sRecordsType;    /* Sparse records type. */
638   long sArraysType;     /* Sparse arrays type. */
639   long sArraysParms[CDF_MAX_PARMS];
640 			/* Sparse arrays parameters. */
641   long cType;           /* Compression type. */
642   long cParms[CDF_MAX_PARMS];
643 			/* Compression parameters. */
644   long valueN;          /* Value number. */
645   long indices[CDF_MAX_DIMS];
646 			/* Indices for this variable. */
647   long varNo;           /* Corresponding variable number in an output CDF. */
648   long oRecords;        /* Number of records to be written to the corresponding
649 			   variable in an output CDF. */
650   void *min;            /* Minimum filter value. */
651   void *max;            /* Maximum filter value. */
652   void *fill;           /* FILLVAL entry converted to variable's data type. */
653   void *pad;            /* Pad value. */
654   void *value;          /* Buffer for one value. */
655   Byte *buffer;         /* Buffer for many values. */
656   char *name;           /* Variable name. */
657   char *format;         /* Format (C or Fortran). */
658   size_t nValueBytes;   /* Number of bytes per variable value. */
659   int monotonic;        /* `INCREASEmono' if this variable is monotonic
660 			   increase, `DECREASEmono' if monotonic decrease,
661 			   `FALSEmono' if not monotonic, or `UNKNOWNmono'
662 			   if monotonicity is unknown. */
663   Logical zVar;         /* TRUE if a zVariable, FALSE if an rVariable. */
664   Logical scalar;       /* Scalar variable? */
665 };
666 
667 /******************************************************************************
668 * Item structure.
669 ******************************************************************************/
670 
671 struct ItemStruct {
672   int type;                     /* RECORDSt, INDICESt, or VARIABLEt. */
673   int width;
674   Logical outputSetting;        /* Setting on the SelectionWindow. */
675   Logical filterSetting;        /* Setting on the SelectionWindow. */
676   Logical output;               /* If item should be output. */
677   Logical filter;               /* If item should be filtered. */
678   Logical inclusive;
679   struct VarStruct *Var;
680   struct RecordStruct *Record;
681   struct IndicesStruct *Indices;
682   struct ItemStruct *nextItem;
683   struct ItemStruct *nextExport;
684   struct ItemStruct *nextScalar;
685   struct ItemStruct *nextHyper;
686 };
687 
688 /******************************************************************************
689 * Options structure.
690 ******************************************************************************/
691 
692 struct OptionStruct {
693   long encoding;                /* Encoding for output CDFs. */
694   long majority;                /* Majority for listings/output CDFs. */
695   Logical eachFilter;           /* Initial filter setting for each
696 				   item/variable (yes/no). */
697   Logical overallFilter;        /* Overall use of filters? */
698   Logical useFills;             /* Use fill values? */
699   Logical useFORMAT;            /* Use FORMAT attribute entries? */
700   Logical useFILLVAL;           /* Use FILLVAL attribute entries? */
701   Logical useVALIDMIN;          /* Use VALIDMIN attribute entries? */
702   Logical useVALIDMAX;          /* Use VALIDMAX attribute entries? */
703   Logical useMONOTON;           /* Use MONOTON attribute entries? */
704   Logical singleFile;
705   Logical horizontalMode;
706   Logical showRecord;
707   Logical showIndices;
708   Logical showFiltered;
709   Logical exclusive;
710   Logical outputItem;           /* Initial output setting for each
711 				   item/variable (yes/no). */
712   Logical deleteExisting;       /* Delete existing CDFs? */
713   Logical preAllocate;          /* Preallocate variable records? */
714   Logical textHeading;          /* Display heading line in text files? */
715   int epochStyle;
716   int spacing;
717 };
718 
719 /******************************************************************************
720 * Global variables.
721 ******************************************************************************/
722 
723 #if defined(CDFXP)
724 int batchMode = noBATCH;
725 Logical simpleMode = DEFAULTsimpleEXPORT;
726 Logical dumpStats = DEFAULTstatsEXPORT;
727 Logical report[3] = {
728   REPORTerrorsDEFAULT, REPORTwarningsDEFAULT, REPORTinfosDEFAULT
729 };
730 long inMajority;
731 struct OptionStruct opt;
732 int nItems;
733 struct ItemStruct *itemHead;
734 struct FieldWindowStruct *FWcdf;
735 struct ItemWindowStruct *IWsel;
736 struct EditWindowStruct *EWkey;
737 struct EditWindowStruct *EWmsg;
738 long workingCache = useDEFAULTcacheSIZE;
739 long stageCache = useDEFAULTcacheSIZE;
740 long compressCache = useDEFAULTcacheSIZE;
741 char na[] = "n/a";
742 char dots[] = "...";
743 char *monos[] = { "n/a", "Unknown", "Increase", "Decrease", "False" };
744 char *epochStyles[] = {
745   "standard", "alternate/1", "alternate/2", "alternate/3",
746   "Format/C_Fortran", "Format/custom"
747 };
748 char *encodings[] = {
749   NULL, "NETWORK", "SUN", "VAX", "DECSTATION", "SGi", "IBMPC", "IBMRS",
750   "HOST", "PPC", NULL, "HP", "NeXT", "ALPHAOSF1", "ALPHAVMSd", "ALPHAVMSg",
751   "ALPHAVMSi", "PowerPC",
752 };
753 char *majorities[] = { "input", "row", "column" };
754 char *compressions[] = { "no", "rle", "huff", "ahuff", "gzip" };
755 char *checksums[] = {"no", "md5"};
756 char readingCDF[] = "reading input CDF";
757 char writingCDF[] = "writing output CDF";
758 long dimIndices_0[CDF_MAX_DIMS] = { 0,0,0,0,0,0,0,0,0,0 };
759 long dimCounts_1[CDF_MAX_DIMS] = { 1,1,1,1,1,1,1,1,1,1 };
760 long CDFcType;
761 long CDFcParms[CDF_MAX_PARMS];
762 long NrVars, NzVars;
763 long rMaxRec, zMaxRec;
764 long CDFchecksum;
765 #if DEFAULTsimpleEXPORT
766 char settingsFile[DU_MAX_PATH_LEN+1] = "simple.set";
767 #else
768 char settingsFile[DU_MAX_PATH_LEN+1] = "export.set";
769 #endif
770 char outputText[DU_MAX_PATH_LEN+1] = "default.lis";
771 char outputCDF[CDF_PATHNAME_LEN+1] = "default";
772 #else
773 extern int batchMode;
774 extern Logical simpleMode;
775 extern Logical dumpStats;
776 extern Logical report[3];
777 extern long inMajority;
778 extern struct OptionStruct opt;
779 extern int nItems;
780 extern struct ItemStruct *itemHead;
781 extern struct FieldWindowStruct *FWcdf;
782 extern struct ItemWindowStruct *IWsel;
783 extern struct EditWindowStruct *EWkey;
784 extern struct EditWindowStruct *EWmsg;
785 extern long workingCache, stageCache, compressCache;
786 extern char na[];
787 extern char dots[];
788 extern char *monos[];
789 extern char *epochStyles[];
790 extern char *encodings[];
791 extern char *majorities[];
792 extern char *compressions[];
793 extern char *checksums[];
794 extern char readingCDF[];
795 extern char writingCDF[];
796 extern long dimIndices_0[CDF_MAX_DIMS];
797 extern long dimCounts_1[CDF_MAX_DIMS];
798 extern long CDFcType;
799 extern long CDFcParms[CDF_MAX_PARMS];
800 extern long NrVars, NzVars;
801 extern long rMaxRec, zMaxRec;
802 extern long CDFchecksum;
803 extern char settingsFile[DU_MAX_PATH_LEN+1];
804 extern char outputText[DU_MAX_PATH_LEN+1];
805 extern char outputCDF[CDF_PATHNAME_LEN+1];
806 #endif
807 
808 /******************************************************************************
809 * Function prototypes.
810 ******************************************************************************/
811 
812 Logical ExportCDFs PROTOARGs((int argC, char *argV[]));
813 void CDFexportMenu PROTOARGs((
814   char *iniSpec, Logical prompt, long zMode, Logical negToPosFp0
815 ));
816 void ExportCDFsSpec PROTOARGs((
817   char *path, long zMode, Logical negToPosFp0, char *varLabel0,
818   char *varHeader0[]
819 ));
820 void ExportCDF PROTOARGs((char *path, long zMode, Logical negToPosFp0));
821 Logical LoadCDF PROTOARGs((void));
822 Logical LoadSelectionWindow PROTOARGs((int part));
823 void LoadCDFwindow PROTOARGs((char *path));
824 void SelectionWindow PROTOARGs((Logical *noMoreAccess));
825 Logical SelectionWindow1 PROTOARGs((Logical *noMoreAccess));
826 Logical SelectionWindow2 PROTOARGs((Logical *noMoreAccess));
827 Logical SelectionWindow3 PROTOARGs((Logical *noMoreAccess));
828 Logical SelectionWindow4 PROTOARGs((Logical *noMoreAccess));
829 Logical ActionMenu PROTOARGs((int part));
830 void OptionMenu PROTOARGs((void));
831 Logical ConfirmExit PROTOARGs((void));
832 void DisplayStatus PROTOARGs((CDFstatus status, char *text));
833 int DisplayMessage PROTOARGs((char *message, int wait));
834 int MatchOption PROTOARGs((char *option, char *validOptions[]));
835 void FreeItems PROTOARGs((void));
836 int LongValueWidth PROTOARGs((long value));
837 int RecordIndicesWidth PROTOARGs((
838   long lastRec, long numDims, long dimSizes[], int type
839 ));
840 void FreeToScreen PROTOARGs((
841   char *header[], char *scrLines[], char *trailer[]
842 ));
843 Logical PromptFor PROTOARGs((
844   char *value, int valueL, int cursorAt, char *label, int helpID
845 ));
846 Logical PromptForMinMax PROTOARGs((struct ItemStruct *Item, Logical min));
847 Logical PromptForFill PROTOARGs((struct VarStruct *Var));
848 Logical PromptForReserve PROTOARGs((struct VarStruct *Var));
849 Logical PromptForBlocking PROTOARGs((struct VarStruct *Var));
850 Logical PromptForWidth PROTOARGs((struct ItemStruct *Item));
851 Logical PromptForFormat PROTOARGs((struct ItemStruct *Item));
852 Logical PromptForCompression PROTOARGs((
853   long *cType, long cParms[CDF_MAX_PARMS]
854 ));
855 Logical PromptForSparseness PROTOARGs((struct VarStruct *Var));
856 Logical PromptForChecksum PROTOARGs((long *checksum));
857 Logical FlipItems PROTOARGs((int itemX));
858 int VariableWidth PROTOARGs((struct VarStruct *Var));
859 void SaveSettings PROTOARGs((void));
860 void RestoreSettings PROTOARGs((void));
861 Logical ToWalk PROTOARGs((void));
862 Logical ToScreenHori PROTOARGs((void));
863 Logical ToFileHori PROTOARGs((void));
864 CDFstatus EncodeLineHori PROTOARGs((
865   char *line, long recN, int *filterStatus, struct ItemStruct *exportHead,
866   Logical standard
867 ));
868 Logical ToScreenVert PROTOARGs((void));
869 Logical ToFileVert PROTOARGs((void));
870 CDFstatus EncodeLineVert PROTOARGs((
871   char *line, long recN, long valueN, long numDims,
872   long indices[CDF_MAX_DIMS], Logical same, int *filterStatus,
873   struct ItemStruct *exportHead, Logical outRowMajor, Logical standard
874 ));
875 Logical ListAttributes PROTOARGs((FILE *oFp, Logical *cdfFatal));
876 Logical ToCDF PROTOARGs((CDFid inID));
877 int ToCDFsameGt0 PROTOARGs((
878   CDFid inID, CDFid outID, long firstRec, long lastRec, long numDims,
879   long dimSizes[], long firstIndices[], long outMajority,
880   struct ItemStruct *exportHead
881 ));
882 int ToCDFdiffOrZero PROTOARGs((
883   CDFid inID, CDFid outID, long firstRec, long lastRec, long outMajority,
884   struct ItemStruct *exportHead
885 ));
886 int OutputNRVvalues PROTOARGs((
887   CDFid inID, CDFid outID, struct ItemStruct *exportHead, Logical same,
888   long dimSizes[], long firstIndices[], long outMajority
889 ));
890 Logical OutputHyperBuffer PROTOARGs((
891   CDFid outID, long varNo, Logical zVar, long outMajority, long recNumber,
892   long recCount, long dimIndices[], long dimCounts[], long numDims,
893   long dimSizes[], Byte *buffer, long nValues, Logical fullRecord,
894   size_t nValueBytes, long nRecordValues
895 ));
896 int CopyAttributesANDgEntries PROTOARGs((
897   CDFid inID, CDFid outID, long *nAttrs
898 ));
899 int CopyVariablesANDrzEntries PROTOARGs((
900   CDFid inID, CDFid outID, long nAttrs, Logical same, long numDims,
901   long dimSizes[], struct ItemStruct *exportHead
902 ));
903 Logical FirstLastRecord PROTOARGs((
904   long *firstRec, long *lastRec, Logical toCDF, struct ItemStruct *exportHead
905 ));
906 Logical FirstLastIndices PROTOARGs((
907   long numDims, long dimSizes[], long firstIndices[], long lastIndices[],
908   long *nValues, Logical toCDF, struct ItemStruct *exportHead
909 ));
910 Logical ScalarVariable PROTOARGs((struct VarStruct *Var));
911 Logical DimensionalVariable PROTOARGs((struct VarStruct *Var, int *dimN));
912 Logical OneDimensionVaries PROTOARGs((struct VarStruct *Var));
913 Logical ReadScalarValue PROTOARGs((struct VarStruct *Var, long recN));
914 Logical ReadDimensionalValue PROTOARGs((
915   struct VarStruct *Var, long indices[]
916 ));
917 Logical ValidFormat PROTOARGs((char *format));
918 Logical SameDimensionalities PROTOARGs((
919   long *numDims, long dimSizes[], struct ItemStruct *exportHead
920 ));
921 void ValidateRecordIndices PROTOARGs((
922   int type, Logical same, long numDims, struct ItemStruct *exportHead
923 ));
924 Logical VarPassesMin PROTOARGs((struct ItemStruct *Item, void *value));
925 Logical VarPassesMax PROTOARGs((struct ItemStruct *Item, void *value));
926 Logical RecordPassesMin PROTOARGs((struct ItemStruct *Item, long recN));
927 Logical RecordPassesMax PROTOARGs((struct ItemStruct *Item, long recN));
928 Logical IndicesPassMin PROTOARGs((struct ItemStruct *Item, long indices[]));
929 Logical IndicesPassMax PROTOARGs((struct ItemStruct *Item, long indices[]));
930 void DisplayPctComplete PROTOARGs((int pct, char *msg));
931 void UpdateToScreen PROTOARGs((
932   struct EditWindowStruct *EWscr, char *trailerMsg, long at, long total
933 ));
934 Logical SetItemMonotonicities PROTOARGs((void));
935 Logical SetVarMonotonicity PROTOARGs((struct VarStruct *Var));
936 void BuildExportList PROTOARGs((
937   struct ItemStruct **exportHead, Logical walking
938 ));
939 void RemoveExportItems PROTOARGs((struct ItemStruct **exportHead));
940 void FreeExportBuffers PROTOARGs((struct ItemStruct *exportHead));
941 void FilterHypers PROTOARGs((struct ItemStruct *hyperHead, long nValues));
942 long FindFirstRecord PROTOARGs((
943   long recX, struct ItemStruct *scalarHead, Logical filteringScalars,
944   long recCount
945 ));
946 long FindLastRecord PROTOARGs((
947   long recF, struct ItemStruct *scalarHead, Logical filteringScalars,
948   long recCount
949 ));
950 void FilterBuffer PROTOARGs((
951   struct ItemStruct *Item, Byte *buffer, long nValues
952 ));
953 Logical AbortListing PROTOARGs((FILE *oFp, char *line));
954 Logical AbortCDF PROTOARGs((struct ItemStruct *exportHead));
955 int PreAllocateRecords PROTOARGs((
956   CDFid inID, CDFid outID, struct ItemStruct *scalarHead,
957   struct ItemStruct *hyperHead, long *firstRec, long *lastRec
958 ));
959 void OptDefaults PROTOARGs((void));
960 
961 #if defined(mac)
962 Logical ExportQOPs PROTOARGs((
963   int *argC, char **argV[]
964 ));
965 #endif
966 
967 /*****************************************************************************/
968 
969 #endif /* ___cdfxport_h___ */
970