Beispiel #1
0
/*
 * Non-MT-safe version.
 */
wint_t
__fputwc(wchar_t wc, FILE *fp, locale_t locale)
{
	char buf[MB_LEN_MAX];
	size_t i, len;
	struct xlocale_ctype *l = XLOCALE_CTYPE(locale);

	if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) {
		/*
		 * Assume single-byte locale with no special encoding.
		 * A more careful test would be to check
		 * _CurrentRuneLocale->encoding.
		 */
		*buf = (unsigned char)wc;
		len = 1;
	} else {
		if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) {
			fp->_flags |= __SERR;
			return (WEOF);
		}
	}

	for (i = 0; i < len; i++)
		if (__sputc((unsigned char)buf[i], fp) == EOF)
			return (WEOF);

	return ((wint_t)wc);
}
Beispiel #2
0
EXPORT_C int
putc (int c,register FILE *fp)
{
  /* CHECK_INIT is (eventually) called by __swbuf.  */

  return __sputc (c, fp);
}
Beispiel #3
0
int
putc_unlocked(int c, FILE *fp)
{
	if (cantwrite(fp)) {
		errno = EBADF;
		return (EOF);
	}
	return (__sputc(c, fp));
}
Beispiel #4
0
int
fputc(int c, FILE *fp)
{
	int retval;
	FLOCKFILE(fp);
	retval = __sputc(c, fp);
	FUNLOCKFILE(fp);
	return (retval);
}
Beispiel #5
0
int
putc_unlocked(int c, FILE *fp)
{
	if (cantwrite(fp)) {
		errno = EBADF;
		return (EOF);
	}
	_SET_ORIENTATION(fp, -1);
	return (__sputc(c, fp));
}
Beispiel #6
0
int fputc(int c, FILE *fp)
{
	int retval;
	FLOCKFILE(fp);
	/* Orientation set by __sputc() when buffer is full. */
	/* ORIENT(fp, -1); */
	retval = __sputc(c, fp);
	FUNLOCKFILE(fp);
	return (retval);
}
/*
 * A subroutine version of the macro putchar
 */
int
putchar(int c)
{
	register int r;

        EXCL_START(&stdout->_file_lock);
	r = __sputc(c, stdout);
        EXCL_END(&stdout->_file_lock);
	return r;
}
Beispiel #8
0
int
putc_unlocked(int c, FILE *fp)
{
  _DIAGASSERT(fp != NULL);
  if(fp == NULL) {
    errno = EINVAL;
    return (EOF);
  }

  return (__sputc(c, fp));
}
Beispiel #9
0
/*
 * A subroutine version of the macro putchar
 */
int
putchar(int c)
{
	int retval;
	FILE *so = stdout;

	FLOCKFILE(so);
	retval = __sputc(c, so);
	FUNLOCKFILE(so);
	return (retval);
}
Beispiel #10
0
int
fputc(int c, FILE *fp)
{
    int r;

    _DIAGASSERT(fp != NULL);

    FLOCKFILE(fp);
    r = __sputc(c, fp);
    FUNLOCKFILE(fp);
    return r;
}
Beispiel #11
0
/*
 * A subroutine version of the macro putchar
 */
EXPORT_C int
putchar(int c)
{
	int retval;
	FILE *so = stdout;

	FLOCKFILE(so);
	/* Orientation set by __sputc() when buffer is full. */
	/* ORIENT(so, -1); */
	retval = __sputc(c, so);
	FUNLOCKFILE(so);
	return (retval);
}
Beispiel #12
0
int
putc(int c, FILE *fp)
{
  int r;

  _DIAGASSERT(fp != NULL);
  if(fp == NULL) {
    errno = EINVAL;
    return (EOF);
  }

  FLOCKFILE(fp);
  r = __sputc(c, fp);
  FUNLOCKFILE(fp);
  return r;
}
Beispiel #13
0
int
fputc(int c, FILE *fp)
{
  int r;

  _DIAGASSERT(fp != NULL);

  if(fp != NULL) {
  FLOCKFILE(fp);
  r = __sputc(c, fp);
  FUNLOCKFILE(fp);
  }
  else {
    r = EOF;
    errno = ENOSTR;
  }
  return r;
}
Beispiel #14
0
/*
 * Non-MT-safe version.
 */
wint_t
__fputwc(wchar_t wc, FILE *fp, locale_t locale)
{
	char buf[MB_LEN_MAX];
	size_t i, len;
	struct xlocale_ctype *l = XLOCALE_CTYPE(locale);

	if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) {
		fp->_flags |= __SERR;
		return (WEOF);
	}

	for (i = 0; i < len; i++)
		if (__sputc((unsigned char)buf[i], fp) == EOF)
			return (WEOF);

	return ((wint_t)wc);
}
Beispiel #15
0
/*
 * Non-MT-safe version.
 */
wint_t
__fputwc(wchar_t wc, FILE *fp, locale_t locale)
{
	struct wchar_io_data *wcio;
	mbstate_t *st;
	char buf[MB_LEN_MAX];
	size_t i, len;
	struct xlocale_ctype *l = XLOCALE_CTYPE(locale);

	ORIENT(fp, 1);
	wcio = WCIO_GET(fp);
	if (wcio == NULL) {
		errno = ENOMEM;
		return WEOF;
	}

	wcio->wcio_ungetwc_inbuf = 0;
	st = &wcio->wcio_mbstate_out;

	if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) {
		/*
		 * Assume single-byte locale with no special encoding.
		 * A more careful test would be to check
		 * _CurrentRuneLocale->encoding.
		 */
		*buf = (unsigned char)wc;
		len = 1;
	} else {
		if ((len = l->__wcrtomb(buf, wc, st)) == (size_t)-1) {
			fp->pub._flags |= __SERR;
			return (WEOF);
		}
	}

	for (i = 0; i < len; i++)
		if (__sputc((unsigned char)buf[i], fp) == EOF)
			return (WEOF);

	return ((wint_t)wc);
}
int
pd_putchar_unlocked_p(int ch)
{

	return (__sputc(ch, stdout));
}
Beispiel #17
0
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/

#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "%W% (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */

#include <_ansi.h>
#include <stdio.h>
#include "local.h"

/*
 * A subroutine version of the macro putc.
 */

#undef putc

int
_DEFUN(putc, (c, fp),
       int c _AND
       register FILE *fp)
{
  int result;
  CHECK_INIT (_REENT, fp);
  _flockfile (fp);
  result = __sputc (c, fp);
  _funlockfile (fp);
  return result;
}
int
pd_putc_unlocked_p(int ch, FILEpd *fp)
{

	return (__sputc(ch, fp));
}