]> git.sesse.net Git - vlc/blobdiff - modules/control/ntservice.c
One more removing session. (useless test before a free())
[vlc] / modules / control / ntservice.c
index 08b58929d5af9f6b668a60ec938a2a5467ff397f..4d52d14a84521928d7f30d6162925fc460c3f2c1 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * ntservice.c: Windows NT/2K/XP service interface
  *****************************************************************************
- * Copyright (C) 2004 VideoLAN (Centrale Réseaux) and its contributors
+ * Copyright (C) 2004 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include <vlc_interface.h>
 
 #define VLCSERVICENAME "VLC media player"
 
@@ -38,21 +41,21 @@ static void Close   ( vlc_object_t * );
 
 #define INSTALL_TEXT N_( "Install Windows Service" )
 #define INSTALL_LONGTEXT N_( \
-    "If enabled the interface will install the Service and exit." )
+    "Install the Service and exit." )
 #define UNINSTALL_TEXT N_( "Uninstall Windows Service" )
 #define UNINSTALL_LONGTEXT N_( \
-    "If enabled the interface will uninstall the Service and exit." )
+    "Uninstall the Service and exit." )
 #define NAME_TEXT N_( "Display name of the Service" )
 #define NAME_LONGTEXT N_( \
-    "This allows you to change the display name of the Service." )
+    "Change the display name of the Service." )
 #define OPTIONS_TEXT N_("Configuration options")
 #define OPTIONS_LONGTEXT N_( \
-    "This option allows you to specify configuration options that will be " \
+    "Configuration options that will be " \
     "used by the Service (eg. --foo=bar --no-foobar). It should be specified "\
     "at install time so the Service is properly configured.")
 #define EXTRAINTF_TEXT N_("Extra interface modules")
 #define EXTRAINTF_LONGTEXT N_( \
-    "This option allows you to select additional interfaces spawned by the " \
+    "Additional interfaces spawned by the " \
     "Service. It should be specified at install time so the Service is " \
     "properly configured. Use a comma separated list of interface modules. " \
     "(common values are: logger, sap, rc, http)")
@@ -149,7 +152,7 @@ static void Run( intf_thread_t *p_intf )
 
     if( StartServiceCtrlDispatcher( dispatchTable ) == 0 )
     {
-        msg_Err( p_intf, "StartServiceCtrlDispatcher failed" );
+        msg_Err( p_intf, "StartServiceCtrlDispatcher failed" ); /* str review */
     }
 
     free( p_intf->p_sys->psz_service );
@@ -164,7 +167,7 @@ static void Run( intf_thread_t *p_intf )
     }
 
     /* Make sure we exit (In case other interfaces have been spawned) */
-    p_intf->p_vlc->b_die = VLC_TRUE;
+    vlc_object_kill( p_intf->p_libvlc );
 }
 
 /*****************************************************************************
@@ -177,7 +180,8 @@ static int NTServiceInstall( intf_thread_t *p_intf )
     SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
     if( handle == NULL )
     {
-        msg_Err( p_intf, "could not connect to SCM database" );
+        msg_Err( p_intf,
+                 "could not connect to Services Control Manager database" );
         return VLC_EGENERIC;
     }
 
@@ -192,7 +196,7 @@ static int NTServiceInstall( intf_thread_t *p_intf )
         strcat( psz_path, " --ntservice-extraintf " );
         strcat( psz_path, psz_extra );
     }
-    if( psz_extra ) free( psz_extra );
+    free( psz_extra );
 
     psz_extra = config_GetPsz( p_intf, "ntservice-options" );
     if( psz_extra && *psz_extra )
@@ -200,7 +204,7 @@ static int NTServiceInstall( intf_thread_t *p_intf )
         strcat( psz_path, " " );
         strcat( psz_path, psz_extra );
     }
-    if( psz_extra ) free( psz_extra );
+    free( psz_extra );
 
     SC_HANDLE service =
         CreateService( handle, p_sys->psz_service, p_sys->psz_service,
@@ -241,7 +245,8 @@ static int NTServiceUninstall( intf_thread_t *p_intf )
     SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
     if( handle == NULL )
     {
-        msg_Err( p_intf, "could not connect to SCM database" );
+        msg_Err( p_intf,
+                 "could not connect to Services Control Manager database" );
         return VLC_EGENERIC;
     }
 
@@ -313,7 +318,7 @@ static void WINAPI ServiceDispatch( DWORD numArgs, char **args )
             sprintf( psz_temp, "%s,none", psz_module );
 
             /* Try to create the interface */
-            p_new_intf = intf_Create( p_intf, psz_temp );
+            p_new_intf = intf_Create( p_intf, psz_temp, 0, NULL );
             if( p_new_intf == NULL )
             {
                 msg_Err( p_intf, "interface \"%s\" initialization failed",
@@ -323,7 +328,6 @@ static void WINAPI ServiceDispatch( DWORD numArgs, char **args )
             }
 
             /* Try to run the interface */
-            p_new_intf->b_block = VLC_FALSE;
             if( intf_RunThread( p_new_intf ) )
             {
                 vlc_object_detach( p_new_intf );
@@ -334,10 +338,7 @@ static void WINAPI ServiceDispatch( DWORD numArgs, char **args )
             free( psz_temp );
         }
     }
-    if( psz_modules )
-    {
-        free( psz_modules );
-    }
+    free( psz_modules );
 
     /* Initialization complete - report running status */
     p_sys->status.dwCurrentState = SERVICE_RUNNING;