#include /** *
 * macwhack.c
 *
 * Macwhack, a MacBinary header remover.
 *
 * Created:	October 26, 1997
 * Author:	Philip C. Tsao (Tp12a@freenet.fsu.edu)
 *
 * Revisions:	1.1a    October 26, 1997
 *			Cleaned up source. Optimized the code a bit.
 *
 *		1.1	May 15, 1997
 *			Fixed null pointer bug.
 *
 *		1.0	January 1, 1997
 *			Initial release.
 * 
* * @author Philip C. Tsao * @version Version 1.1a October 26, 1997 */ void whack_mac( FILE *, FILE * ); void prn_info( char * ); /*** * * main * * Main procedure. Checks command line parameters and calls * appropriate functions. * * Parameters: * int argc Number of command line parameters (plus 1). * * char **argv Array of strings containing the command line * parameters. * * Returns: * An int, usually 0 if everything's OK. * */ int main( int argc, char **argv ) { FILE *ifp, *ofp; printf( "\n%s\n%s\n", "MACWHACK v1.1a (26-10-97) MacBinary header remover", "by Philip C. Tsao (Tp12a@freenet.fsu.edu)" ); if ( argc != 3 ) { prn_info( argv[ 0 ] ); exit( 1 ); } if( ( ifp = fopen( argv[ 1 ], "rb") ) && ( ofp = fopen( argv[ 2 ], "wb" ) ) ) { /* Not the prettiest conditional, but it fixes the null pointer big. */ whack_mac( ifp, ofp ); fclose( ifp ); fclose( ofp ); printf( "\n%s\n\n", "Macwhack probably successful." ); } else { printf( "\n%s\n\n", "Bad filename(s)." ); exit( 1 ); } return 0; } /*** * * whack_mac * * This is the bit that strips the 128-byte header and copies the * rest of the file. * * Parameters: * FILE *ifp incoming file pointer * * FILE *ofp outgoing file pointer * * Returns: * Nothing. * */ void whack_mac( FILE *ifp, FILE *ofp ) { int i; for( i = 0; i <= 127; i++ ) { getc( ifp ); } while( ( i = getc( ifp ) ) != EOF ) { putc( i, ofp ); } } /*** * * prn_info * * Prints (brief) info on correct usage of this program. * * Parameters: * char *prm_name AKA char *argv[ 0 ] from main( ) * This contains the filename of this * program as reported by the OS. * * Returns: * Nothing. * */ void prn_info( char *pgm_name ) { printf( "\n%s%s%s\n\n", "Usage: ", pgm_name, " infile outfile" ); }