]> git.sesse.net Git - vlc/blobdiff - modules/demux/nsc.c
Ogg: remove unused function and variable
[vlc] / modules / demux / nsc.c
index af8691a812fedc695d11f8b936080efafea696a4..719c59dc36d012c8dd3dcaebac4b567f9aedbd46 100644 (file)
@@ -1,25 +1,25 @@
 /*****************************************************************************
  * nsc.c: NSC file demux and encoding decoder
  *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
+ * Copyright (C) 2005 VLC authors and VideoLAN
  * $Id$
  *
- * Authors: Jon Lech Johansen <jon@nanocrew.net>
- *          Derk-Jan Hartman <hartman at videolan dot org>
+ * Authors: Derk-Jan Hartman <hartman at videolan dot org>
+ *          based on work from Jon Lech Johansen <jon@nanocrew.net>
  *
- * 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.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -32,7 +32,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_demux.h>
-#include <vlc_playlist.h>
+#include <vlc_charset.h>
 
 #include <ctype.h>
 #define MAX_LINE 16024
 static int  DemuxOpen  ( vlc_object_t * );
 static void DemuxClose ( vlc_object_t * );
 
-vlc_module_begin();
-    set_description( N_("Windows Media NSC metademux") );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_DEMUX );
-    set_capability( "demux", 3 );
-    set_callbacks( DemuxOpen, DemuxClose );
-vlc_module_end();
+vlc_module_begin ()
+    set_description( N_("Windows Media NSC metademux") )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_DEMUX )
+    set_capability( "demux", 3 )
+    set_callbacks( DemuxOpen, DemuxClose )
+vlc_module_end ()
 
 static int Demux ( demux_t *p_demux );
 static int Control( demux_t *p_demux, int i_query, va_list args );
@@ -77,21 +77,21 @@ static int load_byte( unsigned char encoding_type,
 
     if( encoding_type == 1 )
     {
-        if( isxdigit( **input ) == 0 )
+        if( isxdigit( (unsigned char)**input ) == 0 )
             return -1;
 
-        if( isdigit( **input ) == 0 )
-            *output = (toupper( **input ) - 7) * 16;
+        if( isdigit( (unsigned char)**input ) == 0 )
+            *output = (toupper( (unsigned char)**input ) - 7) * 16;
         else
             *output = **input * 16;
 
         (*input)++;
 
-        if( isxdigit( **input ) == 0 )
+        if( isxdigit( (unsigned char)**input ) == 0 )
             return -1;
 
-        if( isdigit( **input ) == 0 )
-            *output |= toupper( **input ) - 0x37;
+        if( isdigit( (unsigned char)**input ) == 0 )
+            *output |= toupper( (unsigned char)**input ) - 0x37;
         else
             *output |= **input - 0x30;
 
@@ -148,13 +148,8 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
     unsigned int length;
     unsigned char encoding_type;
 
-    vlc_iconv_t conv;
-    size_t buf16_size;
     unsigned char *buf16;
-    const char *p_buf16;
-    size_t buf8_size;
     char *buf8;
-    char *p_buf8;
 
     char *p_input = p_encoded;
 
@@ -211,13 +206,9 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
         return NULL;
     }
 
-    buf16_size = length;
-    buf16 = malloc( buf16_size );
+    buf16 = malloc( length );
     if( buf16 == NULL )
-    {
-        msg_Err( p_demux, "out of memory" );
         return NULL;
-    }
 
     for( i = 0; i < length; i++ )
     {
@@ -229,40 +220,13 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
         }
     }
 
-    buf8_size = length;
-    buf8 = malloc( buf8_size + 1 );
+    buf8 = FromCharset( "UTF-16LE", buf16, length );
+    free( buf16 );
     if( buf8 == NULL )
-    {
-        msg_Err( p_demux, "out of memory" );
-        free( buf16 );
-        return NULL;
-    }
-
-    conv = vlc_iconv_open( "UTF-8", "UTF-16LE" );
-    if( conv == (vlc_iconv_t)(-1) )
-    {
-        msg_Err( p_demux, "iconv_open failed" );
-        free( buf16 );
-        free( buf8 );
-        return NULL;
-    }
-
-    p_buf8 = buf8;
-    p_buf16 = (const char *)buf16;
-
-    if( vlc_iconv( conv, &p_buf16, &buf16_size, &p_buf8, &buf8_size ) == (size_t)(-1) )
     {
         msg_Err( p_demux, "iconv failed" );
         return NULL;
     }
-    else
-    {
-        buf8[ length - buf8_size ] = '\0';
-    }
-
-    vlc_iconv_close( conv );
-
-    free( buf16 );
     return buf8;
 }
 
@@ -301,6 +265,7 @@ static int DemuxOpen( vlc_object_t * p_this )
  *****************************************************************************/
 static void DemuxClose( vlc_object_t *p_this )
 {
+    VLC_UNUSED( p_this );
     return;
 }
 
@@ -367,5 +332,7 @@ static int Demux ( demux_t *p_demux )
 
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
+    VLC_UNUSED( p_demux ); VLC_UNUSED( i_query ); VLC_UNUSED( args );
+    //FIXME
     return VLC_EGENERIC;
 }