source: trunk/sys/dietlibc/getwd.c @ 333

Last change on this file since 333 was 1, checked in by alain, 7 years ago

First import

File size: 2.2 KB
Line 
1/*
2   This file is part of MutekP.
3   COpied from GLibC
4 
5   MutekP is free software; you can redistribute it and/or modify it
6   under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 2 of the License, or
8   (at your option) any later version.
9 
10   MutekP is distributed in the hope that it will be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with MutekP; if not, write to the Free Software Foundation,
17   Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19   UPMC / LIP6 / SOC (c) 2015
20   Copyright Ghassan Almaless <ghassan.almaless@gmail.com>
21*/
22
23/* Obsolete function to get current working directory.
24   Copyright (C) 1991-2013 Free Software Foundation, Inc.
25   This file is part of the GNU C Library.
26
27   The GNU C Library is free software; you can redistribute it and/or
28   modify it under the terms of the GNU Lesser General Public
29   License as published by the Free Software Foundation; either
30   version 2.1 of the License, or (at your option) any later version.
31
32   The GNU C Library is distributed in the hope that it will be useful,
33   but WITHOUT ANY WARRANTY; without even the implied warranty of
34   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
35   Lesser General Public License for more details.
36
37   You should have received a copy of the GNU Lesser General Public
38   License along with the GNU C Library; if not, see
39   <http://www.gnu.org/licenses/>.  */
40
41#include <errno.h>
42#include <limits.h>
43#include <string.h>
44#include <unistd.h>
45
46
47char *
48getwd (buf)
49     char *buf;
50{
51  char tmpbuf[PATH_MAX];
52
53  if (buf == NULL)
54    {
55      __set_errno (EINVAL);
56      return NULL;
57    }
58
59  if (getcwd (tmpbuf, PATH_MAX) == NULL)
60    {
61      return NULL;
62    }
63
64  /* This is completely unsafe.  Nobody can say how big the user
65     provided buffer is.  Perhaps the application and the libc
66     disagree about the value of PATH_MAX.  */
67  return strcpy (buf, tmpbuf);
68}
69
70/* link_warning (getwd,
71              "the `getwd' function is dangerous and should not be used.")*/
Note: See TracBrowser for help on using the repository browser.