home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / fst03f.zip / fst.h < prev    next >
C/C++ Source or Header  |  1996-04-16  |  5KB  |  156 lines

  1. /* fst.h -- Global header file for fst
  2.    Copyright (c) 1995-1996 by Eberhard Mattes
  3.  
  4. This file is part of fst.
  5.  
  6. fst is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. fst is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with fst; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. /* Possible byte orders. */
  23.  
  24. #define LITTLE_ENDIAN   1234
  25. #define BIG_ENDIAN      4321
  26.  
  27. /* Target byte order. */
  28.  
  29. #define BYTE_ORDER      LITTLE_ENDIAN
  30.  
  31. /* Convert numbers from filesystem format to host format and vice
  32.    versa.  These are a no-ops on little-endian machines (Intel
  33.    80386). */
  34.  
  35. #if BYTE_ORDER == LITTLE_ENDIAN
  36. #define ULONG_FROM_FS(x)        (ULONG)(x)
  37. #define USHORT_FROM_FS(x)       (USHORT)(x)
  38. #define ULONG_TO_FS(x)          (ULONG)(x)
  39. #define USHORT_TO_FS(x)         (USHORT)(x)
  40. #else
  41. /* TODO */
  42. #endif
  43.  
  44. /* Return the smaller one of the two arguments. */
  45. #define MIN(x,y)         ((x) < (y) ? (x) : (y))
  46.  
  47. /* Round up X to the smallest multiple of Y which is >= X.  Y must be
  48.    a power of two. */
  49. #define ROUND_UP(x,y)    (((x)+(y)-1) & ~((y)-1))
  50.  
  51. /* Divide X by Y, rounding up. */
  52. #define DIVIDE_UP(x,y)   (((x)+(y)-1) / (y))
  53.  
  54. /* Return true iff X is in the range given by the starting number S
  55.    and the count C (inclusive). */
  56. #define IN_RANGE(x,s,c)  ((s) <= (x) && (x) < (s) + (c))
  57.  
  58. /* Return a non-zero value if bit X is set in bit vector BV.  BV must
  59.    be an array of BYTEs. */
  60. #define BITSETP(bv,x)   ((bv)[(x)>>3] & (1 << ((x) & 7)))
  61.  
  62. /* Let GCC check the format string and all the arguments of
  63.    printf()-like functions.  S is the argument# of the format string,
  64.    F is the argument# of the first argument checked against the format
  65.    string. */
  66. #ifdef __GNUC__
  67. #define ATTR_PRINTF(s,f) __attribute__ ((__format__ (__printf__, s, f)))
  68. #else
  69. #define ATTR_PRINTF(s,f)
  70. #endif
  71.  
  72. /* Tell GCC that a function never returns. */
  73. #ifdef __GNUC__
  74. #define ATTR_NORETURN __attribute__ ((__noreturn__))
  75. #else
  76. #define ATTR_NORETURN
  77. #endif
  78.  
  79. /* Tell GCC to inline a function. */
  80. #ifdef __GNUC__
  81. #define INLINE __inline__
  82. #else
  83. #define INLINE
  84. #endif
  85.  
  86. /* File attributes. */
  87.  
  88. #define ATTR_READONLY   0x01    /* Read only */
  89. #define ATTR_HIDDEN     0x02    /* Hidden */
  90. #define ATTR_SYSTEM     0x04    /* System */
  91. #define ATTR_LABEL      0x08    /* Volume label */
  92. #define ATTR_DIR        0x10    /* Directory */
  93. #define ATTR_ARCHIVED   0x20    /* Archived */
  94. #define ATTR_NONFAT     0x40    /* Name not FAT-compatible (HPFS only) */
  95.  
  96.  
  97. typedef struct path_chain
  98. {
  99.   const struct path_chain *parent;
  100.   const char *name;
  101. } path_chain;
  102.  
  103. #define PATH_CHAIN_NEW(L, P, N) \
  104.   (a_check && plenty_memory \
  105.    ? path_chain_new ((P), (N)) \
  106.    : ((L)->parent = (P), (L)->name = (N), (L)))
  107.  
  108. /* See fst.c */
  109. extern char verbose;
  110. extern char sector_number_format;
  111. extern char a_info;
  112. extern char a_save;
  113. extern char a_check;
  114. extern char a_what;
  115. extern char a_where;
  116. extern char a_copy;
  117. extern char a_dir;
  118. extern char a_find;
  119. extern char plenty_memory;
  120. extern char check_unused;
  121. extern char check_pedantic;
  122. extern char show_unused;
  123. extern char show_free_frag;
  124. extern char show_frag;
  125. extern char show_eas;
  126. extern char show_summary;
  127. extern ULONG what_sector;
  128. extern char what_cluster_flag;
  129. extern const char *find_path;
  130. extern BYTE cur_case_map[256];
  131. extern FILE *diag_file;
  132. extern FILE *prog_file;
  133.  
  134. /* See fst.c */
  135. void quit (int rc, int show) ATTR_NORETURN;
  136. int my_vfprintf (FILE *f, const char *fmt, va_list arg_ptr);
  137. int my_fprintf (FILE *f, const char *fmt, ...) ATTR_PRINTF (2, 3);
  138. int my_sprintf (char *buf, const char *fmt, ...) ATTR_PRINTF (2, 3);
  139. void error (const char *fmt, ...) ATTR_NORETURN ATTR_PRINTF (1, 2);
  140. void warning_prolog (int level);
  141. void warning_epilog (void);
  142. void warning (int level, const char *fmt, ...) ATTR_PRINTF (2, 3);
  143. void warning_cont (const char *fmt, ...) ATTR_PRINTF (1, 2);
  144. int info (const char *fmt, ...) ATTR_PRINTF (1, 2);
  145. void infoi (const char *fmt, int indent, ...) ATTR_PRINTF (1, 3);
  146. const char *format_sector_range (ULONG start, ULONG count);
  147. const char *format_string (const unsigned char *s, size_t n, int zero_term);
  148. const char *format_ea_name (const FEA *pfea);
  149. void *xmalloc (size_t n);
  150. path_chain *path_chain_new (const path_chain *parent, const char *name);
  151. int path_chain_len (const path_chain *p);
  152. const char *format_path_chain (const path_chain *bottom, const char *last);
  153. void list_start (const char *fmt, ...) ATTR_PRINTF (1, 2);
  154. void list (const char *fmt, ...) ATTR_PRINTF (1, 2);
  155. void list_end (void);
  156.