diff options
author | bertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-06-23 09:39:09 +0000 |
---|---|---|
committer | bertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-06-23 09:39:09 +0000 |
commit | 1e3499e1543e789e284428453603aa31aa50271d (patch) | |
tree | c19a31aac1c08fb243a405d88bd2c29c978f4b72 /libmpdemux | |
parent | 9f6e8b15091302dffb4f526d5a9bf0bc3bfd4fc5 (diff) | |
download | mpv-1e3499e1543e789e284428453603aa31aa50271d.tar.bz2 mpv-1e3499e1543e789e284428453603aa31aa50271d.tar.xz |
Improved the authentication interaction. Still need to replace scanf.
After 4 failed authentication, mplayer quits.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6517 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/network.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/libmpdemux/network.c b/libmpdemux/network.c index 8d7a0ca3cc..c70c6caf4a 100644 --- a/libmpdemux/network.c +++ b/libmpdemux/network.c @@ -341,6 +341,7 @@ autodetectProtocol(streaming_ctrl_t *streaming_ctrl, int *fd_out, int *file_form unsigned int i; int fd=-1; int redirect; + int auth_retry=0; char *extension; char *content_type; char *next_url; @@ -497,29 +498,38 @@ extension=NULL; { char username[50], password[50]; char *aut; + if( auth_retry>3 ) { + mp_msg(MSGT_NETWORK,MSGL_ERR,"Authentication failed\n"); + return -1; + } aut = http_get_field(http_hdr, "WWW-Authenticate"); if( aut!=NULL ) { char *aut_space; aut_space = strstr(aut, "realm="); if( aut_space!=NULL ) aut_space += 6; - mp_msg(MSGT_NETWORK,MSGL_ERR,"Authorization required for %s, please enter:\n", aut_space); + mp_msg(MSGT_NETWORK,MSGL_INFO,"Authorization required for %s, please enter:\n", aut_space); } else { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Authorization required, please enter:\n"); + mp_msg(MSGT_NETWORK,MSGL_INFO,"Authorization required, please enter:\n"); } - mp_msg(MSGT_NETWORK,MSGL_ERR,"username: "); - // FIXME - scanf("%s", username); - printf("%s\n", username); - mp_msg(MSGT_NETWORK,MSGL_ERR,"password: "); + if( url->username==NULL ) { + mp_msg(MSGT_NETWORK,MSGL_INFO,"username: "); + // FIXME + scanf("%s", username); + printf("%s\n", username); + + url->username = (char*)malloc(strlen(username)+1); + if( url->username==NULL ) { + mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n"); + return -1; + } + strcpy(url->username, username); + } else { + mp_msg(MSGT_NETWORK,MSGL_INFO,"%s ", url->username ); + } + mp_msg(MSGT_NETWORK,MSGL_INFO,"password: "); // FIXME scanf("%s", password); printf("%s\n", password); - url->username = (char*)malloc(strlen(username)+1); - if( url->username==NULL ) { - mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n"); - return -1; - } - strcpy(url->username, username); url->password = (char*)malloc(strlen(password)+1); if( url->password==NULL ) { mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n"); @@ -527,6 +537,7 @@ extension=NULL; } strcpy(url->password, password); redirect = 1; + auth_retry++; break; } default: |