X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=bin%2Fmegatron%2Fhqx.c;h=acdd519e43e5bfa6aef2f1e398173ffa95fc2044;hb=04e2c1825ba7677034bd180f99a971e10e998794;hp=aae9c7231a6452cf9fd3678e389b7b8fe40bbb3c;hpb=cb22616b6b035325d3f25eb910787da358e06b29;p=netatalk.git diff --git a/bin/megatron/hqx.c b/bin/megatron/hqx.c index aae9c723..acdd519e 100644 --- a/bin/megatron/hqx.c +++ b/bin/megatron/hqx.c @@ -1,32 +1,34 @@ /* - * $Id: hqx.c,v 1.5 2001-05-01 13:21:22 rufustfirefly Exp $ + * $Id: hqx.c,v 1.11 2002-02-19 16:32:17 srittau Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" -#endif +#endif /* HAVE_CONFIG_H */ -#include #include #include #include #include -#ifdef notdef -#if BSD >= 199006 -# include -#else -# include -#endif -#endif notdef -#include -#include + #include -#include #include #include +#include +#include + +#include +#ifdef HAVE_FCNTL_H +#include +#endif /* HAVE_FCNTL_H */ + +#include + #include #include + #include "megatron.h" +#include "hqx.h" #define HEXOUTPUT 0 @@ -35,7 +37,7 @@ */ #ifndef STDIN # define STDIN "-" -#endif +#endif /* ! STDIN */ /* Yes and no */ @@ -64,9 +66,18 @@ u_short updcrc(); +/* Forward declarations. + */ +int skip_junk(int line); +int hqx_close(int keepflag); +int hqx_header_read(struct FHeader *fh); +int hqx_header_write(struct FHeader *fh); +int hqx_7tobin(char *outbuf, int datalen); +int hqx7_fill(u_char *hqx7_ptr); + #if HEXOUTPUT FILE *rawhex, *expandhex; -#endif +#endif /* HEXOUTPUT */ struct hqx_file_data { u_int32_t forklen[ NUMFORKS ]; @@ -98,13 +109,13 @@ int hqx_open( hqxfile, flags, fh, options ) #if DEBUG fprintf( stderr, "megatron: entering hqx_open\n" ); -#endif +#endif /* DEBUG */ if ( flags == O_RDONLY ) { #if HEXOUTPUT rawhex = fopen( "rawhex.unhex", "w" ); expandhex = fopen( "expandhex.unhex", "w" ); -#endif +#endif /* HEXOUTPUT */ first_flag = 0; @@ -120,9 +131,9 @@ int hqx_open( hqxfile, flags, fh, options ) #if DEBUG off_t pos; - pos = lseek( hqx.filed, 0, L_INCR ); + pos = lseek( hqx.filed, 0, SEEK_CUR ); fprintf( stderr, "megatron: current position is %ld\n", pos ); -#endif +#endif /* DEBUG */ return( 0 ); } } @@ -187,12 +198,12 @@ int hqx_read( fork, buffer, length ) #if DEBUG >= 3 { off_t pos; - pos = lseek( hqx.filed, 0, L_INCR ); + pos = lseek( hqx.filed, 0, SEEK_CUR ); fprintf( stderr, "hqx_read: current position is %ld\n", pos ); } fprintf( stderr, "hqx_read: fork is %s\n", forkname[ fork ] ); fprintf( stderr, "hqx_read: remaining length is %d\n", hqx.forklen[fork] ); -#endif +#endif /* DEBUG >= 3 */ if ( hqx.forklen[ fork ] < 0 ) { fprintf( stderr, "This should never happen, dude!\n" ); @@ -206,7 +217,7 @@ int hqx_read( fork, buffer, length ) #if DEBUG >= 4 fprintf( stderr, "hqx_read: storedcrc\t\t%x\n", storedcrc ); fprintf( stderr, "hqx_read: observed crc\t\t%x\n\n", hqx.forkcrc[fork] ); -#endif +#endif /* DEBUG >= 4 */ if ( storedcrc == hqx.forkcrc[ fork ] ) { return( 0 ); } @@ -223,7 +234,7 @@ int hqx_read( fork, buffer, length ) } #if DEBUG >= 3 fprintf( stderr, "hqx_read: readlen is %d\n", readlen ); -#endif +#endif /* DEBUG >= 3 */ cc = hqx_7tobin( buffer, readlen ); if ( cc > 0 ) { @@ -233,7 +244,7 @@ int hqx_read( fork, buffer, length ) } #if DEBUG >= 3 fprintf( stderr, "hqx_read: chars read is %d\n", cc ); -#endif +#endif /* DEBUG >= 3 */ return( cc ); } @@ -257,7 +268,7 @@ int hqx_header_read( fh ) #if HEXOUTPUT int headerfork; headerfork = open( "headerfork", O_WRONLY|O_CREAT, 0622 ); -#endif +#endif /* HEXOUTPUT */ mask = htons( 0xfcee ); hqx.headercrc = 0; @@ -271,7 +282,7 @@ int hqx_header_read( fh ) #if HEXOUTPUT write( headerfork, &namelen, sizeof( namelen )); -#endif +#endif /* HEXOUTPUT */ if (( headerbuf = (char *)malloc( (unsigned int)( namelen + BHH_HEADSIZ ))) == 0 ) { @@ -288,7 +299,7 @@ int hqx_header_read( fh ) #if HEXOUTPUT write( headerfork, headerbuf, ( namelen + BHH_HEADSIZ )); -#endif +#endif /* HEXOUTPUT */ /* * stuff from the hqx file header @@ -296,10 +307,10 @@ int hqx_header_read( fh ) memcpy( fh->name, headerptr, (int)namelen ); headerptr += namelen; - headerptr += BVERSION; - memcpy(&fh->finder_info, headerptr, TCSIZ ); - headerptr += TCSIZ; - memcpy(&fh->finder_info.fdFlags, headerptr, FLAGSIZ ); + headerptr += BHH_VERSION; + memcpy(&fh->finder_info, headerptr, BHH_TCSIZ ); + headerptr += BHH_TCSIZ; + memcpy(&fh->finder_info.fdFlags, headerptr, BHH_FLAGSIZ ); fh->finder_info.fdFlags = fh->finder_info.fdFlags & mask; headerptr += BHH_FLAGSIZ; memcpy(&fh->forklen[ DATA ], headerptr, BHH_DATASIZ ); @@ -342,7 +353,7 @@ int hqx_header_read( fh ) fprintf( stderr, "observed crc\t\t%x\n", hqx.headercrc ); fprintf( stderr, "\n" ); } -#endif +#endif /* DEBUG >= 5 */ /* * create and modify times are figured from right now @@ -583,7 +594,7 @@ int hqx_7tobin( outbuf, datalen ) #if DEBUG fprintf( stderr, "hqx_7tobin: datalen entering %d\n", datalen ); fprintf( stderr, "hqx_7tobin: hqx8i entering %d\n", hqx8i ); -#endif +#endif /* DEBUG */ if ( first_flag == 0 ) { prev_hqx8 = 0; @@ -596,7 +607,7 @@ int hqx_7tobin( outbuf, datalen ) #if DEBUG fprintf( stderr, "hqx_7tobin: hqx8i entering %d\n", hqx8i ); -#endif +#endif /* DEBUG */ out_first = outbuf; out_last = out_first + datalen; @@ -656,14 +667,14 @@ int hqx_7tobin( outbuf, datalen ) #if HEXOUTPUT putc( hqx8i, rawhex ); putc( hqx8[ hqx8i ], rawhex ); -#endif +#endif /* HEXOUTPUT */ if ( prev_hqx8 == RUNCHAR ) { if ( hqx8[ hqx8i ] == 0 ) { *out_first = prev_hqx8; #if HEXOUTPUT putc( *out_first, expandhex ); -#endif +#endif /* HEXOUTPUT */ prev_out = prev_hqx8; out_first++; } @@ -671,7 +682,7 @@ int hqx_7tobin( outbuf, datalen ) *out_first = prev_out; #if HEXOUTPUT putc( *out_first, expandhex ); -#endif +#endif /* HEXOUTPUT */ hqx8[ hqx8i ]--; out_first++; } @@ -687,7 +698,7 @@ int hqx_7tobin( outbuf, datalen ) *out_first = prev_hqx8; #if HEXOUTPUT putc( *out_first, expandhex ); -#endif +#endif /* HEXOUTPUT */ prev_out = prev_hqx8; out_first++; }