nl_langinfo.c revision 72245
1/*-
2 * Copyright (c) 2001 Alexey Zelkin
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/libc/locale/nl_langinfo.c 72245 2001-02-09 18:39:17Z ache $
27 */
28
29#include "langinfo.h"
30#include "../stdtime/timelocal.h"
31#include "lnumeric.h"
32#include "lmonetary.h"
33#include "lmessages.h"
34
35#define _REL(BASE) ((int)item-BASE)
36
37char *
38nl_langinfo(nl_item item) {
39
40   char *ret;
41
42   switch (item) {
43	case CODESET:
44		ret = "";		/* XXX: need to be implemented */
45		break;
46	case D_T_FMT:
47		ret = (char *) __get_current_time_locale()->c_fmt;
48		break;
49	case D_FMT:
50		ret = (char *) __get_current_time_locale()->x_fmt;
51		break;
52	case T_FMT:
53		ret = (char *) __get_current_time_locale()->X_fmt;
54		break;
55	case T_FMT_AMPM:
56		ret = "%r";
57		break;
58	case AM_STR:
59		ret = (char *) __get_current_time_locale()->am;
60		break;
61	case PM_STR:
62		ret = (char *) __get_current_time_locale()->pm;
63		break;
64	case DAY_1: case DAY_2: case DAY_3:
65	case DAY_4: case DAY_5: case DAY_6: case DAY_7:
66		ret = (char*) __get_current_time_locale()->weekday[_REL(DAY_1)];
67		break;
68	case ABDAY_1: case ABDAY_2: case ABDAY_3:
69	case ABDAY_4: case ABDAY_5: case ABDAY_6: case ABDAY_7:
70		ret = (char*) __get_current_time_locale()->wday[_REL(ABDAY_1)];
71		break;
72	case MON_1: case MON_2: case MON_3: case MON_4:
73	case MON_5: case MON_6: case MON_7: case MON_8:
74	case MON_9: case MON_10: case MON_11: case MON_12:
75		ret = (char*) __get_current_time_locale()->month[_REL(MON_1)];
76		break;
77	case ABMON_1: case ABMON_2: case ABMON_3: case ABMON_4:
78	case ABMON_5: case ABMON_6: case ABMON_7: case ABMON_8:
79	case ABMON_9: case ABMON_10: case ABMON_11: case ABMON_12:
80		ret = (char*) __get_current_time_locale()->mon[_REL(ABMON_1)];
81		break;
82	case ERA:
83		/* XXX: ??? */
84		ret = "";
85		break;
86	case ERA_D_FMT:
87		/* XXX: ??? */
88		ret = "";
89		break;
90	case ERA_D_T_FMT:
91		/* XXX: ??? */
92		ret = "";
93		break;
94	case ERA_T_FMT:
95		/* XXX: ??? */
96		ret = "";
97		break;
98	case ALT_DIGITS:
99		/* XXX: ??? */
100		ret = "";
101		break;
102	case RADIXCHAR:         /* deprecated */
103		ret = (char*) __get_current_numeric_locale()->decimal_point;
104		break;
105	case THOUSEP:           /* deprecated */
106		ret = (char*) __get_current_numeric_locale()->thousands_sep;
107		break;
108	case YESEXPR:
109		ret = (char*) __get_current_messages_locale()->yesexpr;
110		break;
111	case NOEXPR:
112		ret = (char*) __get_current_messages_locale()->noexpr;
113		break;
114	case YESSTR:            /* deprecated */
115		ret = "";
116		break;
117	case NOSTR:             /* deprecated */
118		ret = "";
119		break;
120	case CRNCYSTR:          /* deprecated */
121		/* XXX: need to be implemented */
122		/* __get_current_monetary_locale()->currency_symbol    */
123		/* but requare special +-. prefixes according to SUSV2 */
124		ret = "";
125		break;
126	default:
127		ret = "";
128   }
129   return (ret);
130}
131