~pac72/ubuntu/lucid/ddd/devel

« back to all changes in this revision

Viewing changes to libiberty/getcwd.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2004-07-22 03:49:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040722034937-cysl08t1jvba4jrx
Tags: 1:3.3.9-3
USERINFO has been renamed to USERINFO.txt; adjust debian/rules code
to match, to get correct information on the About DDD dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
   This function is in the public domain. */
3
3
 
4
4
/*
5
 
NAME
6
 
        getcwd -- get absolute pathname for current working directory
7
 
 
8
 
SYNOPSIS
9
 
        char *getcwd (char pathname[len], len)
10
 
 
11
 
DESCRIPTION
12
 
        Copy the absolute pathname for the current working directory into
13
 
        the supplied buffer and return a pointer to the buffer.  If the 
14
 
        current directory's path doesn't fit in LEN characters, the result
15
 
        is NULL and errno is set.
16
 
 
17
 
        If pathname is a null pointer, getcwd() will obtain size bytes of
18
 
        space using malloc.
19
 
 
20
 
BUGS
21
 
        Emulated via the getwd() call, which is reasonable for most
22
 
        systems that do not have getcwd().
 
5
 
 
6
@deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len})
 
7
 
 
8
Copy the absolute pathname for the current working directory into
 
9
@var{pathname}, which is assumed to point to a buffer of at least
 
10
@var{len} bytes, and return a pointer to the buffer.  If the current
 
11
directory's path doesn't fit in @var{len} characters, the result is
 
12
@code{NULL} and @code{errno} is set.  If @var{pathname} is a null pointer,
 
13
@code{getcwd} will obtain @var{len} bytes of space using
 
14
@code{malloc}.
 
15
 
 
16
@end deftypefn
23
17
 
24
18
*/
25
19
 
29
23
#include <sys/param.h>
30
24
#endif
31
25
#include <errno.h>
 
26
#ifdef HAVE_STRING_H
 
27
#include <string.h>
 
28
#endif
 
29
#ifdef HAVE_STDLIB_H
 
30
#include <stdlib.h>
 
31
#endif
32
32
 
33
33
extern char *getwd ();
34
34
extern int errno;
40
40
char *
41
41
getcwd (buf, len)
42
42
  char *buf;
43
 
  int len;
 
43
  size_t len;
44
44
{
45
45
  char ourbuf[MAXPATHLEN];
46
46
  char *result;