mturk 2003/02/13 09:48:35 Modified: daemon/src/native/nt/procrun procrun.c procrun.dev procrun.h procrun.rc procrun.vcproj procrund.dev procrunw.dev readme.txt Log: Added GUI mode for PROCRUN_WINAPP mode. This enables that interactively started application puts an icon in the system try. Also it can show the redirected stdout and stderr inside the GUI window. Revision Changes Path 1.6 +93 -4 jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.c Index: procrun.c =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- procrun.c 9 Feb 2003 16:11:23 -0000 1.5 +++ procrun.c 13 Feb 2003 17:48:35 -0000 1.6 @@ -107,6 +107,18 @@ /* The main envronment for services */ procrun_t *g_env = NULL; +#ifdef PROCRUN_WINAPP + +extern DWORD WINAPI gui_thread(LPVOID param); + +extern void ac_add_list_string(const char *str, int len); +extern int ac_use_try; +extern int ac_use_dlg; +extern int ac_use_show; +extern HINSTANCE ac_instance; + +#endif + #ifdef _DEBUG static void dbprintf(char *format, ...) { @@ -449,6 +461,22 @@ STRN_SIZE(PROC_ARG_TEST_SERVICE)); mode = PROCRUN_CMD_TEST_SERVICE; } +#ifdef PROCRUN_WINAPP + else if (STRN_COMPARE(arg, PROC_ARG_GUIT_SERVICE)) { + proc->service.name = pool_strdup(proc->pool, arg + + STRN_SIZE(PROC_ARG_GUIT_SERVICE)); + mode = PROCRUN_CMD_GUIT_SERVICE; + ac_use_try = 1; + ac_use_dlg = 1; + } + else if (STRN_COMPARE(arg, PROC_ARG_GUID_SERVICE)) { + proc->service.name = pool_strdup(proc->pool, arg + + STRN_SIZE(PROC_ARG_GUID_SERVICE)); + mode = PROCRUN_CMD_GUID_SERVICE; + ac_use_dlg = 1; + ac_use_show = 1; + } +#endif else if (STRN_COMPARE(arg, PROC_ARG_STOP_SERVICE)) { proc->service.name = pool_strdup(proc->pool, arg + STRN_SIZE(PROC_ARG_STOP_SERVICE)); @@ -857,6 +885,8 @@ break; case PROCRUN_CMD_RUN_SERVICE: case PROCRUN_CMD_TEST_SERVICE: + case PROCRUN_CMD_GUIT_SERVICE: + case PROCRUN_CMD_GUID_SERVICE: { HKEY key; char skey[256]; @@ -1162,15 +1192,40 @@ unsigned char ch; DWORD readed, written; procrun_t *env = (procrun_t *)param; +#ifdef PROCRUN_WINAPP + static unsigned char buff[MAX_PATH + 1]; + int n = 0; +#endif while (env->c->h_stdout[3] && (ReadFile(env->c->h_stdout[3], &ch, 1, &readed, NULL) == TRUE)) { if (readed) { +#ifdef PROCRUN_WINAPP + if (ac_use_dlg) { + if (ch == '\n' || n >= MAX_PATH) { + buff[n] = '\0'; + DBPRINTF1("RD %s", buff); + ac_add_list_string(buff, n); + n = 0; + } + else if (ch == '\t' && n < (MAX_PATH - 4)) { + int i; + for (i = 0; i < 4; ++i) + buff[n++] = ' '; + } + else if (ch != '\r') + buff[n++] = ch; + else if (ch != '\b') + buff[n++] = ' '; + SwitchToThread(); + } +#else if (WriteFile(env->m->h_stdout[0], &ch, 1, &written, NULL) == TRUE) { SwitchToThread(); } else break; +#endif readed = 0; } } @@ -1183,15 +1238,40 @@ unsigned char ch; DWORD readed, written; procrun_t *env = (procrun_t *)param; +#ifdef PROCRUN_WINAPP + static unsigned char buff[MAX_PATH + 1]; + int n = 0; +#endif while (env->c->h_stderr[3] && (ReadFile(env->c->h_stderr[3], &ch, 1, &readed, NULL) == TRUE)) { if (readed) { +#ifdef PROCRUN_WINAPP + if (ac_use_dlg) { + if (ch == '\n' || n >= MAX_PATH) { + buff[n] = '\0'; + DBPRINTF1("RD %s", buff); + ac_add_list_string(buff, n); + n = 0; + } + else if (ch == '\t' && n < (MAX_PATH - 4)) { + int i; + for (i = 0; i < 4; ++i) + buff[n++] = ' '; + } + else if (ch != '\r') + buff[n++] = ch; + else if (ch != '\b') + buff[n++] = ' '; + SwitchToThread(); + } +#else if (WriteFile(env->m->h_stderr[0], &ch, 1, &written, NULL) == TRUE) { SwitchToThread(); } else break; +#endif readed = 0; } } @@ -2134,14 +2214,22 @@ switch (mode) { case PROCRUN_CMD_TEST_SERVICE: -#ifdef _DEBUG - debug_process(argc, argv, env->m); -#endif +#ifdef PROCRUN_WINAPP + case PROCRUN_CMD_GUIT_SERVICE: + case PROCRUN_CMD_GUID_SERVICE: + { + DWORD gi; + CreateThread(NULL, 0, gui_thread, g_env, 0, &gi); + } +#else if (env->m->service.description) SetConsoleTitle(env->m->service.description); else if (env->m->service.name) SetConsoleTitle(env->m->service.name); - +#endif +#ifdef _DEBUG + debug_process(argc, argv, env->m); +#endif service_main(argc, argv); break; case PROCRUN_CMD_INSTALL_SERVICE: @@ -2228,6 +2316,7 @@ procrun_t *env = alloc_environment(); g_proc_mode = PROCRUN_MODE_WINAPP; g_env = env; + ac_instance = hInstance; rv = procrun_main(__argc, __argv, _environ, env); 1.2 +62 -62 jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.dev Index: procrun.dev =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.dev,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- procrun.dev 7 Feb 2003 07:04:35 -0000 1.1 +++ procrun.dev 13 Feb 2003 17:48:35 -0000 1.2 @@ -1,62 +1,62 @@ -[Project] -FileName=procrun.dev -Name=procrun -UnitCount=2 -Type=1 -Ver=1 -ObjFiles= -Includes=C:\DEVTOOLS\JAVA\include;C:\DEVTOOLS\JAVA\include\win32 -Libs= -PrivateResource=procrun_private.rc -ResourceIncludes= -MakeIncludes= -Resources=procrun.rc -Compiler=-DPROCRUN_CONSOLE -O2 -Linker=-lshlwapi -IsCpp=0 -Icon= -ExeOutput=bin -ObjectOutput=release -OverrideOutput=0 -OverrideOutputName=procrun.exe -HostApplication= -Folders= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=000000000000000000 - -[Unit1] -FileName=procrun.c -Folder=procrun -Compile=1 -CompileCpp=0 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=procrun.h -Folder=procrun -Compile=1 -CompileCpp=0 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= - +[Project] +FileName=procrun.dev +Name=procrun +UnitCount=2 +Type=1 +Ver=1 +ObjFiles= +Includes=C:\DEVTOOLS\JAVA\141\include;C:\DEVTOOLS\JAVA\141\include\win32 +Libs= +PrivateResource=procrun_private.rc +ResourceIncludes= +MakeIncludes= +Resources=procrun.rc +Compiler=-DPROCRUN_CONSOLE -O2 +Linker=-lshlwapi +IsCpp=0 +Icon= +ExeOutput=bin +ObjectOutput=release +OverrideOutput=0 +OverrideOutputName=procrun.exe +HostApplication= +Folders= +CommandLine= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=000000000000000000 + +[Unit1] +FileName=procrun.c +Folder=procrun +Compile=1 +CompileCpp=0 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=procrun.h +Folder=procrun +Compile=1 +CompileCpp=0 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= + 1.5 +19 -1 jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.h Index: procrun.h =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- procrun.h 9 Feb 2003 16:11:23 -0000 1.4 +++ procrun.h 13 Feb 2003 17:48:35 -0000 1.5 @@ -72,7 +72,21 @@ extern "C" { #endif -#define RC_ICO_TRY 101 +#define IDD_DLGCONSOLE 101 +#define IDS_CONWRAPTITLE 102 +#define IDS_CONWRAPCLASS 103 +#define IDM_CONSOLE 104 +#define IDM_EXIT 105 +#define IDI_ICOCONWRAP 106 +#define IDC_STATBAR 107 +#define IDC_SSTATUS 108 +#define IDB_BMPHEADER 109 +#define IDL_STDOUT 110 +#define IDR_CMENU 111 +#define IDM_FILE_EXIT 112 +#define IDM_FILE_EDIT 113 + +#define IDC_STATIC -1 #define PROC_ENV_COUNT 32 #define PROC_ARG_COUNT 128 @@ -88,6 +102,8 @@ #define PROC_ARG_STOP_SERVICE "//SS//" #define PROC_ARG_DELETE_SERVICE "//DS//" #define PROC_ARG_TEST_SERVICE "//TS//" +#define PROC_ARG_GUIT_SERVICE "//GT//" +#define PROC_ARG_GUID_SERVICE "//GD//" #define PROC_ARG_UPDATE_SERVICE "//US//" #define PROC_ARG_EDIT_SERVICE "//ES//" @@ -144,6 +160,8 @@ PROCRUN_CMD_INSTALL_SERVICE, PROCRUN_CMD_RUN_SERVICE, PROCRUN_CMD_TEST_SERVICE, + PROCRUN_CMD_GUIT_SERVICE, + PROCRUN_CMD_GUID_SERVICE, PROCRUN_CMD_STOP_SERVICE, PROCRUN_CMD_DELETE_SERVICE, PROCRUN_CMD_UPDATE_SERVICE, 1.2 +25 -1 jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.rc Index: procrun.rc =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.rc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- procrun.rc 7 Feb 2003 07:04:35 -0000 1.1 +++ procrun.rc 13 Feb 2003 17:48:35 -0000 1.2 @@ -1,7 +1,31 @@ #include "procrun.h" #include "windows.h" -RC_ICO_PROCTRY ICON "proctry.ico" +IDI_ICOCONWRAP ICON "proctry.ico" + +IDR_CMENU MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", IDM_FILE_EXIT + END +END + +IDD_DLGCONSOLE DIALOGEX 0, 0, 480, 240 +STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | + WS_SYSMENU | WS_THICKFRAME +EXSTYLE WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT +CAPTION "Apache Service Monitor" +MENU IDR_CMENU +FONT 10, "Courier New" +BEGIN + LISTBOX IDL_STDOUT,0,0,200,200,NOT LBS_NOTIFY | LBS_USETABSTOPS | + LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | + NOT WS_BORDER | WS_VSCROLL | + WS_HSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE + + +END 1 VERSIONINFO FILEVERSION 2,1,0,0 1.3 +3 -0 jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.vcproj Index: procrun.vcproj =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- procrun.vcproj 9 Feb 2003 16:11:23 -0000 1.2 +++ procrun.vcproj 13 Feb 2003 17:48:35 -0000 1.3 @@ -289,6 +289,9 @@ Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> <File + RelativePath="procgui.c"> + </File> + <File RelativePath="procrun.c"> </File> </Filter> 1.2 +62 -62 jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrund.dev Index: procrund.dev =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrund.dev,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- procrund.dev 9 Feb 2003 16:08:40 -0000 1.1 +++ procrund.dev 13 Feb 2003 17:48:35 -0000 1.2 @@ -1,62 +1,62 @@ -[Project] -FileName=procrund.dev -Name=procrun -UnitCount=2 -Type=3 -Ver=1 -ObjFiles= -Includes=C:\DEVTOOLS\JAVA\include;C:\DEVTOOLS\JAVA\include\win32 -Libs= -PrivateResource=procrun_private.rc -ResourceIncludes= -MakeIncludes= -Resources=procrun.rc -Compiler=-DPROCRUN_WINDLL -O2 -Linker=-lshlwapi -IsCpp=0 -Icon= -ExeOutput=bin -ObjectOutput=ReleaseDLL -OverrideOutput=1 -OverrideOutputName=procrun.dll -HostApplication= -Folders= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=000000000000000000 - -[Unit1] -FileName=procrun.c -Folder=procrun -Compile=1 -CompileCpp=0 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=procrun.h -Folder=procrun -Compile=1 -CompileCpp=0 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= - +[Project] +FileName=procrund.dev +Name=procrun +UnitCount=2 +Type=3 +Ver=1 +ObjFiles= +Includes=C:\DEVTOOLS\JAVA\141\include;C:\DEVTOOLS\JAVA\141\include\win32 +Libs= +PrivateResource=procrun_private.rc +ResourceIncludes= +MakeIncludes= +Resources=procrun.rc +Compiler=-DPROCRUN_WINDLL -O2 +Linker=-lshlwapi +IsCpp=0 +Icon= +ExeOutput=bin +ObjectOutput=ReleaseDLL +OverrideOutput=1 +OverrideOutputName=procrun.dll +HostApplication= +Folders= +CommandLine= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=000000000000000000 + +[Unit1] +FileName=procrun.c +Folder=procrun +Compile=1 +CompileCpp=0 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=procrun.h +Folder=procrun +Compile=1 +CompileCpp=0 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= + 1.2 +70 -62 jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrunw.dev Index: procrunw.dev =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrunw.dev,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- procrunw.dev 7 Feb 2003 19:07:28 -0000 1.1 +++ procrunw.dev 13 Feb 2003 17:48:35 -0000 1.2 @@ -1,62 +1,70 @@ -[Project] -FileName=procrunw.dev -Name=procrun -UnitCount=2 -Type=1 -Ver=1 -ObjFiles= -Includes=C:\DEVTOOLS\JAVA\include;C:\DEVTOOLS\JAVA\include\win32 -Libs= -PrivateResource=procrun_private.rc -ResourceIncludes= -MakeIncludes= -Resources=procrun.rc -Compiler=-DPROCRUN_WINAPP -O2 -Linker=-lshlwapi -IsCpp=0 -Icon= -ExeOutput=bin -ObjectOutput=release -OverrideOutput=0 -OverrideOutputName=procrunw.exe -HostApplication= -Folders= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=000000000000000000 - -[Unit1] -FileName=procrun.c -Folder=procrun -Compile=1 -CompileCpp=0 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=procrun.h -Folder=procrun -Compile=1 -CompileCpp=0 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= - +[Project] +FileName=procrunw.dev +Name=procrun +UnitCount=3 +Type=1 +Ver=1 +ObjFiles= +Includes=C:\DEVTOOLS\JAVA\141\include;C:\DEVTOOLS\JAVA\141\include\win32 +Libs= +PrivateResource=procrun_private.rc +ResourceIncludes= +MakeIncludes= +Resources=procrun.rc +Compiler=-DPROCRUN_WINAPP -O2 +Linker=-lshlwapi -lcomctl32 +IsCpp=0 +Icon= +ExeOutput=bin +ObjectOutput=release +OverrideOutput=0 +OverrideOutputName=procrunw.exe +HostApplication= +Folders= +CommandLine= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=000000000000000000 + +[Unit1] +FileName=procrun.c +Folder=procrun +Compile=1 +CompileCpp=0 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=procrun.h +Folder=procrun +Compile=1 +CompileCpp=0 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= + +[Unit3] +FileName=procgui.c +Folder=procrun +Compile=1 +CompileCpp=0 +OverrideBuildCmd=0 +BuildCmd= + 1.4 +5 -0 jakarta-commons-sandbox/daemon/src/native/nt/procrun/readme.txt Index: readme.txt =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/readme.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- readme.txt 9 Feb 2003 09:36:56 -0000 1.3 +++ readme.txt 13 Feb 2003 17:48:35 -0000 1.4 @@ -28,6 +28,11 @@ Run service as ordinary console application. //US//<serviceName> Update service Change services startup parameters +//GT//<serviceName> Test (Run) the service using windows try + The service will run and put the icon in the + system try. +//GD//<serviceName> Test (Run) the service using windows try + The service will run and and show console window. Options:
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]