1*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate /* 4*0Sstevel@tonic-gate * The contents of this file are subject to the Netscape Public 5*0Sstevel@tonic-gate * License Version 1.1 (the "License"); you may not use this file 6*0Sstevel@tonic-gate * except in compliance with the License. You may obtain a copy of 7*0Sstevel@tonic-gate * the License at http://www.mozilla.org/NPL/ 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * Software distributed under the License is distributed on an "AS 10*0Sstevel@tonic-gate * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 11*0Sstevel@tonic-gate * implied. See the License for the specific language governing 12*0Sstevel@tonic-gate * rights and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * The Original Code is Mozilla Communicator client code, released 15*0Sstevel@tonic-gate * March 31, 1998. 16*0Sstevel@tonic-gate * 17*0Sstevel@tonic-gate * The Initial Developer of the Original Code is Netscape 18*0Sstevel@tonic-gate * Communications Corporation. Portions created by Netscape are 19*0Sstevel@tonic-gate * Copyright (C) 1998-1999 Netscape Communications Corporation. All 20*0Sstevel@tonic-gate * Rights Reserved. 21*0Sstevel@tonic-gate * 22*0Sstevel@tonic-gate * Contributor(s): 23*0Sstevel@tonic-gate */ 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate /* 26*0Sstevel@tonic-gate * LDAP tools fileurl.h -- defines for file URL functions. 27*0Sstevel@tonic-gate * Used by ldapmodify. 28*0Sstevel@tonic-gate */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate /* 31*0Sstevel@tonic-gate * ldaptool_fileurl2path() convert a file URL to a local path. 32*0Sstevel@tonic-gate * 33*0Sstevel@tonic-gate * If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *localpathp is 34*0Sstevel@tonic-gate * set point to an allocated string. If not, a different LDAPTOOL_FILEURL_ 35*0Sstevel@tonic-gate * error code is returned. 36*0Sstevel@tonic-gate */ 37*0Sstevel@tonic-gate int ldaptool_fileurl2path( const char *fileurl, char **localpathp ); 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * Convert a local path to a file URL. 42*0Sstevel@tonic-gate * 43*0Sstevel@tonic-gate * If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *urlp is 44*0Sstevel@tonic-gate * set point to an allocated string. If not, a different LDAPTOOL_FILEURL_ 45*0Sstevel@tonic-gate * error code is returned. At present, the only possible error is 46*0Sstevel@tonic-gate * LDAPTOOL_FILEURL_NOMEMORY. 47*0Sstevel@tonic-gate * 48*0Sstevel@tonic-gate */ 49*0Sstevel@tonic-gate int ldaptool_path2fileurl( char *path, char **urlp ); 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate /* 53*0Sstevel@tonic-gate * Populate *bvp from "value" of length "vlen." 54*0Sstevel@tonic-gate * 55*0Sstevel@tonic-gate * If recognize_url_syntax is non-zero, :<fileurl is recognized. 56*0Sstevel@tonic-gate * If always_try_file is recognized and no file URL was found, an 57*0Sstevel@tonic-gate * attempt is made to stat and read the value as if it were the name 58*0Sstevel@tonic-gate * of a file. 59*0Sstevel@tonic-gate * 60*0Sstevel@tonic-gate * If reporterrs is non-zero, specific error messages are printed to 61*0Sstevel@tonic-gate * stderr. 62*0Sstevel@tonic-gate * 63*0Sstevel@tonic-gate * If successful, LDAPTOOL_FILEURL_SUCCESS is returned and bvp->bv_len 64*0Sstevel@tonic-gate * and bvp->bv_val are set (the latter is set to malloc'd memory). 65*0Sstevel@tonic-gate * Upon failure, a different LDAPTOOL_FILEURL_ error code is returned. 66*0Sstevel@tonic-gate */ 67*0Sstevel@tonic-gate int ldaptool_berval_from_ldif_value( const char *value, int vlen, 68*0Sstevel@tonic-gate struct berval *bvp, int recognize_url_syntax, int always_try_file, 69*0Sstevel@tonic-gate int reporterrs ); 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate /* 73*0Sstevel@tonic-gate * Map an LDAPTOOL_FILEURL_ error code to an LDAP error code (crude). 74*0Sstevel@tonic-gate */ 75*0Sstevel@tonic-gate int ldaptool_fileurlerr2ldaperr( int lderr ); 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate /* 79*0Sstevel@tonic-gate * Possible return codes for the functions declared in this file: 80*0Sstevel@tonic-gate */ 81*0Sstevel@tonic-gate #define LDAPTOOL_FILEURL_SUCCESS 0 82*0Sstevel@tonic-gate #define LDAPTOOL_FILEURL_NOTAFILEURL 1 83*0Sstevel@tonic-gate #define LDAPTOOL_FILEURL_MISSINGPATH 2 84*0Sstevel@tonic-gate #define LDAPTOOL_FILEURL_NONLOCAL 3 85*0Sstevel@tonic-gate #define LDAPTOOL_FILEURL_NOMEMORY 4 86*0Sstevel@tonic-gate #define LDAPTOOL_FILEURL_FILEIOERROR 5 87