diff options
author | George Williams <gww@silcom.com> | 2005-08-25 21:13:42 +0000 |
---|---|---|
committer | George Williams <gww@silcom.com> | 2005-08-25 21:13:42 +0000 |
commit | 71966b18cc2b3c24b97cf932dbef4a569dd83051 (patch) | |
tree | 8cfb27b42445d8dc1ecf9c6e33c2c68a22a86bd7 | |
parent | a8139580a8d40bb09215ed48a46c0d40878fb28a (diff) |
Don't use FSSpec type any more (except when in compatibility mode).
-rw-r--r-- | fondu.c | 10 | ||||
-rw-r--r-- | fondups.c | 6 | ||||
-rw-r--r-- | frommacbinary.c | 45 | ||||
-rw-r--r-- | res2data.c | 35 | ||||
-rw-r--r-- | tomacbinary.c | 39 |
5 files changed, 124 insertions, 11 deletions
@@ -353,14 +353,14 @@ static void MakeAfmFiles(FOND *fond,FILE *f, int isfixed,char *origfilename) { for ( k=0; k<fond->stylekerns[i].kernpairs; ++k ) { const char *name1, *name2; struct kerns *kp = &fond->stylekerns[i].kerns[k]; - if ( kp->ch1<=256 ) + if ( 1 /* kp->ch1<=256 */ ) name1 = macnames[kp->ch1]; else { sprintf( buffer, "char%04x", kp->ch1 ); name1 = buffer; } if ( name1==NULL ) name1 = ".notdef"; - if ( kp->ch2<=256 ) + if ( 1 /* kp->ch2<=256 */ ) name2 = macnames[kp->ch2]; else { sprintf( fontname, "char%04x", kp->ch2 ); @@ -955,9 +955,7 @@ static int HasResourceFork(char *filename,PSFONT *psfont) { return( ret ); } #else - /* OS/9 and before */ -#include "MacFiles.h" - + /* OS/9 and before, these calls depreciated in X.4 */ static int HasResourceFork(char *filename,PSFONT *psfont) { /* If we're on a mac, we can try to see if we've got a real resource fork */ FSRef ref; @@ -1226,7 +1224,7 @@ int main(int argc, char **argv) { fprintf( stderr, " if -force is given you will not be asked about replacing existing files\n" ); fprintf( stderr, " if -inquire is given you will be asked about writing each file (whether\n" ); fprintf( stderr, "\tit exists or not). -inquire overrides -force.\n" ); - fprintf( stderr, " if -show is given you will not be told about each file created.\n" ); + fprintf( stderr, " if -show is given you will be told about each file created.\n" ); fprintf( stderr, " if -latin1 is given nfnts will be reencoded to latin1 (else left in mac roman)\n" ); fprintf( stderr, " if -trackps is given then any postscript files referenced by a FOND\n" ); fprintf( stderr, "\twill be loaded and processed.\n" ); @@ -3006,15 +3006,15 @@ void ParsePfb(FILE *pfb,PSFONT *psfont) { memset(psfont,0,sizeof(PSFONT)); if ( fd==NULL || fd->fontname==NULL ) return; - psfont->glyphcnt = fd->chars->cnt; + psfont->glyphcnt = fd->chars->next; psfont->glyphs = calloc(psfont->glyphcnt,sizeof(struct bbglyph)); psfont->temp = fd->chars; for ( i=0; i<256; ++i ) { - for ( j=fd->chars->cnt-1; j>=0; --j ) + for ( j=fd->chars->next-1; j>=0; --j ) if ( strcmp(fd->encoding[i],fd->chars->keys[j])==0 ) break; if ( j==-1 ) - for ( j=fd->chars->cnt-1; j>0; --j ) + for ( j=fd->chars->next-1; j>0; --j ) if ( strcmp(".notdef",fd->chars->keys[j])==0 ) break; psfont->encoding[i] = j; diff --git a/frommacbinary.c b/frommacbinary.c index 53d9f7e..d2d0199 100644 --- a/frommacbinary.c +++ b/frommacbinary.c @@ -140,6 +140,51 @@ return; fclose( infofile ); } } +#elif !defined(OldMacintosh) + { + FILE *datafile, *resfile; + FSRef ref; + + if ( dlen>0 || rlen>0 ) { + fseek(binfile,128,SEEK_SET); + name[header[1]]='\0'; + datafile = fopen(name,"w"); + if ( datafile==NULL ) + fprintf( stderr, "Cannot open output file: %s\n", name ); + else { + for ( i=0; i<dlen && (ch=getc(binfile))!=EOF; ++i ) + putc(ch,datafile); + fclose(datafile); + + if ( rlen>0 ) { + fseek(binfile,128 + ((dlen+127)&~127),SEEK_SET); + strcpy(name+header[1],"/rsrc"); + resfile = fopen(name,"w"); + if ( resfile==NULL ) + fprintf( stderr, "Cannot open output file: %s\n", name ); + else { + for ( i=0; i<rlen && (ch=getc(binfile))!=EOF; ++i ) + putc(ch,resfile); + fclose(resfile); + } + } + + /* Set type/creator */ + if ( FSPathMakeRef( (unsigned char *) name,&ref,NULL)==noErr ) { + FSCatalogInfo info; + /* Finder info contains more than type/creator. So don't */ + /* change the other values */ + if ( FSGetCatalogInfo(&ref,kFSCatInfoFinderInfo,&info,NULL,NULL,NULL)==noErr ) { + ((FInfo *) (info.finderInfo))->fdType = + (header[65]<<24)|(header[66]<<16)|(header[67]<<8)|header[68]; + ((FInfo *) (info.finderInfo))->fdCreator = + (header[69]<<24)|(header[70]<<16)|(header[71]<<8)|header[72]; + FSSetCatalogInfo(&ref,kFSCatInfoFinderInfo,&info); + } + } + } + } + } #else /* __Mac */ { FILE *file; @@ -37,6 +37,40 @@ static int ToResourceFork(char *filename) { /* If we're on a mac, we can try to see if we've got a real resource fork */ +#ifndef OldMacintosh + char *buf, *pt, *respath; + FILE *res, *temp; + + respath = galloc(strlen(filename)+strlen("/rsrc")+1); + strcpy(respath,filename); + strcat(respath,"/rsrc"); + resfork = fopen(respath,"r"); + free(respath); + + buf = malloc(strlen(filename)+strlen(".res")+20); + pt = strrchr(filename,'/'); + if ( pt==NULL ) pt=filename-1; + strcpy(buf,pt+1); + strcat(buf,".res"); + temp = fopen(buf,"w"); + if ( temp==NULL ) { + fprintf( stderr, "Failed to open %s for output\n", buf); +return( -1 ); + } + buf = malloc(8192); + while ( 1 ) { + cnt = 8192; + cnt = fread(buf,1,cnt,temp); + if ( cnt>0 ) + fwrite(buf,1,cnt,temp); + if ( cnt<=0 ) + break; + } + free(buf); + fclose(res); + fclose(temp); +return( 1 ); +#else FSRef ref; FSSpec spec; short res; @@ -75,6 +109,7 @@ return( -1 ); FSClose(res); fclose(temp); return( 1 ); +#endif } static void Usage(char *prog) { diff --git a/tomacbinary.c b/tomacbinary.c index 0500140..d76e06e 100644 --- a/tomacbinary.c +++ b/tomacbinary.c @@ -79,7 +79,17 @@ static void Usage(char *prog) { } static FILE *ResForkOfDataFile(char *dataname) { -#if __Mac +#ifndef OldMacintosh + /* OS/X and linux with appropriate drivers */ + char *respath = malloc(strlen(dataname)+strlen("/rsrc")+1); + FILE *temp; + + strcpy(respath,dataname); + strcat(respath,"/rsrc"); + temp = fopen(respath,"r"); + free(respath); +return( temp ); +#elif __Mac /* At 10.4 Mac starts warning that FSSpec is depreciated */ /* copy the resource fork of dataname (if any) into the data fork of a temp file */ FSRef ref; FSSpec spec; @@ -118,7 +128,32 @@ return( NULL ); } static void FindTypeCreater(char *dataname,char **create,char **type) { -#if __Mac +#if __Mac && !defined(OldMacintosh) + static char cbuf[5], tbuf[5]; + FSRef ref; + FSCatalogInfo info; + + if ( FSPathMakeRef( (unsigned char *) dataname,&ref,NULL)!=noErr ) +return; + if ( FSGetCatalogInfo(&ref,kFSCatInfoFinderInfo,&info,NULL,NULL,NULL)!=noErr ) +return; + if ( *type==NULL ) { + tbuf[0] = ((FInfo *) (info.finderInfo))->fdType>>24; + tbuf[1] = ((FInfo *) (info.finderInfo))->fdType>>16; + tbuf[2] = ((FInfo *) (info.finderInfo))->fdType>>8; + tbuf[3] = ((FInfo *) (info.finderInfo))->fdType; + tbuf[4] = '\0'; + *type = tbuf; + } + if ( *create==NULL ) { + cbuf[0] = ((FInfo *) (info.finderInfo))->fdCreator>>24; + cbuf[1] = ((FInfo *) (info.finderInfo))->fdCreator>>16; + cbuf[2] = ((FInfo *) (info.finderInfo))->fdCreator>>8; + cbuf[3] = ((FInfo *) (info.finderInfo))->fdCreator; + cbuf[4] = '\0'; + *create = cbuf; + } +#elif defined(OldMacintosh) static char cbuf[5], tbuf[5]; FSRef ref; FSSpec spec; |