summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/fetch.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1998-07-11 18:56:01 +0000
committerdes <des@FreeBSD.org>1998-07-11 18:56:01 +0000
commit5b74d7e9c7c1f6bdcbae4e658c76c41016cdbf6b (patch)
tree4c94334611bca07668a0219331f52a4629e64811 /lib/libfetch/fetch.c
parentc39856b85e73a59eb926c7f6cc6a6b4097c4947b (diff)
downloadFreeBSD-src-5b74d7e9c7c1f6bdcbae4e658c76c41016cdbf6b.zip
FreeBSD-src-5b74d7e9c7c1f6bdcbae4e658c76c41016cdbf6b.tar.gz
Too many changes to list. Basically, FTP is nearly there and error
reporting is kinda sorted out. Now HTTP needs to catch up...
Diffstat (limited to 'lib/libfetch/fetch.c')
-rw-r--r--lib/libfetch/fetch.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index 99a2b9f..9e60938 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -25,15 +25,20 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$
+ * $Id: fetch.c,v 1.1.1.1 1998/07/09 16:52:42 des Exp $
*/
#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <ctype.h>
+#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "fetch.h"
@@ -43,6 +48,8 @@
#define DEBUG(x) do { } while (0)
#endif
+int fetchLastErrCode;
+const char *fetchLastErrText;
/* get URL */
FILE *
@@ -187,3 +194,31 @@ fetchFreeURL(url_t *u)
free(u);
}
}
+
+int
+fetchConnect(char *host, int port)
+{
+ struct sockaddr_in sin;
+ struct hostent *he;
+ int sd;
+
+ /* look up host name */
+ if ((he = gethostbyname(host)) == NULL)
+ return -1;
+
+ /* set up socket address structure */
+ bzero(&sin, sizeof(sin));
+ bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
+ sin.sin_family = he->h_addrtype;
+ sin.sin_port = htons(port);
+
+ /* try to connect */
+ if ((sd = socket(sin.sin_family, SOCK_STREAM, 0)) < 0)
+ return -1;
+ if (connect(sd, (struct sockaddr *)&sin, sizeof sin) < 0) {
+ close(sd);
+ return -1;
+ }
+
+ return sd;
+}
OpenPOWER on IntegriCloud