/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* pwd library support
*/
#include <ast.h>
#if _WINIX
#else
#if defined(SYSGETCWD)
#include <error.h>
char*
{
size_t n;
size_t r;
int oerrno;
if (buf)
n = PATH_MAX;
for (;;)
{
{
break;
}
{
return 0;
}
n += PATH_MAX / 4;
}
return buf;
}
#else
#include <ast_dir.h>
#include <error.h>
#include <fs3d.h>
#ifndef ERANGE
#endif
struct dirlist /* long path chdir(2) component */
{
int index; /* index from end of buf */
};
/*
* pop long dir component chdir stack
*/
static int
{
int v;
v = 0;
while (dp = d)
{
d = d->next;
if (!v)
{
}
}
return v;
}
/*
* push long dir component onto stack
*/
static struct dirlist*
{
register struct dirlist* p;
{
if (p) free(p);
return 0;
}
p->next = d;
return p;
}
/*
* return a pointer to the absolute path name of .
* this path name may be longer than PATH_MAX
*
* a few environment variables are checked before the search algorithm
* return value is placed in buf of len chars
* if buf is 0 then space is allocated via malloc() with
* len extra chars after the path name
* 0 is returned on error with errno set as appropriate
*/
char*
{
register char* d;
register char* p;
register char* s;
int n;
int x;
static struct
{
char* name;
char* path;
} env[] =
{
{ /*previous*/0 },
{ "PWD" },
{ "HOME" },
};
if (fs3d(FS3D_TEST) && (namlen = mount(".", dots, FS3D_GET|FS3D_VIEW|FS3D_SIZE(sizeof(dots)), NiL)) > 1 && namlen < sizeof(dots))
{
p = dots;
easy:
namlen++;
if (buf)
{
}
}
for (n = 0; n < elementsof(env); n++)
{
{
{
goto easy;
}
}
}
if (!buf)
{
}
d = dots;
*p = 0;
n = elementsof(env);
for (;;)
{
{
d = dots;
}
*d++ = '.';
*d++ = '.';
*d = 0;
#if !_dir_ok || _mem_dd_fd_DIR
#else
#endif
*d++ = '/';
{
{
*--p = '/';
pop:
if (p != buf)
{
d = buf;
while (*d++ = *p++);
}
{
dirstk = 0;
}
return buf;
}
#ifdef D_FILENO
{
goto found;
}
#endif
/*
* this fallthrough handles logical naming
*/
}
do
{
{
*d = 0;
d = dots + 3;
}
if (*p) *--p = '/';
{
}
if (n < elementsof(env))
{
goto pop;
}
dirp = 0;
for (n = 0; n < elementsof(env); n++)
{
goto found;
}
}
if (buf)
{
}
return 0;
}
#endif
#endif