+ return AddToProcessingList(ptr, fname, 0);
+}
+
+//
+// Process an ar archive file (*.a)
+//
+int DoArchive(char * fname, int fd)
+{
+ // Read in the archive file to memory and process
+ long size = FileSize(fd);
+ char * ptr = malloc(size);
+ char * endPtr = ptr + size;
+
+ if (ptr == NULL)
+ {
+ printf("Out of memory while processing %s\n", fname);
+ close(fd);
+ return 1;
+ }
+
+ if (read(fd, ptr, size) != size)
+ {
+ printf("File read error on %s\n", fname);
+ close(fd);
+ free(ptr);
+ return 1;
+ }
+
+ close(fd);
+
+ // Save the pointer for later...
+ arPtr[arIndex++] = ptr;
+ char objName[17];
+ char objSize[11];
+ int i;
+
+ // Loop through all objects in the archive and process them
+ do
+ {
+ objName[16] = objSize[10] = 0;
+
+ for(i=0; i<16; i++)
+ {
+ if (ptr[i] == '/')
+ {
+ objName[i] = 0;
+ break;
+ }
+
+ objName[i] = ptr[i];
+ }
+
+ for(i=0; i<10; i++)
+ {
+ if (ptr[48 + i] == ' ')
+ {
+ objSize[i] = 0;
+ break;
+ }
+
+ objSize[i] = ptr[48 + i];
+ }
+
+ if (objName[0] != 0)
+ {
+ strcpy(obj_fname[obj_index], objName);
+ obj_segsize[obj_index][0] = (getlong(ptr + 60 + 4) + secalign) & ~secalign;
+ obj_segsize[obj_index][1] = (getlong(ptr + 60 + 8) + secalign) & ~secalign;
+ obj_segsize[obj_index][2] = (getlong(ptr + 60 + 12) + secalign) & ~secalign;
+ obj_index++;
+
+ if (AddToProcessingList(ptr + 60, objName, 1))
+ return 1;
+ }
+
+ uint32_t size = atoi(objSize);
+ size += (size & 0x01 ? 1 : 0);
+ ptr += 60 + size;
+ }
+ while (ptr < endPtr);
+
+ return 0;