Reformated

GETADDRINFO
Stephane Bortzmeyer 24 years ago
parent 0fb146d516
commit cd8c0af868

@ -84,12 +84,14 @@ extern int sys_nerr;
#endif
#ifndef HEADER_INCLUDED
typedef union _CHANNEL {
typedef union _CHANNEL
{
FILE *fs;
#ifdef OPENSSL
SSL* ssl;
SSL *ssl;
#endif
} CHANNEL;
}
CHANNEL;
#endif
struct timeval null_timeval;
@ -101,7 +103,7 @@ struct timeval max_timeval;
#define DEFAULT_HTTP_TCP_PORT "HTTP"
#define DEFAULT_HTTPS_TCP_PORT "HTTPS"
#define DEFAULT_ICP_UDP_PORT "ICP"
/* #define ICP_UDP_PORT "icp" */ /* In config.h */
/* #define ICP_UDP_PORT "icp" *//* In config.h */
#define USE_ECHO 1
#define USE_DISCARD 2

@ -13,7 +13,6 @@
void *
make_icp_sendline (url, shost, opcode, length)
const char *url;
u_num32 *shost;
icp_opcode opcode;
@ -51,7 +50,6 @@ make_icp_sendline (url, shost, opcode, length)
int
recv_icp (sockfd, buf, retcode)
int sockfd;
char *buf;
char *retcode;
@ -62,43 +60,42 @@ recv_icp (sockfd, buf, retcode)
icp_common_t *headerp = (icp_common_t *) buf;
int nr, length;
unsigned char opcode;
static char *icp_op_code[] =
{
/* 0 */ "ICP_OP_INVALID",
/* 1 */ "ICP_OP_QUERY",
/* 2 */ "ICP_OP_HIT",
/* 3 */ "ICP_OP_MISS",
/* 4 */ "ICP_OP_ERR",
/* 5 */ "",
/* 6 */ "",
/* 7 */ "",
/* 8 */ "",
/* 9 */ "",
/* 10 */ "ICP_OP_SECHO",
/* 11 */ "ICP_OP_DECHO",
/* 12 */ "",
/* 13 */ "",
/* 14 */ "",
/* 15 */ "",
/* 16 */ "",
/* 17 */ "",
/* 18 */ "",
/* 19 */ "",
/* 20 */ "",
/* 21 */ "ICP_OP_MISS_NOFETCH",
/* 22 */ "ICP_OP_DENIED",
/* 23 */ "ICP_OP_HIT_OBJ"
static char *icp_op_code[] = {
/* 0 */ "ICP_OP_INVALID",
/* 1 */ "ICP_OP_QUERY",
/* 2 */ "ICP_OP_HIT",
/* 3 */ "ICP_OP_MISS",
/* 4 */ "ICP_OP_ERR",
/* 5 */ "",
/* 6 */ "",
/* 7 */ "",
/* 8 */ "",
/* 9 */ "",
/* 10 */ "ICP_OP_SECHO",
/* 11 */ "ICP_OP_DECHO",
/* 12 */ "",
/* 13 */ "",
/* 14 */ "",
/* 15 */ "",
/* 16 */ "",
/* 17 */ "",
/* 18 */ "",
/* 19 */ "",
/* 20 */ "",
/* 21 */ "ICP_OP_MISS_NOFETCH",
/* 22 */ "ICP_OP_DENIED",
/* 23 */ "ICP_OP_HIT_OBJ"
};
nr = recvfrom (sockfd, buf, DEFLINE, 0,
(struct sockaddr *) 0, (int *) 0);
if (nr < 0) {
if (timeout_flag)
err_quit ("Timeout while reading");
else
err_sys ("No reply from ICP proxy server");
}
nr = recvfrom (sockfd, buf, DEFLINE, 0, (struct sockaddr *) 0, (int *) 0);
if (nr < 0)
{
if (timeout_flag)
err_quit ("Timeout while reading");
else
err_sys ("No reply from ICP proxy server");
}
opcode = headerp->opcode;
length = ntohs (headerp->length);
sprintf (retcode, "ICP reply: \42%s\42", icp_op_code[opcode]);
@ -107,9 +104,3 @@ recv_icp (sockfd, buf, retcode)
#endif /* ICP */

@ -69,42 +69,47 @@ SSL_readline (sslh, ptr, maxlen, ln)
if (ln)
{
/* Empty buffer */
if (buf_end == 0) {
rc = SSL_read (sslh, SSL_buffer, maxlen);
buf_end = rc;
}
if (buf_end == 0)
{
rc = SSL_read (sslh, SSL_buffer, maxlen);
buf_end = rc;
}
/* No more data in the buffer */
else if (buf_ptr == buf_end) {
buf_ptr = 0;
rc = SSL_read (sslh, SSL_buffer, maxlen);
buf_end = rc;
}
for (oi=buf_ptr,i=buf_ptr; SSL_buffer[i] != '\n'; i++) {
*ptr++ = SSL_buffer[i];
buf_ptr++;
}
if (SSL_buffer[i] == '\n')
else if (buf_ptr == buf_end)
{
buf_ptr = 0;
rc = SSL_read (sslh, SSL_buffer, maxlen);
buf_end = rc;
}
for (oi = buf_ptr, i = buf_ptr; SSL_buffer[i] != '\n'; i++)
{
*ptr++ = SSL_buffer[i];
buf_ptr++;
}
if (SSL_buffer[i] == '\n')
buf_ptr++;
*ptr = '\0';
return (i-oi);
return (i - oi);
}
else {
/* Since OpenSSL reads at most 4096 characters, we should loop
here like we do in non-SSL readline */
if ((buf_end == 0) || (buf_ptr == buf_end)) {
rc = SSL_read (sslh, ptr, maxlen);
buf_end = 0;
buf_ptr = 0;
}
else {
for (i=buf_ptr; i<maxlen && i<=buf_end; i++) {
*ptr++ = SSL_buffer[i];
rc++;
}
else
{
/* Since OpenSSL reads at most 4096 characters, we should loop
here like we do in non-SSSL readline */
if ((buf_end == 0) || (buf_ptr == buf_end))
{
rc = SSL_read (sslh, ptr, maxlen);
buf_end = 0;
buf_ptr = 0;
}
else
{
for (i = buf_ptr; i < maxlen && i <= buf_end; i++)
{
*ptr++ = SSL_buffer[i];
rc++;
}
}
return rc;
}
return rc;
}
}
#endif

Loading…
Cancel
Save