Deleted Added
full compact
common.c (97868) common.c (97891)
1/*-
2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/lib/libfetch/common.c 97868 2002-06-05 12:46:36Z des $");
30__FBSDID("$FreeBSD: head/lib/libfetch/common.c 97891 2002-06-05 21:35:35Z des $");
31
32#include <sys/param.h>
33#include <sys/socket.h>
34#include <sys/time.h>
35#include <sys/uio.h>
36#include <netinet/in.h>
37
38#include <errno.h>

--- 226 unchanged lines hidden (view full) ---

265
266/*
267 * Enable SSL on a connection.
268 */
269int
270_fetch_ssl(conn_t *conn, int verbose)
271{
272
31
32#include <sys/param.h>
33#include <sys/socket.h>
34#include <sys/time.h>
35#include <sys/uio.h>
36#include <netinet/in.h>
37
38#include <errno.h>

--- 226 unchanged lines hidden (view full) ---

265
266/*
267 * Enable SSL on a connection.
268 */
269int
270_fetch_ssl(conn_t *conn, int verbose)
271{
272
273#ifdef WITH_SSL
273 /* Init the SSL library and context */
274 if (!SSL_library_init()){
275 fprintf(stderr, "SSL library init failed\n");
276 return (-1);
277 }
278
279 SSL_load_error_strings();
280

--- 24 unchanged lines hidden (view full) ---

305 free(str);
306 name = X509_get_issuer_name(conn->ssl_cert);
307 str = X509_NAME_oneline(name, 0, 0);
308 printf("Certificate issuer: %s\n", str);
309 free(str);
310 }
311
312 return (0);
274 /* Init the SSL library and context */
275 if (!SSL_library_init()){
276 fprintf(stderr, "SSL library init failed\n");
277 return (-1);
278 }
279
280 SSL_load_error_strings();
281

--- 24 unchanged lines hidden (view full) ---

306 free(str);
307 name = X509_get_issuer_name(conn->ssl_cert);
308 str = X509_NAME_oneline(name, 0, 0);
309 printf("Certificate issuer: %s\n", str);
310 free(str);
311 }
312
313 return (0);
314#else
315 (void)conn;
316 (void)verbose;
317 fprintf(stderr, "SSL support disabled\n");
318 return (-1);
319#endif
313}
314
315/*
316 * Read a character from a connection w/ timeout
317 */
318ssize_t
319_fetch_read(conn_t *conn, char *buf, size_t len)
320{

--- 24 unchanged lines hidden (view full) ---

345 errno = 0;
346 r = select(conn->sd + 1, &readfds, NULL, NULL, &wait);
347 if (r == -1) {
348 if (errno == EINTR && fetchRestartCalls)
349 continue;
350 return (-1);
351 }
352 }
320}
321
322/*
323 * Read a character from a connection w/ timeout
324 */
325ssize_t
326_fetch_read(conn_t *conn, char *buf, size_t len)
327{

--- 24 unchanged lines hidden (view full) ---

352 errno = 0;
353 r = select(conn->sd + 1, &readfds, NULL, NULL, &wait);
354 if (r == -1) {
355 if (errno == EINTR && fetchRestartCalls)
356 continue;
357 return (-1);
358 }
359 }
360#ifdef WITH_SSL
353 if (conn->ssl != NULL)
354 rlen = SSL_read(conn->ssl, buf, len);
355 else
361 if (conn->ssl != NULL)
362 rlen = SSL_read(conn->ssl, buf, len);
363 else
364#endif
356 rlen = read(conn->sd, buf, len);
357 if (rlen == 0)
358 break;
359 if (rlen < 0) {
360 if (errno == EINTR && fetchRestartCalls)
361 continue;
362 return (-1);
363 }

--- 84 unchanged lines hidden (view full) ---

448 r = select(conn->sd + 1, NULL, &writefds, NULL, &wait);
449 if (r == -1) {
450 if (errno == EINTR && fetchRestartCalls)
451 continue;
452 return (-1);
453 }
454 }
455 errno = 0;
365 rlen = read(conn->sd, buf, len);
366 if (rlen == 0)
367 break;
368 if (rlen < 0) {
369 if (errno == EINTR && fetchRestartCalls)
370 continue;
371 return (-1);
372 }

--- 84 unchanged lines hidden (view full) ---

457 r = select(conn->sd + 1, NULL, &writefds, NULL, &wait);
458 if (r == -1) {
459 if (errno == EINTR && fetchRestartCalls)
460 continue;
461 return (-1);
462 }
463 }
464 errno = 0;
465#ifdef WITH_SSL
456 if (conn->ssl != NULL)
457 wlen = SSL_write(conn->ssl, buf, len);
458 else
466 if (conn->ssl != NULL)
467 wlen = SSL_write(conn->ssl, buf, len);
468 else
469#endif
459 wlen = write(conn->sd, buf, len);
460 if (wlen == 0)
461 /* we consider a short write a failure */
462 return (-1);
463 if (wlen < 0) {
464 if (errno == EINTR && fetchRestartCalls)
465 continue;
466 return (-1);

--- 68 unchanged lines hidden ---
470 wlen = write(conn->sd, buf, len);
471 if (wlen == 0)
472 /* we consider a short write a failure */
473 return (-1);
474 if (wlen < 0) {
475 if (errno == EINTR && fetchRestartCalls)
476 continue;
477 return (-1);

--- 68 unchanged lines hidden ---