home *** CD-ROM | disk | FTP | other *** search
- #include <Dialogs.h>
- #include <Events.h>
- #include <Files.h>
- #include <Stdlib.h>
- #include <Types.h>
- #include "ui.h"
-
- int read(int fd, char * p, unsigned long n)
- {
- if (fd == 0) {
- return DoRead(p, n);
- } else {
- return mpw_read(fd, p, n);
- }
- }
-
- int write(int fd, char * p, unsigned long n)
- {
- if (fd == 1 || fd == 2) {
- DoWrite(CAMLPrinter, p, n);
- return n;
- } else {
- return mpw_write(fd, p, n);
- }
- }
-
- void exit(int status)
- {
- if (status != 0) {
- NoteAlert(140, 0);
- while(1) {
- LookEvent(15);
- }
- } else {
- Quit();
- }
- }
-
- static int maxcount = 30;
- static int count = 30;
- static unsigned long lastdate = 0;
-
- pascal void SpinCursor(short delta)
- {
- #pragma unused(delta)
-
- unsigned long date;
-
- --count;
- if (count == 0){
- LookEvent (0);
- date = TickCount ();
- if (date - lastdate < 15 && maxcount < 50) ++maxcount;
- if (date - lastdate > 15 && maxcount > 10) --maxcount;
- count = maxcount;
- }
- }
-
- char *get_wd_name (short wd_refnum, char *postfix)
- {
- char buf [64];
- char *temp, *result;
- DirInfo cinfo;
- WDPBRec wd;
-
- wd.ioCompletion = NULL;
- wd.ioNamePtr = NULL;
- wd.ioVRefNum = wd_refnum;
- wd.ioWDIndex = 0;
- wd.ioWDProcID = 0;
- wd.ioWDVRefNum = 0;
- if (PBGetWDInfo (&wd, 0) != noErr) return postfix;
- cinfo.ioDrParID = wd.ioWDDirID;
- result = malloc (strlen (postfix) + 1);
- if (result == NULL) return postfix;
- strcpy (result, postfix);
- do{
- cinfo.ioCompletion = NULL;
- cinfo.ioNamePtr = buf;
- cinfo.ioVRefNum = wd.ioWDVRefNum;
- cinfo.ioFDirIndex = -1;
- cinfo.ioDrDirID = cinfo.ioDrParID;
- if (PBGetCatInfo ((CInfoPBPtr) &cinfo, 0) != noErr) return postfix;
- p2cstr (buf);
- temp = malloc (strlen (result) + strlen (buf) + 2);
- if (temp == NULL){
- free (result);
- return postfix;
- }
- sprintf (temp, ":%s%s", buf, result);
- free (result);
- result = temp;
- }while (cinfo.ioDrDirID != 2);
- return result + 1;
- }
-
- extern int sub_main (int argc, char *argv []);
-
- main (int argc, char *argv [])
- {
- #pragma unused (argc)
- char *new_argv [4];
- WDPBRec wd;
-
- Initialize ();
- new_argv [0] = argv [0];
- new_argv [1] = "-stdlib";
- wd.ioCompletion = NULL;
- wd.ioNamePtr = NULL;
- if (PBHGetVol (&wd, 0) != noErr){
- new_argv [2] = ":lib:";
- }else{
- new_argv [2] = get_wd_name (wd.ioVRefNum, ":lib:");
- }
- new_argv [3] = NULL;
- return sub_main (3, new_argv);
- }
-