Utility Functions
There are several HEC-DSS utility functions available. There are utilities to check for the existence of a record, rename a record, delete a record, undelete a record, copy a record, rebuild (squeeze) a file, etc.
Most of the utility functions are relatively efficient. For example, when a record is checked (if it exists), its address information is left in memory (ifltab), so that if it is accessed again immediately, the code will go right to the file location of that record without having to access the address tables. Thus, checking and then reading a record takes the same amount of computer effort as just reading the record.
zinquire, zquerry
The function zinquire provides a means of determing information about the DSS file or records in the file. zinquire has two versions; "zinquire" which returns long values, and "zinquireChar" which returns character strings. (Function zinqir returns the same as zinquireChar, but for DSS version 6 files.) zinquire requires that the DSS file is opened and that the ifltab is passed to it.
The function zquerry will return global, non-file parameters and does not require the file to be opened.
The function calls are as follows:
long long zinquire(long long *ifltab, const char *request);
int zinquireChar(long long *ifltab, const char *request, char *creturn, size_t creturnSize, int *number);
int zquery(const char* parameter, char* charVal, size_t lenCharVal, int *integerValue);
For zquery, valid parameters are:
Parameter | Returns | Returns in stringContainer |
mlev | The current message level (0-15) | Nothing |
muni | The message (Fortran) unit | Nothing |
vers | The primary software version (7) | The charater string for the software version. For example "7-AB" |
date | 7 | The software (library) version date |
erro | The last error code encountered, or 0 if no errors | The error message |
For zinquire, valid parameters are:
Parameter | Returns |
handle | The handle of the DSS file |
write | 1, if there is write access to the file. 0, if no write access |
nrecords | Total number of records (pathnames) in the file |
npirmary | number of primary (non-alias) records |
nalias | number of alias recors |
mlevel | message level, DSS-6 equivalent |
mhandle | handle of the message file, if set |
munit | Fortran unit of the message file, if set. |
error | The last error code, or zero if none |
fversion | The 5 digit version number for the file. For example, 7-AB would be 70102 |
size | The size of the DSS file in Kbytes |
fsize | The size of the DSS file in 64 bit words |
dsize | Unused (deleted) space in 64 bit words |
dead | Precentage deleted (dead) space |
readmode | "1" if the file is in read-only mode, "0" if the file is in read and write mode |
reclaim | The reclaim level for this file |
collection | The number of collection records |
expansion | The number of expansions that have occurred for this file |
deleted | The numbe of deleted records in the file |
renamed | The number of renamed records in the file |
maxa | The length of the longest A pathname part |
maxb | The length of the longest B pathname part |
maxc | The length of the longest C pathname part |
maxd | The length of the longest D pathname part |
maxe | The length of the longest E pathname part |
maxf | The length of the longest F pathname part |
multiuser | The multi user access mode |
nother | The number of other processes accessing the file |
squeeze | 1 if a squeeze is suggested, 0 if not |
ftime | File last write time in miliseconds |
mtime | Last write time of this process, in miliseconds |
total | For a loop process, the total number of records |
current | For a loop process, the number of the current record being processed |
nerrors | For a loop process, the number of errors that have been encountered (such as record does not exist) |
For zinquireChar and zinqir (version 6), valid parameters are:
Parameter | Returns | Returns in stringContainer |
erro | The last error code, or zero if none | The last error message |
fver | The 5 digit version number for the file. For example, 7-AB would be 70102 | The charater string for the file version. For example "7-AB" |
vers | The primary software version (7) | The charater string for the software version. For example "7-AB" |
name | zero | The DSS file name |
read | "1" if the file is in read-only mode, "0" if the file is in read and write mode | "ON" if read-only, "OFF if read/write |
rver | The version (number of writes) for the last record accessed | Nothing |
type | The numeric data type for the last record accessed (e.g., 100 for regular interval time series) | The 3-character string representing the last record data type (e.g., "RTS" for regular interval time series) |
prog | Nothing | The name of the program that wrote the last record accessed (if set) |
zset
The function zset sets global (generally non-file) parameters. Its calling sequqnce is:
int zset (const char* parameter, const char* charVal, int integerValue)
Valid parameters are:
Parameter | Alpha | int number | Action |
mlvl | ignored | 0-15 | Set global message level, with 2 terse, 4 normal, > 6 debug levels. For compatibility only, use function zsetMessageLevel instead |
munit | ignored | Fortran unit | Sets the Fortran unit number to write messages to. File must be opened prior to calling. |
mhandle | ignored | C Handle | Sets the C handle number to write messages to. File must be opened prior to calling. |
program | Program name | ignored | Sets the name of the program writing data to the file. For informational purposes only. |
maxpath | ignored | any | Sets the expected maximum number of pathnames for the next new file to be created to correctly size tables. |
collection | ignored | ignored | Cause the next new file to be created to be sized for collections. A collection set uses the same hash code for all records in the set, so that the collection can be quickly traversed. |
empty | ignored | 1 | When the file is copied, this causes empty time series records (all missing data) to be copied also. Normally empty records are not copied |
zgetRecordBasics and zgetRecordSize
zgetRecordBasics is a function to get basic information about a single record; however, not data within that record (you need to read the record to get that.) zgetRecordSize returns the same information as zgetRecordBasics along with several other parameters, and can be used for time series data sets (multiple records).
Be sure to free the structs when you are finished with them.
The calling sequences are:
zStructRecordBasics* zstructRecordBasicsNew(const char* pathname);
int zgetRecordBasics(long long *ifltab, zStructRecordBasics *recordBasics);
zStructRecordSize* zstructRecordSizeNew(const char* pathname);
int zgetRecordSize(long long *ifltab, zStructRecordSize *recordSize);
zStructRecordBasics
typedef struct {
char *pathname;
// Basic record information for all data types
int recordType;
int version;
int numberValues; // The actual number stored (excluding missing) (Daily = 1 to 365)
int logicalNumberValues; // What the user expects including missing (Daily = 365)
// Length (4 byte) of each data array
int values1Number; // (For TS, this is data values)
int values2Number; // (For TS, this is quality array)
int values3Number; // (For TS, this is notes array)
// Length (4 byte) of the 3 header arrays
int internalHeaderNumber;
int header2Number;
int userHeaderNumber;
int allocatedSize; // Total size of all (in ints)
long long recLastWriteTimeMillis;
long long recCreationTimeMillis;
long long fileLastWriteTimeMillis;
long long fileCreationTimeMillis;
int tableHash;
long long pathnameHash;
// Private
char allocated[zSTRUCT_length];
} zStructRecordBasics;
zStructRecordSize
typedef struct {
char *pathname;
// Record information for all data types
int dataType;
int version;
int numberValues;
int logicalNumberValues;
// Length (4 byte) of each data array
int values1Number; // (For TS, this is data values)
int values2Number; // (For TS, this is quality array)
int values3Number; // (For TS, this is notes array)
// Length (4 byte) of the 3 header arrays
int internalHeaderNumber;
int header2Number;
int userHeaderNumber;
int allocatedSize;
long long lastWriteTimeMillis;
char programLastWrite[17];
// Time Series parameters
int numberRecordsFound;
int itsTimePrecisionStored;
int tsPrecision;
int tsTimeOffset;
int tsProfileDepthsNumber;
int tsBlockStartPosition;
int tsBlockEndPosition;
int tsValueSize;
int tsValueElementSize;
int tsValuesCompressionFlag;
int tsQualityElementSize;
int tsQualityCompressionFlag;
int tsInotesElementSize;
int tsInotesCompressionFlag;
int tsCnotesLength;
// Paired Data parameters
int pdNumberCurves;
int pdNumberOrdinates;
int ipdValueSize;
int pdBoolIndependentIsXaxis;
int pdLabelsLength;
int pdPrecision;
} zStructRecordSize;
Record Level Functions
The following record level utility functions are available. The DSS file must be opened for their use. Note, if space reclaimation is on, zundelete and zundeleteAll will not be successful, if their space has already ben reused. If needed, you should call these functions as soon as possible after the delete action. A squeeze will also remove all deleted records.
int zcheck(long long ifltab, const char pathname); // Returns 1 if exits
int zdataType (long long ifltab, const char pathname); // Returns type, eg 100 for RTS
long long zgetLastWriteTimeRec (long long *ifltab, const char *pathname); // milliseconds
int zrename(long long ifltab, const char oldPathname, const char* newPathname);
int zduplicateRecord(long long *ifltab, const char *pathnameFrom, const char *pathnameTo);
int zdelete(long long ifltab, const char pathname);
int zundelete(long long ifltab, const char pathname);
int zundeleteAll(long long *ifltab);
File Level Functions
The following file level functions are available. Some of these functions are convience functions with duplicate capability in function zinquire.
zgetFileVersion does not require the DSS file to be opened, and can also determine if the DSS file exists. It will return 0 if the file does not exist, or the DSS version for the file.
int zgetFileVersion(const char *dssFilename); // 6 or 7. 0 if file does not exist
int zgetVersion(long long *ifltab);
long long zgetLastWriteTimeFile(long long *ifltab); // milliseconds
long long zgetMyLastWriteTime(long long *ifltab);
int zsqueezeNeeded(long long *ifltab); // 1 if true
int zsqueeze(const char *dssFilename); // Close file first
int zcheckFile(long long *ifltab); // Lengthy integrity check. Returns 0 if okay.
int zcopyFile(long long *ifltabFrom, long long *ifltabTo, int statusWanted); // statusWanted = 0
int zconvertVersion(const char* fileNameFrom, const char* fileNameTo); // to 7 or 6