コード例 #1
0
ファイル: id_table.c プロジェクト: dzruyk/crypti
void
id_table_show_all_items()
{
    struct scopes *tmp;

    tmp = scopes;

    printf("getting info about id_items...\n");
    while (tmp != NULL) {
        id_item_t *item;
        struct hash_table_iter *iter;
        void *key;

        iter = hash_table_iterate_init(tmp->scope);

        while (hash_table_iterate(iter, &key, (void **)&item) == TRUE) {
            printf("name = %s, type = %d\n",
                   item->name, item->type);
        }

        hash_table_iterate_deinit(&iter);

        tmp = tmp->prev;
    }

    printf("finishing...\n");
}
コード例 #2
0
ファイル: spider.c プロジェクト: 2manysecrets/parallel-wget
void
print_broken_links (void)
{
  hash_table_iterator iter;
  int num_elems;

  if (!nonexisting_urls_set)
    {
      logprintf (LOG_NOTQUIET, _("Found no broken links.\n\n"));
      return;
    }

  num_elems = hash_table_count (nonexisting_urls_set);
  assert (num_elems > 0);

  logprintf (LOG_NOTQUIET, ngettext("Found %d broken link.\n\n",
                                    "Found %d broken links.\n\n", num_elems),
             num_elems);

  for (hash_table_iterate (nonexisting_urls_set, &iter);
       hash_table_iter_next (&iter); )
    {
      /* Struct url_list *list; */
      const char *url = (const char *) iter.key;

      logprintf (LOG_NOTQUIET, _("%s\n"), url);
    }
  logputs (LOG_NOTQUIET, "\n");
}
コード例 #3
0
ファイル: password-scheme.c プロジェクト: bdraco/core
const char *
password_scheme_detect(const char *plain_password, const char *crypted_password,
		       const struct password_generate_params *params)
{
	struct hash_iterate_context *ctx;
	const char *key;
	const struct password_scheme *scheme;
	const unsigned char *raw_password;
	size_t raw_password_size;
	const char *error;

	ctx = hash_table_iterate_init(password_schemes);
	while (hash_table_iterate(ctx, password_schemes, &key, &scheme)) {
		if (password_decode(crypted_password, scheme->name,
				    &raw_password, &raw_password_size,
				    &error) <= 0)
			continue;

		if (password_verify(plain_password, params, scheme->name,
				    raw_password, raw_password_size,
				    &error) > 0)
			break;
		key = NULL;
	}
	hash_table_iterate_deinit(&ctx);
	return key;
}
コード例 #4
0
void auth_request_handler_abort_requests(struct auth_request_handler *handler)
{
	struct hash_iterate_context *iter;
	void *key;
	struct auth_request *auth_request;

	iter = hash_table_iterate_init(handler->requests);
	while (hash_table_iterate(iter, handler->requests, &key, &auth_request)) {
		switch (auth_request->state) {
		case AUTH_REQUEST_STATE_NEW:
		case AUTH_REQUEST_STATE_MECH_CONTINUE:
		case AUTH_REQUEST_STATE_FINISHED:
			auth_request_unref(&auth_request);
			hash_table_remove(handler->requests, key);
			break;
		case AUTH_REQUEST_STATE_PASSDB:
		case AUTH_REQUEST_STATE_USERDB:
			/* can't abort a pending passdb/userdb lookup */
			break;
		case AUTH_REQUEST_STATE_MAX:
			i_unreached();
		}
	}
	hash_table_iterate_deinit(&iter);
}
コード例 #5
0
ファイル: db-passwd-file.c プロジェクト: IvanKharpalev/core
void db_passwd_file_unref(struct db_passwd_file **_db)
{
        struct db_passwd_file *db = *_db;
        struct db_passwd_file **p;
	struct hash_iterate_context *iter;
	char *path;
	struct passwd_file *file;

	*_db = NULL;
	i_assert(db->refcount >= 0);
	if (--db->refcount > 0)
		return;

	for (p = &passwd_files; *p != NULL; p = &(*p)->next) {
		if (*p == db) {
			*p = db->next;
			break;
		}
	}

	if (db->default_file != NULL)
		passwd_file_free(db->default_file);
	else {
		iter = hash_table_iterate_init(db->files);
		while (hash_table_iterate(iter, db->files, &path, &file))
			passwd_file_free(file);
		hash_table_iterate_deinit(&iter);
		hash_table_destroy(&db->files);
	}
	i_free(db->path);
	i_free(db);
}
コード例 #6
0
void test_hash_iterator_key_pair()
{
	HashTable *hash_table;
	HashTableIterator iterator;
	HashTablePair pair;
	int *key = 0;
	int *val = 0;
	hash_table = hash_table_new(int_hash, int_equal);

	/* Add some values */

	hash_table_insert(hash_table, &value1, &value1);
	hash_table_insert(hash_table, &value2, &value2);

	hash_table_iterate(hash_table, &iterator);

	while (hash_table_iter_has_more(&iterator)) {

		/* Retrieve both Key and Value */

		pair = hash_table_iter_next(&iterator);

		key = (int*) pair.key;
		val = (int*) pair.value;

		assert(*key == *val);
	}

	hash_table_free(hash_table);
}
コード例 #7
0
void test_hash_table_iterating_remove(void)
{
	HashTable *hash_table;
	HashTableIterator iterator;
	char buf[10];
	char *val;
	HashTablePair pair;
	int count;
	unsigned int removed;
	int i;

	hash_table = generate_hash_table();

	/* Iterate over all values in the table */

	count = 0;
	removed = 0;

	hash_table_iterate(hash_table, &iterator);

	while (hash_table_iter_has_more(&iterator)) {

		/* Read the next value */

		pair = hash_table_iter_next(&iterator);
		val = pair.value;

		/* Remove every hundredth entry */

		if ((atoi(val) % 100) == 0) {
			hash_table_remove(hash_table, val);
			++removed;
		}

		++count;
	}

	/* Check counts */

	assert(removed == 100);
	assert(count == NUM_TEST_VALUES);

	assert(hash_table_num_entries(hash_table)
	       == NUM_TEST_VALUES - removed);

	/* Check all entries divisible by 100 were really removed */

	for (i=0; i<NUM_TEST_VALUES; ++i) {
		sprintf(buf, "%i", i);

		if (i % 100 == 0) {
			assert(hash_table_lookup(hash_table, buf) == NULL);
		} else {
			assert(hash_table_lookup(hash_table, buf) != NULL);
		}
	}

	hash_table_free(hash_table);
}
コード例 #8
0
ファイル: chash.c プロジェクト: ki4wangdy/imServer-protobuf
void
print_hash (struct hash_table *sht)
{
  hash_table_iterator iter;
  int count = 0;

  for (hash_table_iterate (sht, &iter); hash_table_iter_next (&iter);
       ++count)
    printf ("%s: %s\n", iter.key, iter.value);
  assert (count == sht->count);
}
コード例 #9
0
static void replicator_abort_all_requests(struct replicator_connection *conn)
{
	struct hash_iterate_context *iter;
	void *key, *value;

	iter = hash_table_iterate_init(conn->requests);
	while (hash_table_iterate(iter, conn->requests, &key, &value))
		conn->callback(FALSE, value);
	hash_table_iterate_deinit(&iter);
	hash_table_clear(conn->requests, TRUE);
}
コード例 #10
0
ファイル: ctx_unitigs.c プロジェクト: ambarrio/mccortex
static void print_gfa_syntax(UnitigPrinter *p)
{
  fputs("H VN:Z:1.0\n", p->fout);

  unitig_graph_create(&p->ugraph, p->nthreads, p->visited,
                      print_unitig_gfa, p);

  p->num_unitigs = p->ugraph.num_unitigs;
  // Now print edges
  hash_table_iterate(&p->db_graph->ht, p->nthreads, print_edges, p);
}
コード例 #11
0
static void stats_drop_stale(struct top_context *ctx)
{
	struct hash_iterate_context *iter;
	char *id;
	struct top_line *line;

	iter = hash_table_iterate_init(ctx->sessions);
	while (hash_table_iterate(iter, ctx->sessions, &id, &line)) {
		if (line->flip != ctx->flip)
			hash_table_remove(ctx->sessions, id);
	}
	hash_table_iterate_deinit(&iter);
}
コード例 #12
0
void test_hash_table_iterating(void)
{
	HashTable *hash_table;
	HashTableIterator iterator;
	int count;

	hash_table = generate_hash_table();

	/* Iterate over all values in the table */

	count = 0;

	hash_table_iterate(hash_table, &iterator);

	while (hash_table_iter_has_more(&iterator)) {
		hash_table_iter_next(&iterator);

		++count;
	}

	assert(count == NUM_TEST_VALUES);

	/* Test iter_next after iteration has completed. */

	assert(hash_table_iter_next(&iterator) == HASH_TABLE_NULL);

	hash_table_free(hash_table);

	/* Test iterating over an empty table */

	hash_table = hash_table_new(int_hash, int_equal);
	
	hash_table_iterate(hash_table, &iterator);

	assert(hash_table_iter_has_more(&iterator) == 0);

	hash_table_free(hash_table);
}
コード例 #13
0
ファイル: convert.c プロジェクト: 2manysecrets/parallel-wget
static void
downloaded_files_free (void)
{
    if (downloaded_files_hash)
    {
        hash_table_iterator iter;
        for (hash_table_iterate (downloaded_files_hash, &iter);
                hash_table_iter_next (&iter);
            )
            xfree (iter.key);
        hash_table_destroy (downloaded_files_hash);
        downloaded_files_hash = NULL;
    }
}
コード例 #14
0
ファイル: id_table.c プロジェクト: dzruyk/spam
void
id_table_free(struct hash_table *table)
{
	void *key, *data;
	struct hash_table_iter *iter;

	iter = hash_table_iterate_init(table);
	
	while (hash_table_iterate(iter, &key, &data) != FALSE)
		id_table_destroy_cb((id_table_item_t*)data);

	hash_table_iterate_deinit(&iter);

	hash_table_destroy(&table);
}
コード例 #15
0
ファイル: la_helper.c プロジェクト: hagemt/libalexandria
void
__la_dump_table(HashTable *table, __value_handler_t func)
{
	HashTableIterator itr;
	LOGV("%p (hash table: dump table)", table);
	if (func == NULL) {
		LOGW("%p (dump hash table: given no handler)", table);
		return;
	}
	/* Print each value in detail */
	hash_table_iterate(table, &itr);
	while (hash_table_iter_has_more(&itr)) {
		(*func)(hash_table_iter_next(&itr));
	}
}
コード例 #16
0
ファイル: str-table.c プロジェクト: bdraco/core
void str_table_deinit(struct str_table **_table)
{
	struct str_table *table = *_table;
	struct hash_iterate_context *iter;
	char *key;
	void *value;

	*_table = NULL;

	iter = hash_table_iterate_init(table->hash);
	while (hash_table_iterate(iter, table->hash, &key, &value))
		i_free(key);
	hash_table_iterate_deinit(&iter);
	hash_table_destroy(&table->hash);
	i_free(table);
}
コード例 #17
0
ファイル: ctx_unitigs.c プロジェクト: ambarrio/mccortex
static void print_dot_syntax(UnitigPrinter *p, bool dot_use_points)
{
  fputs("digraph G {\n", p->fout);
  fputs("  edge [dir=both arrowhead=none arrowtail=none color=\"blue\"]\n", p->fout);
  fprintf(p->fout, "  node [%s, fontname=courier, fontsize=9]\n",
          dot_use_points ? "shape=point, label=none" : "shape=none");

  unitig_graph_create(&p->ugraph, p->nthreads, p->visited,
                      print_unitig_dot, p);

  p->num_unitigs = p->ugraph.num_unitigs;

  // Now print edges
  fputc('\n', p->fout);
  hash_table_iterate(&p->db_graph->ht, p->nthreads, print_edges, p);
  fputs("}\n", p->fout);
}
コード例 #18
0
ファイル: res.c プロジェクト: 2manysecrets/parallel-wget
void
res_cleanup (void)
{
  if (registered_specs)
    {
      hash_table_iterator iter;
      for (hash_table_iterate (registered_specs, &iter);
           hash_table_iter_next (&iter);
           )
        {
          xfree (iter.key);
          free_specs (iter.value);
        }
      hash_table_destroy (registered_specs);
      registered_specs = NULL;
    }
}
コード例 #19
0
static void
auth_server_connection_remove_requests(struct auth_server_connection *conn)
{
	static const char *const temp_failure_args[] = { "temp", NULL };
	struct hash_iterate_context *iter;
	void *key, *value;

	iter = hash_table_iterate_init(conn->requests);
	while (hash_table_iterate(iter, &key, &value)) {
		struct auth_client_request *request = value;

		auth_client_request_server_input(request,
						 AUTH_REQUEST_STATUS_FAIL,
						 temp_failure_args);
	}
	hash_table_iterate_deinit(&iter);
	hash_table_clear(conn->requests, FALSE);
}
コード例 #20
0
ファイル: crypt_hashes.c プロジェクト: dzruyk/crypti
void
hash_ctx_table_destroy()
{
	void *key, *data;
	struct hash_table_iter *iter;

	iter = hash_table_iterate_init(ctx_table->hash);

	while (hash_table_iterate(iter, &key, &data) != FALSE)
		hash_ctx_destroy_cb((struct hash_ctx *)data);

	hash_table_iterate_deinit(&iter);

	hash_table_destroy(&ctx_table->hash);

	ufree(ctx_table);
	ctx_table = NULL;
}
コード例 #21
0
static void checkpassword_deinit(struct userdb_module *_module)
{
	struct checkpassword_userdb_module *module =
		(struct checkpassword_userdb_module *)_module;
	struct hash_iterate_context *iter;
	void *key, *value;

	iter = hash_table_iterate_init(module->clients);
	while (hash_table_iterate(iter, &key, &value)) {
		checkpassword_request_finish(value,
					     USERDB_RESULT_INTERNAL_FAILURE);
	}
	hash_table_iterate_deinit(&iter);
	hash_table_destroy(&module->clients);

	if (checkpassword_userdb_children != NULL)
		child_wait_free(&checkpassword_userdb_children);
}
コード例 #22
0
ファイル: login-proxy-state.c プロジェクト: bdraco/core
void login_proxy_state_deinit(struct login_proxy_state **_state)
{
	struct login_proxy_state *state = *_state;
	struct hash_iterate_context *iter;
	struct login_proxy_record *rec;

	*_state = NULL;

	/* sanity check: */
	iter = hash_table_iterate_init(state->hash);
	while (hash_table_iterate(iter, state->hash, &rec, &rec))
		i_assert(rec->num_waiting_connections == 0);
	hash_table_iterate_deinit(&iter);

	timeout_remove(&state->to_reopen);
	login_proxy_state_close(state);
	hash_table_destroy(&state->hash);
	pool_unref(&state->pool);
	i_free(state);
}
コード例 #23
0
ファイル: host.c プロジェクト: AOSC-Dev/wget
void
host_cleanup (void)
{
  if (host_name_addresses_map)
    {
      hash_table_iterator iter;
      for (hash_table_iterate (host_name_addresses_map, &iter);
           hash_table_iter_next (&iter);
           )
        {
          char *host = iter.key;
          struct address_list *al = iter.value;
          xfree (host);
          assert (al->refcount == 1);
          address_list_delete (al);
        }
      hash_table_destroy (host_name_addresses_map);
      host_name_addresses_map = NULL;
    }
}
コード例 #24
0
static void
auth_server_connection_remove_requests(struct auth_server_connection *conn,
				       const char *disconnect_reason)
{
	static const char *const temp_failure_args[] = { "temp", NULL };
	struct hash_iterate_context *iter;
	void *key;
	struct auth_client_request *request;
	time_t created, oldest = 0;
	unsigned int request_count = 0;

	if (hash_table_count(conn->requests) == 0)
		return;

	iter = hash_table_iterate_init(conn->requests);
	while (hash_table_iterate(iter, conn->requests, &key, &request)) {
		if (!auth_client_request_is_aborted(request)) {
			request_count++;
			created = auth_client_request_get_create_time(request);
			if (oldest > created || oldest == 0)
				oldest = created;
		}

		auth_client_request_server_input(request,
			AUTH_REQUEST_STATUS_INTERNAL_FAIL,
			temp_failure_args);
	}
	hash_table_iterate_deinit(&iter);
	hash_table_clear(conn->requests, FALSE);

	if (request_count > 0) {
		i_warning("Auth connection closed with %u pending requests "
			  "(max %u secs, pid=%s, %s)", request_count,
			  (unsigned int)(ioloop_time - oldest),
			  my_pid, disconnect_reason);
	}
}
コード例 #25
0
int main(int arg, char *argv) {

	char * str1 = "HTTP/1.1 index.html";
	char * str2 = "HTTP/1.0 aaaaa.html";
	char * str3 = "HTTP/1.0 bbbbb.html";
	char * str4 = "HTTP/1.1 ccccc.html";
	char * str5 = "HTTP/0.9 ddddd.html";
	char * str6 = "HTTP/1.1 fffff.html";
	char * str7 = "HTTP/0.9 eeeee.html";

	LST_String * nbytes1 = lst_string_new(str1, 1, strlen(str1));
	LST_String * nbytes2 = lst_string_new(str2, 1, strlen(str2));
	LST_String * nbytes3 = lst_string_new(str3, 1, strlen(str3));
	LST_String * nbytes4 = lst_string_new(str4, 1, strlen(str4));
	LST_String * nbytes5 = lst_string_new(str5, 1, strlen(str5));
	LST_String * nbytes6 = lst_string_new(str6, 1, strlen(str6));
	LST_String * nbytes7 = lst_string_new(str7, 1, strlen(str7));

	LST_StringSet * set = lst_stringset_new();
	lst_stringset_add(set, nbytes1);
	lst_stringset_add(set, nbytes2);
	lst_stringset_add(set, nbytes3);
	lst_stringset_add(set, nbytes4);
	lst_stringset_add(set, nbytes5);
	lst_stringset_add(set, nbytes6);
	lst_stringset_add(set, nbytes7);

	int first_bytes = 8;
	int last_bytes = 10;
	int num_bytes = 19;
	int gamma_merge = 2;

	product_distribution_t * pd = product_distribution_new(set, first_bytes, last_bytes, num_bytes);

	/* print pd */
	HashTableIterator iterator1;
	hash_table_iterate(pd->offset_distribution, &iterator1);

	while (hash_table_iter_has_more(&iterator1)){
		HashTablePair pair1 = hash_table_iter_next(&iterator1);
		
		int *key1 = (int *) pair1.key;
		byte_distribution_t *value1 = (byte_distribution_t *) pair1.value;

		HashTableIterator iterator2;
		hash_table_iterate(value1->value_frequency, &iterator2);
		if (hash_table_num_entries(value1->value_frequency) > gamma_merge) {
			continue;
		}
		printf("offset %d : ", *key1);	
		while(hash_table_iter_has_more(&iterator2)){
			HashTablePair pair2 = hash_table_iter_next(&iterator2);
			char *key2 = (char *) pair2.key;
			int *value2 = (int *) pair2.value;
			//printf("<%c, %d>\t", key2[0], *value2);
			if (0 == *key1) {
				printf("^%s\t", key2);
			} else if (num_bytes - 1 == *key1) {
				printf("%s$\t", key2);
			} else {
				printf("%s\t", key2);
			}
		}
		printf("\n");
	}

	product_distribution_free(pd);

	return 0;
}
コード例 #26
0
static void iterate_all_classes(void *(f)(void*, void*)) {
    hash_table_iterate(class_key_table, f);
}