X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fsmb.c;h=a86cb3cb9a10a18775d10e015f02e44cfb3284dc;hb=d8fc0a94ed76c7f4d9e441b28010d997ab9890eb;hp=06e73f014c2aec67e6d3d9b6e8c9b8623b405e93;hpb=81c5ac29fa2e80426c1b1dfcc941a1aabe8bc808;p=vlc diff --git a/modules/access/smb.c b/modules/access/smb.c index 06e73f014c..a86cb3cb9a 100644 --- a/modules/access/smb.c +++ b/modules/access/smb.c @@ -24,7 +24,6 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#define _GNU_SOURCE #include @@ -110,8 +109,8 @@ struct access_sys_t static void Win32AddConnection( access_t *, char *, char *, char *, char * ); #endif -void smb_auth( const char *srv, const char *shr, char *wg, int wglen, - char *un, int unlen, char *pw, int pwlen ) +static void smb_auth( const char *srv, const char *shr, char *wg, int wglen, + char *un, int unlen, char *pw, int pwlen ) { //wglen = unlen = pwlen = 0; } @@ -221,16 +220,16 @@ static int Open( vlc_object_t *p_this ) if( !smbc_init_context( p_smb ) ) { - msg_Err( p_access, "cannot initialize context (%s)", strerror(errno) ); + msg_Err( p_access, "cannot initialize context (%m)" ); smbc_free_context( p_smb, 1 ); free( psz_uri ); return VLC_EGENERIC; } - if( !(p_file = p_smb->open( p_smb, psz_uri, O_RDONLY, 0 )) ) + if( !(p_file = (p_smb->open)( p_smb, psz_uri, O_RDONLY, 0 )) ) { - msg_Err( p_access, "open failed for '%s' (%s)", - p_access->psz_path, strerror(errno) ); + msg_Err( p_access, "open failed for '%s' (%m)", + p_access->psz_path ); smbc_free_context( p_smb, 1 ); free( psz_uri ); return VLC_EGENERIC; @@ -240,7 +239,7 @@ static int Open( vlc_object_t *p_this ) STANDARD_READ_ACCESS_INIT; i_ret = p_smb->fstat( p_smb, p_file, &filestat ); - if( i_ret ) msg_Err( p_access, "stat failed (%s)", strerror(errno) ); + if( i_ret ) msg_Err( p_access, "stat failed (%m)" ); else p_access->info.i_size = filestat.st_size; #else @@ -252,10 +251,18 @@ static int Open( vlc_object_t *p_this ) } #endif +/* +** some version of glibc defines open as a macro, causing havoc +** with other macros using 'open' under the hood, such as the +** following one: +*/ +#if defined(smbc_open) && defined(open) +# undef open +#endif if( (i_smb = smbc_open( psz_uri, O_RDONLY, 0 )) < 0 ) { - msg_Err( p_access, "open failed for '%s' (%s)", - p_access->psz_path, strerror(errno) ); + msg_Err( p_access, "open failed for '%s' (%m)", + p_access->psz_path ); free( psz_uri ); return VLC_EGENERIC; } @@ -264,7 +271,11 @@ static int Open( vlc_object_t *p_this ) STANDARD_READ_ACCESS_INIT; i_ret = smbc_fstat( i_smb, &filestat ); - if( i_ret ) msg_Err( p_access, "stat failed (%s)", strerror(i_ret) ); + if( i_ret ) + { + errno = i_ret; + msg_Err( p_access, "stat failed (%m)" ); + } else p_access->info.i_size = filestat.st_size; #endif @@ -324,7 +335,7 @@ static int Seek( access_t *p_access, int64_t i_pos ) #endif if( i_ret == -1 ) { - msg_Err( p_access, "seek failed (%s)", strerror(errno) ); + msg_Err( p_access, "seek failed (%m)" ); return VLC_EGENERIC; } @@ -351,7 +362,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) #endif if( i_read < 0 ) { - msg_Err( p_access, "read failed (%s)", strerror(errno) ); + msg_Err( p_access, "read failed (%m)" ); return -1; } @@ -407,6 +418,7 @@ static int Control( access_t *p_access, int i_query, va_list args ) case ACCESS_SET_TITLE: case ACCESS_SET_SEEKPOINT: case ACCESS_SET_PRIVATE_ID_STATE: + case ACCESS_GET_CONTENT_TYPE: return VLC_EGENERIC; default: @@ -467,7 +479,7 @@ static void Win32AddConnection( access_t *p_access, char *psz_path, { msg_Dbg( p_access, "connected to %s", psz_remote ); } - else if( i_result != ERROR_ALREADY_ASSIGNED && + else if( i_result != ERROR_ALREADY_ASSIGNED && i_result != ERROR_DEVICE_ALREADY_REMEMBERED ) { msg_Dbg( p_access, "already connected to %s", psz_remote );