PREV UP NEXT The Ftape Tools Manual - API


8.4.2.3: Printing volume table entries and parsing of input.

Library Function: void ftvt_print (const ftvt *VOLUMES, int MAXNUM)

Print the volume table to stdout. The format of the output depends on whether the flag FTVT_TAGGED had been passed to ftvt_set_ctrl(). See Option Settings.

In case FTVT_TAGGED is set the output of ftvt_print() can be used as input to ftvt_parse_tagged() (see below).

Arguments
const ftvt *VOLUMES

The libraries volume table representation. This must be the same pointer as given to ftvt_read().


int MAXNUM

Number of entries in VOLUMES, i.e. the return value of ftvt_read() (see Tape I/O), or ftvt_add_volume() (see Modifying Entries).


Return Value

None.


Side Effects

None.


Example
ftvt_print(volumes, num_volumes);

The resulting output would look like (FTVT_TAGGED not set)

 Nr  Id          Label                   Date           Start      End    Space
--------------------------------------------------------------------------------
  0 VTBL "zftape volume 000     "  00:00:00 01/01/70        3     1271    2.34%

or in case FTVT_TAGGED has been specified:

VTBL START 2 54199
ENTRY 0
SIGNATURE "VTBL"
START 3
END 1271
DESCRIPTION "zftape volume 000"
DATE "00:00:00 01/01/70"
FLAG_VENDOR_SPECIFIC 0
FLAG_MULTI_CARTRIDGE 0
FLAG_NOT_VERIFIED 1
FLAG_REDIRECTION_INHIBIT 0
FLAG_SEGMENT_SPANNING 1
FLAG_DIRECTORY_LAST 0
FLAG_RESERVED_6 0
FLAG_RESERVED_7 0
MULTI_CARTRIDGE_COUNT 1
VENDOR_EXTENSION "0x4c 0x49 0x4e 0x55 0x58 0x20 0x5a 0x46 0x54 0x00 0x00 0x28 0x
00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00"
PASSWORD "0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00"
DIRECTORY_SIZE 0
DATA_SIZE 37672960
OS_VERSION 0x0000
SOURCE_DRIVE
DEVICE 0x00
RESERVED_1 0x00
COMPRESSION_FLAGS 0x3f
FORMAT 0x00
RESERVED_2 0x00
RESERVED_3 0x00
ENTRY END
VTBL END

In the latter case, the first line `VTBL START 2 54199' indicates the start of the volume table, the `2' means that the first data segment (and location of the volume table segment) is the third segment of the cartridge (segments are counted starting from 3), and that the last data segment has the number `54199'. Each volume table entry is surrounded by a `ENTRY NUM' - `ENTRY END' pair, where NUM specifies the number of the entry.

Library Function: void ftvt_print_one (const ftvt *VOLUME)

Print one volume table entry to stdout.

Arguments
const ftvt *VOLUMES

Pointer to the volume table entry to print


Return Value None.
Side effects None.
Diagnostics None.
Example

ftvt_print_one(volume);
Library Function: void ftvt_print_one_tagged (const ftvt *VOLUME)

Print one volume table entry in tagged output format (i.e. keyword-value pairs) to stdout.

Arguments
const ftvt *VOLUMES

Pointer to the volume table entry to print


Return Value None.
Side effects None.
Diagnostics None.
Example

ftvt_print_one_tagged(volume);
Library Function: int ftvt_parse_tagged (ftvt *VOLUMES)

Parse a volume table fed into stdin of the calling process. The stream must consist of certain keyword-value pairs as described in Vtblc Options, option `--modify=tagged'.

Arguments
const ftvt *VOLUMES

Pointer to the storage area for the input. Must consists of FTVT_MAX_VOLUMES entries. The function checks that no more than max_volumes entries are stored in volumes, where max_volumes is an internal variable initialised by ftvt_read() when reading in the volume table segment.


Return Value

-1 on error, the number of volumes otherwise.


Side effects

In case of an error an error string is generated and remembered. It can be retrieved by a call to ftvt_get_ctrl(). See Option Settings.


Diagnostics

The following error messages are generated by ftvt_parse_tagged(). ERROR is the return value of strerror(errno). See Error Messages (info file libc). Note that libftvt has native language support, so the actual message might differ from the messages below depending on your `locale' setting.

Corrupt volume input data: BUFFER

The input data doesn't obey the required format (see Vtblc Options, option `--modify=tagged').

BUFFER is the contents of the input buffer.


Too many volumes: NUM (MAXNUM max)

The input streams contains too many volume table entries. NUM is the number of entries processed so far, and MAXNUM is the value of the internal max_volumes variable which holds the number of entries which fit into the volume table segment.


Premature end of volume table

The volume table descriptions didn't end with `VTBL END'.


Example
if ((num_volumes = ftvt_parse_tagged(volumes)) == -1) {
        struct ftvt_ctrl *info = ftvt_get_ctrl();

        fprintf(stderr, "ftvt_parse_tagged() failed: %s\n", info->errstr);

        (void)ftvt_close(tapefd);
        exit(1);
}

ftape logo Use these buttons to jump to the top menu

TOP (previous node) TOP (parent node) TOP (next node) TOP (this node)