PageRenderTime 23ms CodeModel.GetById 8ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/libc/src/libio.inc

https://github.com/slibre/freepascal
Pascal | 83 lines | 52 code | 17 blank | 14 comment | 4 complexity | 5538dcfdccd38ca38391641f62884f2a MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
 1{ ---------------------------------------------------------------------
 2    Macros from libio.h
 3  ---------------------------------------------------------------------}
 4
 5Function _IO_getc_unlocked(_fp: P_IO_FILE): longint;
 6begin
 7  if _fp^._IO_read_ptr>=_fp^._IO_read_end then
 8    Result:=__uflow(_fp)
 9  else
10    begin
11    Result:=PByte(_fp^._IO_read_ptr)^;
12    Inc(_fp^._IO_read_ptr);
13    end;
14end;
15
16
17Function _IO_peekc_unlocked(_fp: P_IO_FILE): longint;
18begin
19  if (_fp^._IO_read_ptr>=_fp^._IO_read_end) and (__underflow(_fp) = __EOF) then
20    Result:=__EOF
21  else
22    Result:=PByte(_fp^._IO_read_ptr)^;
23end;
24
25
26Function _IO_putc_unlocked(_ch: Char; _fp: P_IO_FILE): longint;
27begin
28  if _fp^._IO_write_ptr>=_fp^._IO_write_end then
29    Result:=__overflow(_fp, Byte(_ch))
30  else
31    begin
32    Result:=Byte(_ch);
33    _fp^._IO_write_ptr^:=_ch;
34    Inc(_fp^._IO_write_ptr);
35    end;
36end;
37
38
39Function _IO_getwc_unlocked(_fp: P_IO_FILE): longint;
40begin
41  if Cardinal(_fp^._wide_data^._IO_read_ptr)>=Cardinal(_fp^._wide_data^._IO_read_end) then
42    Result:=__wuflow(_fp)
43  else
44    begin
45//!! MVC    Result:=_fp^._wide_data^._IO_read_ptr^;
46    Inc(_fp^._wide_data^._IO_read_ptr);
47    end;
48end;
49
50
51Function _IO_putwc_unlocked(_wch: wchar_t; _fp: P_IO_FILE): longint;
52begin
53{ //!! MVC
54  if Cardinal(_fp^._wide_data^._IO_write_ptr)>=Cardinal(_fp^._wide_data^._IO_write_end) then
55    Result:=__woverflow(_fp, _wch)
56  else
57    begin
58    Result:=_wch;
59    _fp^._wide_data^._IO_write_ptr^:=_wch;
60    Inc(_fp^._wide_data^._IO_write_ptr);
61    end;
62}
63end;
64
65
66Function _IO_feof_unlocked(_fp: P_IO_FILE): longint;
67begin
68  Result:=Ord((_fp^._flags and _IO_EOF_SEEN)<>0);
69end;
70
71
72Function _IO_ferror_unlocked(_fp: P_IO_FILE): longint;
73begin
74  Result:=Ord((_fp^._flags and _IO_ERR_SEEN)<>0);
75end;
76
77
78Function _IO_PENDING_OUTPUT_COUNT(_fp: P_IO_FILE): longint;
79begin
80  Result:=(_fp^._IO_write_ptr)-(_fp^._IO_write_base);
81end;
82
83