home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / os232.exe / INCLUDE / UNICODE.H < prev   
C/C++ Source or Header  |  1995-05-17  |  15KB  |  344 lines

  1.  
  2. /*--------------------------------------------------------------------------
  3.  
  4.    $Workfile:   unicode.h  $
  5.    $Revision:   1.23  $
  6.    $Date:   17 May 1995 08:39:40  $
  7.    $Copyright:
  8.  
  9.    Copyright (c) 1989-1995 Novell, Inc.  All Rights Reserved.                      
  10.  
  11.    THIS WORK IS  SUBJECT  TO  U.S.  AND  INTERNATIONAL  COPYRIGHT  LAWS  AND
  12.    TREATIES.   NO  PART  OF  THIS  WORK MAY BE  USED,  PRACTICED,  PERFORMED
  13.    COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED,  ABRIDGED, CONDENSED,
  14.    EXPANDED,  COLLECTED,  COMPILED,  LINKED,  RECAST, TRANSFORMED OR ADAPTED
  15.    WITHOUT THE PRIOR WRITTEN CONSENT OF NOVELL, INC. ANY USE OR EXPLOITATION
  16.    OF THIS WORK WITHOUT AUTHORIZATION COULD SUBJECT THE PERPETRATOR TO
  17.    CRIMINAL AND CIVIL LIABILITY.$
  18.  
  19. --------------------------------------------------------------------------*/
  20.  
  21.  
  22. #if !defined( UNICODE_H )
  23. #define UNICODE_H
  24.  
  25.  
  26. /* make sure size_t is defined */
  27. #include <stddef.h>
  28.  
  29. #ifndef NTYPES_H
  30. #  include "ntypes.h"
  31. #endif
  32.  
  33. /****************************************************************************/
  34. /*
  35.     Definition of a Unicode character - Must be 16 bits wide
  36. */
  37. typedef nwchar    unicode;
  38. typedef pnwchar   punicode;
  39. typedef ppnwchar  ppunicode;
  40.  
  41.  
  42. /****************************************************************************/
  43. /*
  44.     Error codes
  45. */
  46. #define UNI_ALREADY_LOADED   -489  /* Already loaded another country or code page */
  47. #define UNI_FUTURE_OPCODE    -490  /* Rule table has unimplimented rules*/
  48. #define UNI_NO_SUCH_FILE     -491  /* No such file or directory */
  49. #define UNI_TOO_MANY_FILES   -492  /* Too many files already open */
  50. #define UNI_NO_PERMISSION    -493  /* Permission denied on file open */
  51. #define UNI_NO_MEMORY        -494  /* Not enough memory */
  52. #define UNI_LOAD_FAILED      -495  /* NWLoadRuleTable failed, don't know why */
  53. #define UNI_HANDLE_BAD       -496  /* Rule table handle was bad */
  54. #define UNI_HANDLE_MISMATCH  -497  /* Rule table handle doesn't match operation*/
  55. #define UNI_RULES_CORRUPT    -498  /* Rule table is corrupt */
  56. #define UNI_NO_DEFAULT       -499  /* No default rule and no 'No map' character*/
  57. #define UNI_INSUFFICIENT_BUFFER -500
  58. #define UNI_OPEN_FAILED      -501  /* Open failed in NWLoadRuleTable */
  59. #define UNI_NO_LOAD_DIR      -502  /* Load directory could not be determined */
  60. #define UNI_BAD_FILE_HANDLE  -503  /* File handle was bad */
  61. #define UNI_READ_FAILED      -504  /* File read of rule table failed */
  62.  
  63.  
  64. /****************************************************************************/
  65. /*
  66.   Functions in Unicode.Lib that have no counterpart in string.h
  67. */
  68.  
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif
  72.  
  73. /*
  74.   Memory models with near returns require different libc calls
  75.      NWInitUnicodeTables()
  76.      NWFreeUnicodeTables()
  77.      NWLoadRuleTable()
  78.      NWUnloadRuleTable()
  79.   MSC uses M_I86TM, M_I86SM and M_I86CM for tiny, small and compact.
  80.   Borland, Zortech and Watcom all use __TINY__ and __SMALL__ __COMPACT__.
  81. */
  82.  
  83. #if (defined(NWDOS) && \
  84.       (defined(M_I86SM) || defined(M_I86TM) || defined(M_I86CM) || \
  85.       defined(__SMALL__) || defined(__TINY__) || defined(__COMPACT__)))
  86.  
  87. #define NWInitUnicodeTables     NWNInitUnicodeTables
  88. N_EXTERN_LIBRARY(nint)
  89. NWNInitUnicodeTables(nint countryCode, nint codePage);
  90.  
  91. #define NWFreeUnicodeTables     NWNFreeUnicodeTables
  92. N_EXTERN_LIBRARY(nint)
  93. NWNFreeUnicodeTables(void);
  94.  
  95. #define NWLoadRuleTable         NWNLoadRuleTable
  96. N_EXTERN_LIBRARY(nint)
  97. NWNLoadRuleTable(                   /* Load a rule table                   */
  98.    char     N_FAR *ruleTableName,   /* Name of the rule table              */
  99.    pnptr               ruleHandle); /* Where to put the rule table handle  */
  100.  
  101. #define NWUnloadRuleTable       NWNUnloadRuleTable
  102. N_EXTERN_LIBRARY(nint)
  103. NWNUnloadRuleTable(                 /* Unload a rule table                 */
  104.    nptr            ruleHandle);     /* Rule table handle                   */
  105.  
  106. #else  /* small model */
  107.  
  108. N_EXTERN_LIBRARY(nint)
  109. NWInitUnicodeTables(nint countryCode, nint codePage);
  110.  
  111. N_EXTERN_LIBRARY(nint)
  112. NWFreeUnicodeTables(void);
  113.  
  114. N_EXTERN_LIBRARY(nint)
  115. NWLoadRuleTable(                    /* Load a rule table                   */
  116.    char     N_FAR *ruleTableName,   /* Name of the rule table              */
  117.    pnptr               ruleHandle); /* Where to put the rule table handle  */
  118.  
  119. N_EXTERN_LIBRARY(nint)
  120. NWUnloadRuleTable(                  /* Unload a rule table                 */
  121.    nptr        ruleHandle);         /* Rule table handle                   */
  122. #endif   /* small model */
  123.  
  124.  
  125. #if defined( N_PLAT_NLM )
  126.  
  127. N_EXTERN_LIBRARY(nint)
  128. NWLocalToUnicode(                   /* Convert local to Unicode            */
  129.    nptr            ruleHandle,      /* Rule table handle                   */
  130.    punicode        dest,            /* Buffer for resulting Unicode        */
  131.    nuint32         maxLen,          /* Size of results buffer              */
  132.    nptr            src,             /* Buffer with source local code       */
  133.    unicode         noMap,           /* No map character                    */
  134.    pnuint          len,             /* Number of unicode chars in output   */
  135.    nuint32   allowNoMapFlag);  /* Flag indicating default map is allowable */
  136.  
  137. N_EXTERN_LIBRARY(nint)
  138. NWUnicodeToLocal(                   /* Convert Unicode to local code       */
  139.    nptr            ruleHandle,      /* Rule table handle                   */
  140.    nptr            dest,            /* Buffer for resulting local code     */
  141.    nuint32         maxLen,          /* Size of results buffer              */
  142.    punicode        src,             /* Buffer with source Unicode          */
  143.    nuint8          noMap,           /* No Map character                    */
  144.    pnuint          len,             /* Number of bytes in output           */
  145.    nuint32   allowNoMapFlag);  /* Flag indicating default map is allowable */
  146.  
  147. #if !defined(EXCLUDE_UNICODE_NLM_COMPATIBILITY_MACROS)
  148. #define NWLocalToUnicode(P1,P2,P3,P4,P5,P6) NWLocalToUnicode(P1,P2,P3,P4,P5,P6, 1)
  149. #define NWUnicodeToLocal(P1,P2,P3,P4,P5,P6) NWUnicodeToLocal(P1,P2,P3,P4,P5,P6, 1)
  150. #endif
  151.  
  152. /* If I could make size_t be nuint32 for N_PLAT_NLM all of the functions */
  153. /* below here could be single sourced.                                   */
  154. #if 0
  155. N_EXTERN_LIBRARY(nint)
  156. NWUnicodeToCollation(               /* Convert Unicode to collation        */
  157.    nptr            ruleHandle,      /* Rule table handle                   */
  158.    punicode        dest,            /* Buffer for resulting Unicode weights*/
  159.    nuint32         maxLen,          /* Size of results buffer              */
  160.    punicode        src,             /* Buffer with source Unicode          */
  161.    unicode         noMap,           /* No map character                    */
  162.    pnuint32        len);            /* Number of unicode chars in output   */
  163.  
  164. N_EXTERN_LIBRARY(nint)
  165. NWUnicodeCompare(                   /* Compare two unicode characters      */
  166.    nptr           ruleHandle,       /* Rule table handle                   */
  167.    unicode        chr1,             /* 1st character                       */
  168.    unicode        chr2);            /* 2nd character                       */
  169.  
  170. N_EXTERN_LIBRARY(nint)
  171. NWUnicodeToMonocase(                /* Convert Unicode to collation        */
  172.    nptr            ruleHandle,      /* Rule table handle                   */
  173.    punicode        dest,            /* Buffer for resulting Unicode weights*/
  174.    nuint32         maxLen,          /* Size of results buffer              */
  175.    punicode        src,             /* Buffer with source Unicode          */
  176.    pnuint32        len);            /* Number of unicode chars in output   */
  177.  
  178. N_EXTERN_LIBRARY(nint)
  179. NWGetUnicodeToLocalHandle(pnptr handle );
  180.  
  181. N_EXTERN_LIBRARY(nint)
  182. NWGetLocalToUnicodeHandle(pnptr handle);
  183.  
  184. N_EXTERN_LIBRARY(nint)
  185. NWGetMonocaseHandle(pnptr handle);
  186.  
  187. #endif
  188. #else   /*  not N_PLAT_NLM  */
  189.  
  190. N_EXTERN_LIBRARY(nint)
  191. NWLocalToUnicode(                   /* Convert local to Unicode            */
  192.    nptr           ruleHandle,       /* Rule table handle                   */
  193.    punicode       dest,             /* Buffer for resulting Unicode        */
  194.    size_t         maxLen,           /* Size of results buffer              */
  195. #ifndef MACINTOSH
  196.    unsigned char     N_FAR *src,    /* Buffer with source local code       */
  197. #else
  198.    void           *src,
  199. #endif
  200.    unicode        noMap,            /* No map character                    */
  201.    size_t   N_FAR *len);            /* Number of unicode chars in output   */
  202.  
  203. N_EXTERN_LIBRARY(nint)
  204. NWUnicodeToLocal(                   /* Convert Unicode to local code       */
  205.    nptr           ruleHandle,       /* Rule table handle                   */
  206. #ifndef MACINTOSH
  207.    unsigned char     N_FAR *dest,   /* Buffer for resulting local code     */
  208. #else
  209.    nptr           dest,
  210. #endif
  211.    size_t         maxLen,           /* Size of results buffer              */
  212.    punicode       src,              /* Buffer with source Unicode          */
  213.    unsigned char  noMap,            /* No Map character                    */
  214.    size_t   N_FAR *len);            /* Number of bytes in output           */
  215.  
  216. #endif    /* not N_PLAT_NLM */
  217.  
  218. N_EXTERN_LIBRARY(nint)
  219. NWUnicodeToCollation(               /* Convert Unicode to collation        */
  220.    nptr           ruleHandle,       /* Rule table handle                   */
  221.    punicode       dest,             /* Buffer for resulting Unicode weights*/
  222.    size_t         maxLen,           /* Size of results buffer              */
  223.    punicode       src,              /* Buffer with source Unicode          */
  224.    unicode        noMap,            /* No map character                    */
  225.    size_t   N_FAR *len);            /* Number of unicode chars in output   */
  226.  
  227. N_EXTERN_LIBRARY(nint)
  228. NWUnicodeCompare(                   /* Compare two unicode characters      */
  229.    nptr           ruleHandle,       /* Rule table handle                   */
  230.    unicode        chr1,             /* 1st character                       */
  231.    unicode        chr2);            /* 2nd character                       */
  232.  
  233. N_EXTERN_LIBRARY(nint)
  234. NWUnicodeToMonocase(                /* Convert Unicode to collation        */
  235.    nptr           ruleHandle,       /* Rule table handle                   */
  236.    punicode       dest,             /* Buffer for resulting Unicode weights*/
  237.    size_t         maxLen,           /* Size of results buffer              */
  238.    punicode       src,              /* Buffer with source Unicode          */
  239.    size_t   N_FAR *len);            /* Number of unicode chars in output   */
  240.  
  241. N_EXTERN_LIBRARY(nint)
  242. NWGetUnicodeToLocalHandle(pnptr handle);
  243.  
  244. N_EXTERN_LIBRARY(nint)
  245. NWGetLocalToUnicodeHandle(pnptr handle);
  246.  
  247. N_EXTERN_LIBRARY(nint)
  248. NWGetMonocaseHandle(pnptr handle);
  249.  
  250. N_EXTERN_LIBRARY(nint)
  251. NWGetCollationHandle(pnptr handle);
  252.  
  253.  
  254. /****************************************************************************/
  255. /*
  256.     Functions in Unicode.Lib that work like those in string.h
  257. */
  258. punicode N_API unicat(    /* Corresponds to strcat               */
  259.    punicode s1,           /* Original string                     */
  260.    punicode s2);          /* String to be appended               */
  261.  
  262. punicode N_API unichr(    /* Corresponds to strchr               */
  263.    punicode s,            /* String to be scanned                */
  264.    unicode  c);           /* Character to be found               */
  265.  
  266. punicode N_API unicpy(    /* Corresponds to strcpy               */
  267.    punicode s1,           /* Destination string                  */
  268.    punicode s2);          /* Source string                       */
  269.  
  270. size_t N_API unicspn(     /* Corresponds to strcspn              */
  271.    punicode s1,           /* String to be scanned                */
  272.    punicode s2);          /* Character set                       */
  273.  
  274. size_t N_API unilen(      /* Corresponds to strlen               */
  275.    punicode s);           /* String to determine length of       */
  276.  
  277. punicode N_API unincat(   /* Corresponds to strncat              */
  278.    punicode s1,           /* Original string                     */
  279.    punicode s2,           /* String to be appended               */
  280.    size_t   n);           /* Maximum characters to be appended   */
  281.  
  282. punicode N_API unincpy(   /* Corresponds to strncpy              */
  283.    punicode s1,           /* Destination string                  */
  284.    punicode s2,           /* Source string                       */
  285.    size_t   n);           /* Maximum length                      */
  286.  
  287. punicode N_API uninset(   /* Corresponds to strnset              */
  288.    punicode s,            /* String to be modified               */
  289.    unicode  c,            /* Fill character                      */
  290.    size_t   n);           /* Maximum length                      */
  291.  
  292. punicode N_API unipbrk(   /* Corresponds to strpbrk              */
  293.    punicode s1,           /* String to be scanned                */
  294.    punicode s2);          /* Character set                       */
  295.  
  296. punicode N_API unipcpy(   /* Corresponds to strpcpy              */
  297.    punicode s1,           /* Destination string                  */
  298.    punicode s2);          /* Source string                       */
  299.  
  300. punicode N_API unirchr(   /* Corresponds to strrchr              */
  301.    punicode s,            /* String to be scanned                */
  302.    unicode  c);           /* Character to be found               */
  303.  
  304. punicode N_API unirev(    /* Corresponds to strrev               */
  305.    punicode s);           /* String to be reversed               */
  306.  
  307. punicode N_API uniset(    /* Corresponds to strset               */
  308.    punicode s,            /* String to modified                  */
  309.    unicode  c);           /* Fill character                      */
  310.  
  311. size_t N_API unispn(      /* Corresponds to strspn               */
  312.    punicode s1,           /* String to be tested                 */
  313.    punicode s2);          /* Character set                       */
  314.  
  315. punicode N_API unistr(    /* Corresponds to strstr               */
  316.    punicode s1,           /* String to be scanned                */
  317.    punicode s2);          /* String to be located                */
  318.  
  319. punicode N_API unitok(    /* Corresponds to strtok               */
  320.    punicode s1,           /* String to be parsed                 */
  321.    punicode s2);          /* Delimiter values                    */
  322.  
  323. nint N_API uniicmp(       /* Corresponds to stricmp              */
  324.    punicode s1,           /* 1st string to be compared           */
  325.    punicode s2);          /* 2nd string to be compared           */
  326.  
  327. nint N_API uninicmp(      /* Corresponds to strnicmp             */
  328.    punicode s1,           /* 1st string to be compared           */
  329.    punicode s2,           /* 2nd string to be compared           */
  330.    size_t   n);           /* Maximum length                      */
  331.  
  332. #ifndef MACINTOSH
  333. size_t N_API unisize(     /* Corresponds to sizeof               */
  334.    punicode s);
  335. #else
  336. #  define unisize(uS)  ((unilen((unicode *) uS) + 1) * sizeof(unicode))
  337. #endif
  338.  
  339. #ifdef __cplusplus
  340. }
  341. #endif
  342.  
  343. #endif
  344.