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