/* filemode.c -- make a string describing file modes
Copyright (C) 1985, 1990, 1993, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
+ the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
\f
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
#include <sys/types.h>
#include <sys/stat.h>
#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
-void mode_string ();
-static char ftypelet ();
-static void rwx ();
-static void setst ();
+void mode_string (short unsigned int mode, char *str);
+static char ftypelet (long int bits);
+static void rwx (short unsigned int bits, char *chars);
+static void setst (short unsigned int bits, char *chars);
/* filemodestring - fill in string STR with an ls-style ASCII
representation of the st_mode field of file stats block STATP.
'T' if the file is sticky but not executable. */
void
-filemodestring (statp, str)
- struct stat *statp;
- char *str;
+filemodestring (struct stat *statp, char *str)
{
mode_string (statp->st_mode, str);
}
is given as an argument. */
void
-mode_string (mode, str)
- unsigned short mode;
- char *str;
+mode_string (short unsigned int mode, char *str)
{
str[0] = ftypelet ((long) mode);
rwx ((mode & 0700) << 0, &str[1]);
'?' for any other file type. */
static char
-ftypelet (bits)
- long bits;
+ftypelet (long int bits)
{
#ifdef S_ISBLK
if (S_ISBLK (bits))
flags in CHARS accordingly. */
static void
-rwx (bits, chars)
- unsigned short bits;
- char *chars;
+rwx (short unsigned int bits, char *chars)
{
chars[0] = (bits & S_IRUSR) ? 'r' : '-';
chars[1] = (bits & S_IWUSR) ? 'w' : '-';
according to the file mode BITS. */
static void
-setst (bits, chars)
- unsigned short bits;
- char *chars;
+setst (short unsigned int bits, char *chars)
{
#ifdef S_ISUID
if (bits & S_ISUID)