]> git.sesse.net Git - vlc/blobdiff - src/extras/libc.c
Clean up vlc_iconv prototype
[vlc] / src / extras / libc.c
index 80dfba9a3ebd4408382b5bbad21be0992b571aec..01a180b2aef295695ed853db5e10618c91b40cbc 100644 (file)
@@ -182,7 +182,7 @@ char * vlc_strcasestr( const char *psz_big, const char *psz_little )
 /*****************************************************************************
  * vasprintf:
  *****************************************************************************/
-#if !defined(HAVE_VASPRINTF) || defined(SYS_DARWIN) || defined(SYS_BEOS)
+#if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
 int vlc_vasprintf(char **strp, const char *fmt, va_list ap)
 {
     /* Guess we need no more than 100 bytes. */
@@ -228,7 +228,7 @@ int vlc_vasprintf(char **strp, const char *fmt, va_list ap)
 /*****************************************************************************
  * asprintf:
  *****************************************************************************/
-#if !defined(HAVE_ASPRINTF) || defined(SYS_DARWIN) || defined(SYS_BEOS)
+#if !defined(HAVE_ASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
 int vlc_asprintf( char **strp, const char *fmt, ... )
 {
     va_list args;
@@ -343,6 +343,19 @@ int64_t vlc_atoll( const char *nptr )
 }
 #endif
 
+/*****************************************************************************
+ * lldiv: returns quotient and remainder
+ *****************************************************************************/
+#if defined(SYS_BEOS)
+lldiv_t vlc_lldiv( long long numer, long long denom )
+{
+    lldiv_t d;
+    d.quot = numer / denom;
+    d.rem  = numer % denom;
+    return d;
+}
+#endif
+
 /*****************************************************************************
  * vlc_*dir_wrapper: wrapper under Windows to return the list of drive letters
  * when called with an empty argument or just '\'
@@ -498,6 +511,7 @@ int vlc_scandir( const char *name, struct dirent ***namelist,
 }
 #endif
 
+#if defined (WIN32) || !defined (HAVE_SHARED_LIBVLC)
 /*****************************************************************************
  * dgettext: gettext for plugins.
  *****************************************************************************/
@@ -510,6 +524,7 @@ char *vlc_dgettext( const char *package, const char *msgid )
     return (char *)msgid;
 #endif
 }
+#endif
 
 /*****************************************************************************
  * count_utf8_string: returns the number of characters in the string.
@@ -529,17 +544,14 @@ static int count_utf8_string( const char *psz_string )
  * wraptext: inserts \n at convenient places to wrap the text.
  *           Returns the modified string in a new buffer.
  *****************************************************************************/
-char *vlc_wraptext( const char *psz_text, int i_line, vlc_bool_t b_utf8 )
+char *vlc_wraptext( const char *psz_text, int i_line )
 {
     int i_len;
     char *psz_line, *psz_new_text;
 
     psz_line = psz_new_text = strdup( psz_text );
 
-    if( b_utf8 )
-        i_len = count_utf8_string( psz_text );
-    else
-        i_len = strlen( psz_text );
+    i_len = count_utf8_string( psz_text );
 
     while( i_len > i_line )
     {
@@ -548,10 +560,7 @@ char *vlc_wraptext( const char *psz_text, int i_line, vlc_bool_t b_utf8 )
         int i_count = 0;
         while( i_count <= i_line && *psz_parser != '\n' )
         {
-            if( b_utf8 )
-            {
-                while( *((unsigned char *)psz_parser) >= 0x80UL ) psz_parser++;
-            }
+            while( *((unsigned char *)psz_parser) >= 0x80UL ) psz_parser++;
             psz_parser++;
             i_count++;
         }
@@ -565,10 +574,7 @@ char *vlc_wraptext( const char *psz_text, int i_line, vlc_bool_t b_utf8 )
         /* Find the furthest space. */
         while( psz_parser > psz_line && *psz_parser != ' ' )
         {
-            if( b_utf8 )
-            {
-                while( *((unsigned char *)psz_parser) >= 0x80UL ) psz_parser--;
-            }
+            while( *((unsigned char *)psz_parser) >= 0x80UL ) psz_parser--;
             psz_parser--;
             i_count--;
         }
@@ -583,10 +589,7 @@ char *vlc_wraptext( const char *psz_text, int i_line, vlc_bool_t b_utf8 )
         /* Wrapping has failed. Find the first space or newline */
         while( i_count < i_len && *psz_parser != ' ' && *psz_parser != '\n' )
         {
-            if( b_utf8 )
-            {
-                while( *((unsigned char *)psz_parser) >= 0x80UL ) psz_parser++;
-            }
+            while( *((unsigned char *)psz_parser) >= 0x80UL ) psz_parser++;
             psz_parser++;
             i_count++;
         }
@@ -610,11 +613,12 @@ vlc_iconv_t vlc_iconv_open( const char *tocode, const char *fromcode )
 #endif
 }
 
-size_t vlc_iconv( vlc_iconv_t cd, char **inbuf, size_t *inbytesleft,
+size_t vlc_iconv( vlc_iconv_t cd, const char **inbuf, size_t *inbytesleft,
                   char **outbuf, size_t *outbytesleft )
 {
 #if defined(HAVE_ICONV)
-    return iconv( cd, inbuf, inbytesleft, outbuf, outbytesleft );
+    return iconv( cd, (ICONV_CONST char **)inbuf, inbytesleft,
+                  outbuf, outbytesleft );
 #else
     int i_bytes;