2 ** mwlib.h - POSIX 1003.2 "ar" command
6 ** This isn't a pure POSIX 1003.2 ar; it only manipulates Metrowerks
7 ** Library files, not general-purpose POSIX 1003.2 format archives.
9 ** Dec. 14, 1997 Chris Herborth (chrish@qnx.com)
11 ** This code is donated to the PUBLIC DOMAIN. You can use, abuse, modify,
12 ** redistribute, steal, or otherwise manipulate this code. No restrictions
13 ** at all. If you laugh at this code, you can't use it.
15 ** This "ar" was implemented using IEEE Std 1003.2-1992 as the basis for
16 ** the interface, and Metrowerk's published docs detailing their library
17 ** format. Look inside for clues about how reality differs from MW's
18 ** documentation on BeOS...
21 #include <support/SupportDefs.h>
24 /* ----------------------------------------------------------------------
28 #define MWLIB_MAGIC_WORD 'MWOB'
29 #define MWLIB_MAGIC_PROC 'PPC '
31 /* ----------------------------------------------------------------------
34 ** This is based on the "Metrowerks CodeWarrior Library Reference
35 ** Specification", which isn't 100% accurate for BeOS.
38 typedef struct MWLibHeader
{
50 typedef struct MWLibFile
{
59 typedef struct MWLib
{
69 /* This bears no resemblance to what's in the Metrowerks docs.
71 ** Note that this is incomplete; this is all the info I needed for
74 typedef struct MWObject
{
75 uint32 magic_word
; /* 'MWOB' */
76 uint32 arch
; /* 'PPC '; this isn't in the docs */
84 /* ----------------------------------------------------------------------
85 ** Function prototypes
87 ** load_MW_lib() - load a Metrowerks library
91 ** B_FILE_NOT_FOUND - can't open the given file
92 ** B_IO_ERROR - can't read from the given file
93 ** B_BAD_VALUE - invalid magic word in the file
94 ** B_MISMATCHED_VALUES - invalid processor value (ie, not a PowerPC lib),
95 ** or the magicflags member is not 0, or the file
96 ** version number isn't 1.
97 ** B_NO_MEMORY - unable to allocate memory while loading the lib
99 ** write_MW_lib() - write a Metrowerks library
102 ** B_OK - all is well
104 ** write_MW_lib() - write a Metrowerks library file
107 ** B_OK - all is well; doesn't necessarily mean the file was written
108 ** properly, just that you didn't lose any data
109 ** B_NO_MEMORY - unable to allocate offset buffers
110 ** B_ERROR - problem with backup file (can't rename existing file)
113 ** If you use this in a long-lived program, it leaks memory; the MWLib
114 ** contents are never free()'d.
116 status_t
load_MW_lib( MWLib
*lib
, const char *filename
);
117 status_t
write_MW_lib( MWLib
*lib
, const char *filename
);
118 void setfiletype( const char *filename
, const char *type
);