Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!hplabs!felix!dhw68k!macintosh
From: cruff@ncar.ucar.edu (Craig Ruff)
Newsgroups: comp.sources.mac
Subject: Tar 1.1 Source (part 1 of 3)
Message-ID: <7889@dhw68k.cts.com>
Date: 12 May 88 02:14:22 GMT
Sender: macintosh@dhw68k.cts.com
Organization: Scientific Computing Division/NCAR, Boulder CO
Lines: 1176
Approved: bytebug@dhw68k.cts.com (Roger L. Long)

[Tar 1.1 Source - part 1 of 3]

[Moderator's Note:  The Tar 1.1 binary will be posted in comp.binaries.mac.]

---
#! /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:
#	README
#	Makefile
#	tar.h
#	tar.c
#	tar.resource
#	buffer.c
# This archive created: Wed May 11 07:24:03 1988
# By:	Roger L. Long (bytebug@dhw68k.cts.com)
export PATH; PATH=/bin:$PATH
echo shar: extracting "'README'" '(355 characters)'
if test -f 'README'
then
	echo shar: will not over-write existing file "'README'"
else
sed 's/^X//' << \SHAR_EOF > 'README'
X		Tar for the Macintosh
X
XThese files make up the sources of tar for the Macintosh.  I used Aztec C
Xv3.4b to compile the program.  I then used ResEdit to copy the (compiled)
Xresources to the application.  The file tar.resource contains the decompiled
Xresources.  This was done with ResTools 3.00.  You can use that program
Xor Rez to rebuild the resources.
SHAR_EOF
if test 355 -ne "`wc -c < 'README'`"
then
	echo shar: error transmitting "'README'" '(should have been 355 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'Makefile'" '(244 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
XOBJECTS = buffer.o create.o dialog.o dir.o extract.o list.o menu.o tar.o window.o
X
Xtar:	$(OBJECTS) hdrs.dmp
X	ln -W -o tar -M ../lib3/sacroot.o $(OBJECTS) -lc
X
X$(OBJECTS): hdrs.dmp
X	cc +Ihdrs.dmp -o $@ $*.c
X
Xhdrs.dmp: tar.h
X	cc +Hhdrs.dmp tar.h
SHAR_EOF
if test 244 -ne "`wc -c < 'Makefile'`"
then
	echo shar: error transmitting "'Makefile'" '(should have been 244 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'tar.h'" '(3783 characters)'
if test -f 'tar.h'
then
	echo shar: will not over-write existing file "'tar.h'"
else
sed 's/^X//' << \SHAR_EOF > 'tar.h'
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X#include 
X
X#ifndef NIL
X#define NIL	(0L)
X#endif
X
X#ifndef EOF
X#define EOF	(-1L)
X#endif
X
X#define DIRECTORY(pb)	(((pb).ioFlAttrib & 0x10) == 0x10)
X
X/*
X * Character definitions
X */
X#define ENTER	0x03
X#define BS	0x08
X#define TAB	0x09
X#define	RETURN	0x0d
X
X/*
X * Difference between Mac and Unix times
X */
X#define TIMEDIFF	0x7c25b080
X
X/*
X * Global Variables
X */
Xextern Boolean	autoPage;
Xextern Boolean	cvtNl;
Xextern Boolean	doneFlag;
Xextern Boolean	doPrint;
Xextern Boolean	ignorez;
Xextern Boolean	menusOK;
Xextern Boolean	pOpen;
X
Xextern char	fdCreator[];
Xextern char	fdType[];
Xextern char	header[];
X
Xextern jmp_buf	errJmp;
X
Xextern THPrint	prRecHdl;
X
X/*
X * Standard File and GetDir saved outputs
X */
Xextern char	*arName;
Xextern short	arVRefNum;
Xextern long	dirDirID;
Xextern short	dirVRefNum;
X
X/*
X * External routines
X */
Xextern Boolean	GetDir();
Xextern Boolean	MenuInit();
Xextern Boolean	PrSetup();
Xextern Boolean	WindInit();
X
X/*
X * Remainder taken from:
X * Header file for public domain tar (tape archive) program.
X *
X * @(#)tar.h 1.20 86/10/29	Public Domain.
X *
X * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
X */
X
X/*
X * Header block on tape.
X *
X * I'm going to use traditional DP naming conventions here.
X * A "block" is a big chunk of stuff that we do I/O on.
X * A "record" is a piece of info that we care about.
X * Typically many "record"s fit into a "block".
X */
X#define	RECORDSIZE	512
X#define	NAMSIZ	100
X#define	TUNMLEN	32
X#define	TGNMLEN	32
X
Xunion record {
X	char		charptr[RECORDSIZE];
X	struct header {
X		char	name[NAMSIZ];
X		char	mode[8];
X		char	uid[8];
X		char	gid[8];
X		char	size[12];
X		char	mtime[12];
X		char	chksum[8];
X		char	linkflag;
X		char	linkname[NAMSIZ];
X		char	magic[8];
X		char	uname[TUNMLEN];
X		char	gname[TGNMLEN];
X		char	devmajor[8];
X		char	devminor[8];
X	} header;
X};
X
X/* The checksum field is filled with this while the checksum is computed. */
X#define	CHKBLANKS	"        "	/* 8 blanks, no null */
X
X/* The magic field is filled with this if uname and gname are valid. */
X#define	TMAGIC		"ustar  "	/* 7 chars and a null */
X
X/* The linkflag defines the type of file */
X#define	LF_OLDNORMAL	'\0'		/* Normal disk file, Unix compat */
X#define	LF_NORMAL	'0'		/* Normal disk file */
X#define	LF_LINK		'1'		/* Link to previously dumped file */
X#define	LF_SYMLINK	'2'		/* Symbolic link */
X#define	LF_CHR		'3'		/* Character special file */
X#define	LF_BLK		'4'		/* Block special file */
X#define	LF_DIR		'5'		/* Directory */
X#define	LF_FIFO		'6'		/* FIFO special file */
X#define	LF_CONTIG	'7'		/* Contiguous file */
X/* Further link types may be defined later. */
X
X/*
X * Global variables
X */
Xextern int		blocking;	/* Size of each block, in records */
Xextern int		blockSize;	/* Size of each block, in bytes */
Xextern Boolean		reblock;
Xextern Boolean		oldArch;
X
X/*
X * We now default to Unix Standard format rather than 4.2BSD tar format.
X * The code can actually produce all three:
X *	standard	ANSI standard
X *	oldarch		V7
X *	neither		4.2BSD
X * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
X * The only advantage to the "neither" option is that we can cmp(1) our
X * output to the output of 4.2BSD tar, for debugging.
X */
X#define	standard	(!oldArch)
X
Xextern short	archive;	/* File descriptor for archive file */
X
X/*
X * Declarations of functions available to the world.
X */
Xunion record	*FindRec();
Xvoid		UseRec();
Xunion record	*EndOfRecs();
XBoolean		OpenArchive();
SHAR_EOF
if test 3783 -ne "`wc -c < 'tar.h'`"
then
	echo shar: error transmitting "'tar.h'" '(should have been 3783 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'tar.c'" '(2669 characters)'
if test -f 'tar.c'
then
	echo shar: will not over-write existing file "'tar.c'"
else
sed 's/^X//' << \SHAR_EOF > 'tar.c'
X/*
X * Macintosh TAR
X *
X * Written by Craig Ruff
X *
X * Main routine and global variables.
X */
X
X#include "tar.h"
X#include 
X
X#ifdef DEBUG
X#include 
X#endif
X
X#define FSFCBLen	(*(short *) 0x3f6)
X
X/*
X * Global variable declarations
X */
XBoolean autoPage = FALSE;	/* List by screenfulls */
XBoolean cvtNl = FALSE;		/* Convert newline to return and back */
XBoolean doneFlag = FALSE;	/* Quit item selected? */
XBoolean doPrint = FALSE;	/* List to printer */
XBoolean ignorez = FALSE;	/* Ignore zero blocks */
XBoolean	pOpen = FALSE;		/* Printer open? */
XBoolean reblock = FALSE;	/* Read enough for a full block size buffer */
XBoolean oldArch = FALSE;	/* Old tar compatible */
X
XTHPrint	prRecHdl;		/* Printer record (when printing) */
X
Xchar	*arName;		/* Archive file name */
Xshort	arVRefNum;		/* Archive file VRefNum */
X
Xshort	archive;		/* File descriptor for archive file */
Xint	blocking;		/* Size of each block, in records */
Xint	blockSize;		/* Size of each block, in bytes */
X
Xchar	fdCreator[4];		/* Finder Creator */
Xchar	fdType[4];		/* Finder Type */
Xchar	header[128];		/* Common header for listings */
Xjmp_buf	errJmp;			/* For error exits */
X
Xmain() {
X	WindowPtr	wind;
X	EventRecord	e;
X
X	/*
X	 * Standard Mac Initializations
X	 */
X	InitGraf(&thePort);
X	InitFonts();
X	FlushEvents(everyEvent, 0);
X	InitWindows();
X	InitMenus();
X	TEInit();
X	InitDialogs(NIL);
X	InitCursor();
X
X#ifdef DEBUG
X	/*
X	 * So we don't keep copying resources into our application.
X	 */
X	if (OpenResFile("\Psys:C:tar:tar.rsrc") == -1) {
X		OSAlert("\Pmain", "\PDebug OpenResFile", NIL, 0);
X		ExitToShell();
X	}
X#endif
X
X	/* Check for HFS running */
X	if (FSFCBLen <= 0) {
X		HFSAlert();
X		ExitToShell();
X	}
X
X	if (MenuInit())
X		ExitToShell();
X
X	blocking = 20;
X	blockSize = blocking * RECORDSIZE;
X	strncpy(fdCreator, "????", 4);
X	strncpy(fdType, "TEXT", 4);
X	if ((prRecHdl = (THPrint) NewHandle((long) sizeof(TPrint))) == NIL) {
X		OSAlert("\Pmain", "\PNewHandle returned NIL", NIL, MemError());
X		ExitToShell();
X	}
X
X	sprintf(header, "T     Size Date              Name%*s", 40, "");
X	do {
X		SystemTask();
X		/* Should never have a window open while a DA is running */
X		if (!menusOK && (FrontWindow() == NIL))
X			DDaMenus();
X
X		if (GetNextEvent(everyEvent, &e))
X			switch (e.what) {
X			case mouseDown:
X				switch (FindWindow(pass(e.where), &wind)) {
X				case inSysWindow:
X					SystemClick(&e, wind);
X					break;
X
X				case inMenuBar:
X					MenuCmd(MenuSelect(pass(e.where)));
X					break;
X
X				}
X				break;
X
X			case keyDown:
X			case autoKey:
X				if (e.modifiers & cmdKey)
X					MenuCmd(MenuKey(e.message & charCodeMask));
X				break;
X			}
X
X	} while (!doneFlag);
X
X	if (pOpen)
X		PrClose();
X
X	ExitToShell();
X}
SHAR_EOF
if test 2669 -ne "`wc -c < 'tar.c'`"
then
	echo shar: error transmitting "'tar.c'" '(should have been 2669 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'tar.resource'" '(10649 characters)'
if test -f 'tar.resource'
then
	echo shar: will not over-write existing file "'tar.resource'"
else
sed 's/^X//' << \SHAR_EOF > 'tar.resource'
Xresource  'PICT' (128, purgeable)
X{
X    474,
X    {7, 7, 114, 254},
X    {17; 1; 160; 0; 130; 161; 0; 150; 0; 6; 5; 0; 0
X    ; 0; 2; 152; 161; 0; 154; 0; 8; 255; 252; 0; 0
X    ; 0; 69; 0; 0; 160; 0; 152; 1; 0; 10; 0; 7
X    ; 0; 7; 0; 114; 0; 254; 3; 0; 2; 13; 0; 12
X    ; 43; 11; 22; 21; 84; 97; 114; 32; 102; 111; 114; 32
X    ; 116; 104; 101; 32; 77; 97; 99; 105; 110; 116; 111; 115
X    ; 104; 160; 0; 153; 160; 0; 151; 161; 0; 150; 0; 6
X    ; 5; 0; 0; 0; 2; 152; 161; 0; 154; 0; 8; 0
X    ; 26; 0; 0; 0; 120; 0; 0; 160; 0; 152; 13; 0
X    ; 10; 42; 27; 34; 87; 114; 105; 116; 116; 101; 110; 32
X    ; 98; 121; 32; 67; 114; 97; 105; 103; 32; 82; 117; 102
X    ; 102; 32; 119; 105; 116; 104; 32; 101; 120; 99; 101; 114
X    ; 112; 116; 41; 191; 7; 115; 32; 102; 114; 111; 109; 13
X    ; 160; 0; 153; 161; 0; 154; 0; 8; 0; 14; 0; 0
X    ; 0; 120; 0; 0; 160; 0; 152; 40; 0; 61; 0; 11
X    ; 34; 74; 111; 104; 110; 32; 71; 105; 108; 109; 111; 114
X    ; 101; 39; 115; 32; 112; 117; 98; 108; 105; 99; 32; 100
X    ; 111; 109; 97; 105; 110; 32; 116; 97; 114; 32; 112; 41
X    ; 191; 8; 114; 111; 103; 114; 97; 109; 46; 13; 160; 0
X    ; 153; 161; 0; 154; 0; 8; 0; 2; 0; 0; 0; 120
X    ; 0; 0; 160; 0; 152; 40; 0; 73; 0; 11; 1; 13
X    ; 160; 0; 153; 161; 0; 154; 0; 8; 255; 246; 0; 0
X    ; 0; 120; 0; 0; 160; 0; 152; 42; 12; 34; 84; 104
X    ; 105; 115; 32; 112; 114; 111; 103; 114; 97; 109; 32; 105
X    ; 115; 32; 112; 117; 98; 108; 105; 99; 32; 100; 111; 109
X    ; 97; 105; 110; 46; 32; 32; 78; 111; 41; 190; 9; 32
X    ; 102; 101; 101; 32; 109; 97; 121; 13; 160; 0; 153; 161
X    ; 0; 154; 0; 8; 255; 234; 0; 0; 0; 120; 0; 0
X    ; 160; 0; 152; 40; 0; 97; 0; 11; 34; 98; 101; 32
X    ; 99; 104; 97; 114; 103; 101; 100; 32; 102; 111; 114; 32
X    ; 97; 32; 99; 111; 112; 121; 32; 111; 102; 32; 116; 104
X    ; 105; 115; 32; 112; 114; 111; 103; 41; 186; 8; 114; 97
X    ; 109; 32; 97; 110; 100; 13; 160; 0; 153; 161; 0; 154
X    ; 0; 8; 255; 222; 0; 0; 0; 120; 0; 0; 160; 0
X    ; 152; 40; 0; 109; 0; 11; 34; 100; 105; 115; 116; 114
X    ; 105; 98; 117; 116; 105; 111; 110; 32; 109; 97; 121; 32
X    ; 110; 111; 116; 32; 98; 101; 32; 114; 101; 115; 116; 114
X    ; 105; 99; 116; 101; 100; 41; 184; 1; 46; 160; 0; 153
X    ; 160; 0; 151; 160; 0; 131; 255}
X};
X
Xuserdefined resource  'TAR ' (0)
X{
X    long:0x8546172;
X    long:0x2076312e;
X    byte:49};
X
Xresource  'BNDL' (128)
X{
X    'TAR ',     0,
X    {
X    'ICN#', {0, 128; 1, 129};
X    'FREF', {0, 128; 1, 129}
X    }
X};
X
Xresource  'FREF' (128)
X{
X    'APPL',
X    0,
X    ""
X};
X
Xresource  'FREF' (129)
X{
X    'TARF',
X    1,
X    ""
X};
X
Xresource  'ICN#' (128)
X{
X    0xffff 0xffff 0x8000 0x0001 
X    0x8780 0x01e1 0x8840 0x0211 
X    0x97a0 0x0409 0xafd0 0x0805 
X    0xafd0 0x08c5 0xafd0 0x08c5 
X    0xafd0 0x0805 0x97a0 0x0409 
X    0x8840 0x0211 0x8f80 0x01e1 
X    0x8400 0x0041 0x8200 0x0081 
X    0x810f 0xf101 0x8088 0x1201 
X    0x8048 0x1401 0x8027 0xe801 
X    0x801f 0xf001 0x8000 0x0001 
X    0x8000 0x0001 0x8000 0x0001 
X    0x80f9 0xcf01 0x8022 0x2881 
X    0x8022 0x2881 0x8023 0xef01 
X    0x8022 0x2901 0x8022 0x2881 
X    0x8022 0x2881 0x8000 0x0001 
X    0x8000 0x0001 0xffff 0xffff ;
X
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X    0xffff 0xffff 0xffff 0xffff 
X};
X
Xresource  'ICN#' (129)
X{
X    0x0000 0x0000 0x0000 0x0000 
X    0x000f 0xf000 0x0030 0x0c00 
X    0x00c0 0x0300 0x0100 0x0080 
X    0x0200 0x0040 0x0400 0x0020 
X    0x0800 0x0010 0x0800 0x0010 
X    0x1000 0x0008 0x1000 0x0008 
X    0x21f3 0x9e04 0x2044 0x5104 
X    0x2044 0x5104 0x2047 0xde04 
X    0x2044 0x5204 0x2044 0x5104 
X    0x2044 0x5104 0x2000 0x0004 
X    0x1000 0x0008 0x1000 0x0008 
X    0x0800 0x0010 0x0800 0x0010 
X    0x0400 0x0020 0x0200 0x0040 
X    0x0100 0x0080 0x00c0 0x0300 
X    0x0030 0x0c00 0x000f 0xfffc 
X    0x0000 0x0000 0x0000 0x0000 ;
X
X    0x0000 0x0000 0x0000 0x0000 
X    0x000f 0xf000 0x003f 0xfc00 
X    0x00ff 0xff00 0x01ff 0xff80 
X    0x03ff 0xffc0 0x07ff 0xffe0 
X    0x0fff 0xfff0 0x0fff 0xfff0 
X    0x1fff 0xfff8 0x1fff 0xfff8 
X    0x3fff 0xfffc 0x3fff 0xfffc 
X    0x3fff 0xfffc 0x3fff 0xfffc 
X    0x3fff 0xfffc 0x3fff 0xfffc 
X    0x3fff 0xfffc 0x3fff 0xfffc 
X    0x1fff 0xfff8 0x1fff 0xfff8 
X    0x0fff 0xfff0 0x0fff 0xfff0 
X    0x07ff 0xffe0 0x03ff 0xffc0 
X    0x01ff 0xff80 0x00ff 0xff00 
X    0x003f 0xfc00 0x000f 0xfffc 
X    0x0000 0x0000 0x0000 0x0000 
X};
X
Xresource  'WIND' (129)
X{
X    {40, 20, 320, 480},
X    1,
X    visible,
X    noGoAway,
X    0x0,
X    ""
X};
X
Xresource  'ALRT' (129, purgeable)
X{
X    {50, 65, 140, 385},
X    192,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0
X};
X
Xresource  'ALRT' (130, purgeable)
X{
X    {50, 65, 200, 385},
X    193,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0
X};
X
Xresource  'ALRT' (131, purgeable)
X{
X    {50, 65, 200, 385},
X    194,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0
X};
X
Xresource  'ALRT' (132, purgeable)
X{
X    {50, 65, 140, 385},
X    195,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0
X};
X
Xresource  'ALRT' (133, purgeable)
X{
X    {50, 65, 140, 385},
X    196,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0
X};
X
Xresource  'ALRT' (134, purgeable)
X{
X    {50, 65, 140, 385},
X    197,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0,
X    OK,visible,0
X};
X
Xresource  'DITL' (129, purgeable)
X{
X  {
X    {15, 200, 37, 260},
X      Button {enabled, "OK"};
X    {50, 200, 74, 260},
X      Button {enabled, "Cancel"};
X    {40, 80, 55, 121},
X      EditText {enabled, ""};
X    {15, 40, 35, 159},
X      StaticText {enabled, "Enter block size:"}
X  }
X};
X
Xresource  'DITL' (192, purgeable)
X{
X  {
X    {60, 124, 80, 184},
X      Button {enabled, "OK"};
X    {9, 67, 49, 256},
X      StaticText {enabled, "Block size must be between 1 and 128 inclusive!"}
X  }
X};
X
Xresource  'DITL' (130, purgeable)
X{
X  {
X    {35, 15, 56, 160},
X      Button {enabled, ""};
X    {179, 256, 200, 336},
X      Button {enabled, "Cancel"};
X    {55, 247, 75, 341},
X      StaticText {disabled, ""};
X    {67, 456, 85, 536},
X      Button {disabled, "Eject"};
X    {93, 456, 111, 536},
X      Button {disabled, "Drive"};
X    {65, 15, 210, 230},
X      Useritem {enabled, 7215};
X    {141, 252, 142, 339},
X      Useritem {disabled, 8274};
X    {35, 168, 56, 228},
X      Button {enabled, "UP"};
X    {151, 256, 172, 336},
X      Button {enabled, "Open"};
X    {7, 15, 28, 339},
X      StaticText {enabled, "Select directory ^0:"};
X    {83, 256, 104, 336},
X      Button {enabled, "Drive"};
X    {111, 256, 132, 336},
X      Button {enabled, "Eject"}
X  }
X};
X
Xresource  'DITL' (193, purgeable)
X{
X  {
X    {121, 126, 141, 186},
X      Button {enabled, "OK"};
X    {10, 68, 57, 311},
X      StaticText {enabled, "^0: ^1"};
X    {60, 69, 91, 313},
X      StaticText {enabled, "^2"};
X    {96, 80, 116, 200},
X      StaticText {enabled, "OS Error: ^3"}
X  }
X};
X
Xresource  'DITL' (194, purgeable)
X{
X  {
X    {122, 123, 142, 183},
X      Button {enabled, "OK"};
X    {9, 99, 28, 289},
X      StaticText {enabled, "^0: ^1"};
X    {35, 100, 91, 289},
X      StaticText {enabled, "^2"};
X    {95, 101, 115, 289},
X      StaticText {enabled, "^3"}
X  }
X};
X
Xresource  'DITL' (195, purgeable)
X{
X  {
X    {60, 124, 80, 184},
X      Button {enabled, "OK"};
X    {9, 92, 49, 221},
X      StaticText {enabled, "Macintosh Tar only works with HFS."}
X  }
X};
X
Xresource  'DITL' (196)
X{
X  {
X    {63, 130, 83, 190},
X      Button {enabled, "OK"};
X    {9, 81, 56, 266},
X      StaticText {enabled, "Skipping archive file (it is within the directory being archived)."}
X  }
X};
X
Xresource  'DITL' (197)
X{
X  {
X    {63, 130, 83, 190},
X      Button {enabled, "OK"};
X    {9, 81, 56, 266},
X      StaticText {enabled, "Overrun of stack in window print (can't continue)!"}
X  }
X};
X
Xresource  'DITL' (131, purgeable)
X{
X  {
X    {78, 43, 98, 103},
X      Button {enabled, "OK"};
X    {79, 182, 99, 242},
X      Button {enabled, "Cancel"};
X    {13, 114, 33, 174},
X      EditText {enabled, ""};
X    {45, 114, 65, 174},
X      EditText {enabled, ""};
X    {13, 38, 33, 98},
X      StaticText {enabled, "Creator:"};
X    {44, 58, 65, 100},
X      StaticText {enabled, "Type:"}
X  }
X};
X
Xresource  'DITL' (128, purgeable)
X{
X  {
X    {130, 74, 150, 134},
X      Button {enabled, "OK"};
X    {7, 7, 114, 254},
X      Picture {enabled, 128}
X  }
X};
X
Xresource  'DLOG' (128, purgeable)
X{
X    {68, 112, 240, 380},
X    1,
X    visible,
X    noGoAway,
X    0x0,
X    128,
X    "About TAR"
X};
X
Xresource  'DLOG' (130, purgeable)
X{
X    {60, 75, 275, 423},
X    1,
X    invisible,
X    noGoAway,
X    0x0,
X    130,
X    ""
X};
X
Xresource  'DLOG' (129, purgeable)
X{
X    {44, 75, 144, 375},
X    1,
X    visible,
X    noGoAway,
X    0x0,
X    129,
X    "Block Size"
X};
X
Xresource  'DLOG' (131, purgeable)
X{
X    {44, 75, 144, 375},
X    1,
X    visible,
X    goAway,
X    0x0,
X    131,
X    "New Dialog"
X};
X
Xresource  'MENU' (128, preLoad)
X{
X    128,
X    0,
X    0xfffffffb,
X    enabled,
X    "\024",
X    {
X    "About Tar...", noIcon, noKey, noMark, plain;
X    "-", noIcon, noKey, noMark, plain
X    }
X};
X
Xresource  'MENU' (129)
X{
X    129,
X    0,
X    0xffffff6f,
X    enabled,
X    "File",
X    {
X    "Create...", noIcon, noKey, noMark, plain;
X    "Extract...", noIcon, noKey, noMark, plain;
X    "List...", noIcon, noKey, noMark, plain;
X    "-", noIcon, noKey, noMark, plain;
X    "Close", noIcon, noKey, noMark, plain;
X    "Page Setup...", noIcon, noKey, noMark, plain;
X    "-", noIcon, noKey, noMark, plain;
X    "Quit", noIcon, noKey, noMark, plain
X    }
X};
X
Xresource  'MENU' (130, preLoad)
X{
X    130,
X    0,
X    0xfffffffb,
X    enabled,
X    "Edit",
X    {
X    "Undo", noIcon, 'Z', noMark, plain;
X    "-", noIcon, noKey, noMark, plain;
X    "Cut", noIcon, 'X', noMark, plain;
X    "Copy", noIcon, 'C', noMark, plain;
X    "Paste", noIcon, 'V', noMark, plain;
X    "Clear", noIcon, noKey, noMark, plain
X    }
X};
X
Xresource  'MENU' (131)
X{
X    131,
X    0,
X    0xffffff6f,
X    enabled,
X    "Options",
X    {
X    "Convert Newlines", noIcon, noKey, noMark, plain;
X    "Old Tar Compatible", noIcon, noKey, noMark, plain;
X    "Block Size...", noIcon, noKey, noMark, plain;
X    "-", noIcon, noKey, noMark, plain;
X    "Page Screen Listings", noIcon, noKey, noMark, plain;
X    "List to Printer", noIcon, noKey, noMark, plain;
X    "-", noIcon, noKey, noMark, plain;
X    "Set Creator/Type...", noIcon, noKey, noMark, plain
X    }
X};
X
SHAR_EOF
if test 10649 -ne "`wc -c < 'tar.resource'`"
then
	echo shar: error transmitting "'tar.resource'" '(should have been 10649 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'buffer.c'" '(6263 characters)'
if test -f 'buffer.c'
then
	echo shar: will not over-write existing file "'buffer.c'"
else
sed 's/^X//' << \SHAR_EOF > 'buffer.c'
X/*
X * Macintosh Tar
X *
X * Modified by Craig Ruff for use on the Macintosh.
X */
X/*
X * Buffer management for public domain tar.
X *
X * Written by John Gilmore, ihnp4!hoptoad!gnu, on 25 August 1985.
X *
X * @(#) buffer.c 1.14 10/28/86 Public Domain - gnu
X *
X */
X
X#include "tar.h"
X
Xunion record	*arBlock;	/* Start of block of archive */
Xunion record	*arRecord;	/* Current record of archive */
Xunion record	*arLast;	/* Last+1 record of archive block */
Xchar		arReading;	/* 0 writing, !0 reading archive */
X
X/*
X * The record pointed to by save_rec should not be overlaid
X * when reading in a new tape block.  Copy it to record_save_area first, and
X * change the pointer in *save_rec to point to record_save_area.
X * Saved_recno records the record number at the time of the save.
X * This is used by annofile() to print the record number of a file's
X * header record.
X */
Xstatic union record **saveRec;
Xstatic union record recordSaveArea;
Xstatic int	    savedRecno;
X
X/*
X * Record number of the start of this block of records
X */
Xstatic int	baseRec;
X
X/*
X * Return the location of the next available input or output record.
X */
Xunion record *
XFindRec()
X{
X	if (arRecord == arLast) {
X		FlushArchive();
X		if (arRecord == arLast)
X			return((union record *) NIL);	/* EOF */
X	}
X
X	return(arRecord);
X}
X
X/*
X * Indicate that we have used all records up thru the argument.
X * (should the arg have an off-by-1? XXX FIXME)
X */
Xvoid
XUseRec(rec)
Xunion record *rec;
X{
X	while (rec >= arRecord)
X		arRecord++;
X	/*
X	 * Do NOT flush the archive here.  If we do, the same
X	 * argument to userec() could mean the next record (if the
X	 * input block is exactly one record long), which is not what
X	 * is intended.
X	 */
X	if (arRecord > arLast) {
X		PgmAlert("\PUseRec", "\ParRecord > arLast", NIL, NIL);
X		longjmp(errJmp, 1);
X	}
X}
X
X/*
X * Return a pointer to the end of the current records buffer.
X * All the space between findrec() and endofrecs() is available
X * for filling with data, or taking data from.
X */
Xunion record *
XEndOfRecs()
X{
X	return(arLast);
X}
X
X/*
X * Open an archive file.  The argument specifies whether we are
X * reading or writing.
X */
XBoolean
XOpenArchive(read)
Xint	read;
X{
X	OSErr	err;
X	char	*routine = "\POpenArchive";
X
X	/*
X	 * Get a block buffer for use later
X	 */
X	arBlock = (union record *) NewPtr((Size) blockSize);
X	if (arBlock == NIL) {
X		OSAlert(routine, "\RNewPtr", NIL, MemError());
X		return(TRUE);
X	}
X
X	arRecord = arBlock;
X	arLast   = arBlock + blocking;
X
X	/*
X	 * Try and open the archive file.
X	 */
X	if (read) {
X		err = FSOpen(arName, arVRefNum, &archive);
X
X	} else {
X		if ((err = Create(arName, arVRefNum, (OSType)'TAR ', (OSType)'TARF'))
X				== noErr) {
X			err = FSOpen(arName, arVRefNum, &archive);
X		}
X	}
X
X	if (err != noErr) {
X		OSAlert(routine, "\PFSOpen or FSCreate", arName, err);
X		DisposPtr(arBlock);
X		archive = 0;
X		return(TRUE);
X	}
X
X	arReading = read;
X	if (read) {
X		arLast = arBlock;		/* Set up for 1st block = # 0 */
X		FlushArchive();
X	}
X
X	return(FALSE);
X}
X
X/*
X * Remember a union record * as pointing to something that we
X * need to keep when reading onward in the file.  Only one such
X * thing can be remembered at once, and it only works when reading
X * an archive.
X */
XSaveRec(pointer)
Xunion record	**pointer;
X{
X	saveRec = pointer;
X	savedRecno = baseRec + arRecord - arBlock;
X}
X
X/*
X * Perform a write to flush the buffer.
X */
XFlWrite()
X{
X	OSErr	err;
X	long	count;
X
X	count = blockSize;
X	err = FSWrite(archive, &count, arBlock->charptr);
X	if ((err == noErr) && (count == blockSize))
X		return;
X
X	/* FIXME, multi volume support on write goes here */
X	OSAlert("\PFLWrite", "\PFSRead", NIL, err);
X	longjmp(errJmp, 1);
X}
X
X/*
X * Perform a read to flush the buffer.
X */
XFlRead()
X{
X	OSErr	err;		/* Result from system call */
X	long	count;
X	int	left;		/* Bytes left */
X	char	*more;		/* Pointer to next byte to read */
X	char	*routine = "\PFlRead";
X
X	/*
X	 * If we are about to wipe out a record that
X	 * somebody needs to keep, copy it out to a holding
X	 * area and adjust somebody's pointer to it.
X	 */
X	if (saveRec &&
X	    *saveRec >= arRecord &&
X	    *saveRec < arLast) {
X		recordSaveArea = **saveRec;
X		*saveRec = &recordSaveArea;
X	}
X
X	count = blockSize;
X	err = FSRead(archive, &count, arBlock->charptr);
X	if ((err == noErr) && (count == blockSize))
X		return;
X
X	else if ((err != noErr) && (err != eofErr)) {
X		OSAlert("\PReadError", "\PFSRead", NIL, err);
X		longjmp(errJmp, 1);
X	}
X
X	more = arBlock->charptr + count;
X	left = blockSize - count;
X
Xagain:
X	if (0 == (((unsigned)left) % RECORDSIZE)) {
X		/* FIXME, for size=0, multi vol support */
X		/* On the first block, warn about the problem */
X		if (!reblock && baseRec == 0) {
X			char	buf[80];
X
X			sprintf(&buf[1], "Blocksize = %ld records",
X					count / (long) RECORDSIZE);
X			buf[0] = strlen(&buf[1]);
X			PgmAlert(routine, buf, NIL, NIL);
X		}
X
X		arLast = arBlock + ((unsigned)(blockSize - left))/RECORDSIZE;
X		return;
X	}
X
X	if (reblock) {
X		/*
X		 * User warned us about this.  Fix up.
X		 */
X		if (left > 0) {
X			count = left;
X			err = FSRead(archive, &count, more);
X			if ((err != noErr) && (err != eofErr)) {
X				OSAlert("\PReadError", "\PFSRead", NIL, err);
X				longjmp(errJmp, 1);
X			}
X			if ((count == 0) || (err = eofErr)) {
X				PgmAlert(routine, "\PEof not on block boundary",
X						NIL, NIL);
X				longjmp(errJmp, 1);
X			}
X			left -= count;
X			more += count;
X			goto again;
X		}
X	} else {
X		PgmAlert(routine, "\PDid not read blocksize bytes", NIL, NIL);
X		longjmp(errJmp, 1);
X	}
X}
X
X/*
X * Flush the current buffer to/from the archive.
X */
XFlushArchive()
X{
X	baseRec += arLast - arBlock;/* Keep track of block #s */
X	arRecord = arBlock;		/* Restore pointer to start */
X	arLast = arBlock + blocking;	/* Restore pointer to end */
X
X	if (!arReading) 
X		FlWrite();
X	else
X		FlRead();
X}
X
X/*
X * Close the archive file.
X */
XCloseArchive()
X{
X	if (!arReading)
X		FlushArchive();
X
X	DisposPtr(arBlock);
X	if (archive != 0)
X		(void) FSClose(archive);
X
X	archive = 0;
X}
X
X/*
X * bcopy and bzero compatability routines.
X * These could (should) potentially be done with the Mac traps.
X */
Xchar *
Xbcopy(s1, s2, n)
Xchar *s1, *s2;
Xregister int n;
X{
X	register char *s = s1;
X	register char *d = s2;
X
X	while (--n >= 0)
X		*d++ = *s++;
X
X	return(s1);
X}
X
Xvoid
Xbzero (s1, n)
Xregister char *s1;
Xregister int n;
X{
X	while (--n >= 0)
X		*s1++ = 0;
X}
SHAR_EOF
if test 6263 -ne "`wc -c < 'buffer.c'`"
then
	echo shar: error transmitting "'buffer.c'" '(should have been 6263 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0
--- end of part 1 ---