Exemple #1
0
/**
 *	main function of program.
 *
 *	Return 0 if success, -1 on error. 
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate())
		return -1;

	if (cfg_load_file(_s_proxy, _s_cfgfile)) {
		_release();
		ERR_RET(-1, "parse config file %s failed\n", _s_cfgfile);
	}

	if (_s_vrycfg)	
		proxy_print(_s_proxy);		
	else 
		proxy_main(_s_proxy);

	_release();

	return 0;
}
Exemple #2
0
int main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	proxy_main(&_g_arg);

	return 0;
}
Exemple #3
0
	int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) {
		int res = 0;
		if( nCmdShow != SW_HIDE ) {
			char szApp[4096];
			STARTUPINFOA si;
			PROCESS_INFORMATION pi;
			GetModuleFileNameA(NULL, szApp, sizeof(szApp));
			ZeroMemory(&si, sizeof(STARTUPINFO));
			si.cb			= sizeof(STARTUPINFO);
			si.dwFlags		= STARTF_USESHOWWINDOW;
			si.wShowWindow	= SW_HIDE;
			CreateProcessA(szApp, lpCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
			return res;
		}

		AllocConsole();
		res = proxy_main(__argc, __argv);
		FreeConsole();

		return res;
	}
Exemple #4
0
int 
cproc_create(cproc_t *cp, proxy_arg_t *arg)
{
	pid_t pid;

	if (!cp || !arg || index < 0)
		return -1;

	pid = fork();
	if (pid < 0) {
		printf("fork failed %s\n", strerror(errno));
		return -1;
	}
	else if (pid == 0) {
		proxy_main(arg);
		exit(0);
	}
	
	cp->pid = pid;
	cp->index = arg->index;

	return 0;
}