1 /* fetch.c - routines for fetching data at URLs */
4 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
6 * Copyright 1999-2004 The OpenLDAP Foundation.
7 * Portions Copyright 1999-2003 Kurt D. Zeilenga.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted only as authorized by the OpenLDAP
14 * A copy of this license is available in the file LICENSE in the
15 * top-level directory of the distribution or, alternatively, at
16 * <http://www.OpenLDAP.org/license.html>.
18 /* This work was initially developed by Kurt D. Zeilenga for
19 * inclusion in OpenLDAP Software.
26 #include <ac/stdlib.h>
28 #include <ac/string.h>
29 #include <ac/socket.h>
39 #include "ldap_config.h"
44 LDAP_CONST char *urlstr,
59 url = fetchGetURL( (char*) urlstr, "" );
62 if( strncasecmp( "file://", urlstr, sizeof("file://")-1 ) == 0 ) {
63 p = strchr( &urlstr[sizeof("file://")-1], '/' );
68 /* we don't check for LDAP_DIRSEP since URLs should contain '/' */
70 /* skip over false root */
75 ldap_pvt_hex_unescape( p );
77 url = fopen( p, "rb" );
90 while( (bytes = fread( buffer, 1, sizeof(buffer), url )) != 0 ) {
91 char *newp = ber_memrealloc( p, total + bytes + 1 );
98 AC_MEMCPY( &p[total], buffer, bytes );
105 char *newp = ber_memrealloc( p, 1 );