From 04543deb6c064f49c7bb05efac876800f216b502 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 13 Dec 2002 15:05:00 +0000 Subject: Compatibility files that haven't been used in a long time. --- Mac/Compat/chdir.c | 42 --------------- Mac/Compat/dirent.h | 23 --------- Mac/Compat/getbootvol.c | 18 ------- Mac/Compat/getwd.c | 102 ------------------------------------ Mac/Compat/macgetmtime.c | 44 ---------------- Mac/Compat/macstat.c | 63 ---------------------- Mac/Compat/macstat.h | 34 ------------ Mac/Compat/mkdir.c | 28 ---------- Mac/Compat/nfullpath.c | 75 --------------------------- Mac/Compat/nfullpath.h | 1 - Mac/Compat/opendir.c | 132 ----------------------------------------------- Mac/Compat/rmdir.c | 20 ------- 12 files changed, 582 deletions(-) delete mode 100644 Mac/Compat/chdir.c delete mode 100644 Mac/Compat/dirent.h delete mode 100644 Mac/Compat/getbootvol.c delete mode 100644 Mac/Compat/getwd.c delete mode 100644 Mac/Compat/macgetmtime.c delete mode 100644 Mac/Compat/macstat.c delete mode 100644 Mac/Compat/macstat.h delete mode 100644 Mac/Compat/mkdir.c delete mode 100644 Mac/Compat/nfullpath.c delete mode 100644 Mac/Compat/nfullpath.h delete mode 100644 Mac/Compat/opendir.c delete mode 100644 Mac/Compat/rmdir.c diff --git a/Mac/Compat/chdir.c b/Mac/Compat/chdir.c deleted file mode 100644 index 0560800..0000000 --- a/Mac/Compat/chdir.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Chdir for the Macintosh. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Pathnames must be Macintosh paths, with colons as separators. */ - -#include "macdefs.h" - -#ifdef __MWERKS__ -/* XXXX All compilers should use this, really */ -#include -#else -/* Last directory used by Standard File */ -#define SFSaveDisk (*(short *)0x214) -#define CurDirStore (*(long *)0x398) -#endif - -/* Change current directory. */ - -int -chdir(path) - char *path; -{ - WDPBRec pb; - - pb.ioNamePtr= (StringPtr) Pstring(path); - pb.ioVRefNum= 0; - pb.ioWDDirID= 0; - if (PBHSetVol(&pb, FALSE) != noErr) { - errno= ENOENT; - return -1; - } - if (PBHGetVol(&pb, FALSE) == noErr) { - /* Set the Standard File directory */ -#ifdef __MWERKS__ - LMSetSFSaveDisk(-pb.ioWDVRefNum); - LMSetCurDirStore(pb.ioWDDirID); -#else - SFSaveDisk= -pb.ioWDVRefNum; - CurDirStore= pb.ioWDDirID; -#endif - } - return 0; -} diff --git a/Mac/Compat/dirent.h b/Mac/Compat/dirent.h deleted file mode 100644 index 7cfe404..0000000 --- a/Mac/Compat/dirent.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * "Dir.h" for the Macintosh. - * Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - */ - -#define MAXNAMLEN 31 -#define MAXPATH 256 - -#define DIR struct _dir - -struct _dir { - short vrefnum; - long dirid; - int nextfile; -}; - -struct dirent { - char d_name[MAXPATH]; -}; - -extern DIR *opendir(char *); -extern struct dirent *readdir(DIR *); -extern void closedir(DIR *); diff --git a/Mac/Compat/getbootvol.c b/Mac/Compat/getbootvol.c deleted file mode 100644 index df450c6..0000000 --- a/Mac/Compat/getbootvol.c +++ /dev/null @@ -1,18 +0,0 @@ -/* Return the name of the boot volume (not the current directory). - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). -*/ - -#include "macdefs.h" - -char * -getbootvol(void) -{ - short vrefnum; - static unsigned char name[32]; - - (void) GetVol(name, &vrefnum); - p2cstr(name); - /* Shouldn't fail; return ":" if it does */ - strcat((char *)name, ":"); - return (char *)name; -} diff --git a/Mac/Compat/getwd.c b/Mac/Compat/getwd.c deleted file mode 100644 index 738d756..0000000 --- a/Mac/Compat/getwd.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Get full pathname of current working directory. The pathname is - copied to the parameter array 'cwd', and a pointer to this array - is also returned as function result. If an error occurred, however, - the return value is NULL but 'cwd' is filled with an error message. - - BUG: expect spectacular crashes when called from a directory whose - path would be over MAXPATH bytes long (files in such directories are - not reachable by full pathname). - - Starting with the dir ID returned by PBHGetVol, we do successive - PBGetCatInfo's to get a component of the path until we reach the - root (recognized by a dir ID of 2). We move up along the path - using the dir ID of the parent directory returned by PBGetCatInfo. - - Then we catenate the components found in reverse order with the volume - name (already gotten from PBHGetVol), with intervening and trailing - colons - - The code works correctly on MFS disks (where it always returns the - volume name) by simply skipping the PBGetCatinfo calls in that case. - There is a 'bug' in PBGetCatInfo when called for an MFS disk (with - HFS running): it then seems to call PBHGetVInfo, which returns a - larger parameter block. But we won't run into this problem because - we never call PBGetCatInfo for the root (assuming that PBHGetVol - still sets the root ID in this case). - - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). -*/ - -#include "macdefs.h" -#include - -#define ROOTID 2 /* Root directory ID */ - -char * -getwd(char *cwd) -{ - /* Universal parameter block. */ - union { - struct HFileInfo f; - struct DirInfo d; - struct WDPBRec w; - } pb; - char buf[MAXPATH]; /* Buffer to store the name components */ - char *ecwd, *ebuf; /* Pointers to end of used part of cwd and buf */ - int err; /* Error code of last I/O call */ - - /* First, get the default volume name and working directory ID. */ - - pb.w.ioNamePtr= (unsigned char *)cwd; - err= PBHGetVolSync(&pb.w); - if (err != noErr) { - sprintf(cwd, "I/O error %d in PBHGetVolSync", err); - return NULL; - } - p2cstrcpy(cwd, (StringPtr)cwd); - ecwd = strchr(cwd, EOS); - ebuf= buf; - *ebuf = EOS; - - /* Next, if at least we're running HFS, walk up the path. */ - - { - long dirid= pb.w.ioWDDirID; - pb.d.ioVRefNum= pb.w.ioWDVRefNum; - while (dirid != ROOTID) { - pb.d.ioNamePtr= (unsigned char *) ++ebuf; - pb.d.ioFDirIndex= -1; - pb.d.ioDrDirID= dirid; - err= PBGetCatInfoSync((CInfoPBPtr)&pb.d); - if (err != noErr) { - sprintf(cwd, "I/O error %d in PBGetCatInfoSync", err); - return NULL; - } - dirid= pb.d.ioDrParID; - p2cstrcpy(ebuf, (StringPtr)ebuf); - ebuf += strlen(ebuf); - /* Should check for buf overflow */ - } - } - - /* Finally, reverse the list of components and append it to cwd. - Ebuf points at the EOS after last component, - and there is an EOS before the first component. - If there are no components, ebuf equals buf (but there - is still an EOS where it points). - Ecwd points at the EOS after the path built up so far, - initially the volume name. - We break out of the loop in the middle, thus - appending a colon at the end in all cases. */ - - for (;;) { - *ecwd++ = ':'; - if (ebuf == buf) - break; - do { } while (*--ebuf != EOS); /* Find component start */ - strcpy(ecwd, ebuf+1); - ecwd= strchr(ecwd, EOS); - } - *ecwd= EOS; - return cwd; -} diff --git a/Mac/Compat/macgetmtime.c b/Mac/Compat/macgetmtime.c deleted file mode 100644 index c270834..0000000 --- a/Mac/Compat/macgetmtime.c +++ /dev/null @@ -1,44 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -#include "macstat.h" - -/* Interfaced used by import.c */ - -long -getmtime(path) - char *path; -{ - struct macstat st; - if (macstat(path, &st) != 0) - return -1L; - return st.st_mtime; -} diff --git a/Mac/Compat/macstat.c b/Mac/Compat/macstat.c deleted file mode 100644 index ee2c099..0000000 --- a/Mac/Compat/macstat.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Minimal 'stat' emulation: tells directories from files and - gives length and mtime. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Updated to give more info, August 1994. -*/ - -#include "macstat.h" -#include "macdefs.h" - -/* Bits in ioFlAttrib: */ -#define LOCKBIT (1<<0) /* File locked */ -#define DIRBIT (1<<4) /* It's a directory */ - -int -macstat(path, buf) - char *path; - struct macstat *buf; -{ - union { - DirInfo d; - FileParam f; - HFileInfo hf; - } pb; - short err; - - pb.d.ioNamePtr = (unsigned char *)Pstring(path); - pb.d.ioVRefNum = 0; - pb.d.ioFDirIndex = 0; - pb.d.ioDrDirID = 0; - pb.f.ioFVersNum = 0; /* Fix found by Timo! See Tech Note 102 */ - err = PBGetCatInfoSync((CInfoPBPtr)&pb); - if (err != noErr) { - errno = ENOENT; - return -1; - } - if (pb.d.ioFlAttrib & LOCKBIT) - buf->st_mode = 0444; - else - buf->st_mode = 0666; - if (pb.d.ioFlAttrib & DIRBIT) { - buf->st_mode |= 0111 | S_IFDIR; - buf->st_size = pb.d.ioDrNmFls; - buf->st_rsize = 0; - } - else { - buf->st_mode |= S_IFREG; - if (pb.f.ioFlFndrInfo.fdType == 'APPL') - buf->st_mode |= 0111; - } - buf->st_ino = pb.hf.ioDirID; - buf->st_nlink = 1; - buf->st_uid = 1; - buf->st_gid = 1; - buf->st_size = (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlLgLen; - buf->st_mtime = buf->st_atime = pb.f.ioFlMdDat; - buf->st_ctime = pb.f.ioFlCrDat; - buf->st_rsize = (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlRLgLen; - *(unsigned long *)buf->st_type = - (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlFndrInfo.fdType; - *(unsigned long *)buf->st_creator = - (buf->st_mode & S_IFDIR) ? 0 : pb.f.ioFlFndrInfo.fdCreator; - return 0; -} diff --git a/Mac/Compat/macstat.h b/Mac/Compat/macstat.h deleted file mode 100644 index 10d9653..0000000 --- a/Mac/Compat/macstat.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Include file belonging to stat emulator. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Updated August 1994. */ - -struct macstat { - unsigned short st_dev; - unsigned long st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned short st_rdev; - unsigned long st_size; - unsigned long st_atime; - unsigned long st_mtime; - unsigned long st_ctime; - /* Non-standard additions */ - unsigned long st_rsize; /* Resource size */ - char st_type[4]; /* File type, e.g. 'APPL' or 'TEXT' */ - char st_creator[4]; /* File creator, e.g. 'PYTH' */ -}; - -#define S_IFMT 0170000 -#define S_IFDIR 0040000 -#define S_IFREG 0100000 -#define S_IREAD 0400 -#define S_IWRITE 0200 -#define S_IEXEC 0100 - -extern int macstat(char *, struct macstat *); -/* To stop inclusion of MWerks header: */ -#ifndef _STAT -#define _STAT -#endif diff --git a/Mac/Compat/mkdir.c b/Mac/Compat/mkdir.c deleted file mode 100644 index 3c35eb0..0000000 --- a/Mac/Compat/mkdir.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Mkdir for the Macintosh. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Pathnames must be Macintosh paths, with colons as separators. */ - -#include "macdefs.h" - -/* Create a directory. */ - -int -mkdir(path, mode) - char *path; - int mode; /* Ignored */ -{ - HFileParam pb; - - if (!hfsrunning()) { - errno= ENODEV; - return -1; - } - pb.ioNamePtr= (StringPtr) Pstring(path); - pb.ioVRefNum= 0; - pb.ioDirID= 0; - if (PBDirCreate((HParmBlkPtr)&pb, FALSE) != noErr) { - errno= EACCES; - return -1; - } - return 0; -} diff --git a/Mac/Compat/nfullpath.c b/Mac/Compat/nfullpath.c deleted file mode 100644 index ca027c8..0000000 --- a/Mac/Compat/nfullpath.c +++ /dev/null @@ -1,75 +0,0 @@ -/* GET FULL PATHNAME OF A FILE. -** Original by Guido, modified by Jack to handle FSSpecs -*/ - -#include - -#include - -#include "nfullpath.h" - -/* Mac file system parameters */ -#define MAXPATH 256 /* Max path name length+1 */ -#define SEP ':' /* Separator in path names */ - -/* Macro to find out whether we can do HFS-only calls: */ -#define FSFCBLen (* (short *) 0x3f6) -#define hfsrunning() (FSFCBLen > 0) - -int -nfullpath(fsp, retbuf) - FSSpec *fsp; - char *retbuf; -{ - union { - HFileInfo f; - DirInfo d; - WDPBRec w; - VolumeParam v; - } pb; - char cwd[2*MAXPATH]; - unsigned char namebuf[MAXPATH]; - short err; - int dir; - long dirid; - char *next = cwd + sizeof cwd - 1; - int len; - int need_sep = 1; - - if (!hfsrunning()) - return -1; - - dir = fsp->vRefNum; - dirid = fsp->parID; - /* Stuff the filename into the buffer */ - len = fsp->name[0]; - *next = '\0'; - next -= len; - memcpy(next, fsp->name+1, len); - - while (dirid != fsRtParID) { - pb.d.ioNamePtr = namebuf; - pb.d.ioVRefNum = dir; - pb.d.ioFDirIndex = -1; - pb.d.ioDrDirID = dirid; - err= PBGetCatInfo((CInfoPBPtr)&pb.d, 0); - if (err != noErr) - return err; - *--next = SEP; - len = namebuf[0]; - if ( len + strlen(next) >= MAXPATH ) - return -1; - next -= len; - memcpy(next, (char *)namebuf+1, len); - dirid = pb.d.ioDrParID; - need_sep = 0; - } - - strcpy(retbuf, next); - if (need_sep) { - next = strchr(retbuf, '\0'); - *next++ = SEP; - *next++ = '\0'; - } - return 0; -} diff --git a/Mac/Compat/nfullpath.h b/Mac/Compat/nfullpath.h deleted file mode 100644 index 65ae5f3..0000000 --- a/Mac/Compat/nfullpath.h +++ /dev/null @@ -1 +0,0 @@ -int nfullpath(FSSpec *, char *); /* Generate full path from fsspec */ diff --git a/Mac/Compat/opendir.c b/Mac/Compat/opendir.c deleted file mode 100644 index a015609..0000000 --- a/Mac/Compat/opendir.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Macintosh version of UNIX directory access package - * (opendir, readdir, closedir). - * Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - */ - -#include "dirent.h" -#include "macdefs.h" - -static DIR opened; - -/* - * Open a directory. This means calling PBOpenWD. - * The value returned is always the address of opened, or NULL. - * (I have as yet no use for multiple open directories; this could - * be implemented by allocating memory dynamically.) - */ - -DIR * -opendir(path) - char *path; -{ -#if TARGET_API_MAC_CARBON - Str255 ppath; - FSSpec fss; - int plen; - OSErr err; - - if (opened.nextfile != 0) { - errno = EBUSY; - return NULL; /* A directory is already open. */ - } - plen = strlen(path); - c2pstrcpy(ppath, path); - if ( ppath[plen] != ':' ) - ppath[++plen] = ':'; - ppath[++plen] = 'x'; - ppath[0] = plen; - if( (err = FSMakeFSSpec(0, 0, ppath, &fss)) < 0 && err != fnfErr ) { - errno = EIO; - return NULL; - } - opened.dirid = fss.parID; - opened.vrefnum = fss.vRefNum; - opened.nextfile = 1; - return &opened; -#else - union { - WDPBRec d; - VolumeParam v; - } pb; - char ppath[MAXPATH]; - short err; - - if (opened.nextfile != 0) { - errno = EBUSY; - return NULL; /* A directory is already open. */ - } - strncpy(ppath+1, path, ppath[0]= strlen(path)); - pb.d.ioNamePtr= (unsigned char *)ppath; - pb.d.ioVRefNum= 0; - pb.d.ioWDProcID= 0; - pb.d.ioWDDirID= 0; - err= PBOpenWD((WDPBPtr)&pb, 0); - if (err != noErr) { - errno = ENOENT; - return NULL; - } - opened.dirid= pb.d.ioVRefNum; - opened.nextfile= 1; - return &opened; -#endif -} - -/* - * Close a directory. - */ - -void -closedir(dirp) - DIR *dirp; -{ -#if TARGET_API_MAC_CARBON - dirp->nextfile = 0; -#else - WDPBRec pb; - - pb.ioVRefNum= dirp->dirid; - (void) PBCloseWD(&pb, 0); - dirp->dirid= 0; - dirp->nextfile= 0; -#endif -} - -/* - * Read the next directory entry. - */ - -struct dirent * -readdir(dp) - DIR *dp; -{ - union { - DirInfo d; - FileParam f; - HFileInfo hf; - } pb; - short err; - static struct dirent dir; - - dir.d_name[0]= 0; - pb.d.ioNamePtr= (unsigned char *)dir.d_name; -#if TARGET_API_MAC_CARBON - pb.d.ioVRefNum= dp->vrefnum; - pb.d.ioDrDirID= dp->dirid; -#else - pb.d.ioVRefNum= dp->dirid; - pb.d.ioDrDirID= 0; -#endif - pb.d.ioFDirIndex= dp->nextfile++; - err= PBGetCatInfo((CInfoPBPtr)&pb, 0); - if (err != noErr) { - errno = EIO; - return NULL; - } -#if TARGET_API_MAC_CARBON - p2cstrcpy(dir.d_name, (StringPtr)dir.d_name); -#else - (void) p2cstr((unsigned char *)dir.d_name); -#endif - return &dir; -} diff --git a/Mac/Compat/rmdir.c b/Mac/Compat/rmdir.c deleted file mode 100644 index 2e406c2..0000000 --- a/Mac/Compat/rmdir.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Rmdir for the Macintosh. - Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). - Pathnames must be Macintosh paths, with colons as separators. */ - -#include "macdefs.h" - -int -rmdir(path) - char *path; -{ - IOParam pb; - - pb.ioNamePtr= (StringPtr) Pstring(path); - pb.ioVRefNum= 0; - if (PBDelete((ParmBlkPtr)&pb, FALSE) != noErr) { - errno= EACCES; - return -1; - } - return 0; -} -- cgit v0.12