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

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

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

int wctomb (char *s, wchar_t wchar)
{
#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 _wctomb (s, wchar, MB_LEN_MAX, &shift);
}
