From: Rolf K. <lab...@us...> - 2006-01-10 22:51:41
|
Update of /cvsroot/opengtoolkit/lvzip/c_source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28436/c_source Modified Files: Makefile macbin.c macbin.h zlibvc.def Log Message: Updated shared lib to be more compatible with previous VI versions Index: macbin.c =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/macbin.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** macbin.c 10 Jan 2006 17:38:01 -0000 1.17 --- macbin.c 10 Jan 2006 22:51:31 -0000 1.18 *************** *** 53,56 **** --- 53,135 ---- return noErr; } + + static Boolean HasFMExtension(FSSpec *fss, int32 attr) + { + HParamBlockRec pb; + Str255 volName; + char *p; + GetVolParmsInfoBuffer vParms; + + strncpy(volName, fss->name, PStrLen(fss->name)); + volName[PStrLen(fss->name)] = 0; + p = strchr(volName, ':'); + if (!p) + return false; + *(++p) = 0; + + pb.volumeParam.ioCompletion = 0L; + pb.volumeParam.ioNamePtr = volName; + pb.volumeParam.ioVRefNum = fss->vRefNum; + pb.ioParam.ioReqCount = sizeof(vParms); + pb.ioParam.ioBuffer = (Ptr)&vParms; + if (err = PBHGetVolParmsSync(&pb)) + { + return false; + } + return ((vParms.vMAttrib & attributes) == attributes); + } + + /* Compatibility functions for older LabVIEW libraries */ + extern OSErr ZEXPORT HasResourceFork(PStr path, int32 *hasResFork) + { + FSSpec theFSSpec; + OSErr err = noErr; + + *hasResFork = 0; + + err = MakeFSSpec(0, 0, path, &theFSSpec); + if (!err) + { + int theRefNum = FSpOpenResFile(&theFSSpec, fsRdPerm); + if (ResError() == noErr) //we've got a resource file + { + CloseResFile(theRefNum); + *hasResFork = 1; + } + } + return err; + } + + extern OSErr ZEXPORT LV_EncodeMacbinary(PStr srcPath, PStr dstPath) + { + FSSpec srcFSSpec; + FSSpec dstFSSpec; + OSErr err; + + err = MakeFSSpec(srcPath, &srcFSSpec); + if (!err) + { + err = MakeFSSpec(dstPath, &dstFSSpec); + if (!err) + err = EncodeMacbinaryFiles(&srcFSSpec, &dstFSSpec); + } + return err; + } + + extern MgErr ZEXPORT LV_DecodeMacbinary(PStr srcPath, PStr dstPath) + { + FSSpec srcFSSpec; + FSSpec dstFSSpec; + OSErr err; + + err = MakeFSSpec(srcPath, &srcFSSpec); + if (!err) + { + err = MakeFSSpec(dstPath, &dstFSSpec); + if (err) + err = DecodeMacBinaryFiles(&srcFSSpec, &dstFSSpec); + } + return OSErrToLVErr(err); + } #elif Win32 #include "iowin32.h" *************** *** 62,67 **** } ! extern MgErr ZEXPORT HasResourceFork(Path path, int32 *hasResFork){ ! #if Mac FSSpec theFSSpec; --- 141,146 ---- } ! extern MgErr ZEXPORT LVPath_HasResourceFork(Path path, int32 *hasResFork) ! { #if Mac FSSpec theFSSpec; *************** *** 80,84 **** } } ! return OSErrToLVErr(err); #else *hasResFork = 0; --- 159,163 ---- } } ! return OSErrToLVErr(err);; #else *hasResFork = 0; *************** *** 87,91 **** } ! extern MgErr ZEXPORT LV_EncodeMacbinary(Path srcPath, Path dstPath) { #if Mac --- 166,170 ---- } ! extern MgErr ZEXPORT LVPath_EncodeMacbinary(Path srcPath, Path dstPath) { #if Mac *************** *** 107,111 **** } ! extern MgErr ZEXPORT LV_DecodeMacbinary(Path srcPath, Path dstPath) { #if Mac --- 186,190 ---- } ! extern MgErr ZEXPORT LVPath_DecodeMacbinary(Path srcPath, Path dstPath) { #if Mac *************** *** 127,138 **** } ! extern MgErr ZEXPORT OpenResFork(LVRefNum *refnum, Path path, uInt32 openMode, uInt32 denyMode) { - MgErr err = mgNotSupported; #if Mac int16 perm; FSSpec fss; - int16 fd = 0;; OSErr ret; switch (openMode) --- 206,225 ---- } ! extern MgErr ZEXPORT LVPath_OpenResFork(LVRefNum *refnum, Path path, uInt32 openMode, uInt32 denyMode) { #if Mac int16 perm; + HParamBlockRec pb; FSSpec fss; OSErr ret; + Boolean hasDeny; + + *refnum = 0; + + if (ret = MakeMacSpec(path, &fss)) + { + return OSErrToLVErr(err); + } + hasDeny = HasFMExtension(&fss, 1L << bHasOpenDeny); switch (openMode) *************** *** 151,192 **** return mgArgErr; } ! switch (denyMode) { ! case denyReadWrite: ! perm |= 0x0030; ! break; ! case denyWriteOnly: ! perm |= 0x0020; ! break; ! case denyNeither: ! /* leave all deny mode bits clear */ ! break; ! default: ! return mgArgErr; } ! if (ret = MakeMacSpec(path, &fss)) { ! return OSErrToLVErr(err); } ! ret = FSpOpenRF(&fss, perm, &fd); if (!ret) { if (openMode == openWriteOnlyTruncate) ! ret = SetEOF(fd, 0L); } ! if (ret) ! err = OSErrToLVErr(ret); ! else ! err = FNewRefNum(path, (File)fd, refnum); #endif ! return err; } ! extern MgErr ZEXPORT UtilFileInfo(Path path, ! uInt8 write, ! LVFileInfo *fileInfo, ! PStr comment, ! int32 *length) { #if Mac --- 238,294 ---- return mgArgErr; } ! ! if (hasDeny) { ! switch (denyMode) ! { ! case denyReadWrite: ! perm |= fsRdDenyPerm | fsWrDenyPerm; ! break; ! case denyWriteOnly: ! perm |= fsWrDenyPerm; ! break; ! case denyNeither: ! /* leave all deny mode bits clear */ ! break; ! default: ! return mgArgErr; ! } } ! pb.ioCompletionProc = 0; ! pb.ioNamePtr = fss.name; ! pb.ioVRefNum = fss.vRefNum; ! pb.ioDirID = fss.parID; ! pb.ioDenyModes = perm; ! ! if (hasDeny) { ! ret = PBHOpenRFDenySync(&pb); } ! else ! { ! pbr.ioParam.ioPermssn = perm; ! ret = PBHOpenSync(&pb); ! } ! if (!ret) { if (openMode == openWriteOnlyTruncate) ! ret = SetEOF(pb.ioRefNum, 0L); } ! if (!ret) ! *refnum = pb.ioRefNum; ! ! return OSErrToLVErr(ret); #endif ! *refnum = 0; ! return noErr; } ! extern MgErr ZEXPORT LVPath_UtilFileInfo(Path path, ! uInt8 write, ! LVFileInfo *fileInfo, ! PStr comment) { #if Mac *************** *** 194,201 **** DTPBRec dtpb; CInfoPBRec cpb; ! OSErr err = noErr; ! if (*length > 255) ! return mgArgErr; if (err = MakeMacSpec(path, &fss)) --- 296,303 ---- DTPBRec dtpb; CInfoPBRec cpb; ! OSErr err; ! if (!comment || !PStrLen(comment) ! return mgArgErr; if (err = MakeMacSpec(path, &fss)) *************** *** 218,223 **** { dtpb.ioNamePtr = fss.name; - dtpb.ioDTBuffer = comment; dtpb.ioDirID = fss.parID; if (write) --- 320,328 ---- { dtpb.ioNamePtr = fss.name; dtpb.ioDirID = fss.parID; + dtpb.ioDTBuffer = comment; + if (comment) + dtpb.ioDTReqCount = PStrLen(comment) + 1; + else if (write) *************** *** 248,254 **** err = PBSetCatInfoSync(&cpb); ! if (!err && *length && comment && PStrLen(comment)) { - dtpb.ioDTReqCount = *length; err = PBDTSetCommentSync(&dtpb); } --- 353,358 ---- err = PBSetCatInfoSync(&cpb); ! if (!err && comment) { err = PBDTSetCommentSync(&dtpb); } *************** *** 286,292 **** ConvertLVTime(&fileInfo->cDate, &cpb.hFileInfo.ioFlMdDat, true); } - err = PBDTGetCommentSync(&dtpb); - *length = dtpb.ioDTActCount; } } --- 390,394 ---- Index: macbin.h =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/macbin.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** macbin.h 10 Jan 2006 17:38:01 -0000 1.12 --- macbin.h 10 Jan 2006 22:51:31 -0000 1.13 *************** *** 35,39 **** Private(LVRefNum); ! typedef int32 MgErr; enum { /* Manager Error Codes */ --- 35,39 ---- Private(LVRefNum); ! typedef int32 MgErr, OSErr; enum { /* Manager Error Codes */ *************** *** 174,189 **** extern void ZEXPORT DLLVersion OF((uChar* Version)); ! extern MgErr ZEXPORT HasResourceFork OF((Path path, int32 *hasResFork)); ! extern MgErr ZEXPORT LV_EncodeMacbinary OF((Path srcFileName, Path dstFileName)); ! extern MgErr ZEXPORT LV_DecodeMacbinary OF((Path srcFileName, Path dstFileName)); ! extern MgErr ZEXPORT UtilFileInfo OF((Path path, uInt8 write, LVFileInfo *finderInfo, ! PStr comment, ! int32 *length)); ! extern MgErr ZEXPORT OpenResFork OF((LVRefNum *refnum, Path path, uInt32 openMode, --- 174,191 ---- extern void ZEXPORT DLLVersion OF((uChar* Version)); ! extern OSErr ZEXPORT HasResourceFork OF((PStr path, int32 *hasResFork)); ! extern OSErr ZEXPORT LV_EncodeMacbinary OF((PStr srcFileName, PStr dstFileName)); ! extern OSErr ZEXPORT LV_DecodeMacbinary OF((PStr srcFileName, PStr dstFileName)); ! extern MgErr ZEXPORT LVPath_HasResourceFork OF((Path path, int32 *hasResFork)); ! extern MgErr ZEXPORT LVPath_EncodeMacbinary OF((Path srcFileName, Path dstFileName)); ! extern MgErr ZEXPORT LVPath_DecodeMacbinary OF((Path srcFileName, Path dstFileName)); ! extern MgErr ZEXPORT LVPath_UtilFileInfo OF((Path path, uInt8 write, LVFileInfo *finderInfo, ! PStr comment)); ! extern MgErr ZEXPORT LVPath_OpenResFork OF((LVRefNum *refnum, Path path, uInt32 openMode, Index: Makefile =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 6 Apr 2005 21:20:58 -0000 1.6 --- Makefile 10 Jan 2006 22:51:31 -0000 1.7 *************** *** 26,30 **** # -Wstrict-prototypes -Wmissing-prototypes ! LDFLAGS=libz.a LDSHARED=$(CC) -shared -Wl CPP=$(CC) -E --- 26,30 ---- # -Wstrict-prototypes -Wmissing-prototypes ! LDFLAGS=lvzlib.a LDSHARED=$(CC) -shared -Wl CPP=$(CC) -E *************** *** 82,89 **** example$(EXE): example.o $(LIBS) ! $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) minigzip$(EXE): minigzip.o $(LIBS) ! $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) install: $(LIBS) --- 82,89 ---- example$(EXE): example.o $(LIBS) ! $(CC) $(CFLAGS) -o $@ example.o $(LIBS) minigzip$(EXE): minigzip.o $(LIBS) ! $(CC) $(CFLAGS) -o $@ minigzip.o $(LIBS) install: $(LIBS) Index: zlibvc.def =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/zlibvc.def,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** zlibvc.def 7 Jan 2006 20:12:01 -0000 1.11 --- zlibvc.def 10 Jan 2006 22:51:31 -0000 1.12 *************** *** 97,104 **** DLLVersion @190 ! OpenResFork @200 ! UtilFileInfo @201 ! InitializeFileFuncs @202 ! HasResourceFork @203 ! LV_EncodeMacbinary @204 ! LV_DecodeMacbinary @205 --- 97,104 ---- DLLVersion @190 ! InitializeFileFuncs @200 ! LVPath_UtilFileInfo @201 ! LVPath_OpenResFork @202 ! LVPath_HasResourceFork @203 ! LVPath_EncodeMacbinary @204 ! LVPath_DecodeMacbinary @205 |