Example #1
0
/**
 * Checks if the supplied path is a known directory.
 *
 * The path argument is fully qualified, so it should start with a '/'.
 *
 * Returns 1 if the path is a directory, or 0 if not.
 */
static int isDirectory(const char *path)
{
  if ((path == NULL) || (path[0] != '/'))
  {
    return 0;
  }
  // Eliminate the starting '/'
  path++;

  // Checking for the '/' directory
  if (path[0] == '\0')
  {
    return 1;
  }
  // Need to check if it's a known directory
  if (g_slist_find_custom(dir_list, path, (GCompareFunc) strcmp) != NULL)
  {
    return 1;
  }

  return 0;
}
Example #2
0
libspectrum_error
libspectrum_rzx_rollback_to( libspectrum_rzx *rzx, libspectrum_snap **snap,
			     size_t which )
{
  GSList *previous = NULL, *list;
  rzx_block_t *block;
  size_t i;

  /* Find the nth snapshot block in the file */
  for( i = 0, list = rzx->blocks; i <= which; i++, list = list->next ) {
    list =
      g_slist_find_custom( list,
			   GINT_TO_POINTER( LIBSPECTRUM_RZX_SNAPSHOT_BLOCK ),
			   find_block );
    if( !list ) {
      libspectrum_print_error( LIBSPECTRUM_ERROR_CORRUPT,
			       "snapshot block %lu not found in recording",
			       (unsigned long)which );
      return LIBSPECTRUM_ERROR_CORRUPT;
    }

    previous = list;
  }

  if( rzx->current_input ) {
    libspectrum_error error;
    error = libspectrum_rzx_stop_input( rzx ); if( error ) return error;
  }

  /* Delete all blocks after the snapshot */
  g_slist_foreach( previous->next, block_free_wrapper, NULL );
  previous->next = NULL;

  block = previous->data;
  *snap = block->types.snap.snap;

  return LIBSPECTRUM_ERROR_NONE;
}
Example #3
0
GSList*
mono_w32process_get_modules (pid_t pid)
{
	GSList *ret = NULL;
	MonoW32ProcessModule *mod;
	GPtrArray *dlarray = g_ptr_array_new();
	gint i;

	if (dl_iterate_phdr (mono_w32process_get_modules_callback, dlarray) < 0)
		return NULL;

	for (i = 0; i < dlarray->len; i++) {
		struct dl_phdr_info *info = g_ptr_array_index (dlarray, i);

		mod = g_new0 (MonoW32ProcessModule, 1);
		mod->address_start = (gpointer)(info->dlpi_addr + info->dlpi_phdr[0].p_vaddr);
		mod->address_end = (gpointer)(info->dlpi_addr + info->dlpi_phdr[info->dlpi_phnum - 1].p_vaddr);
		mod->perms = g_strdup ("r--p");
		mod->address_offset = 0;
		mod->inode = i;
		mod->filename = g_strdup (info->dlpi_name);

		mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER_PROCESS, "%s: inode=%d, filename=%s, address_start=%p, address_end=%p",
			__func__, mod->inode, mod->filename, mod->address_start, mod->address_end);

		g_free (info);

		if (g_slist_find_custom (ret, mod, mono_w32process_module_equals) == NULL) {
			ret = g_slist_prepend (ret, mod);
		} else {
			mono_w32process_module_free (mod);
		}
	}

	g_ptr_array_free (dlarray, TRUE);

	return g_slist_reverse (ret);
}
Example #4
0
static int gap_driver_accept(struct btd_service *service)
{
	struct btd_device *device = btd_service_get_device(service);
	struct gatt_db *db = btd_device_get_gatt_db(device);
	struct bt_gatt_client *client = btd_device_get_gatt_client(device);
	struct gas *gas;
	GSList *l;
	char addr[18];
	bt_uuid_t gap_uuid;

	ba2str(device_get_address(device), addr);
	DBG("GAP profile accept (%s)", addr);

	l = g_slist_find_custom(devices, device, cmp_device);
	if (!l) {
		error("GAP service not handled by profile");
		return -1;
	}

	gas = l->data;

	/* Clean-up any old client/db and acquire the new ones */
	gas->attr = NULL;
	gatt_db_unregister(gas->db, gas->db_id);
	gatt_db_unref(gas->db);
	bt_gatt_client_unref(gas->client);

	gas->db = gatt_db_ref(db);
	gas->client = bt_gatt_client_ref(client);
	gas->db_id = gatt_db_register(db, service_added, service_removed, gas,
									NULL);

	/* Handle the GAP services */
	bt_uuid16_create(&gap_uuid, GAP_UUID16);
	gatt_db_foreach_service(db, &gap_uuid, foreach_gap_service, gas);

	return 0;
}
Example #5
0
/**
 * hildon_program_add_window:
 * @self: The @HildonProgram to which the window should be registered
 * @window: A @HildonWindow to be added
 *
 * Registers a @HildonWindow as belonging to a given @HildonProgram. This
 * allows to apply program-wide settings as all the registered windows,
 * such as hildon_program_set_common_menu() and
 * hildon_pogram_set_common_toolbar()
 **/
void
hildon_program_add_window                       (HildonProgram *self, 
                                                 HildonWindow *window)
{
    HildonProgramPrivate *priv;
    
    g_return_if_fail (HILDON_IS_PROGRAM (self));
    
    priv = HILDON_PROGRAM_GET_PRIVATE (self);
    g_assert (priv);

    if (g_slist_find_custom (priv->windows, window,
           hildon_program_window_list_compare) )
    {
        /* We already have that window */
        return;
    }

    if (!priv->window_count)
    {
        hildon_program_update_top_most (self);
        
        /* Now that we have a window we should start keeping track of
         * the root window */
        gdk_window_set_events (gdk_get_default_root_window (),
                gdk_window_get_events (gdk_get_default_root_window ()) | GDK_PROPERTY_CHANGE_MASK);

        gdk_window_add_filter (gdk_get_default_root_window (),
                hildon_program_root_window_event_filter, self );
    }
    
    hildon_window_set_can_hibernate_property (window, &priv->killable);

    hildon_window_set_program (window, G_OBJECT (self));

    priv->windows = g_slist_append (priv->windows, window);
    priv->window_count ++;
}
Example #6
0
/* This takes ownership of the socket.
 * It creates and attaches a source to the component’s context. */
void
component_attach_socket (Component *component, NiceSocket *nicesock)
{
  GSList *l;
  SocketSource *socket_source;

  g_assert (component != NULL);
  g_assert (nicesock != NULL);

  g_assert (component->ctx != NULL);

  if (nicesock->fileno == NULL)
    return;

  /* Find an existing SocketSource in the component which contains @socket, or
   * create a new one.
   *
   * Whenever a source is added or remove to socket_sources, socket_sources_age
   * must be incremented.
   */
  l = g_slist_find_custom (component->socket_sources, nicesock,
          _find_socket_source);
  if (l != NULL) {
    socket_source = l->data;
  } else {
    socket_source = g_slice_new0 (SocketSource);
    socket_source->socket = nicesock;
    socket_source->component = component;
    component->socket_sources =
        g_slist_prepend (component->socket_sources, socket_source);
    component->socket_sources_age++;
  }

  /* Create and attach a source */
  nice_debug ("Component %p (agent %p): Attach source (stream %u).",
      component, component->agent, component->stream->id);
  socket_source_attach (socket_source, component->ctx);
}
static GSList *
panel_applets_manager_get_applets_dirs (void)
{
    const gchar *dir = NULL;
    gchar      **paths;
    guint        i;
    GSList      *retval = NULL;

    dir = g_getenv ("CONSORT_PANEL_APPLETS_DIR");
    if (!dir || g_strcmp0 (dir, "") == 0) {
        return g_slist_prepend (NULL, g_strdup (PANEL_APPLETS_DIR));
    }

    paths = g_strsplit (dir, ":", 0);
    for (i = 0; paths[i]; i++) {
        if (g_slist_find_custom (retval, paths[i], (GCompareFunc) g_strcmp0))
            continue;
        retval = g_slist_prepend (retval, g_strdup (paths[i]));
    }
    g_strfreev (paths);

    return g_slist_reverse (retval);
}
static PyObject *PyScript_signal_unregister(PyScript *self, PyObject *args, PyObject *kwds)
{
    static char *kwlist[] = {"signal", NULL};
    char *signal = "";
    GSList *search;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, 
           &signal))
        return NULL;

    search = g_slist_find_custom(self->registered_signals, signal, (GCompareFunc)strcmp);
    if (!search)
        return PyErr_Format(PyExc_KeyError, "script has not registered that signal");
   
    g_free(search->data);
    self->registered_signals = g_slist_delete_link(self->registered_signals, search);
   
    if (!pysignals_unregister(signal))
        return PyErr_Format(PyExc_SystemError, 
                "script registered signal, but signal does not exist");
    
    Py_RETURN_NONE;
}
Example #9
0
/* Return non-zero and set *value if key is in hash table.
   On zero return, *value is undefined.
 */
int hash_find(guint32 key, guint32 *value)
{
        guint16 hash_index;
        HashBucket this_bucket;
        GSList *list_item;
        HashEntry *entry;

        g_assert(value);
        hash_index = key & 0xffff;
        this_bucket = hash_table[hash_index];
        if(!this_bucket) return 0;
        
        list_item = g_slist_find_custom(this_bucket,
                                        GINT_TO_POINTER((guint32)hash_index),
                                        hash_find_comparator);
        if(list_item) {
                entry = list_item->data;
                g_assert(entry);
                *value = entry->value;
                return 1;
        }
        return 0;
}
Example #10
0
/* This makes sure that only all the buddies are in the permit list. */
static void
add_buddies_in_permit(PurpleAccount *account, gboolean local)
{
	GSList *list;

	/* Remove anyone in the permit list who is not in the buddylist */
	for (list = account->permit; list != NULL; ) {
		char *person = list->data;
		list = list->next;
		if (!purple_find_buddy(account, person))
			purple_privacy_permit_remove(account, person, local);
	}

	/* Now make sure everyone in the buddylist is in the permit list */
	list = purple_find_buddies(account, NULL);
	while (list != NULL)
	{
		PurpleBuddy *buddy = list->data;
		if (!g_slist_find_custom(account->permit, buddy->name, (GCompareFunc)g_utf8_collate))
			purple_privacy_permit_add(account, buddy->name, local);
		list = g_slist_delete_link(list, list);
	}
}
Example #11
0
File: gobex.c Project: Fiend90/obex
static void handle_request(GObex *obex, GObexPacket *req)
{
	GSList *match;
	int op;

	op = parse_request(obex, req);
	if (op < 0)
		goto fail;

	match = g_slist_find_custom(obex->req_handlers, GUINT_TO_POINTER(op),
							req_handler_cmpop);
	if (match) {
		struct req_handler *handler = match->data;
		handler->func(obex, req, handler->user_data);
		return;
	}

	op = -G_OBEX_RSP_NOT_IMPLEMENTED;

fail:
	g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", g_obex_strerror(-op));
	g_obex_send_rsp(obex, -op, NULL, G_OBEX_HDR_INVALID);
}
Example #12
0
File: mime.c Project: ib/xarchiver
GdkPixbuf *xa_get_pixbuf_icon_from_cache(gchar *filename,gint size)
{
	pixbuf_cache *tie = NULL;
	const gchar *icon_name;
	GSList *found = NULL;
	GdkPixbuf *pixbuf = NULL;

	if (strcmp(filename,"folder") == 0)
		icon_name = filename;
	else if (strcmp(filename,"lock") == 0)
		icon_name = "dialog-password";
	else
		icon_name = xa_get_stock_mime_icon(filename);

	tie = g_new0(pixbuf_cache,1);
	if (tie)
	{
		tie->icon_name = g_strdup(icon_name);
		found = g_slist_find_custom(icon_cache,tie,(GCompareFunc)xa_icon_name_compare_func);
		if (found)
		{
			g_free (tie->icon_name);
			g_free (tie);
			return ((pixbuf_cache *)found->data)->pixbuf;
		}
		else
		{
			pixbuf = gtk_icon_theme_load_icon(icon_theme, icon_name, size, (GtkIconLookupFlags) 0, NULL);
			if (pixbuf)
			{
				tie->pixbuf = pixbuf;
				icon_cache = g_slist_prepend(icon_cache,tie);
			}
		}
	}
	return pixbuf;
}
Example #13
0
/**
 * return the number of the sub-budget wich has the name in param
 * create it if necessary
 *
 * \param budget_number the number of the budget
 * \param name the name of the sub-budget
 * \param create TRUE if we want to create it if it doen't exist
 *
 * \return the number of the sub-budget or FALSE if problem
 * */
gint gsb_data_budget_get_sub_budget_number_by_name ( gint budget_number,
                        const gchar *name,
                        gboolean create )
{
    GSList *list_tmp;
    struct_budget *budget;
    gint sub_budget_number = 0;

    if (!name || !strlen (name))
	return FALSE;

    budget = gsb_data_budget_get_structure ( budget_number );

    if (!budget)
	return FALSE;

    list_tmp = g_slist_find_custom ( budget -> sub_budget_list,
				     name,
				     (GCompareFunc) gsb_data_budget_get_pointer_from_sub_name_in_glist );

    if ( list_tmp )
    {
        struct_sub_budget *sub_budget;

        sub_budget = list_tmp -> data;
        sub_budget_number = sub_budget -> sub_budget_number;
    }
    else
    {
        if ( create )
        {
            sub_budget_number = gsb_data_budget_new_sub_budget ( budget_number, name );
            gsb_budget_update_combofix ( FALSE );
        }
    }
    return sub_budget_number;
}
static void
check_color_schemes_enabled (GtkSettings *settings,
                             AppearanceData *data)
{
  gchar *theme = NULL;
  gchar *filename;
  GSList *symbolic_colors = NULL;
  gboolean enable_colors = FALSE;
  gint i;

  g_object_get (settings, "gtk-theme-name", &theme, NULL);
  filename = gtkrc_find_named (theme);
  g_free (theme);

  gtkrc_get_details (filename, NULL, &symbolic_colors);
  g_free (filename);

  for (i = 0; i < NUM_SYMBOLIC_COLORS; ++i) {
    gboolean found;

    found = (g_slist_find_custom (symbolic_colors, symbolic_names[i], (GCompareFunc) strcmp) != NULL);
    gtk_widget_set_sensitive (appearance_capplet_get_widget (data, symbolic_names[i]), found);

    enable_colors |= found;
  }

  g_slist_foreach (symbolic_colors, (GFunc) g_free, NULL);
  g_slist_free (symbolic_colors);

  gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "color_scheme_table"), enable_colors);
  gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "color_scheme_defaults_button"), enable_colors);

  if (enable_colors)
    gtk_widget_hide (appearance_capplet_get_widget (data, "color_scheme_message_hbox"));
  else
    gtk_widget_show (appearance_capplet_get_widget (data, "color_scheme_message_hbox"));
}
Example #15
0
static int headset_probe(struct btd_device *device, GSList *uuids)
{
	struct btd_adapter *adapter = device_get_adapter(device);
	const gchar *path = device_get_path(device);
	const sdp_record_t *record;
	sdp_list_t *protos;
	int ch;
	bdaddr_t src, dst;

	DBG("path %s", path);

	if (!g_slist_find_custom(uuids, HSP_HS_UUID,
					(GCompareFunc) strcasecmp))
		return -EINVAL;

	record = btd_device_get_record(device, uuids->data);

	if (!record || sdp_get_access_protos(record, &protos) < 0) {
		error("Invalid record");
		return -EINVAL;
	}

	ch = sdp_get_proto_port(protos, RFCOMM_UUID);
	sdp_list_foreach(protos, (sdp_list_func_t) sdp_list_free, NULL);
	sdp_list_free(protos, NULL);

	if (ch <= 0) {
		error("Invalid RFCOMM channel");
		return -EINVAL;
	}

	adapter_get_address(adapter, &src);
	device_get_address(device, &dst);

	return fake_input_register(connection, device, path, &src, &dst,
				HSP_HS_UUID, ch);
}
Example #16
0
/** Remove a file */
static int fuse_unlink(const char *path)
{
#ifndef HIDE_COMPLETED
  tolog(path);
  tolog(" - unlink\n");
#endif

  path++;
  GSList *item = g_slist_find_custom(link_list, path, (GCompareFunc) linkpathcmp);

  if (item == NULL)
  {
    return -ENOENT;
  }

  struct link_pair *l = (struct link_pair *) item->data;

  g_free(l->path);
  g_free(l->dest);
  g_free(item->data);
  link_list = g_slist_delete_link(link_list, item);

  return 0;;
}
Example #17
0
static uint8_t link_loss_alert_lvl_read(struct attribute *a, gpointer user_data,
					struct btd_device *device)
{
	struct link_loss_adapter *adapter = user_data;
	struct connected_device *condev;
	GSList *l = NULL;
	uint8_t alert_level = NO_ALERT;

	if (device)
		l = g_slist_find_custom(adapter->connected_devices, device,
					lldevice_cmp);
	if (l) {
		condev = l->data;
		alert_level = condev->alert_level;
	}

	DBG("return alert level %d for dev %p", alert_level, device);

	/* update the alert level according to the requesting device */
	attrib_db_update(adapter->adapter, a->handle, NULL, &alert_level,
			 sizeof(alert_level), NULL);

	return 0;
}
Example #18
0
static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
{
	struct a2dp_device *dev;
	bdaddr_t dst;
	char address[18];
	GError *gerr = NULL;
	GSList *l;

	if (err) {
		error("%s", err->message);
		return;
	}

	bt_io_get(chan, &gerr,
			BT_IO_OPT_DEST_BDADDR, &dst,
			BT_IO_OPT_INVALID);
	if (gerr) {
		error("%s", gerr->message);
		g_error_free(gerr);
		g_io_channel_shutdown(chan, TRUE, NULL);
		return;
	}

	ba2str(&dst, address);
	DBG("Incoming connection from %s", address);

	l = g_slist_find_custom(devices, &dst, device_cmp);
	if (l) {
		transport_connect_cb(chan, err, l->data);
		return;
	}

	dev = a2dp_device_new(&dst);
	bt_a2dp_notify_state(dev, HAL_A2DP_STATE_CONNECTING);
	signaling_connect_cb(chan, err, dev);
}
Example #19
0
static void bt_a2dp_connect(const void *buf, uint16_t len)
{
	const struct hal_cmd_a2dp_connect *cmd = buf;
	struct a2dp_device *dev;
	uint8_t status;
	char addr[18];
	bdaddr_t dst;
	GSList *l;

	DBG("");

	android2bdaddr(&cmd->bdaddr, &dst);

	l = g_slist_find_custom(devices, &dst, device_cmp);
	if (l) {
		status = HAL_STATUS_FAILED;
		goto failed;
	}

	dev = a2dp_device_new(&dst);
	if (!a2dp_device_connect(dev, signaling_connect_cb)) {
		a2dp_device_remove(dev);
		status = HAL_STATUS_FAILED;
		goto failed;
	}

	ba2str(&dev->dst, addr);
	DBG("connecting to %s", addr);

	bt_a2dp_notify_state(dev, HAL_A2DP_STATE_CONNECTING);

	status = HAL_STATUS_SUCCESS;

failed:
	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_CONNECT, status);
}
Example #20
0
/**
 * nice_component_detach_socket:
 * @component: a #NiceComponent
 * @socket: the socket to detach the source for
 *
 * Detach the #GSource for the single specified @socket. It also closes it
 * and frees it!
 *
 * If the @socket doesn’t exist in this @component, do nothing.
 */
static void
nice_component_detach_socket (NiceComponent *component, NiceSocket *nicesock)
{
  GSList *l;
  SocketSource *socket_source;

  nice_debug ("Detach socket %p.", nicesock);

  /* Remove the socket from various lists. */
  for (l = component->incoming_checks; l != NULL;) {
    IncomingCheck *icheck = l->data;
    GSList *next = l->next;

    if (icheck->local_socket == nicesock) {
      component->incoming_checks =
          g_slist_delete_link (component->incoming_checks, l);
      incoming_check_free (icheck);
    }

    l = next;
  }

  /* Find the SocketSource for the socket. */
  l = g_slist_find_custom (component->socket_sources, nicesock,
          _find_socket_source);
  if (l == NULL)
    return;

  /* Detach the source. */
  socket_source = l->data;
  component->socket_sources = g_slist_delete_link (component->socket_sources, l);
  component->socket_sources_age++;

  socket_source_detach (socket_source);
  socket_source_free (socket_source);
}
Example #21
0
static uint8_t link_loss_alert_lvl_write(struct attribute *a,
		gpointer user_data, struct btd_device *device)
{
	uint8_t value;
	struct link_loss_adapter *adapter = user_data;
	GSList *l = NULL;
	struct connected_device *condev = NULL;

	if (device) {
		l = g_slist_find_custom(adapter->connected_devices, device,
					lldevice_cmp);
		if (l)
			condev = l->data;
	}

	if (a->len == 0) {
		DBG("Illegal alert level len");
		goto set_error;
	}

	value = a->data[0];
	if (value != NO_ALERT && value != MILD_ALERT && value != HIGH_ALERT) {
		DBG("Illegal alert value");
		goto set_error;
	}

	/* Register a disconnect cb if the alert level is non-zero */
	if (value != NO_ALERT && device && !condev) {
		condev = g_new0(struct connected_device, 1);
		condev->device = btd_device_ref(device);
		condev->adapter = adapter;
		condev->callback_id = btd_device_add_attio_callback(device,
					NULL, link_loss_disc_cb, condev);
		adapter->connected_devices = g_slist_append(
					adapter->connected_devices, condev);
	} else if (value == NO_ALERT && condev) {
static void
cache_by_id (ShellAppSystem *self, GSList *apps)
{
  GSList *iter;

  for (iter = apps; iter; iter = iter->next)
    {
      ShellAppInfo *info = iter->data;
      const char *id = shell_app_info_get_id (info);
      char *prefix = shell_app_info_get_prefix (info);

      shell_app_info_ref (info);
      /* the name is owned by the info itself */

      if (prefix
          && !g_slist_find_custom (self->priv->known_vendor_prefixes, prefix,
                                   (GCompareFunc)g_strcmp0))
        self->priv->known_vendor_prefixes = g_slist_append (self->priv->known_vendor_prefixes,
                                                            prefix);
      else
        g_free (prefix);
      g_hash_table_replace (self->priv->app_id_to_info, (char*)id, info);
    }
}
Example #23
0
static void
on_clicked_fold (RosterViewGtk* self,
		 GtkTreePath* path,
		 const gchar* name)
{
  gboolean row_expanded = TRUE;
  GSList* existing_group = NULL;

  row_expanded
    = gtk_tree_view_row_expanded (GTK_TREE_VIEW (self->priv->tree_view), path);

  existing_group = g_slist_find_custom (self->priv->folded_groups,
					name,
					(GCompareFunc) g_ascii_strcasecmp);
  if (!row_expanded) {

    if (existing_group == NULL) {
      self->priv->folded_groups = g_slist_append (self->priv->folded_groups,
						  g_strdup (name));
    }
  }
  else {

    if (existing_group != NULL) {

      self->priv->folded_groups
        = g_slist_remove_link (self->priv->folded_groups, existing_group);

      g_free ((gchar *) existing_group->data);
      g_slist_free_1 (existing_group);
    }
  }

  gm_conf_set_string_list (CONTACTS_KEY "roster_folded_groups",
			   self->priv->folded_groups);
}
static gboolean
update_ignore_paths (GSList **ignore_paths,
                     const gchar *mount_path,
                     gboolean ignore)
{
        GSList *found;
        gchar *path_to_remove;
        
        found = g_slist_find_custom (*ignore_paths, mount_path, (GCompareFunc) ignore_path_compare);
        
        if (ignore && (found == NULL)) {
                *ignore_paths = g_slist_prepend (*ignore_paths, g_strdup (mount_path));
                return TRUE;
        }
        
        if (!ignore && (found != NULL)) {
                path_to_remove = found->data;
                *ignore_paths = g_slist_remove (*ignore_paths, path_to_remove);
                g_free (path_to_remove);
                return TRUE;
        }
                
        return FALSE;
}
Example #25
0
void add_contact_with_three_groups_update_removing_two(void **state)
{
    roster_create();

    GSList *groups1 = NULL;
    groups1 = g_slist_append(groups1, strdup("friends"));
    groups1 = g_slist_append(groups1, strdup("work"));
    groups1 = g_slist_append(groups1, strdup("stuff"));
    roster_add("*****@*****.**", NULL, groups1, NULL, FALSE);

    GSList *groups2 = NULL;
    groups2 = g_slist_append(groups2, strdup("stuff"));
    roster_update("*****@*****.**", NULL, groups2, NULL, FALSE);

    GSList *groups_res = roster_get_groups();
    assert_int_equal(g_slist_length(groups_res), 1);

    GSList *found = g_slist_find_custom(groups_res, "stuff", g_strcmp0);
    assert_true(found != NULL);
    assert_string_equal(found->data, "stuff");

    g_slist_free_full(groups_res, g_free);
    roster_destroy();
}
Example #26
0
File: pnat.c Project: 520lly/bluez
static void pnat_remove(struct btd_adapter *adapter)
{
	struct dun_server *server;
	GSList *match;
	bdaddr_t src;

	adapter_get_address(adapter, &src);

	match = g_slist_find_custom(servers, &src, server_cmp);
	if (match == NULL)
		return;

	server = match->data;

	servers = g_slist_delete_link(servers, match);

	disconnect(server);

	remove_record_from_server(server->record_handle);
	close(server->rfcomm_ctl);
	g_io_channel_shutdown(server->server, TRUE, NULL);
	g_io_channel_unref(server->server);
	g_free(server);
}
Example #27
0
/**
 * @name fab_route_get
 *
 * @brief Get a fabric route
 */
GSList *
fab_route_get(void *rt_service, int src_sw, int dst_sw,
              fab_route_t *froute)
{
    GSList *route = NULL;

    if (!fab_ctx->use_ecmp || !froute) {
        if (!(route = mul_route_get(rt_service, src_sw, dst_sw))) {
            return NULL;
        }
    } else {
        if (!(route = mul_route_get_mp(rt_service, src_sw, dst_sw,
                                       froute, fab_mp_select))) {
            return NULL;
        }
    }

    if (!g_slist_find_custom(route, froute, (GCompareFunc)fab_route_elem_valid)) {
        mul_destroy_route(route);
        return NULL;
    }
    
    return route;
}
Example #28
0
void heartrate_device_unregister(struct btd_device *device)
{
	struct btd_adapter *adapter;
	struct heartrate_adapter *hradapter;
	struct heartrate *hr;
	GSList *l;

	adapter = device_get_adapter(device);

	hradapter = find_heartrate_adapter(adapter);
	if (hradapter == NULL)
		return;

	l = g_slist_find_custom(hradapter->devices, device, cmp_device);
	if (l == NULL)
		return;

	hr = l->data;

	hradapter->devices = g_slist_remove(hradapter->devices, hr);

	g_dbus_unregister_interface(btd_get_dbus_connection(),
				device_get_path(device), HEART_RATE_INTERFACE);
}
Example #29
0
static inline void
tree_selection_collect_data_record(GtkTreeModel *model, GtkTreeIter *iter,
		collect_data_struct_t *cdata, gboolean unselect)
{
	gpointer data;

	g_assert(NULL != cdata);
	g_assert(NULL != iter);

	data = cdata->gdf(model, iter);

	if (unselect) {
		cdata->to_unselect = g_slist_prepend(cdata->to_unselect,
								w_tree_iter_copy(iter));
	}

	if (NULL != cdata->cfn &&
		NULL != g_slist_find_custom(cdata->results, data, cdata->cfn)) {
		if (GUI_PROPERTY(gui_debug) >= 3)
			g_warning("%s has duplicate data: %p", cdata->name, data);
		return;
	}
	cdata->results = g_slist_prepend(cdata->results, data);
}
Example #30
0
static gnc_commodity *
xaccTransFindCommonCurrency (Transaction *trans, QofBook *book)
{
    gnc_commodity *com_scratch;
    GList *node = NULL;
    GSList *comlist = NULL, *found = NULL;

    if (!trans) return NULL;

    if (trans->splits == NULL) return NULL;

    g_return_val_if_fail (book, NULL);

    /* Find the most commonly used currency among the splits.  If a given split
       is in a non-currency commodity, then look for an ancestor account in a
       currency, but prefer currencies used directly in splits.  Ignore trading
       account splits in this whole process, they don't add any value to this algorithm. */
    for (node = trans->splits; node; node = node->next)
    {
        Split *s = node->data;
        unsigned int curr_weight;

        if (s == NULL || s->acc == NULL) continue;
        if (xaccAccountGetType(s->acc) == ACCT_TYPE_TRADING) continue;
        com_scratch = xaccAccountGetCommodity(s->acc);
        if (com_scratch && gnc_commodity_is_currency(com_scratch))
        {
            curr_weight = 3;
        }
        else
        {
            com_scratch = gnc_account_get_currency_or_parent(s->acc);
            if (com_scratch == NULL) continue;
            curr_weight = 1;
        }
        if ( comlist )
        {
            found = g_slist_find_custom(comlist, com_scratch, commodity_equal);
        }
        if (comlist == NULL || found == NULL)
        {
            CommodityCount *count = g_slice_new0(CommodityCount);
            count->commodity = com_scratch;
            count->count = curr_weight;
            comlist = g_slist_append(comlist, count);
        }
        else
        {
            CommodityCount *count = (CommodityCount*)(found->data);
            count->count += curr_weight;
        }
    }
    found = g_slist_sort( comlist, commodity_compare);

    if ( found && found->data && (((CommodityCount*)(found->data))->commodity != NULL))
    {
        return ((CommodityCount*)(found->data))->commodity;
    }
    /* We didn't find a currency in the current account structure, so try
     * an old one. */
    return xaccTransFindOldCommonCurrency( trans, book );
}