wine/memory/string.c
Alexandre Julliard 8bbf8180e5 Release 960913
Wed Sep 11 18:08:30 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [windows/event.c]
	Minor improvements in setting event time in MSG struct.

	* [windows/hook.c]
	Removed an useless 'unimplemented hook' message.

	* [windows/win.c]
	Added a WH_CBT hook call during window creation: good for CTL3D.DLL

Wed Sep 11 11:19:56 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
	* [loader/pe_image.c]
	Fixed imports with no name/ordinal list (MFC30.DLL).
	Added borland style - ordinal import (wsock32.dll).

	* [files/file.c] [win32/file.c] [if1632/kernel.spec]
	  [if1632/kernel32.spec] [include/windows.h]
	Win32 and Win16 code use the same filehandles/HFILEs.
	Added SetEndOfFile, MoveFile*, diverse *W functions.

	* [loader/pe_image.c]
	Fixed argument 2 to DllEntry.

	* [misc/comm.c]
	Adapt to filehandling changes, win32 code still broken.

	* [misc/registry.c]
	Use Wine filehandling.
	StartupRegistry to add startup-detected registry entries.

	* [miscemu/dpmi.c] [miscemu/int21.c]
	Some missing interrupt-functions added.

	* [if1632/gdi32.spec][if1632/user32.spec]
	Some thunks to 16 bit equivalent functions added.

Sat Sep  7 11:36:57 EDT 1996  Matthew Ghio <ghio@netcom.com>

	* [misc/winsocket.c]
	Rewrote WINSOCK_select() and WSAFDIsSet() to properly convert
	Windows fd_set structs.

	* [if1632/winsock.spec]
	Corrected arguments to select().
1996-09-13 16:50:47 +00:00

367 lines
8.4 KiB
C

/*
* String functions
*
* Copyright 1993 Yngvi Sigurjonsson
* Copyright 1996 Alexandre Julliard
*/
#include <ctype.h>
#include <string.h>
#include "windows.h"
#include "ldt.h"
/***********************************************************************
* hmemcpy (KERNEL.348)
*/
void hmemcpy( LPVOID dst, LPCVOID src, LONG count )
{
memcpy( dst, src, count );
}
/***********************************************************************
* lstrcat16 (KERNEL.89)
*/
SEGPTR lstrcat16( SEGPTR dst, SEGPTR src )
{
lstrcat32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src) );
return dst;
}
/***********************************************************************
* lstrcat32A (KERNEL32.599)
*/
LPSTR lstrcat32A( LPSTR dst, LPCSTR src )
{
strcat( dst, src );
return dst;
}
/***********************************************************************
* lstrcat32W (KERNEL32.600)
*/
LPWSTR lstrcat32W( LPWSTR dst, LPCWSTR src )
{
register LPWSTR p = dst;
while (*p) p++;
while ((*p++ = *src++));
return dst;
}
/***********************************************************************
* lstrcatn16 (KERNEL.352)
*/
SEGPTR lstrcatn16( SEGPTR dst, SEGPTR src, INT16 n )
{
lstrcatn32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src), n );
return dst;
}
/***********************************************************************
* lstrcatn32A (Not a Windows API)
*/
LPSTR lstrcatn32A( LPSTR dst, LPCSTR src, INT32 n )
{
register LPSTR p = dst;
while (*p) p++;
if ((n -= (INT32)(p - dst)) <= 0) return dst;
lstrcpyn32A( p, src, n );
return dst;
}
/***********************************************************************
* lstrcatn32W (Not a Windows API)
*/
LPWSTR lstrcatn32W( LPWSTR dst, LPCWSTR src, INT32 n )
{
register LPWSTR p = dst;
while (*p) p++;
if ((n -= (INT32)(p - dst)) <= 0) return dst;
lstrcpyn32W( p, src, n );
return dst;
}
/***********************************************************************
* lstrcmp16 (USER.430)
*/
INT16 lstrcmp16( LPCSTR str1, LPCSTR str2 )
{
return (INT16)lstrcmp32A( str1, str2 );
}
/***********************************************************************
* lstrcmp32A (KERNEL.602)
*/
INT32 lstrcmp32A( LPCSTR str1, LPCSTR str2 )
{
return (INT32)strcmp( str1, str2 );
}
/***********************************************************************
* lstrcmp32W (KERNEL.603)
*/
INT32 lstrcmp32W( LPCWSTR str1, LPCWSTR str2 )
{
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
return (INT32)(*str1 - *str2);
}
/***********************************************************************
* lstrcmpi16 (USER.471)
*/
INT16 lstrcmpi16( LPCSTR str1, LPCSTR str2 )
{
return (INT16)lstrcmpi32A( str1, str2 );
}
/***********************************************************************
* lstrcmpi32A (KERNEL32.605)
*/
INT32 lstrcmpi32A( LPCSTR str1, LPCSTR str2 )
{
INT32 res;
while (*str1)
{
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
str1++;
str2++;
}
return toupper(*str1) - toupper(*str2);
}
/***********************************************************************
* lstrcmpi32W (KERNEL32.606)
*/
INT32 lstrcmpi32W( LPCWSTR str1, LPCWSTR str2 )
{
INT32 res;
while (*str1)
{
/* FIXME: Unicode */
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
str1++;
str2++;
}
return toupper(*str1) - toupper(*str2);
}
/***********************************************************************
* lstrcpy16 (KERNEL.88)
*/
SEGPTR lstrcpy16( SEGPTR dst, SEGPTR src )
{
lstrcpy32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src) );
return dst;
}
/***********************************************************************
* lstrcpy32A (KERNEL32.608)
*/
LPSTR lstrcpy32A( LPSTR dst, LPCSTR src )
{
if (!src || !dst) return NULL;
strcpy( dst, src );
return dst;
}
/***********************************************************************
* lstrcpy32W (KERNEL32.609)
*/
LPWSTR lstrcpy32W( LPWSTR dst, LPCWSTR src )
{
register LPWSTR p = dst;
while ((*p++ = *src++));
return dst;
}
/***********************************************************************
* lstrcpyn16 (KERNEL.353)
*/
SEGPTR lstrcpyn16( SEGPTR dst, SEGPTR src, INT16 n )
{
lstrcpyn32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src), n );
return dst;
}
/***********************************************************************
* lstrcpyn32A (KERNEL32.611)
*/
LPSTR lstrcpyn32A( LPSTR dst, LPCSTR src, INT32 n )
{
LPSTR p = dst;
while ((n-- > 1) && *src) *p++ = *src++;
*p = 0;
return dst;
}
/***********************************************************************
* lstrcpyn32W (KERNEL32.612)
*/
LPWSTR lstrcpyn32W( LPWSTR dst, LPCWSTR src, INT32 n )
{
LPWSTR p = dst;
while ((n-- > 1) && *src) *p++ = *src++;
*p = 0;
return dst;
}
/***********************************************************************
* lstrlen16 (KERNEL.90)
*/
INT16 lstrlen16( LPCSTR str )
{
return (INT16)lstrlen32A( str );
}
/***********************************************************************
* lstrlen32A (KERNEL32.614)
*/
INT32 lstrlen32A( LPCSTR str )
{
/* looks weird, but win3.1 KERNEL got a GeneralProtection handler
* in lstrlen() ... we check only for NULL pointer reference.
* - Marcus Meissner
*/
if (!str) return 0;
return (INT32)strlen(str);
}
/***********************************************************************
* lstrlen32W (KERNEL32.615)
*/
INT32 lstrlen32W( LPCWSTR str )
{
INT32 len = 0;
if (!str) return 0;
while (*str++) len++;
return len;
}
/***********************************************************************
* lstrncmp32A (Not a Windows API)
*/
INT32 lstrncmp32A( LPCSTR str1, LPCSTR str2, INT32 n )
{
return (INT32)strncmp( str1, str2, n );
}
/***********************************************************************
* lstrncmp32W (Not a Windows API)
*/
INT32 lstrncmp32W( LPCWSTR str1, LPCWSTR str2, INT32 n )
{
if (!n) return 0;
while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
return (INT32)(*str1 - *str2);
}
/***********************************************************************
* lstrncmpi32A (Not a Windows API)
*/
INT32 lstrncmpi32A( LPCSTR str1, LPCSTR str2, INT32 n )
{
INT32 res;
if (!n) return 0;
while ((--n > 0) && *str1)
if ( (res = toupper(*str1++) - toupper(*str2++)) ) return res;
return toupper(*str1) - toupper(*str2);
}
/***********************************************************************
* lstrncmpi32W (Not a Windows API)
*/
INT32 lstrncmpi32W( LPCWSTR str1, LPCWSTR str2, INT32 n )
{
INT32 res;
if (!n) return 0;
while ((--n > 0) && *str1)
{
/* FIXME: Unicode */
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
str1++;
str2++;
}
return toupper(*str1) - toupper(*str2);
}
/***********************************************************************
* lstrcpynAtoW (Not a Windows API)
*/
LPWSTR lstrcpynAtoW( LPWSTR dst, LPCSTR src, INT32 n )
{
LPWSTR p = dst;
while ((n-- > 1) && *src) *p++ = (WCHAR)(unsigned char)*src++;
*p = 0;
return dst;
}
/***********************************************************************
* lstrcpynWtoA (Not a Windows API)
*/
LPSTR lstrcpynWtoA( LPSTR dst, LPCWSTR src, INT32 n )
{
LPSTR p = dst;
while ((n-- > 1) && *src) *p++ = (CHAR)*src++;
*p = 0;
return dst;
}
/***********************************************************************
* RtlFillMemory (KERNEL32.441)
*/
VOID RtlFillMemory( LPVOID ptr, UINT32 len, UINT32 fill )
{
memset( ptr, fill, len );
}
/***********************************************************************
* RtlMoveMemory (KERNEL32.442)
*/
VOID RtlMoveMemory( LPVOID dst, LPCVOID src, UINT32 len )
{
memmove( dst, src, len );
}
/***********************************************************************
* RtlZeroMemory (KERNEL32.444)
*/
VOID RtlZeroMemory( LPVOID ptr, UINT32 len )
{
memset( ptr, 0, len );
}