/* * Copies to printerName the name of the next printer in the list. * The StringBuilder passed in "printerName" must EnsureCapacity of at least MAX_PRINTER_NAME_SIZE, * which is the limit that we artificially impose. * In the next invocation after the last printer is retrieved, * the memory of the local list of printers is freed, and an empty ("") string passed back. * - isShared: true if printerName is shared with the guest. */ void SpiceGlibGlueGetNextLocalPrinter(char* printerName, int32_t* isShared) { SPICE_DEBUG("FMP: SpiceGlibGlueGetNextLocalPrinter()"); // When we get get past the end of the list, free the list if (localPrinter == NULL) { SPICE_DEBUG("FMP: No more printers."); printerName[0]= '\0'; g_slist_free_full(localPrinters, g_free); localPrinters= NULL; } else { strncpy(printerName, (const char *)localPrinter->data, MAX_PRINTER_NAME_SIZE); gboolean inSharedSet = g_hash_table_contains (sharedPrinters, printerName); *isShared= inSharedSet?1:0; SPICE_DEBUG("FMP: Found printer %s shared %d", (const char *)localPrinter->data, *isShared); localPrinter = g_slist_next(localPrinter); } }
void delete_vars_from_set(sc_memory_context *context, scp_operand *set, GHashTable *non_erasable_vars) { scp_operand arc1, arc2, elem; scp_iterator5 *it; MAKE_DEFAULT_ARC_ASSIGN(arc1); MAKE_DEFAULT_ARC_ASSIGN(arc2); MAKE_DEFAULT_OPERAND_ASSIGN(elem); elem.erase = SCP_TRUE; it = scp_iterator5_new(context, set, &arc1, &elem, &arc2, &rrel_scp_var); while (SCP_RESULT_TRUE == scp_iterator5_next(context, it, set, &arc1, &elem, &arc2, &rrel_scp_var)) { elem.param_type = SCP_FIXED; if (non_erasable_vars != nullptr && FALSE == g_hash_table_contains(non_erasable_vars, MAKE_HASH(elem))) { eraseEl(context, &elem); } elem.param_type = SCP_ASSIGN; } scp_iterator5_free(it); }
/** * Add an event source for a file descriptor. * * @param session The session to use. Must not be NULL. * @param key The key which identifies the event source. * @param source An event source object. Must not be NULL. * * @retval SR_OK Success. * @retval SR_ERR_ARG Invalid argument. * @retval SR_ERR_BUG Event source with @a key already installed. * @retval SR_ERR Other error. * * @private */ SR_PRIV int sr_session_source_add_internal(struct sr_session *session, void *key, GSource *source) { /* * This must not ever happen, since the source has already been * created and its finalize() method will remove the key for the * already installed source. (Well it would, if we did not have * another sanity check there.) */ if (g_hash_table_contains(session->event_sources, key)) { sr_err("Event source with key %p already exists.", key); return SR_ERR_BUG; } g_hash_table_insert(session->event_sources, key, source); if (session_source_attach(session, source) == 0) return SR_ERR; return SR_OK; }
static gboolean refresh_cache_helper (gpointer key, gpointer value, gpointer data) { Resource *resource; GHashTable *fresh_resources; resource = value; fresh_resources = data; if (g_hash_table_contains (fresh_resources, key)) return FALSE; else { g_signal_emit (resource->resource_browser, signals[RESOURCE_UNAVAILABLE], 0, resource->usn); return TRUE; } }
void enable_plugin(GSettings* gsettings, char const* id, gboolean value) { if (value && !g_hash_table_contains(enabled_plugins, id)) { g_hash_table_add(enabled_plugins, g_strdup(id)); g_hash_table_replace(plugins_state, g_strdup(id), GINT_TO_POINTER(ENABLED_PLUGIN)); } else if (!value) { g_hash_table_remove(enabled_plugins, id); g_hash_table_replace(plugins_state, g_strdup(id), GINT_TO_POINTER(DISABLED_PLUGIN)); } GPtrArray* values = g_ptr_array_new_with_free_func(g_free); g_hash_table_foreach(enabled_plugins, create_strv, (gpointer)values); g_ptr_array_add(values, NULL); g_settings_set_strv(gsettings, SCHEMA_KEY_ENABLED_PLUGINS, (char const* const*)values->pdata); g_ptr_array_unref(values); g_settings_sync(); }
/* Get image from cache if available */ static ClutterImage* _xfdashboard_image_content_get_cached_image(const gchar *inKey) { ClutterImage *image; /* If no key is given the image is not stored */ if(!inKey || *inKey==0) return(NULL); /* If we have no hash table no image is cached */ if(!_xfdashboard_image_content_cache) return(NULL); /* Lookup key in cache and return image if found */ if(!g_hash_table_contains(_xfdashboard_image_content_cache, inKey)) return(NULL); /* Get loaded image and reference it */ image=CLUTTER_IMAGE(g_hash_table_lookup(_xfdashboard_image_content_cache, inKey)); g_object_ref(image); g_debug("Using cached image '%s' - ref-count is now %d" , inKey, G_OBJECT(image)->ref_count); return(image); }
static gboolean system_timezone_is_valid (const gchar *tz, GHashTable *ical_zones) { const gchar *c; if (tz == NULL) return FALSE; for (c = tz; *c != '\0'; c++) { if (!(g_ascii_isalnum (*c) || *c == '/' || *c == '-' || *c == '_')) return FALSE; } if (ical_zones == NULL) return TRUE; return g_hash_table_contains (ical_zones, tz); }
static void namespace_watcher_name_appeared (NamespaceWatcher *watcher, const gchar *name, const gchar *owner) { /* There's a race between NameOwnerChanged signals arriving and the * ListNames/GetNameOwner sequence returning, so this function might * be called more than once for the same name. To ensure that * appeared_handler is only called once for each name, it is only * called when inserting the name into watcher->names (each name is * only inserted once there). */ if (g_hash_table_contains (watcher->names, name)) return; g_hash_table_add (watcher->names, g_strdup (name)); if (watcher->appeared_handler) watcher->appeared_handler (watcher->connection, name, owner, watcher->user_data); }
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str) { assert(jid != NULL); Jid *jidp = jid_create(jid); if (jidp->domainpart) { muc_confserver_add(jidp->domainpart); } jid_destroy(jidp); if (g_hash_table_contains(bookmarks, jid)) { return FALSE; } Bookmark *bookmark = malloc(sizeof(Bookmark)); bookmark->barejid = strdup(jid); if (nick) { bookmark->nick = strdup(nick); } else { bookmark->nick = NULL; } if (password) { bookmark->password = strdup(password); } else { bookmark->password = NULL; } if (g_strcmp0(autojoin_str, "on") == 0) { bookmark->autojoin = TRUE; } else { bookmark->autojoin = FALSE; } g_hash_table_insert(bookmarks, strdup(jid), bookmark); autocomplete_add(bookmark_ac, jid); _send_bookmarks(); return TRUE; }
/* Store image in cache */ static void _xfdashboard_image_content_store_in_cache(XfdashboardImageContent *self, const gchar *inKey) { XfdashboardImageContentPrivate *priv; g_return_if_fail(XFDASHBOARD_IS_IMAGE_CONTENT(self)); g_return_if_fail(inKey && *inKey!=0); priv=self->priv; /* Create cache hashtable */ if(!_xfdashboard_image_content_cache) _xfdashboard_image_content_create_cache(); /* Set key */ if(priv->key) { g_critical(_("Image has already key '%s' set and will be replaced with '%s'"), priv->key, inKey); g_free(priv->key); priv->key=NULL; } priv->key=g_strdup(inKey); /* Store image in cache */ if(g_hash_table_contains(_xfdashboard_image_content_cache, priv->key)) { ClutterContent *content; g_critical(_("An image with key '%s' is already cache and will be replaced."), priv->key); /* Unreference current cached image */ content=CLUTTER_CONTENT(g_hash_table_lookup(_xfdashboard_image_content_cache, inKey)); if(content) { g_object_unref(content); g_debug("Replacing image '%s' which had ref-count %u", priv->key, G_OBJECT(content)->ref_count); } } /* Store new image in cache */ g_hash_table_insert(_xfdashboard_image_content_cache, priv->key, self); g_debug("Added image '%s' with ref-count %d" , priv->key, G_OBJECT(self)->ref_count); }
static gboolean kms_dummy_sink_request_new_sink_pad (KmsElement * obj, KmsElementPadType type, const gchar * description, const gchar * name) { KmsDummySink *self = KMS_DUMMY_SINK (obj); KmsDummySinkElement *dummy; GstElement *sink; GstPad *sinkpad; KMS_ELEMENT_LOCK (KMS_ELEMENT (self)); if (g_hash_table_contains (self->priv->sinks, name)) { KMS_ELEMENT_UNLOCK (KMS_ELEMENT (self)); return TRUE; } sink = gst_element_factory_make ("fakesink", NULL); g_object_set (sink, "async", FALSE, "sync", FALSE, NULL); dummy = create_dummy_sink_element (type, description, sink); if (!gst_bin_add (GST_BIN (self), sink)) { KMS_ELEMENT_UNLOCK (KMS_ELEMENT (self)); destroy_dummy_sink_element (dummy); return FALSE; } g_hash_table_insert (self->priv->sinks, g_strdup (name), dummy); KMS_ELEMENT_UNLOCK (KMS_ELEMENT (self)); gst_element_sync_state_with_parent (sink); sinkpad = gst_element_get_static_pad (sink, "sink"); kms_element_connect_sink_target_full (KMS_ELEMENT (self), sinkpad, type, description, NULL, NULL); g_object_unref (sinkpad); return TRUE; }
static void etfci_rebuild_combined (ETableFieldChooserItem *etfci) { gint count; GHashTable *hash; gint i; if (etfci->combined_header != NULL) g_object_unref (etfci->combined_header); etfci->combined_header = e_table_header_new (); hash = g_hash_table_new (NULL, NULL); count = e_table_header_count (etfci->header); for (i = 0; i < count; i++) { ETableCol *ecol = e_table_header_get_column (etfci->header, i); if (ecol->spec->disabled) continue; g_hash_table_add ( hash, GINT_TO_POINTER (ecol->spec->model_col)); } count = e_table_header_count (etfci->full_header); for (i = 0; i < count; i++) { ETableCol *ecol; gpointer key; ecol = e_table_header_get_column (etfci->full_header, i); key = GINT_TO_POINTER (ecol->spec->model_col); if (ecol->spec->disabled) continue; if (!g_hash_table_contains (hash, key)) e_table_header_add_column ( etfci->combined_header, ecol, -1); } g_hash_table_destroy (hash); }
void autocompleters_add(const char *const plugin_name, const char *key, char **items) { GHashTable *key_to_ac = g_hash_table_lookup(plugin_to_acs, plugin_name); if (key_to_ac) { if (g_hash_table_contains(key_to_ac, key)) { Autocomplete existing_ac = g_hash_table_lookup(key_to_ac, key); autocomplete_add_all(existing_ac, items); } else { Autocomplete new_ac = autocomplete_new(); autocomplete_add_all(new_ac, items); g_hash_table_insert(key_to_ac, strdup(key), new_ac); } } else { key_to_ac = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)autocomplete_free); Autocomplete new_ac = autocomplete_new(); autocomplete_add_all(new_ac, items); g_hash_table_insert(key_to_ac, strdup(key), new_ac); g_hash_table_insert(plugin_to_acs, strdup(plugin_name), key_to_ac); } }
static gboolean insert_value (GUPnPDLNAInfoSet *info_set, const gchar *name, GUPnPDLNAInfoValue *value) { if (value == NULL) { g_debug ("Info set: value '%s' is NULL.", name); return FALSE; } if (g_hash_table_contains (info_set->entries, name)) { g_debug ("Info set: value '%s' already exists.", name); gupnp_dlna_info_value_free (value); return FALSE; } g_hash_table_insert (info_set->entries, g_strdup (name), value); return TRUE; }
static void _concat_hash_func (GHashTable *table1, GHashTable *table2) { GHashTableIter iter; gpointer key, value1, value2; g_hash_table_iter_init (&iter, table2); while (g_hash_table_iter_next (&iter, &key, &value2)) { if (g_hash_table_contains (table1, key)) { value1 = g_hash_table_lookup (table1, key); value1 = GINT_TO_POINTER (GPOINTER_TO_INT (value1) + GPOINTER_TO_INT (value2)); g_hash_table_insert (table1, key, value1); } else { g_hash_table_insert (table1, key, value2); } } }
static void egg_task_cache_populate (EggTaskCache *self, gconstpointer key, gpointer value) { CacheItem *item; g_assert (EGG_IS_TASK_CACHE (self)); item = cache_item_new (self, key, value); if (g_hash_table_contains (self->cache, key)) egg_task_cache_evict (self, key); g_hash_table_insert (self->cache, item->key, item); egg_heap_insert_val (self->evict_heap, item); EGG_COUNTER_INC (cached); if (self->evict_source != NULL) evict_source_rearm (self->evict_source); }
void pnl_dock_transient_grab_release (PnlDockTransientGrab *self) { guint i; g_return_if_fail (PNL_IS_DOCK_TRANSIENT_GRAB (self)); g_return_if_fail (self->acquired == TRUE); for (i = 0; i < self->items->len; i++) { PnlDockItem *item = g_ptr_array_index (self->items, i); if (g_hash_table_contains (self->hidden, item)) { PnlDockItem *parent = pnl_dock_item_get_parent (item); if (parent != NULL) pnl_dock_item_set_child_visible (parent, item, FALSE); } } }
static gboolean user_classify_is_blacklisted (const char *username) { static GHashTable *exclusions; if (exclusions == NULL) { guint i; exclusions = g_hash_table_new (g_str_hash, g_str_equal); for (i = 0; i < G_N_ELEMENTS (default_excludes); i++) { g_hash_table_add (exclusions, (gpointer) default_excludes[i]); } } if (g_hash_table_contains (exclusions, username)) { return TRUE; } return FALSE; }
void dolink() { if(!opt_id) { g_error("Please specify --id when linking\n"); } if(!opt_link) { g_error("An absolute path must be specified with --link\n"); } if(opt_link[0] != '/') { g_error("An absolute path must be specified when linking\n"); } GHashTable* erlangs = get_erlangs(); gboolean result = g_hash_table_contains(erlangs, opt_id); g_hash_table_destroy(erlangs); if(result) { g_error("An installation of Erlang is already referenced by ID %s\n", opt_id); } gchar* erlpath = g_strconcat(opt_link, "/bin/erl", NULL); g_debug("checking for %s\n", erlpath); gboolean exists = g_file_test(erlpath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR); g_free(erlpath); if(!exists) { g_error("Can't link to an empty Erlang installation\n"); } gchar* output_root = get_config_subdir_file_name("otps", opt_id); gchar* output_path = g_strconcat(output_root, "/dist", NULL); if(g_mkdir_with_parents(output_root, 0755) == -1) { g_error("Cannot create OTP installation directory %s\n", output_path); } set_config_kv("Erlangs", opt_id, output_root); gchar* cmd = g_strconcat("ln -s -f ", opt_link, " ", output_path, NULL); result = system(cmd); g_free(cmd); if(result != 0) { g_error("Error linking to an existing Erlang installation\n"); } else { setup_binaries(opt_id); } }
gboolean stream_write(gpointer user_data){ NPStream stream; uint16_t stype; url_data *data = user_data; if(!g_hash_table_contains(g_FRManager.hash_table, (gpointer)data->instance)) goto done; memset(&stream, 0,sizeof(stream)); stream.end = 0; stream.url = data->url; stream.notifyData = data->notifyData; My_NPP_NewStream(data->instance, "application/x-shockwave-flash", &stream, 0, &stype); if(data->data->offset) if(data->httpType == CURL_HTTP_POST){ int len = data->data->offset; char *tmp = data->data->buf; if(!strncmp(tmp, "HTTP/1.1", 8) && (tmp = strstr(tmp, "\r\n\r\n"))){ tmp += 4; len -= tmp - data->data->buf; } //printf("%d ++ %s", data->data->offset - (tmp - data->data->buf), tmp); if(!tmp) tmp = data->data->buf; //printf("post: %d+++%s\n", len, data->data->buf); npstream_write(data->instance, &stream, tmp, len); }else{ npstream_write(data->instance, &stream, data->data->buf, data->data->offset); } My_NPP_URLNotify(data->instance, data->url, data->npcode, data->notifyData); My_NPP_DestroyStream(data->instance, &stream, data->npcode);//TODO done: free(data->url); if(data->data->buf) free(data->data->buf); free(data->data); if(data->postData) free(data->postData); free(data); return FALSE; }
static gboolean rumble_callback_set_rumble_state (guint port, RetroRumbleEffect effect, guint16 strength) { RetroCore *self; RetroController *controller; self = retro_core_get_cb_data (); g_return_val_if_fail (RETRO_IS_CORE (self), FALSE); if (!g_hash_table_contains (self->controllers, &port)) return FALSE; controller = g_hash_table_lookup (self->controllers, &port); if (controller == NULL) return FALSE; return retro_controller_set_rumble_state (controller, effect, strength); }
static void kms_recorder_endpoint_add_appsink (KmsRecorderEndpoint * self, KmsElementPadType type, const gchar * description, const gchar * name, gboolean requested) { KmsSinkPadData *data; GstElement *appsink; GstPad *sinkpad; if (g_hash_table_contains (self->priv->sink_pad_data, name)) { GST_WARNING_OBJECT (self, "Sink %s already added", name); return; } if (type != KMS_ELEMENT_PAD_TYPE_AUDIO && type != KMS_ELEMENT_PAD_TYPE_VIDEO) { GST_WARNING_OBJECT (self, "Unsupported pad type %u", type); return; } appsink = gst_element_factory_make ("appsink", NULL); g_object_set (appsink, "emit-signals", FALSE, "async", FALSE, "sync", FALSE, "qos", FALSE, NULL); gst_bin_add (GST_BIN (self), appsink); sinkpad = gst_element_get_static_pad (appsink, "sink"); gst_element_sync_state_with_parent (appsink); data = sink_pad_data_new (type, description, name, requested); data->sink_target = sinkpad; g_hash_table_insert (self->priv->sink_pad_data, g_strdup (name), data); g_object_set_data_full (G_OBJECT (sinkpad), KMS_PAD_IDENTIFIER_KEY, g_strdup (name), g_free); g_object_unref (sinkpad); }
void moose_job_manager_wait_for_id(MooseJobManager *jm, int job_id) { if(jm == NULL || job_id < 0) { /* Well, this is just down right invalid. */ return; } MooseJobManagerPrivate *priv = jm->priv; if(job_id > priv->last_send_job) { /* Was not sended yet, also no need to wait */ return; } gboolean has_key = FALSE; /* Lookup if the results hash table already has this key */ g_mutex_lock(&priv->hash_table_mutex); { has_key = g_hash_table_contains(priv->results, GINT_TO_POINTER(job_id)); } g_mutex_unlock(&priv->hash_table_mutex); if(has_key == TRUE) { /* Result was already computed */ return; } /* Otherwise wait till we get notified upon execution */ g_mutex_lock(&priv->finish_mutex); { for(;;) { if(priv->last_finished_job == job_id) { break; } else { g_cond_wait(&priv->finish_cond, &priv->finish_mutex); } } } g_mutex_unlock(&priv->finish_mutex); }
void setup_binaries(gchar* otpid) { GHashTable* erlangs = get_erlangs(); gboolean has_erlang = g_hash_table_contains(erlangs, otpid); gchar* path0 = (gchar*)g_hash_table_lookup(erlangs, otpid); // path0 is freed when the hashtable is freed gchar* path = strdup(path0); g_hash_table_destroy(erlangs); if(!has_erlang) { g_error("%s doesn't appear to be linked. Did something go wrong with the build?\n", otpid); } gchar* genbins = g_strconcat("cd ", path, " && for i in `find -L . -perm -111 -type f | grep -v \"\\.so\" | grep -v \"\\.o\" | grep -v \"lib/erlang/bin\" | grep -v Install`; do `ln -s -f $i $(basename $i)` ; done", NULL); g_debug("%s\n", genbins); if(!opt_dryrun) { int result = system(genbins); if(result != 0) { g_error("Error while generating symlinks using the following command: %s", genbins); } } else { printf("%s", genbins); } g_free(genbins); g_free(path); }
void dounlink() { if(!opt_id) { g_error("Please specify --id when unlinking\n"); } GHashTable* erlangs = get_erlangs(); gboolean result = g_hash_table_contains(erlangs, opt_id); g_hash_table_destroy(erlangs); if(!result) { g_error("Can't remove %s, it doesn't exist\n", opt_id); } gchar* output_root = get_config_subdir_file_name("otps", opt_id); gchar* output_path = g_strconcat(output_root, "/dist", NULL); if(!g_file_test(output_path, G_FILE_TEST_IS_SYMLINK)) { g_error("%s isn't a linked version of Erlang\n", opt_id); } gchar* cmd = g_strconcat("rm ", output_path, " && rm -rf ", output_root, NULL); g_debug("%s\n", cmd); rm_config_kv("Erlangs", opt_id); result = system(cmd); if(result != 0) { g_error("Error unlinking an existing Erlang installation\n"); } }
static void add_layout_to_table (GHashTable *table, const gchar *key, Layout *layout) { GHashTable *set; if (!layout->xkb_name) return; set = g_hash_table_lookup (table, key); if (!set) { set = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_replace (table, g_strdup (key), set); } else { if (g_hash_table_contains (set, layout->xkb_name)) return; } g_hash_table_replace (set, layout->xkb_name, layout); }
static void _otr_smp_secret(const char * const recipient, const char *secret) { ConnContext *context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; } if (context->msgstate != OTRL_MSGSTATE_ENCRYPTED) { return; } // if recipient initiated SMP, send response, else initialise if (g_hash_table_contains(smp_initiators, recipient)) { otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); ui_otr_authenticating(recipient); g_hash_table_remove(smp_initiators, context->username); } else { otrl_message_initiate_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); ui_otr_authetication_waiting(recipient); } }
static void daemon_maybe_add_extension_interface (GHashTable *ifaces, GDBusInterfaceInfo *iface) { gint i; /* We visit the XDG data dirs in precedence order, so if we * already have this one, we should not add it again. */ if (g_hash_table_contains (ifaces, iface->name)) return; /* Only accept interfaces with only properties */ if ((iface->methods && iface->methods[0]) || (iface->signals && iface->signals[0])) return; /* Add it only if we can find the annotation */ for (i = 0; iface->annotations && iface->annotations[i]; i++) { if (g_str_equal (iface->annotations[i]->key, "org.freedesktop.Accounts.VendorExtension")) { g_hash_table_insert (ifaces, g_strdup (iface->name), g_dbus_interface_info_ref (iface)); return; } } }
// write an ERLN8_CONFIG_FILE file into the cwd // won't override an existing file // unless the user specifies --force void init_here(gchar* erlang) { GHashTable* erlangs = get_erlangs(); gboolean has_erlang = g_hash_table_contains(erlangs, erlang); g_hash_table_destroy(erlangs); if(!has_erlang) { g_error("%s is not a configured version of Erlang\n", erlang); } GKeyFile* kf = g_key_file_new(); g_key_file_set_string(kf, "Config", "Erlang", erlang); GError* error = NULL; gchar* d = g_key_file_to_data (kf, NULL, &error); gchar* fn = "./" ERLN8_CONFIG_FILE; gboolean result = FALSE; if(!opt_force) { result = g_file_test(fn, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR); } if(result) { g_error("Config already exists in this directory. Override with --force.\n"); } else { GError* error2 = NULL; if(!g_file_set_contents(fn, d, -1, &error2)) { if (error2 != NULL) { g_error("Unable to write file %s: %s\n", fn, error2->message); } else { g_error("Unable to write file %s\n", fn); } } else { fprintf(stderr, "%sSaved " ERLN8_CONFIG_FILE " to %s%s\n", green(), fn, color_reset()); } } g_key_file_free(kf); }
void resolve_callback( AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, const char *domain, const char *host_name, const AvahiAddress *address, uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, AVAHI_GCC_UNUSED void* userdata) { assert(r); /* Called whenever a service has been resolved successfully or timed out */ switch (event) { case AVAHI_RESOLVER_FAILURE: l_debug("(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r)))); break; case AVAHI_RESOLVER_FOUND: { char a[AVAHI_ADDRESS_STR_MAX]; avahi_address_snprint(a, sizeof(a), address); char *value; char *type = NULL; size_t *size=NULL; AvahiStringList *type_txt = avahi_string_list_find(txt,"type"); if (type_txt != NULL){ avahi_string_list_get_pair(type_txt,&type, &value, size); l_debug("Type = %s",value); if ((g_strcmp0(value,"miniview") == 0) || (g_strcmp0(value,"android") == 0)) { char *data="data"; char *extra_data; size_t *size2=NULL; AvahiStringList *data_txt = avahi_string_list_find(txt,"data"); if (data_txt != NULL) { avahi_string_list_get_pair(data_txt,&data, &extra_data, size2); gchar *myhost = g_strdup_printf("%s:%u",hostname,server_port); if (g_strcmp0(extra_data, myhost)==0) { gchar *host = g_strdup_printf("%s:%u",a, port); l_debug("Found miniview on %s", host); if (!g_hash_table_contains(miniviews,host)) { g_hash_table_insert(miniviews, g_strdup(name), host); } } avahi_free(data); avahi_free(extra_data); g_free(myhost); } } avahi_free(value); avahi_free(type); } } } avahi_service_resolver_free(r); }