cread Function (ROM Call 0x137)

cert.h

short cread (CFILE *context, CERT_FIELD *dest);

Reads a field from a context.

Certificate files in TIOS (which packages up all the data required to perform authentification) are well-organized as files of variable-length records called "fields". So, the different components are split up into various fields, which can be accessed fairly easily. Each field begins with ID word. High 12 bits of ID are used as field ID number, and lower 4 bits are used to encode size of the field (as the length of the field can be a variable size). If these bits are smaller or equal to 0xC, this value is just the length of the field. If these bits are 0xD, 0xE or 0xF, then the following byte, word or doubleword contains the actual length of the field. Fields in the file are stored sequentially. They may contain various data, including other fields (i.e. "subfields"), which are usually opened with copensub.

cread reads a field from the file associated with the file context pointed to by context and collects necessary information (field ID number, length of the field, and the pointer to the actual content of the field) into the CERT_FIELD structure pointed to by dest. It also moves the field pointer to the next field, and sets the EOF indicator in the context if the end of the file is reached. cread returns TRUE if the operation was successful, otherwise it returns FALSE (this usually means end-of-file error).


Uses: ceof, cgetflen, cgetns
Used by: cfindfield, ROM Call 0x3D2, ROM Call 0x44B, ROM Call 0x477, ROM Call 0x4F3