]> git.sesse.net Git - vlc/blobdiff - src/config/chain.c
help: use direct ioctl() rather than spawning stty to get console width
[vlc] / src / config / chain.c
index 027e570c67c6a5b6f11e2f58bf622245f495992b..7d0b71d789c5be7ca3d0c381a2bef9fcc1809550 100644 (file)
@@ -1,26 +1,26 @@
 /*****************************************************************************
  * chain.c : configuration module chain parsing stuff
  *****************************************************************************
- * Copyright (C) 2002-2007 the VideoLAN team
+ * Copyright (C) 2002-2007 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
  *
- * 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
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -175,10 +175,55 @@ static char *ChainGetValue( const char **ppsz_string )
     return psz_value;
 }
 
+/* Parse all name=value[,] elements */
+const char *config_ChainParseOptions( config_chain_t **pp_cfg, const char *psz_opts )
+{
+    config_chain_t **pp_next = pp_cfg;
+    bool first = true;
+    do
+    {
+        if (!first)
+            psz_opts++; /* skip previous delimiter */
+        SKIPSPACE( psz_opts );
+
+        first = false;
+
+        /* Look for the end of the name (,={}_space_) */
+        size_t len = strcspn( psz_opts, "=,{} \t" );
+        if( len == 0 )
+            continue; /* ignore empty parameter */
+
+        /* Append the new parameter */
+        config_chain_t *p_cfg = malloc( sizeof(*p_cfg) );
+        if( !p_cfg )
+            break;
+        p_cfg->psz_name = strndup( psz_opts, len );
+        psz_opts += len;
+        p_cfg->psz_value = NULL;
+        p_cfg->p_next = NULL;
+
+        *pp_next = p_cfg;
+        pp_next = &p_cfg->p_next;
+
+        /* Extract the option value */
+        SKIPSPACE( psz_opts );
+        if( strchr( "={", *psz_opts ) )
+        {
+            p_cfg->psz_value = ChainGetValue( &psz_opts );
+            SKIPSPACE( psz_opts );
+        }
+    }
+    while( !memchr( "}", *psz_opts, 2 ) );
+
+    if( *psz_opts ) psz_opts++; /* skip '}' */;
+    SKIPSPACE( psz_opts );
+
+    return psz_opts;
+}
+
 char *config_ChainCreate( char **ppsz_name, config_chain_t **pp_cfg,
                           const char *psz_chain )
 {
-    config_chain_t **pp_next = pp_cfg;
     size_t len;
 
     *ppsz_name = NULL;
@@ -196,43 +241,7 @@ char *config_ChainCreate( char **ppsz_name, config_chain_t **pp_cfg,
     /* Parse the parameters */
     SKIPSPACE( psz_chain );
     if( *psz_chain == '{' )
-    {
-        /* Parse all name=value[,] elements */
-        do
-        {
-            psz_chain++; /* skip previous delimiter */
-            SKIPSPACE( psz_chain );
-
-            /* Look for the end of the name (,={}_space_) */
-            len = strcspn( psz_chain, "=,{} \t" );
-            if( len == 0 )
-                continue; /* ignore empty parameter */
-
-            /* Append the new parameter */
-            config_chain_t *p_cfg = malloc( sizeof(*p_cfg) );
-            if( !p_cfg )
-                break;
-            p_cfg->psz_name = strndup( psz_chain, len );
-            psz_chain += len;
-            p_cfg->psz_value = NULL;
-            p_cfg->p_next = NULL;
-
-            *pp_next = p_cfg;
-            pp_next = &p_cfg->p_next;
-
-            /* Extract the option value */
-            SKIPSPACE( psz_chain );
-            if( strchr( "={", *psz_chain ) )
-            {
-                p_cfg->psz_value = ChainGetValue( &psz_chain );
-                SKIPSPACE( psz_chain );
-            }
-        }
-        while( !memchr( "}", *psz_chain, 2 ) );
-
-        if( *psz_chain ) psz_chain++; /* skip '}' */;
-        SKIPSPACE( psz_chain );
-    }
+        psz_chain = config_ChainParseOptions( pp_cfg, psz_chain );
 
     if( *psz_chain == ':' )
         return strdup( psz_chain + 1 );
@@ -342,13 +351,6 @@ void config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
                  * modules so i'll do it later */
                 continue;
             }
-            if( p_conf->psz_oldname
-             && !strcmp( p_conf->psz_oldname, name ) )
-            {
-                 psz_name = p_conf->psz_name;
-                 msg_Warn( p_this, "Option %s is obsolete. Use %s instead.",
-                           name, psz_name );
-            }
         }
         /* </Check if the option is deprecated> */