//--------------------------------------------------------------------------------
bool DoMonitor(const char* pBuf, CTokenMaster*& pMaster)
	{
	if(pBuf == NULL)
		{
		printf("error ^^^^^^^\n");
		return false;
		}

	char sTemp[256];
	strcpy(sTemp, pBuf);

	char* pUser = sTemp;
	char* pPwd = strchr(sTemp, ',');
	if(pPwd == NULL)
		{
		printf("error ^^^^^^^ must be username, password\n");
		return false;
		}

	*pPwd = 0;
	pPwd++;

	strcpy(g_pMonitorUser, TrimString(sTemp));
	strcpy(g_pMonitorPwd, TrimString(pPwd));
	return true;
	}
Exemple #2
0
static bool GetConfigOptions(std::istream& stream, std::string& error, std::vector<std::pair<std::string, std::string>> &options)
{
    std::string str, prefix;
    std::string::size_type pos;
    int linenr = 1;
    while (std::getline(stream, str)) {
        if ((pos = str.find('#')) != std::string::npos) {
            str = str.substr(0, pos);
        }
        const static std::string pattern = " \t\r\n";
        str = TrimString(str, pattern);
        if (!str.empty()) {
            if (*str.begin() == '[' && *str.rbegin() == ']') {
                prefix = str.substr(1, str.size() - 2) + '.';
            } else if (*str.begin() == '-') {
                error = strprintf("parse error on line %i: %s, options in configuration file must be specified without leading -", linenr, str);
                return false;
            } else if ((pos = str.find('=')) != std::string::npos) {
                std::string name = prefix + TrimString(str.substr(0, pos), pattern);
                std::string value = TrimString(str.substr(pos + 1), pattern);
                options.emplace_back(name, value);
            } else {
                error = strprintf("parse error on line %i: %s", linenr, str);
                if (str.size() >= 2 && str.substr(0, 2) == "no") {
                    error += strprintf(", if you intended to specify a negated option, use %s=1 instead", str);
                }
                return false;
            }
        }
        ++linenr;
    }
    return true;
}
void InputManager::Initialize()
{
#define USEINPUTKEY(e,hashVal,text) \
	_keyNameTable[ToUpper(text)] = e;
#include "InputKeys.h"
#undef USEINPUTKEY

	//Clear Xbox Button States
	ClearXboxButtonStates();
	
	StringList bindings;
	GetLinesFromFile("Config/input_bindings.ini", bindings);
	StringList::iterator it = bindings.begin();
	while (it != bindings.end())
	{
		if (((*it).size() == 0) || ((*it)[0] == ';'))
		{
			it++;
			continue;
		}
		StringList splitBinding = SplitString(*it, "=:", false);
		if (splitBinding.size() >= 2)
		{
			splitBinding[0] = TrimString(splitBinding[0]);
			splitBinding[1] = TrimString(splitBinding[1]);
			BindKey(splitBinding[0], splitBinding[1]);
		}
		it++;
	}
}
/**
* Description:  GetFieldValue().    获取指定头域的内容
* @param  [in]  strField    所有头域字符串
* @param  [in]  strKey      头域Key值
* @param  [out] strContent  头域内容
* @param  [in]  strEnd          结束符
* @param  [in]  strInterval     分隔符
* @return       long.   返回码
*/
long CRtspPacket::GetFieldValue
(
    IN  const string&   strField,
    IN  const string&   strKey,
    OUT string&         strContent,
    IN  const string&   strEnd,
    IN  const string&   strInterval
)
{
    //先加一个结束符
    std::string strFieldTmp = strField + strEnd;//lint !e1036
    
    string strLine;
    string strValue;
    size_t nPosLineStart = 0;
    size_t nPosLineEnd = strFieldTmp.find(strEnd, nPosLineStart);

    long lResult = RTSP::RET_CODE_FAIL;
    
    while(string::npos != nPosLineEnd)
    {
        strLine = strFieldTmp.substr(nPosLineStart, nPosLineEnd - nPosLineStart);
    
        size_t nPosStart = 0;
        size_t nPosEnd = strLine.find(strInterval, nPosStart);

        //找到冒号,说明是某头域,进一步解析头域的值
        if (string::npos != nPosEnd)
        {
            strValue = strLine.substr(nPosStart, (nPosEnd - nPosStart));   //lint !e845

            //去掉字符串首尾的空格、Tab
            TrimString(strValue);

            //不区分大小写的比较,找到则直接退出
            if (0 == _strnicmp(strKey.c_str(), strValue.c_str(), strKey.length()))
            {
                //提取内容
                strContent = strLine.substr(nPosEnd + 1, nPosLineEnd - nPosEnd);
                //去掉字符串首尾的空格、Tab
                TrimString(strContent);
                
                lResult = RTSP::RET_CODE_OK;
                break;
            }
        }        

        //下一个行
        nPosLineStart = nPosLineEnd + strEnd.size();
        nPosLineEnd = strFieldTmp.find(strEnd, nPosLineStart);
    }
    
    return lResult;
}
Exemple #5
0
void SimpleConfig::_parse(std::istream &is) {
	std::vector<std::string> lines;
	std::vector<std::string>::iterator L;
	std::string line;
	int state = 0;
	line.reserve(256);
	while (is.good() && !is.eof()) {
		char buffer[1024];
		is.getline(buffer, 1024);
		buffer[1023] = 0;
		lines.push_back(buffer);
	}
	line = "";
	state = 0;
	std::string section;
	std::string comment;
	int line_no = 0;
	for (L = lines.begin(); L != lines.end(); L++) {
		line = TrimString(*L, WHITESPACE);
		line_no++;
		if (line == "") {
			if (L+1 != lines.end()) {
				_addComment(line);
			}
		} else {
			char c = line[0];
			if (c == SECTION_START) {
				int e = line.find(SECTION_END);
				if (e < 0) {
					throw ConfigError("missing end-section tag", m_file, line_no, *L);
				}
				section = line.substr(1, e-1);
				_addSection(section);
			} else
			if (c == COMMENT_CHAR) {
				_addComment(line);
			} else {
				int eq = line.find_first_of(EQUAL_CHAR);
				if (eq < 0) {
					throw ConfigError("missing equal sign in key-value pair", m_file, line_no, *L);
				}
				std::string key = TrimString(line.substr(0, eq), WHITESPACE);
				std::string value = TrimString(line.substr(eq+1), WHITESPACE);
				_addValue(section, key, value);
			}
		}
	}
}
Exemple #6
0
void zs_ut_s::TrimString(char * str, int flag)
{
	assert(str != NULL);
	std::string s = str;
	TrimString(s, flag);
	strcpy(str, s.c_str());
}
Exemple #7
0
bool CheatFileParser::Parse() {
	for (line_ = 1; file_ && !file_.eof(); ++line_) {
		std::string line;
		getline(file_, line, '\n');
		line = TrimString(line);

		// Minimum length is set to 5 just to match GetCodesList() function
		// which discards anything shorter when called anyway.
		// It's decided from shortest possible _ lines name of the game "_G N+"
		// and a minimum of 1 displayable character in cheat name string "_C0 1"
		// which both equal to 5 characters.
		if (line.length() >= 5 && line[0] == '_') {
			ParseLine(line);
		} else if (line.length() >= 2 && line[0] == '/' && line[1] == '/') {
			// Comment, ignore.
		} else if (line.length() >= 1 && line[0] == '#') {
			// Comment, ignore.
		} else if (line.length() > 0) {
			errors_.push_back(StringFromFormat("Unrecognized content on line %d: expecting _", line_));
		}
	}

	Flush();

	return errors_.empty();
}
Exemple #8
0
const char * StringUtils::ExtractPropertyName(const char *a_buffer, const char *a_delim)
{
	// Early out for bad string or no delim
	const char * delimLoc = strstr(a_buffer, a_delim);
	if (a_buffer == NULL || 
		strlen(a_buffer) == 0 || 
		delimLoc == NULL)
	{
		return NULL;
	}
   
    // Alloc a new string and return it
	unsigned int propLength = delimLoc - a_buffer;
	char * retBuf = (char*)malloc(sizeof(char)*propLength+1);
	if (retBuf != NULL)
	{
		// Copy all chars up to delim and null terminate
		memset(retBuf, 0, sizeof(char) * propLength);
		memcpy(retBuf, a_buffer, propLength);
		retBuf[propLength] = '\0';
		return TrimString(retBuf);
    }
	
	// Failure case
	return NULL;
}
// This is the heuristic which detects the requests issued by Flash.ocx.
// It turned out that the implementation from ''Flash.ocx'' (tested version is 15.0.0.152)
// returns quite minimal configuration in comparison with the implementation from Microsofts'
// libraries (see grfBINDF and bindInfo.dwOptions). The impl from MS often includes something
// else.
bool WBPassthruSink::IsFlashRequest(const wchar_t* const* additionalHeaders)
{
  if (additionalHeaders && *additionalHeaders)
  {
    auto flashVersionHeader = ExtractHttpHeader<std::wstring>(*additionalHeaders, L"x-flash-version:", L"\n");
    if (!TrimString(flashVersionHeader).empty())
    {
      return true;
    }
  }
  ATL::CComPtr<IBindStatusCallback> bscb;
  if (SUCCEEDED(QueryServiceFromClient(&bscb)) && !!bscb)
  {
    DWORD grfBINDF = 0;
    BINDINFO bindInfo = {};
    bindInfo.cbSize = sizeof(bindInfo);
    if (SUCCEEDED(bscb->GetBindInfo(&grfBINDF, &bindInfo)) &&
      (BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE| BINDF_PULLDATA) == grfBINDF &&
      (BINDINFO_OPTIONS_ENABLE_UTF8 | BINDINFO_OPTIONS_USE_IE_ENCODING) == bindInfo.dwOptions
      )
    {
      return true;
    }
  }
  return false;
}
void do_GMEndGame(CPC *a1, char *a2)
{
    int v3; // [sp+24h] [bp-4h]@4
    char *sa; // [sp+34h] [bp+Ch]@4

    if(!a2 || !*a2)
        return;

    sa = AnyOneArg(a2, g_buf, false);
    v3 = atoi(g_buf);
    TrimString(sa);

    if(gserver.Unk41088 != -1)
        return;

    gserver.Unk41088 = 10 * v3;

    if(!*sa)
        return;

    CNetMsg v2;

    MsgrNoticeMsg(v2, -1, -1, -1, -1, sa);

    if(!gserver.Unk452129 && gserver.Unk12 && !gserver.Unk12->Unk361)
    {
        if(gserver.Unk12)
            gserver.Unk12->WriteToOutput(v2);
    }
}
void do_GMQuestComplete(CPC *a1, char *a2)
{
    int v10; // [sp+34h] [bp-4h]@5

    if(a2 && *a2)
    {
        TrimString(a2);
        if(strlen(a2))
        {
            v10 = atoi(a2);
            for(int i = 0; i <= 9; ++i)
            {
                if(a1->Unk1900.Unk0[i] && a1->Unk1900.Unk40[i] && !a1->Unk1900.Unk50[i] && a1->Unk1900.Unk0[i]->Unk0->Unk0 == v10)
                {
                    g_gamelogbuffer.__ls(init("QUEST COMPLETE"));
                    g_gamelogbuffer.__ls(a1->Unk8);
                    g_gamelogbuffer.__ls(delim);
                    g_gamelogbuffer.__ls(a1->Unk1900.Unk0[i]->Unk0->Unk0);
                    g_gamelogbuffer.__ls(end);

                    CNetMsg v7;

                    QuestCompleteMsg(v7, a1->Unk1900.Unk0[i]);
                    if(a1->Unk768)
                        a1->Unk768->WriteToOutput(v7);

                    a1->Unk1900.Unk50[i] = 1;
                    return;
                }
            }
        }
    }
}
Exemple #12
0
bool zs_ut_s::GetXmlParam(std::string content, std::string param, std::vector<std::string> & data)
{
	TrimXmlContent(content);

	data.clear();
	std::string preParam = "<";
	preParam += param;
	preParam += ">";
	std::string suffParam = "</";
	suffParam += param;
	suffParam += ">";

	std::string::size_type pos1 = 0;
	while(1)
	{
		pos1 = content.find(preParam, pos1);
		if (pos1 == std::string::npos)
		{
			break;
		}
		pos1 += preParam.length();
		std::string::size_type pos2 = content.find(suffParam, pos1);
		if (pos2 == std::string::npos)
		{
			break;
		}

		data.push_back(content.substr(pos1, pos2-pos1));
		TrimString(data.back());
	}
	return true;
}
Exemple #13
0
std::vector<std::string> CWCheatEngine::GetCodesList() {
	// Reads the entire cheat list from the appropriate .ini.
	std::vector<std::string> codesList;
#if defined(_WIN32) && !defined(__MINGW32__)
	std::ifstream list(ConvertUTF8ToWString(activeCheatFile));
#else
	std::ifstream list(activeCheatFile.c_str());
#endif
	while (list && !list.eof()) {
		std::string line;
		getline(list, line, '\n');

		bool validCheatLine = false;
		// This function is called by cheat menu(UI) which doesn't support empty names
		// minimum 1 non space character is required starting from 5 position.
		// It also goes through other "_" lines, but they all have to meet this requirement anyway
		// so we don't have to specify any syntax checks here that are made by cheat engine.
		if (line.length() >= 5 && line[0] == '_') {
			for (size_t i = 4; i < line.length(); i++) {
				if (line[i] != ' ') {
					validCheatLine = true;
					break;
				}
			}
		}
		// Any lines not passing this check are discarded when we save changes to the cheat ini file
		if (validCheatLine || (line.length() >= 2 && line[0] == '/' && line[1] == '/') || (line.length() >= 1 && line[0] == '#')) {
			codesList.push_back(TrimString(line));
		}
	}
	return codesList;
}
Exemple #14
0
bool cCraftingRecipes::ParseItem(const AString & a_String, cItem & a_Item)
{
	// The caller provides error logging
	
	AStringVector Split = StringSplit(a_String, "^");
	if (Split.empty())
	{
		return false;
	}
	
	if (!StringToItem(Split[0], a_Item))
	{
		return false;
	}
	
	if (Split.size() > 1)
	{
		AString Damage = TrimString(Split[1]);
		if (!StringToInteger<short>(Damage.c_str(), a_Item.m_ItemDamage))
		{
			// Parsing the number failed
			return false;
		}
	}
	
	// Success
	return true;
}
status_t StagefrightRecorder::setParameters(const String8 &params) {
    LOGV("setParameters: %s", params.string());
    const char *cparams = params.string();
    const char *key_start = cparams;
    for (;;) {
        const char *equal_pos = strchr(key_start, '=');
        if (equal_pos == NULL) {
            LOGE("Parameters %s miss a value", cparams);
            return BAD_VALUE;
        }
        String8 key(key_start, equal_pos - key_start);
        TrimString(&key);
        if (key.length() == 0) {
            LOGE("Parameters %s contains an empty key", cparams);
            return BAD_VALUE;
        }
        const char *value_start = equal_pos + 1;
        const char *semicolon_pos = strchr(value_start, ';');
        String8 value;
        if (semicolon_pos == NULL) {
            value.setTo(value_start);
        } else {
            value.setTo(value_start, semicolon_pos - value_start);
        }
        if (setParameter(key, value) != OK) {
            return BAD_VALUE;
        }
        if (semicolon_pos == NULL) {
            break;  // Reaches the end
        }
        key_start = semicolon_pos + 1;
    }
    return OK;
}
Exemple #16
0
static int MsgEventAdded(WPARAM wParam,LPARAM lParam)
{
	HANDLE hDbEvent = (HANDLE)lParam;

	if (currentWatcherType & SDWTF_MESSAGE) {
		DBEVENTINFO dbe = { sizeof(dbe) };
		dbe.cbBlob = db_event_getBlobSize(hDbEvent);
		dbe.pBlob = (BYTE*)mir_alloc(dbe.cbBlob+2); /* ensure term zero */
		if (dbe.pBlob == NULL)
			return 0;
		if (!db_event_get(hDbEvent, &dbe))
			if (dbe.eventType == EVENTTYPE_MESSAGE && !(dbe.flags & DBEF_SENT)) {
				DBVARIANT dbv;
				if (!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
					TrimString(dbv.ptszVal);
					TCHAR *pszMsg = GetMessageText(&dbe.pBlob,&dbe.cbBlob);
					if (pszMsg != NULL && _tcsstr(pszMsg,dbv.ptszVal) != NULL)
						ShutdownAndStopWatcher(); /* msg with specified text recvd */
					mir_free(dbv.ptszVal); /* does NULL check */
				}
			}
		mir_free(dbe.pBlob);
	}
	return 0;
}
Exemple #17
0
char  *prs_translate(char *trans, const char *tfile)
{
char *sptr;
int i,found=0;
FILE *fh;

	if((fh=fopen(tfile,"r"))!=NULL)
	{
		while(!found && fgets(prstrans,511,fh))
		{
			TrimString(prstrans);
			if(strstr(prstrans,trans)==prstrans)
			{
				sptr=prstrans+strlen(trans);
				if(*sptr=='|')
				{
					++sptr;
					i=strlen(sptr);
					memmove(prstrans,sptr,i+1);
					found=1;
				}
			}
		}
		fclose(fh);
	}
	if(found && strlen(prstrans))
	{	
		if(!strcmp(prstrans,"---"))
		{
			*prstrans=0;
		}
		return prstrans;
	}
	return trans;
}
Exemple #18
0
void prs_check_missing(char *entry)
{
char rstr[512];
int found=0;
FILE *fh;

	if((fh=fopen(MISS_FILE,"r"))!=NULL)
	{
		while(!feof(fh)&&!found)
		{
			if(fgets(rstr,500,fh))
			{
				TrimString(rstr);
				if(!strcmp(rstr,entry))
				{
					found=1;
				}
			}
		}
		fclose(fh);
	}
	if(!found)
	{
		if((fh=fopen(MISS_FILE,"a"))!=NULL)
		{
			fprintf(fh,"%s\n",entry);
			fclose(fh);
		}
	}
}
// 创建新的键值的函数
HKEY CRegKeyManager::CreateNewKey(HKEY hRootKey, LPCTSTR lpszSubKey, HKEY hSubKey)
{
	std::wstring strSubKey;
	if (((UINT)hRootKey & 0x80000000) == 0)
	{
		// rootkey不是predefined的,需要再次获取一下
		hRootKey = GetRegFullPath(hRootKey, strSubKey);
		if (hRootKey == NULL)
			return NULL;
		if (lpszSubKey)
		{
			strSubKey += _T("\\");
			strSubKey += lpszSubKey;
		}
	}
	else if (lpszSubKey)
		strSubKey = lpszSubKey;
	TrimString(strSubKey, BLANKS_SLASH);

	// 这个注册表键值不存在,需要搞一个虚拟的
	// 在实际中建一个是为了得到HKEY值,既不跟实际的注册表一样,又达到虚拟自己的目的
	if (hSubKey == NULL)
	{
		std::wstringstream strVirtualKey;
		strVirtualKey << _T("Software\\Bank\\VirtualReg\\") << (UINT)hRootKey << _T("\\") << strSubKey;
		::RegCreateKey(HKEY_CURRENT_USER, strVirtualKey.str().c_str(), &hSubKey);
	}
	::EnterCriticalSection(&m_cs);
	m_HKeyMap.insert(std::make_pair(hSubKey, std::make_pair(hRootKey, strSubKey)));
	::LeaveCriticalSection(&m_cs);
	return hSubKey;
}
bool CPluginFilter::ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngine::ContentType contentType, const std::wstring& domain, bool addDebug) const
{
  std::wstring srcTrimmed = TrimString(src);

  // We should not block the empty string, so all filtering does not make sense
  // Therefore we just return
  if (srcTrimmed.empty())
  {
    return false;
  }

  CPluginSettings* settings = CPluginSettings::GetInstance();

  CPluginClient* client = CPluginClient::GetInstance();
  bool result = client->Matches(srcTrimmed, contentType, domain);

#ifdef ENABLE_DEBUG_RESULT
  if (addDebug)
  {
    std::wstring type = ToUtf16String(AdblockPlus::FilterEngine::ContentTypeToString(contentType));
    if (result)
    {
      CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain);
    }
    else
    {
      CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain);
    }
  }
#endif
  return result;
}
Exemple #21
0
/*!
* Checks whether the string passed is an integer.
*
* \param str original string
*
* \return integer string?
*/
bool CUtil::IsInteger(const string &str)
{
    string str1 = TrimString(str);
    if (str1.find_first_not_of("0123456789") != string::npos)
        return false;
    else
        return true;
}
 inline std::string GetCurrentTime(){
     time_t raw_time;
     time(&raw_time);
     auto* time_info = localtime(&raw_time);
     std::string time_str(asctime(time_info));
     TrimString(time_str);
     return time_str;
 }
Exemple #23
0
bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item)
{
	AString ItemName = TrimString(a_ItemTypeString);
	if (ItemName.substr(0, 10) == "minecraft:")
	{
		ItemName = ItemName.substr(10);
	}
	return gsBlockIDMap.ResolveItem(ItemName, a_Item);
}
Exemple #24
0
/**	装载符号定义文件
 */
int LoadSymbolData(const TCHAR *file_name)
{
	TCHAR buffer[10 * 1024];			//10K的buffer
	TCHAR line[0x100];
	TCHAR *english_symbol, *chinese_symbol;
	int  char_count;
	int  length, index;
	int  i;

	if (share_segment->symbol_loaded)
		return 1;

	//Copy Default symbol table
	for (i = 0; i < SYMBOL_NUMBER; i++)
		_tcscpy(share_segment->symbol_table[i].chinese_symbol, share_segment->symbol_table[i].default_chinese_symbol);

	if (!(length = LoadFromFile(file_name, buffer, _SizeOf(buffer))))
		return 0;

	index  = 1;
	length = length / sizeof(TCHAR);

	while(index < length)
	{
		//得到一行数据
		char_count = 0;
		while(char_count < _SizeOf(line) - 1 && index < length)
		{
			line[char_count++] = buffer[index++];

			if (buffer[index - 1] == '\n')
				break;				//遇到回车结束
		}

		line[char_count] = 0;		//得到一行数据

		//除掉首尾的空白符号
		TrimString(line);

		if (line[0] == '/' && line[1]=='/')			//注释行,跳过
			continue;

		english_symbol = _tcstok(line, TEXT(" "));
		chinese_symbol = _tcstok(0, TEXT(" "));

		if (!english_symbol || !chinese_symbol)
			continue;
		//TrimString(english_symbol);
		//TrimString(chinese_symbol);

		UpdateSymbol(english_symbol, chinese_symbol);
	}

	share_segment->symbol_loaded = 1;

	return 1;
}
Exemple #25
0
void Parser::SearchForKeywords() {
  for (auto it = tokens_.begin(); it != tokens_.end(); ++it) {
    auto& token = *it;

    if (token.category != kUnknown)
      continue;

    auto word = token.content;
    TrimString(word, L" -");

    if (word.empty())
      continue;
    // Don't bother if the word is a number that cannot be CRC
    if (word.size() != 8 && IsNumericString(word))
      continue;

    // Performs better than making a case-insensitive Find
    auto keyword = keyword_manager.Normalize(word);
    ElementCategory category = kElementUnknown;
    KeywordOptions options;

    if (keyword_manager.Find(keyword, category, options)) {
      if (!options_.parse_release_group && category == kElementReleaseGroup)
        continue;
      if (!IsElementCategorySearchable(category) || !options.searchable)
        continue;
      if (IsElementCategorySingular(category) && !elements_.empty(category))
        continue;
      if (category == kElementAnimeSeasonPrefix) {
        CheckAnimeSeasonKeyword(it);
        continue;
      } else if (category == kElementEpisodePrefix) {
        if (options.valid)
          CheckExtentKeyword(kElementEpisodeNumber, it);
        continue;
      } else if (category == kElementReleaseVersion) {
        word = word.substr(1);  // number without "v"
      } else if (category == kElementVolumePrefix) {
        CheckExtentKeyword(kElementVolumeNumber, it);
        continue;
      }
    } else {
      if (elements_.empty(kElementFileChecksum) && IsCrc32(word)) {
        category = kElementFileChecksum;
      } else if (elements_.empty(kElementVideoResolution) &&
                 IsResolution(word)) {
        category = kElementVideoResolution;
      }
    }

    if (category != kElementUnknown) {
      elements_.insert(category, word);
      if (options.identifiable)
        token.category = kIdentifier;
    }
  }
}
Exemple #26
0
bool HttpHeader::ParseHeaderItem(const char* pBuffer, int nDataLen, int& nHeaderLen)
{
    int nConsoleLen = 0;
    int nColonPos = 0;
    int nRNPos = 0;
    
    const char* pPos = pBuffer;
    while (true)
    {
        if (!FindLine(pPos, nDataLen, nColonPos, nRNPos, nConsoleLen))
        {
            return false;
        }
        if (nRNPos == 0) //\r\n\r\n meet
        {
            nHeaderLen += nConsoleLen;
            break;
        }
        
        if (nColonPos == -1) //none : found
        {
            return false;
        }
        
        if (nRNPos <= (nColonPos + 1)) //empty value
        {
            return false;
        }
        
        const std::string strName(pPos, nColonPos);
        const std::string strValue(pPos + nColonPos + 1, nRNPos - nColonPos - 1);
        
        HttpHeaderItem nItem;
        nItem.m_strName = TrimString(strName, ' ');
        nItem.m_strValue = TrimString(strValue, ' ');
        m_nItemArray.push_back(nItem);
                
        nHeaderLen += nConsoleLen;
        pPos += nConsoleLen;
        nDataLen -= nConsoleLen;
    }
    
    return true;
}
Exemple #27
0
wxString 
CreateReposDlg::GetDir() const
{
  wxASSERT(0 != m_comboDir);

  wxString dir(m_comboDir->GetValue());
  TrimString(dir);

  return dir;
}
Exemple #28
0
wxString
CreateReposDlg::GetName() const
{
  wxASSERT(0 != m_comboName);

  wxString name(m_comboName->GetValue());
  TrimString(name);

  return name;
}
Exemple #29
0
wxString 
CreateReposDlg::GetConfigDir() const
{
  wxASSERT(0 != m_comboConfigDir);

  wxString configDir(m_comboConfigDir->GetValue());
  TrimString(configDir);

  return configDir;
}
bool RegexProcessor::GetGroup(const wxString &str, int grp, wxString &out)
{
	if(m_re && m_re->IsValid()){
		if(m_re->Matches(str)){
			out = m_re->GetMatch(str, grp);
			TrimString(out);
			return true;
		}
	}
	return false;
}