Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 # include "stlport_prefix.h"
29 #define CODECVT_ICONV //Define CODECVT_ICONV to use ICONV APIs for code conversion.
31 //#define _MESSAGE_CATALOG_
32 #ifdef _MESSAGE_CATALOG_
36 # ifdef _STLP_REAL_LOCALE_IMPLEMENTED
38 // here, we'll put C locale implementation for those compilers where
39 // it has to be done in C++
43 /* This is a "stub" implementation of the "c_locale.h" interface,
44 intended for operating systems where we have not yet written
45 a real implementation. A C++ library using this stub implementation
46 is still standard-conforming, since the C++ standard does not require
47 that any locales other than "C" be supported.
50 #if 0 //Madhu - 18/8/06
51 /* Framework functions */
53 struct _Locale_ctype /* { } */ ;
54 struct _Locale_numeric /* { } */;
55 struct _Locale_time /* { } */;
56 struct _Locale_collate /*{ } */;
57 struct _Locale_monetary /* { } */;
58 struct _Locale_messages /* { } */;
66 #define UNICODESTR "UCS2"
78 iconv_t in_iconvstate;
79 iconv_t out_iconvstate;
83 void BEtoLE(wchar_t* src, int size)
87 for (i = 0;i<size;i++)
88 src[i] = (src[i]>>8) | (src[i]<<8);
91 void ExtractCodeset(char* name, char* codeset)
93 char* temp = strstr(name,".");
97 while ( (*temp)&&(*temp!='=') )
102 int AddState(StateList **list, iconv_t icnvstate, mbstate_t* state, enum CONVWAY way)
104 StateList *temp = *list;
105 StateList *newnode = NULL;
108 if (temp->state == state)
115 newnode = new StateList;
118 newnode->next = NULL;
119 newnode->state = state;
120 newnode->in_iconvstate = newnode->out_iconvstate = NULL;
125 temp->in_iconvstate = icnvstate;
127 temp->out_iconvstate = icnvstate;
137 StateList *move = *list;
147 iconv_t GetState(StateList *list, mbstate_t* state, enum CONVWAY way)
151 if (list->state == state)
154 return (iconv_t)list->in_iconvstate;
156 return (iconv_t)list->out_iconvstate;
164 void DeleteAllStates(StateList *list)
168 StateList *temp =list ;
169 iconv_close(temp->in_iconvstate);
170 iconv_close(temp->out_iconvstate);
181 //Madhu - locale function definitions - START
182 //Madhu - temporarily hardcoded system default locale - 18/8/06
183 #define LOCALE_SYSTEM_DEFAULT "C"
184 #define MAX_NAME_LEN 64
185 char presentLocaleName[64]; // Stores present locale name.
189 #if defined (__GNUC__) || defined (_KCC) || defined(__ICC)
190 typedef unsigned short int _Locale_mask_t;
192 typedef unsigned int _Locale_mask_t;
195 typedef struct _Locale_ctype {
196 char name[MAX_NAME_LEN];
197 _Locale_mask_t ctable[257];
199 StateList *statelist;
202 DeleteAllStates(statelist);
209 typedef struct _Locale_numeric {
210 char name[MAX_NAME_LEN];
211 char decimal_point[4];
212 char thousands_sep[4];
216 typedef struct _Locale_time {
217 char name[MAX_NAME_LEN];
219 char *abbrev_month[12];
221 char *abbrev_dayofweek[7];
224 typedef struct _Locale_collate {
225 char name[MAX_NAME_LEN];
228 typedef struct _Locale_monetary {
229 char name[MAX_NAME_LEN];
230 char decimal_point[4];
231 char thousands_sep[4];
233 char int_curr_symbol[5]; // 3+1+1
235 char negative_sign[5];
236 char positive_sign[5];
241 typedef struct _Locale_messages {
242 char name[MAX_NAME_LEN];
247 char* __getString(char* str)
249 int len = strlen(str)+1;
250 char* temp = (char*) new char[len];
257 /* Common function to set locale information */
259 static void* Locale_Common_Create(const char* locale)
262 setlocale(LC_ALL, locale);
264 return (void*) localeconv();
270 /* Gets the system locale name */
271 static const char* Locale_common_default( char* name)
274 char* presentLocalename = NULL;
275 char* defaultLocalename = NULL;
277 //Madhu - going round to get default system locale, need to find alternative - 18/8/96
278 presentLocalename = setlocale(LC_ALL, NULL);
279 defaultLocalename = setlocale(LC_ALL, "");
280 setlocale(LC_ALL, presentLocalename);
284 strcpy(name,LOCALE_SYSTEM_DEFAULT);
286 return LOCALE_SYSTEM_DEFAULT;
291 /* Gets the present locale name */
292 static char* Locale_common_name(const void* cat, char* name)
295 char* presentLocalename = NULL;
297 presentLocalename = setlocale(LC_ALL, NULL);
298 strcpy(name,presentLocalename);
300 return presentLocalename;
302 L_ctype_t* locale = (L_ctype_t*) cat;
303 strcpy(name,locale->name);
308 static char * Locale_extract_name ( const char *cname, char *into, int category )
312 const char* strstar = "*", *strnull = "";
314 if ( cname[0] != '/' )
316 if (strcmp(cname,strnull) == 0)
317 return strcpy(into, strstar);
319 return strcpy(into, cname); /* simple locale name */
322 for ( i = 0; i <= category; i ++ ) {
323 while ( *cname != '\0' && *cname != '/' )
325 if ( *cname == '\0' )
330 if ( *cname == '\0' )
334 while ( *end != '\0' && *end != '/' )
337 strncpy ( into, cname, end - cname );
338 into [ end - cname ] = '\0';
344 _STLP_BEGIN_NAMESPACE //Madhu - moved to here
347 _Locale_mask_t Get_locale_wchar_ctype(wint_t wc, _Locale_mask_t /*mask*/)
350 _Locale_mask_t ret = 0;
352 if (iswcntrl(wc)) ret |= _Locale_CNTRL;
353 if (iswupper(wc)) ret |= _Locale_UPPER;
354 if (iswlower(wc)) ret |= _Locale_LOWER;
355 if (iswdigit(wc)) ret |= _Locale_DIGIT;
356 if (iswxdigit(wc)) ret |= _Locale_XDIGIT;
357 if (iswpunct(wc)) ret |= _Locale_PUNCT;
358 if (iswspace(wc)) ret |= _Locale_SPACE;
359 if (iswprint(wc)) ret |= _Locale_PRINT;
360 if (iswalpha(wc)) ret |= _Locale_ALPHA;
366 _Locale_mask_t Get_locale_char_ctype(unsigned char c)
369 _Locale_mask_t ret = 0;
371 if (iscntrl(c)) ret |= _Locale_CNTRL;
372 if (isupper(c)) ret |= _Locale_UPPER;
373 if (islower(c)) ret |= _Locale_LOWER;
374 if (isdigit(c)) ret |= _Locale_DIGIT;
375 if (isxdigit(c)) ret |= _Locale_XDIGIT;
376 if (ispunct(c)) ret |= _Locale_PUNCT;
377 if (isspace(c)) ret |= _Locale_SPACE;
378 if (isprint(c)) ret |= _Locale_PRINT;
379 if (isalpha(c)) ret |= _Locale_ALPHA;
384 //Madhu - locale function definitions - END
387 //# ifdef __cplusplus
388 //_STLP_BEGIN_NAMESPACE
391 # define __DUMMY_PAR1
392 # define __DUMMY_PAR2
393 # define __DUMMY_PAR3
394 # define __DUMMY_PAR4
395 # define __DUMMY_PAR5
396 # define __DUMMY_PAR6
397 # define __DUMMY_PAR7
398 # define __DUMMY_PAR8
401 void* _Locale_ctype_create(const char * name)
404 unsigned char buffer[256];
406 _Locale_mask_t* ctable;
408 L_ctype_t *plocCType = (L_ctype_t*) new (L_ctype_t);
413 strcpy(plocCType->name, name);
414 char* ptemp = setlocale(LC_CTYPE, name);
417 ctable = plocCType->ctable;
419 /* Partial implementation for ANSI code page, need to implement for DBCS code pages*/
421 /* Make table with all characters. */
422 for(i = 0; i < 256; i++) buffer[i] = i;
427 ctable[i+1] = Get_locale_char_ctype(buffer[i]);
431 plocCType->statelist = NULL;
436 void* _Locale_numeric_create(const char *name)
438 L_numeric_t *plocNumeric = (L_numeric_t *)new (L_numeric_t);
439 struct lconv *plconv;
443 strcpy(plocNumeric->name, name);
445 char* ptemp = setlocale(LC_NUMERIC, name);
448 plconv = localeconv();
450 //copy locale numeric data to local structure
451 strcpy(plocNumeric->decimal_point, plconv->decimal_point);
452 plocNumeric->grouping = __getString(plconv->grouping);
453 strcpy(plocNumeric->thousands_sep, plconv->thousands_sep);
458 void*_Locale_time_create(const char * name)
460 L_time_t *plocTime = (L_time_t *)new(L_time_t);
461 //struct lconv *plconv;
465 strcpy(plocTime ->name, name);
467 char* ptemp = setlocale(LC_TIME, name);
470 //plconv = localeconv();
474 //Get all month names
475 for (i = 0;i<12;i++,index++)
476 plocTime->month[i] = __getString(nl_langinfo(index));
478 //Get all abbrevated month names
480 for (i = 0;i<12;i++,index++)
481 plocTime->abbrev_month[i] = __getString(nl_langinfo(index));
483 //Get all weekday names
485 for (i = 0;i<7;i++,index++)
486 plocTime->dayofweek[i] = __getString(nl_langinfo(index));
488 //Get all weekday names
490 for (i = 0;i<7;i++,index++)
491 plocTime->abbrev_dayofweek[i] = __getString(nl_langinfo(index));
497 void* _Locale_collate_create(const char *name)
499 L_collate_t *plocCollate = (L_collate_t *)new(L_collate_t);
503 strcpy(plocCollate->name, name);
508 void* _Locale_monetary_create(const char * name)
510 L_monetary_t *plocMonetary = (L_monetary_t *)new(L_monetary_t);
511 struct lconv *plconv;
515 strcpy(plocMonetary->name, name);
517 char* ptemp = setlocale(LC_MONETARY, name);
520 plconv = localeconv();
522 strcpy(plocMonetary->decimal_point,plconv->mon_decimal_point);
523 strcpy(plocMonetary->thousands_sep, plconv->mon_thousands_sep);
524 plocMonetary->grouping = __getString(plconv->mon_grouping);
525 strcpy(plocMonetary->int_curr_symbol, plconv->int_curr_symbol); // 3+1+1
526 strcpy(plocMonetary->curr_symbol, plconv->currency_symbol);
527 strcpy(plocMonetary->negative_sign, plconv->negative_sign);
528 strcpy(plocMonetary->positive_sign, plconv->positive_sign);
529 plocMonetary->frac_digits = plconv->frac_digits;
530 plocMonetary->int_frac_digits = plconv->int_frac_digits;
534 void* _Locale_messages_create(const char *name)
536 L_messages_t *plocMessages= (L_messages_t *)new(L_messages_t);
540 strcpy(plocMessages->name, name);
545 const char* _Locale_ctype_default(char* buff)
547 return Locale_common_default(buff);
550 const char* _Locale_numeric_default(char *buff)
552 return Locale_common_default(buff);
555 const char* _Locale_time_default(char* buff)
557 return Locale_common_default(buff);
560 const char* _Locale_collate_default(char* buff)
562 return Locale_common_default(buff);
565 const char* _Locale_monetary_default(char* buff)
567 return Locale_common_default(buff);
570 const char* _Locale_messages_default(char* buff)
572 return Locale_common_default(buff);
575 char* _Locale_ctype_name(const void* cat, char* buff)
577 L_ctype_t* locale = (L_ctype_t*) cat;
578 strcpy(buff,locale->name);
580 //return Locale_common_name(locale,buff);
583 char* _Locale_numeric_name(const void* cat, char* buff)
585 L_numeric_t* locale = (L_numeric_t*) cat;
586 strcpy(buff,locale->name);
588 //return Locale_common_name(locale,buff);
591 char* _Locale_time_name(const void* cat, char* buff)
593 L_time_t* locale = (L_time_t*) cat;
594 strcpy(buff,locale->name);
596 //return Locale_common_name(locale,buff);
599 char* _Locale_collate_name(const void* cat, char* buff)
601 L_collate_t* locale = (L_collate_t*) cat;
602 strcpy(buff,locale->name);
604 //return Locale_common_name(locale,buff);
607 char* _Locale_monetary_name(const void* cat, char* buff)
609 L_monetary_t* locale = (L_monetary_t*) cat;
610 strcpy(buff,locale->name);
612 //return Locale_common_name(locale,buff);
615 char* _Locale_messages_name(const void* cat, char* buff)
617 L_messages_t* locale = (L_messages_t*) cat;
618 strcpy(buff,locale->name);
620 //return Locale_common_name(locale,buff);
623 void _Locale_ctype_destroy(void* locale)
626 DeleteAllStates(((L_ctype_t*)locale)->statelist);
628 delete((L_ctype_t*)locale);
631 void _Locale_numeric_destroy(void* locale)
633 delete ((L_numeric_t*)locale)->grouping;
634 delete (L_numeric_t*)locale;
637 void _Locale_time_destroy(void* locale)
640 L_time_t* plocTime =(L_time_t*)locale;
643 delete (plocTime->month[i]);
644 //delete abbrevated months
646 delete (plocTime->abbrev_month[i]);
649 delete (plocTime->dayofweek[i]);
650 //delete abbrevated week day
652 delete (plocTime->abbrev_dayofweek[i]);
654 delete((L_time_t*)locale);
657 void _Locale_collate_destroy(void* locale)
659 delete((L_collate_t*)locale);
662 void _Locale_monetary_destroy(void* locale)
664 delete ((L_monetary_t*)locale)->grouping;
665 delete((L_monetary_t*)locale);
668 void _Locale_messages_destroy(void* locale)
670 delete((L_messages_t*)locale);
673 char* _Locale_extract_ctype_name(const char* cname, char* buf)
675 return Locale_extract_name(cname, buf, LC_CTYPE);
678 char* _Locale_extract_numeric_name(const char* cname, char* buf)
680 return Locale_extract_name(cname, buf, LC_NUMERIC);
683 char* _Locale_extract_time_name(const char* cname, char* buf)
685 return Locale_extract_name(cname, buf, LC_TIME);
688 char* _Locale_extract_collate_name(const char* cname, char* buf)
690 return Locale_extract_name(cname, buf, LC_COLLATE);
693 char* _Locale_extract_monetary_name(const char* cname, char* buf)
695 return Locale_extract_name(cname, buf, LC_MONETARY);
698 char* _Locale_extract_messages_name(const char* cname, char* buf)
700 return Locale_extract_name(cname, buf, LC_MESSAGES);
703 char* _Locale_compose_name(char* buf,
704 const char* ctype, const char* numeric,
705 const char* time, const char* collate,
706 const char* monetary, const char* messages,
707 const char* /*default_name*/)
710 if ( !strcmp ( ctype, numeric ) &&
711 !strcmp ( ctype, time ) &&
712 !strcmp ( ctype, collate ) &&
713 !strcmp ( ctype, monetary ) &&
714 !strcmp ( ctype, messages ) )
715 return strcpy ( buf, ctype );
718 strcat ( buf, ctype );
721 strcat ( buf, numeric );
724 strcat ( buf, time );
727 strcat ( buf, collate );
730 strcat ( buf, monetary );
733 strcat ( buf, messages );
741 const _Locale_mask_t* _Locale_ctype_table(struct _Locale_ctype* lctype)
744 return lctype->ctable;
747 int _Locale_toupper(struct _Locale_ctype* /*lctype*/, int c)
752 int _Locale_tolower(L_ctype_t* /*lctype*/, int c)
757 #ifndef _STLP_NO_WCHAR_T
759 _Locale_mask_t _Locale_wchar_ctype(L_ctype_t* /*lctype*/, wint_t c, _Locale_mask_t which_bits)
761 _Locale_mask_t mask = Get_locale_wchar_ctype(c,which_bits);
763 return mask & which_bits;
766 wint_t _Locale_wchar_tolower(L_ctype_t* lctype, wint_t c)
768 setlocale(LC_CTYPE, lctype->name);
772 wint_t _Locale_wchar_toupper(L_ctype_t* /*lctype*/, wint_t c)
779 # ifndef _STLP_NO_MBSTATE_T
781 int _Locale_mb_cur_max (L_ctype_t * /*lctype*/)
786 int _Locale_mb_cur_min (L_ctype_t * /*lctype*/)
791 int _Locale_is_stateless (L_ctype_t * /*lctype*/)
793 return (MB_CUR_MAX == 1)?1:0;
796 #ifndef _STLP_NO_WCHAR_T
797 wint_t _Locale_btowc(L_ctype_t * lctype, int c)
799 setlocale(LC_CTYPE, lctype->name);
803 int _Locale_wctob(L_ctype_t * lctype, wint_t wc)
805 setlocale(LC_CTYPE, lctype->name);
809 size_t _Locale_mbtowc(L_ctype_t *lctype,
810 wchar_t *to, size_t n1,
811 const char *from, size_t n, int* chars_write,
812 mbstate_t * shift_state)
819 iconv_t state = GetState(lctype->statelist, shift_state, IN);
822 ExtractCodeset(lctype->name, codeset);
823 state= iconv_open(UNICODESTR,codeset);
826 if (AddState(&lctype->statelist,state,shift_state,IN) == 0)
830 char* outbuf = (char*)to;
831 const char* inbuf = (char*)from;
832 unsigned int inbytes = n;
833 unsigned int outbytes = n1*sizeof(wchar_t);
834 unsigned int chars_read = iconv((void*)state,&inbuf,&inbytes,&outbuf,&outbytes);
835 *chars_write = (wchar_t*)outbuf - to;
836 if (chars_read == (size_t)-1)
838 if ( (errno == EINVAL) || (outbuf!=(char*)to) )
840 BEtoLE(to,(wchar_t*)outbuf-to);
847 BEtoLE(to,(wchar_t*)outbuf-to);
848 //return (wchar_t*)outbuf-to;
852 setlocale(LC_CTYPE, lctype->name);
853 return (size_t) mbtowc(to, from,n);
857 size_t _Locale_wctomb(L_ctype_t* lctype,
860 mbstate_t *shift_state)
867 iconv_t state = GetState(lctype->statelist, shift_state,OUT);
870 ExtractCodeset(lctype->name, codeset);
871 state= iconv_open(codeset, UNICODESTR);
874 if (AddState(&lctype->statelist,state,shift_state,OUT) == 0)
879 const char* inbuf = (char*)&c;
880 unsigned int inbytes = 2;
881 unsigned int outbytes = n;
882 unsigned int chars_read = iconv((void*)state,&inbuf,&inbytes,&outbuf,&outbytes);
883 if (chars_read == (size_t)-1)
891 //BEtoLE(to,(wchar_t*)outbuf-to);
894 setlocale(LC_CTYPE, lctype->name);
895 return (size_t) wctomb(to, c);
902 //Madhu - Need to double check the implementation.
903 size_t _Locale_unshift(L_ctype_t * /*lctype*/,
905 char *buff, size_t n, char ** next)
925 //Conversion is not required, because iconv will not do partial conversion.
930 # endif /* _STLP_NO_MBSTATE_T */
934 int _Locale_strcmp(L_collate_t* lcol,
935 const char* pStr1, size_t len1, const char* pStr2,
939 char *ptempStr1, *ptempStr2;
940 int tempLen1,tempLen2;
942 tempLen1 = _Locale_strxfrm(lcol, NULL,0,pStr1,len1);
943 tempLen2 = _Locale_strxfrm(lcol, NULL,0,pStr2,len2);
944 ptempStr1 = (char*) new char[tempLen1];
945 ptempStr2 = (char*) new char[tempLen2];
947 int minN = tempLen1 < tempLen2 ? tempLen1 : tempLen2;
948 setlocale(LC_COLLATE, lcol->name);
949 _Locale_strxfrm(lcol, ptempStr1,tempLen1,pStr1,len1);
950 _Locale_strxfrm(lcol, ptempStr2,tempLen2,pStr2,len2);
951 ret = strncmp(ptempStr1, ptempStr2, minN);
956 else if (len1 > len2)
965 # ifndef _STLP_NO_WCHAR_T
967 int _Locale_strwcmp(L_collate_t* lcol,
968 const wchar_t* pStr1, size_t len1,
969 const wchar_t* pStr2, size_t len2)
971 wchar_t *ptempStr1, *ptempStr2;
972 int tempLen1,tempLen2;
974 tempLen1 = _Locale_strwxfrm(lcol, NULL,0,pStr1,len1);
975 tempLen2 = _Locale_strwxfrm(lcol, NULL,0,pStr2,len2);
976 ptempStr1 = (wchar_t*) new wchar_t[tempLen1+1];
977 ptempStr2 = (wchar_t*) new wchar_t[tempLen2+1];
979 int minN = tempLen1 < tempLen2 ? tempLen1 : tempLen2;
980 setlocale(LC_COLLATE, lcol->name);
981 _Locale_strwxfrm(lcol, ptempStr1,tempLen1,pStr1,len1);
982 _Locale_strwxfrm(lcol, ptempStr2,tempLen2,pStr2,len2);
983 ret = wcsncmp(ptempStr1, ptempStr2, minN);
988 else if (len1 > len2)
1000 size_t _Locale_strxfrm(L_collate_t* lcol,
1001 char* pDestStr, size_t destLen,
1002 const char* pSrcStr, size_t srcLen)
1005 setlocale(LC_COLLATE, lcol->name);
1007 char* ptemp = (char*) new char[srcLen+1];
1010 memmove(ptemp,pSrcStr,srcLen);
1011 *(ptemp+srcLen) = 0;
1013 n = strxfrm(pDestStr, ptemp, destLen);
1017 if ((pDestStr == NULL) || (destLen ==0) )
1019 else if(n > destLen)
1026 # ifndef _STLP_NO_WCHAR_T
1028 size_t _Locale_strwxfrm(L_collate_t* lcol,
1029 wchar_t* pDestStr, size_t destLen,
1030 const wchar_t* pSrcStr, size_t srcLen)
1033 setlocale(LC_COLLATE, lcol->name);
1034 wchar_t* ptemp = (wchar_t*) new wchar_t[srcLen+1];
1037 memmove(ptemp,pSrcStr,srcLen*sizeof(wchar_t));
1038 *(ptemp+srcLen) = 0;
1039 n = wcsxfrm(pDestStr, ptemp, destLen);
1042 if ((pDestStr == NULL) || (destLen ==0) )
1044 else if(n > destLen)
1055 char _Locale_decimal_point(L_numeric_t* lnum)
1058 return lnum->decimal_point[0];
1061 char _Locale_thousands_sep(L_numeric_t* lnum)
1064 return lnum->thousands_sep[0];
1066 const char* _Locale_grouping(L_numeric_t*lnum)
1069 return lnum->grouping;
1072 const char * _Locale_true(L_numeric_t * /*lnum*/)
1074 const char* __true_name="true"; //glib and NT doing the same
1080 const char * _Locale_false(L_numeric_t * /*lnum*/)
1082 const char* __false_name="false"; //glib and NT doing the same
1084 return __false_name;
1090 const char* _Locale_int_curr_symbol(L_monetary_t * lmon)
1093 return lmon->int_curr_symbol;
1096 const char* _Locale_currency_symbol(L_monetary_t * lmon)
1099 return lmon->curr_symbol;
1102 char _Locale_mon_decimal_point(L_monetary_t * lmon)
1104 return lmon->decimal_point[0];
1107 char _Locale_mon_thousands_sep(L_monetary_t * lmon)
1110 return lmon->thousands_sep[0];
1113 const char* _Locale_mon_grouping(L_monetary_t * lmon)
1116 return lmon->grouping;
1119 const char* _Locale_positive_sign(L_monetary_t * lmon)
1122 return lmon->positive_sign;
1125 const char* _Locale_negative_sign(L_monetary_t * lmon)
1128 return lmon->negative_sign;
1131 char _Locale_int_frac_digits(L_monetary_t * lmon)
1134 return lmon->int_frac_digits;
1137 char _Locale_frac_digits(L_monetary_t * lmon)
1140 return lmon->frac_digits;
1143 int _Locale_p_cs_precedes(L_monetary_t * lmon)
1145 struct lconv* plconv;
1146 setlocale(LC_MONETARY, lmon->name);
1147 plconv = localeconv();
1149 return plconv->p_cs_precedes;
1152 int _Locale_p_sep_by_space(L_monetary_t * lmon)
1154 struct lconv* plconv;
1155 setlocale(LC_MONETARY, lmon->name);
1156 plconv = localeconv();
1158 return plconv->p_sep_by_space;
1161 int _Locale_p_sign_posn(L_monetary_t * lmon)
1163 struct lconv* plconv;
1164 setlocale(LC_MONETARY, lmon->name);
1165 plconv = localeconv();
1167 return plconv->p_sign_posn;
1170 int _Locale_n_cs_precedes(L_monetary_t * lmon)
1172 struct lconv* plconv;
1173 setlocale(LC_MONETARY, lmon->name);
1174 plconv = localeconv();
1176 return plconv->n_cs_precedes;
1179 int _Locale_n_sep_by_space(L_monetary_t * lmon)
1181 struct lconv* plconv;
1182 setlocale(LC_MONETARY, lmon->name);
1183 plconv = localeconv();
1185 return plconv->n_sep_by_space;
1188 int _Locale_n_sign_posn(L_monetary_t * lmon)
1190 struct lconv* plconv;
1191 setlocale(LC_MONETARY, lmon->name);
1192 plconv = localeconv();
1194 return plconv->n_sign_posn;
1199 const char * _Locale_full_monthname(L_time_t * ltime, int month)
1202 return ltime->month[month];
1205 const char * _Locale_abbrev_monthname(L_time_t * ltime, int month)
1208 return ltime->abbrev_month[month];
1211 const char * _Locale_full_dayofweek(L_time_t * ltime, int day)
1214 return ltime->dayofweek[day];
1217 const char * _Locale_abbrev_dayofweek(L_time_t * ltime, int day)
1220 return ltime->abbrev_dayofweek[day];
1223 const char* _Locale_d_t_fmt(L_time_t* ltime)
1225 setlocale(LC_TIME, ltime->name);
1226 return nl_langinfo(D_T_FMT);
1229 const char* _Locale_d_fmt(L_time_t* ltime)
1231 setlocale(LC_TIME, ltime->name);
1232 return nl_langinfo(D_FMT);
1235 const char* _Locale_t_fmt(L_time_t* ltime)
1237 setlocale(LC_TIME, ltime->name);
1238 return nl_langinfo(T_FMT);
1241 const char* _Locale_long_d_t_fmt(L_time_t* ltime)
1243 setlocale(LC_TIME, ltime->name);
1244 return nl_langinfo(D_T_FMT); //Madhu--now same as D_T_FMT, need to check
1247 const char* _Locale_long_d_fmt(L_time_t* ltime)
1249 setlocale(LC_TIME, ltime->name);
1250 return nl_langinfo(D_FMT); //Madhu--now same as D_FMT, need to check
1252 const char* _Locale_am_str(L_time_t* ltime)
1254 setlocale(LC_TIME, ltime->name);
1255 return nl_langinfo(AM_STR);
1258 const char* _Locale_pm_str(L_time_t* ltime)
1260 setlocale(LC_TIME, ltime->name);
1261 return nl_langinfo(PM_STR);
1264 const char* _Locale_t_fmt_ampm(L_time_t* ltime)
1266 setlocale(LC_TIME, ltime->name);
1267 return nl_langinfo(T_FMT_AMPM);
1270 /* Messages */ // Madhu - support after libc team supported.
1274 int _Locale_catopen(L_messages_t* lmessage, const char* catalogName)
1276 lmessage->domain = __getString((char*)catalogName);
1277 return 1;//catopen(catalogName,/*NL_CAT_LOCALE*/1);
1280 void _Locale_catclose(L_messages_t* lmessage, int /*catalog_desc*/)
1282 //setlocale(LC_MESSAGES, lmessage->name);
1283 delete(lmessage->domain);
1284 lmessage->domain = NULL;
1285 //catclose(catalog_desc);
1289 const char* _Locale_catgets(L_messages_t* lmessage, int /*catalog_desc*/,
1290 int /*set*/, int /*message*/,
1293 char* locale = setlocale(LC_ALL, lmessage->name);
1294 #ifdef _MESSAGE_CATALOG_
1295 textdomain(lmessage->domain);
1297 return gettext(dfault);
1309 #endif /* real locale */