[Mplayer-cvslog] CVS: main/libmpdemux network.c,1.50,1.51
Bertrand Baudet
bertrand at mplayerhq.hu
Sun Jun 23 11:39:12 CEST 2002
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv13600
Modified Files:
network.c
Log Message:
Improved the authentication interaction. Still need to replace scanf.
After 4 failed authentication, mplayer quits.
Index: network.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/network.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- network.c 23 Jun 2002 09:17:52 -0000 1.50
+++ network.c 23 Jun 2002 09:39:09 -0000 1.51
@@ -341,6 +341,7 @@
unsigned int i;
int fd=-1;
int redirect;
+ int auth_retry=0;
char *extension;
char *content_type;
char *next_url;
@@ -497,29 +498,38 @@
{
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 @@
}
strcpy(url->password, password);
redirect = 1;
+ auth_retry++;
break;
}
default:
More information about the MPlayer-cvslog
mailing list