1 /*
2 * Copyright (C) 2016 The Android Open Source Project
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 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #include <langinfo.h>
30
31 #include <stdlib.h>
32
nl_langinfo(nl_item item)33 char* nl_langinfo(nl_item item) {
34 const char* result = "";
35 switch (item) {
36 case CODESET: result = (MB_CUR_MAX == 1) ? "ASCII" : "UTF-8"; break;
37
38 case D_T_FMT: result = "%F %T %z"; break;
39 case D_FMT: result = "%F"; break;
40 case T_FMT: result = "%T"; break;
41 case T_FMT_AMPM: result = "%I:%M:%S %p"; break;
42 case AM_STR: result = "AM"; break;
43 case PM_STR: result = "PM"; break;
44 case DAY_1: result = "Sunday"; break;
45 case DAY_2: result = "Monday"; break;
46 case DAY_3: result = "Tuesday"; break;
47 case DAY_4: result = "Wednesday"; break;
48 case DAY_5: result = "Thursday"; break;
49 case DAY_6: result = "Friday"; break;
50 case DAY_7: result = "Saturday"; break;
51 case ABDAY_1: result = "Sun"; break;
52 case ABDAY_2: result = "Mon"; break;
53 case ABDAY_3: result = "Tue"; break;
54 case ABDAY_4: result = "Wed"; break;
55 case ABDAY_5: result = "Thu"; break;
56 case ABDAY_6: result = "Fri"; break;
57 case ABDAY_7: result = "Sat"; break;
58 case MON_1: result = "January"; break;
59 case MON_2: result = "February"; break;
60 case MON_3: result = "March"; break;
61 case MON_4: result = "April"; break;
62 case MON_5: result = "May"; break;
63 case MON_6: result = "June"; break;
64 case MON_7: result = "July"; break;
65 case MON_8: result = "August"; break;
66 case MON_9: result = "September"; break;
67 case MON_10: result = "October"; break;
68 case MON_11: result = "November"; break;
69 case MON_12: result = "December"; break;
70 case ABMON_1: result = "Jan"; break;
71 case ABMON_2: result = "Feb"; break;
72 case ABMON_3: result = "Mar"; break;
73 case ABMON_4: result = "Apr"; break;
74 case ABMON_5: result = "May"; break;
75 case ABMON_6: result = "Jun"; break;
76 case ABMON_7: result = "Jul"; break;
77 case ABMON_8: result = "Aug"; break;
78 case ABMON_9: result = "Sep"; break;
79 case ABMON_10: result = "Oct"; break;
80 case ABMON_11: result = "Nov"; break;
81 case ABMON_12: result = "Dec"; break;
82 case ERA: result = ""; break;
83 case ERA_D_FMT: result = ""; break;
84 case ERA_D_T_FMT: result = ""; break;
85 case ERA_T_FMT: result = ""; break;
86 case ALT_DIGITS: result = ""; break;
87
88 case RADIXCHAR: result = "."; break;
89 case THOUSEP: result = ""; break;
90
91 case YESEXPR: result = "^[yY]"; break;
92 case NOEXPR: result = "^[nN]"; break;
93
94 case CRNCYSTR: result = ""; break;
95
96 default: break;
97 }
98 return const_cast<char*>(result);
99 }
100
nl_langinfo_l(nl_item item,locale_t)101 char* nl_langinfo_l(nl_item item, locale_t) {
102 return nl_langinfo(item);
103 }
104