mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
DtHelp: use system locales.
This commit is contained in:
parent
3c67bd0cb1
commit
f3965ed394
11 changed files with 117 additions and 314 deletions
|
@ -1324,21 +1324,51 @@ char *
|
|||
_DtHelpCeGetCcdfVolLocale (
|
||||
_DtHelpVolume vol)
|
||||
{
|
||||
char *locale = NULL;
|
||||
char *charSet;
|
||||
char *locale, *ptr, *resStr;
|
||||
char *mResStr = NULL;
|
||||
char *mLang = NULL;
|
||||
char *lang = "C";
|
||||
char *defLocale = "C.UTF-8";
|
||||
CcdfVolumePtr ccdfVol = GetCcdfVolumePtr(vol);
|
||||
|
||||
errno = 0;
|
||||
locale = GetResourceString(ccdfVol->volDb, NULL, "CharSet", "charSet");
|
||||
if (_DtHelpCeStrchr(locale, ".", 1, &charSet) != 0)
|
||||
{
|
||||
charSet = locale;
|
||||
_DtHelpCeXlateOpToStdLocale(DtLCX_OPER_CCDF,charSet,&locale,NULL,NULL);
|
||||
/* charset is owned by the volume Xrm database; don't free */
|
||||
}
|
||||
else if (NULL != locale)
|
||||
locale = strdup(locale);
|
||||
|
||||
/* resStr is owned by the volume Xrm database; don't free */
|
||||
resStr = GetResourceString(ccdfVol->volDb, NULL, "CharSet", "charSet");
|
||||
|
||||
if (resStr == NULL || *resStr == '\0')
|
||||
{
|
||||
locale = strdup(defLocale);
|
||||
goto done;
|
||||
}
|
||||
|
||||
mResStr = strdup(resStr);
|
||||
|
||||
if (_DtHelpCeStrchr(mResStr, ".", 1, &ptr) == 0)
|
||||
{
|
||||
*ptr++ = '\0';
|
||||
|
||||
if (mResStr == NULL || *mResStr == '\0' || ptr == NULL || *ptr == '\0')
|
||||
locale = strdup(defLocale);
|
||||
else
|
||||
locale = strdup(resStr);
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
mLang = _DtHelpGetLocale();
|
||||
|
||||
if (_DtHelpCeStrrchr(mLang, ".", 1, &ptr) == 0)
|
||||
{
|
||||
*ptr = '\0';
|
||||
if (mLang != NULL && *mLang != '\0') lang = mLang;
|
||||
}
|
||||
|
||||
asprintf(&locale, "%s.%s", lang, resStr);
|
||||
|
||||
done:
|
||||
free(mLang);
|
||||
free(mResStr);
|
||||
return locale;
|
||||
|
||||
} /* End _DtHelpCeGetCcdfVolLocale */
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
#include "FormatSDLI.h"
|
||||
#include "StringFuncsI.h"
|
||||
#include "UtilSDLI.h"
|
||||
#include "HelpXlate.h"
|
||||
|
||||
#ifdef NLS16
|
||||
#endif
|
||||
|
@ -89,7 +90,7 @@ static int ProcessEntry (
|
|||
/******** End Private Function Declarations ********/
|
||||
|
||||
/******** Private Variable Declarations ********/
|
||||
static const char *IsoString = "ISO-8859-1";
|
||||
static const char *IsoString = "UTF-8";
|
||||
static const CESDLVolume DefaultSdlVolume =
|
||||
{
|
||||
NULL, /* _DtCvSegment *sdl_info; */
|
||||
|
|
|
@ -475,9 +475,9 @@ _DtHelpFormatAsciiFile(
|
|||
{
|
||||
_DtHelpCeCopyDefFontAttrList (&fontAttrs);
|
||||
fontAttrs.spacing = _DtHelpFontSpacingMono;
|
||||
_DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,
|
||||
setlocale(LC_CTYPE,NULL), NULL,
|
||||
&(fontAttrs.language), &(fontAttrs.char_set));
|
||||
|
||||
_DtHelpCeGetLcCtype(NULL, &(fontAttrs.language),
|
||||
&(fontAttrs.char_set));
|
||||
|
||||
/*
|
||||
* fill out the ui information
|
||||
|
@ -494,8 +494,7 @@ _DtHelpFormatAsciiFile(
|
|||
/*
|
||||
* get the formatting structure.
|
||||
*/
|
||||
varHandle = __DtHelpCeSetUpVars(fontAttrs.language,
|
||||
fontAttrs.char_set, &myUiInfo);
|
||||
varHandle = __DtHelpCeSetUpVars(&myUiInfo);
|
||||
if (varHandle == NULL)
|
||||
{
|
||||
free(fontAttrs.language);
|
||||
|
@ -585,12 +584,8 @@ _DtHelpFormatAsciiString(
|
|||
*ret_handle = NULL;
|
||||
|
||||
_DtHelpCeCopyDefFontAttrList (&fontAttrs);
|
||||
_DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,setlocale(LC_CTYPE,NULL),
|
||||
NULL, &(fontAttrs.language),
|
||||
&(fontAttrs.char_set));
|
||||
|
||||
varHandle = __DtHelpCeSetUpVars(fontAttrs.language, fontAttrs.char_set,
|
||||
&myUiInfo);
|
||||
_DtHelpCeGetLcCtype(NULL, &(fontAttrs.language), &(fontAttrs.char_set));
|
||||
varHandle = __DtHelpCeSetUpVars(&myUiInfo);
|
||||
if (varHandle == NULL)
|
||||
{
|
||||
free(fontAttrs.language);
|
||||
|
@ -678,12 +673,8 @@ _DtHelpFormatAsciiStringDynamic(
|
|||
*ret_handle = NULL;
|
||||
|
||||
_DtHelpCeCopyDefFontAttrList (&fontAttrs);
|
||||
_DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,setlocale(LC_CTYPE,NULL),
|
||||
NULL, &(fontAttrs.language),
|
||||
&(fontAttrs.char_set));
|
||||
|
||||
varHandle = __DtHelpCeSetUpVars(fontAttrs.language, fontAttrs.char_set,
|
||||
&myUiInfo);
|
||||
_DtHelpCeGetLcCtype(NULL, &(fontAttrs.language), &(fontAttrs.char_set));
|
||||
varHandle = __DtHelpCeSetUpVars(&myUiInfo);
|
||||
if (varHandle == NULL)
|
||||
{
|
||||
free(fontAttrs.language);
|
||||
|
|
|
@ -318,7 +318,6 @@ static int SegmentSave(
|
|||
*****************************************************************************/
|
||||
static const char *Specials = "<\n\\ ";
|
||||
static const char *SpaceString = " ";
|
||||
static const char *CString = "C";
|
||||
static const char *Period = ".";
|
||||
static const char *Slash = "/";
|
||||
|
||||
|
@ -472,6 +471,7 @@ GetMbLen (
|
|||
char *ptr;
|
||||
char *langPart = NULL;
|
||||
char *codePart = NULL;
|
||||
char *mLang = NULL;
|
||||
|
||||
/*
|
||||
* strip spaces
|
||||
|
@ -494,34 +494,32 @@ GetMbLen (
|
|||
*ptr++ = '\0';
|
||||
langPart = strdup(font_str);
|
||||
codePart = strdup(ptr);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* old CCDF volume
|
||||
*/
|
||||
else
|
||||
{
|
||||
_DtHelpCeXlateOpToStdLocale(DtLCX_OPER_CCDF, font_str,
|
||||
NULL, &langPart, &codePart);
|
||||
/*
|
||||
* if the language is not specified for the code set,
|
||||
* get the environment's.
|
||||
*/
|
||||
if (strcmp(langPart, "?") == 0)
|
||||
{
|
||||
free(langPart);
|
||||
if (font_str == NULL || *font_str == '\0') codePart = strdup("UTF-8");
|
||||
else codePart = strdup(font_str);
|
||||
|
||||
langPart = _DtHelpGetLocale();
|
||||
if (langPart == NULL || *langPart == '\0')
|
||||
langPart = strdup((char *) CString);
|
||||
else if (_DtHelpCeStrrchr(langPart, "_", MB_CUR_MAX, &ptr) == 0)
|
||||
*ptr = '\0';
|
||||
else if (_DtHelpCeStrrchr(langPart, Period, MB_CUR_MAX, &ptr) == 0)
|
||||
*ptr = '\0';
|
||||
mLang = _DtHelpGetLocale();
|
||||
|
||||
if (_DtHelpCeStrrchr(mLang, Period, MB_CUR_MAX, &ptr) == 0)
|
||||
{
|
||||
*ptr = '\0';
|
||||
|
||||
if (mLang != NULL && *mLang != '\0')
|
||||
{
|
||||
langPart = strdup(mLang);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
cur_vars->cur_mb_max = _DtHelpCeGetMbLen(langPart, codePart);
|
||||
langPart = strdup("C");
|
||||
|
||||
done:
|
||||
cur_vars->cur_mb_max = MB_CUR_MAX;
|
||||
|
||||
/*
|
||||
* now set the return variables
|
||||
|
@ -535,6 +533,8 @@ GetMbLen (
|
|||
*set_ptr = codePart;
|
||||
else
|
||||
free(codePart);
|
||||
|
||||
free(mLang);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -4121,7 +4121,7 @@ Format(
|
|||
|
||||
/*
|
||||
* change the character set to the returned character set
|
||||
* Assume that the charset is 'iso8859' if not specified.
|
||||
* Assume that the charset is 'UTF-8' if not specified.
|
||||
*/
|
||||
cur_vars->cur_mb_max = 1;
|
||||
if (NULL != charSet)
|
||||
|
@ -4355,7 +4355,7 @@ FormatCCDFTitle(
|
|||
|
||||
/*
|
||||
* change the character set to the returned character set
|
||||
* Assume that the charset is 'iso8859' if not specified.
|
||||
* Assume that the charset is 'UTF-8' if not specified.
|
||||
*/
|
||||
cur_vars->cur_mb_max = 1;
|
||||
if (NULL != charSet)
|
||||
|
@ -4794,7 +4794,7 @@ FormatExpandedToc(
|
|||
*
|
||||
*****************************************************************************/
|
||||
/******************************************************************************
|
||||
* Function: VarHandle *__DtHelpCeSetUpVars (char *rd_buf, grow_size)
|
||||
* Function: VarHandle *__DtHelpCeSetUpVars (_FrmtUiInfo *ui_info)
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
|
@ -4807,8 +4807,6 @@ FormatExpandedToc(
|
|||
******************************************************************************/
|
||||
VarHandle
|
||||
__DtHelpCeSetUpVars(
|
||||
char *lang,
|
||||
char *code_set,
|
||||
_FrmtUiInfo *ui_info)
|
||||
{
|
||||
FormatVariables *newVars;
|
||||
|
@ -4817,7 +4815,7 @@ __DtHelpCeSetUpVars(
|
|||
*newVars = DefVars;
|
||||
newVars->ui_info = ui_info;
|
||||
|
||||
newVars->topic_mb_max = _DtHelpCeGetMbLen(lang, code_set);
|
||||
newVars->topic_mb_max = MB_CUR_MAX;
|
||||
newVars->cur_mb_max = newVars->topic_mb_max;
|
||||
|
||||
return ((VarHandle) newVars);
|
||||
|
@ -5447,7 +5445,7 @@ _DtHelpCeGetCcdfVolTitleChunks(
|
|||
*/
|
||||
charSet = _DtHelpCeGetCcdfVolLocale(volume);
|
||||
if (charSet == NULL)
|
||||
charSet = strdup("C.ISO-8859-1");
|
||||
charSet = strdup("C.UTF-8");
|
||||
|
||||
titleStr = _DtHelpCeGetCcdfVolTitle(volume);
|
||||
if (titleStr != NULL)
|
||||
|
|
|
@ -83,8 +83,6 @@ extern int __DtHelpCeProcessString(
|
|||
int ret_on_nl,
|
||||
_DtHelpFontHints *font_attr);
|
||||
extern VarHandle __DtHelpCeSetUpVars (
|
||||
char *lang,
|
||||
char *code_set,
|
||||
_FrmtUiInfo *ui_info);
|
||||
|
||||
#endif /* _DtHelpFormatCCDFI_h */
|
||||
|
|
|
@ -840,10 +840,8 @@ _DtHelpFormatManPage(
|
|||
*/
|
||||
_DtHelpCeCopyDefFontAttrList (&fontAttr);
|
||||
fontAttr.spacing = _DtHelpFontSpacingMono;
|
||||
_DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,setlocale(LC_CTYPE,NULL),
|
||||
NULL, &(fontAttr.language), &(fontAttr.char_set));
|
||||
|
||||
myVars = __DtHelpCeSetUpVars(fontAttr.language, fontAttr.char_set, &myUiInfo);
|
||||
_DtHelpCeGetLcCtype(NULL, &(fontAttr.language), &(fontAttr.char_set));
|
||||
myVars = __DtHelpCeSetUpVars(&myUiInfo);
|
||||
if (myVars == NULL)
|
||||
{
|
||||
free(fontAttr.language);
|
||||
|
|
|
@ -1556,7 +1556,7 @@ static SDLElementAttrList SdlDocAttrList[] =
|
|||
{ SDL_ATTR_PRODVER , SdlAttrValueImplied , NULL },
|
||||
{ SDL_ATTR_LICENSE , SdlAttrValueImplied , NULL },
|
||||
{ SDL_ATTR_LANGUAGE , SdlAttrValueImplied , "C" },
|
||||
{ SDL_ATTR_CHARSET , SdlAttrValueImplied , IsoStr },
|
||||
{ SDL_ATTR_CHARSET , SdlAttrValueImplied , "UTF-8"},
|
||||
{ SDL_ATTR_AUTHOR , SdlAttrValueImplied , NULL },
|
||||
{ SDL_ATTR_VERSION , SdlAttrValueImplied , NULL },
|
||||
{ SDL_ATTR_FRST_PG , SdlAttrValueImplied , NULL },
|
||||
|
@ -4638,9 +4638,7 @@ SetUp (
|
|||
/*
|
||||
* determine mb_len should be based on lang/charset.
|
||||
*/
|
||||
frmt_struct->mb_len = _DtHelpCeGetMbLen(
|
||||
_DtHelpFontHintsLang(*(frmt_struct->my_fonts)),
|
||||
_DtHelpFontHintsCharSet(*(frmt_struct->my_fonts)));
|
||||
frmt_struct->mb_len = MB_CUR_MAX;
|
||||
frmt_struct->toss = toss;
|
||||
frmt_struct->ui_info = ui_info;
|
||||
|
||||
|
@ -5605,9 +5603,8 @@ ParseElementAttr(
|
|||
|
||||
if (SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE)
|
||||
|| SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_CHARSET))
|
||||
my_struct->mb_len = _DtHelpCeGetMbLen(
|
||||
_DtHelpFontHintsLang(*(my_struct->my_fonts)),
|
||||
_DtHelpFontHintsCharSet(*(my_struct->my_fonts)));
|
||||
my_struct->mb_len = MB_CUR_MAX;
|
||||
|
||||
/*
|
||||
* Do some specific work for containers.
|
||||
*/
|
||||
|
|
|
@ -2493,27 +2493,25 @@ static Boolean OpenVolForSearch(
|
|||
|
||||
if (curVol->gotLocale == False)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
|
||||
curVol->stdLocale = _DtHelpGetVolumeLocale(curVol->volHandle);
|
||||
/* get the op-specific locales; the strings are default values */
|
||||
_DtHelpCeXlateStdToOpLocale(DtLCX_OPER_ICONV3,curVol->stdLocale,
|
||||
"iso88591",&curVol->iconv3Codeset);
|
||||
|
||||
if (_DtHelpCeStrchr(curVol->stdLocale, ".", 1, &ptr) == 0)
|
||||
{
|
||||
++ptr;
|
||||
if (ptr == NULL || *ptr == '\0') ptr = NULL;
|
||||
}
|
||||
|
||||
curVol->iconv3Codeset = strdup(ptr ? ptr : "UTF-8");
|
||||
curVol->gotLocale = True;
|
||||
}
|
||||
openedVolume = True;
|
||||
|
||||
/* get the codeset of the application's locale, if haven't gotten it */
|
||||
if ( NULL == hw->help_dialog.srch.iconv3Codeset )
|
||||
{
|
||||
char * locale = NULL;
|
||||
_DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,
|
||||
setlocale(LC_CTYPE,NULL),&locale,NULL,NULL);
|
||||
/* get the op-specific locales; the strings are default values */
|
||||
/* impt: XlateStdToOpLocale() call requires a locale, not a codeset */
|
||||
_DtHelpCeXlateStdToOpLocale(DtLCX_OPER_ICONV3,locale,
|
||||
"iso88591",&hw->help_dialog.srch.iconv3Codeset);
|
||||
XtFree(locale);
|
||||
}
|
||||
|
||||
_DtHelpCeGetLcCtype(NULL, NULL, &(hw->help_dialog.srch.iconv3Codeset));
|
||||
|
||||
/** only saves or changes the locale if necessary **/
|
||||
/* create an iconv3 context to convert codeset of */
|
||||
/* the volume to the codeset of the application */
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
$FILEBEG$: HelpXlate.c
|
||||
$PROJECT$: Cde 1.0
|
||||
$COMPONENT$: DtXlate service
|
||||
$1LINER$: Implements a translation service using tables and regex search
|
||||
$1LINER$: Implements a translation service
|
||||
$COPYRIGHT$:
|
||||
(c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
(c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
|
@ -35,227 +35,36 @@ $END$
|
|||
****************************************************************************
|
||||
************************************<+>*************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h> /* MAXPATHLEN */
|
||||
#include <time.h>
|
||||
|
||||
/* for Xrm */
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <locale.h>
|
||||
|
||||
/*=================================================================
|
||||
$SHAREDBEG$: This header appears in all appropriate DtXlate topics
|
||||
=======================================================$SKIP$======*/
|
||||
/*$INCLUDE$*/
|
||||
#include "HelpXlate.h"
|
||||
#include "Lock.h"
|
||||
/*$INCLUDE$*/
|
||||
#include "StringFuncsI.h"
|
||||
/*$END$*/
|
||||
|
||||
static char MyPlatform[_DtPLATFORM_MAX_LEN+1];
|
||||
static _DtXlateDb MyDb = NULL;
|
||||
static int ExecVer;
|
||||
static int CompVer;
|
||||
void _DtHelpCeGetLcCtype(char **locale, char **lang, char **charset) {
|
||||
char *ptr;
|
||||
char *mLang = NULL;
|
||||
char *mCharset = NULL;
|
||||
char *mLocale = setlocale(LC_CTYPE, NULL);
|
||||
|
||||
static const char *DfltStdCharset = "ISO-8859-1";
|
||||
static const char *DfltStdLang = "C";
|
||||
if (mLocale) mLocale = strdup(mLocale);
|
||||
|
||||
/*========================================================*/
|
||||
/*================== Private routines ====================*/
|
||||
/*========================================================*/
|
||||
/******************************************************************************
|
||||
* Function: static int OpenLcxDb ()
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return Value: 0: ok
|
||||
* -1: error
|
||||
*
|
||||
* errno Values:
|
||||
*
|
||||
* Purpose: Opens the Ce-private Lcx database
|
||||
*
|
||||
*****************************************************************************/
|
||||
static int
|
||||
OpenLcxDb (void)
|
||||
{
|
||||
time_t time1 = 0;
|
||||
time_t time2 = 0;
|
||||
static short MyProcess = False;
|
||||
static short MyFirst = True;
|
||||
if (_DtHelpCeStrchr(mLocale, ".", 1, &ptr) == 0) {
|
||||
*ptr++ = '\0';
|
||||
if (mLocale != NULL && *mLocale != '\0') mLang = strdup(mLocale);
|
||||
if (ptr != NULL && *ptr != '\0') mCharset = strdup(ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* wait 30 sec. until another thread or enter is done modifying the table
|
||||
*/
|
||||
while (MyProcess == True)
|
||||
{
|
||||
/* if time out, return */
|
||||
if (time(&time2) == (time_t)-1)
|
||||
return -1;
|
||||
if (lang) *lang = strdup(mLang ? mLang : "C");
|
||||
if (charset) *charset = strdup(mCharset ? mCharset : "UTF-8");
|
||||
if (locale) *locale = strdup(mLocale ? mLocale : "C.UTF-8");
|
||||
|
||||
if (time1 == 0)
|
||||
time1 = time2;
|
||||
else if (time2 - time1 >= (time_t)30)
|
||||
return -1;
|
||||
}
|
||||
|
||||
_DtHelpProcessLock();
|
||||
if (MyFirst == True)
|
||||
{
|
||||
MyProcess = True;
|
||||
if (_DtLcxOpenAllDbs(&MyDb) == 0 &&
|
||||
_DtXlateGetXlateEnv(MyDb,MyPlatform,&ExecVer,&CompVer) != 0)
|
||||
{
|
||||
_DtLcxCloseDb(&MyDb);
|
||||
MyDb = NULL;
|
||||
}
|
||||
MyFirst = False;
|
||||
MyProcess = False;
|
||||
}
|
||||
_DtHelpProcessUnlock();
|
||||
|
||||
return (MyDb == NULL ? -1 : 0 );
|
||||
free(mLang);
|
||||
free(mCharset);
|
||||
free(mLocale);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: int _DtHelpCeXlateStdToOpLocale ( char *operation, char *stdLoc
|
||||
ale,
|
||||
* char *dflt_opLocale, char **ret_opLocale
|
||||
)
|
||||
*
|
||||
* Parameters:
|
||||
* operation operation whose locale value will be retrieved
|
||||
* stdLocale standard locale value
|
||||
* dflt_opLocale operation-specific locale-value
|
||||
* This is the default value used in error case
|
||||
* ret_opLocale operation-specific locale-value placed here
|
||||
* Caller must free this string.
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* Purpose: Gets an operation-specific locale string given the standard string
|
||||
*
|
||||
*****************************************************************************/
|
||||
void
|
||||
_DtHelpCeXlateStdToOpLocale (
|
||||
char *operation,
|
||||
char *stdLocale,
|
||||
char *dflt_opLocale,
|
||||
char **ret_opLocale)
|
||||
{
|
||||
int result = OpenLcxDb();
|
||||
|
||||
_DtHelpProcessLock();
|
||||
if (result == 0)
|
||||
{
|
||||
(void) _DtLcxXlateStdToOp(MyDb, MyPlatform, CompVer,
|
||||
operation, stdLocale, NULL, NULL, NULL, ret_opLocale);
|
||||
}
|
||||
_DtHelpProcessUnlock();
|
||||
|
||||
/* if translation fails, use a default value */
|
||||
if (ret_opLocale && (result != 0 || *ret_opLocale == NULL))
|
||||
{
|
||||
if (dflt_opLocale) *ret_opLocale = strdup(dflt_opLocale);
|
||||
else if (stdLocale) *ret_opLocale = strdup(stdLocale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Function: int _DtHelpCeXlateOpToStdLocale (char *operation, char *opLocale
|
||||
,
|
||||
* char **ret_stdLocale, char **ret_stdLang, char **ret_
|
||||
stdSet)
|
||||
*
|
||||
* Parameters:
|
||||
* operation Operation associated with the locale value
|
||||
* opLocale An operation-specific locale string
|
||||
* ret_locale Returns the std locale
|
||||
* Caller must free this string.
|
||||
* ret_stdLang Returns the std language & territory string.
|
||||
* Caller must free this string.
|
||||
* ret_stdSet Returns the std code set string.
|
||||
* Caller must free this string.
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* Purpose: Gets the standard locale given an operation and its locale
|
||||
*
|
||||
*****************************************************************************/
|
||||
void
|
||||
_DtHelpCeXlateOpToStdLocale (
|
||||
char *operation,
|
||||
char *opLocale,
|
||||
char **ret_stdLocale,
|
||||
char **ret_stdLang,
|
||||
char **ret_stdSet)
|
||||
{
|
||||
int result = OpenLcxDb();
|
||||
|
||||
_DtHelpProcessLock();
|
||||
if (result == 0)
|
||||
{
|
||||
(void) _DtLcxXlateOpToStd(MyDb, MyPlatform, CompVer,
|
||||
operation,opLocale,
|
||||
ret_stdLocale, ret_stdLang, ret_stdSet, NULL);
|
||||
}
|
||||
_DtHelpProcessUnlock();
|
||||
|
||||
/* if failed, give default values */
|
||||
if (ret_stdLocale != NULL && (result != 0 || *ret_stdLocale == NULL))
|
||||
{
|
||||
*ret_stdLocale = malloc(
|
||||
strlen(DfltStdLang)+strlen(DfltStdCharset)+3);
|
||||
sprintf(*ret_stdLocale,"%s.%s",DfltStdLang,DfltStdCharset);
|
||||
}
|
||||
if (ret_stdLang != NULL && (result != 0 || *ret_stdLang == NULL))
|
||||
*ret_stdLang = strdup(DfltStdLang);
|
||||
if (ret_stdSet != NULL && (result != 0 || *ret_stdSet == NULL))
|
||||
*ret_stdSet = strdup(DfltStdCharset);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: int _DtHelpCeGetMbLen (char *lang, char *char_set)
|
||||
*
|
||||
* Parameters:
|
||||
* lang Represents the language. A NULL value
|
||||
* defaults to "C".
|
||||
* char_set Represents the character set. A NULL
|
||||
* value value defaults to "ISO-8859-1"
|
||||
*
|
||||
* Return Value: Returns the MB_CUR_MAX for the combination
|
||||
* lang.charset.
|
||||
*
|
||||
* errno Values:
|
||||
*
|
||||
* Purpose: To determine the maximum number of bytes required to display
|
||||
* a character if/when the environment is set to 'lang.charset'
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
_DtHelpCeGetMbLen (
|
||||
char *lang,
|
||||
char *char_set)
|
||||
{
|
||||
int retLen = 1;
|
||||
|
||||
if (lang == NULL)
|
||||
lang = (char *)DfltStdLang;
|
||||
|
||||
if (char_set == NULL)
|
||||
char_set = (char *)DfltStdCharset;
|
||||
|
||||
_DtHelpProcessLock();
|
||||
if (OpenLcxDb() == 0)
|
||||
{
|
||||
/* if translation is present, lang.charset are a multibyte locale */
|
||||
if (_DtLcxXlateStdToOp(MyDb, MyPlatform, CompVer, DtLCX_OPER_MULTIBYTE,
|
||||
NULL, lang, char_set, NULL, NULL) == 0)
|
||||
retLen = MB_CUR_MAX;
|
||||
}
|
||||
_DtHelpProcessUnlock();
|
||||
|
||||
return retLen;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
**
|
||||
** Project: DtXlate
|
||||
**
|
||||
** Description: DtHelp-specific table-based translation services
|
||||
** Description: DtHelp-specific translation services
|
||||
**
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
|
@ -41,25 +41,12 @@
|
|||
#ifndef _DtHELP_XLATE_I
|
||||
#define _DtHELP_XLATE_I
|
||||
|
||||
#include <Dt/LocaleXlate.h>
|
||||
#include <Dt/XlationSvc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Functions */
|
||||
void _DtHelpCeXlateOpToStdLocale(
|
||||
char *operation,
|
||||
char *opLocale,
|
||||
char **ret_locale,
|
||||
char **ret_lang,
|
||||
char **ret_set);
|
||||
void _DtHelpCeXlateStdToOpLocale(
|
||||
char *operation,
|
||||
char *stdLocale,
|
||||
char *dflt_opLocale,
|
||||
char **ret_opLocale);
|
||||
void _DtHelpCeGetLcCtype(char **locale, char **lang, char **charset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -706,8 +706,6 @@ void _DtHelpCeCompressSpace (
|
|||
* Purpose:
|
||||
* Converts string from fromCode to toCode using iconv(3)
|
||||
* It expects the codeset strings to be iconv(3) compatible.
|
||||
* Generally, compatible strings can be retrieved using
|
||||
* the _DtHelpCeXlateStdToOpLocale() call.
|
||||
*
|
||||
* Comments:
|
||||
* iconv(3) is standardized in XPG4, which is just starting
|
||||
|
@ -760,8 +758,6 @@ int _DtHelpCeIconvStr1Step(
|
|||
* Opens an iconv table/algorithm to convert string from
|
||||
* fromCode to toCode using iconv(3)
|
||||
* It expects the codeset strings to be iconv(3) compatible.
|
||||
* Generally, compatible strings can be retrieved using
|
||||
* the _DtHelpCeXlateStdToOpLocale() call.
|
||||
*
|
||||
* Comments:
|
||||
* iconv(3) is standardized in XPG4, which is just starting
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue