- off_t lastOffset=0, thisOffset=0;
- char arVersion[8];
- rawArHeader_t rawArHeader;
-
- lseek(srcFd, 0, SEEK_SET);
- if (fullRead(srcFd, arVersion, 8) <= 0) {
- errorMsg("Invalid header magic\n");
- return (FALSE);
- }
- if (strncmp(arVersion,"!<arch>",7) != 0) {
- errorMsg("This doesnt appear to be an ar archive\n");
- return(FALSE);
- }
- while (fullRead(srcFd, (char *) &rawArHeader, 60) == 60) {
- if ( (rawArHeader.fmag[0] == '`') &&
- (rawArHeader.fmag[1] == '\n')) {
- sscanf(rawArHeader.name, "%s", current->name);
- parse_mode(rawArHeader.mode, ¤t->mode);
- current->mtime = atoi(rawArHeader.date);
- current->uid = atoi(rawArHeader.uid);
- current->gid = atoi(rawArHeader.gid);
- current->size = (size_t) atoi(rawArHeader.size);
- current->offset = lseek(srcFd, 0 , SEEK_CUR);
- current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
- lastOffset = lseek(srcFd, (off_t) current->size, SEEK_CUR);
- current = current->next;
- }
- else { /* GNU ar has an extra char after data */
- thisOffset=lseek(srcFd, 0, SEEK_CUR);
- if ( (thisOffset - lastOffset) > ((off_t) 61) )
- return(FALSE);
- lseek(srcFd, thisOffset - 59, SEEK_SET);
- }
- }
- return(FALSE);
-}