Relocate CERT_INFO_PREFIX to ssl.c
[privoxy.git] / w32svrapi.c
index 405e8e0..71f2946 100644 (file)
@@ -1,4 +1,3 @@
-const char w32_svrapi_rcs[] = "$Id: w32svrapi.c,v 1.1 2006/08/12 03:54:37 david__schmidt Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/w32svrapi.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/w32svrapi.c,v $
@@ -17,7 +16,7 @@ const char w32_svrapi_rcs[] = "$Id: w32svrapi.c,v 1.1 2006/08/12 03:54:37 david_
  *                doing to provide that isolation.
  *
  * Copyright   :  Written by and Copyright (C) 2003, 2006 members of
  *                doing to provide that isolation.
  *
  * Copyright   :  Written by and Copyright (C) 2003, 2006 members of
- *                the Privoxy team.  http://www.privoxy.org/
+ *                the Privoxy team.  https://www.privoxy.org/
  *
  *                Written by and Copyright (C) 2003 Ian Cummings
  *                <ian_a_c@hotmail.com>
  *
  *                Written by and Copyright (C) 2003 Ian Cummings
  *                <ian_a_c@hotmail.com>
@@ -26,7 +25,7 @@ const char w32_svrapi_rcs[] = "$Id: w32svrapi.c,v 1.1 2006/08/12 03:54:37 david_
  *                some very helpful feedback and suggestions during the
  *                development of this code.
  *
  *                some very helpful feedback and suggestions during the
  *                development of this code.
  *
- *                This program is free software; you can redistribute it 
+ *                This program is free software; you can redistribute it
  *                and/or modify it under the terms of the GNU General
  *                Public License as published by the Free Software
  *                Foundation; either version 2 of the License, or (at
  *                and/or modify it under the terms of the GNU General
  *                Public License as published by the Free Software
  *                Foundation; either version 2 of the License, or (at
@@ -44,15 +43,8 @@ const char w32_svrapi_rcs[] = "$Id: w32svrapi.c,v 1.1 2006/08/12 03:54:37 david_
  *                or write to the Free Software Foundation, Inc., 59
  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
  *                or write to the Free Software Foundation, Inc., 59
  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * Revisions   :
- *    $Log: w32svrapi.c,v $
- *    Revision 1.1  2006/08/12 03:54:37  david__schmidt
- *    Windows service integration
- *
- *
- *
  *********************************************************************/
  *********************************************************************/
-\f
+
 
 #include "config.h"
 
 
 #include "config.h"
 
@@ -71,8 +63,6 @@ const char w32_svrapi_rcs[] = "$Id: w32svrapi.c,v 1.1 2006/08/12 03:54:37 david_
 #endif /* ndef _WIN_CONSOLE */
 
 #include "w32svrapi.h"
 #endif /* ndef _WIN_CONSOLE */
 
 #include "w32svrapi.h"
-const char w32_svrapi_h_rcs[] = W32_SVRAPI_H_VERSION;
-
 
 /* Only the ANSI Win32 APIs are used at this time. If for some
  * reason, we're building under unicode then we must stop
 
 /* Only the ANSI Win32 APIs are used at this time. If for some
  * reason, we're building under unicode then we must stop
@@ -126,7 +116,7 @@ static BOOL HasServiceControlManager()
       return FALSE;
    }
 
       return FALSE;
    }
 
-   /* Try and connect to the SCM. If it fails check and see if the error 
+   /* Try and connect to the SCM. If it fails check and see if the error
     * code is ERROR_CALL_NOT_IMPLEMENTED, which means:
     *    "This function is not supported on this system."
     */
     * code is ERROR_CALL_NOT_IMPLEMENTED, which means:
     *    "This function is not supported on this system."
     */
@@ -172,12 +162,12 @@ BOOL CanSystemSupportServices()
  * The Service functions are defined in <winsvc.h> which is where
  * the declarations used in this file are taken from
  *
  * The Service functions are defined in <winsvc.h> which is where
  * the declarations used in this file are taken from
  *
- *********************************************************************/ 
+ *********************************************************************/
 
 
 /*********************************************************************
  * Open a connection to the service control manager
 
 
 /*********************************************************************
  * Open a connection to the service control manager
- *********************************************************************/ 
+ *********************************************************************/
 SC_HANDLE w32_open_sc_manager(
   LPCTSTR lpMachineName,   /* computer name */
   LPCTSTR lpDatabaseName,  /* SCM database name */
 SC_HANDLE w32_open_sc_manager(
   LPCTSTR lpMachineName,   /* computer name */
   LPCTSTR lpDatabaseName,  /* SCM database name */
@@ -212,7 +202,7 @@ SC_HANDLE w32_open_sc_manager(
     */
    FreeLibrary(hDll);
    SetLastError(dwLastErr);
     */
    FreeLibrary(hDll);
    SetLastError(dwLastErr);
-     
+
    return hScm;
 
 } /* -END- w32_open_sc_manager */
    return hScm;
 
 } /* -END- w32_open_sc_manager */
@@ -260,7 +250,7 @@ BOOL w32_close_service_handle(
 
 /*********************************************************************
  * Open a service
 
 /*********************************************************************
  * Open a service
- *********************************************************************/ 
+ *********************************************************************/
 SC_HANDLE w32_open_service(
   SC_HANDLE hSCManager,   /* handle to SCM database */
   LPCTSTR lpServiceName,  /* service name */
 SC_HANDLE w32_open_service(
   SC_HANDLE hSCManager,   /* handle to SCM database */
   LPCTSTR lpServiceName,  /* service name */
@@ -295,7 +285,7 @@ SC_HANDLE w32_open_service(
     */
    FreeLibrary(hDll);
    SetLastError(dwLastErr);
     */
    FreeLibrary(hDll);
    SetLastError(dwLastErr);
-     
+
    return hSrv;
 
 } /* -END- w32_open_service */
    return hSrv;
 
 } /* -END- w32_open_service */
@@ -358,7 +348,7 @@ SC_HANDLE w32_create_service(
     */
    FreeLibrary(hDll);
    SetLastError(dwLastErr);
     */
    FreeLibrary(hDll);
    SetLastError(dwLastErr);
-     
+
    return hSrv;
 
 } /* -END- w32_create_service */
    return hSrv;
 
 } /* -END- w32_create_service */
@@ -570,12 +560,12 @@ static void display_win32_msg(BOOL bIsError, char *msg)
 #else
    if (bIsError)
    {
 #else
    if (bIsError)
    {
-      MessageBox(NULL, msg, "Privoxy Error", 
+      MessageBox(NULL, msg, "Privoxy Error",
          MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
    }
    else
    {
          MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
    }
    else
    {
-      MessageBox(NULL, msg, "Privoxy Information", 
+      MessageBox(NULL, msg, "Privoxy Information",
          MB_OK | MB_ICONINFORMATION | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
    }
 #endif
          MB_OK | MB_ICONINFORMATION | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
    }
 #endif
@@ -635,9 +625,9 @@ BOOL install_service(const char *service_name)
     * We'll temporarily use szDisplayName as a second buffer.
     *********************************************************************/
    GetModuleFileName(NULL, szDisplayName, MAX_PATH);
     * We'll temporarily use szDisplayName as a second buffer.
     *********************************************************************/
    GetModuleFileName(NULL, szDisplayName, MAX_PATH);
-   sprintf(szModule, "\"%s\" --service", szDisplayName); 
+   sprintf(szModule, "\"%s\" --service", szDisplayName);
+
 
 
-   
    /*********************************************************************
     * Get the display name for the service
     *********************************************************************/
    /*********************************************************************
     * Get the display name for the service
     *********************************************************************/
@@ -647,7 +637,7 @@ BOOL install_service(const char *service_name)
    /*********************************************************************
     * Create the service
     *********************************************************************/
    /*********************************************************************
     * Create the service
     *********************************************************************/
-   hService = w32_create_service(hSCM, 
+   hService = w32_create_service(hSCM,
                            service_name,              /* the internal service name */
                            szDisplayName,             /* the display name */
                            SERVICE_ALL_ACCESS,        /* get full access during creation */
                            service_name,              /* the internal service name */
                            szDisplayName,             /* the display name */
                            SERVICE_ALL_ACCESS,        /* get full access during creation */
@@ -770,7 +760,7 @@ static void WINAPI privoxy_w32_service_start(DWORD dw, LPSTR* pszArgs)
 {
    int child_id;
 
 {
    int child_id;
 
-   /* Arg zero is always the service name, and we need to 
+   /* Arg zero is always the service name, and we need to
     * know it when we call RegisterServiceCtrlHandler.
     */
    strcpy(szThisServiceName, pszArgs[0]);
     * know it when we call RegisterServiceCtrlHandler.
     */
    strcpy(szThisServiceName, pszArgs[0]);
@@ -792,6 +782,9 @@ static void WINAPI privoxy_w32_service_start(DWORD dw, LPSTR* pszArgs)
    w32_set_service_status(hSrv_status, &srv_status);
 
 #ifndef FEATURE_PTHREAD
    w32_set_service_status(hSrv_status, &srv_status);
 
 #ifndef FEATURE_PTHREAD
+   /* NOTE: a cygwin cross-compiler build for --host=i686-w64-mingw32 must disable POSIX threading - eg
+    *         ./configure --host=i686-w64-mingw32 --disable-pthread
+    */
    child_id = _beginthread(w32_service_listen_loop, 0, NULL);
    if (child_id > 0)
 #else
    child_id = _beginthread(w32_service_listen_loop, 0, NULL);
    if (child_id > 0)
 #else
@@ -922,7 +915,7 @@ static void WINAPI privoxy_w32_service_handler(DWORD dwOpcode)
           * even after the process had disappeared.
           *
           * It seems that if we call exit in the ServiceMain thread, it causes
           * even after the process had disappeared.
           *
           * It seems that if we call exit in the ServiceMain thread, it causes
-          * the SCM to not recieve the status we sent in the line above. The
+          * the SCM to not receive the status we sent in the line above. The
           * simple fix was to create a new thread to actually call exit for us
           * whilst this thread continues and returns to its caller.
           */
           * simple fix was to create a new thread to actually call exit for us
           * whilst this thread continues and returns to its caller.
           */