Merge aicom-network-branch (without NDIS changes for now)
[reactos.git] / rosapps / applications / sysutils / utils / sdkparse / safestr.h
1 //
2 // safestr.h
3 //
4 // safe versions of some string manipulation routines
5 //
6
7 #ifndef __SAFESTR_H
8 #define __SAFESTR_H
9
10 #include <tchar.h>
11
12 #ifndef tchar
13 #define tchar TCHAR
14 #endif//tchar
15
16 #include <string.h>
17 #include "assert.h"
18
19 inline size_t safestrlen ( const tchar *string )
20 {
21 if ( !string )
22 return 0;
23 return _tcslen(string);
24 }
25
26 inline tchar* safestrcpy ( tchar* strDest, const tchar* strSource )
27 {
28 ASSERT(strDest);
29 if ( !strSource )
30 *strDest = 0;
31 else
32 _tcscpy ( strDest, strSource );
33 return strDest;
34 }
35
36 inline tchar* safestrncpy ( tchar* strDest, const tchar* strSource, size_t count )
37 {
38 ASSERT(strDest);
39 if ( !strSource )
40 count = 0;
41 else
42 _tcsncpy ( strDest, strSource, count );
43 strDest[count] = 0;
44 return strDest;
45 }
46
47 inline tchar* safestrlwr ( tchar* str )
48 {
49 if ( !str )
50 return 0;
51 return _tcslwr(str);
52 }
53
54 inline tchar* safestrupr ( tchar* str )
55 {
56 if ( !str )
57 return 0;
58 return _tcsupr(str);
59 }
60
61 #endif//__SAFESTR_H