=================================================================== RCS file: /home/cvs/OpenXM_contrib2/windows/asir32gui/io.c,v retrieving revision 1.1.1.1 retrieving revision 1.9 diff -u -p -r1.1.1.1 -r1.9 --- OpenXM_contrib2/windows/asir32gui/io.c 2000/11/22 06:14:29 1.1.1.1 +++ OpenXM_contrib2/windows/asir32gui/io.c 2013/11/29 08:27:59 1.9 @@ -5,6 +5,8 @@ #include #include +#include "asir32gui_io.h" + #define ECGEN_KEYNAME "SoftWare\\Fujitsu\\FSEcParamGen\\V1.0L10" #define ASIR_KEYNAME "SoftWare\\Fujitsu\\Asir\\1999.03.31" @@ -13,7 +15,7 @@ static int use_current_dir; -int asir_main_window; +int asirgui_kind; HANDLE hProc; static HANDLE hRead,hWrite; HANDLE hNotify,hNotify_Ack; @@ -36,9 +38,9 @@ char *errmsg; LONG ret; HKEY hOpenKey; DWORD Type,dw; - char dir[BUFSIZ],message[BUFSIZ]; + char dir[BUFSIZ],message[BUFSIZ],engine[BUFSIZ]; char *slash; - int ldir; + size_t ldir; static char rootdir[BUFSIZ]; static int rootdir_is_initialized; @@ -47,25 +49,40 @@ char *errmsg; return TRUE; } + if(GetModuleFileName(NULL,dir,BUFSIZ)) { + slash = strrchr(dir,'\\'); + *slash = 0; + sprintf(engine,"%s\\engine.exe", dir); + if ( access(engine,0) >= 0 ) { + slash = strrchr(dir,'\\'); + if ( slash ) { + *slash = 0; + } + use_current_dir = 1; + strcpy(rootdir,dir); + strcpy(name,dir); + rootdir_is_initialized = 1; + return TRUE; + } + } + GetCurrentDirectory(BUFSIZ,dir); + slash = strrchr(dir,'\\'); + if ( slash ) + *slash = 0; + ldir = strlen(dir)+1; + if ( access("UseCurrentDir",0) >= 0 ) { + use_current_dir = 1; + strcpy(rootdir,dir); + strcpy(name,dir); + rootdir_is_initialized = 1; + return TRUE; + } ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ECGEN_KEYNAME, 0, KEY_QUERY_VALUE, &hOpenKey); if ( ret != ERROR_SUCCESS ) ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ASIR_KEYNAME, 0, KEY_QUERY_VALUE, &hOpenKey); if( ret != ERROR_SUCCESS ) { - GetCurrentDirectory(BUFSIZ,dir); - slash = strrchr(dir,'\\'); - if ( slash ) - *slash = 0; - ldir = strlen(dir)+1; - if ( access("UseCurrentDir",0) >= 0 ) { - use_current_dir = 1; - strcpy(rootdir,dir); - strcpy(name,dir); - rootdir_is_initialized = 1; - return TRUE; - } - sprintf(message,"May I register '%s' as the ASIR main directory?",dir); if( IDNO == MessageBox(NULL,message,"Asir", MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2) ) { @@ -85,7 +102,7 @@ char *errmsg; NULL); return FALSE; } - if ( ret = RegSetValueEx(hOpenKey,"Directory",NULL,REG_SZ,dir,ldir) ) { + if ( ret = RegSetValueEx(hOpenKey,"Directory",0,REG_SZ,dir,ldir) ) { FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, @@ -105,6 +122,27 @@ char *errmsg; return TRUE; } +const char *get_helpdir() { + static char helpdir[BUFSIZ]; + static int helpdir_is_initialized; + char lang[BUFSIZ]; + char file[BUFSIZ]; + char root[BUFSIZ]; + char errmsg[BUFSIZ]; + + if( !helpdir_is_initialized ) { + get_rootdir(root,sizeof(root),errmsg); + GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SISO639LANGNAME, lang, BUFSIZ); + sprintf(helpdir, "%s\\help\\%s", root, lang); + sprintf(file, "%s\\asirhelp.chm", helpdir); + if ( access(file,0) < 0 ) { + sprintf(helpdir, "%s\\help", root); + } + helpdir_is_initialized = 1; + } + return helpdir; +} + BOOL Init_IO(char *errmsg) { int i; char *av[BUFSIZ]; @@ -118,7 +156,7 @@ BOOL Init_IO(char *errmsg) { _setargv(); if ( !strcmp(__argv[0],"debuggui") ) { - asir_main_window = 0; + asirgui_kind = ASIRGUI_DEBUG; hRead = atoi(__argv[1]); hWrite = atoi(__argv[2]); hNotify = OpenEvent(EVENT_ALL_ACCESS|EVENT_MODIFY_STATE,TRUE,__argv[3]); @@ -128,14 +166,14 @@ BOOL Init_IO(char *errmsg) { hKill = OpenEvent(EVENT_ALL_ACCESS|EVENT_MODIFY_STATE,TRUE,__argv[7]); return TRUE; } else if ( !strcmp(__argv[0],"messagegui") ) { - asir_main_window = 0; + asirgui_kind = ASIRGUI_MESSAGE; hRead = atoi(__argv[1]); hWrite = atoi(__argv[2]); hNotify = OpenEvent(EVENT_ALL_ACCESS|EVENT_MODIFY_STATE,TRUE,__argv[3]); hNotify_Ack = OpenEvent(EVENT_ALL_ACCESS|EVENT_MODIFY_STATE,TRUE,__argv[4]); return TRUE; } else { - asir_main_window = 1; + asirgui_kind = ASIRGUI_MAIN; mypid = GetCurrentProcessId(); sprintf(notify,"asir_notify_%d",mypid); sprintf(notify_ack,"asir_notify_ack_%d",mypid); @@ -164,7 +202,7 @@ BOOL Init_IO(char *errmsg) { return FALSE; } sprintf(AsirExe,"%s\\bin\\engine.exe",name); -// sprintf(AsirExe,"c:\\home\\noro\\engine2000\\debug\\engine.exe"); +// sprintf(AsirExe,"d:\\cygwin\\home\\noro\\new\\OpenXM_contrib2\\windows\\engine2000\\debug\\engine.exe"); if ( !getenv("HOME") ) { sprintf(home,"HOME=%s",name); _putenv(home); @@ -258,23 +296,33 @@ void read_and_insert() } } +static char history_path[BUFSIZ]; +static char history_errmsg[BUFSIZ]; + void init_input_history() { + char rootdir[BUFSIZ]; + get_rootdir(rootdir,sizeof(rootdir),history_errmsg); + sprintf(history_path,"%s\\bin\\%s",rootdir,HISTORY); init_hist(MAXHIST); } void write_input_history() { - write_hist(HISTORY); + write_hist(history_path); } void read_input_history() { - read_hist(HISTORY); + read_hist(history_path); } void send_intr() { + HANDLE handle[1]; + PulseEvent(hIntr); + handle[0] = hIntr_Ack; + WaitForMultipleObjects(1,(CONST HANDLE *)handle,FALSE,(DWORD)-1); } void terminate_asir() {