home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / setlocal.c < prev    next >
C/C++ Source or Header  |  1992-09-17  |  3KB  |  83 lines

  1. /*
  2.  * Routines for handling the local environment.
  3.  * WARNING: This probably isn't in accord with the pANS standard yet.
  4.  *
  5.  * Written by Eric R. Smith and placed in the public domain.
  6.  *
  7.  */
  8.  
  9. #include <stddef.h>
  10. #include <string.h>
  11. #include <locale.h>
  12.  
  13. static char *C_mth_name[] =
  14. { "January", "February", "March", "April", "May", "June",
  15.   "July", "August", "September", "October", "November", "December"
  16. };
  17.  
  18. static char *C_day_name[] =
  19. {
  20. "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
  21. };
  22.  
  23. static struct lconv C_locale = {
  24.         ".",    /* decimal point for ordinary numbers */
  25.         ",",    /* thousands separator */
  26.         3,      /* how digits in ordinary numbers are grouped */
  27.         "$",    /* international currency symbol */
  28.         "$",    /* currency symbol for ordinary use */
  29.         ".",    /* decimal point for money */
  30.         ",",    /* thousands separator for money */
  31.         3,      /* how digits in a monetary value are grouped */
  32.         "",     /* symbol for positive amount of money */
  33.         "-",    /* symbol for negative amount of money */
  34.         4,      /* International: number of places after '.' for money*/
  35.         2,      /* local: number of places after '.' for money */
  36.         1,      /* currency symbol 1 precedes 0 succeeds positive value */
  37.         1,      /* 1=space 0=no space between currency symbol and pos. value */
  38.         1,      /* currency symbol 1 precedes 0 succeeds neg. value */
  39.         0,      /* 1=space 0=no space between currency symbol and neg. value */
  40.         1,      /* position of sign in postive money values (???) */
  41.         1       /* position of sign in negative money values (???) */
  42. };
  43.  
  44. /* current locale info */
  45. static struct lconv _LC_Curlocale;
  46.  
  47. /* time names for current locale: used by strftime.c */
  48. char **_LC_Mth_name = C_mth_name;
  49. char **_LC_Day_name = C_day_name;
  50.  
  51. static int localeset = 0;
  52.  
  53. /* localeconv: return current locale information */
  54.  
  55. struct lconv *localeconv()
  56. {
  57.         if (localeset == 0) {
  58.                 _LC_Curlocale = C_locale;
  59.                 localeset = 1;
  60.         }
  61.         return &_LC_Curlocale;
  62. }
  63.  
  64. /* setlocale: set the locale.
  65.  * FIXME: right now, only "C" is supported.
  66.  */
  67.  
  68. char *setlocale(category, name)
  69.         int category;
  70.         const char *name;
  71. {
  72.         if (name && strcmp(name, "C"))
  73.                 return (char *)0;
  74.  
  75.         if (!localeset) {
  76.                 localeset = 1;
  77.                 _LC_Curlocale = C_locale;
  78.         }
  79.  
  80. /* here's where we usually would change things */
  81.         return "C";
  82. }
  83.