VDataLength
Get length of variable-length data record.
Short Name
GTVLEN()
Type
Low-Level variable-length data file function
Declaration
VRLEN VDataLength(FILNO datno, LONG recbyt) Description
In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering
VDataLength() returns the total length of the variable-length data record beginning at byte offset recbyt in file datno.
Return
If no error occurs, VDataLength() returns the total record length for the specified offset. When VDataLength() returns a zero, check uerr_cod. If uerr_cod is zero, the record length is zero. Otherwise, an error occurred as follows:
| Value | Symbolic Constant | Explanation |
|---|---|---|
| 0 | CTDBRET_OK | Successful operation. |
| 29 | ZREC_ERR | Data file routine called with recbyt = 0. |
| 48 | FMOD_ERR |
Operation incompatible with type of file. The specifics vary by function:
|
| 149 | VRLN_ERR | Variable-length passed to AddVRecord() is less than minimum record length established at file creation. |
| 154 | VRCL_ERR | Attempt to read (R) a zero length record from a variable-length data file. |
| 158 | VFLG_ERR | ReReadVRecord() record not marked active. |
See c-tree Error Codes for a complete listing of valid c-tree error values.
Example
LONG pntr;
VRLEN vreclen;
FILNO datno,keyno;
TEXT key_buffer[64];
if ((pntr = FirstKey(keyno,key_buffer)) != 0L) {
vreclen = VDataLength(datno,pntr);
if (uerr_cod == 0) {
if (vreclen)
printf(
"\nFirst variable record by key requires %d bytes",
vreclen);
else
printf("\nRecord length is zero.");
}
else
printf("\nError %d getting length.", uerr_cod);
}See also
- VRecordLength()
- Record Offsets Under Huge File Support
VRecordLength
Get length of current variable-length ISAM record.
Short Name
GETVLEN()
Type
ISAM variable-length record function
Declaration
VRLEN VRecordLength(FILNO datno) Description
VRecordLength() returns the length of the current ISAM record for variable-length data file datno. If an error occurs, VRecordLength() returns a zero and isam_err is set to the error code.
Ordinarily, VRecordLength() is used to determine the buffer size requirements for the entire record after a call to an ISAM function that reads only the fixed-length portion of the record. ReReadVRecord() can then be called to retrieve the full record. If you already know the maximum possible record length for the data file, it is not necessary to call VRecordLength() before ReReadVRecord().
Return
If no error occurs, VRecordLength() returns the total record length for the current ISAM record. Otherwise, VRecordLength() returns a zero and isam_err is set as follows:
| Value | Symbolic Content | Explanation |
|---|---|---|
| 0 | NO_ERROR | Successful return. |
| 48 | FMOD_ERR | datno is assigned to a fixed length data file. |
| 100 | ICUR_ERR | No current ISAM record for data file. |
See c-tree Error Codes for a complete listing of valid c-tree error values.
Example
COUNT invfil,datfil;
VRLEN varlen;
struct invd {
LONG part_no;
TEXT part_name[120];
} recbuf;
if (FirstRecord(invfil,&recbuf) == NO_ERROR &&
(varlen = VRecordLength(datfil))
printf("\nThe first record is %u bytes long.",varlen);
else
printf("\nError #%d on file %d",isam_err,isam_fil);See also
ReReadVRecord(), VDataLength()
vtclose
Close the least recently used c-tree virtual file.
Short Name
vtclose()
Type
Utility function
Declaration
COUNT vtclose()Description
vtclose() frees an operating system file descriptor by closing the least recently used open c-tree virtual file. In other words, the c-tree virtual file that has not been accessed for the longest period of time will be closed to the operating system, freeing up an operating system file descriptor.
Each time this function is called, c-tree attempts to free one operating system file descriptor.
Note: This function can impose a layer of overhead in Standalone Multi-user systems, especially in heavily loaded network environments. Rather than virtually closing files, it is preferable to increase the number of available operating system file descriptors. This is typically done through the C compiler run-time on non-Unix systems and in the operating system kernel for most Unix systems.
Note: This function is intended for non-server operation, including local library support. If a client side application calls this function, it is ignored so the application does not require special treatment when linking with different c-tree libraries.
Return
vtclose() returns either YES (1) or NO (0). YES signifies a file handle was made available, NO signifies a file handle could not be freed.
See also
“Virtual Files” in the index.