/* OSGLUXWN.c Copyright (C) 2009 Michael Hanni, Christian Bauer, Stephan Kochen, Paul C. Pratt, and others You can redistribute this file and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. You should have received a copy of the license along with this file; see the file COPYING. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.*/ /* Operating System GLUe for X WiNdow system All operating system dependent code for the X Window System should go here. This code is descended from Michael Hanni's X port of vMac, by Philip Cummins. I learned more about how X programs work by looking at other programs such as Basilisk II, the UAE Amiga Emulator, Bochs, QuakeForge, DooM Legacy, and the FLTK. A few snippets from them are used here. Drag and Drop support is based on the specification "XDND: Drag-and-Drop Protocol for the X Window System" developed by John Lindal at New Planet Software, and looking at included examples, one by Paul Sheer.*/ #include "CNFGRAPI.h"#include "SYSDEPNS.h"#include "ENDIANAC.h" #include "MYOSGLUE.h" #include "STRCONST.h" /* --- some simple utilities --- */ GLOBALOSGLUPROC MyMoveBytes(anyp srcPtr, anyp destPtr, si5b byteCount){ (void) memcpy((char *)destPtr, (char *)srcPtr, byteCount);} /* --- control mode and internationalization --- */ #define NeedCell2PlainAsciiMap 1 #include "INTLCHAR.h" LOCALVAR char *d_arg = NULL;LOCALVAR char *n_arg = NULL; #if CanGetAppPathLOCALVAR char *app_parent = NULL;LOCALVAR char *app_name = NULL;#endif LOCALFUNC tMacErr ChildPath(char *x, char *y, char **r){ tMacErr err = mnvm_miscErr; int nx = strlen(x); int ny = strlen(y); { if ((nx > 0) && ('/' == x[nx - 1])) { --nx; } { int nr = nx + 1 + ny; char *p = malloc(nr + 1); if (p != NULL) { char *p2 = p; (void) memcpy(p2, x, nx); p2 += nx; *p2++ = '/'; (void) memcpy(p2, y, ny); p2 += ny; *p2 = 0; *r = p; err = mnvm_noErr; } } } return err;} #if UseActvFile || IncludeSonyNewLOCALFUNC tMacErr FindOrMakeChild(char *x, char *y, char **r){ tMacErr err; struct stat folder_info; char *r0; if (mnvm_noErr == (err = ChildPath(x, y, &r0))) { if (0 != stat(r0, &folder_info)) { if (0 != mkdir(r0, S_IRWXU)) { err = mnvm_miscErr; } else { *r = r0; err = mnvm_noErr; } } else { if (! S_ISDIR(folder_info.st_mode)) { err = mnvm_miscErr; } else { *r = r0; err = mnvm_noErr; } } } return err;}#endif LOCALPROC MyMayFree(char *p){ if (NULL != p) { free(p); }} /* --- sending debugging info to file --- */ #if dbglog_HAVE #define dbglog_ToStdErr 0 #if ! dbglog_ToStdErrLOCALVAR FILE *dbglog_File = NULL;#endif LOCALFUNC blnr dbglog_open0(void){#if dbglog_ToStdErr return trueblnr;#else dbglog_File = fopen("dbglog.txt", "w"); return (NULL != dbglog_File);#endif} LOCALPROC dbglog_write0(char *s, uimr L){#if dbglog_ToStdErr (void) fwrite(s, 1, L, stderr);#else if (dbglog_File != NULL) { (void) fwrite(s, 1, L, dbglog_File); }#endif} LOCALPROC dbglog_close0(void){#if ! dbglog_ToStdErr if (dbglog_File != NULL) { fclose(dbglog_File); dbglog_File = NULL; }#endif} #endif /* --- debug settings and utilities --- */ #if ! dbglog_HAVE#define WriteExtraErr(s)#elseLOCALPROC WriteExtraErr(char *s){ dbglog_writeCStr("*** error: "); dbglog_writeCStr(s); dbglog_writeReturn();}#endif LOCALVAR Display *x_display = NULL; #define MyDbgEvents (dbglog_HAVE && 0) #if MyDbgEventsLOCALPROC WriteDbgAtom(char *s, Atom x){ char *name = XGetAtomName(x_display, x); if (name != NULL) { dbglog_writeCStr("Atom "); dbglog_writeCStr(s); dbglog_writeCStr(": "); dbglog_writeCStr(name); dbglog_writeReturn(); XFree(name); }}#endif /* --- information about the environment --- */ LOCALVAR Atom MyXA_DeleteW = (Atom)0;#if EnableDragDropLOCALVAR Atom MyXA_UriList = (Atom)0;LOCALVAR Atom MyXA_DndAware = (Atom)0;LOCALVAR Atom MyXA_DndEnter = (Atom)0;LOCALVAR Atom MyXA_DndLeave = (Atom)0;LOCALVAR Atom MyXA_DndDrop = (Atom)0;LOCALVAR Atom MyXA_DndPosition = (Atom)0;LOCALVAR Atom MyXA_DndStatus = (Atom)0;LOCALVAR Atom MyXA_DndActionCopy = (Atom)0;LOCALVAR Atom MyXA_DndActionPrivate = (Atom)0;LOCALVAR Atom MyXA_DndSelection = (Atom)0;LOCALVAR Atom MyXA_DndFinished = (Atom)0;LOCALVAR Atom MyXA_MinivMac_DndXchng = (Atom)0;LOCALVAR Atom MyXA_NetActiveWindow = (Atom)0;LOCALVAR Atom MyXA_NetSupported = (Atom)0;#endif#if IncludeHostTextClipExchangeLOCALVAR Atom MyXA_CLIPBOARD = (Atom)0;LOCALVAR Atom MyXA_TARGETS = (Atom)0;LOCALVAR Atom MyXA_MinivMac_Clip = (Atom)0;#endif LOCALPROC LoadMyXA(void){ MyXA_DeleteW = XInternAtom(x_display, "WM_DELETE_WINDOW", False);#if EnableDragDrop MyXA_UriList = XInternAtom (x_display, "text/uri-list", False); MyXA_DndAware = XInternAtom (x_display, "XdndAware", False); MyXA_DndEnter = XInternAtom(x_display, "XdndEnter", False); MyXA_DndLeave = XInternAtom(x_display, "XdndLeave", False); MyXA_DndDrop = XInternAtom(x_display, "XdndDrop", False); MyXA_DndPosition = XInternAtom(x_display, "XdndPosition", False); MyXA_DndStatus = XInternAtom(x_display, "XdndStatus", False); MyXA_DndActionCopy = XInternAtom(x_display, "XdndActionCopy", False); MyXA_DndActionPrivate = XInternAtom(x_display, "XdndActionPrivate", False); MyXA_DndSelection = XInternAtom(x_display, "XdndSelection", False); MyXA_DndFinished = XInternAtom(x_display, "XdndFinished", False); MyXA_MinivMac_DndXchng = XInternAtom(x_display, "_MinivMac_DndXchng", False); MyXA_NetActiveWindow = XInternAtom(x_display, "_NET_ACTIVE_WINDOW", False); MyXA_NetSupported = XInternAtom(x_display, "_NET_SUPPORTED", False);#endif#if IncludeHostTextClipExchange MyXA_CLIPBOARD = XInternAtom(x_display, "CLIPBOARD", False); MyXA_TARGETS = XInternAtom(x_display, "TARGETS", False); MyXA_MinivMac_Clip = XInternAtom(x_display, "_MinivMac_Clip", False);#endif} #if EnableDragDropLOCALFUNC blnr NetSupportedContains(Atom x){ /* Note that the window manager could be replaced at any time, so don't cache results of this function. */ Atom ret_type; int ret_format; unsigned long ret_item; unsigned long remain_byte; unsigned long i; unsigned char *s = 0; blnr foundit = falseblnr; Window rootwin = XRootWindow(x_display, DefaultScreen(x_display)); if (Success != XGetWindowProperty(x_display, rootwin, MyXA_NetSupported, 0, 65535, False, XA_ATOM, &ret_type, &ret_format, &ret_item, &remain_byte, &s)) { WriteExtraErr("XGetWindowProperty failed"); } else if (! s) { WriteExtraErr("XGetWindowProperty failed"); } else if (ret_type != XA_ATOM) { WriteExtraErr("XGetWindowProperty returns wrong type"); } else { Atom *v = (Atom *)s; for (i = 0; i < ret_item; ++i) { if (v[i] == x) { foundit = trueblnr; /* fprintf(stderr, "found the hint\n"); */ } } } if (s) { XFree(s); } return foundit;}#endif #define WantColorTransValid 1 #include "COMOSGLU.h" #include "PBUFSTDC.h" #include "CONTROLM.h" /* --- text translation --- */ #if IncludePbufs/* this is table for Windows, any changes needed for X? */LOCALVAR const ui3b Native2MacRomanTab[] = { 0xAD, 0xB0, 0xE2, 0xC4, 0xE3, 0xC9, 0xA0, 0xE0, 0xF6, 0xE4, 0xB6, 0xDC, 0xCE, 0xB2, 0xB3, 0xB7, 0xB8, 0xD4, 0xD5, 0xD2, 0xD3, 0xA5, 0xD0, 0xD1, 0xF7, 0xAA, 0xC5, 0xDD, 0xCF, 0xB9, 0xC3, 0xD9, 0xCA, 0xC1, 0xA2, 0xA3, 0xDB, 0xB4, 0xBA, 0xA4, 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0xBD, 0xA8, 0xF8, 0xA1, 0xB1, 0xC6, 0xD7, 0xAB, 0xB5, 0xA6, 0xE1, 0xFC, 0xDA, 0xBC, 0xC8, 0xDE, 0xDF, 0xF0, 0xC0, 0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82, 0xE9, 0x83, 0xE6, 0xE8, 0xED, 0xEA, 0xEB, 0xEC, 0xF5, 0x84, 0xF1, 0xEE, 0xEF, 0xCD, 0x85, 0xF9, 0xAF, 0xF4, 0xF2, 0xF3, 0x86, 0xFA, 0xFB, 0xA7, 0x88, 0x87, 0x89, 0x8B, 0x8A, 0x8C, 0xBE, 0x8D, 0x8F, 0x8E, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95, 0xFD, 0x96, 0x98, 0x97, 0x99, 0x9B, 0x9A, 0xD6, 0xBF, 0x9D, 0x9C, 0x9E, 0x9F, 0xFE, 0xFF, 0xD8};#endif #if IncludePbufsLOCALFUNC tMacErr NativeTextToMacRomanPbuf(char *x, tPbuf *r){ if (NULL == x) { return mnvm_miscErr; } else { ui3p p; ui5b L = strlen(x); p = (ui3p)malloc(L); if (NULL == p) { return mnvm_miscErr; } else { ui3b *p0 = (ui3b *)x; ui3b *p1 = (ui3b *)p; int i; for (i = L; --i >= 0; ) { ui3b v = *p0++; if (v >= 128) { v = Native2MacRomanTab[v - 128]; } else if (10 == v) { v = 13; } *p1++ = v; } return PbufNewFromPtr(p, L, r); } }}#endif #if IncludePbufs/* this is table for Windows, any changes needed for X? */LOCALVAR const ui3b MacRoman2NativeTab[] = { 0xC4, 0xC5, 0xC7, 0xC9, 0xD1, 0xD6, 0xDC, 0xE1, 0xE0, 0xE2, 0xE4, 0xE3, 0xE5, 0xE7, 0xE9, 0xE8, 0xEA, 0xEB, 0xED, 0xEC, 0xEE, 0xEF, 0xF1, 0xF3, 0xF2, 0xF4, 0xF6, 0xF5, 0xFA, 0xF9, 0xFB, 0xFC, 0x86, 0xB0, 0xA2, 0xA3, 0xA7, 0x95, 0xB6, 0xDF, 0xAE, 0xA9, 0x99, 0xB4, 0xA8, 0x80, 0xC6, 0xD8, 0x81, 0xB1, 0x8D, 0x8E, 0xA5, 0xB5, 0x8A, 0x8F, 0x90, 0x9D, 0xA6, 0xAA, 0xBA, 0xAD, 0xE6, 0xF8, 0xBF, 0xA1, 0xAC, 0x9E, 0x83, 0x9A, 0xB2, 0xAB, 0xBB, 0x85, 0xA0, 0xC0, 0xC3, 0xD5, 0x8C, 0x9C, 0x96, 0x97, 0x93, 0x94, 0x91, 0x92, 0xF7, 0xB3, 0xFF, 0x9F, 0xB9, 0xA4, 0x8B, 0x9B, 0xBC, 0xBD, 0x87, 0xB7, 0x82, 0x84, 0x89, 0xC2, 0xCA, 0xC1, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, 0xCC, 0xD3, 0xD4, 0xBE, 0xD2, 0xDA, 0xDB, 0xD9, 0xD0, 0x88, 0x98, 0xAF, 0xD7, 0xDD, 0xDE, 0xB8, 0xF0, 0xFD, 0xFE};#endif #if IncludePbufsLOCALFUNC blnr MacRomanTextToNativePtr(tPbuf i, blnr IsFileName, ui3p *r){ ui3p p; void *Buffer = PbufDat[i]; ui5b L = PbufSize[i]; p = (ui3p)malloc(L + 1); if (p != NULL) { ui3b *p0 = (ui3b *)Buffer; ui3b *p1 = (ui3b *)p; int j; if (IsFileName) { for (j = L; --j >= 0; ) { ui3b x = *p0++; if (x < 32) { x = '-'; } else if (x >= 128) { x = MacRoman2NativeTab[x - 128]; } else { switch (x) { case '/': case '<': case '>': case '|': case ':': x = '-'; default: break; } } *p1++ = x; } if ('.' == p[0]) { p[0] = '-'; } } else { for (j = L; --j >= 0; ) { ui3b x = *p0++; if (x >= 128) { x = MacRoman2NativeTab[x - 128]; } else if (13 == x) { x = '\n'; } *p1++ = x; } } *p1 = 0; *r = p; return trueblnr; } return falseblnr;}#endif LOCALPROC NativeStrFromCStr(char *r, char *s){ ui3b ps[ClStrMaxLength]; int i; int L; ClStrFromSubstCStr(&L, ps, s); for (i = 0; i < L; ++i) { r[i] = Cell2PlainAsciiMap[ps[i]]; } r[L] = 0;} /* --- drives --- */ #define NotAfileRef NULL LOCALVAR FILE *Drives[NumDrives]; /* open disk image files */#if IncludeSonyGetName || IncludeSonyNewLOCALVAR char *DriveNames[NumDrives];#endif LOCALPROC InitDrives(void){ /* This isn't really needed, Drives[i] and DriveNames[i] need not have valid values when not vSonyIsInserted[i]. */ tDrive i; for (i = 0; i < NumDrives; ++i) { Drives[i] = NotAfileRef;#if IncludeSonyGetName || IncludeSonyNew DriveNames[i] = NULL;#endif }} GLOBALOSGLUFUNC tMacErr vSonyTransfer(blnr IsWrite, ui3p Buffer, tDrive Drive_No, ui5r Sony_Start, ui5r Sony_Count, ui5r *Sony_ActCount){ tMacErr err = mnvm_miscErr; FILE *refnum = Drives[Drive_No]; ui5r NewSony_Count = 0;Lines 1–500 of 4839. Load more
/* OSGLUXWN.c Copyright (C) 2009 Michael Hanni, Christian Bauer, Stephan Kochen, Paul C. Pratt, and others You can redistribute this file and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. You should have received a copy of the license along with this file; see the file COPYING. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /* Operating System GLUe for X WiNdow system All operating system dependent code for the X Window System should go here. This code is descended from Michael Hanni's X port of vMac, by Philip Cummins. I learned more about how X programs work by looking at other programs such as Basilisk II, the UAE Amiga Emulator, Bochs, QuakeForge, DooM Legacy, and the FLTK. A few snippets from them are used here. Drag and Drop support is based on the specification "XDND: Drag-and-Drop Protocol for the X Window System" developed by John Lindal at New Planet Software, and looking at included examples, one by Paul Sheer. */ #include "CNFGRAPI.h" #include "SYSDEPNS.h" #include "ENDIANAC.h" #include "MYOSGLUE.h" #include "STRCONST.h" /* --- some simple utilities --- */ GLOBALOSGLUPROC MyMoveBytes(anyp srcPtr, anyp destPtr, si5b byteCount) { (void) memcpy((char *)destPtr, (char *)srcPtr, byteCount); } /* --- control mode and internationalization --- */ #define NeedCell2PlainAsciiMap 1 #include "INTLCHAR.h" LOCALVAR char *d_arg = NULL; LOCALVAR char *n_arg = NULL; #if CanGetAppPath LOCALVAR char *app_parent = NULL; LOCALVAR char *app_name = NULL; #endif LOCALFUNC tMacErr ChildPath(char *x, char *y, char **r) { tMacErr err = mnvm_miscErr; int nx = strlen(x); int ny = strlen(y); { if ((nx > 0) && ('/' == x[nx - 1])) { --nx; } { int nr = nx + 1 + ny; char *p = malloc(nr + 1); if (p != NULL) { char *p2 = p; (void) memcpy(p2, x, nx); p2 += nx; *p2++ = '/'; (void) memcpy(p2, y, ny); p2 += ny; *p2 = 0; *r = p; err = mnvm_noErr; } } } return err; } #if UseActvFile || IncludeSonyNew LOCALFUNC tMacErr FindOrMakeChild(char *x, char *y, char **r) { tMacErr err; struct stat folder_info; char *r0; if (mnvm_noErr == (err = ChildPath(x, y, &r0))) { if (0 != stat(r0, &folder_info)) { if (0 != mkdir(r0, S_IRWXU)) { err = mnvm_miscErr; } else { *r = r0; err = mnvm_noErr; } } else { if (! S_ISDIR(folder_info.st_mode)) { err = mnvm_miscErr; } else { *r = r0; err = mnvm_noErr; } } } return err; } #endif LOCALPROC MyMayFree(char *p) { if (NULL != p) { free(p); } } /* --- sending debugging info to file --- */ #if dbglog_HAVE #define dbglog_ToStdErr 0 #if ! dbglog_ToStdErr LOCALVAR FILE *dbglog_File = NULL; #endif LOCALFUNC blnr dbglog_open0(void) { #if dbglog_ToStdErr return trueblnr; #else dbglog_File = fopen("dbglog.txt", "w"); return (NULL != dbglog_File); #endif } LOCALPROC dbglog_write0(char *s, uimr L) { #if dbglog_ToStdErr (void) fwrite(s, 1, L, stderr); #else if (dbglog_File != NULL) { (void) fwrite(s, 1, L, dbglog_File); } #endif } LOCALPROC dbglog_close0(void) { #if ! dbglog_ToStdErr if (dbglog_File != NULL) { fclose(dbglog_File); dbglog_File = NULL; } #endif } #endif /* --- debug settings and utilities --- */ #if ! dbglog_HAVE #define WriteExtraErr(s) #else LOCALPROC WriteExtraErr(char *s) { dbglog_writeCStr("*** error: "); dbglog_writeCStr(s); dbglog_writeReturn(); } #endif LOCALVAR Display *x_display = NULL; #define MyDbgEvents (dbglog_HAVE && 0) #if MyDbgEvents LOCALPROC WriteDbgAtom(char *s, Atom x) { char *name = XGetAtomName(x_display, x); if (name != NULL) { dbglog_writeCStr("Atom "); dbglog_writeCStr(s); dbglog_writeCStr(": "); dbglog_writeCStr(name); dbglog_writeReturn(); XFree(name); } } #endif /* --- information about the environment --- */ LOCALVAR Atom MyXA_DeleteW = (Atom)0; #if EnableDragDrop LOCALVAR Atom MyXA_UriList = (Atom)0; LOCALVAR Atom MyXA_DndAware = (Atom)0; LOCALVAR Atom MyXA_DndEnter = (Atom)0; LOCALVAR Atom MyXA_DndLeave = (Atom)0; LOCALVAR Atom MyXA_DndDrop = (Atom)0; LOCALVAR Atom MyXA_DndPosition = (Atom)0; LOCALVAR Atom MyXA_DndStatus = (Atom)0; LOCALVAR Atom MyXA_DndActionCopy = (Atom)0; LOCALVAR Atom MyXA_DndActionPrivate = (Atom)0; LOCALVAR Atom MyXA_DndSelection = (Atom)0; LOCALVAR Atom MyXA_DndFinished = (Atom)0; LOCALVAR Atom MyXA_MinivMac_DndXchng = (Atom)0; LOCALVAR Atom MyXA_NetActiveWindow = (Atom)0; LOCALVAR Atom MyXA_NetSupported = (Atom)0; #endif #if IncludeHostTextClipExchange LOCALVAR Atom MyXA_CLIPBOARD = (Atom)0; LOCALVAR Atom MyXA_TARGETS = (Atom)0; LOCALVAR Atom MyXA_MinivMac_Clip = (Atom)0; #endif LOCALPROC LoadMyXA(void) { MyXA_DeleteW = XInternAtom(x_display, "WM_DELETE_WINDOW", False); #if EnableDragDrop MyXA_UriList = XInternAtom (x_display, "text/uri-list", False); MyXA_DndAware = XInternAtom (x_display, "XdndAware", False); MyXA_DndEnter = XInternAtom(x_display, "XdndEnter", False); MyXA_DndLeave = XInternAtom(x_display, "XdndLeave", False); MyXA_DndDrop = XInternAtom(x_display, "XdndDrop", False); MyXA_DndPosition = XInternAtom(x_display, "XdndPosition", False); MyXA_DndStatus = XInternAtom(x_display, "XdndStatus", False); MyXA_DndActionCopy = XInternAtom(x_display, "XdndActionCopy", False); MyXA_DndActionPrivate = XInternAtom(x_display, "XdndActionPrivate", False); MyXA_DndSelection = XInternAtom(x_display, "XdndSelection", False); MyXA_DndFinished = XInternAtom(x_display, "XdndFinished", False); MyXA_MinivMac_DndXchng = XInternAtom(x_display, "_MinivMac_DndXchng", False); MyXA_NetActiveWindow = XInternAtom(x_display, "_NET_ACTIVE_WINDOW", False); MyXA_NetSupported = XInternAtom(x_display, "_NET_SUPPORTED", False); #endif #if IncludeHostTextClipExchange MyXA_CLIPBOARD = XInternAtom(x_display, "CLIPBOARD", False); MyXA_TARGETS = XInternAtom(x_display, "TARGETS", False); MyXA_MinivMac_Clip = XInternAtom(x_display, "_MinivMac_Clip", False); #endif } #if EnableDragDrop LOCALFUNC blnr NetSupportedContains(Atom x) { /* Note that the window manager could be replaced at any time, so don't cache results of this function. */ Atom ret_type; int ret_format; unsigned long ret_item; unsigned long remain_byte; unsigned long i; unsigned char *s = 0; blnr foundit = falseblnr; Window rootwin = XRootWindow(x_display, DefaultScreen(x_display)); if (Success != XGetWindowProperty(x_display, rootwin, MyXA_NetSupported, 0, 65535, False, XA_ATOM, &ret_type, &ret_format, &ret_item, &remain_byte, &s)) { WriteExtraErr("XGetWindowProperty failed"); } else if (! s) { WriteExtraErr("XGetWindowProperty failed"); } else if (ret_type != XA_ATOM) { WriteExtraErr("XGetWindowProperty returns wrong type"); } else { Atom *v = (Atom *)s; for (i = 0; i < ret_item; ++i) { if (v[i] == x) { foundit = trueblnr; /* fprintf(stderr, "found the hint\n"); */ } } } if (s) { XFree(s); } return foundit; } #endif #define WantColorTransValid 1 #include "COMOSGLU.h" #include "PBUFSTDC.h" #include "CONTROLM.h" /* --- text translation --- */ #if IncludePbufs /* this is table for Windows, any changes needed for X? */ LOCALVAR const ui3b Native2MacRomanTab[] = { 0xAD, 0xB0, 0xE2, 0xC4, 0xE3, 0xC9, 0xA0, 0xE0, 0xF6, 0xE4, 0xB6, 0xDC, 0xCE, 0xB2, 0xB3, 0xB7, 0xB8, 0xD4, 0xD5, 0xD2, 0xD3, 0xA5, 0xD0, 0xD1, 0xF7, 0xAA, 0xC5, 0xDD, 0xCF, 0xB9, 0xC3, 0xD9, 0xCA, 0xC1, 0xA2, 0xA3, 0xDB, 0xB4, 0xBA, 0xA4, 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0xBD, 0xA8, 0xF8, 0xA1, 0xB1, 0xC6, 0xD7, 0xAB, 0xB5, 0xA6, 0xE1, 0xFC, 0xDA, 0xBC, 0xC8, 0xDE, 0xDF, 0xF0, 0xC0, 0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82, 0xE9, 0x83, 0xE6, 0xE8, 0xED, 0xEA, 0xEB, 0xEC, 0xF5, 0x84, 0xF1, 0xEE, 0xEF, 0xCD, 0x85, 0xF9, 0xAF, 0xF4, 0xF2, 0xF3, 0x86, 0xFA, 0xFB, 0xA7, 0x88, 0x87, 0x89, 0x8B, 0x8A, 0x8C, 0xBE, 0x8D, 0x8F, 0x8E, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95, 0xFD, 0x96, 0x98, 0x97, 0x99, 0x9B, 0x9A, 0xD6, 0xBF, 0x9D, 0x9C, 0x9E, 0x9F, 0xFE, 0xFF, 0xD8 }; #endif #if IncludePbufs LOCALFUNC tMacErr NativeTextToMacRomanPbuf(char *x, tPbuf *r) { if (NULL == x) { return mnvm_miscErr; } else { ui3p p; ui5b L = strlen(x); p = (ui3p)malloc(L); if (NULL == p) { return mnvm_miscErr; } else { ui3b *p0 = (ui3b *)x; ui3b *p1 = (ui3b *)p; int i; for (i = L; --i >= 0; ) { ui3b v = *p0++; if (v >= 128) { v = Native2MacRomanTab[v - 128]; } else if (10 == v) { v = 13; } *p1++ = v; } return PbufNewFromPtr(p, L, r); } } } #endif #if IncludePbufs /* this is table for Windows, any changes needed for X? */ LOCALVAR const ui3b MacRoman2NativeTab[] = { 0xC4, 0xC5, 0xC7, 0xC9, 0xD1, 0xD6, 0xDC, 0xE1, 0xE0, 0xE2, 0xE4, 0xE3, 0xE5, 0xE7, 0xE9, 0xE8, 0xEA, 0xEB, 0xED, 0xEC, 0xEE, 0xEF, 0xF1, 0xF3, 0xF2, 0xF4, 0xF6, 0xF5, 0xFA, 0xF9, 0xFB, 0xFC, 0x86, 0xB0, 0xA2, 0xA3, 0xA7, 0x95, 0xB6, 0xDF, 0xAE, 0xA9, 0x99, 0xB4, 0xA8, 0x80, 0xC6, 0xD8, 0x81, 0xB1, 0x8D, 0x8E, 0xA5, 0xB5, 0x8A, 0x8F, 0x90, 0x9D, 0xA6, 0xAA, 0xBA, 0xAD, 0xE6, 0xF8, 0xBF, 0xA1, 0xAC, 0x9E, 0x83, 0x9A, 0xB2, 0xAB, 0xBB, 0x85, 0xA0, 0xC0, 0xC3, 0xD5, 0x8C, 0x9C, 0x96, 0x97, 0x93, 0x94, 0x91, 0x92, 0xF7, 0xB3, 0xFF, 0x9F, 0xB9, 0xA4, 0x8B, 0x9B, 0xBC, 0xBD, 0x87, 0xB7, 0x82, 0x84, 0x89, 0xC2, 0xCA, 0xC1, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, 0xCC, 0xD3, 0xD4, 0xBE, 0xD2, 0xDA, 0xDB, 0xD9, 0xD0, 0x88, 0x98, 0xAF, 0xD7, 0xDD, 0xDE, 0xB8, 0xF0, 0xFD, 0xFE }; #endif #if IncludePbufs LOCALFUNC blnr MacRomanTextToNativePtr(tPbuf i, blnr IsFileName, ui3p *r) { ui3p p; void *Buffer = PbufDat[i]; ui5b L = PbufSize[i]; p = (ui3p)malloc(L + 1); if (p != NULL) { ui3b *p0 = (ui3b *)Buffer; ui3b *p1 = (ui3b *)p; int j; if (IsFileName) { for (j = L; --j >= 0; ) { ui3b x = *p0++; if (x < 32) { x = '-'; } else if (x >= 128) { x = MacRoman2NativeTab[x - 128]; } else { switch (x) { case '/': case '<': case '>': case '|': case ':': x = '-'; default: break; } } *p1++ = x; } if ('.' == p[0]) { p[0] = '-'; } } else { for (j = L; --j >= 0; ) { ui3b x = *p0++; if (x >= 128) { x = MacRoman2NativeTab[x - 128]; } else if (13 == x) { x = '\n'; } *p1++ = x; } } *p1 = 0; *r = p; return trueblnr; } return falseblnr; } #endif LOCALPROC NativeStrFromCStr(char *r, char *s) { ui3b ps[ClStrMaxLength]; int i; int L; ClStrFromSubstCStr(&L, ps, s); for (i = 0; i < L; ++i) { r[i] = Cell2PlainAsciiMap[ps[i]]; } r[L] = 0; } /* --- drives --- */ #define NotAfileRef NULL LOCALVAR FILE *Drives[NumDrives]; /* open disk image files */ #if IncludeSonyGetName || IncludeSonyNew LOCALVAR char *DriveNames[NumDrives]; #endif LOCALPROC InitDrives(void) { /* This isn't really needed, Drives[i] and DriveNames[i] need not have valid values when not vSonyIsInserted[i]. */ tDrive i; for (i = 0; i < NumDrives; ++i) { Drives[i] = NotAfileRef; #if IncludeSonyGetName || IncludeSonyNew DriveNames[i] = NULL; #endif } } GLOBALOSGLUFUNC tMacErr vSonyTransfer(blnr IsWrite, ui3p Buffer, tDrive Drive_No, ui5r Sony_Start, ui5r Sony_Count, ui5r *Sony_ActCount) { tMacErr err = mnvm_miscErr; FILE *refnum = Drives[Drive_No]; ui5r NewSony_Count = 0;