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