示例#1
0
int ob_init(struct order_book *ob)
{
	if (!ob)
		goto fail;

	ob->ghbids = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free);
	if (!ob->ghbids)
		goto fail;

	ob->ghasks = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free);
	if (!ob->ghasks)
		goto fail;

	ob->gtasks = g_tree_new(g_uint_compare);
	if (!ob->gtasks)
		goto fail;

	ob->gtbids = g_tree_new(g_uint_compare);
	if (!ob->gtbids)
		goto fail;

	ob->glasks = NULL;
	ob->glbids = NULL;

	return 0;

fail:
	ob_fini(ob);
	return -1;
}
示例#2
0
/**
 * Initialize the RSFiletype subsystem, this MUST be called before any other
 * rs_filetype_*-functions
 */
void
rs_filetype_init(void)
{
	g_mutex_lock(&lock);
	if (rs_filetype_is_initialized)
		return;
	rs_filetype_is_initialized = TRUE;
	loaders = g_tree_new(tree_sort);
	meta_loaders = g_tree_new(tree_sort);
	g_mutex_unlock(&lock);
}
示例#3
0
文件: msn.c 项目: GRMrGecko/bitlbee
static void msn_login( account_t *acc )
{
	struct im_connection *ic = imcb_new( acc );
	struct msn_data *md = g_new0( struct msn_data, 1 );
	
	ic->proto_data = md;
	ic->flags |= OPT_PONGS | OPT_PONGED;
	
	if( strchr( acc->user, '@' ) == NULL )
	{
		imcb_error( ic, "Invalid account name" );
		imc_logout( ic, FALSE );
		return;
	}
	
	md->ic = ic;
	md->away_state = msn_away_state_list;
	md->domaintree = g_tree_new( msn_domaintree_cmp );
	md->ns->fd = -1;
	
	msn_connections = g_slist_prepend( msn_connections, ic );
	
	imcb_log( ic, "Connecting" );
	msn_ns_connect( ic, md->ns, MSN_NS_HOST, MSN_NS_PORT );
}
static gchar* _make_base_string(
                                GSignondSessionData *session_data, 
                                SoupURI* uri, gchar* nonce, gchar* timestamp)
{
    GString* base_string = g_string_new("POST&");
    
    gchar* base_uri;
    if (soup_uri_uses_default_port(uri))
        base_uri = g_strdup_printf("https://%s%s", soup_uri_get_host(uri),
                                                    soup_uri_get_path(uri));
    else
        base_uri = g_strdup_printf("https://%s:%u%s", soup_uri_get_host(uri),
                                                       soup_uri_get_port(uri),
                                                       soup_uri_get_path(uri));
    gchar* base_uri_e = _percent_encode(base_uri);
    g_string_append(base_string, base_uri_e);
    g_string_append(base_string, "&");
    g_free(base_uri);
    g_free(base_uri_e);
    
    GTree* parameters = g_tree_new((GCompareFunc)g_strcmp0);
    
    const gchar* query_s = soup_uri_get_query(uri);
    GHashTable* query;
    if (query_s != NULL)
        query = soup_form_decode(query_s);
    else    
        query = soup_form_decode("");
   
    g_hash_table_foreach(query, _insert_into_tree, parameters);
    
    const gchar* callback_uri = gsignond_dictionary_get_string(session_data, "Callback");
    if (callback_uri != NULL)
        g_tree_insert(parameters, "oauth_callback", (gchar*)callback_uri);
    const gchar* oauth_verifier = gsignond_dictionary_get_string(session_data, "_OauthVerifier");
    if (oauth_verifier != NULL)
        g_tree_insert(parameters, "oauth_verifier", (gchar*)oauth_verifier);
    g_tree_insert(parameters, "oauth_consumer_key", (gchar*)gsignond_dictionary_get_string(session_data, "ConsumerKey"));
    const gchar* oauth_temp_token = gsignond_dictionary_get_string(session_data, "_OauthTemporaryToken");
    if (oauth_temp_token != NULL)
        g_tree_insert(parameters, "oauth_token", (gchar*)oauth_temp_token);
    g_tree_insert(parameters, "oauth_signature_method", (gchar*)gsignond_dictionary_get_string(session_data, "SignatureMethod"));
    g_tree_insert(parameters, "oauth_nonce", nonce);
    g_tree_insert(parameters, "oauth_timestamp", timestamp);
    g_tree_insert(parameters, "oauth_version", "1.0");
    
    GString* parameters_string = g_string_new(NULL);
    g_tree_foreach(parameters, _make_parameters_string, parameters_string);
    gchar* parameters_s = g_string_free(parameters_string, FALSE);
    parameters_s[strlen(parameters_s)-1] = '\0'; //remove trailing '&'
    gchar* parameters_encoded = _percent_encode(parameters_s);
    g_string_append(base_string, parameters_encoded);
    
    g_free(parameters_encoded);
    g_free(parameters_s);
    g_tree_destroy(parameters);
    g_hash_table_destroy(query);
    
    return g_string_free(base_string, FALSE);
}
示例#5
0
int IDL_ns_check_for_ambiguous_inheritance (IDL_tree interface_ident, IDL_tree p)
{
	/* We use a sorted heap to check for namespace collisions,
	   since we must do case-insensitive collision checks.
	   visited_interfaces is a hash of visited interface nodes, so
	   we only visit common ancestors once. */
	GTree *ident_heap;
	GHashTable *visited_interfaces;
	int is_ambiguous = 0;

	if (!p)
		return 0;

	ident_heap = g_tree_new (IDL_ident_cmp);
	visited_interfaces = g_hash_table_new (g_direct_hash, g_direct_equal);

	assert (IDL_NODE_TYPE (p) == IDLN_LIST);
	for (; p;  p = IDL_LIST (p).next) {
		if (!IDL_ns_load_idents_to_tables (interface_ident, IDL_LIST (p).data,
						   ident_heap, visited_interfaces))
			is_ambiguous = 1;
	}

	g_tree_destroy (ident_heap);
	g_hash_table_destroy (visited_interfaces);

	return is_ambiguous;
}
示例#6
0
文件: emc_server.c 项目: regit/nufw
int emc_init_server(struct emc_server_context *ctx)
{
	int result;
	int max_workers;
	char *emc_data_file;

	g_thread_init(NULL);

	max_workers = emc_config_table_get_or_default_int("emc_max_workers", EMC_DEFAULT_MAX_WORKERS);
	emc_data_file = emc_config_table_get("emc_data_file");

	ctx->nuauth_directory = g_tree_new( emc_netmask_order_func );

	result = emc_parse_datafile(ctx, emc_data_file);
	if (result < 0) {
		return -1;
	}

	loop = ev_default_loop(0);

	result = emc_setup_servers(loop, ctx);
	if (result < 0) {
		return -1;
	}

	ev_signal_init(&sigint_watcher, sigint_cb, SIGINT);
	ev_signal_start(loop, &sigint_watcher);

	ev_signal_init(&sigterm_watcher, sigint_cb, SIGTERM);
	ev_signal_start(loop, &sigterm_watcher);

	ev_signal_init(&sigusr1_watcher, sigusr1_cb, SIGUSR1);
	ev_signal_start(loop, &sigusr1_watcher);

	ev_async_init(&client_ready_signal, emc_client_ready_cb);
	ev_async_start(loop, &client_ready_signal);

	ctx->continue_processing = 1;
	sigint_watcher.data = ctx;
	sigterm_watcher.data = ctx;
	sigusr1_watcher.data = ctx;
	client_ready_signal.data = ctx;

	g_thread_pool_set_max_unused_threads( (int)(max_workers/2) );

	ctx->pool_tls_handshake = g_thread_pool_new((GFunc)emc_worker_tls_handshake, NULL,
						    max_workers, FALSE,
						    NULL);
	ctx->pool_reader = g_thread_pool_new((GFunc)emc_worker_reader, NULL,
						    max_workers, FALSE,
						    NULL);

	ctx->work_queue = g_async_queue_new();

	ctx->tls_client_list_mutex = g_mutex_new();

	log_printf(DEBUG_LEVEL_DEBUG, "Max: %d", g_thread_pool_get_max_unused_threads());

	return 0;
}
示例#7
0
文件: object.c 项目: dsheeler/xmms2
void
xmms_object_connect (xmms_object_t *object, guint32 signalid,
                     xmms_object_handler_t handler, gpointer userdata)
{
	GList *list = NULL;
	xmms_object_handler_entry_t *entry;

	g_return_if_fail (object);
	g_return_if_fail (XMMS_IS_OBJECT (object));
	g_return_if_fail (handler);

	entry = g_new0 (xmms_object_handler_entry_t, 1);
	entry->handler = handler;
	entry->userdata = userdata;

	if (!object->signals)
		object->signals = g_tree_new (compare_signal_key);
	else
		list = g_tree_lookup (object->signals,
		                      GINT_TO_POINTER (signalid));

	list = g_list_prepend (list, entry);

	/* store the list's new head in the tree */
	g_tree_insert (object->signals, GINT_TO_POINTER (signalid), list);
}
int main() {
	GTree *tokens;
	gboolean is_first = TRUE;
	gint i;

	tokens = g_tree_new((GCompareFunc)g_ascii_strcasecmp);

	for (i = 0; i < sql_token_get_last_id(); i++) {
		/** only tokens with TK_SQL_* are keyworks */
		if (0 != strncmp(sql_token_get_name(i, NULL), "TK_SQL_", sizeof("TK_SQL_") - 1)) continue;

		g_tree_insert(tokens, ( gpointer ) (sql_token_get_name(i, NULL) + sizeof("TK_SQL_") - 1), GINT_TO_POINTER(i));
	}

	/* traverse the tree and output all keywords in a sorted way */
	printf("static int sql_keywords[] = {");
	g_tree_foreach(tokens, trav, &is_first);
	printf("\n};\n");

	printf("int *sql_keywords_get() { return sql_keywords; }\n");
	printf("int sql_keywords_get_count() { return sizeof(sql_keywords) / sizeof(sql_keywords[0]); }\n");

	g_tree_destroy(tokens);

	return 0;
}
示例#9
0
static void
fontsel_insert_face (const FT_Face  face,
		     const gchar   *file_name,
		     const gint     face_index)
{
  GTree    *family;
  FontFace *font;
  gchar    *name;

  family = g_tree_lookup (families, face->family_name);
  if (!family)
    {
      family = g_tree_new ((GCompareFunc) strcmp);
      name   = g_strdup (face->family_name);
      g_tree_insert (families, name, family);
    }

  font = g_new (FontFace, 1);
  font->file_name   = g_strdup (file_name);
  font->face_index  = face_index;
  font->family_name = g_strdup (face->family_name);

  if (face->style_name)
    name = g_strdup (face->style_name);
  else
    name = g_strdup ("(unknown)");

  font->style_name  = name;

  g_tree_insert (family, name, font);
}
示例#10
0
static void httpserver_init (HTTPServer *http_server)
{
    gint i;
    RequestData *request_data;

    http_server->listen_thread = NULL;
    http_server->thread_pool = NULL;
    g_mutex_init (&(http_server->request_data_queue_mutex));
    http_server->request_data_queue = g_queue_new ();
    for (i=0; i<kMaxRequests; i++) {
        request_data = (RequestData *)g_malloc (sizeof (RequestData));
        g_mutex_init (&(request_data->events_mutex));
        request_data->id = i;
        request_data->num_headers = 0;
        http_server->request_data_pointers[i] = request_data;
        g_queue_push_head (http_server->request_data_queue, &http_server->request_data_pointers[i]);
    }

    g_mutex_init (&(http_server->idle_queue_mutex));
    g_cond_init (&(http_server->idle_queue_cond));
    http_server->idle_queue = g_tree_new ((GCompareFunc)compare_func);

    g_mutex_init (&(http_server->block_queue_mutex));
    g_cond_init (&(http_server->block_queue_cond));
    http_server->block_queue = g_queue_new ();

    http_server->total_click = 0;
    http_server->encoder_click = 0;
    http_server->system_clock = gst_system_clock_obtain ();
    g_object_set (http_server->system_clock, "clock-type", GST_CLOCK_TYPE_REALTIME, NULL);
}
示例#11
0
/* add a new playlist entry into the table (number, name and random/not random) */
void irmpc_playlist_add (unsigned int number, const char *name, bool random)
{
    if (name == NULL) return;

    if (playlist_name_storage == NULL) {
        playlist_name_storage = g_string_chunk_new (64);
        if (playlist_name_storage == NULL) return;
    }

    gchar *entry_name = g_string_chunk_insert (playlist_name_storage, name);

    if (playlist_table == NULL) {
        playlist_table = g_tree_new (irmpc_playlist_table_cmp_func);
        if (playlist_table == NULL) return;
    }

    struct playlist_info *entry;

    entry = (struct playlist_info *) malloc (sizeof (struct playlist_info));
    if (entry == NULL) return;

    entry->name   = entry_name;
    entry->random = random;

    g_tree_insert (playlist_table, GINT_TO_POINTER(number), entry);
}
示例#12
0
void b_malloc_init(unsigned long heap_nbytes)
{
  bm = bitmap_init((heap_nbytes/BITMAP_BIT_NUM_BYTES)/CHAR_BIT);

  heap_info = g_tree_new((GCompareFunc) compare_heap_entry);
  heap = malloc(heap_nbytes);
}
示例#13
0
int MailboxState_flush_recent(T M) 
{
	GList *recent;

	if ((!M) || (M && MailboxState_getPermission(M) != IMAPPERM_READWRITE))
		return DM_SUCCESS;

	if (! g_tree_nnodes(M->recent_queue))
		return DM_SUCCESS;

	TRACE(TRACE_DEBUG,"flush [%d] recent messages", g_tree_nnodes(M->recent_queue));

	recent = g_tree_keys(M->recent_queue);

	if (recent) {
		long long int changed = 0;
		uint64_t seq = MailboxState_getSeq(M);
		changed = _update_recent(g_list_slices_u64(recent,100), seq+1);
		if (changed)
			db_mailbox_seq_update(MailboxState_getId(M), 0);
	}

	g_list_free(g_list_first(recent));

	g_tree_foreach(M->recent_queue, (GTraverseFunc)_free_recent_queue, M);
	g_tree_destroy(M->recent_queue);
	M->recent_queue = g_tree_new((GCompareFunc)ucmp);

	return 0;
}
示例#14
0
static void
wavegen_init(Machine *mach, WaveGenType type)
{
  WaveGen *wavegen = WAVEGEN (mach);

  machine_init (mach);

  /* Set up callbacks
   */

  mach->noteon = wavegen_noteon;
  mach->noteoff = wavegen_noteoff;
  mach->do_stuff = wavegen_do_stuff;
  mach->all_notes_off = wavegen_all_notes_off;
  mach->free = wavegen_free;

  wavegen->notes = g_tree_new (note_compare_func);

  wavegen->type = type;
#ifdef 0
  if (type == WAVEGEN_SINE)
    {
      wavegen->wavetable_size = 1024;
      wavegen->wavetable = g_new (gfloat, wavegen->wavetable_size);
      init_wavetable_sine (wavegen->wavetable, wavegen->wavetable_size);
    }
  else
    {
      wavegen->wavetable_size = 0;
      wavegen->wavetable = NULL;
    }
#endif
}
示例#15
0
文件: keyboard.c 项目: ahf/irssi
void keyboard_init(void)
{
	keys = g_hash_table_new((GHashFunc) g_str_hash,
				(GCompareFunc) g_str_equal);
	default_keys = g_hash_table_new((GHashFunc) g_str_hash,
					(GCompareFunc) g_str_equal);
	keyinfos = NULL;
	key_states = g_tree_new((GCompareFunc) g_strcmp0);
        key_config_frozen = 0;
	memset(used_keys, 0, sizeof(used_keys));

	settings_add_int("misc", "key_timeout", 0);

	key_bind("command", "Run any command", NULL, NULL, (SIGNAL_FUNC) sig_command);
	key_bind("key", "Specify name for key binding", NULL, NULL, (SIGNAL_FUNC) sig_key);
	key_bind("multi", "Run multiple commands", NULL, NULL, (SIGNAL_FUNC) sig_multi);
	key_bind("nothing", "Do nothing", NULL, NULL, (SIGNAL_FUNC) sig_nothing);

	/* read the keyboard config when all key binds are known */
	signal_add("irssi init read settings", (SIGNAL_FUNC) read_keyboard_config);
	signal_add("setup reread", (SIGNAL_FUNC) read_keyboard_config);
	signal_add("complete command bind", (SIGNAL_FUNC) sig_complete_bind);

	command_bind("bind", NULL, (SIGNAL_FUNC) cmd_bind);
	command_set_options("bind", "delete list");
}
示例#16
0
文件: i2c.c 项目: useche/btstats
void i2c_init(struct plugin *p, struct plugin_set *__un1, struct plug_args *pa)
{
	char filename[FILENAME_MAX];
	struct i2c_data *i2c = p->data = g_new(struct i2c_data,1);

	i2c->is = g_tree_new(comp_int64);
	i2c->outstanding = 0;
	i2c->maxouts = 0;

	i2c->oio_f = NULL;
	if(pa->i2c_oio_f) {
		get_filename(filename, "i2c_oio", pa->i2c_oio_f, pa->end_range);
		i2c->oio_f = fopen(filename,"w");
		if(!i2c->oio_f) perror_exit("Opening I2C detail file");
	}

	i2c->oio_hist_f = NULL;
	if(pa->i2c_oio_hist_f) {
		get_filename(filename, "i2c_oio_hist", pa->i2c_oio_hist_f, pa->end_range);
		i2c->oio_hist_f = fopen(filename,"w");
		if(!i2c->oio_hist_f) perror_exit("Opening I2C detail file");
	}

	i2c->oio = NULL;
	i2c->oio_size = 0;
	i2c->oio_prev_time = UINT64_MAX;
}
示例#17
0
文件: plugins.c 项目: useche/btstats
void init_plugs_ops() 
{
	int i;	
	for(i = 0; i < N_PLUGINS; ++i) {
		ps_ops[i].event_tree = g_tree_new(comp_int);
		if(plug_init_dest[i].ops_init)
			plug_init_dest[i].ops_init(&ps_ops[i]);
	}
}
示例#18
0
/* --- functions --- */
static void
eva_main_loop_select_init (EvaMainLoopSelect *main_loop_select)
{
  main_loop_select->fd_tree = g_tree_new (compare_raw_ints);

  /* XXX: waste of time unless FD_ZERO is not a bitwise zero-ing */
  FD_ZERO (&main_loop_select->read_set);
  FD_ZERO (&main_loop_select->write_set);
  FD_ZERO (&main_loop_select->except_set);
}
示例#19
0
文件: fbapi.c 项目: hellais/Adium-old
static GString *purple_fbapi_construct_request_vargs(PurpleAccount *account, const char *method, va_list args)
{
	GTree *params;
	const char *api_key, *api_secret;
	const char *key, *value;
	char call_id[21];
	char *signature;
	GString *body;

	/* Read all paramters into a sorted tree */
	params = g_tree_new((GCompareFunc)strcmp);
	while ((key = va_arg(args, const char *)) != NULL)
	{
		value = va_arg(args, const char *);
		g_tree_insert(params, (char *)key, (char *)value);

		/* If we have a session_key then we need a call_id */
		if (g_str_equal(key, "session_key")) {
			struct timeval tv;
			if (gettimeofday(&tv, NULL) != 0) {
				time_t now;
				purple_debug_error("fbapi",
						"Error calling gettimeofday(): %s\n",
						g_strerror(errno));
				now = time(NULL);
				strftime(call_id, sizeof(call_id), "%s000000", localtime(&now));
			} else {
				char tmp[22];
				strftime(tmp, sizeof(tmp), "%s", localtime(&tv.tv_sec));
				sprintf(call_id, "%s%06lu", tmp, (long unsigned int)tv.tv_usec);
			}
			g_tree_insert(params, "call_id", call_id);
		}
	}

	api_key = purple_account_get_string(account, "fb_api_key", PURPLE_FBAPI_KEY);
	api_secret = purple_account_get_string(account, "fb_api_secret", API_SECRET);

	/* Add the method and api_key parameters to the list */
	g_tree_insert(params, "method", (char *)method);
	g_tree_insert(params, "api_key", (char *)api_key);

	/* Add the signature parameter to the list */
	signature = generate_signature((char *)api_secret, params);
	g_tree_insert(params, "sig", signature);

	/* Construct the body of the HTTP POST request */
	body = g_string_new(NULL);
	g_tree_foreach(params, append_params_to_body, body);
	g_tree_destroy(params);
	g_free(signature);

	return body;
}
示例#20
0
GTree* pooltag_build_tree() {
    GTree *pooltags = g_tree_new((GCompareFunc) strcmp);

    uint32_t i = 0;
    for (; i < TAG_COUNT; i++) {
        g_tree_insert(pooltags, (char*) tags[i].tag,
                (char*) &tags[i]);
    }

    return pooltags;
}
示例#21
0
void
wavegen_all_notes_off (Machine *mach)
{
  WaveGen *wavegen = WAVEGEN (mach);

  /* BAD STUFF: doesn't free the WaveGenNote! */
  /* I know this (below) sucks, but I'm gonna switch to another
   * tree implementation (libavl) */
  g_tree_destroy (wavegen->notes);
  wavegen->notes = g_tree_new (note_compare_func);
}
示例#22
0
static void __ice_agent_initialize(struct ice_agent *ag) {
	struct call_media *media = ag->media;
	struct call *call = ag->call;

	ag->candidate_hash = g_hash_table_new(__cand_hash, __cand_equal);
	ag->pair_hash = g_hash_table_new(__pair_hash, __pair_equal);
	ag->transaction_hash = g_hash_table_new(__trans_hash, __trans_equal);
	ag->foundation_hash = g_hash_table_new(__found_hash, __found_equal);
	ag->agent_flags = 0;
	bf_copy(&ag->agent_flags, ICE_AGENT_CONTROLLING, &media->media_flags, MEDIA_FLAG_ICE_CONTROLLING);
	ag->local_interface = media->interface;
	ag->desired_family = media->desired_family;
	ag->nominated_pairs = g_tree_new(__pair_prio_cmp);
	ag->valid_pairs = g_tree_new(__pair_prio_cmp);
	ag->succeeded_pairs = g_tree_new(__pair_prio_cmp);
	ag->all_pairs = g_tree_new(__pair_prio_cmp);

	create_random_ice_string(call, &ag->ufrag[1], 8);
	create_random_ice_string(call, &ag->pwd[1], 26);
}
示例#23
0
文件: glib_tree4.c 项目: mitchty/src
int main(void) {
  GTree *t = g_tree_new((GCompareFunc)g_ascii_strcasecmp);
  g_tree_insert(t, "d", "Detroit");
  g_tree_insert(t, "a", "Atlanta");
  g_tree_insert(t, "c", "Chicago");
  g_tree_insert(t, "b", "Boston");
  puts("Iterating over all nodes");
  g_tree_foreach(t, (GTraverseFunc)iterate_all, NULL);
  puts("Iterating over some specific nodes");
  g_tree_foreach(t, (GTraverseFunc)iterate_some, NULL);
  g_tree_destroy(t);
}
示例#24
0
文件: execplugin.c 项目: o9000/tint2
Execp *create_execp()
{
	Execp *execp = calloc(1, sizeof(Execp));
	execp->backend = calloc(1, sizeof(ExecpBackend));
	execp->backend->child_pipe = -1;
	execp->backend->cmd_pids = g_tree_new(cmp_ptr);
	execp->backend->interval = 30;
	execp->backend->cache_icon = TRUE;
	execp->backend->centered = TRUE;
	execp->backend->font_color.alpha = 0.5;
	return execp;
}
示例#25
0
void init_X11() {
    server.dsp = XOpenDisplay(NULL);
    if (!server.dsp) DIE("tint: could not open display.");

    server_init_atoms();
    server.screen = DefaultScreen(server.dsp);
    server.root_win = RootWindow(server.dsp, server.screen);
    server.desktop = server_get_current_desktop();
    server_init_visual();
    XSetErrorHandler((XErrorHandler)server_catch_error);

#ifdef HAVE_SN
    // Initialize startup-notification
    server.sn_dsp = sn_display_new(server.dsp, error_trap_push, error_trap_pop);
    server.pids = g_tree_new(cmp_ptr);
    // Setup a handler for child termination
    struct sigaction act;
    memset(&act, 0, sizeof(struct sigaction));
    act.sa_handler = sigchld_handler;
    if (sigaction(SIGCHLD, &act, 0)) {
        perror("sigaction");
    }
#endif  // HAVE_SN

    imlib_context_set_display(server.dsp);
    imlib_context_set_visual(server.visual);
    imlib_context_set_colormap(server.colormap);

    /* Catch events */
    XSelectInput(server.dsp, server.root_win,
                 PropertyChangeMask | StructureNotifyMask);

    setlocale(LC_ALL, "");
    // config file use '.' as decimal separator
    setlocale(LC_NUMERIC, "POSIX");

    // load default icon
    gchar* path;
    const gchar* const* data_dirs;
    data_dirs = g_get_system_data_dirs();
    int i;
    for (i = 0; data_dirs[i] != NULL; i++) {
        path = g_build_filename(data_dirs[i], "tinto", "default_icon.png", NULL);
        if (g_file_test(path, G_FILE_TEST_EXISTS))
            default_icon = imlib_load_image(path);
        g_free(path);
    }

    // get monitor and desktop config
    get_monitors();
    get_desktops();
}
示例#26
0
static inline void initialize_static()
{
    if (!static_initialized)
    {
        GQuark q = 0;
        administrands = g_tree_new(ptr_compare);
        quark_to_char = g_hash_table_new(g_direct_hash, g_direct_equal);
        char_to_quark = g_array_new(FALSE, FALSE, sizeof(GQuark));
        g_hash_table_insert(quark_to_char, 0, 0);
        g_array_append_val(char_to_quark, q);
        static_initialized = TRUE;
    }
}
示例#27
0
文件: glib_tree1.c 项目: mitchty/src
int main(void) {
  GTree *t = g_tree_new((GCompareFunc)g_ascii_strcasecmp);
  g_tree_insert(t, "c", "Chicago");
  printf("The tree height is %d\n", g_tree_height(t));
  g_tree_insert(t, "b", "Boston");
  g_tree_insert(t, "d", "Detroit");
  printf("Height is now %d for %d nodes in the tree\n", g_tree_height(t),
         g_tree_nnodes(t));
  g_tree_remove(t, "d");
  printf("Height is now %d for %d nodes in the tree\n", g_tree_height(t),
         g_tree_nnodes(t));
  g_tree_destroy(t);
}
示例#28
0
文件: object.c 项目: dsheeler/xmms2
/**
  * Add a command that could be called from the client API to a object.
  *
  * @param object The object that should have the method.
  * @param cmdid A command id.
  * @param desc A command description.
  */
void
xmms_object_cmd_add (xmms_object_t *object, guint cmdid,
                     const xmms_object_cmd_func_t func)
{
	g_return_if_fail (object);
	g_return_if_fail (func);

	if (!object->cmds)
		object->cmds = g_tree_new (compare_cmd_key);

	g_tree_insert (object->cmds, GUINT_TO_POINTER (cmdid),
	               (gpointer) func);
}
示例#29
0
文件: keyboard.c 项目: ahf/irssi
/* Rescan all the key combos and figure out which characters are supposed
   to be treated as characters and which as key combos.
   Yes, this is pretty slow function... */
static void key_states_rescan(void)
{
	GString *temp;

	memset(used_keys, 0, sizeof(used_keys));

	g_tree_foreach(key_states, (GTraverseFunc) key_state_destroy,
			NULL);
	g_tree_destroy(key_states);
	key_states = g_tree_new((GCompareFunc) g_strcmp0);

        temp = g_string_new(NULL);
	g_hash_table_foreach(keys, (GHFunc) key_states_scan_key, temp);
        g_string_free(temp, TRUE);
}
示例#30
0
/**
 * itdb_track_id_tree_create:
 * @itdb: an #Itdb_iTunesDB
 *
 * Creates a balanced-binary tree for quick ID lookup that is used in
 * itdb_track_by_id_tree()
 *
 * Returns: a #GTree indexed by track IDs to be freed with
 * itdb_track_id_tree_destroy() when no longer used
 */
GTree *itdb_track_id_tree_create (Itdb_iTunesDB *itdb)
{
    GTree *idtree;
    GList *gl;

    g_return_val_if_fail (itdb, NULL);

    idtree = g_tree_new (track_id_compare);

    for (gl=itdb->tracks; gl; gl=gl->next)
    {
	Itdb_Track *tr = gl->data;
	g_return_val_if_fail (tr, NULL);
	g_tree_insert (idtree, &tr->id, tr);
    }
    return idtree;
}