From 9334098b1bda87b10d0c85b025e448cba0c96f8f Mon Sep 17 00:00:00 2001 From: johnvg Date: Thu, 29 Apr 2004 11:13:17 +0000 Subject: add set_compiler_id and get_compiler_id git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1492 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d --- main/Windows/Clean System Files/thread_message.obj | Bin 3665 -> 2496 bytes main/Windows/thread_message.c | 254 +++++++++++++++++++++ main/Windows/thread_message.h | 0 3 files changed, 254 insertions(+) create mode 100644 main/Windows/thread_message.c create mode 100644 main/Windows/thread_message.h diff --git a/main/Windows/Clean System Files/thread_message.obj b/main/Windows/Clean System Files/thread_message.obj index 79e99da..d600ff0 100644 Binary files a/main/Windows/Clean System Files/thread_message.obj and b/main/Windows/Clean System Files/thread_message.obj differ diff --git a/main/Windows/thread_message.c b/main/Windows/thread_message.c new file mode 100644 index 0000000..d261842 --- /dev/null +++ b/main/Windows/thread_message.c @@ -0,0 +1,254 @@ + +#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,int *compiler_thread_handle_p,int *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