Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. /*
  3.  * This is file ST_LOSS.C
  4.  *
  5.  * Function to print a human-readable description of _DJSTAT_FAIL_BITS
  6.  * variable, for debugging purposes.  A string which contains description
  7.  * of every fail bit set is printed to the stream given by FP, or to
  8.  * stderr if FP is NULL.
  9.  *
  10.  * Copyright (c) 1994 Eli Zaretskii <eliz@is.elta.co.il>
  11.  *
  12.  * This software may be used freely as long as the above copyright
  13.  * notice is left intact.  There is no warranty on this software.
  14.  *
  15.  */
  16.  
  17. #include <stdio.h>
  18. #include "xstat.h"
  19.  
  20. /* List of messages describing possible failures.  There is a message
  21.    for every bit in the _DJSTAT_FAIL_BITS variable, plus a success
  22.    message, which is printed if no bits are set.
  23. */
  24. static const char *stfail_message[] = {
  25.   "Everything checks out OK",
  26.   "Get DOS SDA call (INT 21h/AX=5D06h/0Dh) failed",
  27.   "Unsupported DOS version: less than 3.10 (for stat), or 1.x (for fstat)",
  28.   "Cannot find SDA entry which corresponds to pathname (bad SDA pointer?)",
  29.   "Get TrueName call (INT 21h/AX=6000h) failed",
  30.   "Failed to get starting cluster number; inode defaults to hashing\n"
  31.   "(if no other messages were printed, then this is either an empty\n"
  32.   "file on a local disk drive, or a file on a networked drive, or\n"
  33.   "you run under some kind of DOS clone)",
  34.   "Root directory has no volume label required to get its time fields",
  35.   "Get SDA call returned preposterously large or negative number of SDAs",
  36.   "Write access bit required, but cannot be figured out",
  37.   "Failed to get drive letter for handle (Novell NetWare 3.x?)",
  38.   "SFT entry found, but is inconsistent with file size and time stamp",
  39.   "Negative index into SFT: might be bad handle table in PSP",
  40.   "File entry not found in SFT array (bad SFT index, or Novell 3.x)"
  41. };
  42.  
  43. /* Number of used bits we know about in _djstat_fail_bits. */
  44. static const int used_bits = sizeof(stfail_message)/sizeof(stfail_message[0]);
  45.  
  46. void
  47. _djstat_describe_lossage(FILE *fp)
  48. {
  49.   int i              = 0;
  50.   unsigned long bits = _djstat_fail_bits;  /* so we don't have side effects */
  51.  
  52.   if (fp == 0)
  53.     fp = stderr;                    /* default: print to stderr */
  54.  
  55.   while (bits && i < used_bits)
  56.     {
  57.       i++;
  58.       if (bits & 1)                 /* print message for this bit, if set */
  59.         fprintf(fp, "%s\n", stfail_message[i]);
  60.  
  61.       bits >>= 1;                   /* get next bit */
  62.     }
  63.  
  64.   /* Did we see any bit set?  */
  65.   if (i == 0)
  66.     fprintf(fp, "%s\n", stfail_message[0]);
  67.  
  68. }
  69.