OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [stdio/] [fwide.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/*
/*
FUNCTION
FUNCTION
<<fwide>>---set and determine the orientation of a FILE stream
<<fwide>>---set and determine the orientation of a FILE stream
 
 
INDEX
INDEX
        fwide
        fwide
INDEX
INDEX
        _fwide_r
        _fwide_r
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <wchar.h>
        #include <wchar.h>
        int fwide(FILE *<[fp]>, int <[mode]>)
        int fwide(FILE *<[fp]>, int <[mode]>)
 
 
        int _fwide_r(struct _reent *<[ptr]>, FILE *<[fp]>, int <[mode]>)
        int _fwide_r(struct _reent *<[ptr]>, FILE *<[fp]>, int <[mode]>)
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <wchar.h>
        #include <wchar.h>
        int fwide(<[fp]>, <[mode]>)
        int fwide(<[fp]>, <[mode]>)
        FILE *<[fp]>;
        FILE *<[fp]>;
        int <[mode]>;
        int <[mode]>;
 
 
        int _fwide_r(<[ptr]>, <[fp]>, <[mode]>)
        int _fwide_r(<[ptr]>, <[fp]>, <[mode]>)
        struct _reent *<[ptr]>;
        struct _reent *<[ptr]>;
        FILE *<[fp]>;
        FILE *<[fp]>;
        int <[mode]>;
        int <[mode]>;
 
 
DESCRIPTION
DESCRIPTION
When <[mode]> is zero, the <<fwide>> function determines the current
When <[mode]> is zero, the <<fwide>> function determines the current
orientation of <[fp]>. It returns a value > 0 if <[fp]> is
orientation of <[fp]>. It returns a value > 0 if <[fp]> is
wide-character oriented, i.e. if wide character I/O is permitted but
wide-character oriented, i.e. if wide character I/O is permitted but
char I/O is disallowed. It returns a value < 0 if <[fp]> is byte
char I/O is disallowed. It returns a value < 0 if <[fp]> is byte
oriented, i.e. if char I/O is permitted but wide character I/O is
oriented, i.e. if char I/O is permitted but wide character I/O is
disallowed. It returns zero if <[fp]> has no orientation yet; in
disallowed. It returns zero if <[fp]> has no orientation yet; in
this case the next I/O operation might change the orientation (to byte
this case the next I/O operation might change the orientation (to byte
oriented if it is a char I/O operation, or to wide-character oriented
oriented if it is a char I/O operation, or to wide-character oriented
if it is a wide character I/O operation).
if it is a wide character I/O operation).
 
 
Once a stream has an orientation, it cannot be changed and persists
Once a stream has an orientation, it cannot be changed and persists
until the stream is closed, unless the stream is re-opened with freopen,
until the stream is closed, unless the stream is re-opened with freopen,
which removes the orientation of the stream.
which removes the orientation of the stream.
 
 
When <[mode]> is non-zero, the <<fwide>> function first attempts to set
When <[mode]> is non-zero, the <<fwide>> function first attempts to set
<[fp]>'s orientation (to wide-character oriented if <[mode]> > 0, or to
<[fp]>'s orientation (to wide-character oriented if <[mode]> > 0, or to
byte oriented if <[mode]> < 0). It then returns a value denoting the
byte oriented if <[mode]> < 0). It then returns a value denoting the
current orientation, as above.
current orientation, as above.
 
 
RETURNS
RETURNS
The <<fwide>> function returns <[fp]>'s orientation, after possibly
The <<fwide>> function returns <[fp]>'s orientation, after possibly
changing it. A return value > 0 means wide-character oriented. A return
changing it. A return value > 0 means wide-character oriented. A return
value < 0 means byte oriented. A return value of zero means undecided.
value < 0 means byte oriented. A return value of zero means undecided.
 
 
PORTABILITY
PORTABILITY
C99, POSIX.1-2001.
C99, POSIX.1-2001.
 
 
*/
*/
 
 
#include <_ansi.h>
#include <_ansi.h>
#include <wchar.h>
#include <wchar.h>
#include "local.h"
#include "local.h"
 
 
int
int
_DEFUN(_fwide_r, (ptr, fp, mode),
_DEFUN(_fwide_r, (ptr, fp, mode),
        struct _reent *ptr _AND
        struct _reent *ptr _AND
        FILE *fp _AND
        FILE *fp _AND
        int mode)
        int mode)
{
{
  int ret;
  int ret;
 
 
  CHECK_INIT(ptr, fp);
  CHECK_INIT(ptr, fp);
 
 
  _flockfile (fp);
  _flockfile (fp);
  if (mode != 0) {
  if (mode != 0) {
    ORIENT (fp, mode);
    ORIENT (fp, mode);
  }
  }
  if (!(fp->_flags & __SORD))
  if (!(fp->_flags & __SORD))
    ret = 0;
    ret = 0;
  else
  else
    ret = (fp->_flags2 & __SWID) ? 1 : -1;
    ret = (fp->_flags2 & __SWID) ? 1 : -1;
  _funlockfile (fp);
  _funlockfile (fp);
  return ret;
  return ret;
}
}
 
 
int
int
_DEFUN(fwide, (fp, mode),
_DEFUN(fwide, (fp, mode),
        FILE *fp _AND
        FILE *fp _AND
        int mode)
        int mode)
{
{
  return _fwide_r (_REENT, fp, mode);
  return _fwide_r (_REENT, fp, mode);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.