*****************************************************************************
* Copyright (C) 2003-2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004-2008 the VideoLAN team
*
* $Id$
*
static char *streallocat( char *psz_string, const char *psz_to_append );
-#ifndef HAVE_STRDUP
-static char *xurl_strdup( const char *psz_string );
-#else
-#define xurl_strdup strdup
-#endif
-
char *XURL_FindQuery ( char *psz_url );
static char *XURL_FindHostname ( char *psz_url );
static char *XURL_FindPath ( char *psz_url );
{
char *psz_return_value = NULL;
- if( XURL_IsAbsolute( psz_append ) == XURL_TRUE )
+ if( XURL_IsAbsolute( psz_append ) )
return strdup( psz_append );
if( XURL_IsAbsolute( psz_url ) )
else
{
/* not an absolute URL */
- if( XURL_HasAbsolutePath( psz_append ) == XURL_FALSE )
+ if( XURL_HasAbsolutePath( psz_append ) == false )
{
char *psz_new_url = XURL_GetHead( psz_url );
else
{
/* URL to append has an absolute path -- just use that instead */
- psz_return_value = xurl_strdup( psz_append );
+ psz_return_value = strdup( psz_append );
}
}
}
-XURL_Bool XURL_IsAbsolute( char *psz_url )
+bool XURL_IsAbsolute( char *psz_url )
{
if( XURL_FindHostname( psz_url ) == NULL )
{
#ifdef XURL_DEBUG
fprintf( stderr, "XURL_IsAbsolute(%s) returning false\n", psz_url );
#endif
- return XURL_FALSE;
+ return false;
}
else
{
#ifdef XURL_DEBUG
fprintf( stderr, "XURL_IsAbsolute(%s) returning true\n", psz_url );
#endif
- return XURL_TRUE;
+ return true;
}
}
-XURL_Bool XURL_HasFragment( char *psz_url )
+bool XURL_HasFragment( char *psz_url )
{
if( XURL_FindFragment( psz_url ) == NULL )
- return XURL_FALSE;
+ return false;
else
- return XURL_TRUE;
+ return true;
}
if( psz_scheme_separator != NULL)
{
char *psz_hostname = psz_scheme_separator + strlen( "://" );
- if( *psz_hostname != '\0') psz_return_value = psz_hostname;
+ if( *psz_hostname != '\0')
+ psz_return_value = psz_hostname;
#ifdef XURL_DEBUG
fprintf( stderr, "XURL_FindHostname(%s): returning \"%s\"\n",
}
-XURL_Bool XURL_HasAbsolutePath( char *psz_url )
+bool XURL_HasAbsolutePath( char *psz_url )
{
#ifdef XURL_WIN32_PATHING
if( psz_url[0] == '/' || psz_url[0] == '\\' )
#else
if( psz_url[0] == '/' )
#endif
- return XURL_TRUE;
+ return true;
else
- return XURL_FALSE;
+ return false;
}
/* Copy hostname to a new string */
psz_new_hostname = malloc( i_hostname_length );
- if (psz_new_hostname == NULL) return NULL;
+ if( psz_new_hostname == NULL )
+ return NULL;
strncpy( psz_new_hostname, psz_hostname, i_hostname_length );
#ifdef XURL_DEBUG
return psz_scheme_and_hostname;
}
-static
-char *XURL_FindFragment( char *psz_url )
+static char *XURL_FindFragment( char *psz_url )
{
char *pc_hash = NULL;
char *pc_return_value = NULL;
pc_hash = strchr( psz_url, '#' );
if( pc_hash != NULL )
- {
pc_return_value = pc_hash;
- }
return pc_return_value;
}
pc_question_mark = strchr( psz_url, '?' );
if( pc_question_mark != NULL )
- {
pc_return_value = pc_question_mark;
- }
return pc_return_value;
}
size_t i_scheme_length;
char *new_scheme;
- if( XURL_IsAbsolute( psz_url ) == XURL_FALSE )
+ if( XURL_IsAbsolute( psz_url ) == false )
return strdup( "file" );
/* this strchr will always succeed since we have an absolute URL, and thus
}
-XURL_Bool XURL_IsFileURL( char *psz_url )
+bool XURL_IsFileURL( char *psz_url )
{
- XURL_Bool b_return_value;
+ bool b_return_value;
char *psz_scheme = XURL_GetScheme( psz_url );
if( strcasecmp( psz_scheme, "file" ) == 0 )
- b_return_value = XURL_TRUE;
+ b_return_value = true;
else
- b_return_value = XURL_FALSE;
+ b_return_value = false;
free( psz_scheme );
return b_return_value;
}
-#ifndef HAVE_STRDUP
-static
-char *xurl_strdup( const char *psz_string )
-{
- size_t i_length;
- char *psz_new_string;
-
- if( !psz_string ) return NULL;
-
- i_length = strlen( psz_string ) + 1;
- psz_new_string = (char *) malloc( i_length );
- if( psz_new_string == NULL ) return NULL;
-
- memcpy( psz_new_string, psz_string, i_length );
-
- return psz_new_string;
-}
-#endif
-static
-char *XURL_FindPath( char *psz_url )
+static char *XURL_FindPath( char *psz_url )
{
- char *psz_return_value = NULL;
-
- if( XURL_IsAbsolute( psz_url ) == XURL_TRUE )
+ if( XURL_IsAbsolute( psz_url ) )
{
char *psz_start_of_hostname = XURL_FindHostname( psz_url );
if( psz_start_of_hostname != NULL )
- {
- char *psz_start_of_path = strchr( psz_start_of_hostname, '/' );
- psz_return_value = psz_start_of_path;
- }
+ return strchr( psz_start_of_hostname, '/' );
+ else
+ return NULL;
}
else
{
- if( XURL_HasAbsolutePath( psz_url ) == XURL_TRUE )
- {
- psz_return_value = psz_url;
- }
+ if( XURL_HasAbsolutePath( psz_url ) == true )
+ return psz_url;
else
- {
- return xurl_strdup (".");
- }
+ return strdup (".");
}
-
- return psz_return_value;
}
char *pc_question_mark = NULL;
char *pc_fragment = NULL;
- psz_path = xurl_strdup( XURL_FindPath( psz_url ) );
+ psz_path = strdup( XURL_FindPath( psz_url ) );
#ifdef XURL_DEBUG
fprintf( stderr, "XURL_GetPath: XURL_FindPath returning \"%s\"\n",
psz_path );
#endif
if( pc_last_slash == NULL )
{
- psz_path_head = xurl_strdup( psz_path );
+ psz_path_head = strdup( psz_path );
}
else
{
size_t i_characters_until_last_slash;
i_characters_until_last_slash = pc_last_slash - psz_path;
- psz_path_head = malloc(
- ( i_characters_until_last_slash + 1 ) * sizeof(char) );
- (void) strncpy( psz_path_head, psz_path,
- i_characters_until_last_slash + 1 );
+ psz_path_head = malloc( i_characters_until_last_slash + 1 );
+ strncpy( psz_path_head, psz_path, i_characters_until_last_slash + 1 );
/* terminate the resulting string with '\0' */
*(psz_path_head +
psz_fragment = XURL_FindFragment( psz_url );
if( psz_fragment == NULL )
{
- psz_return_value = xurl_strdup( psz_url );
+ psz_return_value = strdup( psz_url );
}
else
{
return psz_return_value;
}
-static
-char *streallocat( char *psz_string, const char *psz_to_append )
+static char *streallocat( char *psz_string, const char *psz_to_append )
{
size_t i_new_string_length = strlen( psz_string ) +
strlen( psz_to_append ) + 1;