/**********************************************************************
 
	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	<stdlib.h>
#include	<windows.h>
#include    <Shellapi.h>
#include	"memory_debug.h"
#include	"utils.h"
#include <string.h>
#include <process.h>

char *http_client = 0;

static void ShlProc(void *p){
	char *url = (char*)p;
	ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWDEFAULT);
	free(url);
	_endthread();
}

void
http_system(
	char * hostname,
	int port,
	char * page)
{
//	char url[512];
	char *url = (char*)malloc(512);
	if(page){
		strcpy(url, page);
	}
	else{
		sprintf(url, "http://%s:%i/", hostname, port);
	}
	_beginthread(ShlProc, 0, url);
	
	/*
char * buf;
SHELLEXECUTEINFO si;

	buf = d_alloc(1000,313);
	sprintf(buf,"http://%s:%i/",
		hostname,
		port);
	si.cbSize = sizeof(SHELLEXECUTEINFO);
	si.fMask = SEE_MASK_CLASSNAME ;
	si.hwnd = NULL;
//	si.lpVerb = "open";
	si.lpVerb = NULL;
	si.lpFile = buf;
	si.lpParameters = NULL;
	si.lpDirectory = NULL;
	si.nShow = SW_SHOWDEFAULT;
	si.hInstApp = 0;
	si.lpIDList = NULL;
//	si.lpClass = "ƒeƒXƒg";
	si.lpClass = 0;
	si.hkeyClass  = 0;
	si.dwHotKey = 0;
	si.hIcon  = 0;
	si.hMonitor = 0;
	si.hProcess  = 0;

	//ShellExecute(NULL, "open", buf, NULL,NULL,SW_SHOWNORMAL);
	ShellExecuteEx(&si);
	d_f_ree(buf);
	*/
}
