summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/libc/src/libio.inc
blob: 743efa294b24f457f5465d1e5d85c6227231818c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ ---------------------------------------------------------------------
    Macros from libio.h
  ---------------------------------------------------------------------}

Function _IO_getc_unlocked(_fp: P_IO_FILE): longint;
begin
  if _fp^._IO_read_ptr>=_fp^._IO_read_end then
    Result:=__uflow(_fp)
  else
    begin
    Result:=PByte(_fp^._IO_read_ptr)^;
    Inc(_fp^._IO_read_ptr);
    end;
end;


Function _IO_peekc_unlocked(_fp: P_IO_FILE): longint;
begin
  if (_fp^._IO_read_ptr>=_fp^._IO_read_end) and (__underflow(_fp) = __EOF) then
    Result:=__EOF
  else
    Result:=PByte(_fp^._IO_read_ptr)^;
end;


Function _IO_putc_unlocked(_ch: Char; _fp: P_IO_FILE): longint;
begin
  if _fp^._IO_write_ptr>=_fp^._IO_write_end then
    Result:=__overflow(_fp, Byte(_ch))
  else
    begin
    Result:=Byte(_ch);
    _fp^._IO_write_ptr^:=_ch;
    Inc(_fp^._IO_write_ptr);
    end;
end;


Function _IO_getwc_unlocked(_fp: P_IO_FILE): longint;
begin
  if Cardinal(_fp^._wide_data^._IO_read_ptr)>=Cardinal(_fp^._wide_data^._IO_read_end) then
    Result:=__wuflow(_fp)
  else
    begin
//!! MVC    Result:=_fp^._wide_data^._IO_read_ptr^;
    Inc(_fp^._wide_data^._IO_read_ptr);
    end;
end;


Function _IO_putwc_unlocked(_wch: wchar_t; _fp: P_IO_FILE): longint;
begin
{ //!! MVC
  if Cardinal(_fp^._wide_data^._IO_write_ptr)>=Cardinal(_fp^._wide_data^._IO_write_end) then
    Result:=__woverflow(_fp, _wch)
  else
    begin
    Result:=_wch;
    _fp^._wide_data^._IO_write_ptr^:=_wch;
    Inc(_fp^._wide_data^._IO_write_ptr);
    end;
}
end;


Function _IO_feof_unlocked(_fp: P_IO_FILE): longint;
begin
  Result:=Ord((_fp^._flags and _IO_EOF_SEEN)<>0);
end;


Function _IO_ferror_unlocked(_fp: P_IO_FILE): longint;
begin
  Result:=Ord((_fp^._flags and _IO_ERR_SEEN)<>0);
end;


Function _IO_PENDING_OUTPUT_COUNT(_fp: P_IO_FILE): longint;
begin
  Result:=(_fp^._IO_write_ptr)-(_fp^._IO_write_base);
end;