String RecoverySystem::SanitizeArg(
    /* [in] */ const String& arg)
{
    String result = arg.Replace('\0', '?');;
    result = result.Replace('\n', '?');
    return result;
}
Example #2
0
   String 
      MimeBody::GenerateFileNameFromEncapsulatedSubject(bool unicode) const
   {
      if (!IsEncapsulatedRFC822Message())
         return "";

      shared_ptr<MimeBody> pEncapsulatedMessage = LoadEncapsulatedMessage();

      String sFilename = unicode ? 
         pEncapsulatedMessage->GetUnicodeFieldValue("Subject") :
      pEncapsulatedMessage->GetRawFieldValue("Subject");

      if (!sFilename.IsEmpty())
      {
         // Do some cleaning to reduce the risk of vulnerability in
         // COM client which does not check files before saving them
         // locally.
         sFilename.Replace(_T("\\"), _T(""));
         sFilename.Replace(_T("/"), _T(""));
         sFilename.Replace(_T(":"), _T(""));

         sFilename = sFilename + ".eml";
      }

      return sFilename;
   }
Example #3
0
// Joins the path of an RML or RCSS file with the path of a resource specified within the file.
void SystemInterface::JoinPath(String& translated_path, const String& document_path, const String& path)
{
	// If the path is absolute, strip the leading / and return it.
	if (path.Substring(0, 1) == "/")
	{
		translated_path = path.Substring(1);
		return;
	}

	// If the path is a Windows-style absolute path, return it directly.
	size_t drive_pos = path.Find(":");
	size_t slash_pos = Math::Min(path.Find("/"), path.Find("\\"));
	if (drive_pos != String::npos &&
		drive_pos < slash_pos)
	{
		translated_path = path;
		return;
	}

	// Strip off the referencing document name.
	translated_path = document_path;
	translated_path = translated_path.Replace("\\", "/");
	size_t file_start = translated_path.RFind("/");
	if (file_start != String::npos)
		translated_path.Resize(file_start + 1);
	else
		translated_path.Clear();

	// Append the paths and send through URL to removing any '..'.
	URL url(translated_path.Replace(":", "|") + path.Replace("\\", "/"));
	translated_path = url.GetPathedFileName().Replace("|", ":");
}
Example #4
0
/**
*  @brief
*    Gets a AngelScript function declaration
*/
String Script::GetAngelScriptFunctionDeclaration(const String &sFunctionName, const String &sFunctionSignature, bool bCppToAngelScript) const
{
	// Start with the PixelLight function signature (e.g. "void(int,float)")
	String sFunctionDeclaration = sFunctionSignature;

	// Find the index of the "("
	int nIndex = sFunctionDeclaration.IndexOf("(");
	if (nIndex > -1) {

		// [HACK] AngelScript really don't like something like "string MyFunction(string)", it want's "string @MyFunction(const string &)"!
		// I assume that "@" means "AngelScript, take over the control of the given memory". I wasn't able to find the documentation about
		// the AngelScript function declaration syntax, just "scriptstring.cpp" as example.
		if (bCppToAngelScript && sFunctionDeclaration.IndexOf("string") > -1) {
			String sParameters = sFunctionDeclaration.GetSubstring(nIndex);	// Find the parameters part in the string
			sParameters.Replace("string", "const string &");				// Change parameters
			sFunctionDeclaration.Delete(nIndex);							// Remove parameters from original function declaration
			sFunctionDeclaration.Replace("string", "string @");				// Change return
			sFunctionDeclaration += sParameters;							// Construct new function declaration
			nIndex = sFunctionDeclaration.IndexOf("(");						// Update the "(" index
		}

		// Create the AngelScript function declaration (e.g. "void MyFunction(int,float)")
		sFunctionDeclaration.Insert(' ' + sFunctionName, nIndex);
	}

	// Return the AngelScript function declaration (e.g. "void MyFunction(int,float)")
	return sFunctionDeclaration;
}
Example #5
0
String ResourceCache::SanitateResourceName(const String& nameIn) const
{
    // Sanitate unsupported constructs from the resource name
    String name = GetInternalPath(nameIn);
    name.Replace("../", "");
    name.Replace("./", "");
    return name;
}
Example #6
0
void DisplayMenuToClient (edict_t *ent, MenuText *menu)
{
   if (!IsValidPlayer (ent))
      return;

   int clientIndex = ENTINDEX (ent) - 1;

   if (menu != null)
   {
      String tempText = String (menu->menuText);
      tempText.Replace ("\v", "\n");

      char *text = g_localizer->TranslateInput (tempText);
      tempText = String (text);

      // make menu looks best
      for (int i = 0; i <= 9; i++)
         tempText.Replace (FormatBuffer ("%d.", i), FormatBuffer ("\\r%d.\\w", i));

      text = tempText;

      while (strlen (text) >= 64)
      {
         MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, g_netMsg->GetId (NETMSG_SHOWMENU), null, ent);
            WRITE_SHORT (menu->validSlots);
            WRITE_CHAR (-1);
            WRITE_BYTE (1);

         for (int i = 0; i <= 63; i++)
            WRITE_CHAR (text[i]);

         MESSAGE_END ();

         text += 64;
      }

      MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, g_netMsg->GetId (NETMSG_SHOWMENU), null, ent);
         WRITE_SHORT (menu->validSlots);
         WRITE_CHAR (-1);
         WRITE_BYTE (0);
         WRITE_STRING (text);
      MESSAGE_END();

      g_clients[clientIndex].menu = menu;
   }
   else
   {
      MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, g_netMsg->GetId (NETMSG_SHOWMENU), null, ent);
         WRITE_SHORT (0);
         WRITE_CHAR (0);
         WRITE_BYTE (0);
         WRITE_STRING ("");
      MESSAGE_END();

     g_clients[clientIndex].menu = null;
   }
   CLIENT_COMMAND (ent, "speak \"player/geiger1\"\n"); // Stops others from hearing menu sounds..
}
Example #7
0
void ProcessMaterials (String& code)
{
	code.Replace("R5_materialSpecularity",		"R5_materialParams0.x", true);
	code.Replace("R5_materialSpecularHue",		"R5_materialParams0.y", true);
	code.Replace("R5_materialGlow",				"R5_materialParams0.z", true);
	code.Replace("R5_materialOcclusion",		"R5_materialParams0.w", true);
	code.Replace("R5_materialShininess",		"R5_materialParams1.x", true);
	code.Replace("R5_materialReflectiveness",	"R5_materialParams1.y", true);
}
Example #8
0
String DateTime::ToFormat(const String& format) const
{
	String s = format.IsEmpty() ? "M/D/YYYY" : format;
	TimeSpan t = *this;
	String ampm = "am";
	if (s.Contains("am/pm") || s.Contains("AM/PM"))
	{
		s = s.Replace("am/pm", "{4}");
		s = s.Replace("AM/PM", "{5}");
		if (t.Hours() >= 12)
		{
			t = t.AddHours(-12);
			ampm = "pm";
		}
		else if (t.Hours() == 0)
			t = t.AddHours(12);
	}
	String AMPM = ampm.ToUpper();
	YearString y(*this);
	MonthString m(*this);
	DayString d(*this);
	s = s
		.Replace("YYYY", "{0:~~~~}")
		.Replace("YY", "{0:~~}")
		.Replace("MMMM", "{1:~~~~}")
		.Replace("MMM", "{1:~~~}")
		.Replace("MM", "{1:~~}")
		.Replace("M", "{1}")
		.Replace("DDDD", "{2:~~~~}")
		.Replace("DDD", "{2:~~~}")
		.Replace("DD", "{2:~~}")
		.Replace("D", "{2}")
		.Replace("hh", "{3:HH}")
		.Replace("h", "{3:H}")
		.Replace("mm", "{3:MM}")
		.Replace("m", "{3:M}")
		.Replace("ss", "{3:SS}")
		.Replace("s", "{3:S}")
		.Replace("nnn", "{3:NNN}")
		.Replace("nn", "{3:NN}")
		.Replace("n", "{3:N}")
		.Replace("{3:HH}", "{3:hh}")
		.Replace("{3:H}", "{3:h}")
		.Replace("{3:MM}", "{3:mm}")
		.Replace("{3:M}", "{3:m}")
		.Replace("{3:SS}", "{3:ss}")
		.Replace("{3:S}", "{3:s}")
		.Replace("{3:NNN}", "{3:nnn}")
		.Replace("{3:NN}", "{3:nn}")
		.Replace("{3:N}", "{3:n}");
	if (s.Contains("{4}"))
		s = s.Replace("{4}", ampm);
	if (s.Contains("{5}"))
		s = s.Replace("{5}", AMPM);
	return Format(s, y, m, d, t);
}
Example #9
0
String FrameStandardGame::GetNormalizedInput()
{
	String input = curInput.AsciiLower();
	input.Replace("aa",String(257));
	input.Replace("ee",String(275));
	//input.Replace("ii",String(299));
	input.Replace("oo",String(333));
	input.Replace("ou",String(333));
	input.Replace("uu",String(363));
	return input;
}
Example #10
0
/**
*  @brief
*    Removes precision qualifiers from the given GLSL shader source code
*/
String Shader::RemovePrecisionQualifiersFromGLSL(const String &sSourceCode)
{
	// Remove precision qualifiers
	String sModifiedSourceCode = sSourceCode;
	sModifiedSourceCode.Replace("lowp",    "");
	sModifiedSourceCode.Replace("mediump", "");
	sModifiedSourceCode.Replace("highp",   "");

	// Done
	return sModifiedSourceCode;
}
Example #11
0
void Script::OutputAPIRow(const String& row, bool removeReference)
{
    String out = row;
    ///\todo We need Regex capability in String class to handle whole-word replacement correctly.
    // Temporary fix to prevent property name like 'doubleClickInterval' from being wrongly replaced.
    // Fortunately, there is no occurence of type 'double' in the API at the moment.
    //out.Replace("double", "float");
    out.Replace("&in", "&");
    out.Replace("&out", "&");
    if (removeReference)
        out.Replace("&", "");

    Log::WriteRaw("- " + out + "\n");
}
Example #12
0
   std::shared_ptr<Result>
   Events::FireOnExternalAccountDownload(std::shared_ptr<FetchAccount> fetchAccount, std::shared_ptr<Message> pMessage, const String &sRemoteUID)
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Called once each time delivery to a recipient failed. It may be called
   // several times for a single message.
   //---------------------------------------------------------------------------()
   {
      // Send an event
      std::shared_ptr<Result> pResult = std::shared_ptr<Result>(new Result);
      if (!Configuration::Instance()->GetUseScriptServer())
         return pResult;
      
      String sEventCaller;

      String sRemoteUIDCopy = sRemoteUID;

      String sScriptLanguage = Configuration::Instance()->GetScriptLanguage();

      if (sScriptLanguage == _T("VBScript"))
      {
         sRemoteUIDCopy.Replace(_T("\""), _T("\"\""));

         if (pMessage)
            sEventCaller.Format(_T("OnExternalAccountDownload(HMAILSERVER_FETCHACCOUNT, HMAILSERVER_MESSAGE, \"%s\")"), sRemoteUIDCopy.c_str());
         else
            sEventCaller.Format(_T("OnExternalAccountDownload(HMAILSERVER_FETCHACCOUNT, Nothing, \"%s\")"), sRemoteUIDCopy.c_str());
      }
      else if (sScriptLanguage == _T("JScript"))
      {
         sRemoteUIDCopy.Replace(_T("'"), _T("\'"));

         if (pMessage)
            sEventCaller.Format(_T("OnExternalAccountDownload(HMAILSERVER_FETCHACCOUNT, HMAILSERVER_MESSAGE, '%s')"), sRemoteUIDCopy.c_str());
         else
            sEventCaller.Format(_T("OnExternalAccountDownload(HMAILSERVER_FETCHACCOUNT, null, '%s')"), sRemoteUIDCopy.c_str());
      }

      std::shared_ptr<ScriptObjectContainer> pContainer  = std::shared_ptr<ScriptObjectContainer>(new ScriptObjectContainer);
      
      pContainer->AddObject("HMAILSERVER_FETCHACCOUNT", fetchAccount, ScriptObject::OTFetchAccount);

      if (pMessage)
         pContainer->AddObject("HMAILSERVER_MESSAGE", pMessage, ScriptObject::OTMessage);
      pContainer->AddObject("Result", pResult, ScriptObject::OTResult);

      ScriptServer::Instance()->FireEvent(ScriptServer::EventOnExternalAccountDownload, sEventCaller, pContainer);

      return pResult;
   }
Example #13
0
void Script::GetAssociatedFilenames(Array<String> &lstFilenames)
{
	// We want to have a list of script filenames which were included within this script
	// -> It appears that there's no "easy" way in Lua to get this kind of information :/

	// Contains "Application", "Interaction" and so on (no final filenames)
	Array<String> lstRequire;

	// Get a list of loaded "require"-files
	{ // -> The files loaded within a Lua script by using "require" can be accessed by using the
		//    global control table variable "_LOADED". See http://www.lua.org/pil/8.1.html for details.
		lua_getfield(m_pLuaState, LUA_REGISTRYINDEX, "_LOADED");
		if (lua_istable(m_pLuaState, -1)) {
			lua_pushnil(m_pLuaState);
			while (lua_next(m_pLuaState, -2)) {
				if (lua_isstring(m_pLuaState, -2))
					lstRequire.Add(lua_tostring(m_pLuaState, -2));
				lua_pop(m_pLuaState, 1);
			}
		}

		// Pop the table from the Lua stack
		lua_pop(m_pLuaState, 1);
	}

	// Get the content of "package.path" used by "require" to search for a Lua loader
	// -> The content looks like "?.lua;C:\SomePath\?.lua;"
	const String sPackagePath = GetGlobalVariable("path", "package");

	// Iterate over the "require"-list
	const String sToReplace = "?.";
	for (uint32 i=0; i<lstRequire.GetNumOfElements(); i++) {
		// Get the current "require"
		const String sRequire = lstRequire[i] + '.';

		// Get the index of the first ";" within the package path
		int nPreviousIndex = 0;
		int nIndex = sPackagePath.IndexOf(';');
		while (nIndex>-1) {
			// Get current package search path, we now have e.g. "C:\SomePath\?.lua"
			String sFilename = sPackagePath.GetSubstring(nPreviousIndex, nIndex-nPreviousIndex);

			// Replace "?." with the "require"-name
			sFilename.Replace(sToReplace, sRequire);

			// Does this file exist?
			if (File(sFilename).Exists()) {
				// We found a match!
				lstFilenames.Add(sFilename);

				// Get us out of the while-loop
				nIndex = -1;
			} else {
				// Get the index of the next ";" within the package path
				nPreviousIndex = nIndex + 1;
				nIndex = sPackagePath.IndexOf(';', nPreviousIndex);
			}
		}
	}
}
   VirusScanningResult 
   CustomVirusScanner::Scan(const String &executablePath, int virusReturnCode, const String &sFilename)
   {
      LOG_DEBUG("Running custom virus scanner...");


      String sPath = FileUtilities::GetFilePath(sFilename);

      String sCommandLine;

      if (executablePath.Find(_T("%FILE%")) >= 0)
      {
         sCommandLine = executablePath;
         sCommandLine.Replace(_T("%FILE%"), sFilename);
      }
      else
         sCommandLine.Format(_T("%s %s"), executablePath, sFilename);

      unsigned int exitCode = 0;
      ProcessLauncher launcher(sCommandLine, sPath);
      launcher.SetErrorLogTimeout(20000);
      if (!launcher.Launch(exitCode))
      {
         return VirusScanningResult("CustomVirusScanner::Scan", "Unable to launch executable.");
      }

      String sDebugMessage = Formatter::Format("Scanner: {0}. Return code: {1}", sCommandLine, exitCode);
      LOG_DEBUG(sDebugMessage);

      if (exitCode == virusReturnCode)
         return VirusScanningResult(VirusScanningResult::VirusFound, "Unknown");
      else
         return VirusScanningResult(VirusScanningResult::NoVirusFound, Formatter::Format("Return code: {0}", exitCode));

   }
Example #15
0
   void
   VirusScanner::BlockAttachments(shared_ptr<Message> pMessage)
   {
      shared_ptr<BlockedAttachments> pBlockedAttachments = HM::Configuration::Instance()->GetBlockedAttachments();

      vector<shared_ptr<BlockedAttachment> > vecBlockedAttachments = pBlockedAttachments->GetVector();
      vector<shared_ptr<BlockedAttachment> >::iterator iterBA;

      const String fileName = PersistentMessage::GetFileName(pMessage);

      shared_ptr<MessageData> pMsgData = shared_ptr<MessageData>(new MessageData());
      pMsgData->LoadFromMessage(fileName, pMessage);

      shared_ptr<Attachments> pAttachments = pMsgData->GetAttachments();

      bool bChangesMade = false;

      for (unsigned int i = 0; i < pAttachments->GetCount(); i++)
      {
         shared_ptr<Attachment> pAttachment = pAttachments->GetItem(i);

         // Check if attachment matches blocked file.
         for (iterBA = vecBlockedAttachments.begin(); iterBA < vecBlockedAttachments.end(); iterBA++)
         {
            String sWildcard = (*iterBA)->GetWildcard();

            if (StringParser::WildcardMatchNoCase(sWildcard, pAttachment->GetFileName()))
            {
               // Match. Remove the attachment and add a new dummy.
               bChangesMade = true;
               pAttachment->Delete();

               String sBody = Configuration::Instance()->GetServerMessages()->GetMessage("ATTACHMENT_REMOVED");

               // Replace macros.
               sBody.Replace(_T("%MACRO_FILE%"), pAttachment->GetFileName());

               // Add the new
               shared_ptr<MimeBody> pBody = pMsgData->CreatePart(_T("application/octet-stream"));
               pBody->SetRawText(sBody);

               // Create an content-disposition header.
               pBody->SetRawFieldValue(CMimeConst::ContentDisposition(), CMimeConst::Inline(), "");
               pBody->SetParameter(CMimeConst::ContentDisposition(), CMimeConst::Filename(), pAttachment->GetFileName() + ".txt");

               break;
            }

         }
      }

      if (bChangesMade)
      {
         pMsgData->Write(fileName);
         
         // Update the size of the message.
         pMessage->SetSize(FileUtilities::FileSize(fileName));
      }

   }
ECode CLocaleBuilder::NormalizeAndValidateVariant(
    /* [in] */ const String& variant,
    /* [out] */ String* str)
{
    VALIDATE_NOT_NULL(str)
    *str = String("");

    if (variant.IsNullOrEmpty()) {
        return NOERROR;
    }

    // Note that unlike extensions, we canonicalize to lower case alphabets
    // and underscores instead of hyphens.
    String normalizedVariant = variant.Replace('-', '_');
    AutoPtr<ArrayOf<String> > subTags;
    StringUtils::Split(normalizedVariant, String("_"), (ArrayOf<String>**)&subTags);

    for (Int32 i = 0; i < subTags->GetLength(); ++i) {
        if (!IsValidVariantSubtag((*subTags)[i])) {
            ALOGE("CLocaleBuilder::NormalizeAndValidateVariant: IllformedLocaleException, Invalid variant: %s", variant.string());
            return E_ILLFORMED_LOCALE_EXCEPTION;
        }
    }

    *str = normalizedVariant;
    return NOERROR;
}
   IMAPResult
   IMAPCommandNamespace::ExecuteCommand(std::shared_ptr<HM::IMAPConnection> pConnection, std::shared_ptr<IMAPCommandArgument> pArgument)
   {
      if (!pConnection->IsAuthenticated())
         return IMAPResult(IMAPResult::ResultNo, "Authenticate first");

      std::shared_ptr<IMAPSimpleCommandParser> pParser = std::shared_ptr<IMAPSimpleCommandParser>(new IMAPSimpleCommandParser());
      pParser->Parse(pArgument);

      if (pParser->WordCount() < 1)
         return IMAPResult(IMAPResult::ResultBad, "NAMESPACE command requires exactly 0 parameter.");

      String sPublicFolderName = Configuration::Instance()->GetIMAPConfiguration()->GetIMAPPublicFolderName();
      String hierarchyDelimiter = Configuration::Instance()->GetIMAPConfiguration()->GetHierarchyDelimiter();
      hierarchyDelimiter.Replace(_T("\\"), _T("\\\\"));

      String sPersonalNamespace = "((\"\" \"" + hierarchyDelimiter + "\"))";
      String sOtherUsersNamespace = "NIL";
      String sSharedNamespaces = "((\"" + sPublicFolderName + "\" \"" + hierarchyDelimiter + "\"))";
      String sResponse;
      
      sResponse.Format(_T("* NAMESPACE %s %s %s\r\n"), sPersonalNamespace.c_str(), sOtherUsersNamespace.c_str(), sSharedNamespaces.c_str());
      sResponse += pArgument->Tag() + _T(" OK namespace command complete\r\n");

      pConnection->SendAsciiData(sResponse);   

      return IMAPResult();
   }
Example #18
0
void FixupPath(String &path)
{
    if (path.IsEmpty())
    {
        return;
    }
    path.Replace('\\', '/');
}
Example #19
0
String RemoveTrailingSlash(const String& pathName)
{
    String ret = pathName.Trimmed();
    ret.Replace('\\', '/');
    if (!ret.Empty() && ret.Back() == '/')
        ret.Resize(ret.Length() - 1);
    return ret;
}
Example #20
0
String AddTrailingSlash(const String& pathName)
{
    String ret = pathName.Trimmed();
    ret.Replace('\\', '/');
    if (!ret.Empty() && ret.Back() != '/')
        ret += '/';
    return ret;
}
Example #21
0
   String 
   Utilities::GetRecipientFromReceivedHeader(const String &sReceivedHeader)
   {
      int iLastSemicolon = sReceivedHeader.ReverseFind(_T(";"));
      if (iLastSemicolon == -1)
         return "";

      String sFirstPart = sReceivedHeader.Mid(0, iLastSemicolon);

      /*
      sFirstPart now contains the following
      received =  "Received"    ":"            ; one per relay
            ["from" domain]           ; sending host
            ["by"   domain]           ; receiving host
            ["via"  atom]             ; physical path
            *("with" atom)             ; link/mail protocol
            ["id"   msg-id]           ; receiver msg id
            ["for"  addr-spec]        ; initial form
            ";"    date-time         ; time received

      http://cr.yp.to/immhf/envelope.html
      In theory, the value of a Received field is tokenizable.
      In practice, SMTP servers put all sorts of badly formatted information into Received lines. 
      Hence: We only do a quick search
      */

      int iForPos = sFirstPart.ReverseFind(_T("for "));
      
      if (iForPos == -1)
         return "";
      
      String sAddressPart = sFirstPart.Mid(iForPos + 4);

      sAddressPart.TrimLeft(_T(" \r\n\t"));
      sAddressPart.TrimRight(_T(" \r\n\t"));

      sAddressPart.Replace(_T("<"), _T(""));
      sAddressPart.Replace(_T(">"), _T(""));
      sAddressPart.Replace(_T(" "), _T(""));

      if (!StringParser::IsValidEmailAddress(sAddressPart))
         return "";

      return sAddressPart;
   }
    NETBuild::NETBuild(Context* context, const String& solutionPath, const StringVector& platforms, const StringVector& configurations) :
        Object(context),
        solutionPath_(solutionPath),
        status_(NETBUILD_PENDING)
    {
        for (unsigned i = 0; i < platforms.Size() ; i++)
        {
            platforms_.Push(platforms[i].ToLower());
        }

        for (unsigned i = 0; i < configurations.Size() ; i++)
        {
            String config = configurations[i];
            config.Replace("release", "Release");
            config.Replace("debug", "Debug");
            configurations_.Push(config);
        }
    }
Example #23
0
ConnectionNode * IRailAPI::createConnectionNode(xmlNodePtr xmlNode,Connection* conn){//connection should be passed so vehicle name can be inserted
	ConnectionNode * cn = new ConnectionNode();
	xmlNodePtr child=null;
	//get children
	for(child=xmlNode->children;child;child=child->next){
		String tagName = getString(child->name);
		if(tagName == "time"){
			cn->setDateTime(getTimeAttribute(child));
		}else if(tagName == "platform"){
			if(child->children){
				cn->setPlatform(getString(child->children->content));
			}else{
				cn->setPlatform(L"-");
			}
		}else if(tagName == "vehicle"){
			if(child->children){
				String ve = getString(child->children->content);
				ve.Replace(L".",L" ");
				Vehicle* vehicle = new Vehicle(ve);
				conn->setVehicle(vehicle);
				//conn->setVehicleName(getStringN(child->children->content));
			}
		}else if(tagName == "station"){
			String stationId;
			for(xmlAttrPtr attr = child->properties; attr; attr=attr->next){
				if (attr != null && attr->type== XML_ATTRIBUTE_NODE) {
					String attrName = getString(attr->name);
					if(attrName == "id")
						stationId = getString(attr->children->content);
				}
			}
			Station* st = AppData::GetInstance()->getStationById(stationId);
			if(st == null){
				st = createStation(child);
				AppData::GetInstance()->getStationList()->Add(st);
			}
			cn->setStation(st);
		}
	}
	//get attributes
	xmlAttrPtr attr = null;
	for(attr = xmlNode->properties; attr; attr=attr->next){
		if (attr != null && attr->type== XML_ATTRIBUTE_NODE) {
			String attrName = getString(attr->name);
			String attrValue = getString(attr->children->content);
			if(attrName == "delay"){
				int delay;
				Integer::Parse(attrValue,delay);
				if(delay > 1){
					TimeSpan del = getTimeSpan(delay);
					cn->setDelay(del);
				}
			}
		}
	}
	return cn;
}
Example #24
0
int WriteMiniDump(const char* applicationName, void* exceptionPointers)
{
    // In case of recursive or repeating exceptions, only write the dump once
    /// \todo This function should not allocate any dynamic memory
    if (miniDumpWritten)
        return EXCEPTION_EXECUTE_HANDLER;
    
    miniDumpWritten = true;
    
    MINIDUMP_EXCEPTION_INFORMATION info;
    info.ThreadId = GetCurrentThreadId();
    info.ExceptionPointers = (EXCEPTION_POINTERS*)exceptionPointers;
    info.ClientPointers = TRUE;
    
    static time_t sysTime;
    time(&sysTime);
    const char* dateTime = ctime(&sysTime);
    String dateTimeStr = String(dateTime);
    dateTimeStr.Replace("\n", "");
    dateTimeStr.Replace(":", "");
    dateTimeStr.Replace("/", "");
    dateTimeStr.Replace(' ', '_');
    
    wchar_t pathName[MAX_PATH];
    pathName[0] = 0;
    SHGetSpecialFolderPathW(0, pathName, CSIDL_PERSONAL, 0);
    String applicationNameStr(applicationName);
    String miniDumpDir = String(pathName) + "\\" + applicationNameStr;
    String miniDumpName = miniDumpDir + "\\" + applicationNameStr + "_" + dateTimeStr + ".dmp";
    
    CreateDirectoryW(WString(miniDumpDir).CString(), 0);
    HANDLE file = CreateFileW(WString(miniDumpName).CString(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ,
        0, CREATE_ALWAYS, 0, 0);
    
    BOOL success = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file, MiniDumpWithDataSegs, &info, 0, 0);
    CloseHandle(file);
    
    if (success)
        ErrorDialog(applicationName, "An unexpected error occurred. A minidump was generated to " + miniDumpName);
    else
        ErrorDialog(applicationName, "An unexpected error occurred. Could not write minidump.");
    
    return EXCEPTION_EXECUTE_HANDLER;
}
int LicenseSystem::ParseResponse(const String& response, LicenseParse& parse)
{

    ATOMIC_LOGINFOF("%s", response.CString());

    if (response.StartsWith("AC_ACTIVATIONSEXCEEDED"))
    {
        return 1;
    }

    if (response.StartsWith("AC_IDNOTACTIVATED"))
    {
        return 4;
    }

    if (response.StartsWith("AC_FAILED"))
    {
        return 2;
    }

    if (!response.StartsWith("WINDOWS"))
    {
        ATOMIC_LOGERRORF("Error Parsing Server Response %s", response.CString());
        return 3;
    }

    String codes = response;
    codes.Replace("\n", "");
    codes.Replace("\r", "");

    Vector<String> cvector = codes.Split(' ');

    for (unsigned i = 0; i < cvector.Size(); i++)
    {
        Vector<String> feature = cvector[i].Split('=');
        if (feature.Size() != 2)
            continue;

        if (feature[0] == "WINDOWS")
            parse.licenseWindows_ = !feature[1].StartsWith("0");
        else if (feature[0] == "MAC")
            parse.licenseMac_ = !feature[1].StartsWith("0");
        else if (feature[0] == "ANDROID")
            parse.licenseAndroid_ = !feature[1].StartsWith("0");
        else if (feature[0] == "IOS")
            parse.licenseIOS_ = !feature[1].StartsWith("0");
        else if (feature[0] == "HTML5")
            parse.licenseHTML5_ = !feature[1].StartsWith("0");
        else if (feature[0] == "THREED")
            parse.licenseModule3D_ = !feature[1].StartsWith("0");

    }

    return 0;

}
void DocumentHeader::MergePaths(StringList& target, const StringList& source, const String& source_path)
{
	for (size_t i = 0; i < source.size(); i++)
	{
		String joined_path;
		Rocket::Core::GetSystemInterface()->JoinPath(joined_path, source_path.Replace("|", ":"), source[i].Replace("|", ":"));

		target.push_back(joined_path.Replace(":", "|"));
	}
}
   bool 
   SQLScriptParser::PreprocessLine_(String &sLine)
   {
      // Do some basic preprocessing...
      while (sLine.Left(2).Compare(_T("\r\n")) == 0)
         sLine = sLine.Mid(2);
      
      while (sLine.Left(1).Compare(_T(" ")) == 0)
         sLine = sLine.Mid(1);
     
      while (sLine.Left(1).Compare(_T("\t")) == 0)
         sLine = sLine.Mid(1);


      String sTempLine = sLine;

      if (settings_->GetType() == HM::DatabaseSettings::TypeMSSQLCompactEdition)
      {
         if (sTempLine.ToLower().Left(3).Compare(_T("if ")) == 0)
         {
            return false;
         }
         else if (sLine.FindNoCase(_T(" CLUSTERED ")) >= 0)
         {
            sLine.ReplaceNoCase(_T(" CLUSTERED "), _T(" "));
         }
         else if (sLine.FindNoCase(_T("CREATE PROC")) >= 0)
         {
            // Procedures not supported by SQL CE
            return false;
         }

         sLine.Replace(_T("\t"), _T(" "));
         sLine.Replace(_T(" varchar"), _T(" nvarchar"));

      }

      if (sLine.IsEmpty())
         return false;


      return true;
   }
Example #28
0
void ShellOpenFolder(const String& dir)
{
	#if defined(PLATFORM_WIN32)
		LaunchWebBrowser(dir);
	#elif __APPLE__
		String tempDir = dir;
		tempDir.Replace(" ", "\\ ");

		IGNORE_RESULT(
			system("open " + tempDir + " &")
		);
	#else
		String tempDir = dir;
		tempDir.Replace(" ", "\\ ");
		
		IGNORE_RESULT(
			system("xdg-open " + tempDir + " &")
		);
	#endif
}
Example #29
0
String Asset::GetRelativePath()
{
    Project* project =GetSubsystem<ToolSystem>()->GetProject();

    String path = path_;

    path.Replace(project->GetResourcePath(), "", false);

    return path;

}
Example #30
0
inline void Replace (String& code, const char* match, const char* replacementText, const char* absentText)
{
	if (!code.Replace(match, replacementText, true))
	{
		code << "\t";
		code << replacementText;
		code << " = ";
		code << absentText;
		code << ";\n";
	}
}