source: trunk/include/uniconv.h@ 359

Last change on this file since 359 was 359, checked in by sandervl, 26 years ago

* empty log message *

File size: 16.9 KB
Line 
1/* $Id: uniconv.h,v 1.4 1999-07-22 08:04:18 sandervl Exp $ */
2/*
3 * OS/2 Unicode API definitions
4 *
5 * Copyright 1999 Achim Hasenmueller
6 * 1999 Przemyslaw Dobrowolski
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11#ifndef _ULS_UCONV
12#define _ULS_UCONV
13#ifdef __cplusplus
14extern "C" {
15#endif
16#include <stddef.h>
17#include <time.h>
18#define ULS_API_ERROR_BASE 0x00020400
19#define ULS_API_ERROR(x) (ULS_API_ERROR_BASE | (x))
20typedef enum _uls_return_codes {
21 ULS_SUCCESS = 0x00000000,
22 ULS_OTHER = ULS_API_ERROR(1),
23 ULS_ILLEGALSEQUENCE = ULS_API_ERROR(2),
24 ULS_MAXFILESPERPROC = ULS_API_ERROR(3),
25 ULS_MAXFILES = ULS_API_ERROR(4),
26 ULS_NOOP = ULS_API_ERROR(5),
27 ULS_TOOMANYKBD = ULS_API_ERROR(6),
28 ULS_KBDNOTFOUND = ULS_API_ERROR(7),
29 ULS_BADHANDLE = ULS_API_ERROR(8),
30 ULS_NODEAD = ULS_API_ERROR(9),
31 ULS_NOSCAN = ULS_API_ERROR(10),
32 ULS_INVALIDSCAN = ULS_API_ERROR(11),
33 ULS_NOTIMPLEMENTED = ULS_API_ERROR(12),
34 ULS_NOMEMORY = ULS_API_ERROR(13),
35 ULS_INVALID = ULS_API_ERROR(14),
36 ULS_BADOBJECT = ULS_API_ERROR(15),
37 ULS_NOTOKEN = ULS_API_ERROR(16),
38 ULS_NOMATCH = ULS_API_ERROR(17),
39 ULS_BUFFERFULL = ULS_API_ERROR(18),
40 ULS_RANGE = ULS_API_ERROR(19),
41 ULS_UNSUPPORTED = ULS_API_ERROR(20),
42 ULS_BADATTR = ULS_API_ERROR(21),
43 ULS_VERSION = ULS_API_ERROR(22)
44} uls_error_t;
45#ifndef UNI_SUCCESS
46 #define UNI_SUCCESS ULS_SUCCESS
47#endif
48#ifndef NO_ERROR
49 #define NO_ERROR 0
50#endif
51#ifndef UNI_UNSUPPORTED
52 #define UNI_UNSUPPORTED ULS_UNSUPPORTED
53#endif
54#ifndef UNI_NOMEMORY
55 #define UNI_NOMEMORY ULS_NOMEMORY
56#endif
57#ifndef UNI_INVALID
58 #define UNI_INVALID ULS_INVALID
59#endif
60#ifndef UNI_BADOBJ
61 #define UNI_BADOBJ ULS_BADOBJECT
62#endif
63#ifndef UNI_NOTOKEN
64 #define UNI_NOTOKEN ULS_NOTOKEN
65#endif
66#ifndef UNI_NOMATCH
67 #define UNI_NOMATCH ULS_NOMATCH
68#endif
69#ifndef UNI_BUFFER_FULL
70 #define UNI_BUFFER_FULL ULS_BUFFERFULL
71#endif
72#ifndef UNI_RANGE
73 #define UNI_RANGE ULS_RANGE
74#endif
75#ifndef ERR_NOOP
76 #define ERR_NOOP ULS_NOOP
77#endif
78#ifndef ERR_TOO_MANY_KBD
79 #define ERR_TOO_MANY_KBD ULS_TOOMANYKBD
80#endif
81#ifndef ERR_KBD_NOT_FOUND
82 #define ERR_KBD_NOT_FOUND ULS_KBDNOTFOUND
83#endif
84#ifndef ERR_KBD_INVALID
85 #define ERR_KBD_INVALID ULS_INVALID
86#endif
87#ifndef ERR_BAD_HANDLE
88 #define ERR_BAD_HANDLE ULS_BADHANDLE
89#endif
90#ifndef ERR_NO_DEAD
91 #define ERR_NO_DEAD ULS_NODEAD
92#endif
93#ifndef ERR_NO_SCAN
94 #define ERR_NO_SCAN ULS_NOSCAN
95#endif
96#ifndef ERR_INVALID_SCAN
97 #define ERR_INVALID_SCAN ULS_INVALIDSCAN
98#endif
99#ifndef ERR_NOT_IMPLEMENTED
100 #define ERR_NOT_IMPLEMENTED ULS_NOTIMPLEMENTED
101#endif
102#ifdef ERR_NO_MEMORY
103#undef ERR_NO_MEMORY
104#endif
105#define ERR_NO_MEMORY ULS_NOMEMORY
106typedef int LocaleItem;
107#define D_T_FMT 1
108#define D_FMT 2
109#define T_FMT 3
110#define AM_STR 4
111#define PM_STR 5
112#define ABDAY_1 6
113#define ABDAY_2 7
114#define ABDAY_3 8
115#define ABDAY_4 9
116#define ABDAY_5 10
117#define ABDAY_6 11
118#define ABDAY_7 12
119#define DAY_1 13
120#define DAY_2 14
121#define DAY_3 15
122#define DAY_4 16
123#define DAY_5 17
124#define DAY_6 18
125#define DAY_7 19
126#define ABMON_1 20
127#define ABMON_2 21
128#define ABMON_3 22
129#define ABMON_4 23
130#define ABMON_5 24
131#define ABMON_6 25
132#define ABMON_7 26
133#define ABMON_8 27
134#define ABMON_9 28
135#define ABMON_10 29
136#define ABMON_11 30
137#define ABMON_12 31
138#define MON_1 32
139#define MON_2 33
140#define MON_3 34
141#define MON_4 35
142#define MON_5 36
143#define MON_6 37
144#define MON_7 38
145#define MON_8 39
146#define MON_9 40
147#define MON_10 41
148#define MON_11 42
149#define MON_12 43
150#define RADIXCHAR 44
151#define THOUSEP 45
152#define YESSTR 46
153#define NOSTR 47
154#define CRNCYSTR 48
155#define CODESET 49
156#define T_FMT_AMPM 55
157#define ERA 56
158#define ERA_D_FMT 57
159#define ERA_D_T_FMT 58
160#define ERA_T_FMT 59
161#define ALT_DIGITS 60
162#define YESEXPR 61
163#define NOEXPR 62
164#define DATESEP 63
165#define TIMESEP 64
166#define LISTSEP 65
167#ifndef _NL_NUM_ITEMS
168#define _NL_NUM_ITEMS 66
169#endif
170// Evil UNI Items hackeckeur ;-)
171// PD 21-07-99: Undefined Uni items!!!! Thanx IBM for undocumented items :-P
172// Names like regedit2 uses:
173#define XLOCALETOKEN 50
174#define XWINLOCALE 51
175#define SINTLSYMBOL 87
176#define SABBREVLANGNAME 88
177#define SLANGUAGE 104
178#define WTIMEFORMAT 123
179#define WSHORTDATE 124
180#define WLONGDATE 125
181#define SENGCOUNTRYNAME 105
182#define SENGLANGUAGE 103
183#define SCOUNTRY 106 // Fixme or 107?
184#define IANSICODEPAGE 110
185#define ICODEPAGE 111
186#define IALTCODEPAGE 112
187#define IMACCODEPAGE 113
188#define ICOUNTRY 108
189#define SISO639LANGNAME 101
190#define SISO3166CTRYNAME 102
191#define SABBREVCTRYNAME 102
192#define SNATIVEDIGITS 53
193
194
195#if defined(__IBMCPP__) || defined(__IBMC__)
196 #define CALLCONV _System
197#else
198 #define CALLCONV
199#endif
200typedef int ulsBool;
201#ifndef TRUE
202 #define TRUE 1
203#endif
204#ifndef FALSE
205 #define FALSE 0
206#endif
207#ifndef _ULS_UNICHAR_DEFINED
208 typedef unsigned short UniChar ;
209 #define _ULS_UNICHAR_DEFINED
210#endif
211typedef void *LocaleObject;
212typedef unsigned int LocaleToken;
213typedef void *AttrObject;
214typedef void *XformObject;
215#define UNI_TOKEN_POINTER 1
216#define UNI_MBS_STRING_POINTER 2
217#define UNI_UCS_STRING_POINTER 3
218#undef LANG
219#undef LC_ALL
220#undef LC_COLLATE
221#undef LC_CTYPE
222#undef LC_NUMERIC
223#undef LC_MONETARY
224#undef LC_TIME
225#undef LC_MESSAGES
226#define LANG (-2)
227#define LC_ALL (-1)
228#define LC_COLLATE 0
229#define LC_CTYPE 1
230#define LC_NUMERIC 2
231#define LC_MONETARY 3
232#define LC_TIME 4
233#define LC_MESSAGES 5
234struct UniLconv {
235 UniChar *decimal_point;
236 UniChar *thousands_sep;
237 short *grouping;
238 UniChar *int_curr_symbol;
239 UniChar *currency_symbol;
240 UniChar *mon_decimal_point;
241 UniChar *mon_thousands_sep;
242 short *mon_grouping;
243 UniChar *positive_sign;
244 UniChar *negative_sign;
245 short int_frac_digits;
246 short frac_digits;
247 short p_cs_precedes;
248 short p_sep_by_space;
249 short n_cs_precedes;
250 short n_sep_by_space;
251 short p_sign_posn;
252 short n_sign_posn;
253 short os2_mondecpt;
254 UniChar *debit_sign;
255 UniChar *credit_sign;
256 UniChar *left_parenthesis;
257 UniChar *right_parenthesis;
258};
259int CALLCONV UniCreateLocaleObject ( int locale_spec_type, const void *locale_spec,
260 LocaleObject *locale_object_ptr );
261int CALLCONV UniQueryLocaleObject ( const LocaleObject locale_object, int category,
262 int locale_spec_type, void **locale_spec_ptr );
263int CALLCONV UniFreeLocaleObject ( LocaleObject locale_object );
264int CALLCONV UniFreeMem ( void *memory_ptr );
265int CALLCONV UniLocaleStrToToken ( int locale_string_type, const void *locale_string,
266 LocaleToken *locale_token_ptr );
267int CALLCONV UniLocaleTokenToStr ( const LocaleToken locale_token,
268 int locale_string_type, void **locale_string_ptr );
269int CALLCONV UniQueryLocaleInfo ( const LocaleObject locale_object,
270 struct UniLconv **unilconv_addr_ptr );
271int CALLCONV UniFreeLocaleInfo ( struct UniLconv *unilconv_addr );
272int CALLCONV UniQueryLocaleItem ( const LocaleObject locale_object,
273 LocaleItem item,
274 UniChar **info_item_addr_ptr );
275size_t CALLCONV UniStrftime ( const LocaleObject locale_object,
276 UniChar *ucs, size_t maxsize,
277 const UniChar *format, const struct tm *time_ptr );
278UniChar * CALLCONV UniStrptime ( const LocaleObject locale_object,
279 const UniChar *buf, const UniChar *format,
280 struct tm *time_ptr );
281int CALLCONV UniStrfmon ( const LocaleObject locale_object,
282 UniChar *ucs, size_t maxsize,
283 const UniChar *format, ... );
284UniChar * CALLCONV UniStrcat ( UniChar *ucs1, const UniChar *ucs2 );
285UniChar * CALLCONV UniStrchr ( const UniChar *ucs, UniChar uc );
286int CALLCONV UniStrcmp ( const UniChar *ucs1, const UniChar *ucs2 );
287UniChar * CALLCONV UniStrcpy ( UniChar *ucs1, const UniChar *ucs2 );
288size_t CALLCONV UniStrcspn ( const UniChar *ucs1, const UniChar *ucs2 );
289size_t CALLCONV UniStrlen ( const UniChar *ucs1 );
290UniChar * CALLCONV UniStrncat ( UniChar *ucs1, const UniChar *ucs2, size_t n );
291int CALLCONV UniStrncmp ( const UniChar *ucs1, const UniChar *ucs2, size_t n );
292UniChar * CALLCONV UniStrncpy ( UniChar *ucs1, const UniChar *ucs2, size_t n );
293UniChar * CALLCONV UniStrpbrk ( const UniChar *ucs1, const UniChar *ucs2 );
294UniChar * CALLCONV UniStrrchr ( const UniChar *ucs, UniChar uc );
295size_t CALLCONV UniStrspn ( const UniChar *ucs1, const UniChar *ucs2 );
296UniChar * CALLCONV UniStrstr ( const UniChar *ucs1, const UniChar *ucs2 );
297UniChar * CALLCONV UniStrtok ( UniChar *ucs1, const UniChar *ucs2 );
298int CALLCONV UniCreateAttrObject ( const LocaleObject locale_object,
299 const UniChar *attr_name,
300 AttrObject *attr_object_ptr );
301int CALLCONV UniQueryCharAttr ( AttrObject attr_object, UniChar uc );
302int CALLCONV UniScanForAttr ( AttrObject attr_object, const UniChar *ucs,
303 size_t num_elems, ulsBool inverse_op,
304 size_t *offset_ptr );
305int CALLCONV UniFreeAttrObject ( AttrObject attr_object );
306int CALLCONV UniQueryAlnum ( const LocaleObject locale_object, UniChar uc );
307int CALLCONV UniQueryAlpha ( const LocaleObject locale_object, UniChar uc );
308int CALLCONV UniQueryBlank ( const LocaleObject locale_object, UniChar uc );
309int CALLCONV UniQueryCntrl ( const LocaleObject locale_object, UniChar uc );
310int CALLCONV UniQueryDigit ( const LocaleObject locale_object, UniChar uc );
311int CALLCONV UniQueryGraph ( const LocaleObject locale_object, UniChar uc );
312int CALLCONV UniQueryLower ( const LocaleObject locale_object, UniChar uc );
313int CALLCONV UniQueryPrint ( const LocaleObject locale_object, UniChar uc );
314int CALLCONV UniQueryPunct ( const LocaleObject locale_object, UniChar uc );
315int CALLCONV UniQuerySpace ( const LocaleObject locale_object, UniChar uc );
316int CALLCONV UniQueryUpper ( const LocaleObject locale_object, UniChar uc );
317int CALLCONV UniQueryXdigit ( const LocaleObject locale_object, UniChar uc );
318int CALLCONV UniCreateTransformObject ( const LocaleObject locale_object,
319 const UniChar *xtype,
320 XformObject *xform_object_ptr );
321int CALLCONV UniTransformStr ( XformObject xform_object,
322 const UniChar *inp_buf, int *inp_size,
323 UniChar *out_buf, int *out_size );
324int CALLCONV UniFreeTransformObject ( XformObject xform_object );
325UniChar CALLCONV UniTransLower ( const LocaleObject locale_object, UniChar uc );
326UniChar CALLCONV UniTransUpper ( const LocaleObject locale_object, UniChar uc );
327int CALLCONV UniStrtod ( const LocaleObject locale_object, const UniChar *ucs,
328 UniChar **end_ptr, double *result_ptr );
329int CALLCONV UniStrtol ( const LocaleObject locale_object, const UniChar *ucs,
330 UniChar **end_ptr, int base, long int *result_ptr );
331int CALLCONV UniStrtoul ( const LocaleObject locale_object, const UniChar *ucs,
332 UniChar **end_ptr, int base, unsigned long int *result_ptr );
333int CALLCONV UniStrcoll ( const LocaleObject locale_object,
334 const UniChar *ucs1, const UniChar *ucs2 );
335size_t CALLCONV UniStrxfrm ( const LocaleObject locale_object,
336 UniChar *ucs1, const UniChar *ucs2, size_t n );
337int CALLCONV UniStrcmpi ( const LocaleObject locale_object,
338 const UniChar *ucs1, const UniChar *ucs2 );
339int CALLCONV UniStrncmpi ( const LocaleObject locale_object,
340 const UniChar *ucs1, const UniChar *ucs2, const size_t n );
341UniChar CALLCONV UniToupper (UniChar uc);
342UniChar CALLCONV UniTolower (UniChar uc);
343UniChar * CALLCONV UniStrupr (UniChar *ucs);
344UniChar * CALLCONV UniStrlwr (UniChar *ucs);
345int CALLCONV UniMapCtryToLocale(unsigned long Country,
346 UniChar *LocaleName,
347 size_t n);
348#ifndef _ULS_UCONVP
349#define _ULS_UCONVP
350typedef void * UconvObject;
351#endif
352#ifndef _ULS_UNICHAR_DEFINED
353#define _ULS_UNICHAR_DEFINED
354typedef unsigned short UniChar ;
355#endif
356#ifndef ULS_ATTR
357#define ULS_ATTR
358#define UCONV_OPTION_SUBSTITUTE_FROM_UNICODE 1
359#define UCONV_OPTION_SUBSTITUTE_TO_UNICODE 2
360#define UCONV_OPTION_SUBSTITUTE_BOTH 3
361#define CVTTYPE_PATH 0x00000004 /* Treat string as a path */
362#define CVTTYPE_CDRA 0x00000002 /* Use CDRA control mapping */
363#define CVTTYPE_CTRL7F 0x00000001 /* Treat 0x7F as a control */
364#define DSPMASK_DATA 0xffffffff
365#define DSPMASK_DISPLAY 0x00000000
366#define DSPMASK_TAB 0x00000200
367#define DSPMASK_LF 0x00000400
368#define DSPMASK_CR 0x00002000
369#define DSPMASK_CRLF 0x00002400
370enum uconv_esid {
371 ESID_sbcs_data = 0x2100,
372 ESID_sbcs_pc = 0x3100,
373 ESID_sbcs_ebcdic = 0x1100,
374 ESID_sbcs_iso = 0x4100,
375 ESID_sbcs_windows = 0x4105,
376 ESID_sbcs_alt = 0xF100,
377 ESID_dbcs_data = 0x2200,
378 ESID_dbcs_pc = 0x3200,
379 ESID_dbcs_ebcdic = 0x1200,
380 ESID_mbcs_data = 0x2300,
381 ESID_mbcs_pc = 0x3300,
382 ESID_mbcs_ebcdic = 0x1301,
383 ESID_ucs_2 = 0x7200,
384 ESID_ugl = 0x72FF,
385 ESID_utf_8 = 0x7807,
386 ESID_upf_8 = 0x78FF
387};
388#ifndef __conv_endian_t
389#define __conv_endian_t
390#define ENDIAN_SYSTEM 0x0000
391#define ENDIAN_BIG 0xfeff
392#define ENDIAN_LITTLE 0xfffe
393typedef struct _conv_endian_rec {
394 unsigned short source;
395 unsigned short target;
396} conv_endian_t;
397#endif
398typedef struct _uconv_attribute_t {
399 unsigned long version;
400 char mb_min_len;
401 char mb_max_len;
402 char usc_min_len;
403 char usc_max_len;
404 unsigned short esid;
405 char options;
406 char state;
407 conv_endian_t endian;
408 unsigned long displaymask;
409 unsigned long converttype;
410 unsigned short subchar_len;
411 unsigned short subuni_len;
412 char subchar[16];
413 UniChar subuni[8];
414} uconv_attribute_t;
415typedef struct {
416 unsigned short first;
417 unsigned short last;
418} udcrange_t;
419#endif
420#define uconv_error_t int
421int CALLCONV UniCreateUconvObject(
422 UniChar * code_set,
423 UconvObject * uobj );
424int CALLCONV UniQueryUconvObject(
425 UconvObject uobj,
426 uconv_attribute_t * attr,
427 size_t size,
428 char first[256],
429 char other[256],
430 udcrange_t udcrange[32]);
431int CALLCONV UniSetUconvObject(
432 UconvObject uobj,
433 uconv_attribute_t * attr);
434int CALLCONV UniUconvToUcs(
435 UconvObject uobj,
436 void * * inbuf,
437 size_t * inbytes,
438 UniChar * * outbuf,
439 size_t * outchars,
440 size_t * subst );
441int CALLCONV UniUconvFromUcs(
442 UconvObject uobj,
443 UniChar * * inbuf,
444 size_t * inchars,
445 void * * outbuf,
446 size_t * outbytes,
447 size_t * subst );
448int CALLCONV UniFreeUconvObject(
449 UconvObject uobj );
450int CALLCONV UniMapCpToUcsCp( unsigned long ulCodePage, UniChar *ucsCodePage, size_t n );
451#define UCONV_EOTHER ULS_OTHER
452#define UCONV_EILSEQ ULS_ILLEGALSEQUENCE
453#define UCONV_EINVAL ULS_INVALID
454#define UCONV_E2BIG ULS_BUFFERFULL
455#define UCONV_ENOMEM ULS_NOMEMORY
456#define UCONV_EBADF ULS_BADOBJECT
457#define UCONV_BADATTR ULS_BADATTR
458#define UCONV_EMFILE ULS_MAXFILESPERPROC
459#define UCONV_ENFILE ULS_MAXFILES
460#define UCONV_NOTIMPLEMENTED ULS_NOTIMPLEMENTED
461#define IBM_437 (UniChar *)L"IBM-437"
462#define IBM_819 (UniChar *)L"IBM-819"
463#define IBM_850 (UniChar *)L"IBM-850"
464#define UTF_8 (UniChar *)L"IBM-1208"
465#define UCS_2 (UniChar *)L"IBM-1200"
466#define ISO8859_1 (UniChar *)L"IBM-819"
467#ifdef __cplusplus
468}
469#endif
470#endif
Note: See TracBrowser for help on using the repository browser.