]>
Commit | Line | Data |
---|---|---|
a18f587d | 1 | /* Obsolete function to get current working directory. |
50304ef0 | 2 | Copyright (C) 1991, 1992, 1996, 1997, 1998 Free Software Foundation, Inc. |
47707456 | 3 | This file is part of the GNU C Library. |
28f540f4 | 4 | |
47707456 UD |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
28f540f4 | 9 | |
47707456 UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Library General Public License for more details. | |
28f540f4 | 14 | |
47707456 UD |
15 | You should have received a copy of the GNU Library General Public |
16 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
28f540f4 | 19 | |
28f540f4 RM |
20 | #include <errno.h> |
21 | #include <limits.h> | |
22 | #include <string.h> | |
23 | #include <unistd.h> | |
24 | ||
a18f587d | 25 | |
28f540f4 | 26 | char * |
df21c858 UD |
27 | getwd (buf) |
28 | char *buf; | |
28f540f4 | 29 | { |
df21c858 UD |
30 | #ifndef PATH_MAX |
31 | #define PATH_MAX 1024 | |
df21c858 | 32 | #endif |
a18f587d | 33 | char tmpbuf[PATH_MAX]; |
df21c858 | 34 | |
28f540f4 RM |
35 | if (buf == NULL) |
36 | { | |
c4029823 | 37 | __set_errno (EINVAL); |
28f540f4 RM |
38 | return NULL; |
39 | } | |
40 | ||
50304ef0 | 41 | if (__getcwd (tmpbuf, PATH_MAX) == NULL) |
28f540f4 | 42 | { |
a18f587d | 43 | /* We use 1024 here since it should really be enough and because |
f65fd747 | 44 | this is a safe value. */ |
a18f587d | 45 | __strerror_r (errno, buf, 1024); |
28f540f4 RM |
46 | return NULL; |
47 | } | |
48 | ||
a18f587d UD |
49 | /* This is completely unsafe. Nobody can say how big the user |
50 | provided buffer is. Perhaps the application and the libc | |
51 | disagree about the value of PATH_MAX. */ | |
61c162b5 | 52 | return strcpy (buf, tmpbuf); |
28f540f4 | 53 | } |
a18f587d UD |
54 | |
55 | link_warning (getwd, | |
56 | "the `getwd' function is dangerous and should not be used.") |