1 krisbash 1.1 /*
2 **==============================================================================
3 **
4 ** strings.h:
5 **
6 ** This file defines string-manipluation functions. For each string
7 ** operation, there are three implementations:
8 **
9 ** - Single-character - char
10 ** - Wide-character - wchar_t
11 ** - T-character - TChar (char or wchar_t depending on configuration)
12 **
13 ** Each string function has one of the following prefixes:
14 **
15 ** - Str - single character string
16 ** - Wcs - wide character string
17 ** - Tcs - T-character string
18 **
19 ** For example, the are three variants for simple copying of strings:
20 **
21 ** - Strcpy() - same as strcpy()
22 krisbash 1.1 ** - Wcscpy() - same as wcscpy()
23 ** - Tcscpy() - same as strcpy() or wcscpy() depending on configuration.
24 **
25 ** When passing string literals to the Tcs* variant functions, use the
26 ** PAL_T() macro. For example:
27 **
28 ** TChar buf[32];
29 ** Tcscpy(buf, PAL_T("Hello"));
30 **
31 ** For the typedef TChar, one of the following is true:
32 **
33 ** sizeof(TChar) == sizeof(char)
34 ** sizeof(TChar) == sizeof(wchar_t)
35 **
36 ** If the latter is true, then CONFIG_ENABLE_WCHAR is defined.
37 **
38 **==============================================================================
39 */
40
41 #ifndef _pal_strings_h
42 #define _pal_strings_h
43 krisbash 1.1
44 #ifdef _PREFAST_
45 #pragma prefast(push)
46 #pragma prefast(disable:28252)
47 #pragma prefast(disable:28253)
48 #endif
49 #include <wchar.h>
50 #include <string.h>
51 #ifdef _PREFAST_
52 #pragma prefast(pop)
53 #endif
54
55 #include "palcommon.h"
56
57 PAL_BEGIN_EXTERNC
58
59 /*
60 **==============================================================================
61 **
62 ** Strcmp()
63 ** Wcscmp()
64 krisbash 1.1 ** Tcscmp()
65 **
66 **==============================================================================
67 */
68
69 PAL_INLINE int Wcscmp(
70 _In_z_ const wchar_t* s1,
71 _In_z_ const wchar_t* s2)
72 {
73 return wcscmp(s1, s2);
74 }
75
76 PAL_INLINE int Strcmp(
77 _In_z_ const char* s1,
78 _In_z_ const char* s2)
79 {
80 return strcmp(s1, s2);
81 }
82
83 PAL_INLINE int Tcscmp(
84 _In_z_ const TChar* s1,
85 krisbash 1.1 _In_z_ const TChar* s2)
86 {
87 #if defined(CONFIG_ENABLE_WCHAR)
88 return Wcscmp(s1, s2);
89 #else
90 return Strcmp(s1, s2);
91 #endif
92 }
93
94 /*
95 **==============================================================================
96 **
97 ** Strncmp()
98 ** Wcsncmp()
99 ** Tcsncmp()
100 **
101 **==============================================================================
102 */
103
104 #ifdef _PREFAST_
105 #pragma prefast(push)
106 krisbash 1.1 #pragma prefast(disable:26061)
107 #endif
108
109 _When_(return == 0, _Post_satisfies_(
110 ((_String_length_(s1) >= n) && (_String_length_(s2) >= n)) ||
111 ((_String_length_(s1) < n) && (_String_length_(s2) < n) && (_String_length_(s1) == _String_length_(s2)))
112 ))
113 PAL_INLINE int Strncmp(
114 _In_z_ const char* s1,
115 _In_z_ const char* s2,
116 size_t n)
117 {
118 return strncmp(s1, s2, n);
119 }
120
121 _When_(return == 0, _Post_satisfies_(
122 ((_String_length_(s1) >= n) && (_String_length_(s2) >= n)) ||
123 ((_String_length_(s1) < n) && (_String_length_(s2) < n) && (_String_length_(s1) == _String_length_(s2)))
124 ))
125 PAL_INLINE int Wcsncmp(
126 _In_z_ const wchar_t* s1,
127 krisbash 1.1 _In_z_ const wchar_t* s2,
128 size_t n)
129 {
130 return wcsncmp(s1, s2, n);
131 }
132
133 #ifdef _PREFAST_
134 #pragma prefast(pop)
135 #endif
136
137 _When_(return == 0, _Post_satisfies_(
138 ((_String_length_(s1) >= n) && (_String_length_(s2) >= n)) ||
139 ((_String_length_(s1) < n) && (_String_length_(s2) < n) && (_String_length_(s1) == _String_length_(s2)))
140 ))
141 PAL_INLINE int Tcsncmp(
142 _In_z_ const TChar* s1,
143 _In_z_ const TChar* s2,
144 size_t n)
145 {
146 #if defined(CONFIG_ENABLE_WCHAR)
147 return Wcsncmp(s1, s2, n);
148 krisbash 1.1 #else
149 return Strncmp(s1, s2, n);
150 #endif
151 }
152
153 /*
154 **==============================================================================
155 **
156 ** Strlen()
157 ** Wcslen()
158 ** Tcslen()
159 **
160 **==============================================================================
161 */
162
163 #ifdef _PREFAST_
164 #pragma prefast(push)
165 #pragma prefast(disable:28196)
166 /*
167 * WinBlue bug #48847
168 *
169 krisbash 1.1 * wcslen and strlen in sdpublic\sdk\inc\crt\string.h
170 * do not have any SAL annotations. My attempt to work around by
171 * _Analysis_assume_ or wcsnlen_s has failed, so I am just disabling
172 * prefast warning for these 2 functions
173 */
174 #endif
175
176 _Post_satisfies_(return == _String_length_(str))
177 PAL_INLINE size_t Strlen(
178 _In_z_ const char* str)
179 {
180 return strlen(str);
181 }
182
183 _Post_satisfies_(return == _String_length_(str))
184 PAL_INLINE size_t Wcslen(
185 _In_z_ const wchar_t* str)
186 {
187 return wcslen(str);
188 }
189
190 krisbash 1.1 #ifdef _PREFAST_
191 #pragma prefast(pop)
192 #endif
193
194 _Post_satisfies_(return == _String_length_(str))
195 PAL_INLINE size_t Tcslen(
196 _In_z_ const TChar* str)
197 {
198 #if defined(CONFIG_ENABLE_WCHAR)
199 return Wcslen(str);
200 #else
201 return Strlen(str);
202 #endif
203 }
204
205 /*
206 **==============================================================================
207 **
208 ** Strcasecmp()
209 ** Wcscasecmp()
210 ** Tcscasecmp()
211 krisbash 1.1 **
212 **==============================================================================
213 */
214
215 PAL_INLINE int Strcasecmp(
216 _In_z_ const char* s1,
217 _In_z_ const char* s2)
218 {
219 #if defined(_MSC_VER)
220 return _stricmp(s1, s2);
221 #else
222 return strcasecmp(s1, s2);
223 #endif
224 }
225
226 PAL_INLINE int Wcscasecmp(
227 _In_z_ const wchar_t* s1,
228 _In_z_ const wchar_t* s2)
229 {
230 #if defined(_MSC_VER)
231 return _wcsicmp(s1, s2);
232 krisbash 1.1 #else
233 extern int wcscasecmp(const wchar_t*, const wchar_t*);
234 return wcscasecmp(s1, s2);
235 #endif
236 }
237
238 PAL_INLINE int Tcscasecmp(
239 _In_z_ const TChar* s1,
240 _In_z_ const TChar* s2)
241 {
242 #if defined(CONFIG_ENABLE_WCHAR)
243 return Wcscasecmp(s1, s2);
244 #else
245 return Strcasecmp(s1, s2);
246 #endif
247 }
248
249 /*
250 **==============================================================================
251 **
252 ** Strncasecmp()
253 krisbash 1.1 ** Wcsncasecmp()
254 ** Tcsncasecmp()
255 **
256 **==============================================================================
257 */
258
259 #ifdef _PREFAST_
260 #pragma prefast(push)
261 #pragma prefast(disable:26061)
262 #endif
263
264 _When_(return == 0, _Post_satisfies_(
265 ((_String_length_(s1) >= n) && (_String_length_(s2) >= n)) ||
266 ((_String_length_(s1) < n) && (_String_length_(s2) < n) && (_String_length_(s1) == _String_length_(s2)))
267 ))
268 PAL_INLINE int Strncasecmp(
269 _In_z_ const char* s1,
270 _In_z_ const char* s2,
271 size_t n)
272 {
273 #if defined(_MSC_VER)
274 krisbash 1.1 return _strnicmp(s1, s2, n);
275 #else
276 return strncasecmp(s1, s2, n);
277 #endif
278 }
279
280 _When_(return == 0, _Post_satisfies_(
281 ((_String_length_(s1) >= n) && (_String_length_(s2) >= n)) ||
282 ((_String_length_(s1) < n) && (_String_length_(s2) < n) && (_String_length_(s1) == _String_length_(s2)))
283 ))
284 PAL_INLINE int Wcsncasecmp(
285 _In_z_ const wchar_t* s1,
286 _In_z_ const wchar_t* s2,
287 size_t n)
288 {
289 #if defined(_MSC_VER)
290 return _wcsnicmp(s1, s2, n);
291 #else
292 extern int wcsncasecmp(const wchar_t*, const wchar_t*, size_t n);
293 return wcsncasecmp(s1, s2, n);
294 #endif
295 krisbash 1.1 }
296
297 #ifdef _PREFAST_
298 #pragma prefast(pop)
299 #endif
300
301 _When_(return == 0, _Post_satisfies_(
302 ((_String_length_(s1) >= n) && (_String_length_(s2) >= n)) ||
303 ((_String_length_(s1) < n) && (_String_length_(s2) < n) && (_String_length_(s1) == _String_length_(s2)))
304 ))
305 PAL_INLINE int Tcsncasecmp(
306 _In_z_ const TChar* s1,
307 _In_z_ const TChar* s2,
308 size_t n)
309 {
310 #if defined(CONFIG_ENABLE_WCHAR)
311 return Wcsncasecmp(s1, s2, n);
312 #else
313 return Strncasecmp(s1, s2, n);
314 #endif
315 }
316 krisbash 1.1
317 /*
318 **==============================================================================
319 **
320 ** Strtoul()
321 ** Wcstoul()
322 ** Tcstoul()
323 **
324 **==============================================================================
325 */
326
327 PAL_INLINE unsigned long Strtoul(
328 _In_z_ const char* str,
329 _Out_opt_ _Deref_post_z_ char** end,
330 int base)
331 {
332 return strtoul(str, end, base);
333 }
334
335 PAL_INLINE unsigned long Wcstoul(
336 _In_z_ const wchar_t* str,
337 krisbash 1.1 _Out_opt_ _Deref_post_z_ wchar_t** end,
338 int base)
339 {
340 return wcstoul(str, end, base);
341 }
342
343 PAL_INLINE unsigned long Tcstoul(
344 _In_z_ const TChar* str,
345 _Out_opt_ _Deref_post_z_ TChar** end,
346 int base)
347 {
348 #if defined(CONFIG_ENABLE_WCHAR)
349 return Wcstoul(str, end, base);
350 #else
351 return Strtoul(str, end, base);
352 #endif
353 }
354
355 /*
356 **==============================================================================
357 **
358 krisbash 1.1 ** Strtol()
359 ** Wcstol()
360 ** Tcstol()
361 **
362 **==============================================================================
363 */
364
365 PAL_INLINE long Strtol(
366 _In_z_ const char* str,
367 _Out_opt_ _Deref_post_z_ char** end,
368 int base)
369 {
370 return strtol(str, end, base);
371 }
372
373 PAL_INLINE long Wcstol(
374 _In_z_ const wchar_t* str,
375 _Out_opt_ _Deref_post_z_ wchar_t** end,
376 int base)
377 {
378 return wcstol(str, end, base);
379 krisbash 1.1 }
380
381 PAL_INLINE long Tcstol(
382 _In_z_ const TChar* str,
383 _Out_opt_ _Deref_post_z_ TChar** end,
384 int base)
385 {
386 #if defined(CONFIG_ENABLE_WCHAR)
387 return Wcstol(str, end, base);
388 #else
389 return Strtol(str, end, base);
390 #endif
391 }
392
393 /*
394 **==============================================================================
395 **
396 ** Strtoull()
397 ** Wcstoull()
398 ** Tcstoull()
399 **
400 krisbash 1.1 **==============================================================================
401 */
402
403 PAL_INLINE PAL_Uint64 Strtoull(
404 _In_z_ const char* str,
405 _Out_opt_ _Deref_post_z_ char** end,
406 int base)
407 {
408 #if defined(_MSC_VER)
409 return _strtoui64(str, end, base);
410 #else
411 return strtoull(str, end, base);
412 #endif
413 }
414
415 #if defined(CONFIG_ENABLE_WCHAR)
416 PAL_INLINE PAL_Uint64 Wcstoull(
417 _In_z_ const wchar_t* str,
418 _Out_opt_ _Deref_post_z_ wchar_t** end,
419 int base)
420 {
421 krisbash 1.1 #if defined(_MSC_VER)
422 return _wcstoui64(str, end, base);
423 #else
424 extern unsigned long long wcstoull(const wchar_t* s, wchar_t** e, int b);
425 return wcstoull(str, end, base);
426 #endif
427 }
428 #endif
429
430 PAL_INLINE PAL_Uint64 Tcstoull(
431 _In_z_ const TChar* str,
432 _Out_opt_ _Deref_post_z_ TChar** end,
433 int base)
434 {
435 #if defined(CONFIG_ENABLE_WCHAR)
436 return Wcstoull(str, end, base);
437 #else
438 return Strtoull(str, end, base);
439 #endif
440 }
441
442 krisbash 1.1 /*
443 **==============================================================================
444 **
445 ** Strtoll()
446 ** Wcstoll()
447 ** Tcstoll()
448 **
449 **==============================================================================
450 */
451
452 PAL_INLINE PAL_Sint64 Strtoll(
453 _In_z_ const char* str,
454 _Out_opt_ _Deref_post_z_ char** end,
455 int base)
456 {
457 #if defined(_MSC_VER)
458 return _strtoi64(str, end, base);
459 #else
460 return strtoll(str, end, base);
461 #endif
462 }
463 krisbash 1.1
464 PAL_INLINE PAL_Sint64 Wcstoll(
465 _In_z_ const wchar_t* str,
466 _Out_opt_ _Deref_post_z_ wchar_t** end,
467 int base)
468 {
469 #if defined(_MSC_VER)
470 return _wcstoi64(str, end, base);
471 #else
472 extern long long wcstoll(const wchar_t* s, wchar_t** e, int b);
473 return wcstoll(str, end, base);
474 #endif
475 }
476
477 PAL_INLINE PAL_Sint64 Tcstoll(
478 _In_z_ const TChar* str,
479 _Out_opt_ _Deref_post_z_ TChar** end,
480 int base)
481 {
482 #if defined(CONFIG_ENABLE_WCHAR)
483 return Wcstoll(str, end, base);
484 krisbash 1.1 #else
485 return Strtoll(str, end, base);
486 #endif
487 }
488
489 /*
490 **==============================================================================
491 **
492 ** Strtod()
493 ** Wcstod()
494 ** Tcstod()
495 **
496 **==============================================================================
497 */
498
499 PAL_INLINE double Strtod(
500 _In_z_ const char* str,
501 _Out_opt_ _Deref_post_z_ char** end)
502 {
503 return strtod(str, end);
504 }
505 krisbash 1.1
506 PAL_INLINE double Wcstod(
507 _In_z_ const wchar_t* str,
508 _Out_opt_ _Deref_post_z_ wchar_t** end)
509 {
510 return wcstod(str, end);
511 }
512
513 PAL_INLINE double Tcstod(
514 _In_z_ const TChar* str,
515 _Out_opt_ _Deref_post_z_ TChar** end)
516 {
517 #if defined(CONFIG_ENABLE_WCHAR)
518 return Wcstod(str, end);
519 #else
520 return Strtod(str, end);
521 #endif
522 }
523
524 /*
525 **==============================================================================
526 krisbash 1.1 **
527 ** Strchr()
528 ** Wcschr()
529 ** Tcschr()
530 **
531 **==============================================================================
532 */
533
534 PAL_INLINE char* Strchr(
535 _In_z_ const char* str,
536 char ch)
537 {
538 return (char*)strchr(str, ch);
539 }
540
541 PAL_INLINE wchar_t* Wcschr(
542 _In_z_ const wchar_t* str,
543 wchar_t ch)
544 {
545 return (wchar_t*)wcschr(str, ch);
546 }
547 krisbash 1.1
548 PAL_INLINE TChar* Tcschr(
549 _In_z_ const TChar* str,
550 TChar ch)
551 {
552 #if defined(CONFIG_ENABLE_WCHAR)
553 return (wchar_t*)Wcschr(str, ch);
554 #else
555 return (char*)Strchr(str, ch);
556 #endif
557 }
558
559 /*
560 **==============================================================================
561 **
562 ** Strstr()
563 ** Wcsstr()
564 ** Tcsstr()
565 **
566 **==============================================================================
567 */
568 krisbash 1.1
569 PAL_INLINE char* Strstr(
570 _In_z_ const char* haystack,
571 _In_z_ const char* needle)
572 {
573 return (char*)strstr(haystack, needle);
574 }
575
576 PAL_INLINE wchar_t* Wcsstr(
577 _In_z_ const wchar_t* haystack,
578 _In_z_ const wchar_t* needle)
579 {
580 return (wchar_t*)wcsstr(haystack, needle);
581 }
582
583 PAL_INLINE TChar* Tcsstr(
584 _In_z_ const TChar* haystack,
585 _In_z_ const TChar* needle)
586 {
587 #if defined(CONFIG_ENABLE_WCHAR)
588 return (wchar_t*)Wcsstr(haystack, needle);
589 krisbash 1.1 #else
590 return (char*)Strstr(haystack, needle);
591 #endif
592 }
593
594 /*
595 **==============================================================================
596 **
597 ** Strrchr()
598 ** Wcsrchr()
599 ** Tcsrchr()
600 **
601 **==============================================================================
602 */
603
604 PAL_INLINE char* Strrchr(
605 _In_z_ const char* str,
606 char ch)
607 {
608 return (char*)strrchr(str, ch);
609 }
610 krisbash 1.1
611 PAL_INLINE wchar_t* Wcsrchr(
612 _In_z_ const wchar_t* str,
613 wchar_t ch)
614 {
615 return (wchar_t*)wcsrchr(str, ch);
616 }
617
618 PAL_INLINE TChar* Tcsrchr(
619 _In_z_ const TChar* str,
620 TChar ch)
621 {
622 #if defined(CONFIG_ENABLE_WCHAR)
623 return Wcsrchr(str, ch);
624 #else
625 return Strrchr(str, ch);
626 #endif
627 }
628
629 /*
630 **==============================================================================
631 krisbash 1.1 **
632 ** Strcat()
633 ** Wcscat()
634 ** Tcscat()
635 **
636 **==============================================================================
637 */
638
639 PAL_INLINE char* Strcat(
640 _Inout_updates_z_(count) char* dest,
641 size_t count,
642 _In_z_ const char* src)
643 {
644 #if defined(_MSC_VER)
645 strcat_s(dest, count, src);
646 return dest;
647 #else
648 return strcat(dest, src);
649 #endif
650 }
651
652 krisbash 1.1 PAL_INLINE wchar_t* Wcscat(
653 _Inout_updates_z_(count) wchar_t* dest,
654 size_t count,
655 _In_z_ const wchar_t* src)
656 {
657 #if defined(_MSC_VER)
658 wcscat_s(dest, count, src);
659 return dest;
660 #else
661 return wcscat(dest, src);
662 #endif
663 }
664
665 PAL_INLINE TChar* Tcscat(
666 _Inout_updates_z_(count) TChar* dest,
667 size_t count,
668 _In_z_ const TChar* src)
669 {
670 #if defined(CONFIG_ENABLE_WCHAR)
671 return Wcscat(dest, count, src);
672 #else
673 krisbash 1.1 return Strcat(dest, count, src);
674 #endif
675 }
676
677 /*
678 **==============================================================================
679 **
680 ** Strtok()
681 ** Wcstok()
682 ** Tcstok()
683 **
684 **==============================================================================
685 */
686
687 PAL_INLINE char* Strtok(
688 _Inout_opt_z_ char* str,
689 _In_z_ const char* delim,
690 _Inout_ _Deref_prepost_opt_z_ char** ctx)
691 {
692 #if defined(_MSC_VER)
693 return strtok_s(str, delim, ctx);
694 krisbash 1.1 #else
695 return strtok_r(str, delim, ctx);
696 #endif
697 }
698
699 PAL_INLINE wchar_t* Wcstok(
700 _Inout_opt_z_ wchar_t* str,
701 _In_z_ const wchar_t* delim,
702 _Inout_ _Deref_prepost_opt_z_ wchar_t** ctx)
703 {
704 #if defined(_MSC_VER)
705 return wcstok_s(str, delim, ctx);
706 #else
707 return wcstok(str, delim, ctx);
708 #endif
709 }
710
711 PAL_INLINE TChar* Tcstok(
712 _Inout_opt_z_ TChar* str,
713 _In_z_ const TChar* delim,
714 _Inout_ _Deref_prepost_opt_z_ TChar** ctx)
715 krisbash 1.1 {
716 #if defined(CONFIG_ENABLE_WCHAR)
717 return Wcstok(str, delim, ctx);
718 #else
719 return Strtok(str, delim, ctx);
720 #endif
721 }
722
723 /*
724 **==============================================================================
725 **
726 ** Strlcat()
727 ** Wcslcat()
728 ** Tcslcat()
729 **
730 **==============================================================================
731 */
732
733 size_t Strlcat(
734 _Inout_updates_z_(size) char* dest,
735 _In_z_ const char* src,
736 krisbash 1.1 size_t size);
737
738 size_t Wcslcat(
739 _Inout_updates_z_(size) wchar_t* dest,
740 _In_z_ const wchar_t* src,
741 size_t size);
742
743 PAL_INLINE size_t Tcslcat(
744 _Inout_updates_z_(size) TChar* dest,
745 _In_z_ const TChar* src,
746 size_t size)
747 {
748 #if defined(CONFIG_ENABLE_WCHAR)
749 return Wcslcat(dest, src, size);
750 #else
751 return Strlcat(dest, src, size);
752 #endif
753 }
754
755 /* Converts single-characters to TChar while concatenating.
756 */
757 krisbash 1.1 size_t TcsStrlcat(
758 _Inout_updates_z_(size) TChar* dest,
759 _In_z_ const char* src,
760 size_t size);
761
762 /*
763 **==============================================================================
764 **
765 ** Strlcpy()
766 ** Wcslcpy()
767 ** Tcslcpy()
768 **
769 **==============================================================================
770 */
771
772 size_t Strlcpy(
773 _Out_writes_z_(size) char* dest,
774 _In_z_ const char* src,
775 size_t size);
776
777 size_t Wcslcpy(
778 krisbash 1.1 _Out_writes_z_(size) wchar_t* dest,
779 _In_z_ const wchar_t* src,
780 size_t size);
781
782 PAL_INLINE size_t Tcslcpy(
783 _Out_writes_z_(size) TChar* dest,
784 _In_z_ const TChar* src,
785 size_t size)
786 {
787 #if defined(CONFIG_ENABLE_WCHAR)
788 return Wcslcpy(dest, src, size);
789 #else
790 return Strlcpy(dest, src, size);
791 #endif
792 }
793
794 /* Warning: this function truncates wide-characters to single-characters.
795 * please use with care.
796 */
797 size_t StrWcslcpy(
798 _Out_writes_z_(size) char* dest,
799 krisbash 1.1 _In_z_ const wchar_t* src,
800 size_t size);
801
802 /* Converts single-characters to TChar while copying.
803 */
804 size_t TcsStrlcpy(
805 _Out_writes_z_(size) TChar* dest,
806 _In_z_ const char* src,
807 size_t size);
808
809 /* Converts characters to wide characters while copying. This only works
810 * reliably with 7-bit ASCII source strings, except on machines where char is
811 * unsigned (PowerPC and Sparc). In those cases, it also works with ISO-8859-1
812 * source strings and fairly well with ISO-8859-15 and Windows Code Page 1252
813 * source strings.
814 */
815
816 size_t WcsStrlcpy(
817 _Out_writes_z_(size) wchar_t* dest,
818 _In_z_ const char* src,
819 size_t size);
820 krisbash 1.1
821 /*
822 **==============================================================================
823 **
824 ** TcsFromUInt64()
825 ** Converts PAL_Uint64 to PAL_Char
826 **==============================================================================
827 */
828
829 _Post_satisfies_(*size == _String_length_(*result))
830 void TcsFromUInt64(_Pre_writable_size_(64) PAL_Char buf[64], PAL_Uint64 value, _Outptr_result_z_ const PAL_Char **result, _Out_opt_ size_t* size);
831
832 /*
833 **==============================================================================
834 **
835 ** Missing stuff from base/strings.h
836 **==============================================================================
837 */
838
839 _Post_satisfies_(*size == _String_length_(*result))
840 void Sint64ToZStr(_Pre_writable_size_(64) TChar buf[64], PAL_Sint64 value, _Outptr_result_z_ const TChar **result, _Out_opt_ size_t* size);
841 krisbash 1.1
842 _Post_satisfies_(*size == _String_length_(*result))
843 void Uint64ToStr(_Pre_writable_size_(21) char buf[21], PAL_Uint64 value, _Outptr_result_z_ const char **result, _Out_opt_ size_t* size);
844
845
846
847 _Success_(return != NULL) _Ret_notnull_ _Ret_z_
848 _Post_readable_size_(*size)
849 _Null_terminated_ const char* Uint32ToStr(_Pre_writable_size_(11) char buf[11], PAL_Uint32 x, size_t* size);
850
851 #if !defined(CONFIG_ENABLE_WCHAR)
852 _Success_(return != NULL) _Ret_notnull_ _Ret_z_
853 _Post_readable_size_(*size)
854 PAL_INLINE const TChar* Uint32ToZStr(_Pre_writable_size_(11) TChar buf[11], PAL_Uint32 x, size_t* size)
855 {
856 return Uint32ToStr(buf, x, size);
857 }
858
859 _Post_satisfies_(*size == _String_length_(*result))
860 PAL_INLINE void Uint64ToZStr(_Pre_writable_size_(21) TChar buf[21], PAL_Uint64 value, _Outptr_result_z_ const TChar **result, _Out_opt_ size_t* size)
861 {
862 krisbash 1.1 Uint64ToStr(buf, value, result, size);
863 }
864
865 #else
866 _Success_(return != NULL) _Ret_notnull_ _Ret_z_
867 _Post_readable_size_(*size)
868 const TChar* Uint32ToZStr(_Pre_writable_size_(11) TChar buf[11], PAL_Uint32 x, size_t* size);
869
870 _Post_satisfies_(*size == _String_length_(*result))
871 void Uint64ToZStr(_Pre_writable_size_(21) TChar buf[21], PAL_Uint64 value, _Outptr_result_z_ const TChar **result, _Out_opt_ size_t* size);
872 #endif
873
874 #if defined(CONFIG_ENABLE_WCHAR)
875
876 typedef wchar_t Utf32Char;
877 typedef char Utf8Char;
878
879 int ConvertWideCharToMultiByte(
880 const Utf32Char* utf32,
881 size_t utf32Size,
882 size_t* firstNonAscii,
883 krisbash 1.1 Utf8Char* utf8,
884 int utf8Size);
885 #endif
886
887 PAL_END_EXTERNC
888
889 #endif /* _pal_strings_h */
|