Mercurial > hg > xemacs-beta
comparison src/lstream.h @ 647:b39c14581166
[xemacs-hg @ 2001-08-13 04:45:47 by ben]
removal of unsigned, size_t, etc.
author | ben |
---|---|
date | Mon, 13 Aug 2001 04:46:48 +0000 |
parents | af57a77cbc92 |
children | fdefd0186b75 |
comparison
equal
deleted
inserted
replaced
646:00c54252fe4f | 647:b39c14581166 |
---|---|
59 unrepresentable as an ssize_t, so code that checks to see how many | 59 unrepresentable as an ssize_t, so code that checks to see how many |
60 bytes are actually written (which is mandatory if you are dealing | 60 bytes are actually written (which is mandatory if you are dealing |
61 with certain types of devices) will get completely screwed up. | 61 with certain types of devices) will get completely screwed up. |
62 */ | 62 */ |
63 | 63 |
64 typedef EMACS_INT Lstream_data_count; | 64 typedef EMACS_INT Lstream_Data_Count; |
65 | 65 |
66 typedef enum lstream_buffering | 66 typedef enum lstream_buffering |
67 { | 67 { |
68 /* No buffering. */ | 68 /* No buffering. */ |
69 LSTREAM_UNBUFFERED, | 69 LSTREAM_UNBUFFERED, |
94 however -- e.g. on process output. */ | 94 however -- e.g. on process output. */ |
95 | 95 |
96 typedef struct lstream_implementation | 96 typedef struct lstream_implementation |
97 { | 97 { |
98 const char *name; | 98 const char *name; |
99 Lstream_data_count size; /* Number of additional bytes to be | 99 Lstream_Data_Count size; /* Number of additional bytes to be |
100 allocated with this stream. Access this | 100 allocated with this stream. Access this |
101 data using Lstream_data(). */ | 101 data using Lstream_data(). */ |
102 /* Read some data from the stream's end and store it into DATA, which | 102 /* Read some data from the stream's end and store it into DATA, which |
103 can hold SIZE bytes. Return the number of bytes read. A return | 103 can hold SIZE bytes. Return the number of bytes read. A return |
104 value of 0 means no bytes can be read at this time. This may | 104 value of 0 means no bytes can be read at this time. This may |
115 | 115 |
116 This function can be NULL if the stream is output-only. */ | 116 This function can be NULL if the stream is output-only. */ |
117 /* The omniscient mly, blinded by the irresistible thrall of Common | 117 /* The omniscient mly, blinded by the irresistible thrall of Common |
118 Lisp, thinks that it is bogus that the types and implementations | 118 Lisp, thinks that it is bogus that the types and implementations |
119 of input and output streams are the same. */ | 119 of input and output streams are the same. */ |
120 Lstream_data_count (*reader) (Lstream *stream, unsigned char *data, | 120 Lstream_Data_Count (*reader) (Lstream *stream, unsigned char *data, |
121 Lstream_data_count size); | 121 Lstream_Data_Count size); |
122 /* Send some data to the stream's end. Data to be sent is in DATA | 122 /* Send some data to the stream's end. Data to be sent is in DATA |
123 and is SIZE bytes. Return the number of bytes sent. This | 123 and is SIZE bytes. Return the number of bytes sent. This |
124 function can send and return fewer bytes than is passed in; in | 124 function can send and return fewer bytes than is passed in; in |
125 that case, the function will just be called again until there is | 125 that case, the function will just be called again until there is |
126 no data left or 0 is returned. A return value of 0 means that no | 126 no data left or 0 is returned. A return value of 0 means that no |
127 more data can be currently stored, but there is no error; the | 127 more data can be currently stored, but there is no error; the |
128 data will be squirrelled away until the writer can accept | 128 data will be squirrelled away until the writer can accept |
129 data. (This is useful, e.g., of you're dealing with a | 129 data. (This is useful, e.g., of you're dealing with a |
130 non-blocking file descriptor and are getting EWOULDBLOCK errors.) | 130 non-blocking file descriptor and are getting EWOULDBLOCK errors.) |
131 This function can be NULL if the stream is input-only. */ | 131 This function can be NULL if the stream is input-only. */ |
132 Lstream_data_count (*writer) (Lstream *stream, const unsigned char *data, | 132 Lstream_Data_Count (*writer) (Lstream *stream, const unsigned char *data, |
133 Lstream_data_count size); | 133 Lstream_Data_Count size); |
134 /* Return non-zero if the last write operation on the stream resulted | 134 /* Return non-zero if the last write operation on the stream resulted |
135 in an attempt to block (EWOULDBLOCK). If this method does not | 135 in an attempt to block (EWOULDBLOCK). If this method does not |
136 exists, the implementation returns 0 */ | 136 exists, the implementation returns 0 */ |
137 int (*was_blocked_p) (Lstream *stream); | 137 int (*was_blocked_p) (Lstream *stream); |
138 /* Rewind the stream. If this is NULL, the stream is not seekable. */ | 138 /* Rewind the stream. If this is NULL, the stream is not seekable. */ |
169 struct lstream | 169 struct lstream |
170 { | 170 { |
171 struct lcrecord_header header; | 171 struct lcrecord_header header; |
172 const Lstream_implementation *imp; /* methods for this stream */ | 172 const Lstream_implementation *imp; /* methods for this stream */ |
173 Lstream_buffering buffering; /* type of buffering in use */ | 173 Lstream_buffering buffering; /* type of buffering in use */ |
174 Lstream_data_count buffering_size; /* number of bytes buffered */ | 174 Lstream_Data_Count buffering_size; /* number of bytes buffered */ |
175 | 175 |
176 unsigned char *in_buffer; /* holds characters read from stream end */ | 176 unsigned char *in_buffer; /* holds characters read from stream end */ |
177 Lstream_data_count in_buffer_size; /* allocated size of buffer */ | 177 Lstream_Data_Count in_buffer_size; /* allocated size of buffer */ |
178 Lstream_data_count in_buffer_current; /* number of characters in buffer */ | 178 Lstream_Data_Count in_buffer_current; /* number of characters in buffer */ |
179 Lstream_data_count in_buffer_ind; /* pointer to next character to | 179 Lstream_Data_Count in_buffer_ind; /* pointer to next character to |
180 take from buffer */ | 180 take from buffer */ |
181 | 181 |
182 unsigned char *out_buffer; /* holds characters to write to stream end */ | 182 unsigned char *out_buffer; /* holds characters to write to stream end */ |
183 Lstream_data_count out_buffer_size; /* allocated size of buffer */ | 183 Lstream_Data_Count out_buffer_size; /* allocated size of buffer */ |
184 Lstream_data_count out_buffer_ind; /* pointer to next buffer spot to | 184 Lstream_Data_Count out_buffer_ind; /* pointer to next buffer spot to |
185 write a character */ | 185 write a character */ |
186 | 186 |
187 /* The unget buffer is more or less a stack -- things get pushed | 187 /* The unget buffer is more or less a stack -- things get pushed |
188 onto the end and read back from the end. Lstream_read() | 188 onto the end and read back from the end. Lstream_read() |
189 basically reads backwards from the end to get stuff; Lstream_unread() | 189 basically reads backwards from the end to get stuff; Lstream_unread() |
190 similarly has to push the data on backwards. */ | 190 similarly has to push the data on backwards. */ |
191 unsigned char *unget_buffer; /* holds characters pushed back onto input */ | 191 unsigned char *unget_buffer; /* holds characters pushed back onto input */ |
192 Lstream_data_count unget_buffer_size; /* allocated size of buffer */ | 192 Lstream_Data_Count unget_buffer_size; /* allocated size of buffer */ |
193 Lstream_data_count unget_buffer_ind; /* pointer to next buffer spot | 193 Lstream_Data_Count unget_buffer_ind; /* pointer to next buffer spot |
194 to write a character */ | 194 to write a character */ |
195 | 195 |
196 Lstream_data_count byte_count; | 196 Lstream_Data_Count byte_count; |
197 int flags; | 197 int flags; |
198 max_align_t data[1]; | 198 max_align_t data[1]; |
199 }; | 199 }; |
200 | 200 |
201 #define LSTREAM_TYPE_P(lstr, type) \ | 201 #define LSTREAM_TYPE_P(lstr, type) \ |
234 int Lstream_flush (Lstream *lstr); | 234 int Lstream_flush (Lstream *lstr); |
235 int Lstream_flush_out (Lstream *lstr); | 235 int Lstream_flush_out (Lstream *lstr); |
236 int Lstream_fputc (Lstream *lstr, int c); | 236 int Lstream_fputc (Lstream *lstr, int c); |
237 int Lstream_fgetc (Lstream *lstr); | 237 int Lstream_fgetc (Lstream *lstr); |
238 void Lstream_fungetc (Lstream *lstr, int c); | 238 void Lstream_fungetc (Lstream *lstr, int c); |
239 Lstream_data_count Lstream_read (Lstream *lstr, void *data, | 239 Lstream_Data_Count Lstream_read (Lstream *lstr, void *data, |
240 Lstream_data_count size); | 240 Lstream_Data_Count size); |
241 Lstream_data_count Lstream_write (Lstream *lstr, const void *data, | 241 Lstream_Data_Count Lstream_write (Lstream *lstr, const void *data, |
242 Lstream_data_count size); | 242 Lstream_Data_Count size); |
243 int Lstream_was_blocked_p (Lstream *lstr); | 243 int Lstream_was_blocked_p (Lstream *lstr); |
244 void Lstream_unread (Lstream *lstr, const void *data, Lstream_data_count size); | 244 void Lstream_unread (Lstream *lstr, const void *data, Lstream_Data_Count size); |
245 int Lstream_rewind (Lstream *lstr); | 245 int Lstream_rewind (Lstream *lstr); |
246 int Lstream_seekable_p (Lstream *lstr); | 246 int Lstream_seekable_p (Lstream *lstr); |
247 int Lstream_close (Lstream *lstr); | 247 int Lstream_close (Lstream *lstr); |
248 void Lstream_delete (Lstream *lstr); | 248 void Lstream_delete (Lstream *lstr); |
249 void Lstream_set_character_mode (Lstream *str); | 249 void Lstream_set_character_mode (Lstream *str); |
368 int filedesc_stream_fd (Lstream *stream); | 368 int filedesc_stream_fd (Lstream *stream); |
369 Lisp_Object make_lisp_string_input_stream (Lisp_Object string, | 369 Lisp_Object make_lisp_string_input_stream (Lisp_Object string, |
370 Bytecount offset, | 370 Bytecount offset, |
371 Bytecount len); | 371 Bytecount len); |
372 Lisp_Object make_fixed_buffer_input_stream (const void *buf, | 372 Lisp_Object make_fixed_buffer_input_stream (const void *buf, |
373 Lstream_data_count size); | 373 Lstream_Data_Count size); |
374 Lisp_Object make_fixed_buffer_output_stream (void *buf, | 374 Lisp_Object make_fixed_buffer_output_stream (void *buf, |
375 Lstream_data_count size); | 375 Lstream_Data_Count size); |
376 const unsigned char *fixed_buffer_input_stream_ptr (Lstream *stream); | 376 const unsigned char *fixed_buffer_input_stream_ptr (Lstream *stream); |
377 unsigned char *fixed_buffer_output_stream_ptr (Lstream *stream); | 377 unsigned char *fixed_buffer_output_stream_ptr (Lstream *stream); |
378 Lisp_Object make_resizing_buffer_output_stream (void); | 378 Lisp_Object make_resizing_buffer_output_stream (void); |
379 unsigned char *resizing_buffer_stream_ptr (Lstream *stream); | 379 unsigned char *resizing_buffer_stream_ptr (Lstream *stream); |
380 Lisp_Object make_dynarr_output_stream (unsigned_char_dynarr *dyn); | 380 Lisp_Object make_dynarr_output_stream (unsigned_char_dynarr *dyn); |