Exemplo n.º 1
0
static JILError JCLBeginCompile(JILState* pVM, const JILChar* pName, const JILChar* pText, const JILChar* pPath)
{
	JILError err = JCL_No_Error;
	JCLFile* pFile;
	JCLState* _this;

	if( (_this = pVM->vmpCompiler) == NULL )
		return JIL_ERR_No_Compiler;

	pName = (pName == NULL) ? "unnamed code fragment" : pName;
	pPath = (pPath == NULL) ? "" : pPath;
	if( !_this->miNumCompiles )
	{
		// status message
		const JILVersionInfo* pInfo;
		char vers[32];
		const char* buf1;
		pInfo = JILGetRuntimeVersion(_this->mipMachine);
		JILGetVersionString(pInfo->CompilerVersion, vers);
		buf1 = (pInfo->BuildFlags & kDebugBuild) ? "Debug" : "Release";
		JCLVerbosePrint(_this, "*** JewelScript compiler v%s [%s] ***\n", vers, buf1);
		_this->miTimestamp = (JILFloat) clock();
	}
	JCLVerbosePrint(_this, "Compiling '%s'\n", (strlen(pPath) > 0) ? pPath : pName);
	// create a new file object
	pFile = NEW(JCLFile);
	// open it
	err = pFile->Open(pFile, pName, pText, pPath, GetGlobalOptions(_this));
	if( err )
		goto exit;
	err = cg_resume_intro(_this);
	if( err )
		goto exit;
	// compile it
	err = p_compile(_this, pFile);
	if( err )
		goto exit;

exit:
	pFile->Close(pFile);
	FlushErrorsAndWarnings(_this);
	DELETE(pFile);
	return err;
}
Exemplo n.º 2
0
JILError JCLSetGlobalOptions(JILState* pVM, const JILChar* pOptionString)
{
	JILError err = JIL_No_Exception;
	JCLString* pStr;
	JCLString* pToken;
	JCLOption* pOptions;
	JCLState* _this;

	if( (_this = pVM->vmpCompiler) == NULL )
		return JIL_ERR_No_Compiler;

	pStr = NEW(JCLString);
	pToken = NEW(JCLString);
	JCLSetString(pToken, pOptionString);
	pOptions = GetGlobalOptions(_this);
	while( !JCLAtEnd(pToken) )
	{
		// copy up to separator into pStr
		JCLSpanExcluding(pToken, ",;", pStr);
		// trim any spaces
		JCLTrim(pStr);
		// something left?
		if( JCLGetLength(pStr) )
		{
			// have option object parse it
			err = pOptions->ParseOption(pOptions, pStr, JILHandleRuntimeOptions, pVM);
			// handle warnings and errors
			if( err )
				goto exit;
		}
		// skip the separator(s)
		JCLSpanIncluding(pToken, ",;", pStr);
	}

exit:
	DELETE(pStr);
	DELETE(pToken);
	return err;
}
Exemplo n.º 3
0
void TSessionLog::DoAddStartupInfo(TSessionData *Data)
{
  if (Data == nullptr)
  {
    AddSeparator();
    UnicodeString OS = WindowsVersionLong();
    AddToList(OS, WindowsProductName(), L" - ");
    ADF("NetBox %s (OS %s)", FConfiguration->GetProductVersionStr(), OS);
    {
      std::unique_ptr<THierarchicalStorage> Storage(FConfiguration->CreateConfigStorage());
      DebugAssert(Storage.get());
      ADF("Configuration: %s", Storage->GetSource());
    }

#if 0
    typedef BOOL (WINAPI * TGetUserNameEx)(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize);
    HINSTANCE Secur32 = LoadLibrary(L"secur32.dll");
    TGetUserNameEx GetUserNameEx =
      (Secur32 != nullptr) ? reinterpret_cast<TGetUserNameEx>(::GetProcAddress(Secur32, "GetUserNameExW")) : nullptr;
    wchar_t UserName[UNLEN + 1];
    ULONG UserNameSize = _countof(UserName);
    if ((GetUserNameEx == nullptr) || DebugAlwaysFalse(!GetUserNameEx(NameSamCompatible, (LPWSTR)UserName, &UserNameSize)))
    {
      wcscpy_s(UserName, UNLEN, L"<Failed to retrieve username>");
    }
#endif // #if 0
    UnicodeString LogStr;
    if (FConfiguration->GetLogProtocol() <= 0)
    {
      LogStr = L"Normal";
    }
    else if (FConfiguration->GetLogProtocol() == 1)
    {
      LogStr = L"Debug 1";
    }
    else if (FConfiguration->GetLogProtocol() >= 2)
    {
      LogStr = L"Debug 2";
    }
#if 0
    if (FConfiguration->GetLogSensitive())
    {
      LogStr += L", Logging passwords";
    }
#endif // #if 0
    if (FConfiguration->GetLogMaxSize() > 0)
    {
      LogStr += FORMAT(L", Rotating after: %s", SizeToStr(FConfiguration->GetLogMaxSize()));
      if (FConfiguration->GetLogMaxCount() > 0)
      {
        LogStr += FORMAT(L", Keeping at most %d logs", FConfiguration->GetLogMaxCount());
      }
    }
#if 0
    ADF("Log level: %s", LogStr);
    ADF("Local account: %s", UserName);
#endif // #if 0
    ADF("Working directory: %s", GetCurrentDir());
    ADF("Process ID: %d", intptr_t(GetCurrentProcessId()));
#if 0
    ADF("Command-line: %s", GetCmdLineLog());
    if (FConfiguration->GetLogProtocol() >= 1)
    {
      AddOptions(GetGlobalOptions());
    }
#endif // #if 0
    ADF("Time zone: %s", GetTimeZoneLogString());
    if (!AdjustClockForDSTEnabled())
    {
      ADF("Warning: System option \"Automatically adjust clock for Daylight Saving Time\" is disabled, timestamps will not be represented correctly");
    }
#if 0
    ADF("Login time: %s", dt);
#endif // #if 0
    AddSeparator();
  }
  else
  {
#if 0
    ADF("Session name: %s (%s)", Data->GetSessionName(), Data->GetSource());
    ADF("Host name: %s (Port: %d)", Data->GetHostNameExpanded(), Data->GetPortNumber());
    ADF("User name: %s (Password: %s, Key file: %s, Passphrase: %s)",
      Data->GetUserNameExpanded(), LogSensitive(Data->GetPassword()),
      LogSensitive(Data->GetPublicKeyFile()), LogSensitive(Data->GetPassphrase()))
#endif // #if 0
    if (Data->GetUsesSsh())
    {
      ADF("Tunnel: %s", BooleanToEngStr(Data->GetTunnel()));
      if (Data->GetTunnel())
      {
        ADF("Tunnel: Host name: %s (Port: %d)", Data->GetTunnelHostName(), Data->GetTunnelPortNumber());
#if 0
        ADF("Tunnel: User name: %s (Password: %s, Key file: %s)",
          Data->GetTunnelUserName(), BooleanToEngStr(!Data->GetTunnelPassword().IsEmpty()),
          BooleanToEngStr(!Data->GetTunnelPublicKeyFile().IsEmpty()));
        ADF("Tunnel: Local port number: %d", Data->GetTunnelLocalPortNumber());
#endif // #if 0
      }
    }
    ADF("Transfer Protocol: %s", Data->GetFSProtocolStr());
    ADF("Code Page: %d", Data->GetCodePageAsNumber());
    if (Data->GetUsesSsh() || (Data->GetFSProtocol() == fsFTP))
    {
      TPingType PingType;
      intptr_t PingInterval;
      if (Data->GetFSProtocol() == fsFTP)
      {
        PingType = Data->GetFtpPingType();
        PingInterval = Data->GetFtpPingInterval();
      }
      else
      {
        PingType = Data->GetPingType();
        PingInterval = Data->GetPingInterval();
      }
      ADF("Ping type: %s, Ping interval: %d sec; Timeout: %d sec",
        EnumName(PingType, PingTypeNames), PingInterval, Data->GetTimeout());
      ADF("Disable Nagle: %s",
        BooleanToEngStr(Data->GetTcpNoDelay()));
    }
    TProxyMethod ProxyMethod = Data->GetActualProxyMethod();
    {
      UnicodeString fp = FORMAT(L"FTP proxy %d", Data->GetFtpProxyLogonType());
      ADF("Proxy: %s",
        (Data->GetFtpProxyLogonType() != 0) ? fp : EnumName(ProxyMethod, ProxyMethodNames));
    }
    if ((Data->GetFtpProxyLogonType() != 0) || (ProxyMethod != ::pmNone))
    {
      ADF("ProxyHostName: %s (Port: %d); ProxyUsername: %s; Passwd: %s",
        Data->GetProxyHost(), Data->GetProxyPort(),
        Data->GetProxyUsername(), BooleanToEngStr(!Data->GetProxyPassword().IsEmpty()));
      if (ProxyMethod == pmTelnet)
      {
        ADF("Telnet command: %s", Data->GetProxyTelnetCommand());
      }
      if (ProxyMethod == pmCmd)
      {
        ADF("Local command: %s", Data->GetProxyLocalCommand());
      }
    }
    if (Data->GetUsesSsh() || (Data->GetFSProtocol() == fsFTP))
    {
      ADF("Send buffer: %d", Data->GetSendBuf());
    }
    if (Data->GetUsesSsh())
    {
      ADF("SSH protocol version: %s; Compression: %s",
        Data->GetSshProtStr(), BooleanToEngStr(Data->GetCompression()));
      ADF("Bypass authentication: %s",
        BooleanToEngStr(Data->GetSshNoUserAuth()));
      ADF("Try agent: %s; Agent forwarding: %s; TIS/CryptoCard: %s; KI: %s; GSSAPI: %s",
        BooleanToEngStr(Data->GetTryAgent()), BooleanToEngStr(Data->GetAgentFwd()), BooleanToEngStr(Data->GetAuthTIS()),
        BooleanToEngStr(Data->GetAuthKI()), BooleanToEngStr(Data->GetAuthGSSAPI()));
      if (Data->GetAuthGSSAPI())
      {
        ADF("GSSAPI: Forwarding: %s",
          BooleanToEngStr(Data->GetGSSAPIFwdTGT()));
      }
      ADF("Ciphers: %s; Ssh2DES: %s",
        Data->GetCipherList(), BooleanToEngStr(Data->GetSsh2DES()));
      ADF("KEX: %s", Data->GetKexList());
      UnicodeString Bugs;
      for (intptr_t Index = 0; Index < BUG_COUNT; ++Index)
      {
        AddToList(Bugs, EnumName(Data->GetBug(static_cast<TSshBug>(Index)), AutoSwitchNames), L",");
      }
      ADF("SSH Bugs: %s", Bugs);
      ADF("Simple channel: %s", BooleanToEngStr(Data->GetSshSimple()));
      ADF("Return code variable: %s; Lookup user groups: %s",
        Data->GetDetectReturnVar() ? UnicodeString(L"Autodetect") : Data->GetReturnVar(),
        EnumName(Data->GetLookupUserGroups(), AutoSwitchNames));
      ADF("Shell: %s", Data->GetShell().IsEmpty() ? UnicodeString(L"default") : Data->GetShell());
      ADF("EOL: %s, UTF: %s", EnumName(Data->GetEOLType(), EOLTypeNames), EnumName(Data->GetNotUtf(), NotAutoSwitchNames)); // NotUtf duplicated in FTP branch
      ADF("Clear aliases: %s, Unset nat.vars: %s, Resolve symlinks: %s; Follow directory symlinks: %s",
        BooleanToEngStr(Data->GetClearAliases()), BooleanToEngStr(Data->GetUnsetNationalVars()),
        BooleanToEngStr(Data->GetResolveSymlinks()), BooleanToEngStr(Data->GetFollowDirectorySymlinks()));
      ADF("LS: %s, Ign LS warn: %s, Scp1 Comp: %s",
        Data->GetListingCommand(),
        BooleanToEngStr(Data->GetIgnoreLsWarnings()),
        BooleanToEngStr(Data->GetScp1Compatibility()));
    }
    if ((Data->GetFSProtocol() == fsSFTP) || (Data->GetFSProtocol() == fsSFTPonly))
    {
      UnicodeString Bugs;
      for (intptr_t Index = 0; Index < SFTP_BUG_COUNT; ++Index)
      {
        AddToList(Bugs, EnumName(Data->GetSFTPBug(static_cast<TSftpBug>(Index)), AutoSwitchNames), L",");
      }
      ADF("SFTP Bugs: %s", Bugs);
      ADF("SFTP Server: %s", Data->GetSftpServer().IsEmpty() ? UnicodeString(L"default") : Data->GetSftpServer());
    }
    bool FtpsOn = false;
    if (Data->GetFSProtocol() == fsFTP)
    {
      ADF("UTF: %s", EnumName(Data->GetNotUtf(), NotAutoSwitchNames)); // duplicated in UsesSsh branch
      UnicodeString Ftps;
      switch (Data->GetFtps())
      {
      case ftpsImplicit:
        Ftps = L"Implicit TLS/SSL";
        FtpsOn = true;
        break;

      case ftpsExplicitSsl:
        Ftps = L"Explicit SSL/TLS";
        FtpsOn = true;
        break;

      case ftpsExplicitTls:
        Ftps = L"Explicit TLS/SSL";
        FtpsOn = true;
        break;

      default:
        DebugAssert(Data->GetFtps() == ftpsNone);
        Ftps = L"None";
        break;
      }
      // kind of hidden option, so do not reveal it unless it is set
      if (Data->GetFtpTransferActiveImmediately() != asAuto)
      {
        ADF("Transfer active immediately: %s", EnumName(Data->GetFtpTransferActiveImmediately(), AutoSwitchNames));
      }
      ADF("FTPS: %s [Client certificate: %s]",
        Ftps, LogSensitive(Data->GetTlsCertificateFile()));
      ADF("FTP: Passive: %s [Force IP: %s]; MLSD: %s [List all: %s]; HOST: %s",
        BooleanToEngStr(Data->GetFtpPasvMode()),
        EnumName(Data->GetFtpForcePasvIp(), AutoSwitchNames),
        EnumName(Data->GetFtpUseMlsd(), AutoSwitchNames),
        EnumName(Data->GetFtpListAll(), AutoSwitchNames),
        EnumName(Data->GetFtpHost(), AutoSwitchNames));
    }
    if (Data->GetFSProtocol() == fsWebDAV)
    {
      FtpsOn = (Data->GetFtps() != ftpsNone);
      ADF("HTTPS: %s [Client certificate: %s]",
        BooleanToEngStr(FtpsOn), LogSensitive(Data->GetTlsCertificateFile()));
    }
    if (FtpsOn)
    {
      if (Data->GetFSProtocol() == fsFTP)
      {
        ADF("Session reuse: %s", BooleanToEngStr(Data->GetSslSessionReuse()));
      }
      ADF("TLS/SSL versions: %s-%s", GetTlsVersionName(Data->GetMinTlsVersion()), GetTlsVersionName(Data->GetMaxTlsVersion()));
    }
    ADF("Local directory: %s, Remote directory: %s, Update: %s, Cache: %s",
      Data->GetLocalDirectory().IsEmpty() ? UnicodeString(L"default") : Data->GetLocalDirectory(),
      Data->GetRemoteDirectory().IsEmpty() ? UnicodeString(L"home") : Data->GetRemoteDirectory(),
      BooleanToEngStr(Data->GetUpdateDirectories()),
      BooleanToEngStr(Data->GetCacheDirectories()));
    ADF("Cache directory changes: %s, Permanent: %s",
      BooleanToEngStr(Data->GetCacheDirectoryChanges()),
      BooleanToEngStr(Data->GetPreserveDirectoryChanges()));
    ADF("Recycle bin: Delete to: %s, Overwritten to: %s, Bin path: %s",
      BooleanToEngStr(Data->GetDeleteToRecycleBin()),
      BooleanToEngStr(Data->GetOverwrittenToRecycleBin()),
      Data->GetRecycleBinPath());
    if (Data->GetTrimVMSVersions())
    {
      ADF("Trim VMS versions: %s",
        BooleanToEngStr(Data->GetTrimVMSVersions()));
    }
    UnicodeString TimeInfo;
    if ((Data->GetFSProtocol() == fsSFTP) || (Data->GetFSProtocol() == fsSFTPonly) || (Data->GetFSProtocol() == fsSCPonly) || (Data->GetFSProtocol() == fsWebDAV))
    {
      AddToList(TimeInfo, FORMAT(L"DST mode: %s", EnumName(ToInt(Data->GetDSTMode()), DSTModeNames)), L";");
    }
    if ((Data->GetFSProtocol() == fsSCPonly) || (Data->GetFSProtocol() == fsFTP))
    {
      intptr_t TimeDifferenceMin = TimeToMinutes(Data->GetTimeDifference());
      AddToList(TimeInfo, FORMAT(L"Timezone offset: %dh %dm", TimeDifferenceMin / MinsPerHour, TimeDifferenceMin % MinsPerHour), L";");
    }
    ADSTR(TimeInfo);

    if (Data->GetFSProtocol() == fsWebDAV)
    {
      ADF("Compression: %s",
        BooleanToEngStr(Data->GetCompression()));
    }

    AddSeparator();
  }
}