/**********************************************************************
 
	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	<fcntl.h>
#include	"xlerror.h"
#include	"xl.h"

#include "HTMLDB.h"

XL_SEXP * xl_SaveHtmlDB();

void
init_SaveHtmlDB(XLISP_ENV * env)
{
	set_env(env,l_string(std_cm,"SaveHtmlDB"),
		get_func_prim(xl_SaveHtmlDB,FO_APPLICATIVE,0,0,256));	
}

XL_SEXP * xl_SaveHtmlDB(XLISP_ENV * env,XL_SEXP * s,XLISP_ENV * arg_env,XL_SYM_FIELD * sf)
{
	STREAM* st;
	st = s_open_file("out.txt",O_RDWR,0);

	if ( get_type(HTMLDataBase) == XLT_ERROR ) {
		s_close(st);
		return HTMLDataBase;
	}

	print_sexp(st,HTMLDataBase,PF_MULTI_ROOT);
	s_close(st);
	return 0;
}
