home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / header45.zip / unidef.h < prev    next >
C/C++ Source or Header  |  1999-03-15  |  18KB  |  442 lines

  1. /*
  2.  * COMPONENT_NAME:
  3.  *
  4.  * FUNCTIONS: ULS API prototypes and typedefs - public
  5.  *
  6.  * (C) COPYRIGHT International Business Machines Corp. 1994
  7.  * All Rights Reserved
  8.  * Licensed Materials - Property of IBM
  9.  *
  10.  * US Government Users Restricted Rights - Use, duplication or
  11.  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12.  */
  13.  
  14. #ifndef _ULS_UNIDEF
  15. #define _ULS_UNIDEF
  16.  
  17. #ifdef __cplusplus
  18.    extern "C" {
  19. #endif
  20.  
  21. /* compiler dependent include files */
  22. #include <stddef.h>             /* define size_t and wchar_t types */
  23. #include <time.h>               /* define tm struct */
  24.  
  25. /* ULS include files */
  26. #include <os2def.h>
  27. #include <ulserrno.h>           /* uls return code defs */
  28. #include <errcmpat.h>
  29. #include <ulsitem.h>            /* define LocaleItem type */
  30. #include <callconv.h>
  31.  
  32. /*
  33.  * ulsBool Type
  34.  */
  35. typedef int ulsBool;
  36.  
  37. /*
  38.  * UniChar Type
  39.  */
  40. #ifndef _ULS_UNICHAR_DEFINED
  41.     typedef unsigned  short  UniChar ;
  42.     #define _ULS_UNICHAR_DEFINED
  43. #endif
  44.  
  45. /*
  46.  * LocaleObject Type
  47.  */
  48. typedef void  *LocaleObject;
  49.  
  50. /*
  51.  * LocaleToken Type
  52.  */
  53. typedef unsigned int LocaleToken;
  54.  
  55. /*
  56.  * AttrObject Type
  57.  */
  58. typedef void *AttrObject;
  59.  
  60. /*
  61.  * XformObject type
  62.  */
  63. typedef void *XformObject;
  64.  
  65. /*
  66.  * LocaleSpecType Values
  67.  */
  68. #define UNI_TOKEN_POINTER       1
  69. #define UNI_MBS_STRING_POINTER  2
  70. #define UNI_UCS_STRING_POINTER  3
  71.  
  72. /*
  73.  * Locale Types
  74.  */
  75. #define UNI_SYSTEM_LOCALES      1
  76. #define UNI_USER_LOCALES        2
  77.  
  78. /*
  79.  * Categories
  80.  */
  81. #undef LANG
  82. #undef LC_ALL
  83. #undef LC_COLLATE
  84. #undef LC_CTYPE
  85. #undef LC_NUMERIC
  86. #undef LC_MONETARY
  87. #undef LC_TIME
  88. #undef LC_MESSAGES
  89.  
  90. #define LANG         (-2)
  91. #define LC_ALL       (-1)
  92. #define LC_COLLATE    0
  93. #define LC_CTYPE      1
  94. #define LC_NUMERIC    2
  95. #define LC_MONETARY   3
  96. #define LC_TIME       4
  97. #define LC_MESSAGES   5
  98.  
  99. #define N_LC_CATEGORIES  6     /* Number of categories                   */
  100. #define ULS_LNAMEMAX     32    /* Maxlen of locale name (including null) */
  101.  
  102. /*
  103.  * UniLconv locale conventions structure
  104.  */
  105. typedef struct UniLconv {
  106.    UniChar *decimal_point;      /* non-monetary decimal point           */
  107.    UniChar *thousands_sep;      /* non-monetary thousands separator     */
  108.    short   *grouping;           /* non-monetary size of grouping        */
  109.    UniChar *int_curr_symbol;    /* int'l currency symbol and separator  */
  110.    UniChar *currency_symbol;    /* local  currency symbol               */
  111.    UniChar *mon_decimal_point;  /* monetary decimal point               */
  112.    UniChar *mon_thousands_sep;  /* monetary thousands separator         */
  113.    short   *mon_grouping;       /* monetary size of grouping            */
  114.    UniChar *positive_sign;      /* non-negative values sign             */
  115.    UniChar *negative_sign;      /* negative values sign                 */
  116.    short   int_frac_digits;     /* no of fractional digits int currency */
  117.    short   frac_digits;         /* no of fractional digits loc currency */
  118.    short   p_cs_precedes;       /* nonneg curr sym 1-precedes,0-succeeds*/
  119.    short   p_sep_by_space;      /* nonneg curr sym 1-space,0-no space   */
  120.    short   n_cs_precedes;       /* neg curr sym 1-precedes,0-succeeds   */
  121.    short   n_sep_by_space;      /* neg curr sym 1-space 0-no space      */
  122.    short   p_sign_posn;         /* positioning of nonneg monetary sign  */
  123.    short   n_sign_posn;         /* positioning of negative monetary sign*/
  124.    short   os2_mondecpt;        /* os2 curr sym positioning             */
  125.    short   reserved;
  126.    UniChar *debit_sign;         /* non-neg-valued monetary sym - "DB"   */
  127.    UniChar *credit_sign;        /* negative-valued monetary sym - "CR"  */
  128.    UniChar *left_parenthesis;   /* negative-valued monetary sym - "("   */
  129.    UniChar *right_parenthesis;  /* negative-valued monetary sym - ")"   */
  130. } UNILCONV;
  131.  
  132. /*
  133.  * Locale Management Function Prototypes
  134.  */
  135. int     CALLCONV UniCreateLocaleObject ( int locale_spec_type, const void *locale_spec,
  136.                             LocaleObject *locale_object_ptr );
  137. int     CALLCONV UniQueryLocaleObject  ( const LocaleObject locale_object, int category,
  138.                             int locale_spec_type, void **locale_spec_ptr );
  139. int     CALLCONV UniFreeLocaleObject   ( LocaleObject locale_object );
  140. int     CALLCONV UniFreeMem            ( void *memory_ptr );
  141. int     CALLCONV UniLocaleStrToToken   ( int locale_string_type, const void *locale_string,
  142.                             LocaleToken *locale_token_ptr );
  143. int     CALLCONV UniLocaleTokenToStr   ( const LocaleToken locale_token,
  144.                             int locale_string_type, void **locale_string_ptr );
  145.  
  146. /*
  147.  * Locale Information Function Prototypes
  148.  */
  149. int     CALLCONV UniQueryLocaleInfo ( const LocaleObject locale_object,
  150.                          struct UniLconv **unilconv_addr_ptr );
  151. int     CALLCONV UniFreeLocaleInfo  ( struct UniLconv *unilconv_addr );
  152. int     CALLCONV UniQueryLocaleItem ( const LocaleObject locale_object,
  153.                          LocaleItem item,
  154.                          UniChar **info_item_addr_ptr );
  155. int     CALLCONV UniQueryLocaleValue ( const LocaleObject locale_object,
  156.                          LocaleItem item,
  157.                          int *info_item);
  158.  
  159. /*
  160.  * Date and Time Function Prototypes
  161.  */
  162. size_t       CALLCONV UniStrftime ( const LocaleObject locale_object,
  163.                        UniChar *ucs, size_t maxsize,
  164.                        const UniChar *format, const struct tm *time_ptr );
  165. UniChar    * CALLCONV UniStrptime ( const LocaleObject locale_object,
  166.                        const UniChar *buf, const UniChar *format,
  167.                        struct tm *time_ptr );
  168.  
  169. /*
  170.  * Monetary Formatting Function Prototype
  171.  */
  172. int          CALLCONV UniStrfmon  ( const LocaleObject locale_object,
  173.                        UniChar *ucs, size_t maxsize,
  174.                        const UniChar *format, ... );
  175.  
  176. /*
  177.  * String/Character Function Prototypes
  178.  */
  179. UniChar    * CALLCONV UniStrcat  ( UniChar *ucs1, const UniChar *ucs2 );
  180. UniChar    * CALLCONV UniStrchr  ( const UniChar *ucs, UniChar uc );
  181. int          CALLCONV UniStrcmp  ( const UniChar *ucs1, const UniChar *ucs2 );
  182. UniChar    * CALLCONV UniStrcpy  ( UniChar *ucs1, const UniChar *ucs2 );
  183. size_t       CALLCONV UniStrcspn ( const UniChar *ucs1, const UniChar *ucs2 );
  184. size_t       CALLCONV UniStrlen  ( const UniChar *ucs1 );
  185. UniChar    * CALLCONV UniStrncat ( UniChar *ucs1, const UniChar *ucs2, size_t n );
  186. int          CALLCONV UniStrncmp ( const UniChar *ucs1, const UniChar *ucs2, size_t n );
  187. UniChar    * CALLCONV UniStrncpy ( UniChar *ucs1, const UniChar *ucs2, size_t n );
  188. UniChar    * CALLCONV UniStrpbrk ( const UniChar *ucs1, const UniChar *ucs2 );
  189. UniChar    * CALLCONV UniStrrchr ( const UniChar *ucs, UniChar uc );
  190. size_t       CALLCONV UniStrspn  ( const UniChar *ucs1, const UniChar *ucs2 );
  191. UniChar    * CALLCONV UniStrstr  ( const UniChar *ucs1, const UniChar *ucs2 );
  192. UniChar    * CALLCONV UniStrtok  ( UniChar *ucs1, const UniChar *ucs2 );
  193.  
  194.  
  195. /*
  196.  * Character Attribute Function Prototypes
  197.  */
  198. int   CALLCONV UniCreateAttrObject ( const LocaleObject locale_object,
  199.                            const UniChar *attr_name,
  200.                            AttrObject *attr_object_ptr );
  201. int   CALLCONV UniQueryCharAttr    ( AttrObject attr_object, UniChar uc );
  202. int   CALLCONV UniScanForAttr      ( AttrObject attr_object, const UniChar *ucs,
  203.                            size_t num_elems, ulsBool inverse_op,
  204.                            size_t *offset_ptr );
  205. int   CALLCONV UniFreeAttrObject   ( AttrObject attr_object );
  206. int   CALLCONV UniQueryAlnum       ( const LocaleObject loc, UniChar uc );
  207. int   CALLCONV UniQueryAlpha       ( const LocaleObject loc, UniChar uc );
  208. int   CALLCONV UniQueryBlank       ( const LocaleObject loc, UniChar uc );
  209. int   CALLCONV UniQueryCntrl       ( const LocaleObject loc, UniChar uc );
  210. int   CALLCONV UniQueryDigit       ( const LocaleObject loc, UniChar uc );
  211. int   CALLCONV UniQueryGraph       ( const LocaleObject loc, UniChar uc );
  212. int   CALLCONV UniQueryLower       ( const LocaleObject loc, UniChar uc );
  213. int   CALLCONV UniQueryPrint       ( const LocaleObject loc, UniChar uc );
  214. int   CALLCONV UniQueryPunct       ( const LocaleObject loc, UniChar uc );
  215. int   CALLCONV UniQuerySpace       ( const LocaleObject loc, UniChar uc );
  216. int   CALLCONV UniQueryUpper       ( const LocaleObject loc, UniChar uc );
  217. int   CALLCONV UniQueryXdigit      ( const LocaleObject loc, UniChar uc );
  218.  
  219.  
  220. /*
  221.  * String Transformation Function Prototypes
  222.  */
  223. int   CALLCONV UniCreateTransformObject ( const LocaleObject locale_object,
  224.                                 const UniChar *xtype,
  225.                                 XformObject *xform_object_ptr );
  226. int   CALLCONV UniTransformStr          ( XformObject xform_object,
  227.                                 const UniChar *inp_buf, int *inp_size,
  228.                                 UniChar *out_buf, int *out_size );
  229. int   CALLCONV UniFreeTransformObject   ( XformObject xform_object );
  230. UniChar   CALLCONV UniTransLower        ( const LocaleObject locale_object, UniChar uc );
  231. UniChar   CALLCONV UniTransUpper        ( const LocaleObject locale_object, UniChar uc );
  232.  
  233. /*
  234.  * String Conversion Function Prototypes
  235.  */
  236. int   CALLCONV UniStrtod  ( const LocaleObject locale_object, const UniChar *ucs,
  237.                   UniChar **end_ptr, double *result_ptr );
  238. int   CALLCONV UniStrtol  ( const LocaleObject locale_object, const UniChar *ucs,
  239.                   UniChar **end_ptr, int base, long int *result_ptr );
  240. int   CALLCONV UniStrtoul ( const LocaleObject locale_object, const UniChar *ucs,
  241.                   UniChar **end_ptr, int base, unsigned long int *result_ptr );
  242.  
  243. /*
  244.  * String Comparison Function Prototypes
  245.  */
  246. int      CALLCONV UniStrcoll  ( const LocaleObject locale_object,
  247.                      const UniChar *ucs1, const UniChar *ucs2 );
  248. size_t   CALLCONV UniStrxfrm  ( const LocaleObject locale_object,
  249.                      UniChar *ucs1, const UniChar *ucs2, size_t n );
  250. int      CALLCONV UniStrcmpi  ( const LocaleObject locale_object,
  251.                      const UniChar *ucs1, const UniChar *ucs2 );
  252. int      CALLCONV UniStrncmpi ( const LocaleObject locale_object,
  253.                      const UniChar *ucs1, const UniChar *ucs2, const size_t n );
  254.  
  255. /*
  256.  * Unicode Case Mapping Function Prototypes
  257.  */
  258. UniChar   CALLCONV UniToupper ( UniChar uc );
  259. UniChar   CALLCONV UniTolower ( UniChar uc );
  260. UniChar * CALLCONV UniStrupr  ( UniChar * ucs );
  261. UniChar * CALLCONV UniStrlwr  ( UniChar * ucs );
  262.  
  263.  
  264. int CALLCONV UniMapCtryToLocale( unsigned long Country,
  265.                                  UniChar *LocaleName, size_t n );
  266.  
  267. /*
  268.  * Functions for user locales.  These are designed to be externalizable,
  269.  * and are used by WPShell, but are currently private functions.
  270.  * These functions are in ulx.c
  271.  */
  272. int CALLCONV UniSetUserLocaleItem(UniChar * locale, int item, int type, void * value);
  273. int CALLCONV UniMakeUserLocale(UniChar * name, UniChar * basename);
  274. int CALLCONV UniDeleteUserLocale(UniChar * locale);
  275. int CALLCONV UniCompleteUserLocale(void);
  276. int CALLCONV UniQueryLocaleList(int, UniChar *, int);
  277. int CALLCONV UniQueryLanguageName(UniChar *lang, UniChar *isolang,
  278.                                   UniChar **infoitem);
  279. int CALLCONV UniQueryCountryName(UniChar *country, UniChar *isolang,
  280.                                   UniChar **infoitem);
  281.  
  282.  
  283. /*
  284.  * Typedef for QueryCharType and UniQueryStringType indexed
  285.  */
  286. typedef struct {
  287.     USHORT  itype;        /* CTYPE1 - xpg4 attributes     */
  288.     CHAR    bidi;         /* CTYPE2 - Bidi attributes     */
  289.     CHAR    charset;      /* CHARSET- Character set       */
  290.     USHORT  extend;       /* CTYPE3 - Extended attributes */
  291.     USHORT  codepage;     /* Codepage mask (CCP)          */
  292. } UNICTYPE;
  293.  
  294.  
  295. /*
  296.  * Locale independent character classification
  297.  */
  298. int   CALLCONV UniQueryChar          ( UniChar uc, ULONG attr);
  299. ULONG CALLCONV UniQueryAttr          ( UniChar * name);
  300. ULONG CALLCONV UniQueryStringType    ( UniChar * ustr, int size, USHORT * outstr, int kind );
  301. UNICTYPE * CALLCONV UniQueryCharType ( UniChar uchr);
  302. ULONG CALLCONV UniQueryCharTypeTable ( ULONG * count, UNICTYPE * * unictype);
  303. int   CALLCONV UniQueryNumericValue  ( UniChar   uc);
  304.  
  305. /*
  306.  * Character type constants
  307.  */
  308. #define CT_UPPER           0x0001      /* Upper case alphabetic character */
  309. #define CT_LOWER           0x0002      /* Lower case alphabetic character */
  310. #define CT_DIGIT           0x0004      /* Digits 0-9                      */
  311. #define CT_SPACE           0x0008      /* White space and line ends       */
  312. #define CT_PUNCT           0x0010      /* Punctuation marks               */
  313. #define CT_CNTRL           0x0020      /* Control and format characters   */
  314. #define CT_BLANK           0x0040      /* Space and tab                   */
  315. #define CT_XDIGIT          0x0080      /* Hex digits                      */
  316. #define CT_ALPHA           0x0100      /* Letters and linguistic marks    */
  317. #define CT_ALNUM           0x0200      /* Alphanumeric                    */
  318. #define CT_GRAPH           0x0400      /* All except controls and space   */
  319. #define CT_PRINT           0x0800      /* Everything except controls      */
  320. #define CT_NUMBER          0x1000      /* Integral number                 */
  321. #define CT_SYMBOL          0x2000      /* Symbol                          */
  322. #define CT_ASCII           0x8000      /* In standard ASCII set           */
  323.  
  324. /*
  325.  * Define the Win32 equivalent ames for the bits
  326.  */
  327. #define C1_UPPER    CT_UPPER
  328. #define C1_LOWER    CT_LOWER
  329. #define C1_DIGIT    CT_DIGIT
  330. #define C1_SPACE    CT_SPACE
  331. #define C1_PUNCT    CT_PUNCT
  332. #define C1_CNTRL    CT_CNTRL
  333. #define C1_BLANK    CT_BLANK
  334. #define C1_XDIGIT   CT_XDIGIT
  335. #define C1_ALPHA    CT_ALPHA
  336.  
  337. /*
  338.  * Define types used in the unicode layout function.
  339.  */
  340. #define C2_NOTAPPLICABLE     0x00      /*    - Not a character             */
  341. #define C2_LEFTTORIGHT       0x01      /* L  - Left to Right               */
  342. #define C2_RIGHTTOLEFT       0x02      /* R  - Right to Left               */
  343. #define C2_EUROPENUMBER      0x03      /* EN - European number             */
  344. #define C2_EUROPESEPARATOR   0x04      /* ES - European separator          */
  345. #define C2_EUROPETERMINATOR  0x05      /* ET - European terminator         */
  346. #define C2_ARABICNUMBER      0x06      /* AN - Arabic number               */
  347. #define C2_COMMONSEPARATOR   0x07      /* CS - Common separator            */
  348. #define C2_BLOCKSEPARATOR    0x08      /* B  - Block separator             */
  349. #define C2_WHITESPACE        0x0A      /* WS - Whitespace                  */
  350. #define C2_OTHERNEUTRAL      0x0B      /* ON - Other neutral               */
  351. #define C2_MIRRORED          0x0C      /* M  - Symetrical   (not Win32)    */
  352.  
  353.  
  354. /*
  355.  * Define the character set values.  For alphabetics this defines the
  356.  * lingusitic group.  For symbols and punctuation this defines some
  357.  * subtypes.
  358.  */
  359. #define CHS_NONCHAR       0x00
  360. #define CHS_OTHER         0x01
  361. #define CHS_LATIN         0x02
  362. #define CHS_CYRILLIC      0x03
  363. #define CHS_ARABIC        0x04
  364. #define CHS_GREEK         0x05
  365. #define CHS_HEBREW        0x06
  366. #define CHS_THAI          0x07
  367. #define CHS_KATAKANA      0x08
  368. #define CHS_HIRAGANA      0x09
  369. #define CHS_HANGUEL       0x0a
  370. #define CHS_BOPOMOFO      0x0b
  371. #define CHS_DEVANAGARI    0x0c
  372. #define CHS_TELUGU        0x0d
  373. #define CHS_BENGALI       0x0e
  374. #define CHS_GUJARATI      0x0f
  375. #define CHS_GURMUKHI      0x10
  376. #define CHS_TAMIL         0x11
  377. #define CHS_LAO           0x12
  378.  
  379. #define CHS_PUNCTSTART    0x20
  380. #define CHS_PUNCTEND      0x21
  381. #define CHS_DINGBAT       0x22
  382. #define CHS_MATH          0x23
  383. #define CHS_APL           0x24
  384. #define CHS_ARROW         0x25
  385. #define CHS_BOX           0x26
  386. #define CHS_DASH          0x27
  387. #define CHS_CURRENCY      0x28
  388. #define CHS_FRACTION      0x29
  389. #define CHS_LINESEP       0x2a
  390. #define CHS_USERDEF       0x2b
  391.  
  392. /*
  393.  * Define typed for extensions to the POSIX types based on the Win32
  394.  * text processing types.  These duplicate some of the other information
  395.  * in the CT and CHS areas.
  396.  */
  397. #define C3_NONSPACING     0x0001       /* Nonspacing mark       */
  398. #define C3_DIACRITIC      0x0002       /* Diacritic mark        */
  399. #define C3_NSDIACRITIC    0x0003
  400. #define C3_VOWELMARK      0x0004       /* Vowel mark            */
  401. #define C3_NSVOWEL        0x0005
  402. #define C3_SYMBOL         0x0008       /* Symbol (see CT_SYMBOL)*/
  403. #define C3_KATAKANA       0x0010       /* Katakana character    */
  404. #define C3_HIRAGANA       0x0020       /* Hiragana character    */
  405. #define C3_HALFWIDTH      0x0040       /* Half-width varient    */
  406. #define C3_FULLWIDTH      0x0080       /* Full-width varient    */
  407. #define C3_IDEOGRAPH      0x0100       /* Kanji/Han character   */
  408. #define C3_KASHIDA        0x0200       /* Arabic enlonger       */
  409. #define C3_ALPHA          0x8000       /* Alphabetic            */
  410. #define C3_MASK           0x83FF       /* Mask for Win32 bits   */
  411.  
  412. /*
  413.  * Define containing codepage for UGL codepages
  414.  */
  415. #define CCP_437           0x0001       /* US PC                 */
  416. #define CCP_850           0x0002       /* Multilingual PC       */
  417. #define CCP_SYMB          0x0004       /* PostScript Symbol     */
  418. #define CCP_1252          0x0008       /* Windows Latin 1       */
  419. #define CCP_1250          0x0010       /* Windows Latin 2       */
  420. #define CCP_1251          0x0020       /* Windows Cyrillic      */
  421. #define CCP_1254          0x0040       /* Windows Turkish       */
  422. #define CCP_1257          0x0080       /* Windows Baltic        */
  423.  
  424. /*
  425.  * Kind of data return for UniQueryStringType
  426.  */
  427. #define CT_ITYPE     1
  428. #define CT_BIDI      2
  429. #define CT_CHARSET   3
  430. #define CT_EXTENDED  4
  431. #define CT_CODEPAGE  5
  432. #define CT_INDEX     6
  433. #define CT_CTYPE1    7    /* Win32 compat xpg4            */
  434. #define CT_CTYPE2    8    /* Win32 compat bidi            */
  435. #define CT_CTYPE3    9    /* Win32 compat extended        */
  436.  
  437. #ifdef __cplusplus
  438.    }
  439. #endif
  440.  
  441. #endif
  442.