Пример #1
0
gint config_setndouble (const gchar *key, const gdouble val, const guint idx) {
	config_mutex_lock ();
	cfg_setnfloat (tc, key, val, idx);
	config_mutex_unlock ();

	return 0;
}
Пример #2
0
gint config_setdouble (const gchar *key, const gdouble val) {
	config_mutex_lock ();
	cfg_setfloat (tc, key, val);
	config_mutex_unlock ();

	return 0;
}
Пример #3
0
gint config_setbool(const gchar *key, const gboolean val)
{
	config_mutex_lock ();
	cfg_setbool (tc, key, val);
	config_mutex_unlock ();

	return 0;
}
Пример #4
0
gint config_setstr (const gchar *key, const gchar *val)
{
	config_mutex_lock ();
	cfg_setstr (tc, key, val);
	config_mutex_unlock ();

	return 0;
}
Пример #5
0
gint config_setnint(const gchar *key, const gint val, const guint idx)
{
	config_mutex_lock ();
	cfg_setnint (tc, key, val, idx);
	config_mutex_unlock ();

	return 0;
}
Пример #6
0
gdouble config_getndouble (const gchar* key, const guint idx) {
	gdouble temp;

	config_mutex_lock ();
	temp = cfg_getnfloat (tc, key, idx);
	config_mutex_unlock ();

	return temp;
}
Пример #7
0
gdouble config_getdouble (const gchar* key) {
	gdouble temp;

	config_mutex_lock ();
	temp = cfg_getfloat (tc, key);
	config_mutex_unlock ();

	return temp;
}
Пример #8
0
gboolean config_getbool(const gchar *key)
{
	gboolean temp;

	config_mutex_lock ();
	temp = cfg_getbool (tc, key);
	config_mutex_unlock ();

	return temp;
}
Пример #9
0
gchar* config_getstr (const gchar *key)
{
	gchar *temp;

	config_mutex_lock ();
	temp = cfg_getstr (tc, key);
	config_mutex_unlock ();

	return temp;
}
Пример #10
0
glong config_getnint(const gchar *key, const guint idx)
{
	glong temp;

	config_mutex_lock ();
	temp = cfg_getnint (tc, key, idx);
	config_mutex_unlock ();

	return temp;
}
Пример #11
0
gint config_getint (const gchar *key)
{
	gint temp;

	config_mutex_lock ();
	temp = cfg_getint (tc, key);
	config_mutex_unlock ();

	return temp;
}
Пример #12
0
/* This will write out the current state of the config file to the disk.
 * It's use is generally discouraged, since config_free() will also write
 * out the configuration to disk. */
gint config_write (const gchar *config_file)
{
    DEBUG_FUNCTION ("config_write");
    DEBUG_ASSERT (config_file != NULL);

    gint ret = 0;
    FILE *fp;

    char *temp_config_file = g_strdup_printf ("%s.tmp", config_file);
    fp = fopen(temp_config_file, "w");

    if (fp != NULL)
    {
        config_mutex_lock ();
        cfg_print (tc, fp);
        config_mutex_unlock ();

        if (fsync (fileno(fp)))
        {
            // Error occurred during sync
            TILDA_PERROR ();
            DEBUG_ERROR ("Unable to sync file");

            g_printerr (_("Unable to sync the config file to disk\n"));
            ret = 2;
        }

        if (fclose (fp))
        {
            // An error occurred
            TILDA_PERROR ();
            DEBUG_ERROR ("Unable to close config file");

            g_printerr (_("Unable to close the config file\n"));
            ret = 3;
        }
        if (rename(temp_config_file, config_file)) {
            TILDA_PERROR ();
            DEBUG_ERROR ("Unable to rename temporary config file to final config file.");
        }
    }
    else
    {
        TILDA_PERROR ();
        DEBUG_ERROR ("Unable to write config file");

        g_printerr (_("Unable to write the config file to %s\n"), config_file);
        ret = 4;
    }

    return ret;
}
Пример #13
0
/* This will write out the current state of the config file to the disk.
 * It's use is generally discouraged, since config_free() will also write
 * out the configuration to disk. */
gint config_write (const gchar *config_file)
{
    DEBUG_FUNCTION ("config_write");
    DEBUG_ASSERT (config_file != NULL);

    gint ret = 0;
    FILE *fp;

    /* Check to see if writing is disabled. Leave early if it is. */
    if (config_writing_disabled)
        return 1;

    fp = fopen(config_file, "w");

    if (fp != NULL)
    {
        config_mutex_lock ();
        cfg_print (tc, fp);
        config_mutex_unlock ();

        if (fsync (fileno(fp)))
        {
            // Error occurred during sync
            TILDA_PERROR ();
            DEBUG_ERROR ("Unable to sync file");

            g_printerr (_("Unable to sync the config file to disk\n"));
            ret = 2;
        }

        if (fclose (fp))
        {
            // An error occurred
            TILDA_PERROR ();
            DEBUG_ERROR ("Unable to close config file");

            g_printerr (_("Unable to close the config file\n"));
            ret = 3;
        }
    }
    else
    {
        TILDA_PERROR ();
        DEBUG_ERROR ("Unable to write config file");

        g_printerr (_("Unable to write the config file to %s\n"), config_file);
        ret = 4;
    }

    return ret;
}