X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblutil%2Ffetch.c;h=661bc1e75b164b45cc9be39466a2d942ca1a2fe8;hb=d8eace75a7472731d78f61df01e648e8af8deee5;hp=01ff18320daa5af26afbc354a46101f2d8085d3e;hpb=6c0f8a7cc37009d3d1d3d1f3cde72e7335c114ed;p=openldap diff --git a/libraries/liblutil/fetch.c b/libraries/liblutil/fetch.c index 01ff18320d..661bc1e75b 100644 --- a/libraries/liblutil/fetch.c +++ b/libraries/liblutil/fetch.c @@ -1,9 +1,8 @@ /* fetch.c - routines for fetching data at URLs */ /* $OpenLDAP$ */ -/* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1999-2003 The OpenLDAP Foundation. + * Copyright 1999-2006 The OpenLDAP Foundation. * Portions Copyright 1999-2003 Kurt D. Zeilenga. * All rights reserved. * @@ -39,22 +38,12 @@ #include "ldap_config.h" #include "ldif.h" -int -ldif_fetch_url( - LDAP_CONST char *urlstr, - char **valuep, - ber_len_t *vlenp -) +FILE * +ldif_open_url( + LDAP_CONST char *urlstr ) { FILE *url; - char buffer[1024]; char *p = NULL; - size_t total; - size_t bytes; - - *valuep = NULL; - *vlenp = 0; - #ifdef HAVE_FETCH url = fetchGetURL( (char*) urlstr, "" ); @@ -62,11 +51,11 @@ ldif_fetch_url( if( strncasecmp( "file://", urlstr, sizeof("file://")-1 ) == 0 ) { p = strchr( &urlstr[sizeof("file://")-1], '/' ); if( p == NULL ) { - return -1; + return NULL; } /* we don't check for LDAP_DIRSEP since URLs should contain '/' */ - if( *p != '/' ) { + if( p[1] == '.' && ( p[2] == '/' || ( p[2] == '.' && p[3] == '/' ))) { /* skip over false root */ p++; } @@ -76,10 +65,30 @@ ldif_fetch_url( url = fopen( p, "rb" ); + ber_memfree( p ); } else { - return -1; + return NULL; } #endif + return url; +} + +int +ldif_fetch_url( + LDAP_CONST char *urlstr, + char **valuep, + ber_len_t *vlenp ) +{ + FILE *url; + char buffer[1024]; + char *p = NULL; + size_t total; + size_t bytes; + + *valuep = NULL; + *vlenp = 0; + + url = ldif_open_url( urlstr ); if( url == NULL ) { return -1;