diff --git a/BeOS/PyImport_BeImageID.html b/BeOS/PyImport_BeImageID.html new file mode 100644 index 00000000000..2d045281c67 --- /dev/null +++ b/BeOS/PyImport_BeImageID.html @@ -0,0 +1,47 @@ + +
+PyImport_BeImageID()
function defined in
+ Python/importdl.c; it should be merged with the
+ Importing Modules section of the Python/C API
+ reference (or it should be the first member of a BeOS-specific
+ document in the BeOS directory).image_id PyImport_BeImageID( char *name )
+
+PyImport_BeImageID()
will return B_ERROR
,
+ otherwise it will return a valid image_id
.
+
+ Using PyImport_BeImageID()
outside of a BeOS-specific
+ module is probably a very bad idea.
Function added by Donn Cave +(donn@u.washington.edu), +documented by Chris Herborth +(chrish@qnx.com).
+ + + diff --git a/BeOS/README b/BeOS/README new file mode 100644 index 00000000000..c801afb2269 --- /dev/null +++ b/BeOS/README @@ -0,0 +1,140 @@ +Python 1.5.1 for BeOS + +This directory contains several useful things to help you build your own +version of Python for BeOS. + +At this time, Python only supports BeOS on the PowerPC platform; if you'd +like to help me port it to the x86 platform, please let me know (I only +have limited access to BeOS on an x86 system). If you'd like to lend +me an x86 laptop running BeOS to do the port, _definitely_ let me know! :-) +I'll even give it back when I'm done. + +What's Here? + +ar-1.1 - An "ar" command with a POSIX 1003.2 interface; you'll need + this for building the Python libraries under BeOS + (/bin/ar just won't cut it). + +linkcc - A shell script used by the build process to build the Python + shared library. + +linkmodule - A shell script used by the build process to build the + shared library versions of the standard modules; you'll + probably need this if you want to build dynamically loaded + modules from the Python archives. + +PyImport_BeImageID.html - Documentation for a function added to the + Python interpreter under BeOS; not interesting + unless you're writing your own BeOS-specific + modules for dealing with dynamically-loaded + Python modules. + +README - This file (obviously!). + +README.readline-2.2 - Instructions for compiling/installing GNU readline 2.2. + You'll have to grab the GNU readline source code from + prep.ai.mit.edu:/pub/GNU or any other GNU mirror. + + The Python interpreter is much nicer to work with + interactively if you've got readline installed. Highly + recommended. + +Compiling Your Own Version + +To compile your own version of Python 1.5.1 for BeOS (with any luck, +Python 1.6 will compile "out of the box" on BeOS), try this: + +1) Get the Python 1.5.1 source code from ftp.python.org. + +2) Get the Python 1.5.1 diffs from my web pages + (http://www.qnx.com/~chrish/Be/software/); if you can't get them through + a web browser, send me email and I'll mail them back to you. These + diffs should also be available at ftp.python.org along with the BeOS + binary archive. + + Run autoconf. If you don't have autoconf, you can get a precompiled + version from GeekGadgets (ftp://ftp.ninemoons.com/pub/geekgadgets/...). + +3) Compile and install the POSIX ar from the ar-1.1 directory; see the + README in there for details. + +4) Configure with: + + AR=ar-posix RANLIB=: ./configure --verbose --without-gcc \ + --prefix=/boot/home/config --with-thread + + The only strange thing that happens during the configure is that + we fail the "genuine getopt()" test; this is odd because we've got + a real live GNU getopt() in the system libs. Other packages built + using configure (such as all of the goodies in GeekGadgets) suffer + the same fate though, so it's not a Python problem. + +5) Copy Modules/Setup.in to Modules/Setup. + +6) Edit Modules/Setup to turn on all the modules you want built. I've + personally built the following modules: + + array, audioop, binascii, cPickle, cStringIO, cmath, crypt, curses, + errno, fcntl, gdbm, grp, imageop, math, md5, new, operator, parser, + pcre, posix, pwd, readline, regex, reop, rgbimg, rotor, select, + signal, socket, soundex, strop, struct, syslog, termios, thread, + time, timing, zlib + + Newly compiled/tested with 1.5.1: + + _locale + + You can get precompiled gdbm, ncurses, and zlib libraries from the + GeekGadgets repository (ftp://ftp.ninemoons.com/pub/geekgadgets/...). + + Make sure you use _socket instead of socket for the name of the + socketmodule on BeOS. + +7) Make: + + make + + or, if you feel the need for speed: + + make OPT="-O7 -opt schedule604" + + You can safely ignore any warnings you see during the build (and you'll + see several if you use full warnings; I compiled the distribution with + -w9 -ansi strict and cleaned up any errors...). + +8) Test: + + make test + + Expect the following errors: + + test_builtin failed -- round(1000000000.0) + test_fcntl skipped -- an optional feature could not be imported + test_grp crashed -- exceptions.KeyError : getgrnam(): name not found + test_pwd failed -- Writing: 'fakename', expected: 'caught e' + test_socket crashed -- exceptions.AttributeError : SOCK_RAW + + These are all due to either partial support for certain things (like + sockets), or valid differences between systems (like the round() + error; different CPUs represent floating point numbers differently, + which can cause minor rounding errors). + +9) Install: + + make install + +10) Enjoy! + +NOTE + +If you're going to build your own C/C++-based Python modules, link them +against the libpython1.5.so shared library (in /boot/home/config/lib) +instead of the libpython1.5.a (in /boot/home/config/lib/python1.5/config), +unless you're building a statically-linked python interpreter (then you +could try linking against _APP_ instead). + +Mixing modules linked against the shared library with a statically-linked +interpreter is a bad idea (and it'll fail in _interesting_ ways). + +- Chris Herborth (chrish@qnx.com) + April 25, 1998 diff --git a/BeOS/README.readline-2.2 b/BeOS/README.readline-2.2 new file mode 100644 index 00000000000..db53ac9f98d --- /dev/null +++ b/BeOS/README.readline-2.2 @@ -0,0 +1,56 @@ +GNU readline 2.2 for BeOS + +You can get the original GNU readline 2.2 source code from your favourite +GNU software repository, such as ftp://prep.ai.mit.edu/pub/gnu/. + +You can get the only-slightly-modified-for-BeOS version of GNU readline 2.2 +from the GeekGadgets repository; ftp://ftp.ninemoons.com/pub/geekgadgets/. + +BUILDING libreadline for BeOS hosts +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Note that we don't build a shared library version of libreadline and +libhistory. That's left as an exercise for the reader. + +You won't be able to link against libreadline.a using the limited linker. + +1) If you're on a PowerPC system, install the POSIX ar from + http://www.qnx.com/~chrish/Be/software/index.html#programming + (note that it's currently packaged with Python, in the BeOS/ar-1.1 + directory). + + If you're on an x86 system, you can leave out the "AR=ar-posix" part + of the following instructions. In fact, you'll have to... + +2) For PowerPC, configure with: + + CC=mwcc CFLAGS="-O7 -i- -I." AR=ar-posix RANLIB=: ./configure --verbose \ + --without-gcc --prefix=/boot/home/config powerpc-*-beos + + For x86, configure with: + + CC=mwcc CFLAGS="-O2 -i- -I." RANLIB=: ./configure --verbose \ + --without-gcc --prefix=/boot/home/config x86-*-beos + + Don't worry about the warnings/errors configure spews for + powerpc-*-beos or x86-*-beos; readline doesn't actually use this host + information for anything, although configure will die if you don't + specify it. + +3) Edit config.h to comment out "#define HAVE_SELECT 1"; select() on + BeOS doesn't work on file descriptors (such as stdin). + +4) For PowerPC, make with: + + make AR=ar-posix + + For x86, make with: + + make + +5) Install with: + + make install + +- Chris Herborth (chrish@qnx.com) + April 21, 1998 diff --git a/BeOS/ar-1.1/Makefile b/BeOS/ar-1.1/Makefile new file mode 100644 index 00000000000..8fb11ec023d --- /dev/null +++ b/BeOS/ar-1.1/Makefile @@ -0,0 +1,48 @@ +###################################################################### +# Makefile for ar +# +# Dec. 14, 1997 Chris Herborth (chrish@kagi.com) +# +# $Id$ +###################################################################### + +AR_VERSION=1.1 + +# Make variables +CC=mwcc +LD=mwcc + +CFLAGS=-w9 -rostr -O3 -g +CFLAGS_O=-w9 -rostr -O7 -opt schedule604 +LDFLAGS=-g -map ar.xMAP +LDFLAGS_O= + +INSTALL=install -m 755 + +DESTINATION=/boot/home/config/bin + +PARTS=main.o mwlib.o commands.o copy_attrs.o + +all: ar + +nodebug: + -rm -f ar $(PARTS) ar.dbg ar.xSYM + $(MAKE) CFLAGS="$(CFLAGS_O) -DNO_DEBUG" LDFLAGS="$(LDFLAGS_O)" ar + +ar: $(PARTS) + $(LD) $(LDFLAGS) -o $@ $(PARTS) + +install: ar + $(INSTALL) ar $(DESTINATION) + ln -sf $(DESTINATION)/ar $(DESTINATION)/ar-posix + +clean: + -rm -f $(PARTS) ar ar.dbg ar.xSYM + +zip: + (cd .. ; zip -9ry ar-$(AR_VERSION).zip ar-$(AR_VERSION) \ + -x ar-$(AR_VERSION)/RCS -x ar-$(AR_VERSION)/docs/RCS \ + -x ar-$(AR_VERSION)/RCS/\* -x ar-$(AR_VERSION)/docs/RCS/\*) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ diff --git a/BeOS/ar-1.1/README.html b/BeOS/ar-1.1/README.html new file mode 100644 index 00000000000..607c03a08bf --- /dev/null +++ b/BeOS/ar-1.1/README.html @@ -0,0 +1 @@ +docs/ar.html \ No newline at end of file diff --git a/BeOS/ar-1.1/README.txt b/BeOS/ar-1.1/README.txt new file mode 100644 index 00000000000..f9957896298 --- /dev/null +++ b/BeOS/ar-1.1/README.txt @@ -0,0 +1,29 @@ +ar - POSIX 1003.2 interface to library files + +Here's the source and PowerPC binary for a POSIX 1003.2 interface "ar" +command; this is extremely useful when you're porting complex UNIX/POSIX +software to BeOS for PowerPC (I originally wrote it to support my Python +port). + +To build/install ar, do this in a Terminal: + +make nodebug install + +This will create ar and ar-posix (a symlink to ar) in ~/config/bin. The +ar-posix symlink is to make things a little easier if you happen to +have GeekGadgets (see www.ninemoons.com) installed; it comes with an +ar that only works on objects/libraries produced by GNU C for BeOS. + +To use the POSIX ar with your port, do something like this: + +AR=ar-posix ./configure ... normal configure arguments ... + +and then: + +make AR=ar-posix + +You may need to check the Makefiles; people seem to be quite sloppy about +using just plain "ar cr libfoo.a ..." instead of "$(AR) cr libfoo.a ...". + +- Chris Herborth, April 18, 1998 + (chrish@kagi.com) diff --git a/BeOS/ar-1.1/ar b/BeOS/ar-1.1/ar new file mode 100644 index 00000000000..e44e2dc4c22 Binary files /dev/null and b/BeOS/ar-1.1/ar differ diff --git a/BeOS/ar-1.1/ar.xMAP b/BeOS/ar-1.1/ar.xMAP new file mode 100644 index 00000000000..bee438db502 --- /dev/null +++ b/BeOS/ar-1.1/ar.xMAP @@ -0,0 +1,461 @@ +File: 0 "/boot/src/ar-1.0/main.c" +File: 1 "/boot/src/ar-1.0/mwlib.c" +File: 2 "/boot/src/ar-1.0/commands.c" +File: 3 "/boot/src/ar-1.0/copy_attrs.c" +File: 5 "/boot/rel/src/kit/glue/common/global_destructor_chain.c" +File: 6 "/boot/rel/src/kit/glue/ppc/runtime.c" +File: 9 "/boot/rel/src/kit/glue/common/init_term_dyn.c" +File: 10 "/boot/rel/src/kit/glue/common/start_dyn.c" +File: 11 "/boot/develop/lib/ppc/libroot.so" + +Files that were not referenced: +"libbe.so" +"libtracker.so" +"libmedia.so" +"libnet.so" +"libnetdev.so" +"libdevice.so" +"libmidi.so" +"libgame.so" +"libatalk.so" +"libmail.so" + +Code section, size = 16672 bytes +000000 PR .__sinit file = "*Linker-Generated*" +00001C PR .usage file = "main.c" +000050 PR .version +000094 PR .check_command +000128 PR .main +0005A0 PR .load_MW_lib file = "mwlib.c" +000A1C PR .load_MWLibFile +000BAC PR .fwrite_big32 +000C10 PR .fwrite_big32_seek +000CA4 PR .add_object_sizes +000DA4 PR .setfiletype +000EA8 PR .write_MW_lib +001850 PR .do_match file = "commands.c" +001958 PR .do_delete +001A84 PR .delete_lib_entry +001C5C PR .do_print +001D98 PR .print_lib_entry +001E90 PR .load_lib_file +0020F4 PR .do_replace +0023B8 PR .add_lib_entry +00256C PR .replace_lib_entry +00272C PR .do_table +002868 PR .table_lib_entry +0029E8 PR .do_extract +002B24 PR .extract_lib_entry +002E20 PR .copy_attrs file = "copy_attrs.c" +00306C PR .__destroy_global_chain file = "global_destructor_chain.c" +0030C0 PR .__RTOC file = "init_term_dyn.c" +0030C8 PR ._init_routine_ +003118 PR ._term_routine_ +003148 PR .__start file = "start_dyn.c" +003204 GL .__register_fragment file = "*Linker-Generated*" +00321C GL .find_thread +003234 GL .memcpy +00324C GL ._call_init_routines_ +003264 GL .printf +00327C GL .exit +003294 GL .getopt +0032AC GL .malloc +0032C4 GL .__assertion_failed +0032DC GL .fprintf +0032F4 GL .fopen +00330C GL .fread +003324 GL .fseek +00333C GL .fgets +003354 GL .strdup +00336C GL .fclose +003384 GL .strrchr +00339C GL .strcmp +0033B4 GL .free +0033CC GL .memset +0033E4 GL .access +0033FC GL .stat +003414 GL ._errnop +00342C GL .strerror +003444 GL .strlen +00345C GL .sprintf +003474 GL .unlink +00348C GL .rename +0034A4 GL .fwrite +0034BC GL .ftell +0034D4 GL .chmod +0034EC GL .open +003504 GL .close +00351C GL .fs_fopen_attr_dir +003534 GL .fs_read_attr_dir +00354C GL .fs_stat_attr +003564 GL .fs_read_attr +00357C GL .fs_write_attr +003594 GL .fflush +0035AC GL .realloc +0035C4 GL .localtime +0035DC GL .strftime +0035F4 GL .getgid +00360C GL .getuid +003624 GL .utime +00363C GL ._thread_do_exit_notification +003654 GL .__unregister_fragment +00366C GL .__ptr_glue file = "runtime.c" +003680 RO @10 file = "main.c" +003690 RO @13 +0036B4 RO @16 +0036D8 RO @17 +0036FC RO @18 +003739 RO @30 +003769 RO @109 +00378A RO @110 +0037A2 RO @111 +0037BA RO @112 +0037D3 RO @113 +0037DD RO @114 +0037FD RO @115 +003815 RO @116 +003829 RO @117 +00383D RO @118 +003871 RO @119 +00388C RO @120 +0038A5 RO @121 +0038B9 RO @78 file = "mwlib.c" +0038C3 RO @79 +0038CB RO @80 +0038DA RO @81 +0038DC RO @98 +0038E7 RO @99 +0038F5 RO @104 +0038FE RO @122 +003908 RO @123 +003913 RO @124 +00391E RO @133 +003947 RO @134 +003951 RO @135 +00397B RO @235 +003980 RO @236 +0039AC RO @237 +0039C3 RO @238 +0039F5 RO @239 +0039F9 RO @240 +003A12 RO @241 +003A33 RO @242 +003A35 RO @243 +003A56 RO @244 +003A7B RO @245 +003AA7 RO @246 +003AD1 RO @247 +003AF0 RO @248 +003B14 RO @249 +003B3D RO @250 +003B69 RO @251 +003B90 RO @252 +003BBB RO @253 +003BD8 RO @254 +003BF1 RO @255 +003C11 RO @29 file = "commands.c" +003C1B RO @30 +003C26 RO @31 +003C31 RO @32 +003C3B RO @53 +003C4E RO @54 +003C65 RO @55 +003C7D RO @81 +003C9E RO @82 +003CA6 RO @120 +003CAE RO @121 +003CC5 RO @142 +003CD4 RO @143 +003CDF RO @144 +003CF6 RO @145 +003D0C RO @146 +003D2E RO @147 +003D30 RO @148 +003D47 RO @149 +003D5E RO @198 +003D6F RO @199 +003D89 RO @200 +003DAA RO @222 +003DCF RO @223 +003DE8 RO @224 +003E12 RO @225 +003E1A RO @242 +003E39 RO @243 +003E65 RO @244 +003E6D RO @284 +003E85 RO @285 +003E88 RO @286 +003E9F RO @287 +003EBE RO @288 +003EC9 RO @289 +003ECD RO @343 +003EE6 RO @344 +003EEE RO @345 +003EF0 RO @346 +003F11 RO @347 +003F27 RO @348 +003F53 RO @349 +003F7E RO @350 +003F97 RO @43 file = "copy_attrs.c" +003FA6 RO @44 +003FB3 RO @45 +003FC4 TI @14 file = "main.c" +003FD0 TI @19 +003FDC TI @32 +003FE8 TI @124 +003FF4 TI @82 file = "mwlib.c" +004000 TI @100 +00400C TI @105 +004018 TI @111 +004024 TI @125 +004030 TI @136 +00403C TI @256 +004048 TI @33 file = "commands.c" +004054 TI @56 +004060 TI @83 +00406C TI @110 +004078 TI @122 +004084 TI @150 +004090 TI @201 +00409C TI @226 +0040A8 TI @245 +0040B4 TI @272 +0040C0 TI @290 +0040CC TI @317 +0040D8 TI @351 +0040E4 TI @46 file = "copy_attrs.c" +0040F0 TI @7 file = "global_destructor_chain.c" +0040FC TI @2 file = "init_term_dyn.c" +004108 TI @4 +004114 TI @17 file = "start_dyn.c" + +Data section, size = 1084 bytes (TOC anchor = 000000) +000000 TC fs_write_attr file = "*Linker-Generated*" +000004 TC strftime +000008 TC fwrite +00000C TC sprintf +000010 TC open +000014 TC fread +000018 TC fs_fopen_attr_dir +00001C TC fseek +000020 TC strrchr +000024 TC free +000028 TC printf +00002C TC ftell +000030 TC exit +000034 TC strerror +000038 TC __register_fragment +00003C TC memcpy +000040 TC strcmp +000044 TC strlen +000048 TC _call_init_routines_ +00004C TC strdup +000050 TC _files +000054 TC fgets +000058 TC malloc +00005C TC find_thread +000060 TC close +000064 TC memset +000068 TC chmod +00006C TC fopen +000070 TC stat +000074 TC fs_read_attr +000078 TC access +00007C TC fs_read_attr_dir +000080 TC unlink +000084 TC getopt +000088 TC getgid +00008C TC __unregister_fragment +000090 TC _errnop +000094 TC fprintf +000098 TC optind +00009C TC __assertion_failed +0000A0 TC rename +0000A4 TC utime +0000A8 TC getuid +0000AC TC fs_stat_attr +0000B0 TC fflush +0000B4 TC _thread_do_exit_notification +0000B8 TC fclose +0000BC TC localtime +0000C0 TC realloc +0000C4 TC __global_destructor_chain +0000C8 TC __exception_table_end__ +0000CC TC __exception_table_start__ +0000D0 TC __data_end__ +0000D4 TC __data_start__ +0000D8 TC __code_end__ +0000DC TC __code_start__ +0000E0 TC __main_thread_id +0000E4 TC environ +0000E8 TC argv_save +0000EC TC @123 file = "main.c" +0000F0 TC @122 +0000F4 TC @121 +0000F8 TC @120 +0000FC TC @119 +000100 TC @118 +000104 TC @117 +000108 TC @116 +00010C TC @115 +000110 TC @114 +000114 TC @113 +000118 TC @112 +00011C TC @111 +000120 TC @110 +000124 TC @109 +000128 TC @31 +00012C TC @30 +000130 TC @18 +000134 TC @17 +000138 TC @16 +00013C TC @13 +000140 TC @255 file = "mwlib.c" +000144 TC @254 +000148 TC @253 +00014C TC @252 +000150 TC @251 +000154 TC @250 +000158 TC @249 +00015C TC @248 +000160 TC @247 +000164 TC @246 +000168 TC @245 +00016C TC @244 +000170 TC @243 +000174 TC @242 +000178 TC @241 +00017C TC @240 +000180 TC @239 +000184 TC @238 +000188 TC @237 +00018C TC @236 +000190 TC @235 +000194 TC @135 +000198 TC @134 +00019C TC @133 +0001A0 TC @124 +0001A4 TC @123 +0001A8 TC @122 +0001AC TC @104 +0001B0 TC @99 +0001B4 TC @98 +0001B8 TC @81 +0001BC TC @80 +0001C0 TC @79 +0001C4 TC @78 +0001C8 TC @350 file = "commands.c" +0001CC TC @349 +0001D0 TC @348 +0001D4 TC @347 +0001D8 TC @346 +0001DC TC @345 +0001E0 TC @344 +0001E4 TC @343 +0001E8 TC @289 +0001EC TC @288 +0001F0 TC @287 +0001F4 TC @286 +0001F8 TC @285 +0001FC TC @284 +000200 TC @244 +000204 TC @243 +000208 TC @242 +00020C TC @225 +000210 TC @224 +000214 TC @223 +000218 TC @222 +00021C TC @200 +000220 TC @199 +000224 TC @198 +000228 TC @149 +00022C TC @148 +000230 TC @147 +000234 TC @146 +000238 TC @145 +00023C TC @144 +000240 TC @143 +000244 TC @142 +000248 TC @121 +00024C TC @120 +000250 TC @82 +000254 TC @81 +000258 TC @55 +00025C TC @54 +000260 TC @53 +000264 TC @32 +000268 TC @31 +00026C TC @30 +000270 TC @29 +000274 TC @45 file = "copy_attrs.c" +000278 TC @44 +00027C TC @43 +000280 TC magic_template file = "start_dyn.c" +000284 TC default_environ +000288 TD ar_version_id file = "main.c" +00028C TD fragmentID file = "init_term_dyn.c" +000290 DS _term_routine_ file = "init_term_dyn.c" +000298 DS _init_routine_ +0002A0 DS __start file = "start_dyn.c" +0002A8 RW @31 file = "main.c" +0002FC RW @123 +000388 RW @122 +000414 RW magic_template file = "start_dyn.c" +00041C RW @13 +00042C RW default_environ +000434 RW __global_destructor_chain file = "global_destructor_chain.c" + +Import container "libroot.so" +Current Version = 00000000, Old Implementation = 00000000 +000000 DS fs_write_attr +000001 DS strftime +000002 DS fwrite +000003 DS sprintf +000004 DS open +000005 DS fread +000006 DS fs_fopen_attr_dir +000007 DS fseek +000008 DS strrchr +000009 DS free +00000A RW environ +00000B DS printf +00000C DS ftell +00000D DS exit +00000E DS strerror +00000F DS __register_fragment +000010 DS memcpy +000011 DS strcmp +000012 DS strlen +000013 DS _call_init_routines_ +000014 DS strdup +000015 RW argv_save +000016 RW _files +000017 DS fgets +000018 DS malloc +000019 DS find_thread +00001A DS close +00001B DS memset +00001C DS chmod +00001D DS fopen +00001E DS stat +00001F DS fs_read_attr +000020 DS access +000021 DS fs_read_attr_dir +000022 DS unlink +000023 DS getopt +000024 DS getgid +000025 DS __unregister_fragment +000026 DS _errnop +000027 DS fprintf +000028 RW optind +000029 DS __assertion_failed +00002A DS rename +00002B DS utime +00002C RW __main_thread_id +00002D DS getuid +00002E DS fs_stat_attr +00002F DS fflush +000030 DS _thread_do_exit_notification +000031 DS fclose +000032 DS localtime +000033 DS realloc diff --git a/BeOS/ar-1.1/commands.c b/BeOS/ar-1.1/commands.c new file mode 100644 index 00000000000..f9304d064fd --- /dev/null +++ b/BeOS/ar-1.1/commands.c @@ -0,0 +1,809 @@ +/* +** commands.c - POSIX 1003.2 "ar" command +** +** This isn't a pure POSIX 1003.2 ar; it only manipulates Metrowerks +** Library files, not general-purpose POSIX 1003.2 format archives. +** +** Dec. 14, 1997 Chris Herborth (chrish@kagi.com) +** +** This code is donated to the PUBLIC DOMAIN. You can use, abuse, modify, +** redistribute, steal, or otherwise manipulate this code. No restrictions +** at all. If you laugh at this code, you can't use it. +** +** This "ar" was implemented using IEEE Std 1003.2-1992 as the basis for +** the interface, and Metrowerk's published docs detailing their library +** format. Look inside for clues about how reality differs from MW's +** documentation on BeOS... +*/ + +#include+ar [-][dprtx][cuv] archive [file ...] ++ +
- | ++ The - is optional for introducing ar command-line + arguments; this is a POSIX requirement, and I've never seen anyone + use it. | +
c | ++ Don't print a diagnostic message to stderr when + archive is created. | +
d | ++ Delete file(s) from archive. | +
p | ++ Write the contents of the named file(s) to stdout. + If no file(s) are specified, all of the files in + archive are written in the order of the archive. | +
r | ++ Replace or add file(s) to the archive. This will + create archive if it doesn't already exist. | +
t | ++ Write the table of contents of archive to stdout. + If not file(s) are specified, list all of the files, + otherwise only list the specified files. | +
u | ++ Update older files. When used with the r option, files + within the archive are only replaced if file has a + modification date at least as new as the file already in + the archive. | +
v | +Give verbose output. | +
x | ++ Extract file(s) from the archive. If no + file(s) are specified, all of the files in archive + are extracted. | +
archive | ++ The pathname of an archive file. | +
file | ++ One more more pathnames of object files; only the file name is + used when comparing against the names of files in the + archive. | +
The ar utility creates and maintains groups of files +combined into a library. Once a library has been created, you can +add new files, and extract, delete, or replace existing files.
+ +ar exits with one of the following values:
+ +0 | +Successful completion. |
> 0 | +An error occurred. |
No known bugs, but please read the comments in the code if +you want to use it in another application.
+ +This is a POSIX 1003.2-1992 based ar command; it's not +100% POSIX 1003.2 because POSIX specifies a file format for +ar archives. The BeOS ar produces library files +compatible (at least in theory :-)) with Metrowerks +CodeWarrior for PowerPC.
+ +This ar and its source code were written as a service to +the Be developer community, to make it easier for us to port UNIX +applications and libraries. The code was written from scratch, after +reverse-engineering the Metrowerks library and object file format +(mostly because the library/object file format documentation was +incorrect).
+ +If you find this useful, please +let me know, and tell me what +you're working on. Be sure to include a URL for your homepage or your +product homepages for my +Be Community +pages.
+ +If you find any bugs, please try to fix them, and send me a context +diff (use diff -c original_file fixed_file) so I can include +your fixes in the next update. I have tested this, but these +things have a way of slipping though.
+ +If you'd like to know what other things I'm working on, take a look +at my Be +Software pages, and my +Be Happy! pages.
+ +This program binary and its source code have been donated to the +BeOS Developer Community by Arcane Dragon Software free of charge. +You can do whatever you want with it.
+ +If you really want to show your appreciation, you could +always send me a gift of some sort; cool software you wrote, nice +pictures for my desktop, ZIP drive disks, RAM, hard drives, post +cards, a pointer to a really cool/useful/interesting web site, +an MPEG audio file of an interesting band (make sure you can give me +enough information to track down their CDs if I like it!), etc. +Send me some email and I'll let you +know where to send it.
+ +But you don't have to do anything. Just write good BeOS software. +But you're already doing that, right?
+ +You use this at your own risk. I've tried to ensure that the code +is correct, but software usually has bugs. If ar destroys +your valuable data, formats your hard drive, kicks your cat, and lets +the air out of your tires, I'm not responsible for it. The code is +here, so you should feel fairly safe that there's nothing evil going +on.
+ +And, as I learned once again in December 1997, you really should +keep backups of everything. I only lost a day's work, but it was +still annoying, and it could've been much, much worse.
+ +This code isn't meant to be the ultimate in efficiency or speed, +it's intended to be fairly easy to understand and maintain +(hopefully). I was also quite keen on having something that was +correct, without jumping through a lot of unnecessary hoops.
+ +If you think this code sucks, don't use it. You're already applying +this to your choice of operating system! :-)
+ +Chris Herborth (chrish@qnx.com)
+ +Last modified: $Date$ + + diff --git a/BeOS/ar-1.1/docs/dumpar.py b/BeOS/ar-1.1/docs/dumpar.py new file mode 100644 index 00000000000..93e2283a230 --- /dev/null +++ b/BeOS/ar-1.1/docs/dumpar.py @@ -0,0 +1,271 @@ +#! /bin/env python +""" Dump data about a Metrowerks archive file. + +$Id$ + +Based on reverse-engineering the library file format. + +Copyright (C) 1997 Chris Herborth (chrish@qnx.com) +""" + +# ---------------------------------------------------------------------- +# Standard modules +import sys +import getopt +import string +import time + +# ---------------------------------------------------------------------- +def usage(): + """ Display a usage message and exit. + """ + print "dumpar [-v] library1 [library2 ... libraryn]" + print + print "Attempt to display some useful information about the contents" + print "of the given Metrowerks library file(s)." + print + print "-v Be verbose (displays offsets along with the data)" + raise SystemExit + +# ---------------------------------------------------------------------- +def mk_long( str ): + """ convert a 4-byte string into a number + + Assumes big-endian! + """ + if len( str ) < 4: + raise ValueError, "str must be 4 bytes long" + + num = ord( str[3] ) + num = num + ord( str[2] ) * 0x100 + num = num + ord( str[1] ) * 0x10000 + num = num + ord( str[0] ) * 0x1000000 + + return num + +# ---------------------------------------------------------------------- +def str2hex( str ): + """ convert a string into a string of hex numbers + """ + ret = [] + for c in str: + h = hex( ord( c ) ) + ret.append( string.zfill( "%s" % ( h[2:] ), 2 ) ) + + return string.join( ret ) + +# ---------------------------------------------------------------------- +def print_offset( offset ): + """ print the offset nicely + """ + + # Turn the offset into a hex number and strip off the leading "0x". + val = "%s" % ( hex( offset ) ) + val = val[2:] + + out = "0x" + string.zfill( val, 8 ) + + print out, + +# ---------------------------------------------------------------------- +def get_string( data ): + """ dig a C string out of a data stream + + returns the string + """ + len = 0 + while data[len] != '\0': + len = len + 1 + + return data[:len] + +# ---------------------------------------------------------------------- +def dump_lib( file, verbose ): + """ dump information about a Metrowerks library file + """ + offset = 0 + + print "Dumping library:", file + + # Attempt to read the data. + try: + data = open( file ).read() + except IOError, retval: + print "*** Unable to open file %s: %s" % ( file, retval[1] ) + return + + # Check the magic number. + if verbose: + print_offset( offset ) + print "Magic:", + magic = data[offset:offset + 8] + print "'%s'" % ( magic ) + if magic != "MWOBPPC ": + print "*** Invalid magic number!" + return + + offset = offset + 8 + + # File flags + if verbose: + print_offset( offset ) + print "file flags:", + print mk_long( data[offset:offset + 4] ) + offset = offset + 4 + + if verbose: + print_offset( offset ) + print "file version:", + print mk_long( data[offset:offset + 4] ) + offset = offset + 4 + + # code size + if verbose: + print_offset( offset ) + print "code size:", mk_long( data[offset:offset + 4] ) + offset = offset + 4 + + # data size + if verbose: + print_offset( offset ) + print "data size:", mk_long( data[offset:offset + 4] ) + offset = offset + 4 + + # number of objects + if verbose: + print_offset( offset ) + print "number of objects:", + num_objs = mk_long( data[offset:offset + 4] ) + print num_objs + + offset = offset + 4 + + print + + # Now loop through the objects. + obj_sizes = [ 0, ] * num_objs + obj_data_offsets = [ 0, ] * num_objs + + for obj in range( num_objs ): + # Magic? + if verbose: + print_offset( offset ) + print "modification time:", + modtime = mk_long( data[offset:offset + 4] ) + print "[%s]" % ( ( time.localtime( modtime ), ) ) + + offset = offset + 4 + + # Offsets? + if verbose: + print_offset( offset ) + print "file name offset 1:", + file_offset1 = mk_long( data[offset:offset + 4] ) + unknown = "%s" % ( hex( file_offset1 ) ) + print "%s (%s)" % ( unknown, str2hex( data[offset:offset + 4] ) ) + + offset = offset + 4 + + if verbose: + print_offset( offset ) + print "file name offset 2:", + file_offset2 = mk_long( data[offset:offset + 4] ) + unknown = "%s" % ( hex( file_offset2 ) ) + print "%s (%s)" % ( unknown, str2hex( data[offset:offset + 4] ) ) + + offset = offset + 4 + + # Extra -1 for NUL character. + print " >>>> File name should be %s characters." % \ + ( file_offset2 - file_offset1 - 1) + + if verbose: + print_offset( offset ) + print "object data offset:", + file_data_offset = mk_long( data[offset:offset + 4] ) + unknown = "%s" % ( hex( file_data_offset ) ) + print "%s (%s)" % ( unknown, str2hex( data[offset:offset + 4] ) ) + + obj_data_offsets[obj] = file_data_offset + + offset = offset + 4 + + # object size + if verbose: + print_offset( offset ) + print "object size:", + obj_sizes[obj] = mk_long( data[offset:offset + 4] ) + print "%s bytes" % ( obj_sizes[obj] ) + + offset = offset + 4 + + print + + # Now loop through the object names. + for obj in range( num_objs ): + # First name + if verbose: + print_offset( offset ) + print "object", + print obj, + print "name 1:", + name1 = get_string( data[offset:] ) + print "[%s] %s chars" % ( name1, len( name1 ) ) + + offset = offset + len( name1 ) + 1 + + # Second name + if verbose: + print_offset( offset ) + print "object", + print obj, + print "name 2:", + name2 = get_string( data[offset:] ) + print "[%s] %s chars" % ( name2, len( name1 ) ) + + offset = offset + len( name2 ) + 1 + + # See if we've got a magic cookie in the object data + if verbose: + print_offset( obj_data_offsets[obj] ) + + cookie = data[obj_data_offsets[obj]:obj_data_offsets[obj] + 8] + print "object", + print obj, + print "cookie: '%s'" % ( cookie ) + + print + + # Now loop through the data and check for magic numbers there. + return + +# ---------------------------------------------------------------------- +def main(): + """ mainline + """ + + # Set up some defaults + be_verbose = 0 + + # First, check the command-line arguments + try: + opt, args = getopt.getopt( sys.argv[1:], "vh?" ) + except getopt.error: + print "*** Error parsing command-line options!" + usage() + + for o in opt: + if o[0] == "-h" or o[0] == "-?": + usage() + elif o[0] == "-v": + be_verbose = 1 + else: + print "*** Unknown command-line option!" + usage() + + # Now we can attempt to dump info about the arguments. + for lib in args: + dump_lib( lib, be_verbose ) + +if __name__ == "__main__": + main() diff --git a/BeOS/ar-1.1/docs/dumpar.pyc b/BeOS/ar-1.1/docs/dumpar.pyc new file mode 100644 index 00000000000..bc5045faff5 Binary files /dev/null and b/BeOS/ar-1.1/docs/dumpar.pyc differ diff --git a/BeOS/ar-1.1/docs/dumpo.py b/BeOS/ar-1.1/docs/dumpo.py new file mode 100644 index 00000000000..91bd8db699f --- /dev/null +++ b/BeOS/ar-1.1/docs/dumpo.py @@ -0,0 +1,126 @@ +#! /bin/env python +""" Dump data about a Metrowerks object file. + +Based on reverse-engineering the library file format, since the docs are +wrong. + +Copyright (C) 1997 Chris Herborth (chrish@qnx.com) +""" + +# ---------------------------------------------------------------------- +# Standard modules +import sys, getopt, string, time + +# ---------------------------------------------------------------------- +# Extra goodies +from dumpar import mk_long, str2hex, print_offset, get_string + +# ---------------------------------------------------------------------- +def mk_short( str ): + """ convert a 2-byte string into a number + + Assumes big-endian! + """ + if len( str ) < 2: + raise ValueError, "str must be 2 bytes long" + + num = ord( str[1] ) + num = num + ord( str[0] ) * 0x100 + + return num + +# ---------------------------------------------------------------------- +def usage(): + """ Display a usage message and exit. + """ + print "dumpo [-v] object1 [object2 ... objectn]" + print + print "Attempt to display some useful information about the contents" + print "of the given Metrowerks object file(s)." + print + print "-v Be verbose (displays offsets along with the data)" + raise SystemExit + +# ---------------------------------------------------------------------- +def dump_o( file, verbose ): + """ dump information about a Metrowerks object file + + Note that there is more info there, 6 more quads before the file name. + """ + offset = 0 + + print "Dumping object:", file + + # Attempt to read the data. + try: + data = open( file ).read() + except IOError, retval: + print "*** Unable to open file %s: %s" % ( file, retval[1] ) + return + + # Check the magic number. + if verbose: + print_offset( offset ) + print "Magic:", + magic = data[offset:offset + 8] + print "'%s'" % ( magic ) + if magic != "MWOBPPC ": + print "*** Invalid magic number!" + return + + offset = offset + 8 + + # version + if verbose: + print_offset( offset ) + print "version:", mk_long( data[offset:offset + 4] ) + offset = offset + 4 + + # flags + if verbose: + print_offset( offset ) + print "flags:", str2hex( data[offset:offset + 4] ) + offset = offset + 4 + + # code size + if verbose: + print_offset( offset ) + print "code size:", mk_long( data[offset:offset + 4] ) + offset = offset + 4 + + # data size + if verbose: + print_offset( offset ) + print "data size:", mk_long( data[offset:offset + 4] ) + offset = offset + 4 + +# ---------------------------------------------------------------------- +def main(): + """ mainline + """ + + # Set up some defaults + be_verbose = 0 + + # First, check the command-line arguments + try: + opt, args = getopt.getopt( sys.argv[1:], "vh?" ) + except getopt.error: + print "*** Error parsing command-line options!" + usage() + + for o in opt: + if o[0] == "-h" or o[0] == "-?": + usage() + elif o[0] == "-v": + be_verbose = 1 + else: + print "*** Unknown command-line option!" + usage() + + # Now we can attempt to dump info about the arguments. + for obj in args: + dump_o( obj, be_verbose ) + +if __name__ == "__main__": + main() diff --git a/BeOS/ar-1.1/docs/notes b/BeOS/ar-1.1/docs/notes new file mode 100644 index 00000000000..4a90a16b378 --- /dev/null +++ b/BeOS/ar-1.1/docs/notes @@ -0,0 +1,34 @@ +MW library layout: + +header + magic word, magic processor flag ('MWOBPPC ') - 2x 4 bytes + magic flags, version (file format version?) - 2x 4 bytes + code size - 4 bytes + data size - 4 bytes + # of objects - 4 bytes + + header for file 1 - 20 bytes + - modification time - 4 bytes + - offset to filename - 4 bytes + - offset to full path - 4 bytes (NOTE: NOT a full path in reality!) + - offset to object data - 4 bytes + - size of object data - 4 bytes + + ... + + header for file n - 20 bytes + + file 1 name + NUL - variable + file 1 name + NUL - variable + file 2 name + NUL - variable + file 2 name + NUL - variable + ... + file n name + NUL - variable + file n name + NUL - variable + + padding to multiple of 4 bytes - 0 - 3 bytes + +file 1 data - variable (padded to 4-byte boundary) +file 2 data - variable (padded to 4-byte boundary) +... +file n data - variable (padded to 4-byte boundary) diff --git a/BeOS/ar-1.1/main.c b/BeOS/ar-1.1/main.c new file mode 100644 index 00000000000..225ee628dd2 --- /dev/null +++ b/BeOS/ar-1.1/main.c @@ -0,0 +1,312 @@ +/* +** main.c - POSIX 1003.2 "ar" command +** +** This isn't a pure POSIX 1003.2 ar; it only manipulates Metrowerks +** Library files, not general-purpose POSIX 1003.2 format archives. +** +** Dec. 14, 1997 Chris Herborth (chrish@kagi.com) +** +** This code is donated to the PUBLIC DOMAIN. You can use, abuse, modify, +** redistribute, steal, or otherwise manipulate this code. No restrictions +** at all. If you laugh at this code, you can't use it. +** +** This "ar" was implemented using IEEE Std 1003.2-1992 as the basis for +** the interface, and Metrowerk's published docs detailing their library +** format. Look inside for clues about how reality differs from MW's +** documentation on BeOS... +*/ + +#include