home *** CD-ROM | disk | FTP | other *** search
-
- Please delete this subdirectory.
-
- The code here is an ugly five- (okay, ten-) minute hack I wrote to strip
- corrupted __.SYMDEF headers from ar archives. It assumes an old-style
- ar file header which I got from a SysV man page and the ar(1) man page with
- Markus Wild's gcc 2.3.3 distribution says it doesn't use any more. But
- I dunno, it works.
-
- Here is the source, and the executable, compiled with Manx Aztec C 5.2.
- It takes the names of a bunch of .a files on the command line (sorry, no
- pattern matching provided!), renames them to .a.bak, and copes a "clean"
- version to the original .a filename. It does *not* delete the .a.bak
- file, as an added safety precaution. It quits on encountering any error.
-
- The code is totally uncommented, but pretty darn straightforward.
- It goes through the argv array, moving the files around then opening
- them, then calls unranlib(in,out) on the file handles.
-
- unranlib() checks the input for the ar magic cookie, then a __.SYMDEF
- header. If it sees this, it goes into a loop searching for the next
- file header, since the __.SYMDEF's size is corrupted. When it encounters
- two characters that look like a magic file flag ("`\n"), it validates the
- preceding file header to see if it looks like it should, with all fields
- in ASCII (mostly decimal numbers, but mode in octal), padded at the end
- with spaces. If it fails the test, it keeps looking.
-
- When it finally gets a header, it copies out the ar magic cookie,
- then the just-input file headewr, then copies the rest of the input
- file to the output in 512-byte chunks.
-
- Wasn't that exciting? If you run ranlib on the result, you get the
- files that are included in the rest of this archive.
-
- Oh, yes: no copyright is claimed on this code. It's in the public domain,
- free to use or abuse.
- --
- -Colin (colin@nyx.cs.du.edu)
-