pwd.c revision 39e7390a771e8a17884d4f1558a2a41422b38104
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* UNIX shell
*/
#include "mac.h"
#include <errno.h>
#include <limits.h>
#include "defs.h"
#define DOT '.'
#define NULL 0
#define SLASH '/'
#define PARTLY 2
static void rmslash();
#ifdef __STDC__
extern const char longpwd[];
#else
extern char longpwd[];
#endif
extern char *getcwd();
void
{
unsigned char *pcwd;
unsigned char *pdir;
/* First remove extra /'s */
/* Now remove any .'s */
pdir++;
while(*pdir) /* remove /./ by itself */
{
{
continue;
}
pdir++;
pdir++;
if (*pdir)
pdir++;
}
/* take care of trailing /. */
} else {
}
}
/* Remove extra /'s */
/* Now that the dir is canonicalized, process it */
{
return;
}
{
/* Absolute path */
}
else
{
/* Relative path */
return;
}
while(*dir)
{
{
/* Parent directory, so backup one */
--pcwd;
;
pcwd++;
dir += 2;
{
dir++;
}
continue;
}
{
return;
}
{
{
return;
}
}
if (*dir)
{
{
return;
}
}
}
{
return;
}
--pcwd;
{
/* Remove trailing / */
}
return;
}
void
cwd2()
{
unsigned char *pcwd;
/* check if there are any symbolic links in pathname */
return;
while (*pcwd)
{
char c;
*--pcwd = '\0';
*pcwd = c;
return;
}
*pcwd = c;
if(c)
pcwd++;
}
} else
return;
}
/*
* check if ino's and dev's match; pathname could
* consist of symbolic links with ".."
*/
return;
}
unsigned char *
cwdget()
{
cwd2();
*cwdname = 0;
}
return (cwdname);
}
/*
* Print the current working directory.
*/
void
cwdprint(void)
{
unsigned char *cp;
cwd2();
else
}
}
}
return;
}
/*
* This routine will remove repeated slashes from string.
*/
static void
unsigned char *string;
{
unsigned char *pstring;
while(*pstring)
{
{
/* Remove repeated SLASH's */
continue;
}
pstring++;
}
--pstring;
{
/* Remove trailing / */
}
return;
}