Debian Codegraph @

libgcobol/io.h

raw
1 /*
2 * Copyright (c) 2021-2025 Symas Corporation
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of the Symas Corporation nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /*
32 * File status key values and meanings
33 * 0 Successful completion
34 * 0 No further information
35 * 2 Duplicate key READ
36 * 4 Short/long READ
37 * 5 OPEN optional file unavailable
38 * 7 Not a tape
39 * 1 At-end condition
40 * 0 Sequential READ EOF
41 * 4 Relative record too big
42 * 2 Invalid key condition
43 * 1 Sequence error
44 * 2 Duplicate key WRITE
45 * 3 Record not found
46 * 4 Sequential WRITE EOF
47 * 3 Permanent error
48 * 0 No further information
49 * 1 Filename inconsistent with operating system
50 * 4 Boundary violation
51 * 5 OPEN nonoptional file unavailable
52 * 7 OPEN EACCES
53 * 8 OPEN file previously closed with lock
54 * 9 OPEN wrong file type
55 * 4 Logic error condition
56 * 1 OPEN file already open
57 * 2 CLOSE file not open
58 * 3 REWRITE without prior READ
59 * 4 REWRITE/WRITE boundary violation
60 * 6 READ after failed READ
61 * 7 File not open for READ
62 * 8 File not open for WRITE
63 * 9 File not open for DELETE/REWRITE
64 * 9 Implementor-defined
65 * 0 VSAM/QSAM close on wrong thread
66 * 1 VSAM password failure
67 * 2 Logic error
68 * 3 Resource unavailable
69 * 5 Incomplete file information
70 * 6 VSAM no DD statement
71 * 7 VSAM File integrity verified
72 * 8 OPEN invalid environment variable contents
73 */
74
75 #ifndef IO_H_
76 #define IO_H_
77
78 enum file_high_t {
79 FhSuccess = 0,
80 FhAtEnd = 1,
81 FhInvKey = 2,
82 FhOsError = 3,
83 FhLogicError = 4,
84 FhImplementor = 9,
85 };
86
87 enum file_status_t {
88 FsSuccess = FhSuccess,
89 FsDupRead = (FhSuccess * 10) + 2, // First digit is 0
90 FsRecordLength= (FhSuccess * 10) + 4,
91 FsUnavail = (FhSuccess * 10) + 5,
92 FsNotaTape = (FhSuccess * 10) + 7,
93
94 FsEofSeq = (FhAtEnd * 10) + 0, // First digit is 1
95 FsEofRel = (FhAtEnd * 10) + 4,
96
97 FsKeySeq = (FhInvKey * 10) + 1, // First digit is 2
98 FsDupWrite = (FhInvKey * 10) + 2,
99 FsNotFound = (FhInvKey * 10) + 3,
100 FsEofWrite = (FhInvKey * 10) + 4,
101
102 FsOsError = (FhOsError * 10) + 0, // First digit is 3
103 FsNameError = (FhOsError * 10) + 1,
104 FsBoundary = (FhOsError * 10) + 4,
105 FsNoFile = (FhOsError * 10) + 5,
106 FsNoAccess = (FhOsError * 10) + 7,
107 FsCloseLock = (FhOsError * 10) + 8,
108 FsWrongType = (FhOsError * 10) + 9,
109
110 FsLogicErr = (FhLogicError * 10) + 0, // First digit is 4
111 FsIsOpen = (FhLogicError * 10) + 1,
112 FsCloseNotOpen= (FhLogicError * 10) + 2,
113 FsNoRead = (FhLogicError * 10) + 3,
114 FsBoundWrite = (FhLogicError * 10) + 4,
115 FsReadError = (FhLogicError * 10) + 6,
116 FsReadNotOpen = (FhLogicError * 10) + 7,
117 FsNoWrite = (FhLogicError * 10) + 8,
118 FsNoDelete = (FhLogicError * 10) + 9,
119
120 FsWrongThread = (FhImplementor * 10) + 0, // First digit is 9
121 FsPassword = (FhImplementor * 10) + 1,
122 FsLogicOther = (FhImplementor * 10) + 2,
123 FsNoResource = (FhImplementor * 10) + 3,
124 FsIncomplete = (FhImplementor * 10) + 5,
125 FsNoDD = (FhImplementor * 10) + 6,
126 FsVsamOK = (FhImplementor * 10) + 7,
127 FsBadEnvVar = (FhImplementor * 10) + 8,
128
129 FsErrno = (1000000) // This means "map errno to one of the above errors"
130 };
131
132 #define FhNotOkay FsEofSeq // Values less than 10 mean the data are valid
133
134 extern "C" file_status_t __gg__file_status_word(enum file_status_t status,
135 int error_number);
136
137 #endif