cvs commit: jakarta-tomcat-service/native/winnt/moni Makefile

2002-02-12 Thread jfclere

jfclere 02/02/12 13:55:46

  Modified:native/winnt/moni Makefile
  Log:
  Build vdmonisvc as a windows excutable (so that it does not need cygwin1.dll).
  
  Revision  ChangesPath
  1.2   +2 -2  jakarta-tomcat-service/native/winnt/moni/Makefile
  
  Index: Makefile
  ===
  RCS file: /home/cvs/jakarta-tomcat-service/native/winnt/moni/Makefile,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile  10 Feb 2002 18:02:12 -  1.1
  +++ Makefile  12 Feb 2002 21:55:46 -  1.2
  @@ -5,9 +5,9 @@
gcc $(INCLUDE) -I../executables/vdmoniadm  vdmoniadm.c \
-o ../bin/vdmoniadm -lgdi32
   ../bin/vdmonisvc: vdmonisvc.c vdenv.o kills.o
  - gcc $(INCLUDE) -I../executables/vdmonisvc \
  + gcc -mno-cygwin -I/usr/include $(INCLUDE) -I../executables/vdmonisvc \
-DCYGWIN vdmonisvc.c \
  - -o ../bin/vdmonisvc vdenv.o kills.o -lm
  + -o ../bin/vdmonisvc vdenv.o kills.o
   vdenv.o: ../supcalls_nt/vdenv.c
gcc $(INCLUDE) -c ../supcalls_nt/vdenv.c
   kills.o: ../signals/kills.c
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat-service/native/winnt/moni Makefile vdmonisvc.c

2002-02-16 Thread jfclere

jfclere 02/02/16 14:57:51

  Modified:native/winnt/moni Makefile vdmonisvc.c
  Log:
  Arrange the logic so that is starting on win9x.
  
  Revision  ChangesPath
  1.3   +4 -0  jakarta-tomcat-service/native/winnt/moni/Makefile
  
  Index: Makefile
  ===
  RCS file: /home/cvs/jakarta-tomcat-service/native/winnt/moni/Makefile,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makefile  12 Feb 2002 21:55:46 -  1.2
  +++ Makefile  16 Feb 2002 22:57:51 -  1.3
  @@ -12,3 +12,7 @@
gcc $(INCLUDE) -c ../supcalls_nt/vdenv.c
   kills.o: ../signals/kills.c
gcc $(INCLUDE) -c ../signals/kills.c
  +
  +install:
  + cp ../bin/vdmoniadm c:/home/jakarta/bin
  + cp ../bin/vdmonisvc c:/home/jakarta/bin
  
  
  
  1.4   +155 -44   jakarta-tomcat-service/native/winnt/moni/vdmonisvc.c
  
  Index: vdmonisvc.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-service/native/winnt/moni/vdmonisvc.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- vdmonisvc.c   10 Feb 2002 18:02:12 -  1.3
  +++ vdmonisvc.c   16 Feb 2002 22:57:51 -  1.4
  @@ -15,6 +15,7 @@
   #include 
   #include 
   #include 
  +#include 
   #ifdef CYGWIN
   #else
   #include 
  @@ -26,7 +27,29 @@
   SERVICE_STATUS_HANDLE   sshStatusHandle;
   DWORD   dwErr;
   
  -/* Event logger routines */
  +/*
  + * NT/other detection
  + * from src/os/win32/service.c (httpd-1.3!).
  + */
  + 
  +BOOL isWindowsNT(void)
  +{
  +static BOOL once = FALSE;
  +static BOOL isNT = FALSE;
  + 
  +if (!once)
  +{
  +OSVERSIONINFO osver;
  +osver.dwOSVersionInfoSize = sizeof(osver);
  +if (GetVersionEx(&osver))
  +if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
  +isNT = TRUE;
  +once = TRUE;
  +}
  +return isNT;
  +}
  +
  +/* Event logger routine */
   
   VOID AddToMessageLog(LPTSTR lpszMsg)
   {
  @@ -39,7 +62,10 @@
   
   // Use event logging to log the error.
   //
  -hEventSource = RegisterEventSource(NULL, TEXT(SZSERVICENAME));
  + if (isWindowsNT())
  +hEventSource = RegisterEventSource(NULL, TEXT(SZSERVICENAME));
  + else
  + hEventSource = NULL;
   
   #ifdef CYGWIN
sprintf(szMsg, TEXT("%s error: %d"), TEXT(SZSERVICENAME), dwErr);
  @@ -61,10 +87,89 @@
   NULL);// no raw data
   
   (VOID) DeregisterEventSource(hEventSource);
  -}
  -}
  +} else {
  + /* Default to a trace file */
  + FILE *log;
  + log = fopen("c:/jakarta-service.log","a+");
  + if (log != NULL) {
  +struct tm *newtime;
  +time_t long_time;
  +
  +time( &long_time );
  +newtime = localtime( &long_time );
  +
   
  + fprintf(log,"%.24s:%s: %s\n",asctime(newtime),szMsg, lpszMsg);
  + fclose(log);
  + }
  + }
  +}
   
  +/*  This group of functions are provided for the service/console app
  + *  to register itself a HandlerRoutine to accept tty or service messages
  + *  adapted from src/os/win32/Win9xConHook.c (httpd-1.3!).
  + */
  +
  +/*  Exported function that creates a Win9x 'service' via a hidden window,
  + *  that notifies the process via the HandlerRoutine messages.
  + */
  +BOOL __declspec(dllexport) WINAPI Windows9xServiceCtrlHandler(
  +PHANDLER_ROUTINE phandler,
  +LPCSTR name)
  +{
  +HINSTANCE hkernel;
  +DWORD (WINAPI *register_service_process)(DWORD, DWORD) = NULL;
  +
  +/* If we have not yet done so */
  +FreeConsole();
  +
  +/* Make sure the process will resist logoff */
  +hkernel = LoadLibrary("KERNEL32.DLL");
  +if (!hkernel) {
  +AddToMessageLog(TEXT("LoadLibrary KERNEL32.DLL failed"));
  +return 0;
  +}
  +register_service_process = (DWORD (WINAPI *)(DWORD, DWORD)) 
  +GetProcAddress(hkernel, "RegisterServiceProcess");
  +if (register_service_process == NULL) {
  +AddToMessageLog(TEXT("dlsym RegisterServiceProcess failed"));
  +return 0;
  +}
  +if (!register_service_process(0,TRUE)) {
  +FreeLibrary(hkernel);
  +AddToMessageLog(TEXT("register_service_process failed"));
  +return 0;
  +}
  +AddToMessageLog(TEXT("jsvc registered as a service"));
  +
  +/*
  + * To be handle notice the shutdown, we need a thread and window.
  + */
  +/*
  +if (name)
  +{
  +DWORD tid;
  +HANDLE hThread;
  +static tty_info tty; // Must be static, because we are going to return.
  +tty.instance = GetModuleHandle(NULL);
  +tty.phandler = phandler;
  +tty.parent = NULL;
  +