wget_netrc_t *wget_netrc_new(const char *machine, const char *login, const char *password) { wget_netrc_t *netrc = wget_netrc_init(NULL); netrc->key = wget_strdup(machine); netrc->login = wget_strdup(login); netrc->password = wget_strdup(password); return netrc; }
int main(void) { char *empty = (char *)""; wget_info_printf("%d\n", wget_base64_is_string("")); // base64.c wget_buffer_alloc(0); // buffer.c wget_buffer_printf((wget_buffer_t *)1, "%s", ""); // buffer_printf.c strlcpy((char *)"", "", 0); // strlcpy.c wget_css_parse_buffer((const char *)1, 0, NULL, NULL, NULL); // css.c wget_decompress_close(NULL); // decompressor.c wget_hashmap_create(0, 0, NULL, NULL); // hashmap.c wget_fdgetline(&empty, (size_t *)1, 0); // io.c wget_iri_parse("", NULL); // iri.c wget_list_free((wget_list_t **)1); // list.c wget_debug_write("", 0); // log.c wget_logger_set_file(NULL, ""); // logger.c wget_tcp_set_connect_timeout(NULL, 0); // net.c wget_netrc_deinit(NULL); // netrc.c wget_strdup(""); // mem.c // wget_popenf("r", "%s", ""); // pipe.c // wget_bsprintf(NULL, NULL, "%s", ""); // printf.c wget_ssl_set_config_int(0, 0); // ssl_[gnutls].c wget_stringmap_create(0); // stringmap.c if (wget_strcmp("", "")) {}; // utils.c wget_vector_set_destructor(NULL, NULL); // vector.c wget_malloc(1); // xalloc.c wget_xml_parse_buffer("", NULL, NULL, 0); // xml.c }
wget_ocsp_t *wget_ocsp_new(const char *fingerprint, time_t maxage, int valid) { wget_ocsp_t *ocsp = wget_ocsp_init(NULL); ocsp->key = wget_strdup(fingerprint); ocsp->maxage = maxage; ocsp->valid = valid; return ocsp; }
void wget_bar_slot_begin(wget_bar_t *bar, int slot, const char *filename, ssize_t file_size) { wget_thread_mutex_lock(&bar->mutex); _bar_slot_t *slotp = &bar->slots[slot]; xfree(slotp->filename); slotp->filename = wget_strdup(filename); slotp->tick = 0; slotp->file_size = file_size; slotp->bytes_downloaded = 0; slotp->status = DOWNLOADING; slotp->redraw = 1; wget_thread_mutex_unlock(&bar->mutex); }
int wget_netrc_db_load(wget_netrc_db_t *netrc_db, const char *fname) { wget_netrc_t netrc; FILE *fp; char *buf = NULL, *linep, *p, *key = NULL; size_t bufsize = 0; ssize_t buflen; int nentries = 0, in_macdef = 0, in_machine = 0; if (!netrc_db || !fname || !*fname) return -1; if ((fp = fopen(fname, "r"))) { while ((buflen = wget_getline(&buf, &bufsize, fp)) >= 0) { linep = buf; while (isspace(*linep)) linep++; // ignore leading whitespace if (*linep == '#') continue; // skip comments // strip off \r\n while (buflen > 0 && (buf[buflen] == '\n' || buf[buflen] == '\r')) buf[--buflen] = 0; if (!*linep) { // empty lines reset macro processing in_macdef = 0; continue; } else if (in_macdef) continue; // still processing 'macdef' macro // now we expect key value pairs, e.g.: machine example.com xfree(key); for (p = linep; *linep && !isspace(*linep);) linep++; key = wget_strmemdup(p, linep - p); if (!strcmp(key, "machine") || !strcmp(key, "default")) { if (in_machine) wget_netrc_db_add(netrc_db, wget_memdup(&netrc, sizeof(netrc))); wget_netrc_init(&netrc); in_machine = 1; if (!strcmp(key, "default")) { netrc.key = wget_strdup("default"); continue; } } else if (!in_machine) continue; // token outside of machine or default while (isspace(*linep)) linep++; for (p = linep; *linep && !isspace(*linep);) linep++; if (!strcmp(key, "login")) { if (!netrc.login) netrc.login = wget_strmemdup(p, linep - p); } else if (!strcmp(key, "password")) { if (!netrc.password) netrc.password = wget_strmemdup(p, linep - p); } else if (!strcmp(key, "macdef")) { in_macdef = 1; // the above code skips until next empty line } } if (in_machine) wget_netrc_db_add(netrc_db, wget_memdup(&netrc, sizeof(netrc))); xfree(key); xfree(buf); fclose(fp); nentries = wget_hashmap_size(netrc_db->machines); debug_printf("loaded %d .netrc %s\n", nentries, nentries != 1 ? "entries" : "entry"); } else if (errno != ENOENT) error_printf(_("Failed to open .netrc file '%s' (%d)\n"), fname, errno); return nentries; }