Home | History | Annotate | Line # | Download | only in locale
nl_langinfo.c revision 1.2
      1 /*
      2  * Copyright (c) 1994 Winning Strategies, Inc.
      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  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *      This product includes software developed by Winning Strategies, Inc.
     16  * 4. The name of the author may not be used to endorse or promote products
     17  *    derived from this software without specific prior written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #if defined(LIBC_SCCS) && !defined(lint)
     32 static char *rcsid = "$Id: nl_langinfo.c,v 1.2 1994/09/29 04:57:30 jtc Exp $";
     33 #endif /* LIBC_SCCS and not lint */
     34 
     35 #include <sys/localedef.h>
     36 #include <locale.h>
     37 #include <nl_types.h>
     38 #include <langinfo.h>
     39 
     40 char *
     41 nl_langinfo(item)
     42 	nl_item item;
     43 {
     44 	const char *s;
     45 
     46 	switch (item) {
     47 	case D_T_FMT:
     48 		s = _CurrentTimeLocale->d_t_fmt;
     49 		break;
     50 	case D_FMT:
     51 		s = _CurrentTimeLocale->d_fmt;
     52 		break;
     53 	case T_FMT:
     54 		s = _CurrentTimeLocale->t_fmt;
     55 		break;
     56 	case T_FMT_AMPM:
     57 		s = _CurrentTimeLocale->t_fmt_ampm;
     58 		break;
     59 	case AM_STR:
     60 	case PM_STR:
     61 		s = _CurrentTimeLocale->am_pm[item - AM_STR];
     62 		break;
     63 	case DAY_1:
     64 	case DAY_2:
     65 	case DAY_3:
     66 	case DAY_4:
     67 	case DAY_5:
     68 	case DAY_6:
     69 	case DAY_7:
     70 		s = _CurrentTimeLocale->day[item - DAY_1];
     71 		break;
     72 	case ABDAY_1:
     73 	case ABDAY_2:
     74 	case ABDAY_3:
     75 	case ABDAY_4:
     76 	case ABDAY_5:
     77 	case ABDAY_6:
     78 	case ABDAY_7:
     79 		s = _CurrentTimeLocale->abday[item - ABDAY_1];
     80 		break;
     81 	case MON_1:
     82 	case MON_2:
     83 	case MON_3:
     84 	case MON_4:
     85 	case MON_5:
     86 	case MON_6:
     87 	case MON_7:
     88 	case MON_8:
     89 	case MON_9:
     90 	case MON_10:
     91 	case MON_11:
     92 	case MON_12:
     93 		s = _CurrentTimeLocale->mon[item - MON_1];
     94 		break;
     95 	case ABMON_1:
     96 	case ABMON_2:
     97 	case ABMON_3:
     98 	case ABMON_4:
     99 	case ABMON_5:
    100 	case ABMON_6:
    101 	case ABMON_7:
    102 	case ABMON_8:
    103 	case ABMON_9:
    104 	case ABMON_10:
    105 	case ABMON_11:
    106 	case ABMON_12:
    107 		s = _CurrentTimeLocale->abmon[item - ABMON_1];
    108 		break;
    109 	case RADIXCHAR:
    110 		s = _CurrentNumericLocale->decimal_point;
    111 		break;
    112 	case THOUSEP:
    113 		s = _CurrentNumericLocale->thousands_sep;
    114 		break;
    115 	case YESSTR:
    116 		s = _CurrentMessagesLocale->yesstr;
    117 		break;
    118 	case YESEXPR:
    119 		s = _CurrentMessagesLocale->yesexpr;
    120 		break;
    121 	case NOSTR:
    122 		s = _CurrentMessagesLocale->nostr;
    123 		break;
    124 	case NOEXPR:
    125 		s = _CurrentMessagesLocale->noexpr;
    126 		break;
    127 	case CRNCYSTR:				/* XXX */
    128 		s = "";
    129 		break;
    130 	default:
    131 		s = "";
    132 		break;
    133 	}
    134 
    135 	return (char *) s;
    136 }
    137