Esempio n. 1
0
File: config.c Progetto: abudrys/rss
hash_t *config_get_feeds(storage_handle_t *handle)
{
	storage_stmt_t *stmt = storage_query(handle, "SELECT * FROM feeds");
	hash_t *row, *ret = hash_init();
	
	while (storage_step(stmt, &row) == SQLITE_ROW) {
		feed_t *feed = feed_create(hash_get(row, "url"));
		feed->f_name = hash_get_string(row, "name");
		feed->f_description = hash_get_string(row, "description");
		feed->f_last_update = hash_get_int(row, "updated");
		hash_set(ret, xstrdup(hash_get(row, "name")), feed, TRUE);
		hash_free(row, FALSE, FALSE);
	}
	
	storage_finalize(stmt);
	return ret;
}
Esempio n. 2
0
static sched_kw_gruptree_type * sched_kw_gruptree_copyc(const sched_kw_gruptree_type * src) {
  sched_kw_gruptree_type * target = sched_kw_gruptree_alloc_empty();
  hash_iter_type * iter = hash_iter_alloc(src->gruptree_hash);
  const char * kw = hash_iter_get_next_key(iter);
  while (kw != NULL) {
    char * parent_name = hash_get_string(src->gruptree_hash , kw);
    hash_insert_string( target->gruptree_hash , kw , parent_name);
    kw = hash_iter_get_next_key(iter);
  }
  hash_iter_free(iter);
  return target;
}
Esempio n. 3
0
void sched_kw_gruptree_alloc_child_parent_list(const sched_kw_gruptree_type * kw, char *** __children, char *** __parents, int * num_pairs)
{
  *num_pairs = hash_get_size(kw->gruptree_hash);
  char ** children = hash_alloc_keylist(kw->gruptree_hash);
  char ** parents  = util_malloc(*num_pairs * sizeof * parents);

  for(int child_nr = 0; child_nr < *num_pairs; child_nr++)
  {
    parents[child_nr] = util_alloc_string_copy(hash_get_string(kw->gruptree_hash, children[child_nr]));
  }

  *__children = children;
  *__parents  = parents;
}
Esempio n. 4
0
void sched_kw_gruptree_init_child_parent_list( const sched_kw_gruptree_type * kw , stringlist_type * child , stringlist_type * parent) {
  stringlist_clear( child );
  stringlist_clear( parent );
  {
    hash_iter_type * iter = hash_iter_alloc( kw->gruptree_hash );
    while (!hash_iter_is_complete( iter )) {
      const char * child_group  = hash_iter_get_next_key( iter );
      const char * parent_group = hash_get_string( kw->gruptree_hash , child_group );
      
      stringlist_append_copy( child , child_group );       /* <- The iterator keys go out of scope when hash_iter_free() is called. */
      stringlist_append_ref( parent , parent_group );
    }
    hash_iter_free( iter );
  }
}
Esempio n. 5
0
void sched_kw_gruptree_fprintf(const sched_kw_gruptree_type * kw, FILE * stream)
{

  fprintf(stream, "GRUPTREE\n");
  {
    const int   num_keys = hash_get_size(kw->gruptree_hash);
    char ** child_list   = hash_alloc_keylist(kw->gruptree_hash);
    int i;

    for (i = 0; i < num_keys; i++) {
      const char * parent_name = hash_get_string(kw->gruptree_hash , child_list[i]);
      fprintf(stream,"  '%s'  '%s' /\n",child_list[i] , parent_name);
    }
    util_free_stringlist( child_list , num_keys );
  }
  fprintf(stream,"/\n\n");
};