glib/glib/gkeyfile.h

196 lines
8.6 KiB
C
Raw Normal View History

/* gkeyfile.h - desktop entry file parser
*
* Copyright 2004 Red Hat, Inc.
*
* Ray Strode <halfline@hawaii.rr.com>
*
* GLib is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GLib; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __G_KEY_FILE_H__
#define __G_KEY_FILE_H__
#include <glib/gerror.h>
G_BEGIN_DECLS
typedef enum
{
G_KEY_FILE_ERROR_UNKNOWN_ENCODING,
G_KEY_FILE_ERROR_PARSE,
G_KEY_FILE_ERROR_NOT_FOUND,
G_KEY_FILE_ERROR_KEY_NOT_FOUND,
G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
G_KEY_FILE_ERROR_INVALID_VALUE
} GKeyFileError;
#define G_KEY_FILE_ERROR g_key_file_error_quark()
GQuark g_key_file_error_quark (void);
typedef struct _GKeyFile GKeyFile;
typedef enum
{
G_KEY_FILE_NONE = 0,
G_KEY_FILE_KEEP_COMMENTS = 1 << 0,
G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
} GKeyFileFlags;
GKeyFile *g_key_file_new (void);
void g_key_file_free (GKeyFile *key_file);
void g_key_file_set_list_separator (GKeyFile *key_file,
gchar separator);
Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold 2004-10-26 Ray Strode <rstrode@redhat.com> * glib/gkeyfile.c: Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold comments about groups (g_key_file_load_from_fd): return TRUE on success and FALSE on failure. Don't close fd's opened by other parent function. (g_key_file_load_from_file): run FILE_IS_REGULAR test before trying to open file, to save an fd from being leaked (would probably be better to use fstat()). Close fd when done with it. Return TRUE on success and FALSE on failure. (g_key_file_load_from_data): Return TRUE on success and FALSE on failure. (g_key_file_load_from_data_dirs): remove superfluous const modifier. Return TRUE on success and FALSE on failure. Stop trying to load files when one succeeds. (g_key_file_parse_key_value_pair): don't validate input for UTF-8 until users uses a getter that does validation. Don't leak copy of start_group_name. (g_key_file_to_data): serialize new comment field for groups. (g_key_file_get_keys): Remove convenience code to let NULL group mean start group. Get rid of unneeded NULL check before g_strdup. (g_key_file_get_groups): Reverse groups list before sending to user because it is maintained in backward order internally. (g_key_file_get_value), (g_key_file_set_value): add g_return checks at top of public functions. (g_key_file_get_string), (g_key_file_get_string_list): validate key value is UTF-8. (g_key_file_[sg]et_*comment): new functions for setting/getting comments (g_key_file_remove_comment): new function to remove comment block (g_key_file_remove_key_value_pair_node): new function to pull a key-value pair out of the list and free it. (g_key_file_remove_group_node): call g_key_file_remove_key_value_pair_node instead of freeing the list immediately to get better statistics for approximate_size. (g_key_file_remove_group): use lookup_group_node instead of lookup_group to prevent a g_list_find call. (g_key_file_add_key): report group also when unable to find key. (g_key_file_lookup_group_node): new function to make getting the group node from a group name easier. (g_key_file_lookup_group): use lookup_group_node under the hood. (g_key_file_lookup_key_value_pair_node): new function to make getting the key-value pair from a group and key name eaiser. (g_key_file_parse_comment_as_value): new function to add '#' to the beginning of every line. (g_key_file_parse_value_as_comment): new function that attempts to be the inverse of comment as value.
2004-10-26 12:35:58 +00:00
gboolean g_key_file_load_from_file (GKeyFile *key_file,
const gchar *file,
GKeyFileFlags flags,
GError **error);
Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold 2004-10-26 Ray Strode <rstrode@redhat.com> * glib/gkeyfile.c: Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold comments about groups (g_key_file_load_from_fd): return TRUE on success and FALSE on failure. Don't close fd's opened by other parent function. (g_key_file_load_from_file): run FILE_IS_REGULAR test before trying to open file, to save an fd from being leaked (would probably be better to use fstat()). Close fd when done with it. Return TRUE on success and FALSE on failure. (g_key_file_load_from_data): Return TRUE on success and FALSE on failure. (g_key_file_load_from_data_dirs): remove superfluous const modifier. Return TRUE on success and FALSE on failure. Stop trying to load files when one succeeds. (g_key_file_parse_key_value_pair): don't validate input for UTF-8 until users uses a getter that does validation. Don't leak copy of start_group_name. (g_key_file_to_data): serialize new comment field for groups. (g_key_file_get_keys): Remove convenience code to let NULL group mean start group. Get rid of unneeded NULL check before g_strdup. (g_key_file_get_groups): Reverse groups list before sending to user because it is maintained in backward order internally. (g_key_file_get_value), (g_key_file_set_value): add g_return checks at top of public functions. (g_key_file_get_string), (g_key_file_get_string_list): validate key value is UTF-8. (g_key_file_[sg]et_*comment): new functions for setting/getting comments (g_key_file_remove_comment): new function to remove comment block (g_key_file_remove_key_value_pair_node): new function to pull a key-value pair out of the list and free it. (g_key_file_remove_group_node): call g_key_file_remove_key_value_pair_node instead of freeing the list immediately to get better statistics for approximate_size. (g_key_file_remove_group): use lookup_group_node instead of lookup_group to prevent a g_list_find call. (g_key_file_add_key): report group also when unable to find key. (g_key_file_lookup_group_node): new function to make getting the group node from a group name easier. (g_key_file_lookup_group): use lookup_group_node under the hood. (g_key_file_lookup_key_value_pair_node): new function to make getting the key-value pair from a group and key name eaiser. (g_key_file_parse_comment_as_value): new function to add '#' to the beginning of every line. (g_key_file_parse_value_as_comment): new function that attempts to be the inverse of comment as value.
2004-10-26 12:35:58 +00:00
gboolean g_key_file_load_from_data (GKeyFile *key_file,
const gchar *data,
gsize length,
GKeyFileFlags flags,
GError **error);
Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold 2004-10-26 Ray Strode <rstrode@redhat.com> * glib/gkeyfile.c: Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold comments about groups (g_key_file_load_from_fd): return TRUE on success and FALSE on failure. Don't close fd's opened by other parent function. (g_key_file_load_from_file): run FILE_IS_REGULAR test before trying to open file, to save an fd from being leaked (would probably be better to use fstat()). Close fd when done with it. Return TRUE on success and FALSE on failure. (g_key_file_load_from_data): Return TRUE on success and FALSE on failure. (g_key_file_load_from_data_dirs): remove superfluous const modifier. Return TRUE on success and FALSE on failure. Stop trying to load files when one succeeds. (g_key_file_parse_key_value_pair): don't validate input for UTF-8 until users uses a getter that does validation. Don't leak copy of start_group_name. (g_key_file_to_data): serialize new comment field for groups. (g_key_file_get_keys): Remove convenience code to let NULL group mean start group. Get rid of unneeded NULL check before g_strdup. (g_key_file_get_groups): Reverse groups list before sending to user because it is maintained in backward order internally. (g_key_file_get_value), (g_key_file_set_value): add g_return checks at top of public functions. (g_key_file_get_string), (g_key_file_get_string_list): validate key value is UTF-8. (g_key_file_[sg]et_*comment): new functions for setting/getting comments (g_key_file_remove_comment): new function to remove comment block (g_key_file_remove_key_value_pair_node): new function to pull a key-value pair out of the list and free it. (g_key_file_remove_group_node): call g_key_file_remove_key_value_pair_node instead of freeing the list immediately to get better statistics for approximate_size. (g_key_file_remove_group): use lookup_group_node instead of lookup_group to prevent a g_list_find call. (g_key_file_add_key): report group also when unable to find key. (g_key_file_lookup_group_node): new function to make getting the group node from a group name easier. (g_key_file_lookup_group): use lookup_group_node under the hood. (g_key_file_lookup_key_value_pair_node): new function to make getting the key-value pair from a group and key name eaiser. (g_key_file_parse_comment_as_value): new function to add '#' to the beginning of every line. (g_key_file_parse_value_as_comment): new function that attempts to be the inverse of comment as value.
2004-10-26 12:35:58 +00:00
gboolean g_key_file_load_from_data_dirs (GKeyFile *key_file,
const gchar *file,
gchar **full_path,
GKeyFileFlags flags,
GError **error);
gchar *g_key_file_to_data (GKeyFile *key_file,
gsize *length,
GError **error) G_GNUC_MALLOC;
gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC;
gchar **g_key_file_get_groups (GKeyFile *key_file,
gsize *length) G_GNUC_MALLOC;
gchar **g_key_file_get_keys (GKeyFile *key_file,
const gchar *group_name,
gsize *length,
GError **error) G_GNUC_MALLOC;
gboolean g_key_file_has_group (GKeyFile *key_file,
const gchar *group_name);
gboolean g_key_file_has_key (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
GError **error);
gchar *g_key_file_get_value (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
GError **error) G_GNUC_MALLOC;
void g_key_file_set_value (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
const gchar *value);
gchar *g_key_file_get_string (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
GError **error) G_GNUC_MALLOC;
void g_key_file_set_string (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
const gchar *string);
gchar *g_key_file_get_locale_string (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
const gchar *locale,
GError **error) G_GNUC_MALLOC;
void g_key_file_set_locale_string (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
const gchar *locale,
const gchar *string);
gboolean g_key_file_get_boolean (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
GError **error);
void g_key_file_set_boolean (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
2004-10-26 16:10:52 +00:00
gboolean value);
gint g_key_file_get_integer (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
GError **error);
void g_key_file_set_integer (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
2004-10-26 16:10:52 +00:00
gint value);
gchar **g_key_file_get_string_list (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
gsize *length,
GError **error) G_GNUC_MALLOC;
void g_key_file_set_string_list (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
const gchar * const list[],
gsize length);
gchar **g_key_file_get_locale_string_list (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
const gchar *locale,
gsize *length,
GError **error) G_GNUC_MALLOC;
void g_key_file_set_locale_string_list (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
const gchar *locale,
const gchar * const list[],
gsize length);
gboolean *g_key_file_get_boolean_list (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
gsize *length,
GError **error) G_GNUC_MALLOC;
void g_key_file_set_boolean_list (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
gboolean list[],
gsize length);
gint *g_key_file_get_integer_list (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
gsize *length,
GError **error) G_GNUC_MALLOC;
void g_key_file_set_integer_list (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
gint list[],
gsize length);
Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold 2004-10-26 Ray Strode <rstrode@redhat.com> * glib/gkeyfile.c: Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold comments about groups (g_key_file_load_from_fd): return TRUE on success and FALSE on failure. Don't close fd's opened by other parent function. (g_key_file_load_from_file): run FILE_IS_REGULAR test before trying to open file, to save an fd from being leaked (would probably be better to use fstat()). Close fd when done with it. Return TRUE on success and FALSE on failure. (g_key_file_load_from_data): Return TRUE on success and FALSE on failure. (g_key_file_load_from_data_dirs): remove superfluous const modifier. Return TRUE on success and FALSE on failure. Stop trying to load files when one succeeds. (g_key_file_parse_key_value_pair): don't validate input for UTF-8 until users uses a getter that does validation. Don't leak copy of start_group_name. (g_key_file_to_data): serialize new comment field for groups. (g_key_file_get_keys): Remove convenience code to let NULL group mean start group. Get rid of unneeded NULL check before g_strdup. (g_key_file_get_groups): Reverse groups list before sending to user because it is maintained in backward order internally. (g_key_file_get_value), (g_key_file_set_value): add g_return checks at top of public functions. (g_key_file_get_string), (g_key_file_get_string_list): validate key value is UTF-8. (g_key_file_[sg]et_*comment): new functions for setting/getting comments (g_key_file_remove_comment): new function to remove comment block (g_key_file_remove_key_value_pair_node): new function to pull a key-value pair out of the list and free it. (g_key_file_remove_group_node): call g_key_file_remove_key_value_pair_node instead of freeing the list immediately to get better statistics for approximate_size. (g_key_file_remove_group): use lookup_group_node instead of lookup_group to prevent a g_list_find call. (g_key_file_add_key): report group also when unable to find key. (g_key_file_lookup_group_node): new function to make getting the group node from a group name easier. (g_key_file_lookup_group): use lookup_group_node under the hood. (g_key_file_lookup_key_value_pair_node): new function to make getting the key-value pair from a group and key name eaiser. (g_key_file_parse_comment_as_value): new function to add '#' to the beginning of every line. (g_key_file_parse_value_as_comment): new function that attempts to be the inverse of comment as value.
2004-10-26 12:35:58 +00:00
void g_key_file_set_comment (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
const gchar *comment,
GError **error);
gchar *g_key_file_get_comment (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
GError **error) G_GNUC_MALLOC;
Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold 2004-10-26 Ray Strode <rstrode@redhat.com> * glib/gkeyfile.c: Add Matthias to "Written by" lines (GKeyFileGroup): add field to hold comments about groups (g_key_file_load_from_fd): return TRUE on success and FALSE on failure. Don't close fd's opened by other parent function. (g_key_file_load_from_file): run FILE_IS_REGULAR test before trying to open file, to save an fd from being leaked (would probably be better to use fstat()). Close fd when done with it. Return TRUE on success and FALSE on failure. (g_key_file_load_from_data): Return TRUE on success and FALSE on failure. (g_key_file_load_from_data_dirs): remove superfluous const modifier. Return TRUE on success and FALSE on failure. Stop trying to load files when one succeeds. (g_key_file_parse_key_value_pair): don't validate input for UTF-8 until users uses a getter that does validation. Don't leak copy of start_group_name. (g_key_file_to_data): serialize new comment field for groups. (g_key_file_get_keys): Remove convenience code to let NULL group mean start group. Get rid of unneeded NULL check before g_strdup. (g_key_file_get_groups): Reverse groups list before sending to user because it is maintained in backward order internally. (g_key_file_get_value), (g_key_file_set_value): add g_return checks at top of public functions. (g_key_file_get_string), (g_key_file_get_string_list): validate key value is UTF-8. (g_key_file_[sg]et_*comment): new functions for setting/getting comments (g_key_file_remove_comment): new function to remove comment block (g_key_file_remove_key_value_pair_node): new function to pull a key-value pair out of the list and free it. (g_key_file_remove_group_node): call g_key_file_remove_key_value_pair_node instead of freeing the list immediately to get better statistics for approximate_size. (g_key_file_remove_group): use lookup_group_node instead of lookup_group to prevent a g_list_find call. (g_key_file_add_key): report group also when unable to find key. (g_key_file_lookup_group_node): new function to make getting the group node from a group name easier. (g_key_file_lookup_group): use lookup_group_node under the hood. (g_key_file_lookup_key_value_pair_node): new function to make getting the key-value pair from a group and key name eaiser. (g_key_file_parse_comment_as_value): new function to add '#' to the beginning of every line. (g_key_file_parse_value_as_comment): new function that attempts to be the inverse of comment as value.
2004-10-26 12:35:58 +00:00
void g_key_file_remove_comment (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
GError **error);
void g_key_file_remove_key (GKeyFile *key_file,
const gchar *group_name,
const gchar *key,
GError **error);
void g_key_file_remove_group (GKeyFile *key_file,
const gchar *group_name,
GError **error);
G_END_DECLS
#endif /* __G_KEY_FILE_H__ */