Main Page | File List | Globals

src/langinfo.c

Go to the documentation of this file.
00001 /*
00002      This file is part of PlibC.
00003      (C) 2005 Nils Durner (and other contributing authors)
00004 
00005            This library is free software; you can redistribute it and/or
00006            modify it under the terms of the GNU Lesser General Public
00007            License as published by the Free Software Foundation; either
00008            version 2.1 of the License, or (at your option) any later version.
00009         
00010            This library is distributed in the hope that it will be useful,
00011            but WITHOUT ANY WARRANTY; without even the implied warranty of
00012            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013            Lesser General Public License for more details.
00014         
00015            You should have received a copy of the GNU Lesser General Public
00016            License along with this library; if not, write to the Free Software
00017            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00025 #include "plibc_private.h"
00026 
00027 char __langinfo[251];
00028 
00032 char *nl_langinfo(int item)
00033 {
00034   unsigned int loc;
00035 
00036   loc = GetThreadLocale();
00037 
00038   switch(item)
00039   {
00040     case CODESET:
00041       {
00042         unsigned int cp = GetACP();
00043 
00044         if (cp)
00045           sprintf(__langinfo, "CP%u", cp);
00046         else
00047           strcpy(__langinfo, "UTF-8"); /* ? */
00048         return __langinfo;
00049       }
00050     case D_T_FMT:
00051     case T_FMT_AMPM:
00052     case ERA_D_T_FMT:
00053       strcpy(__langinfo, "%c");
00054       return __langinfo;
00055     case D_FMT:
00056     case ERA_D_FMT:
00057       strcpy(__langinfo, "%x");
00058       return __langinfo;
00059     case T_FMT:
00060     case ERA_T_FMT:
00061       strcpy(__langinfo, "%X");
00062       return __langinfo;
00063     case AM_STR:
00064       GetLocaleInfo(loc, LOCALE_S1159, __langinfo, 251);
00065       return __langinfo;
00066     case PM_STR:
00067       GetLocaleInfo(loc, LOCALE_S2359, __langinfo, 251);
00068       return __langinfo;
00069     case DAY_1:
00070       GetLocaleInfo(loc, LOCALE_SDAYNAME1, __langinfo, 251);
00071       return __langinfo;
00072     case DAY_2:
00073       GetLocaleInfo(loc, LOCALE_SDAYNAME2, __langinfo, 251);
00074       return __langinfo;
00075     case DAY_3:
00076       GetLocaleInfo(loc, LOCALE_SDAYNAME3, __langinfo, 251);
00077       return __langinfo;
00078     case DAY_4:
00079       GetLocaleInfo(loc, LOCALE_SDAYNAME4, __langinfo, 251);
00080       return __langinfo;
00081     case DAY_5:
00082       GetLocaleInfo(loc, LOCALE_SDAYNAME5, __langinfo, 251);
00083       return __langinfo;
00084     case DAY_6:
00085       GetLocaleInfo(loc, LOCALE_SDAYNAME6, __langinfo, 251);
00086       return __langinfo;
00087     case DAY_7:
00088       GetLocaleInfo(loc, LOCALE_SDAYNAME7, __langinfo, 251);
00089       return __langinfo;
00090     case ABDAY_1:
00091       GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME1, __langinfo, 251);
00092       return __langinfo;
00093     case ABDAY_2:
00094       GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME2, __langinfo, 251);
00095       return __langinfo;
00096     case ABDAY_3:
00097       GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME3, __langinfo, 251);
00098       return __langinfo;
00099     case ABDAY_4:
00100       GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME4, __langinfo, 251);
00101       return __langinfo;
00102     case ABDAY_5:
00103       GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME5, __langinfo, 251);
00104       return __langinfo;
00105     case ABDAY_6:
00106       GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME6, __langinfo, 251);
00107       return __langinfo;
00108     case ABDAY_7:
00109       GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME7, __langinfo, 251);
00110       return __langinfo;
00111     case MON_1:
00112       GetLocaleInfo(loc, LOCALE_SMONTHNAME1, __langinfo, 251);
00113       return __langinfo;
00114     case MON_2:
00115       GetLocaleInfo(loc, LOCALE_SMONTHNAME2, __langinfo, 251);
00116       return __langinfo;
00117     case MON_3:
00118       GetLocaleInfo(loc, LOCALE_SMONTHNAME3, __langinfo, 251);
00119       return __langinfo;
00120     case MON_4:
00121       GetLocaleInfo(loc, LOCALE_SMONTHNAME4, __langinfo, 251);
00122       return __langinfo;
00123     case MON_5:
00124       GetLocaleInfo(loc, LOCALE_SMONTHNAME5, __langinfo, 251);
00125       return __langinfo;
00126     case MON_6:
00127       GetLocaleInfo(loc, LOCALE_SMONTHNAME6, __langinfo, 251);
00128       return __langinfo;
00129     case MON_7:
00130       GetLocaleInfo(loc, LOCALE_SMONTHNAME7, __langinfo, 251);
00131       return __langinfo;
00132     case MON_8:
00133       GetLocaleInfo(loc, LOCALE_SMONTHNAME8, __langinfo, 251);
00134       return __langinfo;
00135     case MON_9:
00136       GetLocaleInfo(loc, LOCALE_SMONTHNAME9, __langinfo, 251);
00137       return __langinfo;
00138     case MON_10:
00139       GetLocaleInfo(loc, LOCALE_SMONTHNAME10, __langinfo, 251);
00140       return __langinfo;
00141     case MON_11:
00142       GetLocaleInfo(loc, LOCALE_SMONTHNAME11, __langinfo, 251);
00143       return __langinfo;
00144     case MON_12:
00145       GetLocaleInfo(loc, LOCALE_SMONTHNAME12, __langinfo, 251);
00146       return __langinfo;
00147     case ABMON_1:
00148       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME1, __langinfo, 251);
00149       return __langinfo;
00150     case ABMON_2:
00151       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME2, __langinfo, 251);
00152       return __langinfo;
00153     case ABMON_3:
00154       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME3, __langinfo, 251);
00155       return __langinfo;
00156     case ABMON_4:
00157       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME4, __langinfo, 251);
00158       return __langinfo;
00159     case ABMON_5:
00160       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME5, __langinfo, 251);
00161       return __langinfo;
00162     case ABMON_6:
00163       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME6, __langinfo, 251);
00164       return __langinfo;
00165     case ABMON_7:
00166       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME7, __langinfo, 251);
00167       return __langinfo;
00168     case ABMON_8:
00169       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME8, __langinfo, 251);
00170       return __langinfo;
00171     case ABMON_9:
00172       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME9, __langinfo, 251);
00173       return __langinfo;
00174     case ABMON_10:
00175       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME10, __langinfo, 251);
00176       return __langinfo;
00177     case ABMON_11:
00178       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME11, __langinfo, 251);
00179       return __langinfo;
00180     case ABMON_12:
00181       GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME12, __langinfo, 251);
00182       return __langinfo;
00183     case ERA:
00184       /* Not implemented */
00185       __langinfo[0] = 0;
00186       return __langinfo;
00187     case ALT_DIGITS:
00188       GetLocaleInfo(loc, LOCALE_SNATIVEDIGITS, __langinfo, 251);
00189       return __langinfo;
00190     case RADIXCHAR:
00191       GetLocaleInfo(loc, LOCALE_SDECIMAL, __langinfo, 251);
00192       return __langinfo;
00193     case THOUSEP:
00194       GetLocaleInfo(loc, LOCALE_STHOUSAND, __langinfo, 251);
00195       return __langinfo;
00196     case YESEXPR:
00197       /* Not localized */
00198       strcpy(__langinfo, "^[yY]");
00199       return __langinfo;
00200     case NOEXPR:
00201       /* Not localized */
00202       strcpy(__langinfo, "^[nN]");
00203       return __langinfo;
00204     case CRNCYSTR:
00205       GetLocaleInfo(loc, LOCALE_STHOUSAND, __langinfo, 251);
00206       if (__langinfo[0] == '0' || __langinfo[0] == '2')
00207         __langinfo[0] = '-';
00208       else
00209         __langinfo[0] = '+';
00210       GetLocaleInfo(loc, LOCALE_SCURRENCY, __langinfo + 1, 251);
00211     default:
00212       __langinfo[0] = 0;
00213       return __langinfo;
00214   }
00215 }
00216 
00217 /* end of langinfo.c */

Generated on Sun Sep 4 11:16:47 2005 for PlibC by  doxygen 1.4.2