[net.sources.mac] fpack for the Mac

jimb@amdcad.UUCP (Jim Budler) (02/14/86)

Here's the source for version 2.2 of fpack for the Macintosh.
Based upon and fully compatible with the version for Unix and IBMPC by
Gary Perlman.

==========================< cut here >========================
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	FPack.C
#	FPack.Link
#	FPackR.R
#	SFLib.C
#	VolStuff.c
# This archive created: Sun Feb  9 19:20:42 1986
export PATH; PATH=/bin:$PATH
echo shar: extracting "'FPack.C'" '(12293 characters)'
if test -f 'FPack.C'
then
	echo shar: will not over-write existing file "'FPack.C'"
else
sed 's/^	X//' << \SHAR_EOF > 'FPack.C'
	X #Options Z
	X /* floating point not needed	*/
	X
	X/*
	X * Original author of fpack, UNIX and IBM PCDOS Version:
	X *
	X * Gary Perlman
	X *
	X *
	X * MODIFICATIONS FOR Macintosh by Jim Budler
	X *
	X * Please note, although the functionality remains, files are selected 
	X * after the program is run, rather than with command line options.
	X * 
	X * Both versions of the program are compatible, with the exception
	X * that maximum line length is 255 on the Mac, and BUFSIZ is 512 or greater 
	X * on Unix. I have no idea what it is under MSDOS.
	X * If the length of a line exceeds this extra newlines may be introduced.
	X *
	X * Some of the code below comes from an example program for
	X * MacBinary I found on Compuserve.  It didn't work then, it does now.
	X *
	X * And some of it is my own.
	X *
	X * Jim Budler
	X */
	X
	X
	X#include <stdio.h>
	X
	X#define	MAGIC	"fpack:!@#$%^&*(): "	/* default file delimiter */
	Xtypedef	int       Status;      /* return/exit status of functions */
	X#define	SUCCESS   ((Status) 0)
	X#define	FAILURE   ((Status) 1)
	X
	X/*	Mac Stuff	*/
	X#include "MacCdefs.h"
	X#include "Window.h"
	X#include "Dialog.h"
	X#include "Events.h"
	X#include "Menu.h"
	X  
	X    
	XMenuHandle DeskMenu;
	XMenuHandle FileMenu;
	XMenuHandle EditMenu;
	XMenuHandle FPackMenu;
	X#define NAMESTRING "\p    FPack-Mac Version 2.2 February 9, 1986"
	X    
	X#define Desk_ID 200
	X#define File_ID 201
	X#define Edit_ID 202
	X#define FPack_ID 203
	X    
	X#include "Packages.h"
	X
	X/*
	X *	IM defines fName[64] in struct SFReply
	X *	Packages.h defines char Namelength;char Name[63] instead.
	X *	With the define below, both compatibility and clarity
	X *	are improved (I think); use either. The file name is a 
	X *	63 character Pascal string (with length byte preceeding).
	X */
	X#define fName	Namelength 
	X#include "pbDefs.h"
	X#include "OSIo.h"
	X
	X#define	TRUE	1
	X#define	FALSE	0
	X#define NIL		0
	X
	XRect screenRect = {0, 0, 384, 512};	/* outer limits of screen */
	X
	XPoint location;
	XDialogPtr theDialog;
	Xlong freebytes;
	Xint morefiles;
	Xshort	defvolnum, invol, outvol;
	Xchar	*outname, *inname, OutputV[64];
	Xchar defvol[64];	/* 
	X					 * for default volume name returned by GetVol(). 
	X					 */
	XFILE	*infile, *outfile;
	XSFTypeList	types;
	XSFReply	RP;
	XFileParam	FP;
	Xextern Str255 *tempMacStr();
	X
	X/*FUNCTION fpack:	pack files for later extraction by funpack */
	XStatus
	Xfpack (file)
	Xchar	*file;
	X	{
	X	FILE	*ioptr;
	X	char	line[MAXLINE];
	X	char	*ptr;
	X	
	X	if ((ioptr = fopen (file, "r")) != NULL)
	X		{
	X		blabber (file);
	X		if ((freebytes -= strlen(MAGIC) + strlen(file) + 1) <= 0)
	X			{
	X			error( OutputV," Full!");
	X			fclose(ioptr);
	X			return(FAILURE);
	X			}
	X		fprintf (outfile,"%s%s\n", MAGIC, file);
	X		while (fgets (line, MAXLINE-1, ioptr))
	X			{
	X			if ((freebytes -= strlen(line) + 1) <= 0) 
	X				{
	X				error( OutputV," Full!");
	X				fclose(ioptr);
	X				return(FAILURE);
	X				}
	X			fputs (line, outfile);
	X			}
	X		for (ptr = line; *ptr; ptr++);
	X		if (ptr > line && *(ptr-1) != '\n') /* incomplete last line */
	X			{
	X			putc ('\n', outfile);
	X			freebytes -= 1;
	X			}
	X		fclose (ioptr);
	X		return (SUCCESS);
	X		}
	X	error ("Can't open for reading: ", file);
	X	return (FAILURE);
	X	}
	X
	X/*FUNCTION funpack:	unpack and create files packed by fpack */
	XStatus
	Xfunpack ()
	X	{
	X	FILE	*ioptr = NULL;
	X	char	line[MAXLINE];
	X	int 	maglen = strlen (MAGIC);
	X	char	*ptr,outputname[64];
	X	while (fgets(line, MAXLINE-1, infile))
	X		{
	X		if (line[strlen(line) -1] == '\n')
	X			line[strlen(line) -1] = '\0';
	X		if (!strncmp (MAGIC, line, maglen))
	X			{
	X			if (ioptr)
	X				{
	X				fclose (ioptr);
	X				FlushVol(NULL,invol);	/* update all volume information *//* see VolStuff.c */
	X				ioptr = NULL;
	X				}
	X			ptr = line + maglen;
	X			if (*ptr == '\0') /* done */
	X				ioptr = NULL;
	X			else if (OSFind (ptr) != 0) /* file exists */
	X				{
	X				error ( ptr, " exists (not unpacked)");
	X				ioptr = NULL;
	X				}
	X			else if ((ioptr = fopen (ptr, "w")) != NULL)
	X				{
	X				strcpy(outputname,ptr);
	X				blabber (ptr);
	X				SetFileType( ptr, (long) 'TEXT');
	X				SetFileSignature( ptr, (long) 'EDIT');
	X				}
	X			else
	X				{
	X				error ("Can't create ", ptr);
	X				return (FAILURE);
	X				}
	X			}
	X		else if (ioptr != NULL)
	X			{
	X			if ((freebytes -= strlen(line) + 1) <= 0) 
	X				{
	X				error(OutputV," Full!");
	X				fclose(ioptr);
	X				SetVol(NULL,invol);
	X				unlink(outputname);
	X				FlushVol(NULL,invol);	/* update all volume information *//* see VolStuff.c */
	X				return(FAILURE);
	X				}
	X			fputs (line, ioptr);
	X			putc ('\n', ioptr);
	X			}
	X		}
	X	return (SUCCESS);
	X	}
	X		
	Xblabber(filename )
	Xchar *filename;
	X{
	X	ParamText(tempMacStr(filename), 0, 0, 0);
	X	DrawDialog(theDialog);
	X}
	X
	Xerror(string1 , string2)
	Xchar *string1, *string2;
	X{
	X	char temp[255];
	X	strcpy(temp, string1);
	X	strcat(temp, string2);
	X	CtoPStr(temp);
	X	DoDialog( 1, temp);
	X}
	X	
	X
	XInputFileName(count, types, reply)
	Xshort	count;
	Xchar	*types;
	XSFReply	*reply;
	X{	
	X	SFGetFile(&location, 0, 0, count, types, 0, reply); /* Glue code required - see SFLib.C */
	X}
	X
	XOutputFileName(name, reply)
	Xchar	*name;
	XSFReply	*reply;
	X{
	X	SFPutFile(&location, "\pSave as:", name, 0, reply); /* Glue code required - see SFLib.C */
	X}
	X
	XPackEm()
	X{
	X	theDialog = GetNewDialog(3, 0, (DialogPtr) -1);
	X	blabber(" ");
	X	strcpy(outname, "\pFPack Archive"); /* default archive name */
	X	OutputFileName(outname, &RP);
	X	if (!RP.good)
	X		return;
	X	PtoCstr(outname);
	X	outvol = RP.vRefNum;	/* save for FlushVol() */
	X	SetVol(NULL,outvol);	/* see VolStuff.c */
	X	GetVol(OutputV,&outvol); /* get name back  */
	X	GetVInfo(NULL,OutputV,&outvol,&freebytes);
	X	if ( outvol != RP.vRefNum )
	X		Signal("\pTwo Identical Volume names! Help!");
	X	PtoCStr(OutputV);
	X	/* allow for last MAGIC marker and one line safety */
	X	freebytes -= strlen(MAGIC) + 1 + MAXLINE;
	X	if(OSFind(outname))
	X		OSDelete(outname);
	X		FlushVol(NULL, outvol);
	X	if((outfile = fopen(outname, "w")) == NULL)
	X		Signal("\pUnable to create the file.");
	X	SetFileType( outname, (long) 'TEXT');
	X	SetFileSignature( outname, (long) 'EDIT');
	X
	X	while (morefiles) {
	X		types.ftype[0]='TEXT';
	X		InputFileName(1, &types, &RP);
	X		if (!RP.good) 
	X			{
	X			morefiles = FALSE;
	X			break;
	X			}
	X		strcpy(inname, &RP.fName);
	X		SetVol(NULL,RP.vRefNum);
	X		PtoCstr(inname);
	X		if (fpack(inname)) 
	X			{
	X			fclose (outfile);
	X			SetVol(NULL, outvol);
	X			unlink(outname);
	X			FlushVol(NULL, outvol);
	X			Signal("\pPack Failed");
	X			}
	X		CtoPstr(inname);	/* Always safer to put it back */
	X	}
	X	fprintf (outfile,"%s\n", MAGIC); /* end of files */
	X	fclose(outfile);
	X	FlushVol(NULL, outvol);	/* update all volume information *//* see VolStuff.c */
	X	blabber("Finished");
	X}
	X
	X
	XUnpackEm()
	X{
	X	theDialog = GetNewDialog(4, 0, (DialogPtr) -1);
	X	blabber(" ");
	X	types.ftype[0]='TEXT';
	X	InputFileName(1, &types, &RP);
	X	if (!RP.good)
	X		return;
	X		strcpy(inname, &RP.fName);
	X		invol = RP.vRefNum;	/* save for FlushVol() */
	X		SetVol(NULL,invol);	/* see VolStuff.c */
	X		GetVol(OutputV,&invol); /* get name back  */
	X		GetVInfo(NULL,OutputV,&invol,&freebytes);
	X		if ( invol != RP.vRefNum )
	X			Signal("\pTwo Identical Volume names! Help!");
	X	PtoCStr(OutputV);
	X	/* allow one line safety */
	X	freebytes -= MAXLINE;
	X	PtoCstr(inname);
	X	if((infile = fopen(inname, "r")) == NULL) 
	X		Signal("\pUnable to read the input file.");
	X	if (funpack()) 
	X		{
	X		fclose(infile);
	X		Signal("\pUnpack Failed");
	X		}
	X	fclose(infile);
	X	blabber("Finished");
	X}
	X
	X
	XDoDialog(id,msg)
	Xshort id;
	XStr255 *msg;
	X{
	X	DialogPtr dialog;
	X	short Hit;
	X	ParamText(msg, 0, 0, 0);
	X	dialog = GetNewDialog(id, 0, (DialogPtr) -1);
	X	ModalDialog(0, &Hit);
	X	DisposeDialog(dialog);
	X	return(Hit);
	X}
	X
	XrestartProc()
	X{
	X	ExitToShell();	/* I really don't know why more people don't do this */
	X}
	X
	XDoMenu(menuresult)
	Xlong menuresult;
	X{ 
	X    short menuID, itemNumber;
	X    struct P_Str AccessoryName;
	X    GrafPtr	theCurrentPort;
	X    menuID = HiWord(menuresult);
	X    itemNumber = LoWord(menuresult);
	X    
	X    switch ( menuID )
	X      {
	X	
	X      case Desk_ID:
	X        if ( itemNumber == 1)
	X			AboutWindow();
	X		else {
	X			GetItem(DeskMenu, itemNumber, &AccessoryName);
	X			GetPort(&theCurrentPort);
	X			OpenDeskAcc(&AccessoryName);
	X			SetPort(theCurrentPort);
	X		}
	X		break;
	X	
	X      case File_ID:
	X		switch ( itemNumber )
	X	  	{
	X	  		case 1: 							/* Pack */
	X				morefiles = TRUE;
	X				if (theDialog != (DialogPtr) 0)
	X					DisposeDialog(theDialog);
	X				PackEm();
	X				break;
	X	  		case 2: 							/* Unpack */
	X				if (theDialog != (DialogPtr) 0)
	X					DisposeDialog(theDialog);
	X				UnpackEm(); 
	X				break;
	X	  		case 4:								/* Quit */
	X				SetVol(NULL, defvolnum);
	X				/* Put it back to original default volume */
	X				free(inname);
	X				free(outname);
	X				exit();
	X	  	}
	X		break;
	X	
	X      case Edit_ID:
	X	 	SystemEdit(itemNumber-1);	/* for Desk Accessories */
	X	 	break;
	X      }
	X    HiliteMenu(0);
	X}
	X
	XInit()
	X{ 
	X    InitDialogs(restartProc);
	X    InitMenus();
	X    InitCursor();
	X    FlushEvents(0xFFFF);
	X 
	X    /* Desk Accessory menu */
	X      DeskMenu = NewMenu(Desk_ID,"\p\024");
	X      AppendMenu(DeskMenu, "\pAbout FPack...;(-");
	X      AddResMenu(DeskMenu, 'DRVR');
	X      InsertMenu(DeskMenu, 0);
	X      
	X    /* File menu */
	X      FileMenu = NewMenu(File_ID, "\pFile");
	X      AppendMenu(FileMenu,
	X	  	"\pPack/P;Unpack/U;(-;Quit/Q");
	X      InsertMenu(FileMenu, 0);
	X    
	X    /* Edit menu */
	X      EditMenu = NewMenu(Edit_ID, "\pEdit");
	X      AppendMenu(EditMenu,
	X	  	"\pUndo;(-;Cut/X;Copy/C;Paste/V;Clear"); /* for Desk Accessories */
	X      InsertMenu(EditMenu, 0);
	X     
	X    /* Display name of the program in menu bar */
	X      FPackMenu = NewMenu(FPack_ID, NAMESTRING);
	X      InsertMenu(FPackMenu,0);
	X      DisableItem(FPackMenu, 0); /* Put name in gray */
	X      DrawMenuBar();
	X	  
	X/* save the original default volume */
	X	  GetVol(defvol,defvolnum);	/* see VolStuff.c */
	X}
	X
	XAboutWindow()	
	X{
	X	Rect	theRect;
	X	Rect	aLineRect;
	X	GrafPtr	port;
	X	WindowPtr	theWindow;
	X	EventRecord	anEvent;
	X
	X	char *line1 = "FPack for the Macintosh";
	X	char *version = "Version 2.2 February 9, 1986";
	X	char *line2 = "Based on FPack for Unix and MSDos";
	X	char *line3 = "From USENET mod.sources";
	X	char *line4 = "by Gary Perlman";
	X	char *line5 = "Ported to Macintosh by Jim Budler";
	X	char *line6 = "Using Consulair Mac C";
	X	
	X	GetPort(&port); /* save the port */
	X	SetRect(&aLineRect, 5, 10, 345, 25);
	X	SetRect(&theRect, 75, 110, 425, 265);
	X	
	X	theWindow = NewWindow((WindowPeek) 0, &theRect, "\pAbout FPack",TRUE,
	X		dBoxProc, (WindowPtr) -1, TRUE, 0);
	X	SetPort(theWindow);
	X	TextSize(12);
	X	TextFont(0);	/* system font	*/
	X	TextBox(line1,strlen(line1), &aLineRect, teJustCenter); /* added to TextEdit.h: #define teJustCenter 1 */
	X	OffsetRect(&aLineRect, 0, 20);
	X	TextBox(version,strlen(version), &aLineRect, teJustCenter); /* added to TextEdit.h: #define teJustCenter 1 */
	X	OffsetRect(&aLineRect, 0, 20);
	X	TextBox(line2,strlen(line2), &aLineRect, teJustCenter); /* as suggested by "Using the Macintosh Toolkit with C" */
	X	OffsetRect(&aLineRect, 0, 20);
	X	TextBox(line3,strlen(line3), &aLineRect, teJustCenter);
	X	OffsetRect(&aLineRect, 0, 20);
	X	TextBox(line4,strlen(line4), &aLineRect, teJustCenter);
	X	OffsetRect(&aLineRect, 0, 20);
	X	TextBox(line5,strlen(line5), &aLineRect, teJustCenter);
	X	OffsetRect(&aLineRect, 0, 20);
	X	TextBox(line6,strlen(line6), &aLineRect, teJustCenter);
	X	OffsetRect(&aLineRect, 0, 20);
	X	do {
	X		GetNextEvent(everyEvent, &anEvent);
	X	} while (anEvent.what != mouseDown);
	X	
	X	DisposeWindow(theWindow);
	X	SetPort(port);
	X}
	X
	Xmain()
	X{
	X	SetPt(&location, 80, 190); 
	X	outname = malloc(256);
	X	inname = malloc(256);
	X	struct P_Str *msg, *CatchSignal();
	X	short windowcode;
	X    EventRecord event;
	X	WindowPtr whichWindow;
	X	CouldDialog(1);	/* help single disk systems */		/* Error */
	X	CouldDialog(3);	/* keep the dialogs in memory */	/* Pack */
	X	CouldDialog(4);										/* Unpack */
	X    Init();
	X	if(msg = CatchSignal())
	X	{	
	X		HiliteMenu(0);
	X		DoDialog(1, msg);
	X		DrawMenuBar();
	X	}
	X    
	X    while (TRUE) 
	X    { 
	X      	SystemTask();
	X      	if (GetNextEvent(everyEvent, &event)) 
	X		{
	X			switch ( event.what )
	X	 	 	{
	X	  			case autoKey:
	X	  			case keyDown:
	X	    			if ((event.modifiers & cmdKey))
	X	     				DoMenu(MenuKey(event.message));
	X	    			break;
	X	  
	X	  			case mouseDown:
	X	   				windowcode = FindWindow(&event.where, &whichWindow);
	X	    			switch ( windowcode )
	X					{
	X						case inMenuBar:
	X		    					DoMenu(MenuSelect(&event.where));
	X		    					break;
	X						case inSysWindow:
	X		    					SystemClick(&event, whichWindow);
	X		    					break;
	X						case inDrag:
	X		    					DragWindow(whichWindow, &event.where, &screenRect);
	X		    					break;
	X						case inGoAway:
	X		    					break;
	X					}
	X					break;
	X			} 
	X		}
	X	}
	X}
SHAR_EOF
if test 12293 -ne "`wc -c < 'FPack.C'`"
then
	echo shar: error transmitting "'FPack.C'" '(should have been 12293 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'FPack.Link'" '(108 characters)'
if test -f 'FPack.Link'
then
	echo shar: will not over-write existing file "'FPack.Link'"
else
sed 's/^	X//' << \SHAR_EOF > 'FPack.Link'
	X/Type 'APPL' 'JIMB'
	X/Bundle
	X/Start QuickStart
	X
	XStandard Library
	XSFLib
	XVolStuff
	XFPack
	X/Resources
	XFPackR
	X/End
SHAR_EOF
if test 108 -ne "`wc -c < 'FPack.Link'`"
then
	echo shar: error transmitting "'FPack.Link'" '(should have been 108 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'FPackR.R'" '(1316 characters)'
if test -f 'FPackR.R'
then
	echo shar: will not over-write existing file "'FPackR.R'"
else
sed 's/^	X//' << \SHAR_EOF > 'FPackR.R'
	X*
	X*   I prefer to output to a Rel file for linking. Thus FPack.R.Rel below.
	X*
	X
	XFPackR.Rel
	X
	XType BNDL
	X
	X     ,128
	XJIMB 0
	XICN#
	X0 128
	XFREF
	X0 128
	X
	XType FREF
	X
	X     ,128
	XAPPL 0
	X
	XType JIMB = STR 
	X
	X     ,0
	XFPack Version 2.0 January 19, 1986
	X
	XType ICN# = GNRL
	X
	X     ,128
	X.H
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X00000000
	X01FFF000
	X02000800
	X067FC800
	X06802800
	X02802800
	X02802800
	X02802800
	X02802800
	X028028F8
	X028028F8
	X027FCD80
	X02000F00
	X02000E00
	X0203C800
	X02400800
	X02000800
	X03FFF800
	X01001000
	X01FFF000
	X*
	X1C000000
	X24018000
	X24014000
	X28023000
	X28021000
	X28042000
	X28062000
	X28014000
	X2800C000
	X28000000
	X28000000
	X28000000
	X28000000
	X25FFF000
	X26000800
	X18000800
	X08000000
	X00000000
	X00000000
	X00000000
	X00000000
	X000000F8
	X000000F8
	X00000180
	X00000100
	X00000100
	X00000180
	X000000F8
	X000000F8
	X00000000
	X00000000
	X00000000
	X
	X
	XType DITL
	X
	X     ,4
	X2
	X*   1
	XStatText Disabled
	X20 50 40 300
	X Unpacking File:
	X
	X*   2
	XStatText
	X50 50 90 300
	X ^0
	X
	X     ,3
	X2
	X*   1
	XStatText Disabled
	X20 50 40 300
	X Packing File:
	X
	X*   2
	XStatText
	X50 50 90 300
	X ^0
	X
	X     ,1
	X2
	X*   1
	XStatText
	X20 10 50 380
	X^0
	X
	X*   2
	XBtnItem
	X60 200 80 240
	XOK
	X
	X
	XType DLOG
	X
	X     ,4
	XUnpacking Files
	X50 50 170 450
	XVisible NoGoAway
	X1
	X0
	X4
	X
	X     ,3
	XPacking Files
	X50 50 170 450
	XVisible NoGoAway
	X1
	X0
	X3
	X
	X     ,1
	XError Message
	X190 100 280 400
	XVisible GoAway
	X1
	X0
	X1
SHAR_EOF
if test 1316 -ne "`wc -c < 'FPackR.R'`"
then
	echo shar: error transmitting "'FPackR.R'" '(should have been 1316 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'SFLib.C'" '(1056 characters)'
if test -f 'SFLib.C'
then
	echo shar: will not over-write existing file "'SFLib.C'"
else
sed 's/^	X//' << \SHAR_EOF > 'SFLib.C'
	X#Options M 
	X#include "Packages.h"
	X#include "pbDefs.h"
	X#include "OSIo.h"
	X
	XSFGetFile(where,prompt,fileFilter,numTypes,typeList,dlgHook,reply)
	XPoint		*where;
	XStr255		*prompt;
	XProcPtr		fileFilter;
	Xshort		numTypes;
	XSFTypeList	*typeList;
	XProcPtr		dlgHook;
	XSFReply		*reply;
	X{	
	X#asm
	X	MOVE.L	D0,A0			;Dereference Point since
	X					;structure size is smaller
	X					;than 33 bits
	X	MOVE.L	(A0),-(SP)	;where
	X	MOVE.L	D1,-(SP)	;prompt
	X	MOVE.L	D2,-(SP)	;fileFilter
	X	MOVE.W	D3,-(SP)	;numTypes
	X	MOVE.L	D4,-(SP)	;typeList
	X	MOVE.L	D5,-(SP)	;dlgHook
	X	MOVE.L	D6,-(SP)	;reply
	X	MOVE	#2,-(SP)	;routine selector for GetFile
	X	DC.W	$A9EA	;Pack3
	X#endasm
	X}
	X
	XSFPutFile(where,prompt,origName,dlgHook,reply)
	XPoint	*where;
	XStr255	*prompt;
	XStr255	*origName;
	XProcPtr	dlgHook;
	XSFReply	*reply;
	X{	
	X#asm
	X	MOVE.L	D0,A0			;Dereference Point since
	X					;structure size is smaller
	X					;than 33 bits
	X	MOVE.L	(A0),-(SP)	;where
	X	MOVE.L	D1,-(SP)	;prompt
	X	MOVE.L	D2,-(SP)	;origName
	X	MOVE.L	D3,-(SP)	;dlgHook
	X	MOVE.L	D4,-(SP)	;reply
	X	MOVE	#1,-(SP)	;routine selector for PutFile
	X	DC.W	$A9EA	;Pack3
	X#endasm
	X}
SHAR_EOF
if test 1056 -ne "`wc -c < 'SFLib.C'`"
then
	echo shar: error transmitting "'SFLib.C'" '(should have been 1056 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'VolStuff.c'" '(3439 characters)'
if test -f 'VolStuff.c'
then
	echo shar: will not over-write existing file "'VolStuff.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'VolStuff.c'
	X#Options M
	X#include "pbDefs.h"
	X
	X#define NIL 0
	X
	Xtypedef  struct PARAMBLK
	X    {
	X    long  int qLink;		// next queue entry
	X    short int qType;		// queue type
	X    short int ioTrap;		// routine trap
	X    long  int ioCmdAddr;	// routine address
	X    char     *ioCompletion;	// completion routine
	X    short int ioResult;		// result code
	X    char     *ioFileName;	// volume or file name
	X    short int ioVRefNum;	// volume reference or drive number
	X    short int ioRefNum;		// path reference number
	X    short int filler;		// not used
	X    short int ioVolIndex;	// volume index
	X    long  int ioVCrDate;	// date and time of initialization
	X    long  int ioVLsBkUp;	// date & time of last backup
	X    short int ioVAtrb;		// bit 15 = 1 if volume locked
	X    short int ioVNmFls;		// number of files
	X    short int ioVDirSt;		// first block of file directory
	X    short int ioVBlLn;		// number blocks in file directory
	X    short int ioVNmAlBlks;	// number alloc blocks in volume
	X    long  int ioVAlBlkSiz;	// number bytes per allocation block
	X    long  int ioVClpSiz;	// bytes to allocate
	X    short int ioAlBlSt;		// first block in vol block map
	X    long  int ioVNxtFNum;	// next free file number
	X    short int ioVFrBlk;		// number free alloc blocks
	X    };
	X
	X/*
	X * The trap name is _GetVolInfo but due to the 7 character limit
	X * in Apple's Pascal, PBGetVolInfo would evaluate to PBGetVol, so
	X * the names are PBGetVInfo and GetVInfo.  The Sybex book assumed that
	X * this was an error in the Mac C header files. Because of this
	X * I have modified my header files to define both versions.
	X * and called my library module by the correct name. -- Jim Budler
	X */
	X
	Xshort int GetVInfo(drvnum, vnam, vrefno, freeBytes)
	Xshort int drvnum;
	Xchar * vnam;
	Xshort int *vrefno;
	Xlong int * freeBytes;
	X{
	X	struct PARAMBLK myparamblk;
	X	short int retval;
	X
	X	myparamblk.ioCompletion = 0;
	X	myparamblk.ioVRefNum	= drvnum;
	X	if (vnam == (char *) -1)
	X	   myparamblk.ioVolIndex	= -1;
	X	else
	X	   myparamblk.ioVolIndex	= 0;
	X	myparamblk.ioFileName	= vnam;
	X	retval = PBGetVInfo(&myparamblk, 0);
	X	*freeBytes = (myparamblk.ioVFrBlk * myparamblk.ioVAlBlkSiz);
	X	*vrefno = myparamblk.ioVRefNum;
	X	vnam = myparamblk.ioFileName;
	X	return(retval);
	X
	X}
	X
	Xshort int GetVol(vnam, vrefno)
	Xchar * vnam;
	Xshort int * vrefno;
	X{
	X	struct PARAMBLK myparamblk;
	X	short int retval;
	X
	X	myparamblk.ioCompletion = 0;
	X	retval = PBGetVol(&myparamblk, 0);
	X	*vrefno = myparamblk.ioVRefNum;
	X	vnam = myparamblk.ioFileName;
	X	return(retval);
	X
	X}
	X
	Xshort int SetVol(vnam, vrefno)
	Xchar * vnam;
	Xshort int vrefno;
	X{
	X	struct PARAMBLK myparamblk;
	X	short int retval;
	X
	X	myparamblk.ioCompletion = 0;
	X	myparamblk.ioVRefNum	= vrefno;
	X	myparamblk.ioFileName	= vnam;
	X	return(PBSetVol(&myparamblk, 0));
	X
	X}
	X
	Xshort int FlushVol(vnam, vrefno)
	Xchar * vnam;
	Xshort int vrefno;
	X{
	X	struct PARAMBLK myparamblk;
	X	short int retval;
	X
	X	myparamblk.ioCompletion = 0;
	X	myparamblk.ioVRefNum	= vrefno;
	X	myparamblk.ioFileName	= vnam;
	X	return(PBFlshVol(&myparamblk, 0));
	X
	X}
	X
	Xshort int UnmountVol(vnam, vrefno)
	Xchar * vnam;
	Xshort int vrefno;
	X{
	X	struct PARAMBLK myparamblk;
	X	short int retval;
	X
	X	myparamblk.ioCompletion = 0;
	X	myparamblk.ioVRefNum	= vrefno;
	X	myparamblk.ioFileName	= vnam;
	X	return(PBUnmountVol(&myparamblk, 0));
	X
	X}
	X
	Xshort int Eject(vnam, vrefno)
	Xchar * vnam;
	Xshort int vrefno;
	X{
	X	struct PARAMBLK myparamblk;
	X	short int retval;
	X
	X	myparamblk.ioCompletion = 0;
	X	myparamblk.ioVRefNum	= vrefno;
	X	myparamblk.ioFileName	= vnam;
	X	return(PBEject(&myparamblk, 0));
	X
	X}
SHAR_EOF
if test 3439 -ne "`wc -c < 'VolStuff.c'`"
then
	echo shar: error transmitting "'VolStuff.c'" '(should have been 3439 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0
-- 
 Jim Budler
 Advanced Micro Devices, Inc.
 (408) 749-5806
 Usenet: {ucbvax,decwrl,ihnp4,allegra,intelca}!amdcad!jimb
 Compuserve:	72415,1200