|
|
1.1 root 1: #ifndef UAE_STRING_H
2: #define UAE_STRING_H
3:
4: #ifdef HAVE_CONFIG_H
5: #include "config.h"
6: #endif
7: #include "uae/types.h"
8: #include <string.h>
9:
10: #ifdef _WIN32
11: /* Make sure the real _tcs* functions are already declared before we
12: * re-define them below. */
13: #include <tchar.h>
14: #include <wchar.h>
15: #include <stdlib.h>
16: #endif
17:
18: #ifdef _WIN32
19: /* Using the real _tcs* functions */
20: #else
21: #define _istdigit isdigit
22: #define _istspace isspace
23: #define _istupper isupper
24: #define _sntprintf snprintf
25: #define _stprintf sprintf
26: #define _strtoui64 strtoll
27: #define _tcscat strcat
28: #define _tcschr strchr
29: #define _tcscmp strcmp
30: #define _tcscpy strcpy
31: #define _tcscspn strcspn
32: #define _tcsdup strdup
33: #define _tcsftime strftime
34: #define _tcsftime strftime
35: #define _tcsicmp strcasecmp
36: #define _tcslen strlen
37: #define _tcsncat strncat
38: #define _tcsncmp strncmp
39: #define _tcsncpy strncpy
40: #define _tcsnicmp strncasecmp
41: #define _tcsrchr strrchr
42: #define _tcsspn strspn
43: #define _tcsstr strstr
44: #define _tcstod strtod
45: #define _tcstok strtok
46: #define _tcstol strtol
47: #define _totlower tolower
48: #define _totupper toupper
49: #define _tprintf printf
50: #define _tstof atof
51: #define _tstoi64 atoll
52: #define _tstoi atoi
53: #define _tstol atol
54: #define _vsnprintf vsnprintf
55: #define _vsntprintf vsnprintf
56: #endif
57:
58: static inline size_t uae_tcslcpy(TCHAR *dst, const TCHAR *src, size_t size)
59: {
60: if (size == 0) {
61: return 0;
62: }
63: size_t src_len = _tcslen(src);
64: size_t cpy_len = src_len;
65: if (cpy_len >= size) {
66: cpy_len = size - 1;
67: }
68: memcpy(dst, src, cpy_len * sizeof(TCHAR));
69: dst[cpy_len] = _T('\0');
70: return src_len;
71: }
72:
73: static inline size_t uae_strlcpy(char *dst, const char *src, size_t size)
74: {
75: if (size == 0) {
76: return 0;
77: }
78: size_t src_len = strlen(src);
79: size_t cpy_len = src_len;
80: if (cpy_len >= size) {
81: cpy_len = size - 1;
82: }
83: memcpy(dst, src, cpy_len);
84: dst[cpy_len] = '\0';
85: return src_len;
86: }
87:
88: #endif /* UAE_STRING_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.