[netatalk-admins] megatron patch


Subject: [netatalk-admins] megatron patch
From: Frank Morton (fmorton@mail.base2inc.com)
Date: Thu Aug 27 1998 - 14:33:23 EDT


I have needed the ability to get the macintosh type/creator from a
specified file from the command line and have made the following
patches (diffs) to megatron.c and megatron.h. I would like to see
this integrated in the distributed source, but since I am on the outside
looking in, I'm sending to multiple places hoping one is right.

I have been using the asun version, but it looks like the megatron
utility has not been touched in awhile.

I have added two "modules" as the source code calls it: macheader
and macbinaryheader. These should be linked in the bin directory
just like unhex, macbinary, etc.

To use them, on an apple double format file, you do one of the following:

macheader filename

or

macbinary -header filename

On a macbinary file, to get the same info, you do one of the following:

macbinaryheader filename.bin

or

unbin -header filename.bin

In all cases, the following is written to standard output in a format like
this:

name: filename_in_the_fork
comment:
forklen_0: 1305233
forklen_1: 242877
create_date: 2980256773
mod_date: 2980256778
backup_date: 0
type: EPSF
creator: PSMC
flags: 400

The name field is the filename in the file itself, not necessary the linux
filename. Comment is self explanatory and will usually be blank. The
forklen_0 corresponds to the length of the data fork. I thought about
naming it forklen_data but decided to leave it open-ended to be
consistent with the rest of the source. forklen_1 is the length of the
resource fork. Dates are the corresponding dates to their descriptions.
The type and creator fields are the 4-byte fields in the finder info that
are commonly used. The flags, printed in hex (as in %x) are the status
flags in the finder info. There are a few other fields which I left out
as they are more bookkeeping fields than externally useful info.

To use this to extract, as an example, the creator of the file, I plan to
do the following in a bash shell:

export imagecreator=`macheader filename|awk '{print $2}'`

I will welcome any comments and glad to make any reasonable
additional changes.

Below are the diffs, first for megatron.h and then for megatron.c.
I realize e-mail isn't the best way to send these. If you would rather
me ftp (or whatever) the diffs or the complete megatron.(h,c) files,
let me know:

start megatron.h------------------------------------
26,29c26,27
< #define MACHEADER 6 /* macheader */
< #define MACBINARYHEADER 7 /* macbinaryheader */
< #define MEGATRON 8 /* megatron, default, usually HEX2NAD */
< #define CONVERTS 9 /* # conversions defined */

---
> #define MEGATRON 6 /* megatron, default, usually HEX2NAD */
> #define CONVERTS 7 /* # conversions defined */

end megatron.h-------------------------------------

start megatron.c------------------------------------ 23,24d22 < "macheader", < "macbinaryheader", 35d32 < int showheaderonly = 0; 54d50 < if (( module == MACHEADER ) || ( module == MACBINARYHEADER )) showheaderonly = 1; 61,65c57 < if ( strcmp( argv [ c ], "-header" ) == 0 ) { < showheaderonly = 1; < continue; < } < if ( rc = megatron( argv[ c ], module , showheaderonly ) != 0 ) { --- > if ( rc = megatron( argv[ c ], module ) != 0 ) { 72c64 < megatron( path, module, showheaderonly ) --- > megatron( path, module ) 75d66 < int showheaderonly; 82d72 < int k; 109,121d98 < if ( showheaderonly ) { < printf("name: %s\n",fh.name); < printf("comment: %s\n",fh.comment); < for(k=0;k<NUMFORKS;++k) printf("forklen_%d: %u\n", k, h.forklen[ k ]); < printf("create_date: %u\n",fh.create_date); < printf("mod_date: %u\n",fh.mod_date); < printf("backup_date: %u\n",fh.backup_date); < printf("type: %4.4s\n",(char *)(&(fh.finder_info.fdType))); < printf("creator: %4.4s\n",(char *)(&(fh.finder_info.fdCreator))); < printf("flags: %x\n",fh.finder_info.fdFlags); < return( from_close( module )); < } < 183d159 < case MACBINARYHEADER : 187d162 < case MACHEADER :

end megatron.c-------------------------------------



This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:33:12 EST