.
[gnulib.git] / lib / filemode.c
index 838f49a..91373de 100644 (file)
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 \f
 #ifdef HAVE_CONFIG_H
-#if defined (emacs) || defined (CONFIG_BROKETS)
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#ifndef S_IREAD
-#define S_IREAD S_IRUSR
-#define S_IWRITE S_IWUSR
-#define S_IEXEC S_IXUSR
+#if !S_IRUSR
+# if S_IREAD
+#  define S_IRUSR S_IREAD
+# else
+#  define S_IRUSR 00400
+# endif
 #endif
 
-#if 0 /* This is unreliable, since GCC 2.5 always has S_ISREG in its
-        fixed headers but it does not always have mode_t.
-        It seems safer not to try to use mode_t ever.  */
-#if !defined(S_ISREG) || defined(NO_MODE_T)
-/* Doesn't have POSIX.1 stat stuff or doesn't have mode_t.  */
-#define mode_t unsigned short
+#if !S_IWUSR
+# if S_IWRITE
+#  define S_IWUSR S_IWRITE
+# else
+#  define S_IWUSR 00200
+# endif
 #endif
+
+#if !S_IXUSR
+# if S_IEXEC
+#  define S_IXUSR S_IEXEC
+# else
+#  define S_IXUSR 00100
+# endif
 #endif
 
 #ifdef STAT_MACROS_BROKEN
@@ -193,6 +198,17 @@ ftypelet (bits)
   if (S_ISNWK (bits))
     return 'n';
 #endif
+
+#ifdef S_ISOFD
+  /* Cray migrated dmf file.  */
+  if (S_ISOFD (bits))
+    return 'M';
+#endif
+#ifdef S_ISOFL
+  /* Cray migrated dmf file.  */
+  if (S_ISOFL (bits))
+    return 'M';
+#endif
   return '?';
 }
 
@@ -204,9 +220,9 @@ rwx (bits, chars)
      unsigned short bits;
      char *chars;
 {
-  chars[0] = (bits & S_IREAD) ? 'r' : '-';
-  chars[1] = (bits & S_IWRITE) ? 'w' : '-';
-  chars[2] = (bits & S_IEXEC) ? 'x' : '-';
+  chars[0] = (bits & S_IRUSR) ? 'r' : '-';
+  chars[1] = (bits & S_IWUSR) ? 'w' : '-';
+  chars[2] = (bits & S_IXUSR) ? 'x' : '-';
 }
 
 /* Set the 's' and 't' flags in file attributes string CHARS,