1N/A/***********************************************************************
1N/A* *
1N/A* This software is part of the ast package *
1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property *
1N/A* and is licensed under the *
1N/A* Common Public License, Version 1.0 *
1N/A* by AT&T Intellectual Property *
1N/A* *
1N/A* A copy of the License is available at *
1N/A* http://www.opensource.org/licenses/cpl1.0.txt *
1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
1N/A* *
1N/A* Information and Software Systems Research *
1N/A* AT&T Research *
1N/A* Florham Park NJ *
1N/A* *
1N/A* Glenn Fowler <gsf@research.att.com> *
1N/A* David Korn <dgk@research.att.com> *
1N/A* Phong Vo <kpv@research.att.com> *
1N/A* *
1N/A***********************************************************************/
1N/A#pragma prototyped
1N/A/*
1N/A * Glenn Fowler
1N/A * AT&T Bell Laboratories
1N/A *
1N/A * return strperm() expression for perm
1N/A */
1N/A
1N/A#include <ast.h>
1N/A#include <ls.h>
1N/A
1N/Achar*
1N/Afmtperm(register int perm)
1N/A{
1N/A register char* s;
1N/A char* buf;
1N/A
1N/A s = buf = fmtbuf(32);
1N/A
1N/A /*
1N/A * u
1N/A */
1N/A
1N/A *s++ = 'u';
1N/A *s++ = '=';
1N/A if (perm & S_ISVTX)
1N/A *s++ = 't';
1N/A if (perm & S_ISUID)
1N/A *s++ = 's';
1N/A if (perm & S_IRUSR)
1N/A *s++ = 'r';
1N/A if (perm & S_IWUSR)
1N/A *s++ = 'w';
1N/A if (perm & S_IXUSR)
1N/A *s++ = 'x';
1N/A if ((perm & (S_ISGID|S_IXGRP)) == S_ISGID)
1N/A *s++ = 'l';
1N/A
1N/A /*
1N/A * g
1N/A */
1N/A
1N/A *s++ = ',';
1N/A *s++ = 'g';
1N/A *s++ = '=';
1N/A if ((perm & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP))
1N/A *s++ = 's';
1N/A if (perm & S_IRGRP)
1N/A *s++ = 'r';
1N/A if (perm & S_IWGRP)
1N/A *s++ = 'w';
1N/A if (perm & S_IXGRP)
1N/A *s++ = 'x';
1N/A
1N/A /*
1N/A * o
1N/A */
1N/A
1N/A *s++ = ',';
1N/A *s++ = 'o';
1N/A *s++ = '=';
1N/A if (perm & S_IROTH)
1N/A *s++ = 'r';
1N/A if (perm & S_IWOTH)
1N/A *s++ = 'w';
1N/A if (perm & S_IXOTH)
1N/A *s++ = 'x';
1N/A *s = 0;
1N/A return buf;
1N/A}