Back to index

cell-binutils  2.17cvs20070401
Defines | Functions | Variables
getcwd.c File Reference
#include "config.h"
#include <errno.h>

Go to the source code of this file.

Defines

#define MAXPATHLEN   1024

Functions

char * getwd ()
char * getcwd (char *buf, size_t len)

Variables

int errno

Define Documentation

#define MAXPATHLEN   1024

Definition at line 37 of file getcwd.c.


Function Documentation

char* getcwd ( char *  buf,
size_t  len 
)

Definition at line 41 of file getcwd.c.

{
  char ourbuf[MAXPATHLEN];
  char *result;

  result = getwd (ourbuf);
  if (result) {
    if (strlen (ourbuf) >= len) {
      errno = ERANGE;
      return 0;
    }
    if (!buf) {
       buf = (char*)malloc(len);
       if (!buf) {
           errno = ENOMEM;
          return 0;
       }
    }
    strcpy (buf, ourbuf);
  }
  return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* getwd ( )

Variable Documentation