#include<gtk/gtk.h>
#include<string.h>
#include<stdio.h>
#include "value_pair.h"

char * value_pair_get_value( GList * pairs, char * key )
{
	GList * node;
	for( node = pairs; node; node=node->next)
	{
		value_pair * vp = node->data;
		if(!strcasecmp(key, vp->key))
			return vp->value;
	}
	return NULL;
}

void value_pair_free( GList * pairs )
{
	GList * node;
	for( node = pairs; node; node = node->next )
	{
		g_free(node->data);
	}
	g_list_free(pairs);
}

void value_pair_print_values( GList * pairs, FILE * file, int indent )
{
	GList * node;
	int i;
	
	for( node = pairs; node; node = node->next )
	{
		value_pair * vp = node->data;

		for( i = 0; i < indent; i++ )
		{
			fprintf( file, "\t" );
		}

		fprintf(file, "%s=\"%s\"\n", vp->key, vp->value);
	}
}
				
