-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstdio_h.rpgle
186 lines (171 loc) · 9.24 KB
/
stdio_h.rpgle
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*- +
* Copyright (c) 2003-2006 Scott C. Klement +
* All rights reserved. +
* +
* Redistribution and use in source and binary forms, with or without +
* modification, are permitted provided that the following conditions +
* are met: +
* 1. Redistributions of source code must retain the above copyright +
* notice, this list of conditions and the following disclaimer. +
* 2. Redistributions in binary form must reproduce the above copyright +
* notice, this list of conditions and the following disclaimer in the +
* documentation and/or other materials provided with the distribution. +
* +
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +
* SUCH DAMAGE. +
* +
*/ +
/if defined(STDIO_H)
/eof
/endif
/define STDIO_H
*-----------------------------------------------------------------
* Data types
*-----------------------------------------------------------------
D pFILE S * based(prototype_only)
D stdin s like(pFILE)
D import('_C_IFS_stdin')
D stdout s like(pFILE)
D import('_C_IFS_stdout')
D stderr s like(pFILE)
D import('_C_IFS_stderr')
*-----------------------------------------------------------------
* fopen(): Open File for buffered reading/writing
*
* filename = (input) path to file in the IFS
* mode = (input) various open mode flags. (see manual)
*
* returns *NULL upon error, or a pointer to a FILE structure
*-----------------------------------------------------------------
D fopen PR ExtProc('_C_IFS_fopen')
D like(pFILE)
D filename * value options(*string)
D mode * value options(*string)
*-----------------------------------------------------------------
* fgets(): read a string
*
* string = (output) string read (null-terminated)
* size = (input) maximum size that can be stored in string
* stream = (input) FILE structure to read data from
*
* returns a pointer to the string read from the file
* or *NULL upon EOF or error.
*-----------------------------------------------------------------
D fgets PR * ExtProc('_C_IFS_fgets')
D string * value
D size 10I 0 value
D stream like(pFILE) value
*-----------------------------------------------------------------
* fputs(): Write string
*
* string = (input) string to write to file
* stream = (input) FILE structure designating the file to
* write to.
*
* returns a non-negative value if successful
* or -1 upon error
*-----------------------------------------------------------------
D fputs PR 10I 0 ExtProc('_C_IFS_fputs')
D string * value options(*string)
D stream like(pFILE) value
*-----------------------------------------------------------------
* fread(): Read items
*
* data = (input) data items to read
* size = (input) size of each data item
* count = (input) number of data items
* stream = (input) pointer to FILE structure to read from
*
* returns the number of full items read, a short count
* indicates an error.
*-----------------------------------------------------------------
D fread PR 10U 0 ExtProc('_C_IFS_fread')
D data * value
D size 10U 0 value
D count 10U 0 value
D stream like(pFILE) value
*-----------------------------------------------------------------
* fwrite(): Write items
*
* data = (input) data items to write
* size = (input) size of each data item
* count = (input) number of data items
* stream = (input) pointer to FILE structure to write to
*
* returns the number of full items written. A short count
* indicates an error.
*-----------------------------------------------------------------
D fwrite PR 10U 0 ExtProc('_C_IFS_fwrite')
D data * value
D size 10U 0 value
D count 10U 0 value
D stream like(pFILE) value
*-----------------------------------------------------------------
* fflush(): Flush a stream
*
* stream = (input) pointer to FILE structure to flush
*
* returns 0 if successful, -1 otherwise
*-----------------------------------------------------------------
D fflush PR 10U 0 ExtProc('_C_IFS_fflush')
D stream like(pFILE) value
*-----------------------------------------------------------------
* fclose(): Close File
*
* stream = (input) pointer to FILE structure to close
*-----------------------------------------------------------------
D fclose PR 10I 0 ExtProc('_C_IFS_fclose')
D stream like(pFILE) value
*-----------------------------------------------------------------
* fseek(): Reposition a file
*
* stream = (input) pointer to FILE structure to reposition
* offset = (input) offset from "whence" in bytes
* whence = (input) position to begin offset at, can be
* SEEK_SET, SEEK_END or SEEK_CUR
*
* returns 0 if successful, -1 otherwise
*-----------------------------------------------------------------
D fseek PR 10I 0 ExtProc('_C_IFS_fseek')
D stream like(pFILE) value
D offset 10I 0 value
D whence 10I 0 value
/if not defined(SEEK_WHENCE_VALUES)
D SEEK_SET C CONST(0)
D SEEK_CUR C CONST(1)
D SEEK_END C CONST(2)
/define SEEK_WHENCE_VALUES
/endif
*-----------------------------------------------------------------
* ftell(): Get Current position
*
* stream = (input) pointer to FILE structure
*
* returns the file position, or -1 upon error
*-----------------------------------------------------------------
D ftell PR 10I 0 ExtProc('_C_IFS_ftell')
D stream like(pFILE) value
*-----------------------------------------------------------------
* fdopen(): Upgrade a file descriptor to a buffered stream
*
* fildes = (input) file descriptor to upgrade
* mode = (input) mode, equivalent to the mode specified
* on the fopen() API, except that it must be
* compatible with the flags that were used on
* the open() API.
*
* Returns a new pointer to a buffered stream I/O file
* or *NULL upon error.
*-----------------------------------------------------------------
D fdopen pr * extproc('fdopen')
D fildes 10I 0 value
D mode * value options(*string)