Logo Search packages:      
Sourcecode: mathwar version File versions  Download package

ini_defs.c

/*-------------------------------------------------------------------------
 * Copyright (c) 2000-2002 Kenneth W. Sodemann (stufflehead@bigfoot.com)
 *-------------------------------------------------------------------------
 * ini_defs
 *
 * Synopsis:
 *   Defines used with the INI files
 *
 * $Id: ini_defs.c,v 1.2 2002/05/24 22:04:19 stuffle Exp $
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to
 * Free Software Foundation, Inc.
 * 59 Temple Place, Suite 330 
 * Boston, MA  02111-1307  USA
 *
 *-------------------------------------------------------------------------
 */
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gnome.h>

#include "ini_defs.h"

#define  BASIC_CONF         "/%s/%s/%s"
#define  CONF_WITH_INT_DEF  "/%s/%s/%s=%d"
#define  CONF_WITH_STR_DEF  "/%s/%s/%s=%s"

gint
00042 ini_get_int (const gchar *ini_file,
             const gchar *section,
             const gchar *label,
             gint         def_val)
{
   GString  *str;
   gint      rtn_val;

   str = g_string_new ("");
   g_string_sprintf (str, CONF_WITH_INT_DEF, ini_file, 
                     section, label, def_val);

   rtn_val = gnome_config_get_int (str->str);
   g_string_free (str, TRUE);

   return rtn_val;
}

void
00061 ini_set_int (const gchar *ini_file,
             const gchar *section,
             const gchar *label,
             gint         value)
{
   GString  *str;

   str = g_string_new ("");
   g_string_sprintf (str, BASIC_CONF, ini_file, section, label);
   gnome_config_set_int (str->str, value);
   g_string_free (str, TRUE);

   return;
}


gchar *
00078 ini_get_string (const gchar *ini_file,
                const gchar *section,
                const gchar *label,
                const gchar *def_val)
{
   GString  *str;
   gchar    *rtn;

   str = g_string_new ("");
   g_string_sprintf (str, CONF_WITH_STR_DEF, ini_file,
                     section, label, def_val);

   rtn = gnome_config_get_string (str->str);
   g_string_free (str, TRUE);

   return rtn;
}

void
00097 ini_set_string (const gchar *ini_file, 
                const gchar *section,
                const gchar *label,
                const gchar *value)
{
   GString *str;

   str = g_string_new ("");
   g_string_sprintf (str, BASIC_CONF, ini_file, section, label);
   gnome_config_set_string (str->str, value);
   g_string_free (str, TRUE);

   return;
}

Generated by  Doxygen 1.6.0   Back to index