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



void
send_cindex(L_CHAR * crd)
{
URL u;
XL_SEXP * s,* ret;
L_CHAR * fcrd;
int q;
static int MPct_ses = -1;

ss_printf("Set send_cindex %ls\n",crd);

	fcrd = ll_copy_str(crd,235);
	q = l_strlen(fcrd)-1;
	for ( ; q >= 0 && fcrd[q] != '.' ; q -- );
	if ( q >= 0 )
		fcrd[q] = 0;

	get_url2(&u,l_string(std_cm,"xlp://localhost:9100/"),1218);
	u.port = get_mp_port();
	if ( u.port == 0 ) {
		goto end;
	}

	if ( MPct_ses < 0 )
		MPct_ses = open_session(SEST_OPTIMIZE);
	ret = remote_session(
		gblisp_top_env0,
		MPct_ses,
		&u,
		l_string(std_cm,"gbmp"),
		l_string(std_cm,"user"),
		l_string(std_cm,"Get"),
		List(
			List(n_get_symbol("MPcindex"),
				get_string(fcrd),
				-1),
			-1),
		0,0,0);
	/*
print_sexp(s_stdout,ret,0);
ss_printf("\n");
	*/
end:
	free_url(&u);
	d_f_ree(fcrd);
	return;
}

