home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / oxcc1433.zip / SRC / CFLS.H < prev    next >
C/C++ Source or Header  |  1995-10-18  |  6KB  |  173 lines

  1. /* system-dependent definitions for fileutils programs.
  2.    Copyright (C) 1989, 1990 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 1, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #include <sys/types.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <limits.h>
  22. #include <errno.h>
  23. #include <time.h>
  24. #include "cff.h"
  25.  
  26. #define PCDOS 1
  27. #define STDC_HEADERS
  28.  
  29. #define ST_NBLOCKS(statbuf) (((statbuf)->st_alloc + 512 - 1) / 512)
  30.  
  31. #define convert_blocks(b, k) ((k) ? ((b) + 1) / 2 : (b))
  32.  
  33. #define S_IFMT M_IFMT
  34. #define S_IFDIR M_IFDIR
  35. #define S_IFREG M_IFREG
  36. #define S_IEXEC M_IEXEC
  37. #define S_IFBLK M_IFBLK
  38. #define S_IFCHR M_IFCHR
  39.  
  40. #ifndef _POSIX_PATH_MAX
  41. #define _POSIX_PATH_MAX 511
  42. #define _POSIX_NAME_MAX 32
  43. #endif
  44.  
  45. #define printf cfprintf
  46. #define sprintf cfsprintf
  47. #define fprintf cffprintf
  48. #define putc cfputc
  49. #define fflush cffflush
  50. #define stderr cfstdout
  51. #define stdout cfstdout
  52. #define putchar cfputchar
  53. #define opendir cfopendir
  54. #define readdir cfreadfulldir
  55. #define closedir cfclosedir
  56. #define rewinddir cfrewinddir
  57. #define stat cfstat
  58. #define index strchr
  59. #define rindex strrchr
  60. #define bcopy(from, to, len) memcpy ((to), (from), (len))
  61. #define bzero(s, n) memset ((s), 0, (n))
  62. #define bcmp(s1,s2,n) strncmp(s1,s2,n)
  63.  
  64. #define major(dev)  (((dev) >> 8) & 0xff)
  65. #define minor(dev)  ((dev) & 0xff)
  66. #define makedev(maj, min)  (((maj) << 8) | (min))
  67. #undef NULL
  68. #define NULL ((void *)0)
  69. #define EACCESS EACCES
  70.  
  71. /* declarations for getopt
  72.    Copyright (C) 1989, 1990 Free Software Foundation, Inc.
  73.  
  74.    This program is free software; you can redistribute it and/or modify
  75.    it under the terms of the GNU General Public License as published by
  76.    the Free Software Foundation; either version 1, or (at your option)
  77.    any later version.
  78.  
  79.    This program is distributed in the hope that it will be useful,
  80.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  81.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  82.    GNU General Public License for more details.
  83.  
  84.    You should have received a copy of the GNU General Public License
  85.    along with this program; if not, write to the Free Software
  86.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  87.  
  88. /* For communication from `getopt' to the caller.
  89.    When `getopt' finds an option that takes an argument,
  90.    the argument value is returned here.
  91.    Also, when `ordering' is RETURN_IN_ORDER,
  92.    each non-option ARGV-element is returned here.  */
  93.  
  94. extern char *optarg;
  95.  
  96. /* Index in ARGV of the next element to be scanned.
  97.    This is used for communication to and from the caller
  98.    and for communication between successive calls to `getopt'.
  99.  
  100.    On entry to `getopt', zero means this is the first call; initialize.
  101.  
  102.    When `getopt' returns EOF, this is the index of the first of the
  103.    non-option elements that the caller should itself scan.
  104.  
  105.    Otherwise, `optind' communicates from one call to the next
  106.    how much of ARGV has been scanned so far.  */
  107.  
  108. extern int optind;
  109.  
  110. /* Callers store zero here to inhibit the error message `getopt' prints
  111.    for unrecognized options.  */
  112.  
  113. extern int opterr;
  114.  
  115. /* Describe the long-named options requested by the application.
  116.    _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an
  117.    element containing a name which is zero.
  118.  
  119.    The field `has_arg' is:
  120.    0 if the option does not take an argument,
  121.    1 if the option requires an argument,
  122.    2 if the option takes an optional argument.
  123.  
  124.    If the field `flag' is nonzero, it points to a variable that is set
  125.    to the value given in the field `val' when the option is found, but
  126.    left unchanged if the option is not found.
  127.  
  128.    To have a long-named option do something other than set an `int' to
  129.    a compiled-in constant, such as set a value from `optarg', set the
  130.    option's `flag' field to zero and its `val' field to a nonzero
  131.    value (the equivalent single-letter option character, if there is
  132.    one).  For long options that have a zero `flag' field, `getopt'
  133.    returns the contents of the `val' field.  */
  134.  
  135. struct option
  136. {
  137.   char *name;
  138.   int has_arg;
  139.   int *flag;
  140.   int val;
  141. };
  142.  
  143. #ifdef __STDC__
  144. extern const struct option *_getopt_long_options;
  145. #else
  146. extern struct option *_getopt_long_options;
  147. #endif
  148.  
  149. /* If nonzero, '-' can introduce long-named options.
  150.    Set by getopt_long_only.  */
  151.  
  152. extern int _getopt_long_only;
  153.  
  154. /* The index in GETOPT_LONG_OPTIONS of the long-named option found.
  155.    Only valid when a long-named option has been found by the most
  156.    recent call to `getopt'.  */
  157.  
  158. extern int option_index;
  159.  
  160. #ifdef __STDC__
  161. int getopt (int argc, char **argv, const char *shortopts);
  162. int getopt_long (int argc, char **argv, const char *shortopts,
  163.          const struct option *longopts, int *longind);
  164. int getopt_long_only (int argc, char **argv, const char *shortopts,
  165.               const struct option *longopts, int *longind);
  166. void envopt(int *pargc, char ***pargv, char *optstr);
  167. #else
  168. int getopt ();
  169. int getopt_long ();
  170. int getopt_long_only ();
  171. void envopt();
  172. #endif
  173.