This repository was archived by the owner on Apr 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconf.c
More file actions
58 lines (45 loc) · 1.14 KB
/
conf.c
File metadata and controls
58 lines (45 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>
#include <gtk/gtk.h>
#include "conf.h"
GKeyFile *conf_open(const gchar *file)
{
GKeyFile *kfile = g_key_file_new();
g_key_file_load_from_file(kfile, file, G_KEY_FILE_NONE, NULL);
return kfile;
}
int conf_get_int(GKeyFile *kfile, const gchar *key)
{
return g_key_file_get_integer(kfile, "conf", key, NULL);
}
void conf_set_int(GKeyFile *kfile, const gchar *key, gint value)
{
g_key_file_set_integer(kfile, "conf", key, value);
}
char *conf_get_string(GKeyFile *kfile, const gchar *key)
{
return g_key_file_get_value(kfile, "conf", key, NULL);
}
void conf_set_string(GKeyFile *kfile, const gchar *key, const gchar *value)
{
if (value != NULL)
g_key_file_set_value(kfile, "conf", key, value);
}
gboolean conf_close(GKeyFile *kfile, const gchar *file)
{
gboolean ret = TRUE;
if (file != NULL)
ret = g_key_file_save_to_file(kfile, file, NULL);
g_key_file_free(kfile);
return ret;
}