int hash_table_num_entries(struct hash_table *hash_table) { int entry_count = 0; hash_table_map(hash_table, entry_counter, &entry_count); return entry_count; }
void print_hash (struct hash_table *sht) { int debug_count = 0; hash_table_map (sht, print_hash_table_mapper, &debug_count); assert (debug_count == sht->count); }
void cookies_cleanup (void) { if (!cookies_hash_table) return; hash_table_map (cookies_hash_table, delete_cookie_chain_mapper, NULL); hash_table_destroy (cookies_hash_table); cookies_hash_table = NULL; }
void host_cleanup (void) { if (host_name_addresses_map) { hash_table_map (host_name_addresses_map, host_cleanup_mapper, NULL); hash_table_destroy (host_name_addresses_map); host_name_addresses_map = NULL; } }
void res_cleanup (void) { if (registered_specs) { hash_table_map (registered_specs, cleanup_hash_table_mapper, NULL); hash_table_destroy (registered_specs); registered_specs = NULL; } }
void downloaded_files_free (void) { if (downloaded_files_hash) { hash_table_map (downloaded_files_hash, df_free_mapper, NULL); hash_table_destroy (downloaded_files_hash); downloaded_files_hash = NULL; } }
void save_cookies (const char *file) { FILE *fp; if (!cookies_hash_table || !hash_table_count (cookies_hash_table)) /* no cookies stored; nothing to do. */ return; DEBUGP (("Saving cookies to %s.\n", file)); cookies_now = time (NULL); fp = fopen (file, "w"); if (!fp) { logprintf (LOG_NOTQUIET, _("Cannot open cookies file `%s': %s\n"), file, strerror (errno)); return; } fputs ("# HTTP cookie file.\n", fp); fprintf (fp, "# Generated by Wget on %s.\n", datetime_str (NULL)); fputs ("# Edit at your own risk.\n\n", fp); hash_table_map (cookies_hash_table, save_cookies_mapper, fp); if (ferror (fp)) logprintf (LOG_NOTQUIET, _("Error writing to `%s': %s\n"), file, strerror (errno)); if (fclose (fp) < 0) logprintf (LOG_NOTQUIET, _("Error closing `%s': %s\n"), file, strerror (errno)); DEBUGP (("Done saving cookies.\n")); }
void free_keys_and_values (struct hash_table *ht) { hash_table_map (ht, free_keys_and_values_mapper, NULL); }
void string_set_free (struct hash_table *ht) { hash_table_map (ht, string_set_free_mapper, NULL); hash_table_destroy (ht); }
static void dissociate_urls_from_file (const char *file) { hash_table_map (dl_url_file_map, dissociate_urls_from_file_mapper, (char *)file); }