util.c
资源名称:vlc-1.0.5.zip [点击查看]
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:29k
源码类别:
midi
开发平台:
Unix_Linux
- /*****************************************************************************
- * util.c : Utility functions for HTTP interface
- *****************************************************************************
- * Copyright (C) 2001-2005 the VideoLAN team
- * $Id: aee0199cfec637c129fb21e699d8f71cc59533a4 $
- *
- * Authors: Gildas Bazin <gbazin@netcourrier.com>
- * Laurent Aimar <fenrir@via.ecp.fr>
- * Christophe Massiot <massiot@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
- #ifdef HAVE_CONFIG_H
- # include "config.h"
- #endif
- #include <vlc_common.h>
- #include "http.h"
- #include "vlc_strings.h"
- /****************************************************************************
- * File and directory functions
- ****************************************************************************/
- /* ToUrl: create a good name for an url from filename */
- char *FileToUrl( char *name, bool *pb_index )
- {
- char *url, *p;
- url = p = malloc( strlen( name ) + 1 );
- *pb_index = false;
- if( !url || !p )
- {
- return NULL;
- }
- #ifdef WIN32
- while( *name == '\' || *name == '/' )
- #else
- while( *name == '/' )
- #endif
- {
- name++;
- }
- *p++ = '/';
- strcpy( p, name );
- #ifdef WIN32
- /* convert '\' into '/' */
- name = p;
- while( *name )
- {
- if( *name == '\' )
- *name = '/';
- name++;
- }
- #endif
- /* index.* -> / */
- if( ( p = strrchr( url, '/' ) ) != NULL )
- {
- if( !strncmp( p, "/index.", 7 ) )
- {
- p[1] = ' ';
- *pb_index = true;
- }
- }
- return url;
- }
- /* Load a file */
- int FileLoad( FILE *f, char **pp_data, int *pi_data )
- {
- int i_read;
- /* just load the file */
- *pi_data = 0;
- *pp_data = malloc( 1025 ); /* +1 for