[svn] Use a single version of RBUF_READCHAR.

This commit is contained in:
hniksic 2000-12-05 15:50:34 -08:00
parent e754c99b46
commit 47c6092ec4
3 changed files with 23 additions and 22 deletions

View File

@ -1,3 +1,10 @@
2000-12-06 Hrvoje Niksic <hniksic@arsdigita.com>
* rbuf.h: Implement only a single version of RBUF_READCHAR, using
rbuf_read_bufferful when the buffer is depleted.
* rbuf.c (rbuf_read_bufferful): New function.
2000-12-06 Hrvoje Niksic <hniksic@arsdigita.com>
* gen_sslfunc.h: Use ansi2knr style function declarations.

View File

@ -58,6 +58,17 @@ rbuf_uninitialize (struct rbuf *rbuf)
rbuf->fd = -1;
}
int
rbuf_read_bufferful (struct rbuf *rbuf)
{
#ifdef HAVE_SSL
if (rbuf->ssl)
return ssl_iread (rbuf->ssl, rbuf->buffer, sizeof (rbuf->buffer));
else
#endif
return iread (rbuf->fd, rbuf->buffer, sizeof (rbuf->buffer));
}
/* Currently unused -- see RBUF_READCHAR. */
#if 0
/* Function version of RBUF_READCHAR. */

View File

@ -49,38 +49,18 @@ struct rbuf
result of historical implementation of header code. The macro
should return the character or EOF, and in case of error store it
to rbuf->err or something. */
#ifdef HAVE_SSL
/* SSL version of rbuf. If rbuf.ssl isn't NULL use ssl_iread instead
of iread */
#define RBUF_READCHAR(rbuf, store) \
((rbuf)->buffer_left \
? (--(rbuf)->buffer_left, \
*((char *) (store)) = *(rbuf)->buffer_pos++, 1) \
: ((rbuf)->buffer_pos = (rbuf)->buffer, \
((((rbuf)->internal_dont_touch_this \
= (rbuf->ssl == NULL) ? (iread ((rbuf)->fd, (rbuf)->buffer, \
sizeof ((rbuf)->buffer))) : (ssl_iread ((rbuf)->ssl, (rbuf)->buffer, \
sizeof ((rbuf)->buffer))) ) <= 0) \
= rbuf_read_bufferful (rbuf)) <= 0) \
? (rbuf)->internal_dont_touch_this \
: ((rbuf)->buffer_left = (rbuf)->internal_dont_touch_this - 1, \
*((char *) (store)) = *(rbuf)->buffer_pos++, \
1))))
#else
#define RBUF_READCHAR(rbuf, store) \
((rbuf)->buffer_left \
? (--(rbuf)->buffer_left, \
*((char *) (store)) = *(rbuf)->buffer_pos++, 1) \
: ((rbuf)->buffer_pos = (rbuf)->buffer, \
((((rbuf)->internal_dont_touch_this \
= iread ((rbuf)->fd, (rbuf)->buffer, \
sizeof ((rbuf)->buffer))) <= 0) \
? (rbuf)->internal_dont_touch_this \
: ((rbuf)->buffer_left = (rbuf)->internal_dont_touch_this - 1, \
*((char *) (store)) = *(rbuf)->buffer_pos++, \
1))))
#endif /* HAVE_SSL */
/* Return the file descriptor of RBUF. */
#define RBUF_FD(rbuf) ((rbuf)->fd)
@ -97,4 +77,7 @@ int rbuf_peek PARAMS ((struct rbuf *, char *));
int rbuf_flush PARAMS ((struct rbuf *, char *, int));
void rbuf_discard PARAMS ((struct rbuf *));
/* Internal, but used by the macro. */
int rbuf_read_bufferful PARAMS ((struct rbuf *));
#endif /* RBUF_H */