#include #include #include "Clean.h" #include "thread_message.h" static int CleanCompiler_message_nunber; int get_message_number (void) { return RegisterWindowMessage ("CleanCompiler"); } int get_current_thread_id (void) { return GetCurrentThreadId(); } int compiler_result_handler_installed=0; #ifdef IDE extern void (*dispatch_null_message_hook) (MSG*); #define MAX_N_COMPILERS 32 int compiler_finished[MAX_N_COMPILERS]; int compiler_exit_codes[MAX_N_COMPILERS]; void compiler_result_handler (MSG *msg) { if (msg->message==CleanCompiler_message_nunber){ unsigned int compiler_n; compiler_n=msg->wParam; if (compiler_nlParam; compiler_finished[compiler_n]=1; } } } void install_compiler_result_handler (void) { CleanCompiler_message_nunber=get_message_number(); dispatch_null_message_hook = &compiler_result_handler; } int start_compiler_process (CleanString compiler_path,CleanString compiler_directory,CleanString command, int *compiler_thread_id_p,size_t *compiler_thread_handle_p,size_t *compiler_process_handle_p) { PSTR application_name,command_line,env,dir; STARTUPINFO si; PROCESS_INFORMATION pi; int r; if (!compiler_result_handler_installed){ install_compiler_result_handler(); compiler_result_handler_installed=1; } application_name=CleanStringCharacters (compiler_path); dir=CleanStringCharacters (compiler_directory); command_line=CleanStringCharacters (command); env=NULL; si.cb = sizeof (STARTUPINFO); si.lpReserved = NULL; si.lpReserved2 = NULL; si.cbReserved2 = 0; si.lpDesktop = NULL; si.lpTitle = NULL; si.dwFlags = 0; r=CreateProcess (application_name,command_line,NULL,NULL,TRUE,DETACHED_PROCESS/*0*/,env,dir,&si,&pi); if (r!=0){ *compiler_thread_id_p=pi.dwThreadId; *compiler_thread_handle_p=pi.hThread; *compiler_process_handle_p=pi.hProcess; } else { *compiler_thread_id_p=0; *compiler_thread_handle_p=0; *compiler_process_handle_p=0; } return r; } int get_finished_compiler_id_and_exit_code (int *exit_code_p) { int compiler_n; for (compiler_n=0; compiler_n