home *** CD-ROM | disk | FTP | other *** search
- /*
- * UnixFiles for the Mac
- *
- * ...Various tools ported from GNU and generic sources found at
- * uunet.uu.net including (so far)
- * uuencode
- * uudecode
- * At the moment, I'm working on compress, but the code I have wants
- * to declare a huge array and I'm not too sure about what to do
- * except look for some other compress code. :-)
- *
- * This module written and ⌐ 1989 by Pete Gontier.
- * You may use this code any way you like as long as you
- * don't sell it or sell any of your binaries.
- *
- * I hope I've written this module so that interfaces for other
- * machines can easily be written. I went in and messed with the calling
- * sequences and return structures of each module so that all errors could
- * be reported within this one module. Maybe it even worked. Oh, and before
- * you decide that the code uses too many switches for what it could
- * accomplish in one, think about how other toold might fit into
- * it fairly easily. And note how the main code interacts, through
- * invol and outvol, with my_stdio.h. This is another hack to make
- * plugging other tools in more easy.
- *
- * problems and/or kudos to pete@cavevax.ucsb.edu
- */
-
- #include <string.h>
- #include "my_stdio.h"
- #include "Un*xFiles.h"
-
- extern int invol, outvol;
-
- void CrashSaver ( void ) {
- }
-
- void InitMac ( void ) {
- InitGraf ( &thePort);
- InitFonts ( );
- InitWindows ( );
- InitMenus ( );
- TEInit ( );
- InitDialogs ( ( ProcPtr ) CrashSaver );
- MaxApplZone ( );
-
- ErrorSound ( nil );
- InitCursor ( );
- FlushEvents ( everyEvent, 0 );
- }
-
- #ifdef DEBUG
- void bitch ( char *message ) {
- ParamText ( "\pBitch: ", "\p[", message, "\p]" );
- SysBeep ( 10 );
- myAlert ( 129, nil );
- }
- #endif
-
- void main ( void ) {
-
- int oldvol, result;
- SFReply sfr;
- SFTypeList sft;
- int theButton;
- char infilename [ 64 ];
- char *errstr, *writeprompt, *fnappend;
-
- if ( GetVol ( NIL, &oldvol ) ) {
- SysBeep ( 10 );
- return;
- }
-
- #ifdef DEBUG
- OpenResFile ( "\pUnixFiles ¿" );
- #endif
-
- InitMac ( );
-
- sft[0] = 'TEXT';
-
- while ( 1 < ( theButton = myAlert ( 128, nil ) ) ) {
- SFGetFile ( SFCenter ( -4000 ), NIL, NIL, 1, sft, NIL, &sfr );
- if ( sfr.good )
- if ( SetVol ( nil, sfr.vRefNum ) )
- SysBeep ( 10 );
- else {
- outvol = invol = sfr.vRefNum;
- strcpy ( infilename, PtoCstr ( ( char * ) sfr.fName ) );
-
- switch ( theButton ) {
- case 2 : writeprompt = "\puuencode:";
- fnappend = ".uuencode";
- break;
- case 3 :
- break;
- default : SysBeep ( 10 );
- return;
- break;
- }
-
- switch ( theButton ) {
- case 2 :
- strcat ( ( char * ) sfr.fName, fnappend );
- CtoPstr ( ( char * ) sfr.fName );
- SFPutFile ( SFCenter ( -3999 ),
- writeprompt,
- ( char * ) sfr.fName,
- nil, &sfr );
- outvol = sfr.vRefNum;
- PtoCstr ( ( char * ) sfr.fName );
- break;
- case 3 :
- break;
- default : SysBeep ( 10 );
- return;
- break;
- }
-
- SetCursor ( * GetCursor ( watchCursor ) );
-
- switch ( theButton ) {
- case 2 : result = uuencode ( infilename,
- ( char * ) sfr.fName );
- break;
- case 3 : result = uudecode ( infilename );
- break;
- default : SysBeep ( 10 );
- return;
- break;
- }
-
- SetCursor ( &arrow );
-
- switch ( result ) {
- case NOERR : break;
- case OTHER : errstr = "\pmiscellaneous"; break;
- case NOOPIN : errstr = "\pinput open"; break;
- case NOOPOUT : errstr = "\poutput open"; break;
- case NOREAD : errstr = "\pread"; break;
- case NOWRITE : errstr = "\pwrite"; break;
- case NOCLIN : errstr = "\pinput close"; break;
- case NOCLOUT : errstr = "\poutput close"; break;
- case FORMAT : errstr = "\pincorrect format"; break;
- case UEOF : errstr = "\punexpected end-of-file"; break;
- case DETRANS : errstr = "\pdecompression or translation"; break;
- default : errstr = "undefined %u ";
- sprintf ( errstr, errstr, result );
- CtoPstr ( errstr );
- break;
- }
-
- if ( result ) {
- ParamText ( "\pSorry, a",
- strchr ( "aeiouAEIOU", errstr [ 1 ] ) ? "\pn " : "\p ",
- errstr, "\p error occurred." );
- SysBeep ( 10 );
- myAlert ( 129, nil );
- }
- }
- if ( SetVol ( nil, oldvol ) )
- SysBeep ( 10 );
- }
- }