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