langinfo.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*++
  2. Copyright (c) 2015 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. langinfo.c
  9. Abstract:
  10. This module implements support for getting locale-specific messages.
  11. Author:
  12. Evan Green 21-Jan-2015
  13. Environment:
  14. User Mode C Library
  15. --*/
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include "libcp.h"
  20. #include <langinfo.h>
  21. //
  22. // ---------------------------------------------------------------- Definitions
  23. //
  24. //
  25. // Define the maximum valid langinfo item value.
  26. //
  27. #define LANGINFO_MAX D_MD_ORDER
  28. //
  29. // ------------------------------------------------------ Data Type Definitions
  30. //
  31. //
  32. // ----------------------------------------------- Internal Function Prototypes
  33. //
  34. //
  35. // -------------------------------------------------------------------- Globals
  36. //
  37. PSTR ClPosixLangInfo[LANGINFO_MAX + 1] = {
  38. "UTF-8",
  39. "%b %a %d %k:%M%S %Z %Y",
  40. "%b %a %d",
  41. "%H:%M",
  42. "%I:%M:%S %p",
  43. "AM",
  44. "PM",
  45. "Sunday",
  46. "Monday",
  47. "Tuesday",
  48. "Wednesday",
  49. "Thursday",
  50. "Friday",
  51. "Saturday",
  52. "Sun",
  53. "Mon",
  54. "Tue",
  55. "Wed",
  56. "Thu",
  57. "Fri",
  58. "Sat",
  59. "January",
  60. "February",
  61. "March",
  62. "April",
  63. "May",
  64. "June",
  65. "July",
  66. "August",
  67. "September",
  68. "October",
  69. "November",
  70. "December",
  71. "Jan",
  72. "Feb",
  73. "Mar",
  74. "Apr",
  75. "May",
  76. "Jun",
  77. "Jul",
  78. "Aug",
  79. "Sep",
  80. "Oct",
  81. "Nov",
  82. "Dec",
  83. "",
  84. "",
  85. "",
  86. "",
  87. "",
  88. ".",
  89. "",
  90. "^[yY]",
  91. "^[nN]",
  92. "$",
  93. "md"
  94. };
  95. //
  96. // ------------------------------------------------------------------ Functions
  97. //
  98. LIBC_API
  99. char *
  100. nl_langinfo (
  101. nl_item Item
  102. )
  103. /*++
  104. Routine Description:
  105. This routine returns a pointer to a string containing the relevant message
  106. for the given item.
  107. Arguments:
  108. Item - Supplies the item to get a string for. See definitions in
  109. langinfo.h.
  110. Return Value:
  111. Returns a pointer to a string for the given item. If item is invalid,
  112. returns a pointer to an empty string. If language information is not
  113. defined, returns the string from the POSIX locale. The memory returned here
  114. may be overwritten by subsequent calls.
  115. --*/
  116. {
  117. if (Item > LANGINFO_MAX) {
  118. return NULL;
  119. }
  120. return ClPosixLangInfo[Item];
  121. }
  122. //
  123. // --------------------------------------------------------- Internal Functions
  124. //