Moved global atoms to the server (based on the work of Sergei
[wine] / server / unicode.h
1 /*
2  * Unicode routines for use inside the server
3  *
4  * Copyright (C) 1999 Alexandre Julliard
5  */
6
7 #ifndef __WINE_SERVER_UNICODE_H
8 #define __WINE_SERVER_UNICODE_H
9
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
12 #endif
13
14 #include "config.h"
15
16 #include <ctype.h>
17 #ifdef HAVE_WCTYPE_H
18 #include <wctype.h>
19 #endif
20
21 #include "windef.h"
22 #include "object.h"
23
24 static inline size_t strlenW( const WCHAR *str )
25 {
26     const WCHAR *s = str;
27     while (*s) s++;
28     return s - str;
29 }
30
31 static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 ) 
32 {
33     while (*str1 && (*str1 == *str2)) { str1++; str2++; }
34     return *str1 - *str2;
35 }
36
37 #ifndef HAVE_WCTYPE_H
38 /* FIXME */
39 #define towupper(ch) (HIBYTE(ch) ? ch : (WCHAR)toupper(LOBYTE(ch)))
40 #endif
41
42 static inline int strcmpiW( const WCHAR *str1, const WCHAR *str2 ) 
43 {
44     while (*str1 && (towupper(*str1) == towupper(*str2))) { str1++; str2++; }
45     return towupper(*str1) - towupper(*str2);
46 }
47
48 static inline WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) 
49 {
50     const WCHAR *ret = dst;
51     while ((*dst++ = *src++));
52     return (WCHAR *)ret;
53 }
54
55 static inline WCHAR *strdupW( const WCHAR *str )
56 {
57     size_t len = (strlenW(str) + 1) * sizeof(WCHAR);
58     return memdup( str, len );
59 }
60
61 extern int dump_strW( const WCHAR *str, size_t len, FILE *f, char escape[2] );
62
63 #endif  /* __WINE_SERVER_UNICODE_H */