/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	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.

**********************************************************************/

#include	"utils.h"
#include 	"save_global.h"
#include	"memory_debug.h"


FILE * sg_fd;
int init_sg_flag;

void
init_sg()
{
char filename[100];
char * _filename;

	if ( init_sg_flag )
		return;
	init_sg_flag = 1;
	sprintf(filename,"%sglobal.txt",get_preference_path());
	_filename = change_delim_str(filename);
	u_mkdir(get_preference_path(),0700);
	sg_fd = fopen(_filename,"w+");
	if ( _filename != filename )
		d_f_ree(_filename);
}

void
end_sg()
{
	fclose(sg_fd);
}

void
sg_title(char * title)
{
	if ( sg_fd == 0 )
		return;
	fprintf(sg_fd,"\n%s\n\n",title);
}

void
sg(char * type,char * name,void * ptr)
{
	if ( sg_fd == 0 )
		return;
	fprintf(sg_fd,"%s\t\t*((%s*)0x%x)\n",name,type,ptr);
}

