2 * NTDLL string functions
4 * Copyright 2000 Alexandre Julliard
5 * Copyright 2000 Jon Griffiths
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 /*********************************************************************
32 INT __cdecl
NTDLL__memicmp( LPCSTR s1
, LPCSTR s2
, DWORD len
)
37 if ((ret
= tolower(*s1
) - tolower(*s2
))) break;
44 /*********************************************************************
47 LPSTR __cdecl
_strupr( LPSTR str
)
50 for ( ; *str
; str
++) *str
= toupper(*str
);
54 /*********************************************************************
57 * convert a string in place to lowercase
59 LPSTR __cdecl
_strlwr( LPSTR str
)
62 for ( ; *str
; str
++) *str
= tolower(*str
);
67 /*********************************************************************
70 LPSTR __cdecl
_ultoa( unsigned long x
, LPSTR buf
, INT radix
)
72 char *p
, buffer
[8*sizeof(unsigned long) + 1]; /* assume 8-bit chars */
74 p
= buffer
+ sizeof(buffer
);
79 *--p
= (rem
<= 9) ? rem
+ '0' : rem
+ 'a' - 10;
87 /*********************************************************************
90 LPSTR __cdecl
_ltoa( long x
, LPSTR buf
, INT radix
)
98 _ultoa( x
, p
, radix
);
103 /*********************************************************************
106 LPSTR __cdecl
_itoa( int x
, LPSTR buf
, INT radix
)
108 return _ltoa( x
, buf
, radix
);
112 /*********************************************************************
113 * _splitpath (NTDLL.@)
115 void __cdecl
_splitpath(const char* inpath
, char * drv
, char * dir
,
116 char* fname
, char * ext
)
118 /* Modified PD code from 'snippets' collection. */
120 char pathbuff
[MAX_PATH
], *path
=pathbuff
;
122 strcpy(pathbuff
, inpath
);
124 /* convert slashes to backslashes for searching */
125 for (ptr
= (char*)path
; *ptr
; ++ptr
)
129 /* look for drive spec */
130 if ('\0' != (ptr
= strchr(path
, ':')))
135 strncpy(drv
, path
, ptr
- path
);
136 drv
[ptr
- path
] = '\0';
143 /* find rightmost backslash or leftmost colon */
144 if (NULL
== (ptr
= strrchr(path
, '\\')))
145 ptr
= (strchr(path
, ':'));
149 ptr
= (char *)path
; /* no path */
155 ++ptr
; /* skip the delimiter */
165 if (NULL
== (p
= strrchr(ptr
, '.')))
182 /* Fix pathological case - Win returns ':' as part of the
183 * directory when no drive letter is given.
185 if (drv
&& drv
[0] == ':')
192 strcat(pathbuff
,dir
);
193 strcpy(dir
,pathbuff
);