source: trunk/include/uniconv.h@ 890

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

* empty log message *

File size: 17.0 KB
Line 
1/* $Id: uniconv.h,v 1.5 1999-07-22 15:41:33 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 ICURRENCY 75
176#define INEGCURR 83
177#define SINTLSYMBOL 87
178#define SABBREVLANGNAME 88
179#define SLANGUAGE 104
180#define WTIMEFORMAT 123
181#define WSHORTDATE 124
182#define WLONGDATE 125
183#define SENGCOUNTRYNAME 105
184#define SENGLANGUAGE 103
185#define SCOUNTRY 106 // Fixme or 107?
186#define IANSICODEPAGE 110
187#define ICODEPAGE 111
188#define IALTCODEPAGE 112
189#define IMACCODEPAGE 113
190#define ICOUNTRY 108
191#define SISO639LANGNAME 101
192#define SISO3166CTRYNAME 102
193#define SABBREVCTRYNAME 102
194#define SNATIVEDIGITS 53
195
196
197#if defined(__IBMCPP__) || defined(__IBMC__)
198 #define CALLCONV _System
199#else
200 #define CALLCONV
201#endif
202typedef int ulsBool;
203#ifndef TRUE
204 #define TRUE 1
205#endif
206#ifndef FALSE
207 #define FALSE 0
208#endif
209#ifndef _ULS_UNICHAR_DEFINED
210 typedef unsigned short UniChar ;
211 #define _ULS_UNICHAR_DEFINED
212#endif
213typedef void *LocaleObject;
214typedef unsigned int LocaleToken;
215typedef void *AttrObject;
216typedef void *XformObject;
217#define UNI_TOKEN_POINTER 1
218#define UNI_MBS_STRING_POINTER 2
219#define UNI_UCS_STRING_POINTER 3
220#undef LANG
221#undef LC_ALL
222#undef LC_COLLATE
223#undef LC_CTYPE
224#undef LC_NUMERIC
225#undef LC_MONETARY
226#undef LC_TIME
227#undef LC_MESSAGES
228#define LANG (-2)
229#define LC_ALL (-1)
230#define LC_COLLATE 0
231#define LC_CTYPE 1
232#define LC_NUMERIC 2
233#define LC_MONETARY 3
234#define LC_TIME 4
235#define LC_MESSAGES 5
236struct UniLconv {
237 UniChar *decimal_point;
238 UniChar *thousands_sep;
239 short *grouping;
240 UniChar *int_curr_symbol;
241 UniChar *currency_symbol;
242 UniChar *mon_decimal_point;
243 UniChar *mon_thousands_sep;
244 short *mon_grouping;
245 UniChar *positive_sign;
246 UniChar *negative_sign;
247 short int_frac_digits;
248 short frac_digits;
249 short p_cs_precedes;
250 short p_sep_by_space;
251 short n_cs_precedes;
252 short n_sep_by_space;
253 short p_sign_posn;
254 short n_sign_posn;
255 short os2_mondecpt;
256 UniChar *debit_sign;
257 UniChar *credit_sign;
258 UniChar *left_parenthesis;
259 UniChar *right_parenthesis;
260};
261int CALLCONV UniCreateLocaleObject ( int locale_spec_type, const void *locale_spec,
262 LocaleObject *locale_object_ptr );
263int CALLCONV UniQueryLocaleObject ( const LocaleObject locale_object, int category,
264 int locale_spec_type, void **locale_spec_ptr );
265int CALLCONV UniFreeLocaleObject ( LocaleObject locale_object );
266int CALLCONV UniFreeMem ( void *memory_ptr );
267int CALLCONV UniLocaleStrToToken ( int locale_string_type, const void *locale_string,
268 LocaleToken *locale_token_ptr );
269int CALLCONV UniLocaleTokenToStr ( const LocaleToken locale_token,
270 int locale_string_type, void **locale_string_ptr );
271int CALLCONV UniQueryLocaleInfo ( const LocaleObject locale_object,
272 struct UniLconv **unilconv_addr_ptr );
273int CALLCONV UniFreeLocaleInfo ( struct UniLconv *unilconv_addr );
274int CALLCONV UniQueryLocaleItem ( const LocaleObject locale_object,
275 LocaleItem item,
276 UniChar **info_item_addr_ptr );
277size_t CALLCONV UniStrftime ( const LocaleObject locale_object,
278 UniChar *ucs, size_t maxsize,
279 const UniChar *format, const struct tm *time_ptr );
280UniChar * CALLCONV UniStrptime ( const LocaleObject locale_object,
281 const UniChar *buf, const UniChar *format,
282 struct tm *time_ptr );
283int CALLCONV UniStrfmon ( const LocaleObject locale_object,
284 UniChar *ucs, size_t maxsize,
285 const UniChar *format, ... );
286UniChar * CALLCONV UniStrcat ( UniChar *ucs1, const UniChar *ucs2 );
287UniChar * CALLCONV UniStrchr ( const UniChar *ucs, UniChar uc );
288int CALLCONV UniStrcmp ( const UniChar *ucs1, const UniChar *ucs2 );
289UniChar * CALLCONV UniStrcpy ( UniChar *ucs1, const UniChar *ucs2 );
290size_t CALLCONV UniStrcspn ( const UniChar *ucs1, const UniChar *ucs2 );
291size_t CALLCONV UniStrlen ( const UniChar *ucs1 );
292UniChar * CALLCONV UniStrncat ( UniChar *ucs1, const UniChar *ucs2, size_t n );
293int CALLCONV UniStrncmp ( const UniChar *ucs1, const UniChar *ucs2, size_t n );
294UniChar * CALLCONV UniStrncpy ( UniChar *ucs1, const UniChar *ucs2, size_t n );
295UniChar * CALLCONV UniStrpbrk ( const UniChar *ucs1, const UniChar *ucs2 );
296UniChar * CALLCONV UniStrrchr ( const UniChar *ucs, UniChar uc );
297size_t CALLCONV UniStrspn ( const UniChar *ucs1, const UniChar *ucs2 );
298UniChar * CALLCONV UniStrstr ( const UniChar *ucs1, const UniChar *ucs2 );
299UniChar * CALLCONV UniStrtok ( UniChar *ucs1, const UniChar *ucs2 );
300int CALLCONV UniCreateAttrObject ( const LocaleObject locale_object,
301 const UniChar *attr_name,
302 AttrObject *attr_object_ptr );
303int CALLCONV UniQueryCharAttr ( AttrObject attr_object, UniChar uc );
304int CALLCONV UniScanForAttr ( AttrObject attr_object, const UniChar *ucs,
305 size_t num_elems, ulsBool inverse_op,
306 size_t *offset_ptr );
307int CALLCONV UniFreeAttrObject ( AttrObject attr_object );
308int CALLCONV UniQueryAlnum ( const LocaleObject locale_object, UniChar uc );
309int CALLCONV UniQueryAlpha ( const LocaleObject locale_object, UniChar uc );
310int CALLCONV UniQueryBlank ( const LocaleObject locale_object, UniChar uc );
311int CALLCONV UniQueryCntrl ( const LocaleObject locale_object, UniChar uc );
312int CALLCONV UniQueryDigit ( const LocaleObject locale_object, UniChar uc );
313int CALLCONV UniQueryGraph ( const LocaleObject locale_object, UniChar uc );
314int CALLCONV UniQueryLower ( const LocaleObject locale_object, UniChar uc );
315int CALLCONV UniQueryPrint ( const LocaleObject locale_object, UniChar uc );
316int CALLCONV UniQueryPunct ( const LocaleObject locale_object, UniChar uc );
317int CALLCONV UniQuerySpace ( const LocaleObject locale_object, UniChar uc );
318int CALLCONV UniQueryUpper ( const LocaleObject locale_object, UniChar uc );
319int CALLCONV UniQueryXdigit ( const LocaleObject locale_object, UniChar uc );
320int CALLCONV UniCreateTransformObject ( const LocaleObject locale_object,
321 const UniChar *xtype,
322 XformObject *xform_object_ptr );
323int CALLCONV UniTransformStr ( XformObject xform_object,
324 const UniChar *inp_buf, int *inp_size,
325 UniChar *out_buf, int *out_size );
326int CALLCONV UniFreeTransformObject ( XformObject xform_object );
327UniChar CALLCONV UniTransLower ( const LocaleObject locale_object, UniChar uc );
328UniChar CALLCONV UniTransUpper ( const LocaleObject locale_object, UniChar uc );
329int CALLCONV UniStrtod ( const LocaleObject locale_object, const UniChar *ucs,
330 UniChar **end_ptr, double *result_ptr );
331int CALLCONV UniStrtol ( const LocaleObject locale_object, const UniChar *ucs,
332 UniChar **end_ptr, int base, long int *result_ptr );
333int CALLCONV UniStrtoul ( const LocaleObject locale_object, const UniChar *ucs,
334 UniChar **end_ptr, int base, unsigned long int *result_ptr );
335int CALLCONV UniStrcoll ( const LocaleObject locale_object,
336 const UniChar *ucs1, const UniChar *ucs2 );
337size_t CALLCONV UniStrxfrm ( const LocaleObject locale_object,
338 UniChar *ucs1, const UniChar *ucs2, size_t n );
339int CALLCONV UniStrcmpi ( const LocaleObject locale_object,
340 const UniChar *ucs1, const UniChar *ucs2 );
341int CALLCONV UniStrncmpi ( const LocaleObject locale_object,
342 const UniChar *ucs1, const UniChar *ucs2, const size_t n );
343UniChar CALLCONV UniToupper (UniChar uc);
344UniChar CALLCONV UniTolower (UniChar uc);
345UniChar * CALLCONV UniStrupr (UniChar *ucs);
346UniChar * CALLCONV UniStrlwr (UniChar *ucs);
347int CALLCONV UniMapCtryToLocale(unsigned long Country,
348 UniChar *LocaleName,
349 size_t n);
350#ifndef _ULS_UCONVP
351#define _ULS_UCONVP
352typedef void * UconvObject;
353#endif
354#ifndef _ULS_UNICHAR_DEFINED
355#define _ULS_UNICHAR_DEFINED
356typedef unsigned short UniChar ;
357#endif
358#ifndef ULS_ATTR
359#define ULS_ATTR
360#define UCONV_OPTION_SUBSTITUTE_FROM_UNICODE 1
361#define UCONV_OPTION_SUBSTITUTE_TO_UNICODE 2
362#define UCONV_OPTION_SUBSTITUTE_BOTH 3
363#define CVTTYPE_PATH 0x00000004 /* Treat string as a path */
364#define CVTTYPE_CDRA 0x00000002 /* Use CDRA control mapping */
365#define CVTTYPE_CTRL7F 0x00000001 /* Treat 0x7F as a control */
366#define DSPMASK_DATA 0xffffffff
367#define DSPMASK_DISPLAY 0x00000000
368#define DSPMASK_TAB 0x00000200
369#define DSPMASK_LF 0x00000400
370#define DSPMASK_CR 0x00002000
371#define DSPMASK_CRLF 0x00002400
372enum uconv_esid {
373 ESID_sbcs_data = 0x2100,
374 ESID_sbcs_pc = 0x3100,
375 ESID_sbcs_ebcdic = 0x1100,
376 ESID_sbcs_iso = 0x4100,
377 ESID_sbcs_windows = 0x4105,
378 ESID_sbcs_alt = 0xF100,
379 ESID_dbcs_data = 0x2200,
380 ESID_dbcs_pc = 0x3200,
381 ESID_dbcs_ebcdic = 0x1200,
382 ESID_mbcs_data = 0x2300,
383 ESID_mbcs_pc = 0x3300,
384 ESID_mbcs_ebcdic = 0x1301,
385 ESID_ucs_2 = 0x7200,
386 ESID_ugl = 0x72FF,
387 ESID_utf_8 = 0x7807,
388 ESID_upf_8 = 0x78FF
389};
390#ifndef __conv_endian_t
391#define __conv_endian_t
392#define ENDIAN_SYSTEM 0x0000
393#define ENDIAN_BIG 0xfeff
394#define ENDIAN_LITTLE 0xfffe
395typedef struct _conv_endian_rec {
396 unsigned short source;
397 unsigned short target;
398} conv_endian_t;
399#endif
400typedef struct _uconv_attribute_t {
401 unsigned long version;
402 char mb_min_len;
403 char mb_max_len;
404 char usc_min_len;
405 char usc_max_len;
406 unsigned short esid;
407 char options;
408 char state;
409 conv_endian_t endian;
410 unsigned long displaymask;
411 unsigned long converttype;
412 unsigned short subchar_len;
413 unsigned short subuni_len;
414 char subchar[16];
415 UniChar subuni[8];
416} uconv_attribute_t;
417typedef struct {
418 unsigned short first;
419 unsigned short last;
420} udcrange_t;
421#endif
422#define uconv_error_t int
423int CALLCONV UniCreateUconvObject(
424 UniChar * code_set,
425 UconvObject * uobj );
426int CALLCONV UniQueryUconvObject(
427 UconvObject uobj,
428 uconv_attribute_t * attr,
429 size_t size,
430 char first[256],
431 char other[256],
432 udcrange_t udcrange[32]);
433int CALLCONV UniSetUconvObject(
434 UconvObject uobj,
435 uconv_attribute_t * attr);
436int CALLCONV UniUconvToUcs(
437 UconvObject uobj,
438 void * * inbuf,
439 size_t * inbytes,
440 UniChar * * outbuf,
441 size_t * outchars,
442 size_t * subst );
443int CALLCONV UniUconvFromUcs(
444 UconvObject uobj,
445 UniChar * * inbuf,
446 size_t * inchars,
447 void * * outbuf,
448 size_t * outbytes,
449 size_t * subst );
450int CALLCONV UniFreeUconvObject(
451 UconvObject uobj );
452int CALLCONV UniMapCpToUcsCp( unsigned long ulCodePage, UniChar *ucsCodePage, size_t n );
453#define UCONV_EOTHER ULS_OTHER
454#define UCONV_EILSEQ ULS_ILLEGALSEQUENCE
455#define UCONV_EINVAL ULS_INVALID
456#define UCONV_E2BIG ULS_BUFFERFULL
457#define UCONV_ENOMEM ULS_NOMEMORY
458#define UCONV_EBADF ULS_BADOBJECT
459#define UCONV_BADATTR ULS_BADATTR
460#define UCONV_EMFILE ULS_MAXFILESPERPROC
461#define UCONV_ENFILE ULS_MAXFILES
462#define UCONV_NOTIMPLEMENTED ULS_NOTIMPLEMENTED
463#define IBM_437 (UniChar *)L"IBM-437"
464#define IBM_819 (UniChar *)L"IBM-819"
465#define IBM_850 (UniChar *)L"IBM-850"
466#define UTF_8 (UniChar *)L"IBM-1208"
467#define UCS_2 (UniChar *)L"IBM-1200"
468#define ISO8859_1 (UniChar *)L"IBM-819"
469#ifdef __cplusplus
470}
471#endif
472#endif
Note: See TracBrowser for help on using the repository browser.