*****************************************************************************
* 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$
*
{
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 );
}
-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 );
}
-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 strdup (".");
- }
}
-
- return psz_return_value;
}
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 );
+ strncpy( psz_path_head, psz_path, i_characters_until_last_slash + 1 );
/* terminate the resulting string with '\0' */
*(psz_path_head +
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;
*****************************************************************************
* 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$
*
#include <vlc_common.h>
-/* Specialise boolean definitions to VLC's boolean types */
-typedef bool XURL_Bool;
-#define XURL_FALSE false
-#define XURL_TRUE true
-
/* Use DOS/Windows path separators? */
#ifdef WIN32
# define XURL_WIN32_PATHING
/* Debugging */
#undef XURL_DEBUG
-char * XURL_Join ( char *psz_url1, char *psz_url2 );
-char * XURL_Concat ( char *psz_url, char *psz_append );
+char* XURL_Join ( char *psz_url1, char *psz_url2 );
+char* XURL_Concat ( char *psz_url, char *psz_append );
-XURL_Bool XURL_IsAbsolute ( char *psz_url );
-XURL_Bool XURL_HasAbsolutePath ( char *psz_url );
-XURL_Bool XURL_IsFileURL ( char *psz_url );
-XURL_Bool XURL_HasFragment ( char *psz_url );
+bool XURL_IsAbsolute ( char *psz_url );
+bool XURL_HasAbsolutePath ( char *psz_url );
+bool XURL_IsFileURL ( char *psz_url );
+bool XURL_HasFragment ( char *psz_url );
-char * XURL_GetHostname ( char *psz_url );
-char * XURL_GetSchemeAndHostname ( char *psz_url );
-char * XURL_GetScheme ( char *psz_url );
-char * XURL_GetPath ( char *psz_url );
-char * XURL_GetWithoutFragment ( char *psz_url );
+char* XURL_GetHostname ( char *psz_url );
+char* XURL_GetSchemeAndHostname ( char *psz_url );
+char* XURL_GetScheme ( char *psz_url );
+char* XURL_GetPath ( char *psz_url );
+char* XURL_GetWithoutFragment ( char *psz_url );
-char * XURL_GetHead ( const char *psz_path );
+char* XURL_GetHead ( const char *psz_path );
#endif /* __XURL_H__ */