186 lines
4.0 KiB
C
186 lines
4.0 KiB
C
/*
|
|
* String functions
|
|
*
|
|
* Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
|
|
* Copyright 1996 Marcus Meissner
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
#include "windef.h"
|
|
#include "winbase.h"
|
|
#include "wingdi.h"
|
|
#include "winuser.h"
|
|
#include "wine/winbase16.h"
|
|
#include "wine/winuser16.h"
|
|
#include "wine/unicode.h"
|
|
#include "winnls.h"
|
|
#include "heap.h"
|
|
#include "ldt.h"
|
|
#include "debugtools.h"
|
|
|
|
DEFAULT_DEBUG_CHANNEL(resource);
|
|
|
|
extern const WORD OLE2NLS_CT_CType3_LUT[]; /* FIXME: does not belong here */
|
|
|
|
/***********************************************************************
|
|
* CharLowerA (USER32.25)
|
|
* FIXME: handle current locale
|
|
*/
|
|
LPSTR WINAPI CharLowerA(LPSTR x)
|
|
{
|
|
LPSTR s;
|
|
|
|
if (HIWORD(x))
|
|
{
|
|
s=x;
|
|
while (*s)
|
|
{
|
|
*s=tolower(*s);
|
|
s++;
|
|
}
|
|
return x;
|
|
}
|
|
else return (LPSTR)tolower((char)(int)x);
|
|
}
|
|
|
|
/***********************************************************************
|
|
* CharLowerBuffA (USER32.26)
|
|
* FIXME: handle current locale
|
|
*/
|
|
DWORD WINAPI CharLowerBuffA(LPSTR x,DWORD buflen)
|
|
{
|
|
DWORD done=0;
|
|
|
|
if (!x) return 0; /* YES */
|
|
while (*x && (buflen--))
|
|
{
|
|
*x=tolower(*x);
|
|
x++;
|
|
done++;
|
|
}
|
|
return done;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* CharLowerBuffW (USER32.27)
|
|
*/
|
|
DWORD WINAPI CharLowerBuffW(LPWSTR x,DWORD buflen)
|
|
{
|
|
DWORD done=0;
|
|
|
|
if (!x) return 0; /* YES */
|
|
while (*x && (buflen--))
|
|
{
|
|
*x=tolowerW(*x);
|
|
x++;
|
|
done++;
|
|
}
|
|
return done;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* CharLowerW (USER32.28)
|
|
* FIXME: handle current locale
|
|
*/
|
|
LPWSTR WINAPI CharLowerW(LPWSTR x)
|
|
{
|
|
if (HIWORD(x))
|
|
{
|
|
LPWSTR s = x;
|
|
while (*s)
|
|
{
|
|
*s = tolowerW(*s);
|
|
s++;
|
|
}
|
|
return x;
|
|
}
|
|
else return (LPWSTR)((UINT)tolowerW(LOWORD(x)));
|
|
}
|
|
|
|
/***********************************************************************
|
|
* CharUpperA (USER32.41)
|
|
* FIXME: handle current locale
|
|
*/
|
|
LPSTR WINAPI CharUpperA(LPSTR x)
|
|
{
|
|
if (HIWORD(x))
|
|
{
|
|
LPSTR s = x;
|
|
while (*s)
|
|
{
|
|
*s=toupper(*s);
|
|
s++;
|
|
}
|
|
return x;
|
|
}
|
|
return (LPSTR)toupper((char)(int)x);
|
|
}
|
|
|
|
/***********************************************************************
|
|
* CharUpperBuffA (USER32.42)
|
|
* FIXME: handle current locale
|
|
*/
|
|
DWORD WINAPI CharUpperBuffA( LPSTR str, DWORD len )
|
|
{
|
|
DWORD ret = len;
|
|
if (!str) return 0; /* YES */
|
|
for (; len; len--, str++) *str = toupper(*str);
|
|
return ret;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* CharUpperBuffW (USER32.43)
|
|
* FIXME: handle current locale
|
|
*/
|
|
DWORD WINAPI CharUpperBuffW( LPWSTR str, DWORD len )
|
|
{
|
|
DWORD ret = len;
|
|
if (!str) return 0; /* YES */
|
|
for (; len; len--, str++) *str = toupperW(*str);
|
|
return ret;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* CharUpperW (USER32.44)
|
|
* FIXME: handle current locale
|
|
*/
|
|
LPWSTR WINAPI CharUpperW(LPWSTR x)
|
|
{
|
|
if (HIWORD(x))
|
|
{
|
|
LPWSTR s = x;
|
|
while (*s)
|
|
{
|
|
*s = toupperW(*s);
|
|
s++;
|
|
}
|
|
return x;
|
|
}
|
|
else return (LPWSTR)((UINT)toupperW(LOWORD(x)));
|
|
}
|
|
|
|
/***********************************************************************
|
|
* IsCharAlphaA (USER.433) (USER32.331)
|
|
* FIXME: handle current locale
|
|
*/
|
|
BOOL WINAPI IsCharAlphaA(CHAR x)
|
|
{
|
|
return (OLE2NLS_CT_CType3_LUT[(unsigned char)x] & C3_ALPHA);
|
|
}
|
|
|
|
/***********************************************************************
|
|
* IsCharAlphaNumericA (USER.434) (USER32.332)
|
|
* FIXME: handle current locale
|
|
*/
|
|
BOOL WINAPI IsCharAlphaNumericA(CHAR x)
|
|
{
|
|
return IsCharAlphaA(x) || isdigit(x) ;
|
|
}
|