Lines Matching refs:buf

107 proxy_read_line(int fd, char *buf, size_t bufsz)  in proxy_read_line()  argument
114 if (atomicio(read, fd, buf + off, 1) != 1) in proxy_read_line()
117 if (buf[off] == '\r') in proxy_read_line()
119 if (buf[off] == '\n') { in proxy_read_line()
120 buf[off] = '\0'; in proxy_read_line()
157 char buf[1024]; in socks_connect() local
189 buf[0] = SOCKS_V5; in socks_connect()
190 buf[1] = 1; in socks_connect()
191 buf[2] = SOCKS_NOAUTH; in socks_connect()
192 cnt = atomicio(vwrite, proxyfd, buf, 3); in socks_connect()
196 cnt = atomicio(read, proxyfd, buf, 2); in socks_connect()
200 if ((unsigned char)buf[1] == SOCKS_NOMETHOD) in socks_connect()
211 buf[0] = SOCKS_V5; in socks_connect()
212 buf[1] = SOCKS_CONNECT; in socks_connect()
213 buf[2] = 0; in socks_connect()
214 buf[3] = SOCKS_DOMAIN; in socks_connect()
215 buf[4] = hlen; in socks_connect()
216 (void) memcpy(buf + 5, host, hlen); in socks_connect()
217 (void) memcpy(buf + 5 + hlen, &serverport, in socks_connect()
223 buf[0] = SOCKS_V5; in socks_connect()
224 buf[1] = SOCKS_CONNECT; in socks_connect()
225 buf[2] = 0; in socks_connect()
226 buf[3] = SOCKS_IPV4; in socks_connect()
227 (void) memcpy(buf + 4, &in4->sin_addr, in socks_connect()
229 (void) memcpy(buf + 8, &in4->sin_port, in socks_connect()
236 buf[0] = SOCKS_V5; in socks_connect()
237 buf[1] = SOCKS_CONNECT; in socks_connect()
238 buf[2] = 0; in socks_connect()
239 buf[3] = SOCKS_IPV6; in socks_connect()
240 (void) memcpy(buf + 4, &in6->sin6_addr, in socks_connect()
242 (void) memcpy(buf + 20, &in6->sin6_port, in socks_connect()
251 cnt = atomicio(vwrite, proxyfd, buf, wlen); in socks_connect()
260 cnt = atomicio(read, proxyfd, buf, 10); in socks_connect()
263 if (buf[1] != 0) in socks_connect()
264 errx(1, "connection failed, SOCKS error %d", buf[1]); in socks_connect()
271 buf[0] = SOCKS_V4; in socks_connect()
272 buf[1] = SOCKS_CONNECT; /* connect */ in socks_connect()
273 (void) memcpy(buf + 2, &in4->sin_port, sizeof (in4->sin_port)); in socks_connect()
274 (void) memcpy(buf + 4, &in4->sin_addr, sizeof (in4->sin_addr)); in socks_connect()
275 buf[8] = 0; /* empty username */ in socks_connect()
278 cnt = atomicio(vwrite, proxyfd, buf, wlen); in socks_connect()
286 cnt = atomicio(read, proxyfd, buf, 8); in socks_connect()
289 if (buf[1] != 90) in socks_connect()
290 errx(1, "connection failed, SOCKS error %d", buf[1]); in socks_connect()
300 r = snprintf(buf, sizeof (buf), in socks_connect()
304 r = snprintf(buf, sizeof (buf), in socks_connect()
308 if (r == -1 || (size_t)r >= sizeof (buf)) in socks_connect()
310 r = strlen(buf); in socks_connect()
312 cnt = atomicio(vwrite, proxyfd, buf, r); in socks_connect()
320 r = snprintf(buf, sizeof (buf), "%s:%s", in socks_connect()
323 if (r == -1 || (size_t)r >= sizeof (buf) || in socks_connect()
324 b64_ntop((unsigned char *)buf, strlen(buf), resp, in socks_connect()
327 r = snprintf(buf, sizeof (buf), "Proxy-Authorization: " in socks_connect()
329 if (r == -1 || (size_t)r >= sizeof (buf)) in socks_connect()
331 r = strlen(buf); in socks_connect()
332 if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) in socks_connect()
341 (void) proxy_read_line(proxyfd, buf, sizeof (buf)); in socks_connect()
343 strncmp(buf, HTTP_10_407, strlen(HTTP_10_407)) == 0) { in socks_connect()
350 } else if (strncmp(buf, HTTP_10_200, in socks_connect()
351 strlen(HTTP_10_200)) != 0 && strncmp(buf, HTTP_11_200, in socks_connect()
353 errx(1, "Proxy error: \"%s\"", buf); in socks_connect()
357 (void) proxy_read_line(proxyfd, buf, sizeof (buf)); in socks_connect()
358 if (*buf == '\0') in socks_connect()
361 if (*buf != '\0') in socks_connect()