#include #include #include #include #include "unixmac.h" #include "Files.h" #include #include "sys/time.h" #include "console.h" int _wakeup = 0; int macSleepTicks = 10; int macRunTicks = 5; static long int macLastTicks = 0; /*int utimes(char* fn, void*) { FileParam pb; char pfn[256]; strncpy(pfn, fn, 255); c2pstr(pfn); pb.ioCompletion = NULL; pb.ioVRefNum = NULL; pb.ioFVersNum = 0; pb.ioFDirIndex = 0; pb.ioNamePtr = (StringPtr) &pfn; PBGetFInfo((ParmBlkPtr)&pb, FALSE); GetDateTime(&(pb.ioFlMdDat)); PBSetFInfo((ParmBlkPtr)&pb, FALSE); return 0; } */ /* unsigned int sleep(unsigned int secs) { unsigned long int startTime, endTime, sleepTime, time; EventRecord theEvent; GetDateTime(&startTime); endTime = startTime + secs; time = startTime; while ((time < endTime) && !_wakeup) { sleepTime = 60 * (endTime - time); if (WaitNextEvent(everyEvent, &theEvent,sleepTime,0)) SIOUXHandleOneEvent(&theEvent); GetDateTime(&time); } return 0; } */ void yield() { EventRecord theEvent; long int ticks = LMGetTicks(); if (ticks - macLastTicks >= macRunTicks) { if (WaitNextEvent(everyEvent, &theEvent,macSleepTicks,0)) SIOUXHandleOneEvent(&theEvent); macLastTicks = LMGetTicks(); } } pid_t fork() { return 0; } int link(char*, char*) {return 0;} char* sys_errlist[1]; void InitToolBox() { InitGraf(&qd.thePort); // Toolbox Managers InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); } #ifdef __mac__ #define SEP ':' #else #define SEP '/' #endif char * basename(char * path) { char* p = path; while (*p) p++; while (p>=path && *p != SEP) p--; p++; return p; } int kill(int , int ) {return 0;} int gettimeofday(struct timeval *tp, struct timezone */*tzp*/) { tp->tv_usec = 0; tp->tv_sec = time(NULL); return 0; } #define MAX_ARGS 100 static char argStr[65535]; static char *argv[MAX_ARGS + 1]; static int ParseArgs(char *s) { int n = 1, Quote = 0; char *p = s, *p1, c; p1 = (char *) argStr; while ((c = *p++) != 0) { if (c==' ') continue; argv[n++] = p1; if (n > MAX_ARGS) /* mm 970404 */ return (n-1); /* mm 970404 */ do { if (c=='\\' && *p++) c = *p++; else if ((c=='"') || (c == '\'')) { if (!Quote) { Quote = c; continue; } if (c == Quote) { Quote = 0; continue; } } *p1++ = c; } while (*p && ((c = *p++) != ' ' || Quote)); *p1++ = 0; } return n; } int xccommand(char ***arg) { long len; char* argument; int n = ccommand(arg); if (n==1 && (*arg)[1][0] == '@') { FILE* f = fopen((*arg)[1]+1,"r"); fseek(f, 0, SEEK_END); len = ftell(f); fseek(f, 0, SEEK_SET); argument = (char*) malloc(len+1); fread(argument, 1, len, f); n = ParseArgs(argument); } return n; }