Esempio n. 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);
}
Esempio n. 2
0
EXPORT_C int
putc (int c,register FILE *fp)
{
  /* CHECK_INIT is (eventually) called by __swbuf.  */

  return __sputc (c, fp);
}
Esempio n. 3
0
int
putc_unlocked(int c, FILE *fp)
{
	if (cantwrite(fp)) {
		errno = EBADF;
		return (EOF);
	}
	return (__sputc(c, fp));
}
Esempio n. 4
0
int
fputc(int c, FILE *fp)
{
	int retval;
	FLOCKFILE(fp);
	retval = __sputc(c, fp);
	FUNLOCKFILE(fp);
	return (retval);
}
Esempio n. 5
0
int
putc_unlocked(int c, FILE *fp)
{
	if (cantwrite(fp)) {
		errno = EBADF;
		return (EOF);
	}
	_SET_ORIENTATION(fp, -1);
	return (__sputc(c, fp));
}
Esempio n. 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);
}
Esempio n. 7
0
/*
 * 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;
}
Esempio n. 8
0
int
putc_unlocked(int c, FILE *fp)
{
  _DIAGASSERT(fp != NULL);
  if(fp == NULL) {
    errno = EINVAL;
    return (EOF);
  }

  return (__sputc(c, fp));
}
Esempio n. 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);
}
Esempio n. 10
0
int
fputc(int c, FILE *fp)
{
    int r;

    _DIAGASSERT(fp != NULL);

    FLOCKFILE(fp);
    r = __sputc(c, fp);
    FUNLOCKFILE(fp);
    return r;
}
Esempio n. 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);
}
Esempio n. 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;
}
Esempio n. 13
0
File: fputc.c Progetto: etiago/vbox
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;
}
Esempio n. 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);
}
Esempio n. 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);
}
Esempio n. 16
0
int
pd_putchar_unlocked_p(int ch)
{

	return (__sputc(ch, stdout));
}
Esempio n. 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;
}
Esempio n. 18
0
int
pd_putc_unlocked_p(int ch, FILEpd *fp)
{

	return (__sputc(ch, fp));
}