当前位置: 首页>>代码示例>>C++>>正文


C++ g_key_file_new函数代码示例

本文整理汇总了C++中g_key_file_new函数的典型用法代码示例。如果您正苦于以下问题:C++ g_key_file_new函数的具体用法?C++ g_key_file_new怎么用?C++ g_key_file_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了g_key_file_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: nemo_action_constructed

void
nemo_action_constructed (GObject *object)
{
    G_OBJECT_CLASS (parent_class)->constructed (object);

    NemoAction *action = NEMO_ACTION (object);

    GKeyFile *key_file = g_key_file_new();

    g_key_file_load_from_file (key_file, action->key_file_path, G_KEY_FILE_NONE, NULL);

    gchar *orig_label = g_key_file_get_locale_string (key_file,
                                                      ACTION_FILE_GROUP,
                                                      KEY_NAME,
                                                      NULL,
                                                      NULL);

    gchar *orig_tt = g_key_file_get_locale_string (key_file,
                                                   ACTION_FILE_GROUP,
                                                   KEY_COMMENT,
                                                   NULL,
                                                   NULL);

    gchar *icon_name = g_key_file_get_string (key_file,
                                              ACTION_FILE_GROUP,
                                              KEY_ICON_NAME,
                                              NULL);

    gchar *stock_id = g_key_file_get_string (key_file,
                                             ACTION_FILE_GROUP,
                                             KEY_STOCK_ID,
                                             NULL);


    gchar *exec_raw = g_key_file_get_string (key_file,
                                             ACTION_FILE_GROUP,
                                             KEY_EXEC,
                                             NULL);

    gchar *selection_string_raw = g_key_file_get_string (key_file,
                                                         ACTION_FILE_GROUP,
                                                         KEY_SELECTION,
                                                         NULL);

    gchar *selection_string = g_ascii_strdown (selection_string_raw, -1);

    g_free (selection_string_raw);

    gchar *separator = g_key_file_get_string (key_file,
                                              ACTION_FILE_GROUP,
                                              KEY_SEPARATOR,
                                              NULL);

    gchar *quote_type_string = g_key_file_get_string (key_file,
                                                      ACTION_FILE_GROUP,
                                                      KEY_QUOTE_TYPE,
                                                      NULL);

    QuoteType quote_type = QUOTE_TYPE_NONE;

    if (quote_type_string != NULL) {
        if (g_strcmp0 (quote_type_string, "single") == 0)
            quote_type = QUOTE_TYPE_SINGLE;
        else if (g_strcmp0 (quote_type_string, "double") == 0)
            quote_type = QUOTE_TYPE_DOUBLE;
        else if (g_strcmp0 (quote_type_string, "backtick") == 0)
            quote_type = QUOTE_TYPE_BACKTICK;
    }

    SelectionType type;

    if (g_strcmp0 (selection_string, SELECTION_SINGLE_KEY) == 0)
        type = SELECTION_SINGLE;
    else if (g_strcmp0 (selection_string, SELECTION_MULTIPLE_KEY) == 0)
        type = SELECTION_MULTIPLE;
    else if (g_strcmp0 (selection_string, SELECTION_ANY_KEY) == 0)
        type = SELECTION_ANY;
    else if (g_strcmp0 (selection_string, SELECTION_NONE_KEY) == 0)
        type = SELECTION_NONE;
    else if (g_strcmp0 (selection_string, SELECTION_NOT_NONE_KEY) == 0)
        type = SELECTION_NOT_NONE;
    else {
        gint val = (int) g_ascii_strtoll (selection_string, NULL, 10);
        type = val > 0 ? val : SELECTION_SINGLE;
    }

    g_free (selection_string);

    gsize count;

    gchar **ext = g_key_file_get_string_list (key_file,
                                              ACTION_FILE_GROUP,
                                              KEY_EXTENSIONS,
                                              &count,
                                              NULL);

    gsize mime_count;

    gchar **mimes = g_key_file_get_string_list (key_file,
                                                ACTION_FILE_GROUP,
//.........这里部分代码省略.........
开发者ID:IanLee1521,项目名称:nemo,代码行数:101,代码来源:nemo-action.c

示例2: main


//.........这里部分代码省略.........
          0, G_OPTION_ARG_STRING, &watchx,
          "seat-ready watch item",
          NULL },
        { "vtnr", 'j',
          0, G_OPTION_ARG_INT, &vtnr,
          "virtual terminal number for seat",
          NULL },
        { "rtimedir", 'k',
          0, G_OPTION_ARG_INT, &rtimedir,
          "setup XDG_RUNTIME_DIR for the user - enable/disable",
          NULL },
        { "rtimemode", 'm',
          0, G_OPTION_ARG_STRING, &rtimemode,
          "access mode for the XDG_RUNTIME_DIR",
          NULL },
        { NULL }
    };

    opts = g_option_context_new ("<add|change|remove> [command]");
    g_option_context_add_main_entries (opts, main_entries, NULL);
    g_option_context_parse (opts, &argc, &argv, NULL);
    g_option_context_free (opts);
    if (argc < 2) {
        printf ("%s [options] <add|change|remove> [command]\n", argv[0]);
        return -1;
    }
    if (!cf)
        cf = g_build_filename (TLM_SYSCONF_DIR, "tlm.conf", NULL);
    lockfd = open (cf, O_RDWR);
    if (lockfd < 0)
        g_critical ("open(%s): %s", cf, strerror (errno));
    if (lockf (lockfd, F_LOCK, 0))
        g_critical ("lockf(): %s", strerror (errno));
    kf = g_key_file_new ();
    if (!g_key_file_load_from_file (kf, cf,
                                    G_KEY_FILE_KEEP_COMMENTS, &error)) {
        g_warning ("failed to load config file: %s", error->message);
        goto err_exit;
    }
    nseats = g_key_file_get_integer (kf,
                                     TLM_CONFIG_GENERAL,
                                     TLM_CONFIG_GENERAL_NSEATS,
                                     NULL);

    if (g_strcmp0 (argv[1], "add") == 0) {
        seatx = nseats;
        nseats++;
        sname = g_strdup_printf ("seat%d", seatx);
        puts (sname);
    }
    else if (g_strcmp0 (argv[1], "change") == 0) {
        if (!sname) {
            g_warning ("no seat specified");
            goto err_exit;
        }
        if (!g_key_file_has_group (kf, sname)) {
            g_warning ("given seat doesn't exist");
            goto err_exit;
        }
    }
    else if (g_strcmp0 (argv[1], "remove") == 0) {
        if (!sname) {
            g_warning ("no seat specified");
            goto err_exit;
        }
        if (!g_key_file_has_group (kf, sname)) {
开发者ID:juimonen,项目名称:tlm,代码行数:67,代码来源:tlm-seatconf.c

示例3: main

int main (int argc, char **argv)
{

    char sql[256];
    gboolean verbose = FALSE;
    gboolean use_mysql = FALSE;
    int ret;

    if (argc == 1)
        usage(1);

    int c;
    while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != EOF) {
        switch (c) {
        case 'h':
            usage(0);
            break;
        case 'v':
            verbose = TRUE;
            break;
        case 'm':
            use_mysql = TRUE;
            break;
        case 's':
            config.mysql_host = strdup(optarg);
            break;
        case 't':
            config.mysql_socket = strdup(optarg);
            break;
        case 'r':
            config.mysql_root_passwd = strdup(optarg);
            break;
        case 'd':
            config.seafile_dir = strdup(optarg);
            break;
        case 'p':
            config.port = strdup(optarg);
            break;
        case 'P':
            config.httpserver_port = strdup(optarg);
            break;
        default:
            usage(1);
        }
    }

    if (use_mysql && !config.mysql_root_passwd) {
        fprintf (stderr, "You choose to use mysql database. "
                 "Mysql Root Password must be specified.\n");
        exit(1);
    }

    if (!config.seafile_dir) {
        fprintf (stderr, "You must specify seafile data dir\n");
        usage(1);
    }

    /* Create database for mysql */
    if (use_mysql) {
        SeafDB *db_root = seaf_db_new_mysql (config.mysql_host, "root",
                                             config.mysql_root_passwd,
                                             NULL, config.mysql_socket);
        if (!db_root) {
        fprintf (stderr, "Out of memory!\n");
        return 1;
        }

        /* Create database for Seafile server. */
        snprintf (sql, sizeof(sql), "CREATE DATABASE IF NOT EXISTS `%s`",
              config.mysql_db_name);
        ret = seaf_db_query (db_root, sql);
        if (ret < 0) {
            fprintf (stderr, "Failed to create database %s.\n", config.mysql_db_name);
        return 1;
        }
        
        if (verbose)
            printf ("Successfully created database:     %s\n",
                    config.mysql_db_name);
        
        /* Create database for Seahub. */
        snprintf (sql, sizeof(sql), "CREATE DATABASE IF NOT EXISTS `%s` character set utf8",
                  config.mysql_seahub_db_name);
        ret = seaf_db_query (db_root, sql);
        if (ret < 0) {
            fprintf (stderr, "Failed to create database %s.\n",
                     config.mysql_seahub_db_name);
            return 1;
        }

        if (verbose)
            printf ("Successfully created database:     %s\n",
                    config.mysql_seahub_db_name);
    }
        
    /* Generate config file. */
    GKeyFile *key_file = g_key_file_new ();

    g_key_file_set_string (key_file, "database", "type",
                           use_mysql ? "mysql" : "sqlite");
//.........这里部分代码省略.........
开发者ID:Jack-Tsue,项目名称:seafile,代码行数:101,代码来源:seaf-server-init.c

示例4: remmina_pref_save

void
remmina_pref_save (void)
{
    GKeyFile *gkeyfile;
    gchar *content;
    gsize length;

    gkeyfile = g_key_file_new ();

    g_key_file_load_from_file (gkeyfile, remmina_pref_file, G_KEY_FILE_NONE, NULL);

    g_key_file_set_boolean (gkeyfile, "remmina_pref", "save_view_mode", remmina_pref.save_view_mode);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "save_when_connect", remmina_pref.save_when_connect);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "invisible_toolbar", remmina_pref.invisible_toolbar);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "always_show_tab", remmina_pref.always_show_tab);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "hide_connection_toolbar", remmina_pref.hide_connection_toolbar);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "default_action", remmina_pref.default_action);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "scale_quality", remmina_pref.scale_quality);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "hide_toolbar", remmina_pref.hide_toolbar);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "hide_statusbar", remmina_pref.hide_statusbar);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "show_quick_search", remmina_pref.show_quick_search);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "small_toolbutton", remmina_pref.small_toolbutton);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "view_file_mode", remmina_pref.view_file_mode);
    g_key_file_set_string (gkeyfile, "remmina_pref", "resolutions", remmina_pref.resolutions);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "main_width", remmina_pref.main_width);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "main_height", remmina_pref.main_height);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "main_maximize", remmina_pref.main_maximize);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "main_sort_column_id", remmina_pref.main_sort_column_id);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "main_sort_order", remmina_pref.main_sort_order);
    g_key_file_set_string (gkeyfile, "remmina_pref", "expanded_group", remmina_pref.expanded_group);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "toolbar_pin_down", remmina_pref.toolbar_pin_down);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "sshtunnel_port", remmina_pref.sshtunnel_port);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "applet_new_ontop", remmina_pref.applet_new_ontop);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "applet_hide_count", remmina_pref.applet_hide_count);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "applet_enable_avahi", remmina_pref.applet_enable_avahi);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "disable_tray_icon", remmina_pref.disable_tray_icon);
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "minimize_to_tray", remmina_pref.minimize_to_tray);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "recent_maximum", remmina_pref.recent_maximum);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "default_mode", remmina_pref.default_mode);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "tab_mode", remmina_pref.tab_mode);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "auto_scroll_step", remmina_pref.auto_scroll_step);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "hostkey", remmina_pref.hostkey);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_fullscreen", remmina_pref.shortcutkey_fullscreen);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_autofit", remmina_pref.shortcutkey_autofit);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_nexttab", remmina_pref.shortcutkey_nexttab);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_prevtab", remmina_pref.shortcutkey_prevtab);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_scale", remmina_pref.shortcutkey_scale);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_grab", remmina_pref.shortcutkey_grab);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_minimize", remmina_pref.shortcutkey_minimize);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_disconnect", remmina_pref.shortcutkey_disconnect);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "shortcutkey_toolbar", remmina_pref.shortcutkey_toolbar);
    g_key_file_set_string (gkeyfile, "remmina_pref", "vte_font", remmina_pref.vte_font ? remmina_pref.vte_font : "");
    g_key_file_set_boolean (gkeyfile, "remmina_pref", "vte_allow_bold_text", remmina_pref.vte_allow_bold_text);
    g_key_file_set_integer (gkeyfile, "remmina_pref", "vte_lines", remmina_pref.vte_lines);

    content = g_key_file_to_data (gkeyfile, &length, NULL);
    g_file_set_contents (remmina_pref_file, content, length, NULL);

    g_key_file_free (gkeyfile);
    g_free (content);
}
开发者ID:awakecoding,项目名称:Remmina,代码行数:61,代码来源:remminapref.c

示例5: load_option_rcfile

void load_option_rcfile(const gchar *rcname)
{
  SYLPF_OPTION.rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, rcname, NULL);
  SYLPF_OPTION.rcfile = g_key_file_new();
  g_key_file_load_from_file(SYLPF_OPTION.rcfile, SYLPF_OPTION.rcpath, G_KEY_FILE_KEEP_COMMENTS, NULL);
}
开发者ID:kenhys,项目名称:sylpheed-htmlview,代码行数:6,代码来源:htmlview.c

示例6: get_config_from_opts

static GKeyFile *
get_config_from_opts (FlatpakDir *dir, const char *remote_name, gboolean *changed)
{
  OstreeRepo *repo;
  GKeyFile *config;
  g_autofree char *group = g_strdup_printf ("remote \"%s\"", remote_name);

  repo = flatpak_dir_get_repo (dir);
  if (repo == NULL)
    config = g_key_file_new ();
  else
    config = ostree_repo_copy_config (repo);

  if (opt_no_gpg_verify)
    {
      g_key_file_set_boolean (config, group, "gpg-verify", FALSE);
      g_key_file_set_boolean (config, group, "gpg-verify-summary", FALSE);
      *changed = TRUE;
    }

  if (opt_do_gpg_verify)
    {
      g_key_file_set_boolean (config, group, "gpg-verify", TRUE);
      g_key_file_set_boolean (config, group, "gpg-verify-summary", TRUE);
      *changed = TRUE;
    }

  if (opt_url)
    {
      if (g_str_has_prefix (opt_url, "metalink="))
        g_key_file_set_string (config, group, "metalink", opt_url + strlen ("metalink="));
      else
        g_key_file_set_string (config, group, "url", opt_url);
      *changed = TRUE;
    }

  if (opt_collection_id)
    {
      g_key_file_set_string (config, group, "collection-id", opt_collection_id);
      g_key_file_set_boolean (config, group, "gpg-verify-summary", FALSE);
      *changed = TRUE;
    }

  if (opt_title)
    {
      g_key_file_set_string (config, group, "xa.title", opt_title);
      g_key_file_set_boolean (config, group, "xa.title-is-set", TRUE);
      *changed = TRUE;
    }

  if (opt_comment)
    {
      g_key_file_set_string (config, group, "xa.comment", opt_comment);
      g_key_file_set_boolean (config, group, "xa.comment-is-set", TRUE);
      *changed = TRUE;
    }

  if (opt_description)
    {
      g_key_file_set_string (config, group, "xa.description", opt_description);
      g_key_file_set_boolean (config, group, "xa.description-is-set", TRUE);
      *changed = TRUE;
    }

  if (opt_homepage)
    {
      g_key_file_set_string (config, group, "xa.homepage", opt_homepage);
      g_key_file_set_boolean (config, group, "xa.homepage-is-set", TRUE);
      *changed = TRUE;
    }

  if (opt_icon)
    {
      g_key_file_set_string (config, group, "xa.icon", opt_icon);
      g_key_file_set_boolean (config, group, "xa.icon-is-set", TRUE);
      *changed = TRUE;
    }

  if (opt_default_branch)
    {
      g_key_file_set_string (config, group, "xa.default-branch", opt_default_branch);
      g_key_file_set_boolean (config, group, "xa.default-branch-is-set", TRUE);
      *changed = TRUE;
    }

  if (opt_no_enumerate)
    {
      g_key_file_set_boolean (config, group, "xa.noenumerate", TRUE);
      *changed = TRUE;
    }

  if (opt_do_enumerate)
    {
      g_key_file_set_boolean (config, group, "xa.noenumerate", FALSE);
      *changed = TRUE;
    }

  if (opt_no_deps)
    {
      g_key_file_set_boolean (config, group, "xa.nodeps", TRUE);
//.........这里部分代码省略.........
开发者ID:flatpak,项目名称:flatpak,代码行数:101,代码来源:flatpak-builtins-remote-add.c

示例7: on_account_handle_remove

static gboolean
on_account_handle_remove (GoaAccount            *account,
                          GDBusMethodInvocation *invocation,
                          gpointer               user_data)
{
  GoaDaemon *daemon = GOA_DAEMON (user_data);
  GKeyFile *key_file;
  gchar *path;
  gchar *group;
  gchar *data;
  gsize length;
  GError *error;

  path = NULL;
  group = NULL;
  key_file = NULL;
  data = NULL;

  /* update key-file - right now we only support removing the account
   * if the entry is in ~/.config/goa-1.0/accounts.conf
   */

  key_file = g_key_file_new ();
  path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());

  error = NULL;
  if (!g_key_file_load_from_file (key_file,
                                  path,
                                  G_KEY_FILE_KEEP_COMMENTS,
                                  &error))
    {
      g_dbus_method_invocation_return_gerror (invocation, error);
      g_error_free (error);
      goto out;
    }

  group = g_strdup_printf ("Account %s", goa_account_get_id (account));

  error = NULL;
  if (!g_key_file_remove_group (key_file, group, &error))
    {
      g_dbus_method_invocation_return_gerror (invocation, error);
      g_error_free (error);
      goto out;
    }

  error = NULL;
  data = g_key_file_to_data (key_file,
                             &length,
                             &error);
  if (data == NULL)
    {
      g_prefix_error (&error, "Error generating key-value-file: ");
      g_dbus_method_invocation_return_gerror (invocation, error);
      goto out;
    }

  error = NULL;
  if (!g_file_set_contents (path,
                            data,
                            length,
                            &error))
    {
      g_prefix_error (&error, "Error writing key-value-file %s: ", path);
      g_dbus_method_invocation_return_gerror (invocation, error);
      goto out;
    }

  goa_daemon_reload_configuration (daemon);

  goa_account_complete_remove (account, invocation);

 out:
  g_free (data);
  if (key_file != NULL)
    g_key_file_free (key_file);
  g_free (group);
  g_free (path);
  return TRUE; /* invocation was handled */
}
开发者ID:wvengen,项目名称:gnome-online-accounts,代码行数:80,代码来源:goadaemon.c

示例8: main

/**
 * main:
 **/
int
main (int argc, char *argv[])
{
	FuSignPrivate *priv = NULL;
	GOptionContext *context;
	GMainLoop *loop = NULL;
	gboolean ret;
	gboolean one_shot = FALSE;
	guint retval = 1;
	_cleanup_error_free_ GError *error = NULL;
	_cleanup_free_ gchar *config_file = NULL;
	_cleanup_free_ gchar *destination = NULL;
	_cleanup_free_ gchar *key_id = NULL;
	_cleanup_free_ gchar *source = NULL;
	_cleanup_keyfile_unref_ GKeyFile *config = NULL;
	const GOptionEntry options[] = {
		{ "one-shot", '\0', 0, G_OPTION_ARG_NONE, &one_shot,
		  /* TRANSLATORS: exit after we've started up, used for user profiling */
		  _("Exit after signing queue"), NULL },
		{ "source", 's', 0, G_OPTION_ARG_FILENAME, &source,
		  /* TRANSLATORS: input location to watch  */
		  _("Source path for files"), NULL },
		{ "destination", 'd', 0, G_OPTION_ARG_FILENAME, &destination,
		  /* TRANSLATORS: output location to put files  */
		  _("Destination path for files"), NULL },
		{ "key-id", 'd', 0, G_OPTION_ARG_STRING, &key_id,
		  /* TRANSLATORS: output location to put files  */
		  _("GPG key used to sign the firmware"), NULL },
		{ NULL}
	};

	setlocale (LC_ALL, "");

	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	/* TRANSLATORS: program name */
	g_set_application_name (_("fwsignd"));
	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, options, NULL);
	g_option_context_add_group (context, fu_debug_get_option_group ());
	/* TRANSLATORS: program summary */
	g_option_context_set_summary (context, _("Firmware signing server"));
	ret = g_option_context_parse (context, &argc, &argv, &error);
	if (!ret) {
		g_print ("failed to parse command line arguments: %s\n",
			  error->message);
		retval = EXIT_FAILURE;
		goto out;
	}

	/* fall back to keyfile */
	config = g_key_file_new ();
	config_file = g_build_filename (SYSCONFDIR, "fwsignd.conf", NULL);
	g_debug ("Loading fallback values from %s", config_file);
	if (!g_key_file_load_from_file (config, config_file,
					G_KEY_FILE_NONE, &error)) {
		g_print ("failed to load config file %s: %s\n",
			  config_file, error->message);
		retval = EXIT_FAILURE;
		goto out;
	}
	if (source == NULL)
		source = g_key_file_get_string (config, "fwupd", "SourceDirectory", NULL);
	if (destination == NULL)
		destination = g_key_file_get_string (config, "fwupd", "DestinationDirectory", NULL);
	if (key_id == NULL)
		key_id = g_key_file_get_string (config, "fwupd", "KeyID", NULL);
	if (source == NULL || destination == NULL) {
		g_print ("source and destination required\n");
		retval = EXIT_FAILURE;
		goto out;
	}
	priv = g_new0 (FuSignPrivate, 1);
	priv->source = g_strdup (source);
	priv->destination = g_strdup (destination);
	priv->key_id = g_strdup (key_id);
	priv->keyring = fu_keyring_new ();
	priv->pending_files = g_ptr_array_new_with_free_func (g_free);
	priv->set_owner = g_key_file_get_boolean (config, "fwupd", "SetDestinationOwner", NULL);
	if (priv->key_id != NULL &&
	    !fu_keyring_set_signing_key (priv->keyring, priv->key_id, &error)) {
		g_print ("valid GPG key required: %s\n", error->message);
		retval = EXIT_FAILURE;
		goto out;
	}

	/* process */
	g_debug ("clearing queue");
	if (!fu_sign_coldplug (priv, &error)) {
		g_print ("failed to clear queue: %s\n", error->message);
		retval = EXIT_FAILURE;
		goto out;
	}
	if (!one_shot) {
		_cleanup_object_unref_ GFileMonitor *monitor = NULL;
//.........这里部分代码省略.........
开发者ID:phomes,项目名称:fwupd,代码行数:101,代码来源:fu-sign.c

示例9: on_manager_handle_add_account

static gboolean
on_manager_handle_add_account (GoaManager             *manager,
                               GDBusMethodInvocation  *invocation,
                               const gchar            *provider,
                               const gchar            *identity,
                               const gchar            *presentation_identity,
                               GVariant               *details,
                               gpointer                user_data)
{
  GoaDaemon *daemon = GOA_DAEMON (user_data);
  GKeyFile *key_file;
  GError *error;
  gchar *path;
  gchar *id;
  gchar *group;
  gchar *data;
  gsize length;
  gchar *object_path;
  GVariantIter iter;
  const gchar *key;
  const gchar *value;

  /* TODO: could check for @type */

  key_file = NULL;
  path = NULL;
  id = NULL;
  group = NULL;
  data = NULL;
  object_path = NULL;

  key_file = g_key_file_new ();
  path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());
  error = NULL;
  if (!g_file_get_contents (path,
                            &data,
                            &length,
                            &error))
    {
      if (error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT)
        {
          g_error_free (error);
        }
      else
        {
          g_prefix_error (&error, "Error loading file %s: ", path);
          g_dbus_method_invocation_return_gerror (invocation, error);
          goto out;
        }
    }
  else
    {
      if (length > 0)
        {
          error = NULL;
          if (!g_key_file_load_from_data (key_file, data, length, G_KEY_FILE_KEEP_COMMENTS, &error))
            {
              g_prefix_error (&error, "Error parsing key-value-file %s: ", path);
              g_dbus_method_invocation_return_gerror (invocation, error);
              goto out;
            }
        }
    }

  id = generate_new_id (daemon);
  group = g_strdup_printf ("Account %s", id);
  g_key_file_set_string (key_file, group, "Provider", provider);
  g_key_file_set_string (key_file, group, "Identity", identity);
  g_key_file_set_string (key_file, group, "PresentationIdentity", presentation_identity);

  g_variant_iter_init (&iter, details);
  while (g_variant_iter_next (&iter, "{&s&s}", &key, &value))
    {
      g_key_file_set_string (key_file, group, key, value);
    }

  g_free (data);
  error = NULL;
  data = g_key_file_to_data (key_file,
                             &length,
                             &error);
  if (data == NULL)
    {
      g_prefix_error (&error, "Error generating key-value-file: ");
      g_dbus_method_invocation_return_gerror (invocation, error);
      goto out;
    }

  error = NULL;
  if (!g_file_set_contents (path,
                            data,
                            length,
                            &error))
    {
      g_prefix_error (&error, "Error writing key-value-file %s: ", path);
      g_dbus_method_invocation_return_gerror (invocation, error);
      goto out;
    }

  goa_daemon_reload_configuration (daemon);
//.........这里部分代码省略.........
开发者ID:wvengen,项目名称:gnome-online-accounts,代码行数:101,代码来源:goadaemon.c

示例10: reload_database

static gboolean
reload_database (NMSessionMonitor *self, GError **error)
{
	struct stat statbuf;
	char **groups = NULL;
	gsize len = 0, i;
	Session *s;

	free_database (self);

	errno = 0;
	if (stat (CKDB_PATH, &statbuf) != 0) {
		g_set_error (error,
		             NM_SESSION_MONITOR_ERROR,
		             errno == ENOENT ? NM_SESSION_MONITOR_ERROR_NO_DATABASE : NM_SESSION_MONITOR_ERROR_IO_ERROR,
		             "Error statting file " CKDB_PATH ": %s",
		             strerror (errno));
		goto error;
	}
	self->database_mtime = statbuf.st_mtime;

	self->database = g_key_file_new ();
	if (!g_key_file_load_from_file (self->database, CKDB_PATH, G_KEY_FILE_NONE, error))
		goto error;

	groups = g_key_file_get_groups (self->database, &len);
	if (!groups) {
		g_set_error_literal (error,
		                     NM_SESSION_MONITOR_ERROR,
		                     NM_SESSION_MONITOR_ERROR_IO_ERROR,
		                     "Could not load groups from " CKDB_PATH "");
		goto error;
	}

	for (i = 0; i < len; i++) {
		Session *found;

		if (!g_str_has_prefix (groups[i], "Session "))
			continue;

		s = session_new (self->database, groups[i], error);
		if (!s)
			goto error;

		found = g_hash_table_lookup (self->sessions_by_user, (gpointer) s->user);
		if (found) {
			session_merge (s, found);
			session_free (s);
		} else {
			/* Entirely new user */
			g_hash_table_insert (self->sessions_by_user, (gpointer) s->user, s);
			g_hash_table_insert (self->sessions_by_uid, GUINT_TO_POINTER (s->uid), s);
		}
	}

	g_strfreev (groups);
	return TRUE;

error:
	if (groups)
		g_strfreev (groups);
	free_database (self);
	return FALSE;
}
开发者ID:alfmatos,项目名称:NetworkManager,代码行数:64,代码来源:nm-session-monitor.c

示例11: main

int main (int argc, char *argv[])
{
    GCContext    gc_context;
    GMainLoop   *mainLoop;
    GKeyFile    *keyFile;
    GThread     *displayThread;
    GThread     *inputControllerThread;
    GThread     *x11EventThread;
    int          i;

    
    GCConfig config = {
        .movie_path          = DEFAULT_MOVIE_PATH,
        .mask_path           = DEFAULT_MASK_PATH,
        .controller_path     = DEFAULT_CONTROLLER_PATH,
        .seconds_per_frame   = DEFAULT_SECONDS_PER_FRAME,
        .easing_factor       = DEFAULT_EASING_FACTOR,
        .frames_per_tick     = 0,
        .diameter_controller = 0,
        .diameter_rim        = 0,
        .ctr                 = 0,
        .fpr                 = 0,
        .number_of_frames    = 0,
        .fullscreen          = TRUE,
        .timeZone            = NULL,
    };

    Movie movie = {
        .planes             = NULL,
        .frame_offset       = 0,
        .fd_movie           = -1,
        .frame              = { .pitches = { FRAME_PITCH, 0, 0 } },
        .fd_mask            = -1,
        .mask               = { .pitches = { MASK_PITCH, 0, 0 } },
        .pre_load_surface   = VDP_INVALID_HANDLE,
        .play_direction     = DIRECTION_FORWARD,
        .ticks              = 0,
        .new_frame          = FALSE,
        .ease_to            = TRUE,
    };

    keyFile = g_key_file_new();
    if (argc > 1 && g_key_file_load_from_file(keyFile, argv[1], G_KEY_FILE_NONE, NULL)) {
        if (g_key_file_has_group(keyFile, "MAIN")) {
            if (g_key_file_has_key(keyFile, "MAIN", "utc_offset", NULL))
                config.timeZone = g_time_zone_new(g_key_file_get_string(keyFile, "MAIN", "utc_offset", NULL));
            if (g_key_file_has_key(keyFile, "MAIN", "ease_to_time", NULL))
                movie.ease_to = g_key_file_get_boolean(keyFile, "MAIN", "ease_to_time", NULL);
        }
 
        if (g_key_file_has_group(keyFile, "MOVIE")) {
           if (g_key_file_has_key(keyFile, "MOVIE", "file", NULL))
              config.movie_path = g_key_file_get_string(keyFile, "MOVIE", "file", NULL);
           if (g_key_file_has_key(keyFile, "MOVIE", "mask", NULL))
              config.mask_path = g_key_file_get_string(keyFile, "MOVIE", "mask", NULL);
           if (g_key_file_has_key(keyFile, "MOVIE", "seconds_per_frame", NULL))
              config.seconds_per_frame = (float)g_key_file_get_double(keyFile, "MOVIE", "seconds_per_frame", NULL);
           if (g_key_file_has_key(keyFile, "MOVIE", "easing_factor", NULL))
              config.easing_factor = (float)g_key_file_get_integer(keyFile, "MOVIE", "easing_factor", NULL);
        }
        
        if (g_key_file_has_group(keyFile, "CONTROLLER")) {
           if (g_key_file_has_key(keyFile, "CONTROLLER", "path", NULL))
              config.controller_path = g_key_file_get_string(keyFile, "CONTROLLER", "path", NULL);

           if (g_key_file_has_key(keyFile, "CONTROLLER", "diameter_controller", NULL))
              config.diameter_controller = (float)g_key_file_get_double(keyFile, "CONTROLLER", "diameter_controller", NULL);
           if (g_key_file_has_key(keyFile, "CONTROLLER", "diameter_rim", NULL))
              config.diameter_rim = (float)g_key_file_get_double(keyFile, "CONTROLLER", "diameter_rim", NULL);
           if (g_key_file_has_key(keyFile, "CONTROLLER", "ctr", NULL))
              config.ctr = (float)g_key_file_get_double(keyFile, "CONTROLLER", "ctr", NULL);
           if (g_key_file_has_key(keyFile, "CONTROLLER", "fpr", NULL))
              config.fpr = (float)g_key_file_get_double(keyFile, "CONTROLLER", "fpr", NULL);
           if (g_key_file_has_key(keyFile, "CONTROLLER", "frames_per_tick", NULL))
              config.frames_per_tick = (float)g_key_file_get_double(keyFile, "CONTROLLER", "frames_per_tick", NULL);
        }

        if (g_key_file_has_group(keyFile, "SCREEN")) {
           if (g_key_file_has_key(keyFile, "SCREEN", "fullscreen", NULL))
              config.fullscreen = g_key_file_get_boolean(keyFile, "SCREEN", "fullscreen", NULL);
        }
        g_key_file_free(keyFile);
    }

    if (!config.timeZone)
        config.timeZone = g_time_zone_new_local();

    if (!config.frames_per_tick && 
        !(config.frames_per_tick = frames_per_tick(config.diameter_controller,
                                                   config.diameter_rim,
                                                   config.ctr,
                                                   config.fpr)))
    {
        g_warning("No valid tick settings, using default frames per tick: %f", DEFAULT_FRAMES_PER_TICK);
        config.frames_per_tick = DEFAULT_FRAMES_PER_TICK;
    }

    config.movie_size = get_file_size(config.movie_path);
    config.number_of_frames = config.movie_size / FRAME_SIZE;
    
//.........这里部分代码省略.........
开发者ID:simbits,项目名称:ClaudeGlass,代码行数:101,代码来源:main.c

示例12: nemo_action_new

NemoAction *
nemo_action_new (const gchar *name, 
                 const gchar *path)
{
    GKeyFile *key_file = g_key_file_new();

    g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, NULL);

    if (!g_key_file_has_group (key_file, ACTION_FILE_GROUP)) {
        g_key_file_free (key_file);
        return NULL;
    }

    if (g_key_file_has_key (key_file, ACTION_FILE_GROUP, KEY_ACTIVE, NULL)) {
        if (!g_key_file_get_boolean (key_file, ACTION_FILE_GROUP, KEY_ACTIVE, NULL)) {
            g_key_file_free (key_file);
            return NULL;
        }
    }

    gchar *orig_label = g_key_file_get_locale_string (key_file,
                                                      ACTION_FILE_GROUP,
                                                      KEY_NAME,
                                                      NULL,
                                                      NULL);

    gchar *exec_raw = g_key_file_get_string (key_file,
                                             ACTION_FILE_GROUP,
                                             KEY_EXEC,
                                             NULL);

    gchar **ext = g_key_file_get_string_list (key_file,
                                              ACTION_FILE_GROUP,
                                              KEY_EXTENSIONS,
                                              NULL,
                                              NULL);

    gchar **mimes = g_key_file_get_string_list (key_file,
                                                ACTION_FILE_GROUP,
                                                KEY_MIME_TYPES,
                                                NULL,
                                                NULL);

    gchar **deps  = g_key_file_get_string_list (key_file,
                                                ACTION_FILE_GROUP,
                                                KEY_DEPENDENCIES,
                                                NULL,
                                                NULL);

    gchar *selection_string = g_key_file_get_string (key_file,
                                                     ACTION_FILE_GROUP,
                                                     KEY_SELECTION,
                                                     NULL);

    gboolean finish = TRUE;

    if (deps != NULL) {
        gint i = 0;
        for (i = 0; i < g_strv_length (deps); i++) {
            if (g_path_is_absolute (deps[i])) {
                GFile *f = g_file_new_for_path (deps[i]);
                if (!g_file_query_exists (f, NULL)) {
                    finish = FALSE;
                    DEBUG ("Missing action dependency: %s", deps[i]);
                }
                g_object_unref (f);
            } else {
                gchar *p = g_find_program_in_path (deps[i]);
                if (p == NULL) {
                    finish = FALSE;
                    DEBUG ("Missing action dependency: %s", deps[i]);
                    g_free (p);
                    break;
                }
                g_free (p);
            }
        }
    }

    if (orig_label == NULL || exec_raw == NULL || (ext == NULL && mimes == NULL) || selection_string == NULL) {
        g_printerr ("An action definition requires, at minimum, "
                    "a Label field, an Exec field, a Selection field, and an either an Extensions or Mimetypes field.\n"
                    "Check the %s file for missing fields.\n", path);
        finish = FALSE;
    }

    g_free (orig_label);
    g_free (exec_raw);
    g_free (selection_string);
    g_strfreev (ext);
    g_strfreev (mimes);
    g_strfreev (deps);
    g_key_file_free (key_file);

    return finish ? g_object_new (NEMO_TYPE_ACTION,
                                  "name", name,
                                  "key-file-path", path,
                                  NULL): NULL;
}
开发者ID:IanLee1521,项目名称:nemo,代码行数:99,代码来源:nemo-action.c

示例13: gs_plugin_app_install

/**
 * gs_plugin_app_install:
 */
gboolean
gs_plugin_app_install (GsPlugin *plugin, GsApp *app,
		       GCancellable *cancellable, GError **error)
{
	AsIcon *icon;
	gboolean ret = TRUE;
	gsize kf_length;
	g_autoptr(GError) error_local = NULL;
	g_autofree gchar *app_desktop = NULL;
	g_autofree gchar *epi_desktop = NULL;
	g_autofree gchar *epi_dir = NULL;
	g_autofree gchar *epi_icon = NULL;
	g_autofree gchar *exec = NULL;
	g_autofree gchar *hash = NULL;
	g_autofree gchar *id_nonfull = NULL;
	g_autofree gchar *kf_data = NULL;
	g_autofree gchar *wmclass = NULL;
	g_autoptr(GKeyFile) kf = NULL;
	g_autoptr(GFile) symlink_desktop = NULL;
	g_autoptr(GFile) symlink_icon = NULL;

	/* only process web apps */
	if (gs_app_get_id_kind (app) != AS_ID_KIND_WEB_APP)
		return TRUE;

	/* create the correct directory */
	id_nonfull = _gs_app_get_id_nonfull (app);
	hash = g_compute_checksum_for_string (G_CHECKSUM_SHA1, gs_app_get_name (app), -1);
	epi_dir = g_strdup_printf ("%s/epiphany/app-%s-%s",
				   g_get_user_config_dir (),
				   id_nonfull,
				   hash);
	g_mkdir_with_parents (epi_dir, 0755);

	/* symlink icon */
	epi_icon = g_build_filename (epi_dir, "app-icon.png", NULL);
	symlink_icon = g_file_new_for_path (epi_icon);
	icon = gs_app_get_icon (app);
	ret = g_file_make_symbolic_link (symlink_icon,
					 as_icon_get_filename (icon),
					 NULL,
					 &error_local);
	if (!ret) {
		if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
			g_debug ("ignoring icon symlink failure: %s",
				 error_local->message);
		} else {
			g_set_error (error,
				     GS_PLUGIN_ERROR,
				     GS_PLUGIN_ERROR_FAILED,
				     "Can't symlink icon: %s",
				     error_local->message);
			return FALSE;
		}
	}

	/* add desktop file */
	wmclass = g_strdup_printf ("%s-%s", id_nonfull, hash);
	kf = g_key_file_new ();
	g_key_file_set_string (kf,
			       G_KEY_FILE_DESKTOP_GROUP,
			       G_KEY_FILE_DESKTOP_KEY_NAME,
			       gs_app_get_name (app));
	g_key_file_set_string (kf,
			       G_KEY_FILE_DESKTOP_GROUP,
			       G_KEY_FILE_DESKTOP_KEY_COMMENT,
			       gs_app_get_summary (app));
	exec = g_strdup_printf ("epiphany --application-mode --profile=\"%s\" %s",
				epi_dir,
				gs_app_get_url (app, AS_URL_KIND_HOMEPAGE));
	g_key_file_set_string (kf,
			       G_KEY_FILE_DESKTOP_GROUP,
			       G_KEY_FILE_DESKTOP_KEY_EXEC,
			       exec);
	g_key_file_set_boolean (kf,
				G_KEY_FILE_DESKTOP_GROUP,
				G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY,
				TRUE);
	g_key_file_set_boolean (kf,
				G_KEY_FILE_DESKTOP_GROUP,
				G_KEY_FILE_DESKTOP_KEY_TERMINAL,
				FALSE);
	g_key_file_set_boolean (kf,
				G_KEY_FILE_DESKTOP_GROUP,
				G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY,
				FALSE);
	g_key_file_set_string (kf,
			       G_KEY_FILE_DESKTOP_GROUP,
			       G_KEY_FILE_DESKTOP_KEY_TYPE,
			       G_KEY_FILE_DESKTOP_TYPE_APPLICATION);
	g_key_file_set_string (kf,
			       G_KEY_FILE_DESKTOP_GROUP,
			       G_KEY_FILE_DESKTOP_KEY_ICON,
			       epi_icon);
	g_key_file_set_string (kf,
			       G_KEY_FILE_DESKTOP_GROUP,
			       G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS,
//.........这里部分代码省略.........
开发者ID:JamesLinus,项目名称:gnome-software,代码行数:101,代码来源:gs-plugin-epiphany.c

示例14: get_common_rdf_types

static gboolean
get_common_rdf_types (void)
{
	const gchar *extractors_dir, *name;
	GList *files = NULL, *l;
	GError *error = NULL;
	GDir *dir;

	if (common_rdf_types) {
		return TRUE;
	}

	extractors_dir = g_getenv ("TRACKER_EXTRACTOR_RULES_DIR");
	if (G_LIKELY (extractors_dir == NULL)) {
		extractors_dir = TRACKER_EXTRACTOR_RULES_DIR;
	}

	dir = g_dir_open (extractors_dir, 0, &error);

	if (!dir) {
		g_error ("Error opening extractor rules directory: %s", error->message);
		g_error_free (error);
		return FALSE;
	}

	common_rdf_types = g_hash_table_new_full (g_str_hash,
	                                          g_str_equal,
	                                          g_free,
	                                          NULL);

	while ((name = g_dir_read_name (dir)) != NULL) {
		files = g_list_insert_sorted (files, (gpointer) name, (GCompareFunc) g_strcmp0);
	}

	for (l = files; l; l = l->next) {
		GKeyFile *key_file;
		const gchar *name;
		gchar *path;

		name = l->data;

		if (!g_str_has_suffix (l->data, ".rule")) {
			continue;
		}

		path = g_build_filename (extractors_dir, name, NULL);
		key_file = g_key_file_new ();

		g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &error);

		if (G_UNLIKELY (error)) {
			g_clear_error (&error);
		} else {
			gchar **rdf_types;
			gsize n_rdf_types;

			rdf_types = g_key_file_get_string_list (key_file, "ExtractorRule", "FallbackRdfTypes", &n_rdf_types, &error);

			if (G_UNLIKELY (error)) {
				g_clear_error (&error);
			} else if (rdf_types != NULL) {
				gint i;

				for (i = 0; i < n_rdf_types; i++) {
					const gchar *rdf_type = rdf_types[i];

					g_hash_table_insert (common_rdf_types, g_strdup (rdf_type), GINT_TO_POINTER(TRUE));
				}
			}

			g_strfreev (rdf_types);
		}

		g_key_file_free (key_file);
		g_free (path);
	}

	g_list_free (files);
	g_dir_close (dir);

	/* Make sure some additional RDF types are shown which are not
	 * fall backs.
	 */
	g_hash_table_insert (common_rdf_types, g_strdup ("rdfs:Resource"), GINT_TO_POINTER(TRUE));
	g_hash_table_insert (common_rdf_types, g_strdup ("rdfs:Class"), GINT_TO_POINTER(TRUE));
	g_hash_table_insert (common_rdf_types, g_strdup ("nfo:FileDataObject"), GINT_TO_POINTER(TRUE));
	g_hash_table_insert (common_rdf_types, g_strdup ("nfo:Folder"), GINT_TO_POINTER(TRUE));
	g_hash_table_insert (common_rdf_types, g_strdup ("nfo:Executable"), GINT_TO_POINTER(TRUE));
	g_hash_table_insert (common_rdf_types, g_strdup ("nco:Contact"), GINT_TO_POINTER(TRUE));
	g_hash_table_insert (common_rdf_types, g_strdup ("nao:Tag"), GINT_TO_POINTER(TRUE));
	g_hash_table_insert (common_rdf_types, g_strdup ("tracker:Volume"), GINT_TO_POINTER(TRUE));

	return TRUE;
}
开发者ID:mlehtima,项目名称:tracker,代码行数:94,代码来源:tracker-status.c

示例15: VMTools_ConfigLogging

void
VMTools_ConfigLogging(const gchar *defaultDomain,
                      GKeyFile *cfg,
                      gboolean force,
                      gboolean reset)
{
   gboolean allocDict = (cfg == NULL);
   gchar **list;
   gchar **curr;
   GPtrArray *oldDomains = NULL;
   LogHandler *oldDefault = NULL;

   g_return_if_fail(defaultDomain != NULL);

   if (allocDict) {
      cfg = g_key_file_new();
   }

   /*
    * If not resetting the logging system, keep the old domains around. After
    * we're done loading the new configuration, we'll go through the old domains
    * and restore any data that needs restoring, and clean up anything else.
    */
   VMToolsResetLogging(reset);
   if (!reset) {
      oldDefault = gDefaultData;
      oldDomains = gDomains;
      gDomains = NULL;
      gDefaultData = NULL;
   }

   gLogDomain = g_strdup(defaultDomain);
   gErrorData = VMToolsGetLogHandler(SAFE_HANDLER,
                                     gLogDomain,
                                     G_LOG_LEVEL_MASK,
                                     cfg);

   /*
    * Configure the default domain first. See function documentation for
    * VMToolsConfigLogDomain() for the reason.
    */
   VMToolsConfigLogDomain(gLogDomain, cfg, oldDefault, oldDomains);

   list = g_key_file_get_keys(cfg, LOGGING_GROUP, NULL, NULL);

   for (curr = list; curr != NULL && *curr != NULL; curr++) {
      gchar *domain = *curr;

      /* Check whether it's a domain "declaration". */
      if (!g_str_has_suffix(domain, ".level")) {
         continue;
      }

      /* Trims ".level" from the key to get the domain name. */
      domain[strlen(domain) - 6] = '\0';

      /* Skip the default domain. */
      if (strcmp(domain, gLogDomain) == 0) {
         continue;
      }

      VMToolsConfigLogDomain(domain, cfg, oldDefault, oldDomains);
   }

   g_strfreev(list);

   gLogEnabled = g_key_file_get_boolean(cfg, LOGGING_GROUP, "log", NULL);
   if (g_key_file_has_key(cfg, LOGGING_GROUP, "enableCoreDump", NULL)) {
      gEnableCoreDump = g_key_file_get_boolean(cfg, LOGGING_GROUP,
                                               "enableCoreDump", NULL);
   }

   /* If needed, restore the old configuration. */
   if (!reset) {
      if (oldDomains != NULL) {
         g_ptr_array_free(oldDomains, TRUE);
      }
   }

   /*
    * If core dumps are enabled (default: TRUE), then set up the exception
    * filter on Win32. On POSIX systems, try to modify the resource limit
    * to allow core dumps, but don't complain if it fails. Core dumps may
    * still fail, e.g., if the current directory is not writable by the
    * user running the process.
    *
    * On POSIX systems, if the process is itself requesting a core dump (e.g.,
    * by calling Panic() or g_error()), the core dump routine will try to find
    * a location where it can successfully create the core file. Applications
    * can try to set up core dump filters (e.g., a signal handler for SIGSEGV)
    * that can then call any of the core dumping functions handled by this
    * library.
    *
    * On POSIX systems, the maximum size of a core dump can be controlled by
    * the "maxCoreSize" config option, where "0" means "no limit". By default,
    * it's set to 5MB.
    */
   if (gEnableCoreDump) {
      GError *err = NULL;
#if defined(_WIN32)
//.........这里部分代码省略.........
开发者ID:nf-mlo,项目名称:open-vm-tools,代码行数:101,代码来源:vmtoolsLog.c


注:本文中的g_key_file_new函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。