Example #1
0
/** initialize the basic android values
 */
void android_init_values(void)
{
  const char *text;

  text = get_android_manufacturer();
  if(text)
  {
	write_to_file("/sys/class/android_usb/android0/iManufacturer", text);
	g_free((char *)text);
  }
  text = get_android_vendor_id();
  if(text)
  {
	write_to_file("/sys/class/android_usb/android0/idVendor", text);
	g_free((char *)text);
  }
  text = get_android_product();
  if(text)
  {
	write_to_file("/sys/class/android_usb/android0/iProduct", text);
	g_free((char *)text);
  }
  text = get_android_product_id();
  if(text)
  {
	write_to_file("/sys/class/android_usb/android0/idProduct", text);
	g_free((char *)text);
  }
  text = read_mac();
  if(text)
  {
	write_to_file("/sys/class/android_usb/f_rndis/ethaddr", text);
	g_free((char *)text);
  }
}
Example #2
0
/*
 * Remove an anchor from the table in the viewport. Notice that "name"
 * is freed here.
 */
void p_Dw_gtk_viewport_remove_anchor (DwWidget *widget,
                                      gchar *name)
{
   GtkDwViewport *viewport;
   GtkDwViewportAnchor *anchor;
   gpointer tmp_anchor;
   gboolean exists;

   _MSG("removing anchor %p/'%s'\n", widget, name);

   g_return_if_fail (widget->viewport != NULL);
   viewport = GTK_DW_VIEWPORT (widget->viewport);

   exists =
      g_hash_table_lookup_extended (viewport->anchors_table, name, NULL,
                                    &tmp_anchor);
   g_return_if_fail(exists);

   anchor = tmp_anchor;
   g_return_if_fail(anchor->widget == widget);

   g_hash_table_remove (viewport->anchors_table, name);
   g_free (anchor->name);
   g_free (anchor);
}
static gchar*
get_state_set (AtspiAccessible *accessible)
{
  AtspiStateSet *state_set = atspi_accessible_get_state_set (accessible);
  GArray *states = atspi_state_set_get_states (state_set);
  gchar *result = g_strdup_printf ("[");
  gchar *aux = NULL;
  gint i;
  AtspiStateType state;

  for (i = 0; i < states->len; i++) {
    state = g_array_index (states, gint, i);

    aux = result;
    if (i < states->len -1)
      result = g_strdup_printf ("%s%s,", aux, atspi_state_get_name(state));
    else
      result = g_strdup_printf ("%s%s", aux, atspi_state_get_name(state));
    g_free (aux);
  }

  aux = result;
  result = g_strconcat (aux, "]", NULL);
  g_free (aux);

  g_array_free (states, TRUE);
  g_object_unref (state_set);

  return result;
}
bool isThemeAvailable()
{
	const char* themeName = g_getenv("GTK_THEME");

	if (!themeName)
		return true;

	if (0 == strcasecmp(themeName, "Adwaita"))
		return true;

	// When GTK doesn't find a theme, it simply loads Adwaita.
	GtkCssProvider* selectedTheme = gtk_css_provider_get_named(themeName, NULL);
	GtkCssProvider* adwaitaTheme = gtk_css_provider_get_named("Adwaita", NULL);

	char* selectedThemeString = gtk_css_provider_to_string(selectedTheme);
	char* adwaitaThemeString = gtk_css_provider_to_string(adwaitaTheme);
	const bool isAdwaita =(0 == strcmp(selectedThemeString, adwaitaThemeString));
	g_free(selectedThemeString);
	g_free(adwaitaThemeString);

	if (isAdwaita)
	{
		printf("Error: Theme %s not found\n", themeName);
		return false;
	}

	return true;
}
Example #5
0
/**
 * category_find_preset:
 *
 * find a user language compatible file for category preset
 *
 * Return value: a pathname to the file or NULL
 *
 */
gchar *category_find_preset(gchar **lang)
{
gchar **langs;
gchar *filename;
gboolean exists;
guint i;

	DB( g_print("** category_find_preset **\n") );

	langs = (gchar **)g_get_language_names ();

	DB( g_print(" -> %d languages detected\n", g_strv_length(langs)) );

	for(i=0;i<g_strv_length(langs);i++)
	{
		DB( g_print(" -> %d '%s'\n", i, langs[i]) );
		filename = g_strdup_printf("hb-categories-%s.csv", langs[i]);
		gchar *pathfilename = g_build_filename(homebank_app_get_datas_dir(), filename, NULL);
		exists = g_file_test(pathfilename, G_FILE_TEST_EXISTS);
		DB( g_print(" -> '%s' exists=%d\n", pathfilename, exists) );
		if(exists)
		{
			g_free(filename);
			*lang = langs[i];
			return pathfilename;
		}
		g_free(filename);
		g_free(pathfilename);
	}

	DB( g_print("return NULL\n") );

	*lang = NULL;
	return NULL;
}
Example #6
0
void
cfg_free(GlobalConfig *self)
{
  g_assert(self->persist == NULL);
  if (self->state)
    persist_state_free(self->state);

  g_free(self->file_template_name);
  g_free(self->proto_template_name);  
  log_template_unref(self->file_template);
  log_template_unref(self->proto_template);
  log_template_options_destroy(&self->template_options);
  host_resolve_options_destroy(&self->host_resolve_options);

  if (self->bad_hostname_compiled)
    regfree(&self->bad_hostname);
  g_free(self->bad_hostname_re);
  dns_cache_options_destroy(&self->dns_cache_options);
  g_free(self->custom_domain);
  plugin_free_plugins(self);
  plugin_free_candidate_modules(self);
  cfg_tree_free_instance(&self->tree);
  g_hash_table_unref(self->module_config);
  g_free(self);
}
Example #7
0
void
qdisk_deinit(QDisk *self)
{
  if (self->filename)
    {
      g_free(self->filename);
      self->filename = NULL;
    }

  if (self->hdr)
    {
      if (self->options->read_only)
        g_free(self->hdr);
      else
        munmap((void *)self->hdr, sizeof(QDiskFileHeader));
      self->hdr = NULL;
    }

  if (self->fd != -1)
    {
      close(self->fd);
      self->fd = -1;
    }

  self->options = NULL;
}
Example #8
0
static void set_lxsession_theme (const char *theme)
{
	const char *session_name;
	char *user_config_file, *str;
	GKeyFile *kf;
	gsize len;

	// construct the file path
	session_name = g_getenv ("DESKTOP_SESSION");
	if (!session_name) session_name = DEFAULT_SES;
	user_config_file = g_build_filename (g_get_user_config_dir (), "lxsession/", session_name, "/desktop.conf", NULL);

	// read in data from file to a key file
	kf = g_key_file_new ();
	if (!g_key_file_load_from_file (kf, user_config_file, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL))
	{
		g_free (user_config_file);
		return;
	}

	// update changed values in the key file
	g_key_file_set_string (kf, "GTK", "sNet/ThemeName", theme);

	// write the modified key file out
	str = g_key_file_to_data (kf, &len, NULL);
	g_file_set_contents (user_config_file, str, len, NULL);

	g_free (user_config_file);
	g_free (str);
}
Example #9
0
static void
panel_addto_name_change (PanelAddtoDialog *dialog,
			 const char       *name)
{
	char *title;
	char *label;

	label = NULL;

	if (!PANEL_GLIB_STR_EMPTY (name))
		label = g_strdup_printf (_("Find an _item to add to \"%s\":"),
					 name);

	if (panel_toplevel_get_is_attached (dialog->panel_widget->toplevel)) {
		title = g_strdup_printf (_("Add to Drawer"));
		if (label == NULL)
			label = g_strdup (_("Find an _item to add to the drawer:"));
	} else {
		title = g_strdup_printf (_("Add to Panel"));
		if (label == NULL)
			label = g_strdup (_("Find an _item to add to the panel:"));
	}

	gtk_window_set_title (GTK_WINDOW (dialog->addto_dialog), title);
	g_free (title);

	gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->label), label);
	g_free (label);
}
Example #10
0
static void save_gtk3_settings (void)
{
	char *user_config_file, *cstr;
	char cmdbuf[256];

	// construct the file path
	user_config_file = g_build_filename (g_get_home_dir (), ".config/gtk-3.0/gtk.css", NULL);

	// convert colour to string and use sed to write
	cstr = gdk_color_to_string (&theme_colour);
	sprintf (cmdbuf, "sed -i s/'theme_selected_bg_color #......'/'theme_selected_bg_color #%c%c%c%c%c%c'/g %s",
		cstr[1], cstr[2], cstr[5], cstr[6], cstr[9], cstr[10], user_config_file);
	system (cmdbuf);

	cstr = gdk_color_to_string (&themetext_colour);
	sprintf (cmdbuf, "sed -i s/'theme_selected_fg_color #......'/'theme_selected_fg_color #%c%c%c%c%c%c'/g %s",
		cstr[1], cstr[2], cstr[5], cstr[6], cstr[9], cstr[10], user_config_file);
	system (cmdbuf);

	// write the current font to the file
	sprintf (cmdbuf, "sed -i s/'font:[^;]*'/'font:\t%s'/g %s", desktop_font, user_config_file);
	system (cmdbuf);

	g_free (cstr);
	g_free (user_config_file);
}
Example #11
0
static void save_lxsession_settings (void)
{
	const char *session_name;
	char *user_config_file, *str;
	char colbuf[128];
	GKeyFile *kf;
	gsize len;

	// construct the file path
	session_name = g_getenv ("DESKTOP_SESSION");
	if (!session_name) session_name = DEFAULT_SES;
	user_config_file = g_build_filename (g_get_user_config_dir (), "lxsession/", session_name, "/desktop.conf", NULL);

	// read in data from file to a key file
	kf = g_key_file_new ();
	if (!g_key_file_load_from_file (kf, user_config_file, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL))
	{
		g_free (user_config_file);
		return;
	}

	// update changed values in the key file
	sprintf (colbuf, "selected_bg_color:%s\nselected_fg_color:%s\nbar_bg_color:%s\nbar_fg_color:%s\n",
		gdk_color_to_string (&theme_colour), gdk_color_to_string (&themetext_colour),
		gdk_color_to_string (&bar_colour), gdk_color_to_string (&bartext_colour));
	g_key_file_set_string (kf, "GTK", "sGtk/ColorScheme", colbuf);
	g_key_file_set_string (kf, "GTK", "sGtk/FontName", desktop_font);

	// write the modified key file out
	str = g_key_file_to_data (kf, &len, NULL);
	g_file_set_contents (user_config_file, str, len, NULL);

	g_free (user_config_file);
	g_free (str);
}
Example #12
0
/**
 * shell_app_system_lookup_wmclass:
 * @system: a #ShellAppSystem
 * @wmclass: A WM_CLASS value
 *
 * Find a valid application corresponding to a WM_CLASS value.
 *
 * Returns: (transfer none): A #ShellApp for @wmclass
 */
ShellApp *
shell_app_system_lookup_wmclass (ShellAppSystem *system,
                                 const char     *wmclass)
{
  char *canonicalized;
  char *desktop_file;
  ShellApp *app;

  if (wmclass == NULL)
    return NULL;

  canonicalized = g_ascii_strdown (wmclass, -1);

  /* This handles "Fedora Eclipse", probably others.
   * Note g_strdelimit is modify-in-place. */
  g_strdelimit (canonicalized, " ", '-');

  desktop_file = g_strconcat (canonicalized, ".desktop", NULL);

  app = shell_app_system_lookup_heuristic_basename (system, desktop_file);

  g_free (canonicalized);
  g_free (desktop_file);

  return app;
}
Example #13
0
static void tethering_free(void *user_data)
{
	struct tethering_info *tethering = user_data;

	g_free(tethering->bridge);
	g_free(tethering);
}
static gboolean
append_tag_value_pair (CajaImagePropertiesPage *page,
                       ExifData *data,
                       ExifTag   tag,
                       char     *description)
{
    char *utf_attribute;
    char *utf_value;

    utf_attribute = exifdata_get_tag_name_utf8 (tag);
    utf_value = exifdata_get_tag_value_utf8 (data, tag);

    if ((utf_attribute == NULL) || (utf_value == NULL))
    {
        g_free (utf_attribute);
        g_free (utf_value);
        return FALSE;
    }

    append_label_take_str
    (page->details->vbox,
     g_strdup_printf ("<b>%s:</b> %s",
                      description ? description : utf_attribute,
                      utf_value));

    g_free (utf_attribute);
    g_free (utf_value);
    return TRUE;
}
Example #15
0
void error_set_win32(Error **errp, int win32_err, ErrorClass err_class,
                     const char *fmt, ...)
{
    Error *err;
    char *msg1;
    va_list ap;

    if (errp == NULL) {
        return;
    }
    assert(*errp == NULL);

    err = g_malloc0(sizeof(*err));

    va_start(ap, fmt);
    msg1 = g_strdup_vprintf(fmt, ap);
    if (win32_err != 0) {
        char *msg2 = g_win32_error_message(win32_err);
        err->msg = g_strdup_printf("%s: %s (error: %x)", msg1, msg2,
                                   (unsigned)win32_err);
        g_free(msg2);
        g_free(msg1);
    } else {
        err->msg = msg1;
    }
    va_end(ap);
    err->err_class = err_class;

    if (errp == &error_abort) {
        error_report("%s", error_get_pretty(err));
        abort();
    }

    *errp = err;
}
Example #16
0
static void
g_win32_directory_monitor_finalize (GObject *base)
{
  GWin32DirectoryMonitor *self;
  self = G_WIN32_DIRECTORY_MONITOR (base);

  if (self->priv->hDirectory == INVALID_HANDLE_VALUE)
    {
      /* If we don't have a directory handle we can free
       * self->priv->file_notify_buffer and self->priv here. The
       * callback won't be called obviously any more (and presumably
       * never has been called).
       */
      g_free (self->priv->file_notify_buffer);
      self->priv->file_notify_buffer = NULL;
      g_free (self->priv);
    }
  else
    {
      /* If we have a directory handle, the OVERLAPPED struct is
       * passed once more to the callback as a result of the
       * CloseHandle() done in the cancel method, so self->priv has to
       * be kept around. The GWin32DirectoryMonitor object is
       * disappearing, so can't leave a pointer to it in
       * self->priv->self.
       */
      self->priv->self = NULL;
    }

  if (G_OBJECT_CLASS (g_win32_directory_monitor_parent_class)->finalize)
    (*G_OBJECT_CLASS (g_win32_directory_monitor_parent_class)->finalize) (base);
}
Example #17
0
static void
wireless_dialog_prepare (GstConnectionDialog *dialog)
{
  gchar *essid, *key, *dev, *key_type;

  g_object_get (G_OBJECT (dialog->iface),
		"device", &dev,
		"essid", &essid,
		"key", &key,
		"key-type", &key_type,
		NULL);

  connection_combo_set_value (GTK_COMBO_BOX (dialog->key_type_combo), key_type);
  gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dialog->essid))), (essid) ? essid : "");
  gtk_entry_set_text (GTK_ENTRY (dialog->wep_key), (key) ? key : "");

#ifdef HAVE_LIBIW_H
  dialog->essid_list = gst_essid_list_new (dev);
  on_essid_list_changed (dialog->essid_list, dialog);
  g_signal_connect (G_OBJECT (dialog->essid_list), "changed",
		    G_CALLBACK (on_essid_list_changed), dialog);
#endif

  g_free (key_type);
  g_free (essid);
  g_free (key);
  g_free (dev);
}
Example #18
0
static void gtk_assert_dialog_copy_callback(GtkWidget*, GtkAssertDialog* dlg)
{
    char *msg, *backtrace;
    GtkClipboard *clipboard;
    GString *str;

    msg = gtk_assert_dialog_get_message (dlg);
    backtrace = gtk_assert_dialog_get_backtrace (dlg);

    /* combine both in a single string */
    str = g_string_new("");
    g_string_printf (str, "ASSERT INFO:\n%s\n\nBACKTRACE:\n%s\n\n", msg, backtrace);

    /* copy everything in default clipboard */
    clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
    gtk_clipboard_set_text (clipboard, str->str, str->len);

    /* copy everything in primary clipboard too */
    clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
    gtk_clipboard_set_text (clipboard, str->str, str->len);

    g_free (msg);
    g_free (backtrace);
    g_string_free (str, TRUE);
}
Example #19
0
void ZBarFilterImpl::busMessage (GstMessage *message)
{

  if (GST_MESSAGE_SRC (message) == GST_OBJECT (zbar) &&
      GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
    const GstStructure *st;
    guint64 ts;
    gchar *type, *symbol;

    st = gst_message_get_structure (message);

    if (g_strcmp0 (gst_structure_get_name (st), "barcode") != 0) {
      return;
    }

    if (!gst_structure_get (st, "timestamp", G_TYPE_UINT64, &ts,
                            "type", G_TYPE_STRING, &type, "symbol",
                            G_TYPE_STRING, &symbol, NULL) ) {
      return;
    }

    std::string symbolStr (symbol);
    std::string typeStr (type);

    g_free (type);
    g_free (symbol);

    barcodeDetected (ts, typeStr, symbolStr);
  }
}
Example #20
0
static void ppp_connect(const char *iface, const char *local, const char *peer,
                        const char *dns1, const char *dns2,
                        gpointer user_data)
{
    DBusConnection *conn = ofono_dbus_get_connection();
    struct dundee_device *device = user_data;
    const char *dns[3] = { dns1, dns2, 0 };

    DBG("%p", device);
    DBG("Network Device: %s\n", iface);
    DBG("IP Address: %s\n", local);
    DBG("Peer IP Address: %s\n", peer);
    DBG("Primary DNS Server: %s\n", dns1);
    DBG("Secondary DNS Server: %s\n", dns2);

    if (device->connect_timeout > 0) {
        g_source_remove(device->connect_timeout);
        device->connect_timeout = 0;
    }

    g_free(device->settings.interface);
    device->settings.interface = g_strdup(iface);
    if (device->settings.interface == NULL)
        goto err;

    g_free(device->settings.ip);
    device->settings.ip = g_strdup(local);
    if (device->settings.ip == NULL)
        goto err;

    g_strfreev(device->settings.nameservers);
    device->settings.nameservers = g_strdupv((gchar **)dns);
    if (device->settings.nameservers == NULL)
        goto err;

    __ofono_dbus_pending_reply(&device->pending,
                               dbus_message_new_method_return(device->pending));
    device->pending = NULL;

    device->active = TRUE;

    settings_changed(device);
    ofono_dbus_signal_property_changed(conn, device->path,
                                       DUNDEE_DEVICE_INTERFACE, "Active",
                                       DBUS_TYPE_BOOLEAN, &device->active);

    return;

err:
    g_free(device->settings.interface);
    g_free(device->settings.ip);
    g_strfreev(device->settings.nameservers);
    device->settings.interface = NULL;
    device->settings.ip = NULL;
    device->settings.nameservers = NULL;

    __ofono_dbus_pending_reply(&device->pending,
                               __dundee_error_failed(device->pending));
    device->pending = NULL;
}
Example #21
0
static void
gda_report_engine_dispose (GObject *object)
{
	GdaReportEngine *eng = (GdaReportEngine *) object;

	g_return_if_fail (GDA_IS_REPORT_ENGINE (eng));

	/* free memory */
	if (eng->priv) {
		if (eng->priv->objects) {
			g_hash_table_destroy (eng->priv->objects);
			eng->priv->objects = NULL;
		}

		if (eng->priv->doc) {
			xmlFreeDoc (eng->priv->doc);
			eng->priv->doc = NULL;
		}
		
		if (eng->priv->spec) {
			xmlFreeNode (eng->priv->spec);
			eng->priv->spec = NULL;
		}

		g_free (eng->priv->output_dir);

		g_free (eng->priv);
		eng->priv = NULL;
	}

	/* chain to parent class */
	parent_class->dispose (object);
}
Example #22
0
static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
{
    DBusConnection *conn = ofono_dbus_get_connection();
    struct dundee_device *device = user_data;

    DBG("%p", device);
    DBG("PPP Link down: %d\n", reason);

    g_at_ppp_unref(device->ppp);
    device->ppp = NULL;

    g_at_chat_resume(device->chat);

    g_free(device->settings.interface);
    g_free(device->settings.ip);
    g_strfreev(device->settings.nameservers);
    device->settings.interface = NULL;
    device->settings.ip = NULL;
    device->settings.nameservers = NULL;

    device->active = FALSE;

    settings_changed(device);
    ofono_dbus_signal_property_changed(conn, device->path,
                                       DUNDEE_DEVICE_INTERFACE, "Active",
                                       DBUS_TYPE_BOOLEAN, &device->active);

    device->driver->disconnect(device, disconnect_callback, device);
}
Example #23
0
static
gint _compare_contacts(PContact a, PContact b)
{
    const char * utf8_str_a = NULL;
    const char * utf8_str_b = NULL;

    if (p_contact_name(a) != NULL) {
        utf8_str_a = p_contact_name(a);
    } else {
        utf8_str_a = p_contact_barejid(a);
    }
    if (p_contact_name(b) != NULL) {
        utf8_str_b = p_contact_name(b);
    } else {
        utf8_str_b = p_contact_barejid(b);
    }

    gchar *key_a = g_utf8_collate_key(utf8_str_a, -1);
    gchar *key_b = g_utf8_collate_key(utf8_str_b, -1);

    gint result = g_strcmp0(key_a, key_b);

    g_free(key_a);
    g_free(key_b);

    return result;
}
Example #24
0
static void dictionary_dir_button_clicked_cb(GtkButton *button, gpointer item)
{
	GtkWidget *dialog;
	gchar *text;

	/* initialise the dialog */
	dialog = gtk_file_chooser_dialog_new(_("Select Directory"), NULL,
					GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);

	text = utils_get_locale_from_utf8(gtk_entry_get_text(GTK_ENTRY(item)));
	if (NZV(text))
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), text);

	/* run it */
	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
		gchar *utf8_filename, *tmp;

		tmp = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
		utf8_filename = utils_get_utf8_from_locale(tmp);

		gtk_entry_set_text(GTK_ENTRY(item), utf8_filename);

		g_free(utf8_filename);
		g_free(tmp);
	}

	gtk_widget_destroy(dialog);
}
Example #25
0
/*
 * Standard Gtk+ function
 */
static void Dw_gtk_viewport_destroy (GtkObject *object)
{
   GtkDwViewport *viewport;

   viewport = GTK_DW_VIEWPORT (object);

   if (viewport->back_pixmap)
      gdk_pixmap_unref (viewport->back_pixmap);
   if (viewport->child)
      gtk_object_destroy (GTK_OBJECT (viewport->child));
   if (viewport->draw_resize_idle_id != 0)
      gtk_idle_remove (viewport->draw_resize_idle_id);
   if (viewport->anchor_idle_id != 0)
      gtk_idle_remove (viewport->anchor_idle_id);
   g_free (viewport->anchor);

   g_hash_table_foreach_remove (viewport->anchors_table,
                                Dw_gtk_viewport_destroy_anchor, NULL);
   g_hash_table_destroy (viewport->anchors_table);

   g_free (viewport->draw_areas);

   a_Findtext_state_destroy (viewport->findtext_state);
   a_Selection_free (viewport->selection);

   GTK_OBJECT_CLASS(parent_class)->destroy (object);
}
Example #26
0
static void free_gpx_meta_data ( gpx_meta_data_t *data, gpointer userdata )
{
    g_free(data->name);
    g_free(data->vis);
    g_free(data->desc);
    g_free(data->timestamp);
}
Example #27
0
static char* _net_gen_query_params(GHashTable* query_params) {
    if (g_hash_table_size(query_params) > 0) {
        query_entries q_entries;
        char** entries;
        char* return_string;
        int i;
        //build the query string
        memset(&q_entries, 0, sizeof(query_entries));

        //We need the +1 so that it is NULL terminating for g_strjoinv
        entries = g_new0(char*, g_hash_table_size(query_params) + 1);
        q_entries.entries = entries;
        g_hash_table_foreach(query_params, _hash_for_each, &q_entries);

        return_string = g_strjoinv("&", entries);

        for (i = 0; ; i++) {
            char* current_string = entries[i];
            if (current_string == NULL) {
                break;
            }
            g_free(current_string);
        }

        g_free(entries);
        return return_string;
    } else {
Example #28
0
void error_free(Error *err)
{
    if (err) {
        g_free(err->msg);
        g_free(err);
    }
}
Example #29
0
/** Interpret result of GETD command. */
SR_PRIV int hcs_parse_volt_curr_mode(struct sr_dev_inst *sdi, char **tokens)
{
	char *str;
	double val;
	struct dev_context *devc;

	devc = sdi->priv;

	/* Bytes 0-3: Voltage. */
	str = g_strndup(tokens[0], 4);
	val = g_ascii_strtod(str, NULL) / 100;
	devc->voltage = val;
	g_free(str);

	/* Bytes 4-7: Current. */
	str = g_strndup((tokens[0] + 4), 4);
	val = g_ascii_strtod(str, NULL) / 100;
	devc->current = val;
	g_free(str);

	/* Byte 8: Mode ('0' means CV, '1' means CC). */
	devc->cc_mode = (tokens[0][8] == '1');

	/* Output enabled? Works because voltage cannot be set to 0.0 directly. */
	devc->output_enabled = devc->voltage != 0.0;

	return SR_OK;
}
Example #30
0
void
enclosure_free (enclosurePtr enclosure)
{
	g_free (enclosure->url);
	g_free (enclosure->mime);
	g_free (enclosure);
}