14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 78462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * Phong Vo <kpv@research.att.com> * 204887Schin * * 214887Schin ***********************************************************************/ 224887Schin #pragma prototyped 234887Schin /* 244887Schin * Glenn Fowler 254887Schin * AT&T Bell Laboratories 264887Schin * 274887Schin * mode_t representation support 284887Schin */ 294887Schin 304887Schin #include "modelib.h" 314887Schin 324887Schin /* 334887Schin * convert internal mode to external 344887Schin */ 354887Schin 364887Schin #undef modex 374887Schin 384887Schin int modex(register int i)394887Schinmodex(register int i) 404887Schin { 414887Schin #if _S_IDPERM && _S_IDTYPE 424887Schin return(i); 434887Schin #else 444887Schin register int x; 454887Schin register int c; 464887Schin 474887Schin x = 0; 484887Schin #if _S_IDPERM 494887Schin x |= (i & 07777); 504887Schin #else 514887Schin for (c = 0; c < PERMLEN; c++) 524887Schin if (i & permmap[c++]) 534887Schin x |= permmap[c]; 544887Schin #endif 554887Schin #if _S_IDTYPE 564887Schin x |= (i & X_IFMT); 574887Schin #else 584887Schin if (S_ISREG(i)) x |= X_IFREG; 594887Schin else if (S_ISDIR(i)) x |= X_IFDIR; 604887Schin #ifdef S_ISLNK 614887Schin else if (S_ISLNK(i)) x |= X_IFLNK; 624887Schin #endif 634887Schin else if (S_ISBLK(i)) x |= X_IFBLK; 644887Schin else if (S_ISCHR(i)) x |= X_IFCHR; 654887Schin #ifdef S_ISCTG 664887Schin else if (S_ISCTG(i)) x |= X_IFCTG; 674887Schin #endif 684887Schin else if (S_ISFIFO(i)) x |= X_IFIFO; 694887Schin #ifdef S_ISSOCK 704887Schin else if (S_ISSOCK(i)) x |= X_IFSOCK; 714887Schin #endif 724887Schin #endif 734887Schin return(x); 744887Schin #endif 754887Schin } 76