BuildKey Perform key segment translation from record buffer to target key. Short Name frmkey() Type Low level index file function Declaration COUNT frmkey(COUNT keyno, pTEXT recptr, pTEXT txt, ctRECPT pntr, VRLEN datlen) Description BuildKey() extracts a key value for index number keyno from the data record image of datlen bytes pointed to by recptr. The key value is assembled at the location pointed to by txt. If the index supports duplicate key values, then the 4-byte value given by pntr is appended to the end of the key value in most significant to least significant byte order. BuildKey() uses the information in the Incremental ISAM structure, or ISAM parameter file, to extract the key, concatenating key segments after they have been transformed according to the segment mode parameter. BuildKey() may be called directly from an application program in a situation where a target key value can be created according to the ISAM specifications, but TransformKey() is not convenient. Consider the following example in which the key value is made up of two segments:
In an 80X86 environment, the 4-byte id field will be automatically reversed using a segment mode value of 1 (INTSEG - unsigned integer). The value of pntr is only used when an index supports duplicate entries. CurrentFileOffset() can be used to determine the current file offset. In most cases, pass a long zero (0L) for this parameter. Use 0xffffffff for pntr before a call to GetLTERecord() for an index supporting duplicates. Return BuildKey() returns the length of the key value assembled or a zero if the key is composed entirely of the empty character, as defined in the parameter file. See “c-tree Plus Error Codes” in the c-tree Plus Programmer’s Reference Guide for a complete listing of valid c-tree Plus error values. Example COUNT keyno,i; struct {
COUNT delflg[4]; TEXT name[24]; LONG id; TEXT desc[128]; } cur_info, /* current ISAM buffer */ upd_info, /* rewrite update buffer */ tar_info; /* target key staging area */
scanf("%24s",tar_info.name); /* load name field */
tar_info.name[i] = PADDING;
scanf("%ld",&tar_info.id); /* load id */
frmkey(keyno, &tar_info,target,0L,sizeof(tar_info));
and places the result in target. Now search isam files. */ GetRecord(keyno,target,&cur_info); Limitations The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSetHgh() and ctGetHgh() functions to set or get the high order 4 bytes of the file offset. See also CurrentFileOffset(), GetLTERecord(), TransformKey() |
|||