FskErr FskECMAScriptInitialize(const char *configPath) { FskErr err = kFskErrNone; FskExtensionsEmbedLoad(NULL); #if TARGET_OS_ANDROID { FskThread thread = NULL; err = FskThreadCreate(&thread, FskECMAScriptInitializeThread, kFskThreadFlagsDefault, NULL, "KPR"); } #else FskECMAScriptInitializeThread(); #endif return err; }
static FskErr makeSSLRootVM(const char *calistpath) { #ifdef KPR_CONFIG FskErr err = kFskErrNone; xsBeginHost(gShell->root); xsTry { xsCall1_noResult(xsGet(xsGlobal, xsID("FskSSL")), xsID("loadRootCerts"), xsString((xsStringValue)calistpath)); } xsCatch { err = kFskErrOperationFailed; } xsEndHost(gShell->root); return err; #else char *rootPath, *xsbPath, *xsbName; xsGrammar *grammar; FskErr err; if ((err = FskMemPtrNewClear(sizeof(FskECMAScriptRecord), &gSSLVM)) != kFskErrNone) return err; #if FSK_EMBED FskExtensionsEmbedLoad(SSL_VMNAME); FskExtensionsEmbedGrammar(SSL_VMNAME, &xsbName, &grammar); #else xsbName = "FskCore.xsb"; grammar = &FskCoreGrammar; #endif rootPath = FskEnvironmentDoApply(FskStrDoCopy("[applicationPath]")); xsbPath = FskStrDoCat(rootPath, xsbName); FskMemPtrDispose(rootPath); grammar->name = (xsStringValue)SSL_VMNAME; if ((err = loadGrammar(xsbPath, grammar)) == kFskErrNone) { if ((gSSLVM->the = xsNewMachine(&anAllocation, grammar, gSSLVM)) == NULL) err = kFskErrMemFull; FskMemPtrDispose(grammar->symbols); FskMemPtrDispose(grammar->code); } FskMemPtrDispose(xsbPath); BAIL_IF_ERR(err); xsBeginHost(gSSLVM->the); xsTry { #if !FSK_EMBED /* load Crypt and FskSSL extensions which are only needed for Fsk SSL */ xsCall3_noResult(xsGet(xsGlobal, xsID("System")), xsID("loadExtension"), xsString("Crypt"), xsString("[applicationPath]"), xsInteger(0)); xsCall3_noResult(xsGet(xsGlobal, xsID("System")), xsID("loadExtension"), xsString("FskSSL"), xsString("[applicationPath]"), xsInteger(1)); #endif xsCall1_noResult(xsGet(xsGlobal, xsID("FskSSL")), xsID("loadRootCerts"), xsString((xsStringValue)calistpath)); } xsCatch { err = kFskErrOperationFailed; } xsEndHost(gSSLVM->the); if (err == kFskErrNone) xsShareMachine(gSSLVM->the); bail: if (err != kFskErrNone) disposeSSLRootVM(); return err; #endif }