Ejemplo n.º 1
0
/** apxStrMatchA ANSI string pattern matching
 * Match = 0, NoMatch = 1, Abort = -1
 * Based loosely on sections of wildmat.c by Rich Salz
 */
INT apxStrMatchA(LPCSTR szString, LPCSTR szPattern, BOOL bIgnoreCase)
{
    int x, y;

    for (x = 0, y = 0; szPattern[y]; ++y, ++x) {
        if (!szPattern[x] && (szPattern[y] != '*' || szPattern[y] != '?'))
            return -1;
        if (szPattern[y] == '*') {
            while (szPattern[++y] == '*');
            if (!szPattern[y])
                return 0;
            while (szString[x]) {
                INT rc;
                if ((rc = apxStrMatchA(&szString[x++], &szPattern[y],
                                       bIgnoreCase)) != 1)
                    return rc;
            }
            return -1;
        }
        else if (szPattern[y] != '?') {
            if (bIgnoreCase) {
                if (CharLowerA((LPSTR)((SIZE_T)szString[x])) !=
                    CharLowerA((LPSTR)((SIZE_T)szPattern[y])))
                    return 1;
            }
            else {
                if (szString[x] != szPattern[y])
                    return 1;
            }
        }
    }
    return (szString[x] != '\0');
}
Ejemplo n.º 2
0
	AuthModule* AuthModule::loadFromName(std::string name)
	{
		int length;
		char* filename;
		char* lowerName;
		std::string libraryPath;
		AuthModule* module;
		pRdsAuthModuleEntry moduleEntry;

		libraryPath = APP_CONTEXT.getLibraryPath();

		lowerName = _strdup(name.c_str());
		CharLowerA(lowerName);

		length = strlen(lowerName) + libraryPath.size() + 64;
		filename = (char*) malloc(length + 1);

		sprintf_s(filename, length, "%s/libfreerds-auth-%s.so", libraryPath.c_str(), lowerName);
		free(lowerName);

		module = AuthModule::loadFromFileName(filename);

		free(filename);

		return module;
	}
Ejemplo n.º 3
0
pRdsAuthModuleEntry freerds_load_auth_module(const char* name)
{
        char* lowerName;
        HINSTANCE library;
        char moduleFileName[256];
        pRdsAuthModuleEntry moduleEntry;

        lowerName = _strdup(name);
        CharLowerA(lowerName);

        sprintf_s(moduleFileName, sizeof(moduleFileName), FREERDS_LIB_PATH "/libfreerds-auth-%s.so", lowerName);

        free(lowerName);

        library = LoadLibraryA(moduleFileName);

        if (!library)
                return NULL;

        moduleEntry = (pRdsAuthModuleEntry) GetProcAddress(library, RDS_AUTH_MODULE_ENTRY_POINT_NAME);

        if (moduleEntry)
                return moduleEntry;

        FreeLibrary(library);

        return NULL;
}
Ejemplo n.º 4
0
void DisablePlugins()
{
	char buffer[10000];

	if ( GetSettings("DisablePlugins", buffer, sizeof(buffer)) ) {
		char *name;
		char *value;

		name = buffer;
		while(name[0] != '\0') {
			value = strchr(name, '=');
			if (value == NULL)
				value = &name[mir_strlen(name)];

			// Has " ?
			if (*name == '"' && *(value-1) == '"') {
				name++;
				*(value-1) = '\0';
			}

			// Disable it
			if (name[0] != '\0') {
				CharLowerA(name);
				if (db_get_b(NULL, PLUGINDISABLELIST, name, 0) != 1)
				{
					db_set_b(NULL, PLUGINDISABLELIST, name, 1);
				}
			}

			// Get next one
			name = value + mir_strlen(value) + 1;
		}
	}
}
Ejemplo n.º 5
0
char* ParseTypeBuffer(char* szString)
{
	char* szTemp = malloc(sizeof(char*)*strlen(szString));
	memset(szTemp, 0, sizeof(char*)*strlen(szString));
	strcpy_s(szTemp, strlen(szString) + 1, szString);
	if (strstr(szTemp, "/join"))
	{
		if (szTemp[0] == '/' && szTemp[4] == 'n')
		{
			char* szStr = Substring(szTemp, "/", 1);
			strcpy_s(szTemp, strlen(szStr) + 1, szStr);
			strcpy_s(szString, strlen(szTemp) + 1, szTemp);
			free(szTemp);
			char* __Channel = szBoyer_Moore(szString, strlen(szString), "#", strlen("#"));
			if (__Channel)
			{
				strcpy_s(ContextIRC.szHashKey, strlen(__Channel) + 1, CharLowerA(__Channel));
				strcpy_s(szChannel, 96, __Channel);
				assert(ContextIRC.hParent);
				SendMessage(ContextIRC.hParent, WM_CREATE_IRC_WINDOW, (WPARAM)ContextIRC.szHashKey, 0);
				strcpy_s(ContextIRC.szTypeBuffer, strlen(szString) + 1, szString);
				strcat_s(ContextIRC.szTypeBuffer, 511, "\r\n");
				send(Socket, ContextIRC.szTypeBuffer, strlen(ContextIRC.szTypeBuffer), 0);
				return szString;
			}
		}
	}
	else
	{
		char* szMessage = "PRIVMSG ";
		char* szCached = malloc(512);
		memset(szCached, 0, 512);
		strcpy_s(szCached, 511, ContextIRC.szTypeBuffer);
		memset(ContextIRC.szTypeBuffer, 0, 511);
		strcpy_s(ContextIRC.szTypeBuffer, strlen(szMessage) + 1 , szMessage);
		strcat_s(ContextIRC.szTypeBuffer, 511, szChannel);
		strcat_s(ContextIRC.szTypeBuffer, 511, " :");
		strcat_s(ContextIRC.szTypeBuffer, 511, szCached);
		strcat_s(ContextIRC.szTypeBuffer, 511, "\r\n");

		send(Socket, ContextIRC.szTypeBuffer, strlen(ContextIRC.szTypeBuffer), 0);
		char* TempNick = malloc(sizeof(szNick)+511);
		memset(TempNick, 0, sizeof(szNick)+511);
		TempNick = AddBrackets(szNick, TempNick);
		strcat_s(TempNick, 511, " ");
		strcat_s(TempNick, 511, szCached);
		strcat_s(TempNick, 511, "\r\n");

		SetIRCWindowText(TempNick);
		free(TempNick);
		TempNick = NULL;

		free(szCached);
		szCached = NULL;
	}
	return szString;
}
Ejemplo n.º 6
0
unsigned char loctolower(unsigned char ch)
{
#ifdef _WIN_ALL
  // Convert to LPARAM first to avoid a warning in 64 bit mode.
  return((int)(LPARAM)CharLowerA((LPSTR)ch));
#else
  return(tolower(ch));
#endif
}
Ejemplo n.º 7
0
unsigned char loctolower(unsigned char ch)
{
#if defined(_WIN_ALL)
  // Convert to LPARAM first to avoid a warning in 64 bit mode.
  // Convert to uintptr_t to avoid Clang/win error: cast to 'char *' from smaller integer type 'unsigned char' [-Werror,-Wint-to-pointer-cast]
  return (int)(LPARAM)CharLowerA((LPSTR)(uintptr_t)ch);
#else
  return tolower(ch);
#endif
}
Ejemplo n.º 8
0
char* strlower(char *Str)
{
#ifdef _WIN_ALL
  CharLowerA((LPSTR)Str);
#else
  for (char *ChPtr=Str;*ChPtr;ChPtr++)
    *ChPtr=(char)loctolower(*ChPtr);
#endif
  return(Str);
}
Ejemplo n.º 9
0
/* 从输入表查找CRT版本 */
BOOL WINAPI find_msvcrt(char *crt_name,int len)
{
    BOOL			ret = FALSE;
    IMAGE_DOS_HEADER      *pDos;
    IMAGE_OPTIONAL_HEADER *pOptHeader;
    IMAGE_IMPORT_DESCRIPTOR    *pImport ;
    HMODULE hMod=GetModuleHandleW(NULL);
    if (!hMod)
    {
#ifdef _LOGDEBUG
        logmsg("GetModuleHandleW false,hMod = 0\n");
#endif
        return ret;
    }
    pDos = (IMAGE_DOS_HEADER *)hMod;
    pOptHeader = (IMAGE_OPTIONAL_HEADER *)(
                     (BYTE *)hMod
                     + pDos->e_lfanew
                     + SIZE_OF_NT_SIGNATURE
                     + sizeof(IMAGE_FILE_HEADER)
                 );
    pImport = (IMAGE_IMPORT_DESCRIPTOR * )(
                  (BYTE *)hMod
                  + pOptHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress
              ) ;
    while( TRUE )
    {
        char*		pszDllName = NULL;
        char		name[CRT_LEN+1] = {0};
        IMAGE_THUNK_DATA *pThunk  = (PIMAGE_THUNK_DATA)(pImport->Characteristics);
        IMAGE_THUNK_DATA *pThunkIAT = (PIMAGE_THUNK_DATA)(pImport->FirstThunk);
        if(pThunk == 0 && pThunkIAT == 0) break;
        pszDllName = (char*)((BYTE*)hMod+pImport->Name);
#ifdef _LOGDEBUG
        logmsg("dllname:  [%s]\n",(const char *)pszDllName);
#endif
        if ( PathMatchSpecA(pszDllName,"msvcr*.dll") )
        {
            strncpy(name,pszDllName,CRT_LEN);
            strncpy(crt_name,CharLowerA(name),len);
            ret = TRUE;
            break;
        }
        pImport++;
    }
    return ret;
}
Ejemplo n.º 10
0
/***********************************************************************
 *           MSACM_GetRegistryKey
 */
static	LPSTR	MSACM_GetRegistryKey(const WINE_ACMDRIVERID* padid)
{
    static const char*	baseKey = "Software\\Microsoft\\AudioCompressionManager\\DriverCache\\";
    LPSTR	ret;
    int		len;

    if (!padid->pszDriverAlias) {
	ERR("No alias needed for registry entry\n");
	return NULL;
    }
    len = strlen(baseKey);
    ret = HeapAlloc(MSACM_hHeap, 0, len + strlen(padid->pszDriverAlias) + 1);
    if (!ret) return NULL;

    strcpy(ret, baseKey);
    strcpy(ret + len, padid->pszDriverAlias);
    CharLowerA(ret + len);
    return ret;
}
Ejemplo n.º 11
0
INT_PTR CALLBACK FinishedPageProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM)
{
    switch (message) {
    case WM_INITDIALOG:
        TranslateDialogDefault(hdlg);
        SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 0, 0);
        SendMessage(GetParent(hdlg), WIZM_SETCANCELTEXT, 0, (LPARAM)TranslateT("Finish"));
        CheckDlgButton(hdlg, IDC_DONTLOADPLUGIN, BST_UNCHECKED);
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDOK:
            PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_MIRANDADB, (LPARAM)MirandaPageProc);
            break;

        case IDCANCEL:
            if (IsDlgButtonChecked(hdlg, IDC_DONTLOADPLUGIN)) {
                char sModuleFileName[MAX_PATH];
                GetModuleFileNameA(hInst, sModuleFileName, sizeof(sModuleFileName));
                char *pszFileName = strrchr(sModuleFileName, '\\');
                if (pszFileName == NULL)
                    pszFileName = sModuleFileName;
                else
                    pszFileName++;

                // We must lower case here because if a DLL is loaded in two
                // processes, its file name from GetModuleFileName in one process may
                // differ in case from its file name in the other process. This will
                // prevent the plugin from disabling/enabling correctly (this fix relies
                // on the plugin loader to ignore case)
                CharLowerA(pszFileName);
                db_set_b(NULL, "PluginDisable", pszFileName, 1);
            }
            PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
            break;
        }
        break;
    }

    return FALSE;
}
Ejemplo n.º 12
0
/* check if test is being filtered out */
static BOOL test_filtered_out( LPCSTR module, LPCSTR testname )
{
    char *p, dllname[MAX_PATH];
    unsigned int i, len;

    strcpy( dllname, module );
    CharLowerA( dllname );
    p = strstr( dllname, testexe );
    if (p) *p = 0;
    len = strlen(dllname);

    if (!nb_filters) return FALSE;
    for (i = 0; i < nb_filters; i++)
    {
        if (!strncmp( dllname, filters[i], len ))
        {
            if (!filters[i][len]) return FALSE;
            if (filters[i][len] != ':') continue;
            if (!testname || !strcmp( testname, &filters[i][len+1] )) return FALSE;
        }
    }
    return TRUE;
}
Ejemplo n.º 13
0
LPSTR UnicodeStr4CodeToUTF8Str(LPSTR in)
{
	LPSTR temp;
	unsigned int code, help;
	CHAR utf8[5];
	size_t length;
	while(temp = StrChrA(in, '\\'), temp != NULL)
	{
		if((temp[1] == 'u')||(temp[1] == 'U'))
		{
			temp[0] = '\0';
			StringCchLengthA(in, STRSAFE_MAX_CCH, &length);
			CHAR A[length+1];
			StringCchCopyA(A, length+1, in);
			StringCchLengthA(temp+6, STRSAFE_MAX_CCH, &length);
			CHAR B[length+1];
			StringCchCopyA(B, length+1, temp+6);
			temp[6] = '\0';
			CHAR hex_code[7];
			StringCchCopyA(hex_code, 7, "0x");
			CharLowerA(temp+2);
			StringCchCatA(hex_code, 7, temp+2);
			if(StrToIntExA(hex_code, STIF_SUPPORT_HEX, (int *)&code) == TRUE)
			{
				help = code;
				if(code <= 0x007F)
				{
					utf8[0] = code;
					utf8[1] = '\0';
				}
				else if(code <= 0x07FF)
				{
					utf8[0] = 0xC0+(help >> 6);
					utf8[1] = 0x80+(code&0x3F);
					utf8[2] = '\0';
				}
				else if(code <= 0xFFFF)
Ejemplo n.º 14
0
void LocalUpperInit()
{
	for (unsigned int I=0; I<ARRAYSIZE(LowerToUpper); I++)
	{
		char CvtStr[]={I,L'\0'},ReverseCvtStr[2];
		LowerToUpper[I]=UpperToLower[I]=I;
		OemToCharA(CvtStr,CvtStr);
		CharToOemA(CvtStr,ReverseCvtStr);
		IsUpperOrLower[I]=0;

		if (IsCharAlphaA(CvtStr[0]) && ReverseCvtStr[0]==static_cast<char>(I))
		{
			IsUpperOrLower[I]=IsCharLowerA(CvtStr[0])?1:(IsCharUpperA(CvtStr[0])?2:0);
			CharUpperA(CvtStr);
			CharToOemA(CvtStr,CvtStr);
			LowerToUpper[I]=CvtStr[0];
			CvtStr[0]=I;
			OemToCharA(CvtStr,CvtStr);
			CharLowerA(CvtStr);
			CharToOemA(CvtStr,CvtStr);
			UpperToLower[I]=CvtStr[0];
		}
	}
}
Ejemplo n.º 15
0
char * MyStringLower(char *s) { return CharLowerA(s); }
Ejemplo n.º 16
0
void CToxProto::SearchByNameAsync(void *arg)
{
	char *query = (char*)arg;
	char *name = strtok(query, "@");
	char *domain = strtok(NULL, "");

	int resolved = 0;

	if (IsFileExists((TCHAR*)VARST(_T(TOX_INI_PATH))))
	{
		char fileName[MAX_PATH];
		mir_strcpy(fileName, VARS(TOX_INI_PATH));

		char *section, sections[MAX_PATH], value[TOX_PUBLIC_KEY_SIZE * 2];
		GetPrivateProfileSectionNamesA(sections, _countof(sections), fileName);
		section = sections;
		while (*section != NULL)
		{
			if (strstr(section, "Dns_") == section)
			{
				GetPrivateProfileStringA(section, "Domain", NULL, value, _countof(value), fileName);
				ptrA dnsDomain(mir_strdup(value));
				GetPrivateProfileStringA(section, "PubKey", NULL, value, _countof(value), fileName);
				ToxBinAddress dnsPubKey = value;

				if (domain == NULL || mir_strcmpi(domain, dnsDomain) == 0)
				{
					void *dns = tox_dns3_new((uint8_t*)(const uint8_t*)dnsPubKey);

					uint32_t requestId = 0;
					uint8_t dnsString[MAX_PATH];
					size_t length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)CharLowerA(name), (uint8_t)mir_strlen(name));
					if (length != TOX_ERROR)
					{
						dnsString[length] = 0;
						char dnsQuery[MAX_PATH * 2];
						mir_snprintf(dnsQuery, "_%s._tox.%s", dnsString, dnsDomain);

						ToxHexAddress address = ResolveToxAddressFromDns(dnsQuery);
						if (!address.IsEmpty())
						{
							PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
							psr.flags = PSR_UTF8;
							psr.id.a = mir_strdup(address);
							psr.nick.a = mir_strdup(name);

							char email[MAX_PATH];
							mir_snprintf(email, "%s@%s", name, domain);
							psr.email.a = mir_strdup(email);

							ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
							break;
						}
					}
					tox_dns3_kill(dns);
				}
			}
			section += mir_strlen(section) + 1;
		}
	}

	if (resolved == 0 && domain)
	{
		char dnsQuery[MAX_PATH];
		mir_snprintf(dnsQuery, "%s._tox.%s", name, domain);

		ToxHexAddress address = ResolveToxAddressFromDns(dnsQuery);
		if (!address.IsEmpty())
		{
			PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
			psr.flags = PSR_UTF8;
			psr.id.a = mir_strdup(address);
			psr.nick.a = mir_strdup(name);

			char email[MAX_PATH];
			mir_snprintf(email, "%s@%s", name, domain);
			psr.email.a = mir_strdup(email);

			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
		}
	}

	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
	mir_free(arg);
}
Ejemplo n.º 17
0
static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const TCHAR *fmt, ...)
{
	va_list va;
	int lineLen, textCharsCount=0;
	TCHAR* line = (TCHAR*)alloca(8001 * sizeof(TCHAR));
	char* d;

	va_start(va, fmt);
	lineLen = _vsntprintf( line, 8000, fmt, va);
	if (lineLen < 0) lineLen = 8000;
	line[lineLen] = 0;
	va_end(va);

	lineLen = lineLen*20 + 8;
	if (*cbBufferEnd + lineLen > *cbBufferAlloced) {
		cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024);
		*buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
	}

	d = *buffer + *cbBufferEnd;

	for (; *line; line++, textCharsCount++) {
		if (*line == '\r' && line[1] == '\n') {
			CopyMemory(d, "\\par ", 5);
			line++;
			d += 5;
		}
		else if (*line == '\n') {
			CopyMemory(d, "\\line ", 6);
			d += 6;
		}
		else if (*line == '%' && !simpleMode ) {
			char szTemp[200];

			szTemp[0] = '\0';
			switch ( *++line ) {
			case '\0':
			case '%':
				*d++ = '%';
				break;

			case 'c':
			case 'f':
				if (g_Settings.StripFormat || streamData->bStripFormat)
					line += 2;

				else if ( line[1] != '\0' && line[2] != '\0') {
					TCHAR szTemp3[3], c = *line;
					int col;
					szTemp3[0] = line[1];
					szTemp3[1] = line[2];
					szTemp3[2] = '\0';
					line += 2;

					col = _ttoi(szTemp3);
					col += (OPTIONS_FONTCOUNT + 1);
					mir_snprintf(szTemp, SIZEOF(szTemp), ( c == 'c' ) ? "\\cf%u " : "\\highlight%u ", col);
				}
				break;
			case 'C':
			case 'F':
				if ( !g_Settings.StripFormat && !streamData->bStripFormat) {
					int j = streamData->lin->bIsHighlighted ? 16 : EventToIndex(streamData->lin);
					if ( *line == 'C' )
						mir_snprintf(szTemp, SIZEOF(szTemp), "\\cf%u ", j+1);
					else
						mir_snprintf(szTemp, SIZEOF(szTemp), "\\highlight0 ");
				}
				break;
			case 'b':
			case 'u':
			case 'i':
				if ( !streamData->bStripFormat )
					mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'u') ? "\\%cl " : "\\%c ", *line );
				break;

			case 'B':
			case 'U':
			case 'I':
				if ( !streamData->bStripFormat ) {
					mir_snprintf( szTemp, SIZEOF(szTemp), (*line == 'U') ? "\\%cl0 " : "\\%c0 ", *line );
					CharLowerA( szTemp );
				}
				break;

			case 'r':
				if ( !streamData->bStripFormat ) {
					int index = EventToIndex(streamData->lin);
					mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", Log_SetStyle(index, index));
				}
				break;
			}

			if ( szTemp[0] ) {
				int iLen = lstrlenA(szTemp);
				memcpy( d, szTemp, iLen );
				d += iLen;
			}
		}
		else if (*line == '\t' && !streamData->bStripFormat) {
			CopyMemory(d, "\\tab ", 5);
			d += 5;
		}
		else if ((*line == '\\' || *line == '{' || *line == '}') && !streamData->bStripFormat) {
			*d++ = '\\';
			*d++ = (char) *line;
		}
		else if (*line > 0 && *line < 128) {
			*d++ = (char) *line;
		}
		#if defined( _UNICODE )
			else d += sprintf(d, "\\u%u ?", (WORD)*line);
		#else
			else d += sprintf(d, "\\'%02x", (BYTE)*line);
		#endif
	}
Ejemplo n.º 18
0
MBChar String::ToLowerCaseMB( MBChar ch ) const
{
    return (MBChar)CharLowerA( (LPSTR)ch );
}