1: 
    2: 
    3: 
    4:     5:     6:     7:     8:     9:    10:    11:    12:    13:    14:    15:    16:    17:    18:    19:    20:    21:    22:    23:    24:    25:    26:    27:    28: 
   29: 
   30: #include <sys/cdefs.h>
   31: #include <sys/types.h>
   32: #include <errno.h>
   33: #include <wchar.h>
   34: 
   35: #include "citrus_ctype.h"
   36: #include "rune.h"
   37: #include "multibyte.h"
   38: 
   39: int
   40: mbsinit(const mbstate_t *ps)
   41: {
   42:         struct _citrus_ctype_rec *cc;
   43:         _RuneLocale *rl;
   44: 
   45:         if (ps == NULL)
   46:                 return 1;
   47: 
   48:         rl = _ps_to_runelocale(ps);
   49:         if (rl == NULL)
   50:                 rl = _CurrentRuneLocale;
   51:         cc = rl->rl_citrus_ctype;
   52:         return (*cc->cc_ops->co_mbsinit)(ps);
   53: }
   54: 
   55: size_t
   56: mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
   57: {
   58:         static mbstate_t mbs;
   59:         struct _citrus_ctype_rec *cc;
   60: 
   61:         if (ps == NULL)
   62:                 ps = &mbs;
   63:         cc = _CurrentRuneLocale->rl_citrus_ctype;
   64:         return (*cc->cc_ops->co_mbrtowc)(pwc, s, n, _ps_to_private(ps));
   65: }
   66: 
   67: size_t
   68: mbsrtowcs(wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps)
   69: {
   70:         static mbstate_t mbs;
   71:         struct _citrus_ctype_rec *cc;
   72: 
   73:         if (ps == NULL)
   74:                 ps = &mbs;
   75:         cc = _CurrentRuneLocale->rl_citrus_ctype;
   76:         return (*cc->cc_ops->co_mbsrtowcs)(pwcs, s, n, _ps_to_private(ps));
   77: }
   78: 
   79: size_t
   80: wcrtomb(char *s, wchar_t wc, mbstate_t *ps)
   81: {
   82:         static mbstate_t mbs;
   83:         struct _citrus_ctype_rec *cc;
   84: 
   85:         if (ps == NULL)
   86:                 ps = &mbs;
   87:         cc = _CurrentRuneLocale->rl_citrus_ctype;
   88:         return (*cc->cc_ops->co_wcrtomb)(s, wc, _ps_to_private(ps));
   89: }
   90: 
   91: size_t
   92: wcsrtombs(char *s, const wchar_t **ppwcs, size_t n, mbstate_t *ps)
   93: {
   94:         static mbstate_t mbs;
   95:         struct _citrus_ctype_rec *cc;
   96: 
   97:         if (ps == NULL)
   98:                 ps = &mbs;
   99:         cc = _CurrentRuneLocale->rl_citrus_ctype;
  100:         return (*cc->cc_ops->co_wcsrtombs)(s, ppwcs, n, _ps_to_private(ps));
  101: }