]> git.sesse.net Git - vlc/commitdiff
GetNonEmptyString simplification
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 16 Sep 2007 08:29:09 +0000 (08:29 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 16 Sep 2007 08:29:09 +0000 (08:29 +0000)
modules/access/dvb/http.c
modules/access_filter/timeshift.c
modules/control/http/http.c

index 52998011bea19442c0436b24aa8059de30da12d3..cf84027c504085254c30ad324e83df7ee439b08d 100644 (file)
@@ -91,8 +91,8 @@ int E_(HTTPOpen)( access_t *p_access )
     p_sys->b_request_frontend_info = p_sys->b_request_mmi_info = VLC_FALSE;
     p_sys->i_httpd_timeout = 0;
 
-    psz_address = var_GetString( p_access, "dvb-http-host" );
-    if( psz_address != NULL && *psz_address )
+    psz_address = var_GetNonEmptyString( p_access, "dvb-http-host" );
+    if( psz_address != NULL )
     {
         char *psz_parser = strchr( psz_address, ':' );
         if( psz_parser )
@@ -102,14 +102,11 @@ int E_(HTTPOpen)( access_t *p_access )
         }
     }
     else
-    {
-        if ( psz_address != NULL ) free( psz_address );
         return VLC_SUCCESS;
-    }
 
     /* determine SSL configuration */
-    psz_cert = var_GetString( p_access, "dvb-http-intf-cert" );
-    if ( psz_cert != NULL && *psz_cert )
+    psz_cert = var_GetNonEmptyString( p_access, "dvb-http-intf-cert" );
+    if ( psz_cert != NULL )
     {
         msg_Dbg( p_access, "enabling TLS for HTTP interface (cert file: %s)",
                  psz_cert );
@@ -122,11 +119,6 @@ int E_(HTTPOpen)( access_t *p_access )
     }
     else
     {
-        if ( !*psz_cert )
-        {
-            free( psz_cert );
-            psz_cert = NULL;
-        }
         if ( i_port <= 0 )
             i_port= 8082;
     }
@@ -140,10 +132,10 @@ int E_(HTTPOpen)( access_t *p_access )
     p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_access), psz_address,
                                             i_port, psz_cert, psz_key, psz_ca,
                                             psz_crl );
-    FREE( psz_cert );
-    FREE( psz_key );
-    FREE( psz_ca );
-    FREE( psz_crl );
+    free( psz_cert );
+    free( psz_key );
+    free( psz_ca );
+    free( psz_crl );
 
     if ( p_sys->p_httpd_host == NULL )
     {
@@ -175,9 +167,9 @@ int E_(HTTPOpen)( access_t *p_access )
                                psz_user, psz_password, p_acl,
                                HttpCallback, f );
 
-    FREE( psz_user );
-    FREE( psz_password );
-    FREE( psz_acl );
+    free( psz_user );
+    free( psz_password );
+    free( psz_acl );
     if ( p_acl != NULL )
         ACL_Destroy( p_acl );
 
index cd605de7dee411601384080a85c57d1945ceb03b..49c49a353dfd1d29b0316c6ece8a9dc691125838 100644 (file)
@@ -555,15 +555,9 @@ static int Control( access_t *p_access, int i_query, va_list args )
 #endif
 static char *GetTmpFilePath( access_t *p_access )
 {
-    char *psz_dir = var_GetString( p_access, "timeshift-dir" );
+    char *psz_dir = var_GetNonEmptyString( p_access, "timeshift-dir" );
     char *psz_filename_base;
 
-    if( ( psz_dir != NULL ) && ( psz_dir[0] == '\0' ) )
-    {
-        free( psz_dir );
-        psz_dir = NULL;
-    }
-
     if( psz_dir == NULL )
     {
 #ifdef WIN32
index 1f78b66a6a8b154790f1a57509659ee1a4a080dc..d4c780c63ef651a09077dfd349d6f29bffc78543 100644 (file)
@@ -136,12 +136,7 @@ static int Open( vlc_object_t *p_this )
     int           i_port       = 0;
     char          *psz_src;
 
-    var_Create(p_intf->p_libvlc, "http-host", VLC_VAR_STRING );
-    psz_address = var_GetString(p_intf->p_libvlc, "http-host");
-    if( !psz_address || !*psz_address )
-    {
-        psz_address = config_GetPsz( p_intf, "http-host" );
-    }
+    psz_address = var_GetNonEmptyString(p_intf->p_libvlc, "http-host");
     if( psz_address != NULL )
     {
         char *psz_parser = strchr( psz_address, ':' );
@@ -260,9 +255,9 @@ static int Open( vlc_object_t *p_this )
     {
         msg_Dbg( p_intf, "enabling TLS for HTTP interface (cert file: %s)",
                  psz_cert );
-        psz_key = config_GetPsz( p_intf, "http-intf-key" );
-        psz_ca = config_GetPsz( p_intf, "http-intf-ca" );
-        psz_crl = config_GetPsz( p_intf, "http-intf-crl" );
+        psz_key = var_GetNonEmptyString( p_intf, "http-intf-key" );
+        psz_ca = var_GetNonEmptyString( p_intf, "http-intf-ca" );
+        psz_crl = var_GetNonEmptyString( p_intf, "http-intf-crl" );
 
         if( i_port <= 0 )
             i_port = 8443;
@@ -292,6 +287,7 @@ static int Open( vlc_object_t *p_this )
 
         /* Ugly hack to run several HTTP servers on different ports */
         snprintf( psz_tmp, sizeof (psz_tmp), "%s:%d", psz_address, i_port + 1 );
+        var_Create(p_intf->p_libvlc, "http-host", VLC_VAR_STRING );
         var_SetString( p_intf->p_libvlc, "http-host", psz_tmp );
     }
 
@@ -379,11 +375,8 @@ static int Open( vlc_object_t *p_this )
     return VLC_SUCCESS;
 
 failed:
-    if( psz_src ) free( psz_src );
-    if( p_sys->pp_files )
-    {
-        free( p_sys->pp_files );
-    }
+    free( psz_src );
+    free( p_sys->pp_files );
     httpd_HostDelete( p_sys->p_httpd_host );
     free( p_sys->psz_address );
     free( p_sys->psz_html_type );