/******************************************************************************
*
*  NSSDC/CDF                                    Header file for CDFedit.
*
*  Version 1.3a, 20-Jul-95, Hughes STX.
*
*  Modification history:
*
*   V1.0  24-Jan-94, J Love     Original version.
*   V1.0a 30-Mar-94, J Love     Solaris using Gnu C compiler.
*   V1.1  15-Dec-94, J Love     CDF V2.5.
*   V1.2  23-Jan-95, J Love	IRIX 6.x (64-bit).
*   V1.3   3-Apr-95, J Love	POSIX.
*   V1.3a 20-Jul-95, J Love	CDFexport-related changes.
*
******************************************************************************/

#if !defined(CDFEDITh_INCLUDEd__)
#define CDFEDITh_INCLUDEd__

/******************************************************************************
* Include files.
******************************************************************************/

#include "widgets.h"

#if defined(mac)
#include "cdfedit.rh"
#endif

/******************************************************************************
* Global variables.
******************************************************************************/

#if defined(CDFEDIT)
Logical report[3];
Logical dumpStatistics;
Logical gAttrsAndEntries;
Logical vAttrsAndEntries;
char ilhFile[] = "cdfedit.ilh";
#else
extern Logical report[3];
extern Logical dumpStatistics;
extern Logical gAttrsAndEntries;
extern Logical vAttrsAndEntries;
extern char ilhFile[];
#endif

/******************************************************************************
* QOP constants.
******************************************************************************/

#define CDFSPECparm             0

#define BROWSEqual              0
#define NOBROWSEqual            1
#define ZMODEqual               2
#define FORMATqual              3
#define NOFORMATqual            4
#define PROMPTqual              5
#define NOPROMPTqual            6
#define REPORTqual              7
#define NEG2POSFP0qual          8
#define NONEG2POSFP0qual        9
#define CACHEqual               10
#define STATSqual               11
#define NOSTATSqual             12
#define gWITHqual		13
#define NOgWITHqual		14
#define vWITHqual		15
#define NOvWITHqual		16

/******************************************************************************
* Help Identifiers.
******************************************************************************/

#define CDFShelpID              0
#define CDFhelpID               1
#define GATTRShelpID            2
#define VATTRShelpID            3
#define ENTRIEShelpID           4
#define ZVARShelpID             5
#define RVARShelpID             6
#define CDFNAMEhelpID           7
#define RDIMhelpID              8
#define FORMAThelpID            9
#define ENCODINGhelpID          10
#define MAJORITYhelpID          11
#define SPEChelpID              12
#define DELETECDFhelpID         13
#define CREATECDFhelpID         14
#define ATTRRENAMEhelpID        15
#define VARRENAMEhelpID         16
#define ENTRYDATATYPEhelpID     17
#define ENTRYVALUEhelpID        18
#define ENTRYNUMBERhelpID       19
#define VARSELECThelpID         20
#define VARNUMELEMShelpID       21
#define VARVARYShelpID          22
#define RECNUMBERhelpID         23
#define DIMINDEXhelpID          24
#define VARVALUEhelpID          25
#define VARVALUEShelpID         26
#define VARMOREhelpID           27
#define PADVALUEhelpID          28
#define INITIALRECShelpID       29
#define EXTENDRECShelpID        30
#define VARNAMEhelpID           31
#define ATTRNAMEhelpID          32
#define ZDIMhelpID              33
#define VARDATATYPEhelpID       34
#define DELETEATTRhelpID        35
#define DELETEENTRYhelpID       36
#define DELETEVARhelpID         37
#define ALLOCATERECShelpID      38
#define GATTRShelpIDx		39
#define VATTRShelpIDx		40
#define GATTRENTRIEShelpIDx	41
#define VATTRENTRIEShelpIDx	42
#define OLHhelpID               99

/******************************************************************************
* Constants.
******************************************************************************/

#define ONLINE_HELP_WIDTH               78      /* Doesn't include borders. */

#define CDFs_NAME_LEN                   53
#define MAIN_MENU_1st_HALF_LEN          27
#define VAR_MORE_MENU_1st_HALF_LEN      23
#define VARNAME_FIELD_LEN               16
#define ATTRNAME_FIELD_LEN              16
#define DATASPEC_FIELD_LEN              9
#define DIMENSIONS_FIELD_LEN            16
#define VARIANCES_FIELD_LEN             7
#define ENTRYNUM_FIELD_LEN              6
#define gAttrENTRYVALUE_FIELD_LEN       44
#define vAttrENTRYVALUE_FIELD_LEN       34
#define varENTRYVALUE_FIELD_LEN         51

#define VARNAME_FIELD_BLANKS            1
#define DIMENSIONS_FIELD_BLANKS         1
#define VARIANCES_FIELD_BLANKS          1
#define ATTRNAME_FIELD_BLANKS           1
#define ENTRYNUM_FIELD_BLANKS           1
#define DATASPEC_FIELD_BLANKS           1

#define MAX_RECORD_NUMBER_LEN           15
#define MAX_DIMENSION_INDEX_LEN         15
#define MAX_NUMELEMS_LEN                15
#define MAX_ENTRYNUM_LEN                15
#define MAX_DIMENSIONALITY_LEN          50
#define MAX_ENTRYSTRING_LEN             1000
#define MAX_VARIANCES_LEN               (1 + 1 + CDF_MAX_DIMS)

#define DELIMed_ATTR_NAME_LEN           (1 + CDF_ATTR_NAME_LEN + 1)
#define DELIMed_VAR_NAME_LEN            (1 + CDF_VAR_NAME_LEN + 1)

#define ENTRYNUM_FIELD_LENx             6
#define ENTRYNUM_FIELD_BLANKSx          1
#define VARNAME_FIELD_LENx              16
#define VARNAME_FIELD_BLANKSx           1
#define DATASPEC_FIELD_LENx             9
#define DATASPEC_FIELD_BLANKSx          1
#define gAttrENTRYVALUE_FIELD_LENx      61
#define vAttrENTRYVALUE_FIELD_LENx      51
#define ENTRIES_COLUMNx			69

#define MANY_VARs			30
#define MANY_ENTRYs			30
#define MANY_ATTRs_AND_ENTRYs		150

/******************************************************************************
* DataType ItemWindow macros.
******************************************************************************/

#define DTiwSYMBOLS \
"CDF_CHAR         CDF_UCHAR", \
"CDF_INT1         CDF_UINT1", \
"CDF_INT2         CDF_UINT2", \
"CDF_INT4         CDF_UINT4", \
"CDF_REAL4        CDF_FLOAT", \
"CDF_REAL8        CDF_DOUBLE", \
"CDF_BYTE         CDF_EPOCH"

#define DTiwLINEnS 0,0,1,1,2,2,3,3,4,4,5,5,6,6
#define DTiwCOLs 0,17,0,17,0,17,0,17,0,17,0,17,0,17
#define DTiwLENs 8,9,8,9,8,9,8,9,9,9,9,10,8,9

/******************************************************************************
* Function prototypes.
******************************************************************************/

Logical EditCDFs PROTOARGs((int argC, char *argV[]));
Logical EditCDF PROTOARGs((char *, Logical, Logical, long));
Logical EditCDFsMenu PROTOARGs((char *CDFspec, Logical browseOnly,
				Logical negToPosFp0, Logical useFormat,
				long zMode, long cacheSize));
Logical EditAttrs PROTOARGs((Logical, char *));
Logical EditAttrsX PROTOARGs((Logical, char *));
Logical EditAttrEntriesX PROTOARGs((Logical G, long attrN));
Logical EditVars PROTOARGs((Logical, char *, Logical));
Logical EditVarValues PROTOARGs((Logical, long, Logical, Logical *));
Logical EditVarEntries PROTOARGs((Logical, long));
Logical EditVarMore PROTOARGs((Logical, long, Logical, Logical *));
Logical EditEntry PROTOARGs((long attrN, long entryN, int entryType,
			     Logical newDataSpec, Logical *change));
void BuildCDFsMenu PROTOARGs((char *, int *, char ***, char ***,
			      struct ItemWindowStruct *));
Logical BuildCDFmenu PROTOARGs((char *, struct ItemWindowStruct *));
Logical BuildVarMenu PROTOARGs((Logical, char *, struct ItemWindowStruct *));
Logical BuildVarEntryMenu PROTOARGs((Logical, long, long *, long **,
				     Logical **, struct ItemWindowStruct *));
Logical BuildVarMoreMenu PROTOARGs((Logical, long,
				    struct ItemWindowStruct *, Logical));
Logical BuildAttrMenu PROTOARGs((Logical G, char *CDFname, long *nAttrs,
				 long **attrNs, long **nEntries,
				 long ***entryNs,struct ItemWindowStruct *IW));
Logical BuildAttrMenuX PROTOARGs((Logical G, char *CDFname, long *nAttrs,
				  long **attrNs, struct ItemWindowStruct *IW));
Logical BuildAttrEntriesMenuX PROTOARGs((Logical G, long attrN, long *nEntries,
					 long **entryNs, int **entryTypes,
					 struct ItemWindowStruct *IW));
Logical BuildVarValueLine PROTOARGs((Logical, long, long, long, long *,
				     long *, long, long, void *, char *,
				     char *, int *, int *, int *, int,
				     char *));
void FreeVarEntryMenu PROTOARGs((long *, Logical *,
				 struct ItemWindowStruct *));
void FreeAttrMenu PROTOARGs((long nAttrs, long *attrNs, long *nEntries,
			     long **entryNs, struct ItemWindowStruct *IW));
void FreeAttrMenuX PROTOARGs((long *attrNs, struct ItemWindowStruct *IW));
void FreeAttrEntriesMenuX PROTOARGs((long *entryNs, int *entryTypes,
				     struct ItemWindowStruct *IW));
void FreeCDFsMenu PROTOARGs((char **, char **, struct ItemWindowStruct *));
Logical CreateCDF PROTOARGs((char *, char *, long, Logical, Logical, Logical,
			     long));
Logical CreateEntry PROTOARGs((Logical, long, Logical *));
Logical CreateVar PROTOARGs((Logical, Logical *));
Logical EntryExists PROTOARGs((long, long, int));
Logical SpecificationPrompt PROTOARGs((char CDFspec[DU_MAX_PATH_LEN+1],
				       Logical browseOnly, Logical useFormat,
				       Logical negToPosFp0, long zMode,
				       long cacheSize));
Logical TryToEditCDF PROTOARGs((char *CDFspec, Logical browseOnly,
				Logical negToPosFp0, Logical useFormat,
				long zMode, long cacheSize));
Logical PromptForSpec PROTOARGs((char CDFspec[DU_MAX_PATH_LEN+1]));
void ReportStatus PROTOARGs((CDFstatus status));
void CDFstatusWindow PROTOARGs((CDFstatus status));
void InputErrorWindow PROTOARGs((char *, Logical));
Logical ConfirmWindow PROTOARGs((int, char *, char *, Logical, int));
void InitializeScreen PROTOARGs((void));
void CleanupScreen PROTOARGs((void));
Logical EnterIW PROTOARGs((struct ItemWindowStruct *IW, int helpId));
Logical EnterPW PROTOARGs((struct PromptWindowStruct *PW, int helpId));
int IndexInList PROTOARGs((char *match, int nItems, char **items));
int DataTypeItemN PROTOARGs((long dataType));

#if defined(mac)
Logical EditQOPs PROTOARGs((int *argC, char **argV[]));
#endif

/*****************************************************************************/

#endif
