31 #include <errno.h>
32 #include "ldpart.h"
33 #include "lmessages.h"
34 #include "localeimpl.h"
35
36 #define LCMESSAGES_SIZE_FULL (sizeof (struct lc_messages) / sizeof (char *))
37 #define LCMESSAGES_SIZE_MIN \
38 (offsetof(struct lc_messages, yesstr) / sizeof (char *))
39
40 static char empty[] = "";
41
42 struct lc_messages lc_messages_posix = {
43 "^[yY]", /* yesexpr */
44 "^[nN]", /* noexpr */
45 "yes", /* yesstr */
46 "no" /* nostr */
47 };
48
49 struct locdata __posix_messages_locdata = {
50 .l_lname = "C",
51 .l_refcnt = (uint32_t)-1,
52 .l_data = { &lc_messages_posix }
53 };
54
55 struct locdata *
56 __lc_messages_load(const char *name)
57 {
58 struct locdata *ldata;
59 struct lc_messages *lmsgs;
60 int ret;
61
62 if ((ldata = __locdata_alloc(name, sizeof (*lmsgs))) == NULL)
63 return (NULL);
64 lmsgs = ldata->l_data[0];
65
66 ret = __part_load_locale(name, (char **)&ldata->l_data[1],
67 "LC_MESSAGES", LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN,
68 (const char **)lmsgs);
69
70 if (ret != _LDP_LOADED) {
71 __locdata_release(ldata);
72 errno = EINVAL;
73 return (NULL);
74 }
75
76 if (lmsgs->yesstr == NULL)
77 lmsgs->yesstr = empty;
78 if (lmsgs->nostr == NULL)
79 lmsgs->nostr = empty;
80
81 return (ldata);
82 }
|
31 #include <errno.h>
32 #include "ldpart.h"
33 #include "lmessages.h"
34 #include "localeimpl.h"
35
36 #define LCMESSAGES_SIZE_FULL (sizeof (struct lc_messages) / sizeof (char *))
37 #define LCMESSAGES_SIZE_MIN \
38 (offsetof(struct lc_messages, yesstr) / sizeof (char *))
39
40 static char empty[] = "";
41
42 struct lc_messages lc_messages_posix = {
43 "^[yY]", /* yesexpr */
44 "^[nN]", /* noexpr */
45 "yes", /* yesstr */
46 "no" /* nostr */
47 };
48
49 struct locdata __posix_messages_locdata = {
50 .l_lname = "C",
51 .l_data = { &lc_messages_posix }
52 };
53
54 struct locdata *
55 __lc_messages_load(const char *name)
56 {
57 struct locdata *ldata;
58 struct lc_messages *lmsgs;
59 int ret;
60
61 if ((ldata = __locdata_alloc(name, sizeof (*lmsgs))) == NULL)
62 return (NULL);
63 lmsgs = ldata->l_data[0];
64
65 ret = __part_load_locale(name, (char **)&ldata->l_data[1],
66 "LC_MESSAGES", LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN,
67 (const char **)lmsgs);
68
69 if (ret != _LDP_LOADED) {
70 __locdata_free(ldata);
71 errno = EINVAL;
72 return (NULL);
73 }
74
75 if (lmsgs->yesstr == NULL)
76 lmsgs->yesstr = empty;
77 if (lmsgs->nostr == NULL)
78 lmsgs->nostr = empty;
79
80 return (ldata);
81 }
|