Commit 1955153b authored by Laurent Aimar's avatar Laurent Aimar

* src/misc/net.c: fixed net_Gets

parent 879d9fc3
......@@ -2,7 +2,7 @@
* network.h: interface to communicate with network plug-ins
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: network.h,v 1.6 2004/01/05 14:10:58 fenrir Exp $
* $Id: network.h,v 1.7 2004/01/06 23:03:16 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
......@@ -64,7 +64,7 @@ typedef struct
*****************************************************************************
* option : if != 0 then path is split at this char
*
* format protocol://host[:port]/path[OPTIONoption]
* format [protocol://][host[:port]]/path[OPTIONoption]
*****************************************************************************/
static inline void vlc_UrlParse( vlc_url_t *url, char *psz_url, char option )
{
......@@ -78,9 +78,7 @@ static inline void vlc_UrlParse( vlc_url_t *url, char *psz_url, char option )
url->psz_path = NULL;
url->psz_option = NULL;
p = strchr( psz_dup, ':' );
if( p )
if( ( p = strstr( psz_parse, ":/" ) ) )
{
/* we have a protocol */
......@@ -93,27 +91,29 @@ static inline void vlc_UrlParse( vlc_url_t *url, char *psz_url, char option )
url->psz_protocol = strdup( psz_dup );
psz_parse = p;
}
p = strchr( psz_parse, '/' );
if( !p || psz_parse < p )
{
char *p2;
/* We have a host[:port] */
url->psz_host = strdup( psz_parse );
if( p )
{
url->psz_host[p - psz_parse] = '\0';
}
p = strchr( psz_parse, '/' );
if( !p || psz_parse < p )
{
char *p2;
p2 = strchr( url->psz_host, ':' );
if( p2 )
{
*p2++ = '\0';
url->i_port = atoi( p2 );
}
/* We have a host[:port] */
url->psz_host = strdup( psz_parse );
if( p )
{
url->psz_host[p - psz_parse] = '\0';
}
p2 = strchr( url->psz_host, ':' );
if( p2 )
{
*p2++ = '\0';
url->i_port = atoi( p2 );
}
}
if( p )
{
psz_parse = p;
}
......
......@@ -2,7 +2,7 @@
* net.c:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: net.c,v 1.1 2004/01/05 14:10:58 fenrir Exp $
* $Id: net.c,v 1.2 2004/01/06 23:03:17 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@videolan.org>
*
......@@ -283,16 +283,18 @@ char *__net_Gets( vlc_object_t *p_this, int fd )
{
if( net_Read( p_this, fd, &psz_line[i_line], 1, VLC_TRUE ) != 1 )
{
psz_line[i_line] = '\0';
break;
}
if( psz_line[i_line] == '\n' || psz_line[i_line] == '\r' )
i_line++;
if( psz_line[i_line-1] == '\n' )
{
psz_line[i_line] = '\0';
break;
}
i_line++;
if( i_line >= i_max )
if( i_line >= i_max - 1 )
{
i_max += 1024;
psz_line = realloc( psz_line, i_max );
......@@ -305,11 +307,11 @@ char *__net_Gets( vlc_object_t *p_this, int fd )
return NULL;
}
while( i_line >= 0 &&
( psz_line[i_line] == '\n' || psz_line[i_line] == '\r' ) )
while( i_line >= 1 &&
( psz_line[i_line-1] == '\n' || psz_line[i_line-1] == '\r' ) )
{
psz_line[i_line] = '\0';
i_line--;
psz_line[i_line] = '\0';
}
return psz_line;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment