Exemplo n.º 1
0
void
nemo_action_activate (NemoAction *action, GList *selection, NemoFile *parent)
{
    GList *l;
    GString *exec = g_string_new (action->exec);

    gchar *ptr;
    TokenType token_type;

    ptr = find_token_type (exec->str, &token_type);

    while (ptr != NULL) {
        gint shift = ptr - exec->str;

        gchar *insertion = get_insertion_string (token_type, selection, parent);
        exec = g_string_erase (exec, shift, 2);
        exec = g_string_insert (exec, shift, insertion);

        token_type = TOKEN_NONE;
        g_free  (insertion);
        ptr = find_token_type (exec->str, &token_type);
    }

    if (action->use_parent_dir) {
        exec = g_string_prepend (exec, G_DIR_SEPARATOR_S);
        exec = g_string_prepend (exec, action->parent_dir);
    }

    DEBUG ("Spawning: %s\n", exec->str);
    g_spawn_command_line_async (exec->str, NULL);

    nemo_file_list_free (selection);
    g_string_free (exec, TRUE);
}
Exemplo n.º 2
0
void plugin_discover_available(void)
{
	GDir *dir;
	const gchar *plugin_name;
	Plugin *plugin;
	GString *user_plugin_dir;
	GString *filename;
	
	user_plugin_dir = g_string_new( g_get_home_dir());
	user_plugin_dir = g_string_append(user_plugin_dir, "/.gphpedit/plugins/");
	//g_print("User plugin dir: %s\n", user_plugin_dir->str);
	if (g_file_test(user_plugin_dir->str, G_FILE_TEST_IS_DIR)) {
		dir = g_dir_open(user_plugin_dir->str, 0,NULL);
		if (dir) {
			for (plugin_name = g_dir_read_name(dir); plugin_name != NULL; plugin_name = g_dir_read_name(dir)) {
				// Recommended by __tim in #gtk+ on irc.freenode.net 27/10/2004 11:30
				plugin = g_new0 (Plugin, 1);
				plugin->name = g_strdup(plugin_name);
				// TODO: Could do with replacing ' in name with \' for spawn
				filename = g_string_new(plugin->name);
				filename = g_string_prepend(filename, user_plugin_dir->str);
				plugin->filename = filename;
				//g_print ("PLUGIN FILENAME: %s\n", plugin->filename->str);
				plugin->type = plugin_discover_type(plugin->filename);
				Plugins = g_list_append(Plugins, plugin);
				//g_print("%s\n", plugin_name);
			}
			g_dir_close(dir);			
		}
	}
	g_string_free(user_plugin_dir, TRUE);

	if (g_file_test("/usr/share/gphpedit/plugins/", G_FILE_TEST_IS_DIR)) {
		dir = g_dir_open("/usr/share/gphpedit/plugins/", 0,NULL);
		if (dir) {
			for (plugin_name = g_dir_read_name(dir); plugin_name != NULL; plugin_name = g_dir_read_name(dir)) {
				// Recommended by __tim in #gtk+ on irc.freenode.net 27/10/2004 11:30
				plugin = g_new0 (Plugin, 1);
				plugin->name = g_strdup(plugin_name);
				filename = g_string_new(plugin_name);
				filename = g_string_prepend(filename, "/usr/share/gphpedit/plugins/");
				plugin->filename = filename;
				//g_print ("PLUGIN FILENAME: %s\n", plugin->filename->str);
				plugin->type = plugin_discover_type(plugin->filename);
				Plugins = g_list_append(Plugins, plugin);
				//g_print("%s\n", plugin_name);
			}
			g_dir_close(dir);			
		}
	}

	Plugins = g_list_sort(Plugins, sort_plugin_func);

	//g_print ("FOUND ALL PLUGINS\n");
}
static GString *
gcm_cell_renderer_get_profile_text (CdProfile *profile)
{
	CdColorspace colorspace;
	const gchar *id;
	GString *string;
	g_autofree gchar *markup = NULL;

	if (profile == NULL) {
		/* TRANSLATORS: this is when there is no profile for the device */
		return g_string_new (_("No profile"));
	}

	/* add profile description */
	id = cd_profile_get_title (profile);
	if (id != NULL && id[0] != '\0') {
		markup = g_markup_escape_text (id, -1);
		string = g_string_new (markup);
		goto out;
	}

	/* some meta profiles do not have ICC profiles */
	colorspace = cd_profile_get_colorspace (profile);
	if (colorspace != CD_COLORSPACE_UNKNOWN) {
		string = g_string_new (NULL);
		g_string_append_printf (string,
					_("Default %s"),
					cd_colorspace_to_localised_string (colorspace));
		goto out;
	}

	/* fall back to ID, ick */
	string = g_string_new (cd_profile_get_id (profile));
out:

	/* any source prefix? */
	id = cd_profile_get_metadata_item (profile,
					   CD_PROFILE_METADATA_DATA_SOURCE);
	if (g_strcmp0 (id, CD_PROFILE_METADATA_DATA_SOURCE_EDID) == 0) {
		/* TRANSLATORS: this is a profile prefix to signify the
		 * profile has been auto-generated for this hardware */
		g_string_prepend (string, _("Default: "));
	}
	if (g_strcmp0 (id, CD_PROFILE_METADATA_DATA_SOURCE_STANDARD) == 0) {
		/* TRANSLATORS: this is a profile prefix to signify the
		 * profile his a standard space like AdobeRGB */
		g_string_prepend (string, _("Colorspace: "));
	}
	if (g_strcmp0 (id, CD_PROFILE_METADATA_DATA_SOURCE_TEST) == 0) {
		/* TRANSLATORS: this is a profile prefix to signify the
		 * profile is a test profile */
		g_string_prepend (string, _("Test profile: "));
	}
	return string;
}
Exemplo n.º 4
0
gboolean
gs_plugin_add_category_apps (GsPlugin *plugin,
			     GsCategory *category,
			     GsAppList *list,
			     GCancellable *cancellable,
			     GError **error)
{
	GsCategory *c;
	g_autoptr(GString) id = NULL;
	const gchar *sections = NULL;

	id = g_string_new ("");
	for (c = category; c != NULL; c = gs_category_get_parent (c)) {
		if (c != category)
			g_string_prepend (id, "/");
		g_string_prepend (id, gs_category_get_id (c));
	}

	if (strcmp (id->str, "games/featured") == 0)
		sections = "games";
	else if (strcmp (id->str, "audio-video/featured") == 0)
		sections = "music;video";
	else if (strcmp (id->str, "graphics/featured") == 0)
		sections = "graphics";
	else if (strcmp (id->str, "communication/featured") == 0)
		sections = "social-networking";
	else if (strcmp (id->str, "productivity/featured") == 0)
		sections = "productivity;finance";
	else if (strcmp (id->str, "developer-tools/featured") == 0)
		sections = "developers";
	else if (strcmp (id->str, "utilities/featured") == 0)
		sections = "utilities";

	if (sections != NULL) {
		g_auto(GStrv) tokens = NULL;
		int i;

		tokens = g_strsplit (sections, ";", -1);
		for (i = 0; tokens[i] != NULL; i++) {
			g_autoptr(GPtrArray) snaps = NULL;
			guint j;

			snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_SCOPE_WIDE, tokens[i], NULL, cancellable, error);
			if (snaps == NULL)
				return FALSE;
			for (j = 0; j < snaps->len; j++) {
				g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, j));
				gs_app_list_add (list, app);
			}
		}
	}
	return TRUE;
}
Exemplo n.º 5
0
/* 1982/34 -> 一九八二/三四 */
void num_2_hanzi(int n, char* hanzi, gulong len)
{
    GString *str = g_string_new("");
    int d;
    while (n > 10)
    {
        d = n % 10;
        n = n/10;
        str = g_string_prepend(str, _(hanzi_num[d]));
    }
    str = g_string_prepend(str, _(hanzi_num[n]));

    g_snprintf(hanzi, len, "%s", str->str);
    g_string_free(str, TRUE);
}
Exemplo n.º 6
0
/* Internal: Execute script command */
gboolean
_verve_db_exec_script_command (VerveDb *db, const VerveScriptCommand *cmd)
{
  VerveEnv *env = verve_env_get ();
  const gchar *shell_path = verve_env_shell_get_path (env, cmd->shell);
  
  GString *command = g_string_new (cmd->target_filename);
  g_string_prepend (command, " ");
  g_string_prepend (command, shell_path);
  
  gboolean success = verve_spawn_command_line (command->str);
  
  g_string_free (command, TRUE);
  
  return success;
}
Exemplo n.º 7
0
void xa_7zip_delete (XArchive *archive,GSList *names)
{
	gchar *command,*exe,*e_filename = NULL;
	GSList *list = NULL,*_names;
	GString *files = g_string_new("");

	if (sevenzr)
		exe = "7zr d ";
	if (sevenza)
		exe = "7za d ";

 	_names = names;
 	while (_names)
	{
		e_filename  = xa_escape_filename((gchar*)_names->data,"$'`\"\\!?* ()[]&|:;<>#");
		g_string_prepend (files,e_filename);
		g_string_prepend_c (files,' ');
		_names = _names->next;
	}
	g_slist_foreach(names,(GFunc)g_free,NULL);
	g_slist_free(names);
	command = g_strconcat (exe,archive->escaped_path," ",files->str,NULL);
	g_string_free(files,TRUE);
	list = g_slist_append(list,command);

	xa_run_command (archive,list);
	if (archive->status == XA_ARCHIVESTATUS_DELETE)
		xa_reload_archive_content(archive);
}
Exemplo n.º 8
0
void
ario_lyrics_prepend_infos (ArioLyrics *lyrics)
{
        GString *string;
        gchar *toprepend;

        if (!lyrics)
                return;

        if (lyrics->artist && lyrics->title) {
                toprepend = g_strdup_printf ("%s - %s\n\n", lyrics->artist, lyrics->title);
        } else if (lyrics->artist) {
                toprepend = g_strdup_printf ("%s\n\n", lyrics->artist);
        } else if (lyrics->title) {
                toprepend = g_strdup_printf ("%s\n\n", lyrics->title);
        } else {
                return;
        }

        string = g_string_new (lyrics->lyrics);
        string = g_string_prepend (string, toprepend);
        g_free (lyrics->lyrics);
        lyrics->lyrics = g_string_free (string, FALSE);
        g_free (toprepend);
}
Exemplo n.º 9
0
gboolean xa_7zip_extract(XArchive *archive,GSList *files)
{
	gchar *command,*e_filename = NULL;
	GSList *list = NULL,*_files = NULL;
	GString *names = g_string_new("");
	gboolean result = FALSE;

	_files = files;
	while (_files)
	{
		e_filename  = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#");
		g_string_prepend (names,e_filename);
		g_string_prepend_c (names,' ');
		_files = _files->next;
	}
	g_slist_foreach(_files,(GFunc)g_free,NULL);
	g_slist_free(_files);

	if (archive->passwd != NULL)
		command = g_strconcat ("7za " , archive->full_path ? "x" : "e",
								" -p",archive->passwd,
								archive->overwrite ? " -aoa" : " -aos",
								" -bd ",
								archive->escaped_path,names->str , " -o",archive->extraction_path,NULL);
	else
		command = g_strconcat ( "7za " , archive->full_path ? "x" : "e",
								archive->overwrite ? " -aoa" : " -aos",
								" -bd ",
								archive->escaped_path,names->str , " -o",archive->extraction_path,NULL);
	g_string_free(names,TRUE);
	list = g_slist_append(list,command);

	result = xa_run_command (archive,list);
	return result;
}
Exemplo n.º 10
0
Arquivo: surf.c Projeto: sr/surf
void
loadfile(const Client *c, const gchar *f) {
    GIOChannel *chan = NULL;
    GError *e = NULL;
    GString *code = g_string_new("");
    GString *uri = g_string_new(f);
    gchar *line;

    if(strcmp(f, "-") == 0) {
        chan = g_io_channel_unix_new(STDIN_FILENO);
        if (chan) {
            while(g_io_channel_read_line(chan, &line, NULL, NULL, &e) == G_IO_STATUS_NORMAL) {
                g_string_append(code, line);
                g_free(line);
            }
            webkit_web_view_load_html_string(c->view, code->str, NULL);
            g_io_channel_shutdown(chan, FALSE, NULL);
        }
    }
    else {
        g_string_prepend(uri, "file://");
        loaduri(c, uri->str);
    }

}
Exemplo n.º 11
0
EXPORT_C
#endif


gchar *
parse_sami (ParserState * state, const gchar * line)
{
  gchar *fixed_line;
  GstSamiContext *context = (GstSamiContext *) state->user_data;

  fixed_line = fix_invalid_entities (line);
  htmlParseChunk (context->htmlctxt, fixed_line, strlen (fixed_line), 0);
  g_free (fixed_line);

  if (context->has_result) {
    gchar *r;

    if (context->rubybuf->len) {
      context->rubybuf = g_string_append_c (context->rubybuf, '\n');
      g_string_prepend (context->resultbuf, context->rubybuf->str);
      context->rubybuf = g_string_truncate (context->rubybuf, 0);
    }

    r = g_string_free (context->resultbuf, FALSE);
    context->resultbuf = g_string_new ("");
    state->start_time = context->time1;
    state->duration = context->time2 - context->time1;
    context->has_result = FALSE;
    return r;
  }
  return NULL;
}
Exemplo n.º 12
0
gboolean xa_deb_extract(XArchive *archive,GSList *files)
{
	gchar *command;
	GSList *list = NULL,*_files = NULL;
	GString *names = g_string_new("");
	gboolean result = FALSE;

	_files = files;
	while (_files)
	{
		g_string_prepend (names,(gchar*)_files->data);
		g_string_prepend_c (names,' ');
		_files = _files->next;
	}
	g_slist_foreach(files,(GFunc)g_free,NULL);
	g_slist_free(files);

	chdir (archive->extraction_path);
	command = g_strconcat ("ar x ",archive->escaped_path," ",names->str,NULL);
	if (command != NULL)
	{
		g_string_free(names,FALSE);
		list = g_slist_append(list,command);
		result = xa_run_command (archive,list);
	}
	return result;
}
Exemplo n.º 13
0
gboolean xa_rpm_extract(XArchive *archive,GSList *files)
{
	gchar *command = NULL,*e_filename = NULL;
	GSList *list = NULL,*_files = NULL;
	GString *names = g_string_new("");
	gboolean result = FALSE;

	_files = files;
	while (_files)
	{
		e_filename  = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#");
		g_string_prepend (names,e_filename);
		g_string_prepend_c (names,' ');
		_files = _files->next;
	}
	g_slist_foreach(files,(GFunc)g_free,NULL);
	g_slist_free(files);
	
	chdir (archive->extraction_path);
	command = g_strconcat ( "sh -c \"cpio -id" , names->str," < ",archive->tmp,"/file.cpio\"",NULL);

	g_string_free(names,TRUE);
	list = g_slist_append(list,command);
	result = xa_run_command (archive,list);
	return result;
}
Exemplo n.º 14
0
void xa_tar_delete (XArchive *archive,GSList *files)
{
	gchar *e_filename,*command = NULL;
	GSList *_files,*list = NULL;
	GString *names = g_string_new("");

	_files = files;
	while (_files)
	{
		e_filename  = xa_escape_filename((gchar*)_files->data,"$'`\"\\!?* ()[]&|:;<>#");
		g_string_prepend (names,e_filename);
		g_string_prepend_c (names,' ');
		_files = _files->next;
	}
	g_slist_foreach(files,(GFunc)g_free,NULL);
	g_slist_free(files);

	if (is_tar_compressed(archive->type))
		xa_add_delete_bzip2_gzip_lzma_compressed_tar(names,archive,0);
	else
	{
		command = g_strconcat (tar, " --delete -vf ",archive->escaped_path," ",names->str,NULL);
		list = g_slist_append(list,command);
		xa_run_command (archive,list);
		if (archive->status == XA_ARCHIVESTATUS_DELETE)
			xa_reload_archive_content(archive);
	}
}
Exemplo n.º 15
0
GString *
conv_dec_to_hex (gint dec)
{
  GString *hex;
  hex = g_string_new ("");

  if (dec == 0)
	{
	  g_string_append (hex, "0");
	  return hex;
	}

  while (dec)
	{
	  gint lfbits;
	  gchar digit[2] = "X";
	  lfbits = dec & 0xF;

	  if (lfbits < 10)
		digit[0] = '0' + lfbits;
	  else
		digit[0] = 'A' + lfbits - 10;

	  g_string_prepend (hex, digit);

	  dec >>= 4;
	}

  return hex;
}
Exemplo n.º 16
0
static void
vp_trans_add_prefix(ValuePairsTransform *t, SBGString *key)
{
  VPTransAddPrefix *self = (VPTransAddPrefix *)t;

  g_string_prepend(sb_gstring_string(key), self->prefix);
}
Exemplo n.º 17
0
Arquivo: surf.c Projeto: sr/surf
void
loaduri(const Client *c, const gchar *uri) {
    GString* u = g_string_new(uri);
    if(g_strrstr(u->str, ":") == NULL)
        g_string_prepend(u, "http://");
    webkit_web_view_load_uri(c->view, u->str);
    g_string_free(u, TRUE);
}
Exemplo n.º 18
0
Arquivo: uzbl.c Projeto: dusanx/uzbl
static void
update_title (void) {
    GString* string_long = g_string_new ("");
    GString* string_short = g_string_new ("");
    char* iname = NULL;
    int iname_len;

    if(instance_name) {
            iname_len = strlen(instance_name)+4;
            iname = malloc(iname_len);
            snprintf(iname, iname_len, "<%s> ", instance_name);
            
            g_string_prepend(string_long, iname);
            g_string_prepend(string_short, iname);
            free(iname);
    }

    g_string_append_printf(string_long, "%s ", keycmd->str);
    if (!always_insert_mode)
        g_string_append (string_long, (insert_mode ? "[I] " : "[C] "));
    if (main_title) {
        g_string_append (string_long, main_title);
        g_string_append (string_short, main_title);
    }
    g_string_append (string_long, " - Uzbl browser");
    g_string_append (string_short, " - Uzbl browser");
    if (load_progress < 100)
        g_string_append_printf (string_long, " (%d%%)", load_progress);

    if (selected_url[0]!=0) {
        g_string_append_printf (string_long, " -> (%s)", selected_url);
    }

    gchar* title_long = g_string_free (string_long, FALSE);
    gchar* title_short = g_string_free (string_short, FALSE);

    if (show_status) {
        gtk_window_set_title (GTK_WINDOW(main_window), title_short);
    gtk_label_set_text(GTK_LABEL(mainbar_label), title_long);
    } else {
        gtk_window_set_title (GTK_WINDOW(main_window), title_long);
    }

    g_free (title_long);
    g_free (title_short);
}
Exemplo n.º 19
0
static void
purplerc_write(GtkWidget *widget, gpointer data)
{
	GString *str = make_gtkrc_string();
	str = g_string_prepend(str, "# This file automatically written by the Pidgin GTK+ Theme Control plugin.\n# Any changes to this file will be overwritten by the plugin when told to\n# write the settings again.\n# The FAQ (http://developer.pidgin.im/wiki/FAQ) contains some further examples\n# of possible pidgin gtkrc settings.\n");
	purple_util_write_data_to_file("gtkrc-2.0", str->str, -1);
	g_string_free(str, TRUE);
}
Exemplo n.º 20
0
static const gchar *
mangle (const gchar *component, ...)
{
    GString *mangled;
    va_list args;

    mangled = g_string_new("@YAXXZ");
    va_start(args, component);
    while (component) {
        g_string_prepend(mangled, "@");
        g_string_prepend(mangled, component);
        component = va_arg(args, gchar *);
    }
    va_end(args);
    g_string_prepend(mangled, "?");

    return cut_take_string(g_string_free(mangled, FALSE));
}
Exemplo n.º 21
0
Arquivo: uzbl.c Projeto: dusanx/uzbl
static void
load_uri (WebKitWebView * web_view, const gchar *param) {
    if (param) {
        GString* newuri = g_string_new (param);
        if (g_strrstr (param, "://") == NULL)
            g_string_prepend (newuri, "http://"); 
        webkit_web_view_load_uri (web_view, newuri->str);
        g_string_free (newuri, TRUE);
    }
}
Exemplo n.º 22
0
/** Convert local absolute path to uri.
 *
 * @param filename to (absolute pathed) filename to convert
 * @return a newly allocated uri, you must g_free it later
 */
gchar *
filename2uri(const gchar *filename)
{
    int i = 0;
    gchar *file_tmp;
    GString *filestr;


    filestr = g_string_sized_new(200);

    /* this escaping is somewhat slow but should working fine */
    for(i=0; filename[i]; i++) {
        switch(filename[i]) {
        case(' '):
            g_string_append(filestr, "%20");
            break;
        case('%'):
            g_string_append(filestr, "%%");
            break;
        case('\\'):
            g_string_append_c(filestr, '/');
            break;
            /* XXX - which other chars need to be escaped? */
        default:
            g_string_append_c(filestr, filename[i]);
        }
    }


    /* prepend URI header "file:" appropriate for the system */
#ifdef G_OS_WIN32
    /* XXX - how do we handle UNC names (e.g. //servername/sharename/dir1/dir2/capture-file.cap) */
    g_string_prepend(filestr, "file:///");
#else
    g_string_prepend(filestr, "file://");
#endif

    file_tmp = filestr->str;

    g_string_free(filestr, FALSE /* don't free segment data */);

    return file_tmp;
}
Exemplo n.º 23
0
void warning(const char *fmt, ...)
{
	GString *str;
	va_list ap;
	int err;

	if (alt_warning) {
		va_start(ap, fmt);
		alt_warning(fmt, ap);
		va_end(ap);
		return;
	}

	if (!parent_window) {
		va_start(ap, fmt);
		__vwarning(fmt, ap);
		va_end(ap);
		return;
	}

	err = errno;
	errno = 0;

	str = g_string_new("");

	va_start(ap, fmt);
	g_string_vprintf(str, fmt, ap);
	va_end(ap);

	g_string_append(str, "\n");

	if (errno) {
		g_string_prepend(str, "\n");
		g_string_prepend(str, strerror(errno));
	}

	errno = 0;

	trace_dialog(GTK_WINDOW(parent_window), TRACE_GUI_WARNING,
		     str->str);

	g_string_free(str, TRUE);
}
Exemplo n.º 24
0
Arquivo: uzbl.c Projeto: DuClare/uzbl
static void
load_uri (WebKitWebView * web_view, const gchar *param) {
    if (param) {
        GString* newuri = g_string_new (param);
        if (g_strrstr (param, "://") == NULL)
            g_string_prepend (newuri, "http://");
		/* if we do handle cookies, ask our handler for them */
        webkit_web_view_load_uri (web_view, newuri->str);
        g_string_free (newuri, TRUE);
    }
}
Exemplo n.º 25
0
static gchar* _tgengraph_getHomePath(const gchar* path) {
    g_assert(path);
    GString* sbuffer = g_string_new(path);
    if(g_ascii_strncasecmp(path, "~", 1) == 0) {
        /* replace ~ with home directory */
        const gchar* home = g_get_home_dir();
        g_string_erase(sbuffer, 0, 1);
        g_string_prepend(sbuffer, home);
    }
    return g_string_free(sbuffer, FALSE);
}
Exemplo n.º 26
0
node * mk_autolink(char *text) {
	char *label = label_from_string(text);
	GString *anchor = g_string_new(label);
	g_string_prepend(anchor, "#");

	node *result = mk_node(LINK);
	result->link_data = mk_link_data(label, anchor->str, NULL, NULL);

	g_string_free(anchor, TRUE);
	free(label);
	return result;
}
Exemplo n.º 27
0
static GsApp *
gs_plugin_create_app_dummy (const gchar *id)
{
	GsApp *app = gs_app_new (id);
	g_autoptr(GString) str = NULL;
	str = g_string_new (id);
	as_utils_string_replace (str, ".desktop", "");
	g_string_prepend (str, "No description is available for ");
	gs_app_set_name (app, GS_APP_QUALITY_LOWEST, "Unknown Application");
	gs_app_set_summary (app, GS_APP_QUALITY_LOWEST, "Application not found");
	gs_app_set_description (app, GS_APP_QUALITY_LOWEST, str->str);
	return app;
}
Exemplo n.º 28
0
void
nemo_action_activate (NemoAction *action, GList *selection, NemoFile *parent)
{
    GString *exec = g_string_new (action->exec);

    action->escape_underscores = FALSE;

    exec = expand_action_string (action, selection, parent, exec);

    if (action->use_parent_dir) {
        exec = g_string_prepend (exec, G_DIR_SEPARATOR_S);
        exec = g_string_prepend (exec, action->parent_dir);
    }

    DEBUG ("Action Spawning: %s", exec->str);
    if (action->log_output)
        g_printerr ("Action Spawning: %s\n", exec->str);

    g_spawn_command_line_async (exec->str, NULL);

    g_string_free (exec, TRUE);
}
Exemplo n.º 29
0
static GString *
g_string_prepend_printf(GString *string, const char *format, ...)
{
	va_list args;
	char *str;

	va_start(args, format);
	str = g_strdup_vprintf(format, args);
	va_end(args);
	string = g_string_prepend(string, str);
	g_free(str);
	return string;
}
Exemplo n.º 30
0
/*
 * pk_parse_os_release:
 *
 * Internal helper to parse os-release
 **/
static gboolean
pk_parse_os_release (gchar **id, gchar **name, gchar **version_id, GError **error)
{
	const gchar *filename = "/etc/os-release";
	gboolean ret;
	g_autofree gchar *contents = NULL;
	g_autoptr(GKeyFile) key_file = NULL;
	g_autoptr(GString) str = NULL;

	/* load data */
	if (!g_file_test (filename, G_FILE_TEST_EXISTS))
		filename = "/usr/lib/os-release";
	if (!g_file_get_contents (filename, &contents, NULL, error))
		return FALSE;

	/* make a valid GKeyFile from the .ini data by prepending a header */
	str = g_string_new (contents);
	g_string_prepend (str, "[os-release]\n");
	key_file = g_key_file_new ();
	ret = g_key_file_load_from_data (key_file, str->str, -1, G_KEY_FILE_NONE, error);
	if (!ret) {
		return FALSE;
	}

	/* get keys */
	if (id != NULL) {
		g_autofree gchar *tmp = g_key_file_get_string (key_file, "os-release", "ID", error);
		if (tmp == NULL)
			return FALSE;
		*id = g_shell_unquote (tmp, error);
		if (*id == NULL)
			return FALSE;
	}
	if (name != NULL) {
		g_autofree gchar *tmp = g_key_file_get_string (key_file, "os-release", "NAME", error);
		if (tmp == NULL)
			return FALSE;
		*name = g_shell_unquote (tmp, error);
		if (*name == NULL)
			return FALSE;
	}
	if (version_id != NULL) {
		g_autofree gchar *tmp = g_key_file_get_string (key_file, "os-release", "VERSION_ID", error);
		if (tmp == NULL)
			return FALSE;
		*version_id = g_shell_unquote (tmp, error);
		if (*version_id == NULL)
			return FALSE;
	}
	return TRUE;
}