This repository has been archived on 2021-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
modetw/src/conf.c

35 lines
861 B
C

#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include <glib/gprintf.h>
#include "conf.h"
int
conf_verify_key(const char *f, const char *key, char *value)
{
g_autoptr(GError) error = NULL;
g_autoptr(GKeyFile) key_file = g_key_file_new ();
if (!g_key_file_load_from_file (key_file, f, G_KEY_FILE_NONE, &error))
{
if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
g_warning ("Error loading key file: %s\n", error->message);
return 1;
}
value = g_key_file_get_string (key_file, "Global", key, &error);
if (value == NULL &&
g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
{
g_warning ("Error finding key in key file: %s\n", error->message);
return 1;
}
else if (value == NULL)
{
g_warning ("Error: %s.\n", error->message);
return 1;
}
return 0;
}