Lines Matching refs:buf

105 proxy_read_line(int fd, char *buf, size_t bufsz)  in proxy_read_line()  argument
112 if (atomicio(read, fd, buf + off, 1) != 1) in proxy_read_line()
115 if (buf[off] == '\r') in proxy_read_line()
117 if (buf[off] == '\n') { in proxy_read_line()
118 buf[off] = '\0'; in proxy_read_line()
155 char buf[1024]; in socks_connect() local
187 buf[0] = SOCKS_V5; in socks_connect()
188 buf[1] = 1; in socks_connect()
189 buf[2] = SOCKS_NOAUTH; in socks_connect()
190 cnt = atomicio(vwrite, proxyfd, buf, 3); in socks_connect()
194 cnt = atomicio(read, proxyfd, buf, 2); in socks_connect()
198 if ((unsigned char)buf[1] == SOCKS_NOMETHOD) in socks_connect()
209 buf[0] = SOCKS_V5; in socks_connect()
210 buf[1] = SOCKS_CONNECT; in socks_connect()
211 buf[2] = 0; in socks_connect()
212 buf[3] = SOCKS_DOMAIN; in socks_connect()
213 buf[4] = hlen; in socks_connect()
214 (void) memcpy(buf + 5, host, hlen); in socks_connect()
215 (void) memcpy(buf + 5 + hlen, &serverport, in socks_connect()
221 buf[0] = SOCKS_V5; in socks_connect()
222 buf[1] = SOCKS_CONNECT; in socks_connect()
223 buf[2] = 0; in socks_connect()
224 buf[3] = SOCKS_IPV4; in socks_connect()
225 (void) memcpy(buf + 4, &in4->sin_addr, in socks_connect()
227 (void) memcpy(buf + 8, &in4->sin_port, in socks_connect()
234 buf[0] = SOCKS_V5; in socks_connect()
235 buf[1] = SOCKS_CONNECT; in socks_connect()
236 buf[2] = 0; in socks_connect()
237 buf[3] = SOCKS_IPV6; in socks_connect()
238 (void) memcpy(buf + 4, &in6->sin6_addr, in socks_connect()
240 (void) memcpy(buf + 20, &in6->sin6_port, in socks_connect()
249 cnt = atomicio(vwrite, proxyfd, buf, wlen); in socks_connect()
258 cnt = atomicio(read, proxyfd, buf, 10); in socks_connect()
261 if (buf[1] != 0) in socks_connect()
262 errx(1, "connection failed, SOCKS error %d", buf[1]); in socks_connect()
269 buf[0] = SOCKS_V4; in socks_connect()
270 buf[1] = SOCKS_CONNECT; /* connect */ in socks_connect()
271 (void) memcpy(buf + 2, &in4->sin_port, sizeof (in4->sin_port)); in socks_connect()
272 (void) memcpy(buf + 4, &in4->sin_addr, sizeof (in4->sin_addr)); in socks_connect()
273 buf[8] = 0; /* empty username */ in socks_connect()
276 cnt = atomicio(vwrite, proxyfd, buf, wlen); in socks_connect()
284 cnt = atomicio(read, proxyfd, buf, 8); in socks_connect()
287 if (buf[1] != 90) in socks_connect()
288 errx(1, "connection failed, SOCKS error %d", buf[1]); in socks_connect()
298 r = snprintf(buf, sizeof (buf), in socks_connect()
302 r = snprintf(buf, sizeof (buf), in socks_connect()
306 if (r == -1 || (size_t)r >= sizeof (buf)) in socks_connect()
308 r = strlen(buf); in socks_connect()
310 cnt = atomicio(vwrite, proxyfd, buf, r); in socks_connect()
318 r = snprintf(buf, sizeof (buf), "%s:%s", in socks_connect()
321 if (r == -1 || (size_t)r >= sizeof (buf) || in socks_connect()
322 b64_ntop((unsigned char *)buf, strlen(buf), resp, in socks_connect()
325 r = snprintf(buf, sizeof (buf), "Proxy-Authorization: " in socks_connect()
327 if (r == -1 || (size_t)r >= sizeof (buf)) in socks_connect()
329 r = strlen(buf); in socks_connect()
330 if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) in socks_connect()
339 (void) proxy_read_line(proxyfd, buf, sizeof (buf)); in socks_connect()
341 strncmp(buf, HTTP_10_407, strlen(HTTP_10_407)) == 0) { in socks_connect()
348 } else if (strncmp(buf, HTTP_10_200, in socks_connect()
349 strlen(HTTP_10_200)) != 0 && strncmp(buf, HTTP_11_200, in socks_connect()
351 errx(1, "Proxy error: \"%s\"", buf); in socks_connect()
355 (void) proxy_read_line(proxyfd, buf, sizeof (buf)); in socks_connect()
356 if (*buf == '\0') in socks_connect()
359 if (*buf != '\0') in socks_connect()