#include <stdio.h>
#include <glib.h>

typedef struct _GKeyFileGroup GKeyFileGroup;
typedef struct _GKeyFileKeyValuePair GKeyFileKeyValuePair;

typedef struct _GKeyFile
{
  GList *groups;
  GHashTable *group_hash;

  GKeyFileGroup *start_group;
  GKeyFileGroup *current_group;

  GString *parse_buffer; /* Holds up to one line of not-yet-parsed data */

  /* Used for sizing the output buffer during serialization
   */
  gsize approximate_size;

  gchar list_separator;

  GKeyFileFlags flags;

  gchar **locales;
} _GKeyFile;

struct _GKeyFileGroup
{
  const gchar *name;  /* NULL for above first group (which will be comments) */

  GKeyFileKeyValuePair *comment; /* Special comment that is stuck to the top of a group */
  gboolean has_trailing_blank_line;

  GList *key_value_pairs;

  /* Used in parallel with key_value_pairs for
   * increased lookup performance
   */
  GHashTable *lookup_map;
};

struct _GKeyFileKeyValuePair
{
  gchar *key;  /* NULL for comments */
  gchar *value;
};




int main ()
{
	GKeyFile *keyfile = NULL;
	
	GError *error = NULL;
	gsize length;
	gchar *texto = NULL;
	  
	keyfile = g_key_file_new ();

	_GKeyFile *keyfile2 = keyfile;
	printf("size: %d\n", keyfile2->approximate_size);

	int i = 0;

	g_key_file_set_value(keyfile, "grupo1", "chave1", "1234567890"); 
	printf("size: %d\n", keyfile2->approximate_size);

	g_key_file_set_value(keyfile, "grupo1", "chave1", "123123423423423432432423423");
	printf("size: %d\n", keyfile2->approximate_size);

	g_key_file_remove_group(keyfile, "grupo1", &error);
	printf("size: %d\n", keyfile2->approximate_size);
	if (error) g_error_free(error);    
	error = NULL;

	printf("size: %d\n", keyfile2->approximate_size);

  
	texto = g_key_file_to_data (keyfile, &length, &error);
	if (error) 	g_error_free(error);

	printf("---\n%s\n---\n", texto);
	g_free(texto);

	g_key_file_free(keyfile);
	return 0;
}
