medit/tests/testkeyfile.c

48 lines
1.1 KiB
C
Raw Normal View History

2006-08-22 23:15:25 -05:00
/*
* testkeyfile.c
*
2007-06-24 12:56:20 -05:00
* Copyright (C) 2004-2007 by Yevgen Muntyan <muntyan@math.tamu.edu>
2006-08-22 23:15:25 -05:00
*
2007-06-24 12:56:20 -05:00
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
2007-09-23 11:47:28 -05:00
* License version 2.1 as published by the Free Software Foundation.
2006-08-22 23:15:25 -05:00
*
* See COPYING file that comes with this distribution.
*/
#include "mooedit/mookeyfile.h"
int main (int argc, char *argv[])
{
GError *error = NULL;
MooKeyFile *key_file;
const char *file;
2006-08-23 05:30:40 -05:00
char *string;
2006-08-22 23:15:25 -05:00
if (argc < 2)
g_error ("usage: %s <file>", argv[0]);
file = argv[1];
key_file = moo_key_file_new_from_file (file, &error);
if (!key_file)
{
g_print ("%s\n", error->message);
g_error_free (error);
return 1;
}
g_print ("Successfully parsed file %s\n", file);
2006-08-23 05:30:40 -05:00
string = moo_key_file_format (key_file, "A comment", 2);
g_print ("===========================\n");
g_print ("%s", string);
g_print ("===========================\n");
g_free (string);
2006-08-22 23:15:25 -05:00
moo_key_file_unref (key_file);
return 0;
}