Debian Codegraph @

melder/abcio.h

raw symbols SCIP
1 #ifndef _abcio_h_
2 #define _abcio_h_
3 /* abcio.h
4 *
5 * Copyright (C) 1992-2011,2015,2017-2020,2022,2024 Paul Boersma
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This code is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this work. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 /* Numeric text input and output. */
22
23 int texgeti8 (MelderReadText text);
24 int16 texgeti16 (MelderReadText text);
25 int32 texgeti32 (MelderReadText text);
26 integer texgetinteger (MelderReadText text);
27 #define texgetinteger16BE texgetinteger
28 #define texgetinteger32BE texgetinteger
29 unsigned int texgetu8 (MelderReadText text);
30 uint16 texgetu16 (MelderReadText text);
31 uint32 texgetu32 (MelderReadText text);
32 double texgetr32 (MelderReadText text);
33 double texgetr64 (MelderReadText text);
34 double texgetr80 (MelderReadText text);
35 dcomplex texgetc64 (MelderReadText text);
36 dcomplex texgetc128 (MelderReadText text);
37 int texgete8 (MelderReadText text, enum_generic_getValue getValue);
38 int texgete16 (MelderReadText text, enum_generic_getValue getValue);
39 bool texgeteb (MelderReadText text);
40 bool texgeteq (MelderReadText text);
41 bool texgetex (MelderReadText text);
42 autostring32 texgetw16 (MelderReadText text);
43 autostring32 texgetw32 (MelderReadText text);
44
45 void texindent (MelderFile file);
46 void texexdent (MelderFile file);
47 void texresetindent (MelderFile file);
48
49 #define texput_UP_TO_NINE_NULLABLE_STRINGS \
50 conststring32 s1 = nullptr, conststring32 s2 = nullptr, conststring32 s3 = nullptr, \
51 conststring32 s4 = nullptr, conststring32 s5 = nullptr, conststring32 s6 = nullptr, \
52 conststring32 s7 = nullptr, conststring32 s8 = nullptr, conststring32 s9 = nullptr
53 void texputintro (MelderFile file, texput_UP_TO_NINE_NULLABLE_STRINGS);
54 void texputi8 (MelderFile file, int i, texput_UP_TO_NINE_NULLABLE_STRINGS);
55 void texputi16 (MelderFile file, int i, texput_UP_TO_NINE_NULLABLE_STRINGS);
56 void texputi32 (MelderFile file, long i, texput_UP_TO_NINE_NULLABLE_STRINGS);
57 void texputinteger (MelderFile file, integer i, texput_UP_TO_NINE_NULLABLE_STRINGS);
58 #define texputinteger16BE texputinteger
59 #define texputinteger32BE texputinteger
60 void texputu8 (MelderFile file, unsigned int u, texput_UP_TO_NINE_NULLABLE_STRINGS);
61 void texputu16 (MelderFile file, unsigned int u, texput_UP_TO_NINE_NULLABLE_STRINGS);
62 void texputu32 (MelderFile file, unsigned long u, texput_UP_TO_NINE_NULLABLE_STRINGS);
63 void texputr32 (MelderFile file, double x, texput_UP_TO_NINE_NULLABLE_STRINGS);
64 void texputr64 (MelderFile file, double x, texput_UP_TO_NINE_NULLABLE_STRINGS);
65 void texputc64 (MelderFile file, dcomplex z, texput_UP_TO_NINE_NULLABLE_STRINGS);
66 void texputc128 (MelderFile file, dcomplex z, texput_UP_TO_NINE_NULLABLE_STRINGS);
67 void texpute8 (MelderFile file, int i, conststring32 (*getText) (int), texput_UP_TO_NINE_NULLABLE_STRINGS);
68 void texpute16 (MelderFile file, int i, conststring32 (*getText) (int), texput_UP_TO_NINE_NULLABLE_STRINGS);
69 void texputeb (MelderFile file, bool i, texput_UP_TO_NINE_NULLABLE_STRINGS);
70 void texputeq (MelderFile file, bool i, texput_UP_TO_NINE_NULLABLE_STRINGS);
71 void texputex (MelderFile file, bool i, texput_UP_TO_NINE_NULLABLE_STRINGS);
72 void texputs8 (MelderFile file, conststring8 s, texput_UP_TO_NINE_NULLABLE_STRINGS);
73 void texputs16 (MelderFile file, conststring8 s, texput_UP_TO_NINE_NULLABLE_STRINGS);
74 void texputs32 (MelderFile file, conststring8 s, texput_UP_TO_NINE_NULLABLE_STRINGS);
75 void texputw16 (MelderFile file, conststring32 s, texput_UP_TO_NINE_NULLABLE_STRINGS);
76 void texputw32 (MelderFile file, conststring32 s, texput_UP_TO_NINE_NULLABLE_STRINGS);
77 #undef texput_UP_TO_NINE_NULLABLE_STRINGS
78
79 /* Portable device-independent binary input and output. */
80 /* Works on all machines with 8-bit bytes and chars, and 2's complement integers. */
81 /* Works independent of byte order or floating-point implementations. */
82 /*
83 The 42 routines are analogous to fgetc and fputc, who read or write one character:
84 int fgetc (FILE *f); int fputc (int c, FILE *f); // 0..255
85 */
86 uint32 bingetu8 (FILE *f); void binputu8 (uint32 i, FILE *f); // 0..255
87 uint16 bingetu16 (FILE *f); void binputu16 (uint16 i, FILE *f); // 0..65535
88 uint32 bingetu32 (FILE *f); void binputu32 (uint32 i, FILE *f); // 0..4294967295
89
90 int32 bingeti8 (FILE *f); void binputi8 (int32 i, FILE *f); /* -128..127 */
91 int16 bingeti16 (FILE *f); void binputi16 (int16 i, FILE *f); // -32768..32767
92 int32 bingeti24 (FILE *f); void binputi24 (int32 i, FILE *f); // -8388608..8388607
93 int32 bingeti32 (FILE *f); void binputi32 (int32 i, FILE *f); // -2147483648..2147483647
94 integer bingetinteger32BE (FILE *f); void binputinteger32BE (integer i, FILE *f);
95 integer bingetinteger16BE (FILE *f); void binputinteger16BE (integer i, FILE *f);
96 /*
97 Read or write signed or unsigned integers from or to 2 or 4 bytes in the stream 'f',
98 in big-endian byte order (most significant byte first).
99 This is the native integer format on Macintosh and Silicon Graphics Iris.
100 */
101
102 int16 bingeti16LE (FILE *f); void binputi16LE (int16 i, FILE *f); // -32768..32767
103 int32 bingeti24LE (FILE *f); void binputi24LE (int32 i, FILE *f); // -8388608..8388607
104 int32 bingeti32LE (FILE *f); void binputi32LE (int32 i, FILE *f); // -2147483648..2147483647
105 uint16 bingetu16LE (FILE *f); void binputu16LE (uint16 i, FILE *f); // 0..65535
106 uint32 bingetu32LE (FILE *f); void binputu32LE (uint32 i, FILE *f); // 0..4294967295
107 /*
108 Read or write signed or unsigned integers from or to 2 or 4 bytes in the stream 'f',
109 in little-endian byte order (least significant byte first).
110 This is the native integer format on Vax and IBM PC.
111 */
112
113 int bingete8 (FILE *f, int min, int max, conststring32 type);
114 int bingete16 (FILE *f, int min, int max, conststring32 type);
115 bool bingetbool8 (FILE *f);
116 #define bingeteb bingetbool8
117 #define bingeteq bingetbool8
118 #define bingetex bingetbool8
119
120 void binpute8 (int value, FILE *f);
121 void binpute16 (int value, FILE *f);
122 void binputbool8 (bool value, FILE *f);
123 #define binputeb binputbool8
124 #define binputeq binputbool8
125 #define binputex binputbool8
126
127 double bingetr32 (FILE *f); void binputr32 (double x, FILE *f);
128 /*
129 Read or write a real number from or to 4 bytes in the stream `f`,
130 in IEEE single-precision binary real format, with the most significant bit first.
131 NaN's (Not-a-Numbers) and infinities get the value HUGE, which equals infinity on IEEE machines.
132 Absolute values of normalized numbers (23 bits precision): 1.2e-38 .. 3.4e38.
133 Denormalized: from 1.4e-45.
134 This is the native format of a `float` on Macintosh and Silicon Graphics Iris.
135 */
136 double bingetr32LE (FILE *f); void binputr32LE (double x, FILE *f); // least significant bit first
137
138 double bingetr64 (FILE *f); void binputr64 (double x, FILE *f);
139 /*
140 Read or write a real number from or to 8 bytes in the stream `f`,
141 in IEEE double-precision binary real format, with the most significant bit first.
142 NaN's (Not-a-Numbers) and infinities get the value HUGE, which equals infinity on IEEE machines.
143 Absolute values of normalized numbers (52 bits precision): 2.2e-308 .. 1.8e308.
144 Denormalized: from 4.9e-324.
145 This is the native format of a `double` on Silicon Graphics Iris and PowerMac.
146 */
147 double bingetr64LE (FILE *f); void binputr64LE (double x, FILE *f); // least significant bit first
148
149 double bingetr80 (FILE *f); void binputr80 (double x, FILE *f);
150 /*
151 Read or write a real number from or to 10 bytes in the stream `f`,
152 in IEEE extended-precision binary real format, with the most significant bit first,
153 as implemented in Motorola's MC68881 floating-point coprocessor.
154 NaN's (Not-a-Numbers) and infinities get the value HUGE, which equals infinity on IEEE machines.
155 Absolute values of normalized numbers (63 bits precision): 8e-4933 .. 6e4931.
156 Denormalized: from 9e-4952.
157 This format is used to encode the sampling rate in AIFF (Audio Interchange File Format) files,
158 and is the native format of a `double` on 68k Macintosh.
159 */
160
161 dcomplex bingetc64 (FILE *f);
162 dcomplex bingetc128 (FILE *f);
163 void binputc64 (dcomplex z, FILE *f);
164 void binputc128 (dcomplex z, FILE *f);
165
166 autostring8 bingets8 (FILE *f); void binputs8 (const char *s, FILE *f); // 0..255 characters
167 autostring8 bingets16 (FILE *f); void binputs16 (const char *s, FILE *f); // 0..65535 characters
168 autostring8 bingets32 (FILE *f); void binputs32 (const char *s, FILE *f); // 0..4294967295 characters
169 /*
170 Read or write a string from or to `Melder_length(s)` UTF-16LE or ASCII characters
171 plus 1, 2, or 4 bytes in the stream `f`, in a Pascal-style format:
172 first the length, then the characters, without a trailing null byte.
173 bingetsxxx returns a new 'malloc'ed null-terminated C string (for the caller to `free` it).
174 Fail if out of memory.
175 binputsxxx expects a null-terminated C string whose `Melder_length` fits in 1, 2, or 4 bytes.
176 */
177 autostring32 bingetw8 (FILE *f); void binputw8 (conststring32 s, FILE *f);
178 autostring32 bingetw16 (FILE *f); void binputw16 (conststring32 s, FILE *f);
179 autostring32 bingetw32 (FILE *f); void binputw32 (conststring32 s, FILE *f);
180
181 /* End of file abcio.h */
182 #endif