示例#1
0
文件: runperl.c 项目: cobaugh/rt-rpm
int
main(int argc, char **argv, char **env)
{
#ifdef _MSC_VER
    /* Arrange for _CrtDumpMemoryLeaks() to be called automatically at program
     * termination when built with CFG = DebugFull. */
    int currentFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
    currentFlag |= _CRTDBG_LEAK_CHECK_DF;
    _CrtSetDbgFlag(currentFlag);

    /* Change this -1 to the allocation number of any reported memory leaks to
     * break on the allocation call that was leaked. */
    _CrtSetBreakAlloc(-1L);
#endif

    return RunPerl(argc, argv, env);
}
示例#2
0
int
main(int argc, char **argv, char **env)
{
  int res;

  if(argc == 1)
    XCEShowMessageA("Starting perl with no args is currently\r\n"
		    "not useful on Windows CE");

  w32console_usefunctionkeys = 0; /* this allows backspace key to work */

  res = RunPerl(argc, argv, env);

  if(res != 0)
    XCEShowMessageA("Exitcode: %d", res);

  return res;
}
示例#3
0
文件: padre.c 项目: mishin/padre-0.94
int main(int argc, char **argv, char **env)
{
	// Padre.exe path
	TCHAR szExePath[MAX_PATH];
	// Padre script path
	TCHAR szPadre[MAX_PATH];
	// wperl.exe path
	TCHAR szWPerlExePath[MAX_PATH];
	HMODULE hModule, hModulePerlDll;
	DWORD dwLength;
	HANDLE hHeap;
	char **new_argv;
	PerlInterpreter *my_perl;  /***    The Perl interpreter    ***/
	int i;
	int exitcode;

	hModule = GetModuleHandle(NULL);
	// Find the the executable's path
	dwLength = GetModuleFileName(hModule, szExePath, sizeof(szExePath)/sizeof(szExePath[0]));


	// Build the 'padre' script path
	dwLength = GetDirectory(szPadre, szExePath, sizeof(szPadre)/sizeof(szPadre[0]));
	lstrcpy(szPadre+dwLength, _T("\\padre"));
	//MessageBox(NULL, szPadre, "Padre", MB_OK|MB_ICONINFORMATION);

	// At this point we should check if padre script exists or not
	if (! FileExists(szPadre)) {
		LocalizedMessageBox(MAKEINTRESOURCE(IDS_ERR_SCRIPT), MAKEINTRESOURCE(IDS_APP_TITLE), MB_OK|MB_ICONERROR);
		return 1;
	}

	// Rewrite the command line to insert the padre script
	hHeap = GetProcessHeap();
	new_argv = HeapAlloc(hHeap, 0, (argc+2)*sizeof(new_argv[0]));
	new_argv[0] = argv[0];
	new_argv[1] = "--";
	new_argv[2] = szPadre;
	for(i=1; i<argc; i++)
		new_argv[i+2] = argv[i];
	argc += 2;
	argv = new_argv;

	// We must set $^X to wperl.exe
	// We do that by changing argv[0]

	// Get the module of the Perl DLL to which we have been linked
	// as this is where wperl.exe is.
	if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
						| GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
						(LPCTSTR)RunPerl, &hModulePerlDll)
			&& hModulePerlDll != hModule) {
		// If hModulePerlDll == hModule, we have to for another function

		dwLength = GetModuleFileName(hModulePerlDll, szWPerlExePath,
					sizeof(szWPerlExePath)/sizeof(szWPerlExePath[0]));
		//MessageBox(NULL, szWPerlExePath, "Padre", MB_OK|MB_ICONINFORMATION);
		dwLength = GetDirectory(szWPerlExePath, szWPerlExePath,
					sizeof(szWPerlExePath)/sizeof(szWPerlExePath[0]));
		lstrcpy(szWPerlExePath+dwLength, _T("\\wperl.exe"));
		if (FileExists(szWPerlExePath))
			argv[0] = szWPerlExePath;
	}

	//MessageBox(NULL, argv[0], "Padre", MB_OK|MB_ICONINFORMATION);
	
#if 0
	/*
	 * Unfortunately it seems RunPerl() ignores the changed argv[0] and
	 * overrides argv[0] so that $^X is still Padre.exe
	 */
	exitcode = RunPerl(argc, argv, env);
#else

#if defined(TOP_CLONE) && defined(USE_ITHREADS)
	// See the RunPerl source
	MessageBox(NULL, "FIXME: ithreads support not implemented in Padre.exe launcher!", "Padre", MB_OK|MB_ICONERROR);
#endif

	/* This is derived from the source of RunPerl() */

	PERL_SYS_INIT3(&argc, &argv, &env);
	if (!(my_perl = perl_alloc())) {
		MessageBox(NULL, "Can't allocate Perl interpreter!", "Padre", MB_OK|MB_ICONERROR);
		exitcode = 1;
	} else {
		perl_construct(my_perl);
		PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
		PL_perl_destruct_level = 0;
		exitcode = perl_parse(my_perl, xs_init, argc, argv, env)
				|| perl_run(my_perl);
		perl_destruct(my_perl);
		perl_free(my_perl);
	}
	PERL_SYS_TERM();

#endif

	HeapFree(hHeap, 0, new_argv);
	return exitcode;
}