os/ossrv/genericopenlibs/cstdlib/LLOCALE/LOCALE.C
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LLOCALE/LOCALE.C	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,118 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +* FUNCTION
    1.19 +* <<setlocale>>, <<localeconv>>---select or query locale
    1.20 +* INDEX
    1.21 +* setlocale
    1.22 +* INDEX
    1.23 +* localeconv
    1.24 +* INDEX
    1.25 +* _setlocale_r
    1.26 +* INDEX
    1.27 +* _localeconv_r
    1.28 +* ANSI_SYNOPSIS
    1.29 +* #include <locale.h>
    1.30 +* char *setlocale(int <[category]>, const char *<[locale]>);
    1.31 +* lconv *localeconv(void);
    1.32 +* char *_setlocale_r(void *<[reent]>,
    1.33 +* int <[category]>, const char *<[locale]>);
    1.34 +* lconv *_localeconv_r(void *<[reent]>);
    1.35 +* TRAD_SYNOPSIS
    1.36 +* #include <locale.h>
    1.37 +* char *setlocale(<[category]>, <[locale]>)
    1.38 +* int <[category]>;
    1.39 +* char *<[locale]>;
    1.40 +* lconv *localeconv();
    1.41 +* char *_setlocale_r(<[reent]>, <[category]>, <[locale]>)
    1.42 +* char *<[reent]>;
    1.43 +* int <[category]>;
    1.44 +* char *<[locale]>;
    1.45 +* lconv *_localeconv_r(<[reent]>);
    1.46 +* char *<[reent]>;
    1.47 +* <<setlocale>> is the facility defined by ANSI C to condition the
    1.48 +* execution environment for international collating and formatting
    1.49 +* information; <<localeconv>> reports on the settings of the current
    1.50 +* locale.
    1.51 +* This is a minimal implementation, supporting only the required <<``C''>>
    1.52 +* value for <[locale]>; strings representing other locales are not
    1.53 +* honored.  (<<``''>> is also accepted; it represents the default locale
    1.54 +* for an implementation, here equivalent to <<``C''>>.)
    1.55 +* If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns
    1.56 +* a pointer to the string representing the current locale (always
    1.57 +* <<``C''>> in this implementation).  The acceptable values for
    1.58 +* <[category]> are defined in `<<locale.h>>' as macros beginning with
    1.59 +* <<"LC_">>, but this implementation does not check the values you pass
    1.60 +* in the <[category]> argument.
    1.61 +* <<localeconv>> returns a pointer to a structure (also defined in
    1.62 +* `<<locale.h>>') describing the locale-specific conventions currently
    1.63 +* in effect.  
    1.64 +* <<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of
    1.65 +* <<localeconv>> and <<setlocale>> respectively.  The extra argument
    1.66 +* <[reent]> is a pointer to a reentrancy structure.
    1.67 +* RETURNS
    1.68 +* <<setlocale>> returns either a pointer to a string naming the locale
    1.69 +* currently in effect (always <<``C''>> for this implementation), or, if
    1.70 +* the locale request cannot be honored, <<NULL>>.
    1.71 +* <<localeconv>> returns a pointer to a structure of type <<lconv>>,
    1.72 +* which describes the formatting and collating conventions in effect (in
    1.73 +* this implementation, always those of the C locale).
    1.74 +* PORTABILITY
    1.75 +* ANSI C requires <<setlocale>>, but the only locale required across all
    1.76 +* implementations is the C locale.
    1.77 +* No supporting OS subroutines are required.
    1.78 +* setlocale, localeconv : internationalize your locale.
    1.79 +* (Only "C" or null supported).
    1.80 +* 
    1.81 +*
    1.82 +*/
    1.83 +
    1.84 +
    1.85 +
    1.86 +#include <locale.h>
    1.87 +#include <string.h>
    1.88 +#include <limits.h>
    1.89 +#include <reent.h>
    1.90 +
    1.91 +static const struct lconv lconv = 
    1.92 +{
    1.93 +  ".", "", "", "", "", "", "", "", "", "",
    1.94 +  CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
    1.95 +  CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
    1.96 +};
    1.97 +
    1.98 +/**
    1.99 +The facility defined to condition the execution environment 
   1.100 +for international collating and formatting information.
   1.101 +@return either a pointer to a string naming the locale
   1.102 +currently in effect or, if the locale request cannot be honored NULL.
   1.103 +@param category Category
   1.104 +@param locale Locale
   1.105 +*/
   1.106 +EXPORT_C char* setlocale (int category, const char *locale)
   1.107 +{
   1.108 +  if (locale && strcmp (locale, "C") && strcmp (locale, ""))
   1.109 +   return 0;
   1.110 +  return "C";
   1.111 +}
   1.112 +
   1.113 +/**
   1.114 +Reports on the settings of the current locale.
   1.115 +@return a pointer to a structure of type lconv,
   1.116 +which describes the formatting and collating conventions in effect
   1.117 +*/
   1.118 +EXPORT_C struct lconv* localeconv (void)
   1.119 +{
   1.120 +  return (struct lconv *) &lconv;
   1.121 +}