vfs: check userland buffers before reading them.
[haiku.git] / headers / private / libroot / locale / ICUCtypeData.h
blob72b335ee9a4fccddaab793c32575519bf7ca2c23
1 /*
2 * Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _ICU_CTYPE_DATA_H
6 #define _ICU_CTYPE_DATA_H
9 #include "ICUCategoryData.h"
10 #include "LocaleBackend.h"
13 namespace BPrivate {
14 namespace Libroot {
17 class ICUCtypeData : public ICUCategoryData {
18 typedef ICUCategoryData inherited;
19 public:
20 ICUCtypeData(pthread_key_t tlsKey);
21 virtual ~ICUCtypeData();
23 void Initialize(LocaleCtypeDataBridge* dataBridge);
25 virtual status_t SetTo(const Locale& locale,
26 const char* posixLocaleName);
27 virtual status_t SetToPosix();
29 int IsWCType(wint_t wc, wctype_t charClass);
30 status_t ToWCTrans(wint_t wc, wctrans_t transition,
31 wint_t& result);
33 status_t MultibyteToWchar(wchar_t* wcOut, const char* mb,
34 size_t mbLength, mbstate_t* mbState,
35 size_t& lengthOut);
36 status_t MultibyteStringToWchar(wchar_t* wcDest,
37 size_t wcDestLength, const char** mbSource,
38 size_t mbSourceLength, mbstate_t* mbState,
39 size_t& lengthOut);
40 status_t WcharToMultibyte(char* mbOut, wchar_t wc,
41 mbstate_t* mbState, size_t& lengthOut);
42 status_t WcharStringToMultibyte(char* mbDest,
43 size_t mbDestLength,
44 const wchar_t** wcSource,
45 size_t wcSourceLength, mbstate_t* mbState,
46 size_t& lengthOut);
48 const char* GetLanginfo(int index);
50 private:
51 status_t _GetConverterForMbState(mbstate_t* mbState,
52 UConverter*& converterOut);
54 status_t _DropConverterFromMbState(mbstate_t* mbState);
57 * The following arrays have 384 elements where the elements at
58 * index -128..-2 mirror the elements at index 128..255 (to protect
59 * against invocations of ctype macros with negative character
60 * values).
61 * The element at index -1 is a dummy element containing the
62 * neutral/identity value used when the array is accessed as in
63 * 'isblank(EOF)' (i.e. with index -1).
65 unsigned short fClassInfo[384];
66 int fToLowerMap[384];
67 int fToUpperMap[384];
69 LocaleCtypeDataBridge* fDataBridge;
73 } // namespace Libroot
74 } // namespace BPrivate
77 #endif // _ICU_CTYPE_DATA_H