home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
tarsrc.sit
/
tar.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-09-14
|
3KB
|
131 lines
/*
* Macintosh TAR
*
* Written by Craig Ruff
*
* Main routine and global variables.
*/
/*#define DEBUG*/
#include "tar.h"
#include <SegLoad.h>
#include <Resources.h>
#define FSFCBLen (*(short *) 0x3f6)
/*
* Global variable declarations
*/
Boolean autoPage = false; /* List by screenfulls */
Boolean cvtNl = false; /* Convert newline to return and back */
Boolean doneFlag = false; /* Quit item selected? */
Boolean doPrint = false; /* List to printer */
Boolean ignorez = false; /* Ignore zero blocks */
Boolean pOpen = false; /* Printer open? */
Boolean reblock = false; /* Read enough for a full block size buffer */
Boolean oldArch = false; /* Old tar compatible */
THPrint prRecHdl; /* Printer record (when printing) */
char *arName; /* Archive file name */
short arVRefNum; /* Archive file VRefNum */
short archive; /* File descriptor for archive file */
int blocking; /* Size of each block, in records */
int blockSize; /* Size of each block, in bytes */
char fdCreator[4]; /* Finder Creator */
char fdType[4]; /* Finder Type */
char header[128]; /* Common header for listings */
jmp_buf errJmp; /* For error exits */
main() {
WindowPtr wind;
EventRecord e;
Handle fTypeH;
/*
* Standard Mac Initializations
*/
InitGraf(&qd.thePort);
InitFonts();
FlushEvents(everyEvent, 0);
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
#ifdef DEBUG
/*
* So we don't keep copying resources into our application.
*/
if (OpenResFile("\pDD:tar:tar.rsrc") == -1) {
OSAlert("\pmain", "\pDebug OpenResFile", nil, 0);
ExitToShell();
}
#endif
/* Check for HFS running */
if (FSFCBLen <= 0) {
HFSAlert();
ExitToShell();
}
if (MenuInit())
ExitToShell();
blocking = 20;
blockSize = blocking * RECORDSIZE;
if ((fTypeH = GetResource('ftyp', 0)) == nil) {
strncpy(fdCreator, "????", 4);
strncpy(fdType, "TEXT", 4);
} else {
strncpy(fdCreator, *fTypeH, 4);
strncpy(fdType, (*fTypeH) + 4, 4);
ReleaseResource(fTypeH);
}
if ((prRecHdl = (THPrint) NewHandle((long) sizeof(TPrint))) == nil) {
OSAlert("\pmain", "\pNewHandle returned nil", nil, MemError());
ExitToShell();
}
sprintf(header, "T Size Date Name%*s", 40, "");
do {
SystemTask();
/* Should never have a window open while a DA is running */
if (!menusOK && (FrontWindow() == nil))
DDaMenus();
if (GetNextEvent(everyEvent, &e))
switch (e.what) {
case mouseDown:
switch (FindWindow(e.where, &wind)) {
case inSysWindow:
SystemClick(&e, wind);
break;
case inMenuBar:
MenuCmd(MenuSelect(e.where));
break;
}
break;
case keyDown:
case autoKey:
if (e.modifiers & cmdKey)
MenuCmd(MenuKey(e.message & charCodeMask));
break;
}
} while (!doneFlag);
if (pOpen)
PrClose();
ExitToShell();
}