4 * Author: Teemu Rantanen <tvr@cs.hut.fi>
5 * Copyright (c) 1992 Teemu Rantanen
8 * Created: Fri Apr 17 23:43:01 1992 tvr
9 * Last modified: Mon May 11 23:29:10 1992 tvr
15 #include <sys/types.h>
28 * We want that loading won't kill the whole f*king client.
34 ARGS4 (CONST char *, arg,
40 * Most code from old loading function
47 struct sockaddr_in soc_address; /* Binary network address */
48 struct sockaddr_in *sin = &soc_address;
51 return -3; /* Bad if no name sepcified */
53 return -2; /* Bad if name had zero length */
57 sin->sin_family = AF_INET; /* Family, host order */
58 sin->sin_port = htons (TCP_PORT); /* Default: new port, */
64 "HTTPAccess: Using gateway %s for %s\n", gate, arg);
66 fprintf (stderr, "HTTPAccess: Direct access for %s\n", arg);
69 /* Get node name and optional port number:
72 char *p1 = HTParse (gate ? gate : arg, "", PARSE_HOST);
73 HTParseInet (sin, p1);
78 /* Now, let's get a socket set up from the server for the sgml data:
80 s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
81 (void) fcntl (s, F_SETFL, O_NONBLOCK);
82 (void) fcntl (s, F_SETFL, FNDELAY);
85 * Now. Do first attempt to connect.
87 status = erwise_connect (s,
88 (struct sockaddr *) & soc_address,
89 sizeof (soc_address));
101 printf ("HTTP connected, socket %d\n", s);
103 /* Ask that node for the document,
104 ** omitting the host name & anchor if not gatewayed.
108 command = malloc (4 + strlen (arg) + 1 + 1);
109 strcpy (command, "GET ");
110 strcat (command, arg);
113 { /* not gatewayed */
114 char *p1 = HTParse (arg, "", PARSE_PATH | PARSE_PUNCTUATION);
115 command = malloc (4 + strlen (p1) + 1 + 1);
116 strcpy (command, "GET ");
117 strcat (command, p1);
120 strcat (command, "\r\n"); /* Include CR for telnet compat. */
124 printf ("HTTP writing command `%s' to socket %d\n", command, s);
129 for (p = command; *p; p++)
137 * Ok. Everything is now set up. Set functionpointers so that
138 * the rest of loading works ok.
142 static void (*functions[]) () =
145 WWWErwiseSendCommand,
149 WWWErwiseTerminateIfLoadToFile,
153 WWWErwiseConnection->function = functions;
156 WWWErwiseConnection->command = command;
158 WWWErwiseConnection->diag = diag;
160 WWWErwiseConnection->anAnchor = anAnchor;