


/*
 * GtkScare is a runner for Adrift text adventure games.
 * This program is released under GNU GPL. See the file COPYING.TXT for
 * details.
 * Copyright (c) 2004 Pallav Nawani
 *
 */


/*! 
*
* \file config.c
* 	No description yet
* 
*/


#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gtk/gtk.h"

#include "interface.h"
#include "support.h"
#include "gtkscare.h"
#include "config.h"


extern Gtk_sdata *idata;

void read_config()
{
   char *homedir;
   char *fname;
   int reader;

   FILE *fptr;
   
   homedir = getenv("HOME");
   fname = (char *)malloc(strlen(homedir)+strlen(".gtkscarerc")+2);
   sprintf(fname, "%s/.gtkscarerc", homedir);
   
   fptr = fopen(fname, "ra");
   if(NULL == fptr)
      return;

   fscanf(fptr, "%s\n", idata->name);
   fscanf(fptr, "%d\n", &reader);
   idata->verbose = reader;
   fclose(fptr);

}

void write_config()
{
   char *homedir;
   char *fname;

   FILE *fptr;
   
   homedir = getenv("HOME");
   fname = (char *)malloc(strlen(homedir)+strlen(".gtkscarerc")+2);
   sprintf(fname, "%s/.gtkscarerc", homedir);
   
   fptr = fopen(fname, "wa");
   if(NULL == fptr)
      return;

   fprintf(fptr, "%s\n", idata->name);
   fprintf(fptr, "%d\n", idata->verbose);
   fclose(fptr);

}



//==///////////////////////////////////////////////////////////////////
//
///
///
/// \param
///	
/// \return
///	
//==///////////////////////////////////////////////////////////////////


/*  End of file config.c  */

