From 9cbe909da37e5a146dce55b4d6b7cbec65da57a9 Mon Sep 17 00:00:00 2001 From: "Steffen (Daode) Nurpmeso" Date: Sat, 10 May 2014 14:16:26 +0200 Subject: [PATCH] Drop now unused sopen_old() --- fio.c | 172 ------------------------------------------------------------- nailfuns.h | 2 - 2 files changed, 174 deletions(-) diff --git a/fio.c b/fio.c index b9f02ec0c..1bd3869ce 100644 --- a/fio.c +++ b/fio.c @@ -1384,178 +1384,6 @@ jleave: return (sofd >= 0); } -FL enum okay -sopen_old(char const *xserver, struct sock *sp, int use_ssl, char const *uhp, - char const *portstr) -{ -# ifdef HAVE_SO_SNDTIMEO - struct timeval tv; -# endif -# ifdef HAVE_SO_LINGER - struct linger li; -# endif -# ifdef HAVE_IPV6 - char hbuf[NI_MAXHOST]; - struct addrinfo hints, *res0, *res; -# else - struct sockaddr_in servaddr; - struct in_addr **pptr; - struct hostent *hp; - struct servent *ep; - unsigned short port = 0; -# endif - int sockfd; - char *cp, *server = UNCONST(xserver); - enum okay rv = STOP; - NYD_ENTER; - UNUSED(use_ssl); - UNUSED(uhp); - - if ((cp = strchr(server, ':')) != NULL) { /* TODO URI parse! IPv6! */ - portstr = &cp[1]; -# ifndef HAVE_IPV6 - port = strtol(portstr, NULL, 10); -# endif - server = salloc(cp - xserver +1); - memcpy(server, xserver, cp - xserver); - server[cp - xserver] = '\0'; - } - - /* Connect timeouts after 30 seconds */ -# ifdef HAVE_SO_SNDTIMEO - tv.tv_sec = 30; - tv.tv_usec = 0; -# endif - -# ifdef HAVE_IPV6 - if (options & OPT_VERBOSE) - fprintf(stderr, "Resolving host %s ...", server); - memset(&hints, 0, sizeof hints); - hints.ai_socktype = SOCK_STREAM; - if (getaddrinfo(server, portstr, &hints, &res0) != 0) { - fprintf(stderr, tr(252, " lookup of `%s' failed.\n"), server); - goto jleave; - } else if (options & OPT_VERBOSE) - fprintf(stderr, tr(500, " done.\n")); - - sockfd = -1; - for (res = res0; res != NULL && sockfd < 0; res = res->ai_next) { - if (options & OPT_VERBOSE) { - if (getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, sizeof hbuf, - NULL, 0, NI_NUMERICHOST) != 0) - strcpy(hbuf, "unknown host"); - fprintf(stderr, tr(192, "%sConnecting to %s:%s ..."), - (res == res0 ? "" : "\n"), hbuf, portstr); - } - sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (sockfd >= 0) { -# ifdef HAVE_SO_SNDTIMEO - setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv); -# endif - if (connect(sockfd, res->ai_addr, res->ai_addrlen) != 0) { - close(sockfd); - sockfd = -1; - } - } - } - if (sockfd < 0) { - perror(tr(254, " could not connect")); - freeaddrinfo(res0); - goto jleave; - } - freeaddrinfo(res0); - -# else /* HAVE_IPV6 */ - if (port == 0) { -# ifdef HAVE_SMTP - if (!strcmp(portstr, "smtp")) - port = htons(25); - else if (!strcmp(portstr, "smtps")) - port = htons(465); - else if (!strcmp(portstr, "submission")) - port = htons(587); -# endif -# ifdef HAVE_IMAP - else if (!strcmp(portstr, "imap")) - port = htons(143); - else if (!strcmp(portstr, "imaps")) - port = htons(993); -# endif -# ifdef HAVE_POP3 - else if (!strcmp(portstr, "pop3")) - port = htons(110); - else if (!strcmp(portstr, "pop3s")) - port = htons(995); -# endif - else if ((ep = getservbyname(UNCONST(portstr), "tcp")) != NULL) - port = ep->s_port; - else { - fprintf(stderr, tr(251, "Unknown service: %s\n"), portstr); - rv = STOP; - goto jleave; - } - } else - port = htons(port); - - if (options & OPT_VERBOSE) - fprintf(stderr, "Resolving host %s ...", server); - if ((hp = gethostbyname(server)) == NULL) { - fprintf(stderr, tr(252, " lookup of `%s' failed.\n"), server); - goto jleave; - } else if (options & OPT_VERBOSE) - fprintf(stderr, tr(500, " done.\n")); - - pptr = (struct in_addr**)hp->h_addr_list; - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - perror(tr(253, "could not create socket")); - goto jleave; - } - memset(&servaddr, 0, sizeof servaddr); - servaddr.sin_family = AF_INET; - servaddr.sin_port = port; - memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr)); - if (options & OPT_VERBOSE) - fprintf(stderr, tr(190, "%sConnecting to %s:%d ..."), - "", inet_ntoa(**pptr), (int)ntohs(port)); - -# ifdef HAVE_SO_SNDTIMEO - setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv); -# endif - if (connect(sockfd, (struct sockaddr*)&servaddr, sizeof servaddr) != 0) { - perror(tr(254, " could not connect")); - goto jleave; - } -# endif /* !HAVE_IPV6 */ - if (options & OPT_VERBOSE) - fputs(tr(193, " connected.\n"), stderr); - - /* And the regular timeouts */ -# ifdef HAVE_SO_SNDTIMEO - tv.tv_sec = 42; - tv.tv_usec = 0; - setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv); - setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv); -# endif -# ifdef HAVE_SO_LINGER - li.l_onoff = 1; - li.l_linger = 42; - setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li); -# endif - - memset(sp, 0, sizeof *sp); - sp->s_fd = sockfd; -# ifdef HAVE_SSL - if (use_ssl && ssl_open(server, sp, uhp) != OKAY) { - sclose(sp); - goto jleave; - } -# endif - rv = OKAY; -jleave: - NYD_LEAVE; - return rv; -} - FL int (sgetline)(char **line, size_t *linesize, size_t *linelen, struct sock *sp SMALLOC_DEBUG_ARGS) diff --git a/nailfuns.h b/nailfuns.h index babc96e2c..35fddef5e 100644 --- a/nailfuns.h +++ b/nailfuns.h @@ -805,8 +805,6 @@ FL enum okay get_body(struct message *mp); /* Socket I/O */ #ifdef HAVE_SOCKETS FL bool_t sopen(struct sock *sp, struct url *urlp); -FL enum okay sopen_old(char const *xserver, struct sock *sp, int use_ssl, - char const *uhp, char const *portstr); FL int sclose(struct sock *sp); FL enum okay swrite(struct sock *sp, char const *data); FL enum okay swrite1(struct sock *sp, char const *data, int sz, -- 2.11.4.GIT