]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libpathconv/rel2abs.3
Mark the repository as being converted to Git.
[FreeBSD/FreeBSD.git] / lib / libpathconv / rel2abs.3
1 .\"
2 .\" Copyright (c) 1997 Shigio Yamaguchi. All rights reserved.
3 .\" Copyright (c) 1999 Tama Communications Corporation. All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd Dec 3, 1997"
29 .Dt REL2ABS 3
30 .Os
31 .Sh NAME
32 .Nm rel2abs
33 .Nd make an absolute path name from a relative path name
34 .Sh SYNOPSIS
35 .Ft "char *"
36 .Fn rel2abs "const char *path" "const char *base" "char *result" "size_t size"
37 .Sh DESCRIPTION
38 The
39 .Fn rel2abs
40 function makes an absolute path name from a relative path name
41 .Fa path
42 based on a directory
43 .Fa base
44 and copies the resulting path name into the memory referenced by
45 .Fa result .
46 The
47 .Fa result
48 argument must refer to a buffer capable of storing at least
49 .Fa size
50 character
51
52 The resulting path name may include symbolic links.
53 .Fn abs2rel
54 doesn't check whether or not any path exists.
55 .Sh "RETURN VALUES"
56 The
57 .Fn rel2abs
58 function returns absolute path name on success.
59 If an error occurs, it returns
60 .Dv NULL .
61 .Sh ERRORS
62 The
63 .Fn rel2abs
64 function may fail and set the external variable
65 .Va errno
66 to indicate the error.
67 .Bl -tag -width Er
68 .It Bq Er EINVAL
69 The
70 .Fa base
71 directory isn't an absolute path name or the
72 .Fa size
73 argument is zero.
74 .It Bq Er ERANGE
75 The
76 .Fa size
77 argument is greater than zero but smaller than the length of the pathname plus 1
78 .Sh EXAMPLE
79     char result[MAXPATHLEN];
80     char *path = rel2abs("../../src/sys", "/usr/local/lib", result, MAXPATHLEN);
81
82 yields:
83
84     path == "/usr/src/sys"
85
86 Similarly,
87
88     path1 = rel2abs("src/sys", "/usr", result, MAXPATHLEN);
89     path2 = rel2abs(".", "/usr/src/sys", result, MAXPATHLEN);
90
91 yields:
92
93     path1 == "/usr/src/sys"
94     path2 == "/usr/src/sys"
95 .Sh "SEE ALSO"
96 .Xr abs2rel 3
97 .Sh AUTHORS
98 Shigio Yamaguchi (shigio@tamacom.com)