コード例 #1
0
ファイル: options.c プロジェクト: dupgit/sauvegarde
/**
 * Reads from the configuration file "filename" and fills the options_t *
 * opt structure.
 * @param[in,out] opt : options_t * structure to store options read from
 *                the configuration file "filename"
 * @param filename : the filename of the configuration file to read from
 */
static void read_from_configuration_file(options_t *opt, gchar *filename)
{
    GKeyFile *keyfile = NULL;      /** Configuration file parser                          */
    GError *error = NULL;          /** Glib error handling                                */

    if (filename != NULL)
        {
            print_debug(_("Reading configuration from file %s\n"), filename);

            keyfile = g_key_file_new();

            if (g_key_file_load_from_file(keyfile, filename, G_KEY_FILE_KEEP_COMMENTS, &error))
                {
                    opt->configfile = manage_opt_configfile(opt->configfile, filename);

                    read_from_group_client(opt, keyfile, filename);
                    read_debug_mode_from_file(keyfile, filename);

                    opt->srv_conf = manage_opt_srv_conf(opt->srv_conf, keyfile, filename);
                }
            else if (error != NULL)
                {
                    print_error(__FILE__, __LINE__, _("Failed to open %s configuration file: %s\n"), filename, error->message);
                    free_error(error);
                }

            g_key_file_free(keyfile);
        }
}
コード例 #2
0
ファイル: options.c プロジェクト: cyrinux/sauvegarde
/**
 * Reads keys in keyfile if group GN_ALL is in that keyfile.
 * @param keyfile is the GKeyFile structure that is used by glib to read
 *        groups and keys from.
 * @param filename : the filename of the configuration file to read from
 */
static void read_from_group_all(GKeyFile *keyfile, gchar *filename)
{
    read_debug_mode_from_file(keyfile, filename);
}