BOOL fndtag(buffer,tag_number,offset)
ADB *buffer ;
short tag_number ;
unsigned short *offset ;
Fndtag searches the ADB directory for the tag specified in tag_number.
buffer
ADB
tag_number
tag to find
true if the tag is found, false otherwise. If the tag is found the directory entry containing it is located offset bytes from the beginning of the ADB. Offset is is undefined if the tag was not found.
BOOL fndtag(buffer,tag_number,offset) Loop WHILE the tag number in the current directory entry is NOT LAST_TAG or EXTEND_DIR_TAG DO IF the entry for tag_number has been found THEN set the offset return YES try the next directory entry IF the tag_number in the current entry is LAST_TAG THEN IF LAST_TAG was the tag_number to be found THEN set the offset return YES ELSE return NO IF the tag_number to be found is EXTEND_DIR_TAG THEN this must be it - set the offset - return YES get the next entry
/* FILE: FNDTAG.C */ #include #include "air.h" BOOLE fndtag(buffer,tag_number,offset) ADB *buffer ; short tag_number ; unsigned short *offset ; { DIR_ENTRY *entry ; unsigned char *char_entry, *char_buffer ; entry = (DIR_ENTRY *)buffer ; char_buffer = (unsigned char *)buffer ; while (YES) { while ( (entry->tag_number != LAST_TAG) && (entry->tag_number != EXTEND_DIR_TAG)) { if (entry->tag_number == tag_number) { char_entry = (unsigned char *)entry ; *offset = char_entry - char_buffer ; return(YES) ; } entry++ ; } if (entry->tag_number == LAST_TAG) if (tag_number == LAST_TAG) { char_entry = (unsigned char *)entry ; *offset = char_entry - char_buffer ; return(YES) ; } else { return(NO) ; } if (tag_number == EXTEND_DIR_TAG) { char_entry = (unsigned char *)entry ; *offset = char_entry - char_buffer ; return(YES) ; } entry = (DIR_ENTRY *)(char_buffer + entry->data_offset) ; } }