/* mbtowc.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */

#include <stdlib.h>
#include <emx/thread.h>
#include <emx/locale.h>

#if defined (__MT__)
#define shift tp->_th_mbtowc_shift
#else
static int shift = 0;
#endif


int mbtowc (wchar_t *pwc, const char *s, size_t n)
{
#if defined (__MT__)
  struct _thread *tp = _thread ();
#endif

  if (s == NULL)
    {
      if (_cur_mbyte.mode == _MB_SHIFT)
        {
          shift = 0;
          return 1;             /* State dependency */
        }
      else
        return 0;               /* No state dependency */
    }
  return _mbtowc (pwc, s, n, &shift);
}
