home *** CD-ROM | disk | FTP | other *** search
- /****************************************/
-
- /* ExpressModemVer.c */
- /* Author: Shemin Gau, IP */
- /* Revision History: 03/20/94 */
-
- /****************************************/
-
-
- #include <Files.h>
- #include <string.h>
- #include <Resources.h>
- #include <Memory.h>
- #include <ToolUtils.h>
- #include <Errors.h>
- #include <Packages.h>
- #include <Types.h>
- #include <OSUtils.h>
-
-
-
- //pascal OSErr main(char *msg, Size inSize, void* outMessage, Size* outSize, Handle ignoreMe)
- pascal OSErr main(Str255 msg, Size inSize, void* outMessage, Size* outSize, Handle ignoreMe)
- {
- SysEnvRec theWorld;
- CInfoPBRec pBlck;
- short volID;
- char pathName[256] ;
- char cDummy[128] ;
- Str255 pasDummy;
-
- Handle my_hndl;
- char *str_holder = '\0';
- short myResRefNum;
- char *retstr = '\0';
- char *cp;
- char *version = "1.5";
-
- char *ctemp1;
- char *ctemp2 = "SheminCI:System 7 pro:";
- char *ctemp3 = "Control Panels:PowerBook Setup";
- char *ctemp4 = "SheminCI:System 7 pro:Control Panels:PowerBook Setup";
- char *ctemp5 = "System 7 pro";
- char *ctemp7;
- Str255 ptemp3 = "SheminCI:System 7 pro:";
- StringPtr ptemp4;
- Str255 ptemp5 = "System 7 pro";
-
- StringPtr ptemp1;
- short k = 1;
-
-
- pathName[0] = '\0';
- cDummy[0] = '\0';
- pasDummy[0] = '\0';
-
- if (SysEnvirons(2, &theWorld)) {
- return(1);
- } else {
- volID = theWorld.sysVRefNum;
- }
-
- /* set up pBlck stuff */
- pBlck.dirInfo.ioNamePtr = pasDummy;
- pBlck.dirInfo.ioVRefNum = volID;
- pBlck.dirInfo.ioFDirIndex = 1;
- pBlck.dirInfo.ioDrDirID = 0;
-
- /* get the first directory ID (if we can't, then errorback. */
- if ( PBGetCatInfo(&pBlck, false) != noErr ) {
- return(1);
- }
-
- /* now, keep going up the tree things we reach the top */
- while (pBlck.dirInfo.ioDrDirID != 2) {
- /* swap id's from the parent ID to the current ID and reset the index. */
- pBlck.dirInfo.ioDrDirID = pBlck.dirInfo.ioDrParID;
- pBlck.dirInfo.ioFDirIndex = -1;
- /* get load the NamePtr (which is equal to pasDummy) and build the C string. */
- if (!PBGetCatInfo(&pBlck, false)) {
- #if 0
- /* debugging codes */
- if (pasDummy[1] == 'S')
- return (0);
-
- if (strcmp(p2cstr(pasDummy), ctemp5) == 0)
- return (0);
- #endif
- ctemp1 = p2cstr(pasDummy);
- strcpy(cDummy, ctemp1);
- strcat(cDummy, ":");
- strcat(cDummy, pathName);
- strcpy(pathName, cDummy);
- } else {
- /* this is just in case the PB call fails. */
- return(1);
- }
- }
-
- #if 0
- /* debugging codes */
- if (strcmp(pathName, ctemp2) == 0)
- return(0);
- #endif
-
- ctemp7 = p2cstr(msg);
-
- #if 0
- /* debugging codes */
- if (strcmp(ctemp7, ctemp3) == 0)
- return(0);
- #endif
-
- strcat(pathName, ctemp7);
- //strcat(pathName, '\0');
-
-
- //now, convert the whole pathname into pascal string
- ptemp1 = c2pstr(pathName);
-
- myResRefNum = OpenResFile(ptemp1);
- UseResFile(myResRefNum);
-
- if (ResError() == noErr) {
- if (my_hndl = (Handle)Get1Resource('vers', 2)) {
- HLock(my_hndl);
- cp = *my_hndl;
- HUnlock(my_hndl);
- }
- ReleaseResource((Handle)my_hndl);
-
- //use derez to decode the memory address of the version number
- strncpy(retstr, cp + 7, (size_t)(3));
- if (strcmp(retstr, version) >= 0) {
- CloseResFile(myResRefNum);
- return(0);
- } else {
- CloseResFile(myResRefNum);
- return(1);
- }
- } else {
- CloseResFile(myResRefNum);
- return(1);
- }
-
- }
-