359 lines
11 KiB
C
Executable File
359 lines
11 KiB
C
Executable File
#ifndef h_NLS
|
|
#define h_NLS
|
|
/******************************************************************************
|
|
*
|
|
* Top level include file for National Language Support
|
|
*
|
|
* Module %M% Version %I% Date %H%
|
|
*
|
|
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
|
|
* This is unpublished proprietary source code of Ardent Software, Inc.
|
|
* The copyright notice above does not evidence any actual or intented
|
|
* publication of such source code.
|
|
*
|
|
*******************************************************************************
|
|
*
|
|
* Maintenence log - insert most recent change descriptions at top
|
|
*
|
|
* Date.... GTAR# WHO Description.........................................
|
|
* 01/11/99 24284 RJE/PEJ Correct IsDBCSMAP() and IsWIDEMAP() macros
|
|
* 01/11/99 24284 RJE/PEJ Added support for SHIFT maps; change version
|
|
* 10/14/98 23801 SAP Change copyrights.
|
|
* 06/06/97 20327 MJC Fix comment
|
|
* 04/04/97 20327 MJC Fix prototype for NLSgetsrvmap; fix NLSE_MAP_NOT_FOUND
|
|
* 04/04/97 20327 MJC Added NLSNUMMARKCHARS
|
|
* 02/28/97 20172 NDP Added definition for NLSutf2uc().
|
|
* 04/19/96 17706 PEJ Added locoffset for locale support
|
|
* 04/15/96 18285 EAP Added NLStSTRmap(),NLSgetsrvmap() & NLSsetsrvmap()
|
|
* 04/10/96 18242 GMM Fixes to code cleanup changes to build on NT
|
|
* 04/08/96 18242 DTM Code Cleanup, Phase I
|
|
* 03/21/96 17935 JC Added declaration of NLSset/getgcimap().
|
|
* 03/15/96 17054 AGM Fix MSWIN compiler warnings
|
|
* 03/07/96 18118 EAP Addition of server map globals.
|
|
* 12/21/95 17667 JC Addition of CODEUNI map (swapped UNICODE)
|
|
* 09/19/95 17357 EAP Added DBCSMAP and IsDBCSmap macros
|
|
* 09/19/95 17347 EAP Added NLSopenelse flag
|
|
* 06/14/95 16358 AGM Rename isleadbyte to avoid WINNT system clash
|
|
* 05/26/95 15740 JC Added isleadbyte() macro.
|
|
* 05/25/95 15740 JC Added UTFcharwidth macro.
|
|
* 05/24/95 15741 EAP Added NLSseqmap extern
|
|
* 04/27/95 15736 EAP Added remaining UNICODE mark values
|
|
* 04/19/95 15736 EAP Added UTFcompchr macro
|
|
* 04/03/95 16273 AGM Rename S_OK to avoid conflict on Windows-NT
|
|
* 03/16/95 16150 EAP Added UTFcopychr and UTFnextchr macros.
|
|
* 02/27/95 15741 EAP Added NLSosmap
|
|
* 01/25/95 15736 EAP Added type to CMAP and NLSmapsize macro
|
|
* 01/19/95 15739 JSW Added NLSgconv and NLSptrim
|
|
* 12/15/94 15736 EAP Made NLSreadelse and NLSwriteelse int
|
|
*
|
|
*****************************************************************************/
|
|
|
|
#include "typedef.h"
|
|
|
|
#define MAX_CHARWIDTH (NLSon ? 3 : 1)
|
|
|
|
#define NLSisleadbyte(x) (NLSon ? (((x)&0xc0)!=0x80) : 1)
|
|
|
|
#define UTFcharwidth(p) (((*(p)&0xf0)==0xe0)?3:(((*(p)&0xe0)==0xc0)?2:1))
|
|
|
|
#define UTFcopychr(to_p, from_p) { \
|
|
switch ((*from_p)&0xF0) { \
|
|
case 0xE0: *to_p++ = *from_p++; \
|
|
case 0xD0: \
|
|
case 0xC0: *to_p++ = *from_p++; \
|
|
default: *to_p++ = *from_p++; }}
|
|
|
|
#define UTFnextchr(cp) { \
|
|
switch ((*cp)&0xF0) { \
|
|
case 0xE0: cp++; \
|
|
case 0xD0: \
|
|
case 0xC0: cp++; \
|
|
default: cp++; }}
|
|
|
|
#define UTFcompchr(cp1,cp2,match) { \
|
|
uchar *p1 = cp1,*p2 = cp2; \
|
|
match = 1; \
|
|
switch ((*p1)&0xF0) { \
|
|
case 0xE0: match &= (*p1++ == *p2++); \
|
|
case 0xD0: \
|
|
case 0xC0: match &= (*p1++ == *p2++); \
|
|
default: match &= (*p1++ == *p2++); \
|
|
} }
|
|
|
|
/* declare others as needed */
|
|
#define UNI_SQLNUL 0xf8f7
|
|
#define UNI_SYSDEL 0xf8f8
|
|
#define UNI_TM 0xf8fb
|
|
#define UNI_SM 0xf8fc
|
|
#define UNI_SVM 0xf8fc
|
|
#define UNI_VM 0xf8fd
|
|
#define UNI_AM 0xf8fe
|
|
#define UNI_FM 0xf8fe
|
|
#define UNI_IM 0xf8ff
|
|
|
|
#define UVNLSOFF "UVNLSOFF"
|
|
#define NLSdirmap ".uvnlsmap"
|
|
|
|
/* CMAP type for the basic structure of the Character set mapping table */
|
|
|
|
#ifndef NLSMAPNAMELEN
|
|
#define NLSMAPNAMELEN 32
|
|
#endif
|
|
|
|
/* Number of mark characters returned by NLSgetsrvmap and NLSsetsrvmap */
|
|
/* They are: SQLNUL,TM,SVM,VM,AM,IM */
|
|
|
|
#ifndef NLSNUMMARKCHARS
|
|
#define NLSNUMMARKCHARS 6
|
|
#endif
|
|
|
|
/* Special Map types
|
|
*
|
|
* UTF8MAP indicates that byte sequences for which no mapping is defined
|
|
* but which are valid UTF8 should be passed through unchanged. Byte
|
|
* sequences which are not valid UTF8 will be replaced with "unknown"
|
|
* characters.
|
|
*
|
|
* UNICODEMAP indicates that, on input, two byte sequences for which no mapping
|
|
* is defined should be treated as UNICODE and converted to UTF8. On output,
|
|
* byte sequences for which no mapping is defined but which are valid UTF8
|
|
* should be converted to UNICODE.
|
|
*
|
|
* CODEUNIMAP is the same as UNICODEMAP but with byte swapping, i.e. for i386 NT
|
|
*/
|
|
|
|
#define NORMALMAP 0
|
|
|
|
#define UTF8MAP 1
|
|
|
|
#define UNICODEMAP 2
|
|
|
|
#define CODEUNIMAP 4
|
|
|
|
#define SHIFTMAP 128
|
|
#define DBCSMAP 256
|
|
#define WIDEMAP 512
|
|
|
|
typedef struct cmap_3 {
|
|
int size;
|
|
int type;
|
|
struct {
|
|
int len;
|
|
char text[8];
|
|
} unknown;
|
|
struct {
|
|
char ext[ 4 ] ; /* External character sequence */
|
|
int len ; /* Map name length */
|
|
char map[ NLSMAPNAMELEN ] ; /* Map name */
|
|
int offset ; /* Shared memory offset (set in shared memory copy only)*/
|
|
} shift[ 2 ] ;
|
|
unsigned short btab[256];
|
|
} CMAP;
|
|
|
|
typedef struct cmap_2 { /* Earlier version, retained for backwards compatibility */
|
|
int size;
|
|
int type;
|
|
struct {
|
|
int len;
|
|
char text[8];
|
|
} unknown;
|
|
unsigned short btab[256];
|
|
} CMAP_2 ;
|
|
|
|
#define IsSHIFTMAP(p) ((((CMAP *)(p))->type) & SHIFTMAP)
|
|
#define IsDBCSMAP(p) ((((CMAP *)(p))->type) & DBCSMAP)
|
|
#define IsWIDEMAP(p) ((((CMAP *)(p))->type) & WIDEMAP)
|
|
|
|
#define MapType(p) ((((CMAP *)(p))->type) & \
|
|
(NORMALMAP | UTF8MAP | UNICODEMAP | CODEUNIMAP))
|
|
|
|
/*
|
|
* Macro to calculate byte size of CMAP structure
|
|
*/
|
|
#define NLSmapsize(map) (sizeof(CMAP) + \
|
|
(((CMAP *)(map))->size-256) * sizeof(unsigned short))
|
|
|
|
/* Marker bits in lookup table, (used to identify special entries) */
|
|
|
|
#define SHIFTBIT 0x80
|
|
|
|
typedef struct {
|
|
unsigned char byteorder[4];
|
|
unsigned int version;
|
|
struct {
|
|
int len;
|
|
unsigned char text[NLSMAPNAMELEN];
|
|
} name;
|
|
unsigned int ipmapsize;
|
|
unsigned int opmapsize;
|
|
unsigned int checksum;
|
|
|
|
} CMAPheader;
|
|
|
|
/*
|
|
Versions of UniVerse supporting shifting maps can load both old (type 2) and new (type 3) map images
|
|
from disc into shared memory
|
|
|
|
Maps in shared memory always use the new (type 3) layout, type 2 images on disc are converted during
|
|
the shared memory load process
|
|
*/
|
|
|
|
#define CMAP_VERSION_3 3 /* Shift map format */
|
|
#define CMAP_VERSION_2 2 /* Earlier format */
|
|
|
|
#define MAX_MAPS 256
|
|
|
|
/*
|
|
* Header for shared catalog space
|
|
*/
|
|
#define SHMAPHDR struct shmaphdr
|
|
struct shmaphdr
|
|
{
|
|
int state; /* current state of shared memory */
|
|
int mapcnt; /* current number of maps loaded */
|
|
int mapoffset[MAX_MAPS]; /* offset of header for first map */
|
|
int locoffset ; /* offset of first locale descriptor */
|
|
};
|
|
|
|
/* values for shmaphdr state variable */
|
|
#define S_DETACHED 0x1 /* segment has been detached */
|
|
#define S_LOADING 0x2 /* segment is new and being loaded */
|
|
#define S_OK_FOR_USE 0x4 /* segment is okay for use */
|
|
|
|
|
|
/* declare all the routine calls */
|
|
|
|
EXTERN int NLSaddmap(); /* add character to a map */
|
|
EXTERN STRING NLSSTRmap(); /* map a STRING */
|
|
EXTERN uchar *NLStstrmap(); /* temporarily map a null terminated string */
|
|
EXTERN STRING NLStSTRmap(); /* temporarily map a STRING */
|
|
EXTERN STRING NLSgetc(); /* get and map character from input stream */
|
|
EXTERN int UTFcompose(); /* convert UV-UTF hex digits to UV-UTF char */
|
|
EXTERN int NLSdumpmap(); /* print map structure on stderr */
|
|
EXTERN int NLSSTRlen(); /* character len of UV-UTF string */
|
|
EXTERN int NLSDISlen(); /* Display length of UV-UTF string */
|
|
EXTERN int NLSsavemap(); /* save maps */
|
|
EXTERN int NLSloadmap(); /* load maps to shared memory */
|
|
EXTERN int NLSfindmap(); /* locate map by name */
|
|
EXTERN int NLSfilemap(); /* Validate file map */
|
|
EXTERN uchar *NLSSTRposf(); /* position forwards in UV-UTF string */
|
|
EXTERN uchar *NLSSTRposb(); /* position backwards in UV-UTF string */
|
|
EXTERN int NLSsindex(); /* non-overlappinp index in UV-UTF string */
|
|
EXTERN int NLSpsindex(); /* overlapping index in UV-UTF string */
|
|
EXTERN STRING NLSfield(); /* UV-UTF field, group */
|
|
EXTERN STRING NLSfieldstore(); /* UV-UTF fieldstore */
|
|
EXTERN STRING NLSgroupstore(); /* UV-UTF groupstore */
|
|
EXTERN STRING NLSgconv(); /* UV-UTF iconv group extraction */
|
|
EXTERN STRING NLSptrim(); /* UV-UTF trim */
|
|
EXTERN STRING NLSgetseqmap(); /* Retreive NLSseqmap setting */
|
|
EXTERN int NLSsetseqmap(); /* Set NLSseqmap */
|
|
EXTERN STRING NLSgetgcimap(); /* Retreive NLSgcimap setting */
|
|
EXTERN int NLSsetgcimap(); /* Set NLSgcimap */
|
|
EXTERN int NLSuc2utf(); /* Converts Unicode value to UV-UTF string */
|
|
EXTERN int NLSutf2uc(); /* Converts UV-UTF string to Unicode value */
|
|
EXTERN int NLSgetsrvmap(); /* Retreive NLSsrvmap setting */
|
|
EXTERN int NLSsetsrvmap(); /* Set NLSsrvmap */
|
|
|
|
/* Error codes returned by NLSsetsrvmap() and NLSgetsrvmap() */
|
|
|
|
#define NLSE_NLS_NOT_ENABLED -1
|
|
#define NLSE_MAP_NOT_FOUND -2
|
|
|
|
/* now externs to access all the config parameters */
|
|
|
|
|
|
EXTERN int NLSon; /* UNICODE flag on or off */
|
|
|
|
/* default map for hash file */
|
|
|
|
EXTERN uchar *NLSdeffilemap;
|
|
|
|
/* default map for type 1/19 files */
|
|
|
|
EXTERN uchar *NLSdefdirmap;
|
|
|
|
/* map for new hash files created */
|
|
|
|
EXTERN uchar *NLSnewfilemap;
|
|
|
|
/* map for new type 1/19 files */
|
|
|
|
EXTERN uchar *NLSnewdirmap;
|
|
|
|
/* failure to map on read takes else (except when overriden by file) */
|
|
|
|
EXTERN int NLSreadelse;
|
|
|
|
/* failure to map on write takes else (except when overriden by file) */
|
|
|
|
EXTERN int NLSwriteelse;
|
|
|
|
/* failure to find map on open takes else */
|
|
|
|
EXTERN int NLSopenelse;
|
|
|
|
/* hex value of char not in 8 bit map for hash files */
|
|
|
|
EXTERN uchar *NLSdefptrmap;
|
|
|
|
/* map of terminal channel with no map */
|
|
|
|
EXTERN uchar *NLSdeftermmap;
|
|
|
|
/* map of non terminal in &DEVICES& with no map */
|
|
|
|
EXTERN uchar *NLSdefdevmap;
|
|
|
|
/* map to gci routine with no map */
|
|
|
|
EXTERN uchar *NLSdefgcimap;
|
|
|
|
/* default map for client/server products */
|
|
|
|
EXTERN uchar *NLSdefsrvmap;
|
|
|
|
/* map to sequential i/o when no map can be determined */
|
|
|
|
EXTERN uchar *NLSdefseqmap;
|
|
|
|
/* map for all OS file system names */
|
|
|
|
EXTERN uchar *NLSosmap;
|
|
|
|
/* NLS Locale Mode */
|
|
|
|
EXTERN int NLSlcmode;
|
|
|
|
/* Default user locale */
|
|
|
|
EXTERN uchar *NLSdefuserlc;
|
|
|
|
/* Default server locale */
|
|
|
|
EXTERN uchar *NLSdefsrvlc;
|
|
|
|
/* map used by OPENSEQ pathname and SEQpath() and set by SET.SEQ.MAP */
|
|
|
|
EXTERN uchar *NLSseqmap;
|
|
|
|
/* mapname used by client/server products and set by NLSsetsrvmap(),
|
|
initially NLSDEFSRVMAP */
|
|
|
|
EXTERN uchar *NLSsrvmap;
|
|
|
|
/*
|
|
* global input and output map pointers for NLSosmap which are always required
|
|
* for OS file and pathnames. These are setup in NLSinit()
|
|
*/
|
|
EXTERN CMAP *NLSos_ipmap;
|
|
EXTERN CMAP *NLSos_opmap;
|
|
|
|
/*
|
|
* global input and output map pointers for NLSsrvmap which are used by UVRPC
|
|
* argument pack/unpack functions. These are setup in NLSinit()/NLSsetsrvmap().
|
|
*/
|
|
EXTERN CMAP *NLSsrv_ipmap;
|
|
EXTERN CMAP *NLSsrv_opmap;
|
|
|
|
#endif
|