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.
2021-05-15 19:18:42 +02:00
|
|
|
#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))
|
|
|
|
{
|
2021-06-12 11:01:50 +02:00
|
|
|
if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
2021-05-15 19:18:42 +02:00
|
|
|
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 &&
|
2021-06-12 11:01:50 +02:00
|
|
|
g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
|
2021-05-15 19:18:42 +02:00
|
|
|
{
|
|
|
|
g_warning ("Error finding key in key file: %s\n", error->message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (value == NULL)
|
|
|
|
{
|
2021-06-12 11:01:50 +02:00
|
|
|
g_warning ("Error: %s.\n", error->message);
|
2021-05-15 19:18:42 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2021-06-12 11:01:50 +02:00
|
|
|
return 0;
|
2021-05-15 19:18:42 +02:00
|
|
|
}
|