int __cdecl _pgp_init() { if(!pgpErrMsg) pgpErrMsg = (LPSTR) LocalAlloc(LPTR,pgpErrMsgLen); pgpVer = 0; __try { #if (PGP_WIN32 < 0x700) if (CheckPGPError(PGPsdkInit()) || CheckPGPError(PGPsdkUILibInit())) return 0; PGPNewContext(kPGPsdkAPIVersion, &pgpContext); #else if (CheckPGPError(PGPsdkInit(0)) || CheckPGPError(PGPsdkUILibInit(0))) return 0; PGPNewContext(kPGPsdk20APIVersion, &pgpContext); #endif } __except ( EXCEPTION_EXECUTE_HANDLER ) { return 0; } #if (PGP_WIN32 < 0x700) PGPGetSDKVersion(&pgpVer); int minor = (pgpVer & 0x000FF000 ) >> 12; switch(PGPMajorVersion(pgpVer)) { case 2: pgpVer = 1<<24 | ((minor+1)<<16) | (PGPRevVersion(pgpVer)<<8); break; case 3: pgpVer = 1<<24 | ((minor+5)<<16) | (PGPRevVersion(pgpVer)<<8); break; default: pgpVer = 1<<24 | (minor<<16) | (PGPRevVersion(pgpVer)<<8); break; } #else pgpVer = PGPGetPGPsdkVersion(); #endif return 1; }
PGPError PGPsdkUILibInit(void) { PGPError err = kPGPError_NoErr; if( sInitedCount == 0 ) { /* Initialize the SDK in case the caller has not */ err = PGPsdkInit(); if( IsntPGPError( err ) ) { sInitializedSDK = TRUE; err = PGPsdkNetworkLibInit(); if( IsntPGPError( err ) ) { sInitializedNetworkLib = TRUE; pgpLeaksBeginSession( "PGPsdkUILib" ); #if PGP_WIN32 if( IsNull( gPGPsdkUILibInst ) ) { /* ** If this is a DLL, DLLMain() will set gPGPsdkUILibInst before ** calling this function so loading the resource-only DLL ** will not be necessary. If gPGPsdkUILibInst is NULL, this is ** a static library and we must get our resources from an external ** DLL. */ sResourceDLL=TRUE; gPGPsdkUILibInst = LoadLibrary("PGPuiRes.DLL"); if (gPGPsdkUILibInst == 0) { err = -1; } } #endif } } } if( IsntPGPError( err ) ) { ++sInitedCount; } return( err ); }
int __cdecl _pgp_init() { if (!pgpErrMsg) pgpErrMsg = (LPSTR) LocalAlloc(LPTR,pgpErrMsgLen); pgpVer = 0; #if defined(_WIN64) return 0; #else __try { if (CheckPGPError(PGPsdkInit(0)) || CheckPGPError(PGPsdkUILibInit(0))) return 0; PGPNewContext(kPGPsdk20APIVersion, &pgpContext); } __except ( EXCEPTION_EXECUTE_HANDLER ) { return 0; } pgpVer = PGPGetPGPsdkVersion(); return 1; #endif }
int main(int argc,char *argv[]) { struct pgpmainBones *mainbPtr = &_pgp_mainBones; struct pgpargsBones *argsbPtr; struct pgpfileBones *filebPtr; struct pgpenvBones *envbPtr; PGPContextRef mainContext; int errorLvl = 0, status; PGPError err = PGPsdkInit(); pgpAssertNoErr(err); err = PGPsdkNetworkLibInit(); pgpAssertNoErr(err); err = PGPNewContext( kPGPsdkAPIVersion, &mainContext ); pgpAssertNoErr(err); err = pgpInitSDKPrefsDir( mainContext ); pgpAssertNoErr(err); initMainBones( mainbPtr, mainContext ); signonMsg(mainbPtr); /* link the context and initialize what used to be the global variables. */ argsbPtr = mainbPtr->argsbPtr; filebPtr = mainbPtr->filebPtr; envbPtr = mainbPtr->envbPtr; err = pgpParseArgs( mainbPtr, argc, argv, &errorLvl); /* parse the arguments */ if(err != 0) goto ex; if (argsbPtr->keyFlag && argsbPtr->keyChar == '\0') { keyUsage(filebPtr,&errorLvl); goto ex; } if (argsbPtr->groupFlag && argsbPtr->groupChar == '\0') { groupUsage(filebPtr,&errorLvl); goto ex; } /* * Write to stdout if explicitly asked to, or in filter mode and * no explicit file name was given. */ mainbPtr->outputStdout = argsbPtr->outputFileName ? strcmp(argsbPtr->outputFileName, "-") == 0 : envbPtr->filterMode; #if 1 /* At request of Peter Simons, use stderr always. Sounds reasonable. */ /* JIS: Put this code back in... removing it broke too many things */ if (!mainbPtr->outputStdout) filebPtr->pgpout = stdout; #endif #if defined(PGP_UNIX) || defined(VMS) umask(077); /* Make files default to private */ #endif initSignals(); /* Catch signals */ /* get our groups...*/ err = pgpInitializeWorkingGroupSet( mainbPtr ); if (argsbPtr->keyFlag) { status = doKeyOpt( mainbPtr, argsbPtr->keyChar, &errorLvl ); if (status < 0) { userError(filebPtr,&errorLvl); goto ex; } errorLvl=status; goto ex; } if(argsbPtr->groupFlag) { status = doGroupOpt( mainbPtr, argsbPtr->groupChar, &errorLvl ); if( status < 0 ) { userError(filebPtr,&errorLvl); goto ex; } errorLvl=status; goto ex; } err = pgpProcessArgs(mainbPtr, &errorLvl); ex: err = pgpFinalizeWorkingGroupSet( mainbPtr ); pgpTearDown( mainbPtr, &errorLvl ); exit(errorLvl); /*NOTREACHED*/ return errorLvl; }