diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-10-06 18:03:12 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-10-06 18:03:12 +0000 |
commit | 632b8e8edd707085a9981b4edec7c38b71199cfd (patch) | |
tree | 5dd123cb7e732abd3e31ff1e322802bfbbf9121e /libmpdemux/open.c | |
parent | a5eea66f78c7b30773399b29563f917a577cb543 (diff) | |
download | mpv-632b8e8edd707085a9981b4edec7c38b71199cfd.tar.bz2 mpv-632b8e8edd707085a9981b4edec7c38b71199cfd.tar.xz |
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
TODO: add libsmb* detection and #define LIBSMBCLIENT to ./configure !
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7631 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/open.c')
-rw-r--r-- | libmpdemux/open.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/libmpdemux/open.c b/libmpdemux/open.c index c0fff43920..5b866e2dee 100644 --- a/libmpdemux/open.c +++ b/libmpdemux/open.c @@ -79,6 +79,44 @@ stream_t* cddb_open(char* dev,char* track); #endif #endif +// Define function about auth the libsmbclient library +// FIXME: I really do not not is this function is properly working + +#ifdef LIBSMBCLIENT + +#include "libsmbclient.h" + +static char smb_password[15]; +static char smb_username[15]; + +static void smb_auth_fn(const char *server, const char *share, + char *workgroup, int wgmaxlen, char *username, int unmaxlen, + char *password, int pwmaxlen) +{ + char temp[128]; + + strcpy(temp, "LAN"); + if (temp[strlen(temp) - 1] == 0x0a) + temp[strlen(temp) - 1] = 0x00; + + if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1); + + strcpy(temp, smb_username); + if (temp[strlen(temp) - 1] == 0x0a) + temp[strlen(temp) - 1] = 0x00; + + if (temp[0]) strncpy(username, temp, unmaxlen - 1); + + strcpy(temp, smb_password); + if (temp[strlen(temp) - 1] == 0x0a) + temp[strlen(temp) - 1] = 0x00; + + if (temp[0]) strncpy(password, temp, pwmaxlen - 1); +} + + +#endif + // Open a new stream (stdin/file/vcd/url) stream_t* open_stream(char* filename,int vcd_track,int* file_format){ @@ -409,6 +447,43 @@ if(dvd_title){ #ifdef STREAMING url = url_new(filename); if(url) { + if (strcmp(url->protocol, "smb")==0){ +#ifdef LIBSMBCLIENT + + // we need init of libsmbclient + int err; + + // FIXME: HACK: make the username/password global varaibles + // so the auth_fn function should grab it ... + // i cannot thing other way... + err = smbc_init(smb_auth_fn, 10); /* Initialize things */ + // libsmbclient using + if (err < 0) { + mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBInitError,err); + return NULL; + } + f=smbc_open(filename, O_RDONLY, 0666); + + // cannot open the file, outputs that + // MSGTR_FileNotFound -> MSGTR_SMBFileNotFound + if(f<0){ + mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBFileNotFound,filename); + return NULL; + } + len=smbc_lseek(f,0,SEEK_END); + smbc_lseek(f,0,SEEK_SET); + // FIXME: I really wonder is such situation -> but who cares ;) +// if (len == -1) +// return new_stream(f,STREAMTYPE_STREAM); // open as stream + url_free(url); + stream=new_stream(f,STREAMTYPE_SMB); + stream->end_pos=len; + return stream; +#else + mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBNotCompiled,filename); + return NULL; +#endif + } stream=new_stream(f,STREAMTYPE_STREAM); if( streaming_start( stream, file_format, url )<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename); |