os/ossrv/genericopenlibs/cstdlib/LLOCALE/LOCALE.C
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 * FUNCTION
    16 * <<setlocale>>, <<localeconv>>---select or query locale
    17 * INDEX
    18 * setlocale
    19 * INDEX
    20 * localeconv
    21 * INDEX
    22 * _setlocale_r
    23 * INDEX
    24 * _localeconv_r
    25 * ANSI_SYNOPSIS
    26 * #include <locale.h>
    27 * char *setlocale(int <[category]>, const char *<[locale]>);
    28 * lconv *localeconv(void);
    29 * char *_setlocale_r(void *<[reent]>,
    30 * int <[category]>, const char *<[locale]>);
    31 * lconv *_localeconv_r(void *<[reent]>);
    32 * TRAD_SYNOPSIS
    33 * #include <locale.h>
    34 * char *setlocale(<[category]>, <[locale]>)
    35 * int <[category]>;
    36 * char *<[locale]>;
    37 * lconv *localeconv();
    38 * char *_setlocale_r(<[reent]>, <[category]>, <[locale]>)
    39 * char *<[reent]>;
    40 * int <[category]>;
    41 * char *<[locale]>;
    42 * lconv *_localeconv_r(<[reent]>);
    43 * char *<[reent]>;
    44 * <<setlocale>> is the facility defined by ANSI C to condition the
    45 * execution environment for international collating and formatting
    46 * information; <<localeconv>> reports on the settings of the current
    47 * locale.
    48 * This is a minimal implementation, supporting only the required <<``C''>>
    49 * value for <[locale]>; strings representing other locales are not
    50 * honored.  (<<``''>> is also accepted; it represents the default locale
    51 * for an implementation, here equivalent to <<``C''>>.)
    52 * If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns
    53 * a pointer to the string representing the current locale (always
    54 * <<``C''>> in this implementation).  The acceptable values for
    55 * <[category]> are defined in `<<locale.h>>' as macros beginning with
    56 * <<"LC_">>, but this implementation does not check the values you pass
    57 * in the <[category]> argument.
    58 * <<localeconv>> returns a pointer to a structure (also defined in
    59 * `<<locale.h>>') describing the locale-specific conventions currently
    60 * in effect.  
    61 * <<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of
    62 * <<localeconv>> and <<setlocale>> respectively.  The extra argument
    63 * <[reent]> is a pointer to a reentrancy structure.
    64 * RETURNS
    65 * <<setlocale>> returns either a pointer to a string naming the locale
    66 * currently in effect (always <<``C''>> for this implementation), or, if
    67 * the locale request cannot be honored, <<NULL>>.
    68 * <<localeconv>> returns a pointer to a structure of type <<lconv>>,
    69 * which describes the formatting and collating conventions in effect (in
    70 * this implementation, always those of the C locale).
    71 * PORTABILITY
    72 * ANSI C requires <<setlocale>>, but the only locale required across all
    73 * implementations is the C locale.
    74 * No supporting OS subroutines are required.
    75 * setlocale, localeconv : internationalize your locale.
    76 * (Only "C" or null supported).
    77 * 
    78 *
    79 */
    80 
    81 
    82 
    83 #include <locale.h>
    84 #include <string.h>
    85 #include <limits.h>
    86 #include <reent.h>
    87 
    88 static const struct lconv lconv = 
    89 {
    90   ".", "", "", "", "", "", "", "", "", "",
    91   CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
    92   CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
    93 };
    94 
    95 /**
    96 The facility defined to condition the execution environment 
    97 for international collating and formatting information.
    98 @return either a pointer to a string naming the locale
    99 currently in effect or, if the locale request cannot be honored NULL.
   100 @param category Category
   101 @param locale Locale
   102 */
   103 EXPORT_C char* setlocale (int category, const char *locale)
   104 {
   105   if (locale && strcmp (locale, "C") && strcmp (locale, ""))
   106    return 0;
   107   return "C";
   108 }
   109 
   110 /**
   111 Reports on the settings of the current locale.
   112 @return a pointer to a structure of type lconv,
   113 which describes the formatting and collating conventions in effect
   114 */
   115 EXPORT_C struct lconv* localeconv (void)
   116 {
   117   return (struct lconv *) &lconv;
   118 }