BOOL fulADB(buffer,length)
ADB *buffer ;
int length ;
The first bytes in are checked to see if they represent a complete ADB. The directory is scanned from the beginning to find the entry for LAST_TAG, and to see if the data_offset in that entry is in the buffer.
buffer
input ADB to check
length
number of valid bytes in buffer
The routine returns TRUE if the ADB is complete, FALSE otherwise.
current directory entry is at start of buffer. while the current directory entry is completely in the buffer if current entry is: EXTEND_DIR_TAG: set current directory entry to be start of next directory segment. LAST_TAG: if data_offset is in the buffer, return TRUE otherwise, return FALSE. otherwise: set current directory entry to next contiguous directory entry. return FALSE
/* FILE: FULADB.C */ #include #include "air.h" BOOLE fuladb(buffer,length) char *buffer ; /* pointer to a partial ADB (char * to allow byte arithmetic) */ int length ; /* length (in bytes) of valid data in buffer */ { DIR_ENTRY *entry ; entry = (DIR_ENTRY *)buffer ; /* point to first directory entry */ while (((int *)entry+1) <= ((int *)buffer+length) ) /*room for a directory entry */ { if (entry->data_offset > length) return(NO); switch (entry->tag_number) { case EXTEND_DIR_TAG: entry = (DIR_ENTRY *)(buffer + entry->data_offset) ; /* go to new directory segment */ break ; case LAST_TAG: return(YES); /* end of ADB is in buffer*/ default: ++entry ; /* move to next contiguous directory entry */ break ; } } return(NO) ; }