Print this page
2964 need POSIX 2008 locale object support


  18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26  * SUCH DAMAGE.
  27  */
  28 
  29 #include "lint.h"
  30 #include <stddef.h>
  31 #include "ldpart.h"
  32 #include "timelocal.h"
  33 
  34 static struct lc_time_T _time_locale;
  35 static int _time_using_locale;
  36 static char *time_locale_buf;
  37 


  38 #define LCTIME_SIZE (sizeof (struct lc_time_T) / sizeof (char *))
  39 
  40 static const struct lc_time_T   _C_time_locale = {
  41         {
  42                 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  43                 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  44         }, {
  45                 "January", "February", "March", "April", "May", "June",
  46                 "July", "August", "September", "October", "November", "December"
  47         }, {
  48                 "Sun", "Mon", "Tue", "Wed",
  49                 "Thu", "Fri", "Sat"
  50         }, {
  51                 "Sunday", "Monday", "Tuesday", "Wednesday",
  52                 "Thursday", "Friday", "Saturday"
  53         },
  54 
  55         /* X_fmt */
  56         "%H:%M:%S",
  57 


  81         /*
  82          * ampm_fmt - To determine 12-hour clock format time (empty, if N/A)
  83          */
  84         "%I:%M:%S %p"
  85 };
  86 
  87 struct lc_time_T *
  88 __get_current_time_locale(void)
  89 {
  90         return (_time_using_locale ? &_time_locale :
  91             (struct lc_time_T *)&_C_time_locale);
  92 }
  93 
  94 int
  95 __time_load_locale(const char *name)
  96 {
  97         return (__part_load_locale(name, &_time_using_locale,
  98             &time_locale_buf, "LC_TIME", LCTIME_SIZE, LCTIME_SIZE,
  99             (const char **)&_time_locale));
 100 }













  18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26  * SUCH DAMAGE.
  27  */
  28 
  29 #include "lint.h"
  30 #include <stddef.h>
  31 #include "ldpart.h"
  32 #include "timelocal.h"
  33 
  34 static struct lc_time_T _time_locale;
  35 static int _time_using_locale;
  36 static char *time_locale_buf;
  37 
  38 struct xlocale_time __xlocale_global_time;
  39 
  40 #define LCTIME_SIZE (sizeof (struct lc_time_T) / sizeof (char *))
  41 
  42 static const struct lc_time_T   _C_time_locale = {
  43         {
  44                 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  45                 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  46         }, {
  47                 "January", "February", "March", "April", "May", "June",
  48                 "July", "August", "September", "October", "November", "December"
  49         }, {
  50                 "Sun", "Mon", "Tue", "Wed",
  51                 "Thu", "Fri", "Sat"
  52         }, {
  53                 "Sunday", "Monday", "Tuesday", "Wednesday",
  54                 "Thursday", "Friday", "Saturday"
  55         },
  56 
  57         /* X_fmt */
  58         "%H:%M:%S",
  59 


  83         /*
  84          * ampm_fmt - To determine 12-hour clock format time (empty, if N/A)
  85          */
  86         "%I:%M:%S %p"
  87 };
  88 
  89 struct lc_time_T *
  90 __get_current_time_locale(void)
  91 {
  92         return (_time_using_locale ? &_time_locale :
  93             (struct lc_time_T *)&_C_time_locale);
  94 }
  95 
  96 int
  97 __time_load_locale(const char *name)
  98 {
  99         return (__part_load_locale(name, &_time_using_locale,
 100             &time_locale_buf, "LC_TIME", LCTIME_SIZE, LCTIME_SIZE,
 101             (const char **)&_time_locale));
 102 }
 103 
 104 void *
 105 __time_load(const char* name, locale_t loc)
 106 {
 107         struct xlocale_time *new;
 108 
 109         new = calloc(sizeof(struct xlocale_time), 1);
 110         /* XXX */
 111 
 112         return (new);
 113 }