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

XL_SEXP * 
load_meta(int ses,char * mode,L_CHAR * target)
{
XL_SEXP * ret;
XL_SEXP * gt;
L_CHAR * f;
URL u;
void gc_gb_sexp();

	get_url2(&u,target,1609);

	gc_push(0,0,"remote_fetch");
	gt = get_symbol(l_string(std_cm,"Get"));
	set_attribute(gt,
		l_string(std_cm,"mode"),
		l_string(std_cm,mode));

	f = get_url_filepath(&u);

	ret = remote_session(
		gblisp_top_env0,
		ses,
		&u,
		0,
		l_string(std_cm,"user"),
		l_string(std_cm,"Get"),
		List(List(gt,
			get_string(f),
			-1),
			-1),
		0,0,0);
	d_f_ree(f);

if ( get_type(ret) == XLT_ERROR ){
fflush(stdout);
ss_printf("loadmeta(%i)(%s) %ls = ",get_tid(),mode,get_url_str2(&u));
print_sexp(s_stdout,ret,0);
ss_printf("\n");
ss_printf("\n");
log_print_sexp(LOG_DEBUG,"loadmeta=",ret,0);
}
	gc_pop(ret,gc_gb_sexp);
	return ret;
}



