Lines Matching refs:G
228 # define USR_HEADER_HOST (G.user_headers & HDR_HOST)
229 # define USR_HEADER_USER_AGENT (G.user_headers & HDR_USER_AGENT)
230 # define USR_HEADER_RANGE (G.user_headers & HDR_RANGE)
231 # define USR_HEADER_CONTENT_TYPE (G.user_headers & HDR_CONTENT_TYPE)
232 # define USR_HEADER_AUTH (G.user_headers & HDR_AUTH)
233 # define USR_HEADER_PROXY_AUTH (G.user_headers & HDR_PROXY_AUTH)
278 #define G (*ptr_to_globals) macro
280 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
325 if (G.log_fd >= 0) in progress_meter()
329 bb_progress_init(&G.pmt, G.curfile); in progress_meter()
331 notty = bb_progress_update(&G.pmt, in progress_meter()
332 G.beg_range, in progress_meter()
333 G.transferred, in progress_meter()
334 (G.chunked || !G.got_clen) ? 0 : G.beg_range + G.transferred + G.content_len in progress_meter()
338 bb_progress_free(&G.pmt); in progress_meter()
341 G.transferred = 0; in progress_meter()
390 unsigned len = strnlen(str, sizeof(G.wget_buf)/4*3 - 10); in base64enc()
391 bb_uuencode(G.wget_buf, str, len, bb_uuenc_tbl_base64); in base64enc()
392 return G.wget_buf; in base64enc()
400 if (G.die_if_timed_out) in alarm_handler()
405 if (G.timeout_seconds) { in set_alarm()
406 alarm(G.timeout_seconds); in set_alarm()
407 G.die_if_timed_out = 1; in set_alarm()
410 # define clear_alarm() ((void)(G.die_if_timed_out = 0))
484 if (fgets(G.wget_buf, sizeof(G.wget_buf), fp) == NULL) in fgets_trim_sanitize()
488 buf_ptr = strchrnul(G.wget_buf, '\n'); in fgets_trim_sanitize()
492 sanitize_string(G.wget_buf); in fgets_trim_sanitize()
495 buf_ptr = strchrnul(G.wget_buf, '\r'); in fgets_trim_sanitize()
499 log_io("< %s", G.wget_buf); in fgets_trim_sanitize()
502 fprintf(stderr, fmt, G.wget_buf); in fgets_trim_sanitize()
523 G.wget_buf[3] = 0; in ftpcmd()
526 } while (!isdigit(G.wget_buf[0]) || G.wget_buf[3] != ' '); in ftpcmd()
528 G.wget_buf[3] = '\0'; in ftpcmd()
529 result = xatoi_positive(G.wget_buf); in ftpcmd()
530 G.wget_buf[3] = ' '; in ftpcmd()
634 if (G.wget_buf[0] == '\0') in get_sanitized_hdr()
638 for (s = G.wget_buf; isalnum(*s) || *s == '-' || *s == '.' || *s == '_'; ++s) { in get_sanitized_hdr()
653 bb_error_msg_and_die("bad header line: %s", G.wget_buf); in get_sanitized_hdr()
671 G.beg_range = 0; in reset_beg_range_to_zero()
672 xlseek(G.output_fd, 0, SEEK_SET); in reset_beg_range_to_zero()
839 bb_simple_error_msg_and_die(G.wget_buf); in prepare_ftp_session()
859 bb_error_msg_and_die("ftp login: %s", G.wget_buf); in prepare_ftp_session()
866 G.content_len = BB_STRTOOFF(G.wget_buf + 4, NULL, 10); in prepare_ftp_session()
867 if (G.content_len < 0 || errno) { in prepare_ftp_session()
868 bb_error_msg_and_die("bad SIZE value '%s'", G.wget_buf + 4); in prepare_ftp_session()
870 G.got_clen = 1; in prepare_ftp_session()
879 bb_error_msg_and_die("bad response to %s: %s", "PASV", G.wget_buf); in prepare_ftp_session()
881 port = parse_pasv_epsv(G.wget_buf); in prepare_ftp_session()
899 if (G.beg_range != 0) { in prepare_ftp_session()
900 sprintf(G.wget_buf, "REST %"OFF_FMT"u", G.beg_range); in prepare_ftp_session()
901 if (ftpcmd(G.wget_buf, NULL, sfp) == 350) in prepare_ftp_session()
902 G.content_len -= G.beg_range; in prepare_ftp_session()
911 bb_error_msg_and_die("bad response to %s: %s", "RETR", G.wget_buf); in prepare_ftp_session()
921 unsigned second_cnt = G.timeout_seconds; in retrieve_file_data()
929 if (G.output_fd == 1) in retrieve_file_data()
932 fprintf(stderr, "saving to '%s'\n", G.fname_out); in retrieve_file_data()
936 if (G.chunked) in retrieve_file_data()
968 rdsz = sizeof(G.wget_buf); in retrieve_file_data()
969 if (G.got_clen) { in retrieve_file_data()
970 if (G.content_len < (off_t)sizeof(G.wget_buf)) { in retrieve_file_data()
971 if ((int)G.content_len <= 0) in retrieve_file_data()
973 rdsz = (unsigned)G.content_len; in retrieve_file_data()
976 n = fread(G.wget_buf, 1, rdsz, dfp); in retrieve_file_data()
979 xwrite(G.output_fd, G.wget_buf, n); in retrieve_file_data()
981 G.transferred += n; in retrieve_file_data()
983 if (G.got_clen) { in retrieve_file_data()
984 G.content_len -= n; in retrieve_file_data()
985 if (G.content_len == 0) in retrieve_file_data()
989 second_cnt = G.timeout_seconds; in retrieve_file_data()
1036 if (!G.chunked) in retrieve_file_data()
1045 G.content_len = STRTOOFF(G.wget_buf, NULL, 16); in retrieve_file_data()
1050 if (G.content_len < 0 || errno) in retrieve_file_data()
1051 bb_error_msg_and_die("bad chunk length '%s'", G.wget_buf); in retrieve_file_data()
1052 if (G.content_len == 0) in retrieve_file_data()
1054 G.got_clen = 1; in retrieve_file_data()
1065 G.chunked = 0; /* makes it show 100% even for chunked download */ in retrieve_file_data()
1066 G.got_clen = 1; /* makes it show 100% even for download of (formerly) unknown size */ in retrieve_file_data()
1068 if (G.content_len != 0) { in retrieve_file_data()
1079 off_t pos = lseek(G.output_fd, 0, SEEK_CUR); in retrieve_file_data()
1085 ftruncate(G.output_fd, pos); in retrieve_file_data()
1090 if (G.output_fd == 1) in retrieve_file_data()
1093 fprintf(stderr, "'%s' saved\n", G.fname_out); in retrieve_file_data()
1117 use_proxy = (strcmp(G.proxy_flag, "off") != 0); in download_one_url()
1142 G.fname_out = bb_get_last_path_component_nostrip(target.path); in download_one_url()
1144 if (G.fname_out[0] == '/' || !G.fname_out[0]) in download_one_url()
1145 G.fname_out = (char*)"index.html"; in download_one_url()
1147 if (G.dir_prefix) in download_one_url()
1148 G.fname_out = fname_out_alloc = concat_path_file(G.dir_prefix, G.fname_out); in download_one_url()
1151 G.fname_out = fname_out_alloc = xstrdup(G.fname_out); in download_one_url()
1155 G.curfile = bb_get_last_path_component_nostrip(G.fname_out); in download_one_url()
1159 G.beg_range = 0; in download_one_url()
1161 G.output_fd = open(G.fname_out, O_WRONLY); in download_one_url()
1162 if (G.output_fd >= 0) { in download_one_url()
1163 G.beg_range = xlseek(G.output_fd, 0, SEEK_END); in download_one_url()
1179 G.got_clen = 0; in download_one_url()
1180 G.chunked = 0; in download_one_url()
1234 SENDFMT(sfp, "User-Agent: %s\r\n", G.user_agent); in download_one_url()
1252 if (G.beg_range != 0 && !USR_HEADER_RANGE) in download_one_url()
1253 SENDFMT(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); in download_one_url()
1256 if (G.extra_headers) { in download_one_url()
1257 log_io(G.extra_headers); in download_one_url()
1258 fputs(G.extra_headers, sfp); in download_one_url()
1262 int fd = xopen_stdin(G.post_file); in download_one_url()
1263 G.post_data = xmalloc_read(fd, NULL); in download_one_url()
1267 if (G.post_data) { in download_one_url()
1278 (int) strlen(G.post_data), G.post_data in download_one_url()
1308 str = G.wget_buf; in download_one_url()
1359 if (G.beg_range != 0) { in download_one_url()
1377 if (G.beg_range != 0) in download_one_url()
1383 bb_error_msg_and_die("server returned error: %s", G.wget_buf); in download_one_url()
1405 key = index_in_strings(keywords, G.wget_buf) + 1; in download_one_url()
1407 G.content_len = BB_STRTOOFF(str, NULL, 10); in download_one_url()
1408 if (G.content_len < 0 || errno) { in download_one_url()
1411 G.got_clen = 1; in download_one_url()
1417 G.chunked = 1; in download_one_url()
1462 if (G.output_fd < 0) in download_one_url()
1463 G.output_fd = xopen(G.fname_out, G.o_flags); in download_one_url()
1466 xclose(G.output_fd); in download_one_url()
1467 G.output_fd = -1; in download_one_url()
1479 bb_error_msg_and_die("ftp error: %s", G.wget_buf); in download_one_url()
1539 G.timeout_seconds = 900; in wget_main()
1542 G.proxy_flag = "on"; /* use proxies if env vars are set */ in wget_main()
1543 G.user_agent = "Wget"; /* "User-Agent" header field */ in wget_main()
1564 , &G.fname_out, &G.fname_log, &G.dir_prefix, in wget_main()
1565 &G.proxy_flag, &G.user_agent, in wget_main()
1566 IF_FEATURE_WGET_TIMEOUT(&G.timeout_seconds) IF_NOT_FEATURE_WGET_TIMEOUT(NULL), in wget_main()
1570 IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_data) in wget_main()
1571 IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_file) in wget_main()
1594 G.extra_headers = hdr = xmalloc(size + 1); in wget_main()
1606 G.user_headers |= bit; in wget_main()
1617 G.output_fd = -1; in wget_main()
1618 G.o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL; in wget_main()
1619 if (G.fname_out) { /* -O FILE ? */ in wget_main()
1620 if (LONE_DASH(G.fname_out)) { /* -O - ? */ in wget_main()
1621 G.output_fd = 1; in wget_main()
1625 G.o_flags = O_WRONLY | O_CREAT | O_TRUNC; in wget_main()
1628 G.log_fd = -1; in wget_main()
1629 if (G.fname_log) { /* -o FILE ? */ in wget_main()
1630 if (!LONE_DASH(G.fname_log)) { /* not -o - ? */ in wget_main()
1632 G.log_fd = xopen(G.fname_log, O_WRONLY | O_CREAT | O_TRUNC); in wget_main()
1634 xdup2(G.log_fd, STDERR_FILENO); in wget_main()
1641 if (G.output_fd >= 0) in wget_main()
1642 xclose(G.output_fd); in wget_main()
1644 if (G.log_fd >= 0) in wget_main()
1645 xclose(G.log_fd); in wget_main()
1648 free(G.extra_headers); in wget_main()