OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [stdio/] [fwide.c] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
<<fwide>>---set and determine the orientation of a FILE stream
4
 
5
INDEX
6
        fwide
7
INDEX
8
        _fwide_r
9
 
10
ANSI_SYNOPSIS
11
        #include <wchar.h>
12
        int fwide(FILE *<[fp]>, int <[mode]>)
13
 
14
        int _fwide_r(struct _reent *<[ptr]>, FILE *<[fp]>, int <[mode]>)
15
 
16
TRAD_SYNOPSIS
17
        #include <wchar.h>
18
        int fwide(<[fp]>, <[mode]>)
19
        FILE *<[fp]>;
20
        int <[mode]>;
21
 
22
        int fwide(<[ptr]>, <[fp]>, <[mode]>)
23
        struct _reent *<[ptr]>;
24
        FILE *<[fp]>;
25
        int <[mode]>;
26
 
27
DESCRIPTION
28
When <[mode]> is zero, the <<fwide>> function determines the current
29
orientation of <[fp]>. It returns a value > 0 if <[fp]> is
30
wide-character oriented, i.e. if wide character I/O is permitted but
31
char I/O is disallowed. It returns a value < 0 if <[fp]> is byte
32
oriented, i.e. if char I/O is permitted but wide character I/O is
33
disallowed. It returns zero if <[fp]> has no orientation yet; in
34
this case the next I/O operation might change the orientation (to byte
35
oriented if it is a char I/O operation, or to wide-character oriented
36
if it is a wide character I/O operation).
37
 
38
Once a stream has an orientation, it cannot be changed and persists
39
until the stream is closed, unless the stream is re-opened with freopen,
40
which removes the orientation of the stream.
41
 
42
When <[mode]> is non-zero, the <<fwide>> function first attempts to set
43
<[fp]>'s orientation (to wide-character oriented if <[mode]> > 0, or to
44
byte oriented if <[mode]> < 0). It then returns a value denoting the
45
current orientation, as above.
46
 
47
RETURNS
48
The <<fwide>> function returns <[fp]>'s orientation, after possibly
49
changing it. A return value > 0 means wide-character oriented. A return
50
value < 0 means byte oriented. A return value of zero means undecided.
51
 
52
PORTABILITY
53
C99, POSIX.1-2001.
54
 
55
*/
56
 
57
#include <_ansi.h>
58
#include <wchar.h>
59
#include "local.h"
60
 
61
int
62
_DEFUN(_fwide_r, (ptr, fp, mode),
63
        struct _reent *ptr _AND
64
        FILE *fp _AND
65
        int mode)
66
{
67
  int ret;
68
 
69
  CHECK_INIT(ptr, fp);
70
 
71
  _flockfile (fp);
72
  if (mode != 0) {
73
    ORIENT (fp, mode);
74
  }
75
  if (!(fp->_flags & __SORD))
76
    ret = 0;
77
  else
78
    ret = (fp->_flags2 & __SWID) ? 1 : -1;
79
  _funlockfile (fp);
80
  return ret;
81
}
82
 
83
int
84
_DEFUN(fwide, (fp, mode),
85
        FILE *fp _AND
86
        int mode)
87
{
88
  return _fwide_r (_REENT, fp, mode);
89
}

powered by: WebSVN 2.1.0

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