comparison src/lstream.c @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children e7ef97881643
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
72 it is very efficient. The C argument is only evaluated once 72 it is very efficient. The C argument is only evaluated once
73 but the STREAM argument is evaluated more than once. Returns 73 but the STREAM argument is evaluated more than once. Returns
74 0 on success, -1 on error. 74 0 on success, -1 on error.
75 75
76 int Lstream_getc (Lstream *stream) 76 int Lstream_getc (Lstream *stream)
77 Read one byte from the stream. This is a macro and so it 77 Read one byte from the stream and returns it as an unsigned
78 is very efficient. The STREAM argument is evaluated more 78 char cast to an int, or EOF on end of file or error.
79 than once. Return value is -1 for EOF or error. 79 This is a macro and so it is very efficient. The STREAM
80 argument is evaluated more than once.
80 81
81 void Lstream_ungetc (Lstream *stream, int c) 82 void Lstream_ungetc (Lstream *stream, int c)
82 Push one byte back onto the input queue. This will be the 83 Push one byte back onto the input queue, cast to unsigned char.
83 next byte read from the stream. Any number of bytes can be 84 This will be the next byte read from the stream. Any number
84 pushed back and will be read in the reverse order they were 85 of bytes can be pushed back and will be read in the reverse
85 pushed back -- most recent first. (This is necessary for 86 order they were pushed back -- most recent first. (This is
86 consistency -- if there are a number of bytes that have been 87 necessary for consistency -- if there are a number of bytes
87 unread and I read and unread a byte, it needs to be the first 88 that have been unread and I read and unread a byte, it needs
88 to be read again.) This is a macro and so it is very 89 to be the first to be read again.) This is a macro and so it
89 efficient. The C argument is only evaluated once but the 90 is very efficient. The C argument is only evaluated once but
90 STREAM argument is evaluated more than once. 91 the STREAM argument is evaluated more than once.
91 92
92 int Lstream_fputc (Lstream *stream, int c) 93 int Lstream_fputc (Lstream *stream, int c)
93 int Lstream_fgetc (Lstream *stream) 94 int Lstream_fgetc (Lstream *stream)
94 void Lstream_fungetc (Lstream *stream, int c) 95 void Lstream_fungetc (Lstream *stream, int c)
95 Function equivalents of the above macros. 96 Function equivalents of the above macros.
495 Lstream_was_blocked_p (Lstream *lstr) 496 Lstream_was_blocked_p (Lstream *lstr)
496 { 497 {
497 return lstr->imp->was_blocked_p ? lstr->imp->was_blocked_p (lstr) : 0; 498 return lstr->imp->was_blocked_p ? lstr->imp->was_blocked_p (lstr) : 0;
498 } 499 }
499 500
500 static int 501 static ssize_t
501 Lstream_raw_read (Lstream *lstr, unsigned char *buffer, size_t size) 502 Lstream_raw_read (Lstream *lstr, unsigned char *buffer, size_t size)
502 { 503 {
503 if (! (lstr->flags & LSTREAM_FL_IS_OPEN)) 504 if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
504 Lstream_internal_error ("lstream not open", lstr); 505 Lstream_internal_error ("lstream not open", lstr);
505 if (! (lstr->flags & LSTREAM_FL_READ)) 506 if (! (lstr->flags & LSTREAM_FL_READ))