T_BOOLEAN CString::operator<(const CString & tString) const {
  T_BOOLEAN bResult = false;

  if (__strcmp(m_String, tString.m_String) == -1) {
    bResult = true;
  }

  return (bResult);
} // operator<
Exemple #2
0
/* *
 * strcmp - compares the string @s1 and @s2
 * @s1:     string to be compared
 * @s2:     string to be compared
 *
 * This function starts comparing the first character of each string. If
 * they are equal to each other, it continues with the following pairs until
 * the characters differ or until a terminanting null-character is reached.
 *
 * Returns an integral value indicating the relationship between the strings:
 * - A zero value indicates that both strings are equal;
 * - A value greater than zero indicates that the first character that does
 *   not match has a greater value in @s1 than in @s2;
 * - And a value less than zero indicates the opposite.
 * */
int strcmp(const char *s1, const char *s2)
{
#ifdef __HAVE_ARCH_STRCMP
	return __strcmp(s1, s2);
#else
	while (*s1 != '\0' && *s1 == *s2) {
		s1++, s2++;
	}
	return (int)((unsigned char)*s1 - (unsigned char)*s2);
#endif /* __HAVE_ARCH_STRCMP */
}
T_BOOLEAN CString::operator==(const CString & tString) const {
  T_BOOLEAN bResult = false;

  if (m_Length == tString.m_Length) {
    if (__strcmp(m_String, tString.m_String) == 0) {
      bResult = true;
    }
  }

  return (bResult);
} // operator==
Exemple #4
0
//
//	Searches for the export table entry of the specified function within the specified module. 
//	Returns pointer to the found entry or NULL if there is no such function within module's export.
//
PEXPORT_ENTRY	PeSupGetExportEntry( 
	PVOID	TargetModule,		// Image base of the target module (where exported function located)
	PCHAR   ExportedFunction	// exported function name
	)
{
	PIMAGE_DATA_DIRECTORY	pExportData;
	PIMAGE_EXPORT_DIRECTORY pExportDir;
	PCHAR	ModuleBase = (PCHAR)TargetModule;
	PULONG  ppFunctions, ppNames;
	PUSHORT pOrdinals;
	ULONG	i, NumberOfNames;
	PEXPORT_ENTRY	pFoundEntry	= NULL;


	pExportData = PeSupGetDirectoryEntryPtr((PIMAGE_NT_HEADERS)(ModuleBase + ((PIMAGE_DOS_HEADER)TargetModule)->e_lfanew), IMAGE_DIRECTORY_ENTRY_EXPORT);
	pExportDir = (PIMAGE_EXPORT_DIRECTORY)(ModuleBase + pExportData->VirtualAddress);

	if (pExportData->VirtualAddress == 0 || pExportData->Size == 0 || pExportDir->AddressOfFunctions == 0 || pExportDir->AddressOfNames == 0 )
		return NULL;

	// Get names, functions and ordinals arrays pointers
	ppFunctions =	(PULONG) (ModuleBase + (ULONG)pExportDir ->AddressOfFunctions);
	ppNames =		(PULONG) (ModuleBase + (ULONG)pExportDir ->AddressOfNames);
	pOrdinals =		(PUSHORT)(ModuleBase + (ULONG)pExportDir ->AddressOfNameOrdinals);

	NumberOfNames = pExportDir->NumberOfNames;

	// Walk the export table entries
	for ( i = 0; i < NumberOfNames; ++i )
	{
		// Check if function name matches current entry
		if   (!__strcmp(ModuleBase + *ppNames, ExportedFunction))
		{
			pFoundEntry = (PEXPORT_ENTRY)&ppFunctions [*pOrdinals];
			break;
		}
		ppNames++;
		pOrdinals++;
	}

	return(pFoundEntry);
}
Exemple #5
0
static void strcmp_func() {
	char text[1024] = "`1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:ZXCVBNM<>?\0";
	char equal[1024] = "`1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:ZXCVBNM<>?\0";
	/* Difference in head that is smaller than origin text */
	char not_eqaul_1[1024] = "11234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:ZXCVBNM<>?\0";
	/* Difference in middle that is bigger than origin text */
	char not_eqaul_2[1024] = "`1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,.!~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:ZXCVBNM<>?\0";
	/* Difference in tail that is biggeer than origin text */
	char not_eqaul_3[1024] = "`1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:ZXCVBNMM?!\0";

	assert_int_equal(0, __strcmp(text, equal));	

	/* When return value is over zero */
	assert_in_range(__strcmp(text, not_eqaul_1), 1, INT32_MAX);
	assert_in_range(__strcmp(text, not_eqaul_2), 1, INT32_MAX);
	/* when retrun value is under zero */	
	assert_in_range(__strcmp(text, not_eqaul_3), INT32_MIN, -1);
	assert_int_not_equal(0, __strcmp(text, not_eqaul_1));	
	assert_int_not_equal(0, __strcmp(text, not_eqaul_2));	
	assert_int_not_equal(0, __strcmp(text, not_eqaul_3));	
}
Exemple #6
0
static int ClcSettingChanged(WPARAM hContact, LPARAM lParam)
{
	char *szProto = NULL;
	DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;

	if (hContact) {
		if ( !__strcmp(cws->szModule, "CList")) {
			if ( !__strcmp(cws->szSetting, "StatusMsg"))
				SendMessage(pcli->hwndContactTree, INTM_STATUSMSGCHANGED, hContact, lParam);
		}
		else if ( !__strcmp(cws->szModule, "UserInfo")) {
			if ( !__strcmp(cws->szSetting, "ANSIcodepage"))
				pcli->pfnClcBroadcast(INTM_CODEPAGECHANGED, hContact, lParam);
			else if ( !__strcmp(cws->szSetting, "Timezone") || !__strcmp(cws->szSetting, "TzName"))
				ReloadExtraInfo(hContact);
		}
		else if (hContact != 0 && (szProto = GetContactProto(hContact)) != NULL) {
			char *id = NULL;
			if ( !__strcmp(cws->szModule, "Protocol") && !__strcmp(cws->szSetting, "p")) {
				char *szProto_s;
				pcli->pfnClcBroadcast(INTM_PROTOCHANGED, hContact, lParam);
				if (cws->value.type == DBVT_DELETED)
					szProto_s = NULL;
				else
					szProto_s = cws->value.pszVal;
				pcli->pfnChangeContactIcon(hContact, IconFromStatusMode(szProto_s, szProto_s == NULL ? ID_STATUS_OFFLINE : cfg::getWord(hContact, szProto_s, "Status", ID_STATUS_OFFLINE), hContact, NULL), 0);
			}
			// something is being written to a protocol module
			if ( !__strcmp(szProto, cws->szModule)) {
				// was a unique setting key written?
				pcli->pfnInvalidateDisplayNameCacheEntry(hContact);
				if ( !__strcmp(cws->szSetting, "Status")) {
					if (!cfg::getByte(hContact, "CList", "Hidden", 0)) {
						if (cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT)) {
							// User's state is changing, and we are hideOffline-ing
							if (cws->value.wVal == ID_STATUS_OFFLINE) {
								pcli->pfnChangeContactIcon(hContact, IconFromStatusMode(cws->szModule, cws->value.wVal, hContact, NULL), 0);
								CallService(MS_CLUI_CONTACTDELETED, hContact, 0);
								return 0;
							}
							pcli->pfnChangeContactIcon(hContact, IconFromStatusMode(cws->szModule, cws->value.wVal, hContact, NULL), 1);
						}
						pcli->pfnChangeContactIcon(hContact, IconFromStatusMode(cws->szModule, cws->value.wVal, hContact, NULL), 0);
					}
					SendMessage(pcli->hwndContactTree, INTM_STATUSCHANGED, hContact, lParam);
					return 0;
				}
				else if (strstr("YMsg|StatusDescr|XStatusMsg", cws->szSetting))
					SendMessage(pcli->hwndContactTree, INTM_STATUSMSGCHANGED, hContact, lParam);
				else if (strstr(cws->szSetting, "XStatus"))
					SendMessage(pcli->hwndContactTree, INTM_XSTATUSCHANGED, hContact, lParam);
				else if ( !__strcmp(cws->szSetting, "Timezone") || !__strcmp(cws->szSetting, "TzName"))
					ReloadExtraInfo(hContact);

				if (!(cfg::dat.dwFlags & CLUI_USEMETAICONS) && !__strcmp(szProto, META_PROTO))
					if ((lstrlenA(cws->szSetting) > 6 && !strncmp(cws->szSetting, "Status", 6)) || strstr("Default,ForceSend,Nick", cws->szSetting))
						pcli->pfnClcBroadcast(INTM_NAMEORDERCHANGED, hContact, lParam);
			}
			if (cfg::dat.bMetaEnabled && !__strcmp(cws->szModule, META_PROTO) && !__strcmp(cws->szSetting, "IsSubcontact"))
				pcli->pfnClcBroadcast(INTM_HIDDENCHANGED, hContact, lParam);
		}
	}
	else if (!__strcmp(cws->szModule, META_PROTO)) {
		BYTE bMetaEnabled = cfg::getByte(META_PROTO, "Enabled", 1);
		if (bMetaEnabled != (BYTE)cfg::dat.bMetaEnabled) {
			cfg::dat.bMetaEnabled = bMetaEnabled;
			pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0);
		}
	}
	else if (!__strcmp(cws->szModule, "Skin") && !__strcmp(cws->szSetting, "UseSound")) {
		cfg::dat.soundsOff = cfg::getByte(cws->szModule, cws->szSetting, 0) ? 0 : 1;
		ClcSetButtonState(IDC_TBSOUND, cfg::dat.soundsOff ? BST_CHECKED : BST_UNCHECKED);
		SetButtonStates(pcli->hwndContactList);
	}
	else if (!__strcmp(cws->szModule, "CList") && !__strcmp(cws->szSetting, "UseGroups")) {
		ClcSetButtonState(IDC_TBHIDEGROUPS, cfg::getByte(cws->szModule, cws->szSetting, SETTING_USEGROUPS_DEFAULT));
		SetButtonStates(pcli->hwndContactList);
	}
	else if (!__strcmp(cws->szModule, "TopToolBar") && !__strcmp(cws->szSetting, "UseFlatButton")) {
		SetButtonToSkinned();
	}
	else if (szProto == NULL) {
		if ( !__strcmp(cws->szSetting, "XStatusId"))
			CluiProtocolStatusChanged(0, cws->szModule);
	}
	return 0;
}