1N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 1N/A * Use is subject to license terms. 1N/A * The contents of this file are subject to the Netscape Public 1N/A * License Version 1.1 (the "License"); you may not use this file 1N/A * except in compliance with the License. You may obtain a copy of 1N/A * Software distributed under the License is distributed on an "AS 1N/A * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 1N/A * implied. See the License for the specific language governing 1N/A * rights and limitations under the License. 1N/A * The Original Code is Mozilla Communicator client code, released 1N/A * The Initial Developer of the Original Code is Netscape 1N/A * Communications Corporation. Portions created by Netscape are 1N/A * Copyright (C) 1998-1999 Netscape Communications Corporation. All 1N/A * Used by ldapmodify. 1N/A#
endif /* SOLARIS_LDAP_CMD */ 1N/A * Convert a file URL to a local path. 1N/A * If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *localpathp is 1N/A * set point to an allocated string. If not, an different LDAPTOOL_FILEURL_ 1N/A * error code is returned. 1N/A * See RFCs 1738 and 2396 for a specification for file URLs... but 1N/A * Netscape Navigator seems to be a bit more lenient in what it will 1N/A * accept, especially on Windows). 1N/A * This function parses file URLs of these three forms: 1N/A * On Windows, we convert leading drive letters of the form C| to C: 1N/A * and if a drive letter is present we strip off the slash that precedes 1N/A * path. Otherwise, the leading slash is returned. 1N/A * Make sure this is a file URL we can handle. 1N/A ++
path;
/* skip past '/' at end of "file:/" */ 1N/A * Make sure it is for the local host. 1N/A }
else {
/* URL is of the form file:/path */ 1N/A * The remainder is now of the form /path. On Windows, skip past the 1N/A * leading slash if a drive letter is present. 1N/A#
endif /* _WINDOWS */ 1N/A * Duplicate the path so we can safely alter it. 1N/A * Unescape any %HH sequences. 1N/A * Convert forward slashes to backslashes for Windows. Also, 1N/A * if we see a drive letter / vertical bar combination (e.g., c|) 1N/A * at the beginning of the path, replace the '|' with a ':'. 1N/A#
endif /* _WINDOWS */ 1N/A * Convert a local path to a file URL. 1N/A * If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *urlp is 1N/A * set point to an allocated string. If not, an different LDAPTOOL_FILEURL_ 1N/A * error code is returned. At present, the only possible error is 1N/A * LDAPTOOL_FILEURL_NOMEMORY. 1N/A * This function produces file URLs of the form file:path. 1N/A * On Windows, we convert leading drive letters to C|. 1N/A * Allocate space for the URL, taking into account that path may 1N/A * expand during the hex escaping process. 1N/A * On Windows, convert leading drive letters (e.g., C:) to the correct URL 1N/A * syntax (e.g., C|). 1N/A#
endif /* _WINDOWS */ 1N/A * Append the path, encoding any URL-special characters using the %HH 1N/A * On Windows, convert backwards slashes in the path to forward ones. 1N/A * Populate *bvp from "value" of length "vlen." 1N/A * If recognize_url_syntax is non-zero, :<fileurl is recognized. 1N/A * If always_try_file is recognized and no file URL was found, an 1N/A * attempt is made to stat and read the value as if it were the name 1N/A * If reporterrs is non-zero, specific error messages are printed to 1N/A * If successful, LDAPTOOL_FILEURL_SUCCESS is returned and bvp->bv_len 1N/A * and bvp->bv_val are set (the latter is set to malloc'd memory). 1N/A * Upon failure, a different LDAPTOOL_FILEURL_ error code is returned. 1N/A /* recognize "attr :< url" syntax if LDIF version is >= 1 */ 1N/A * We only support file:// URLs for now. 1N/A gettext(
"%s: unable to process URL \"%s\" -- only" 1N/A " local file:// URLs are supported.\n"),
1N/A * Map an LDAPTOOL_FILEURL_ error code to an LDAP error code (crude). 1N/A * Populate *bvp with the contents of the file named by "path". 1N/A * If reporterrs is non-zero, specific error messages are printed to 1N/A * If successful, LDAPTOOL_FILEURL_SUCCESS is returned and bvp->bv_len 1N/A * and bvp->bv_val are set (the latter is set to malloc'd memory). 1N/A * Upon failure, a different LDAPTOOL_FILEURL_ error code is returned. 1N/A#
endif /* SOLARIS_LDAP_CMD */ 1N/A * Return a non-zero value if the string s begins with prefix and zero if not. 1N/A * Remove URL hex escapes from s... done in place. The basic concept for 1N/A * this routine is borrowed from the WWW library HTUnEscape() routine. 1N/A * A similar function called nsldapi_hex_unescape can be found in 1N/A for ( p = s; *s !=
'\0'; ++s ) {
1N/A if ( *++s !=
'\0' ) {
1N/A if ( *++s !=
'\0' ) {
1N/A * Return the integer equivalent of one hex digit (in c). 1N/A return( c >=
'0' && c <=
'9' ? c -
'0' 1N/A : c >=
'A' && c <=
'F' ? c -
'A' +
10 1N/A ( c >=
'@' && c <=
'Z' ) || \
1N/A ( c >=
'a' && c <=
'z' ))
1N/A * Like strcat(), except if any URL-special characters are found in s2 1N/A * they are escaped using the %HH convention and backslash characters are 1N/A * converted to forward slashes on Windows. 1N/A * Maximum space needed in s1 is 3 * strlen( s2 ) + 1. 1N/A * A similar function that does not convert the slashes called 1N/A for ( q =
s2; *q !=
'\0'; ++q ) {
1N/A#
endif /* _WINDOWS */ 1N/A *p++ =
hexdig[
0x0F & ((*(
unsigned char*)q) >>
4) ];