home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / find-3.8-src.lha / src / amiga / find-3.8 / find / defs.h next >
C/C++ Source or Header  |  1993-03-26  |  6KB  |  215 lines

  1. /* defs.h -- data types and declarations.
  2.    Copyright (C) 1987, 1990, 1991 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 2, 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. #if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
  19. #include <string.h>
  20. #ifndef index
  21. #define index strchr
  22. #endif
  23. #ifndef rindex
  24. #define rindex strrchr
  25. #endif
  26. #else
  27. #include <strings.h>
  28. #endif
  29.  
  30. #include <errno.h>
  31. #ifndef STDC_HEADERS
  32. extern int errno;
  33. #endif
  34.  
  35. #ifdef STDC_HEADERS
  36. #include <stdlib.h>
  37. #endif
  38. #include <time.h>
  39. #include "regex.h"
  40.  
  41. typedef char boolean;
  42. #define        true    1
  43. #define        false    0
  44.  
  45. /* Pointer to function returning boolean. */
  46. typedef boolean (*PFB)();
  47.  
  48. PFB find_parser ();
  49. boolean no_side_effects ();
  50. boolean parse_print ();
  51. char *xmalloc ();
  52. char *xrealloc ();
  53. struct predicate *get_expr ();
  54. struct predicate *get_new_pred ();
  55. struct predicate *get_new_pred_chk_op ();
  56. struct predicate *insert_victim ();
  57. void error ();
  58. void usage ();
  59.  
  60. #ifdef    DEBUG
  61. void print_tree ();
  62. void print_list ();
  63. #endif    /* DEBUG */
  64.  
  65. /* Argument structures for predicates. */
  66.  
  67. enum comparison_type
  68. {
  69.   COMP_GT,
  70.   COMP_LT,
  71.   COMP_EQ
  72. };
  73.  
  74. enum predicate_type
  75. {
  76.   NO_TYPE,
  77.   VICTIM_TYPE,
  78.   UNI_OP,
  79.   BI_OP,
  80.   OPEN_PAREN,
  81.   CLOSE_PAREN
  82. };
  83.  
  84. enum predicate_precedence
  85. {
  86.   NO_PREC,
  87.   COMMA_PREC,
  88.   OR_PREC,
  89.   AND_PREC,
  90.   NEGATE_PREC,
  91.   MAX_PREC
  92. };
  93.  
  94. struct long_val
  95. {
  96.   enum comparison_type kind;
  97.   unsigned long l_val;
  98. };
  99.  
  100. struct size_val
  101. {
  102.   enum comparison_type kind;
  103.   int blocksize;
  104.   unsigned long size;
  105. };
  106.  
  107. struct path_arg
  108. {
  109.   short offset;            /* Offset in `vec' of this arg. */
  110.   short count;            /* Number of path replacements in this arg. */
  111.   char *origarg;        /* Arg with "{}" intact. */
  112. };
  113.  
  114. struct exec_val
  115. {
  116.   struct path_arg *paths;    /* Array of args with path replacements. */
  117.   char **vec;            /* Array of args to pass to program. */
  118. };
  119.  
  120. /* The format string for a -printf or -fprintf is chopped into one or
  121.    more `struct segment', linked together into a list.
  122.    Each stretch of plain text is a segment, and
  123.    each \c and `%' conversion is a segment. */
  124.  
  125. /* Special values for the `kind' field of `struct segment'. */
  126. #define KIND_PLAIN 0        /* This segment is just plain text. */
  127. #define KIND_STOP 1        /* \c -- stop printing from this fmt string. */
  128.  
  129. struct segment
  130. {
  131.   int kind;            /* Format chars or KIND_{PLAIN,STOP}. */
  132.   char *text;            /* Plain text or `%' format string. */
  133.   int text_len;            /* Length of `text'. */
  134.   struct segment *next;        /* Next segment for this predicate. */
  135. };
  136.  
  137. struct format_val
  138. {
  139.   struct segment *segment;    /* Linked list of segments. */
  140.   FILE *stream;            /* Output stream to print on. */
  141. };
  142.  
  143. struct predicate
  144. {
  145.   /* Pointer to the function that implements this predicate.  */
  146.   PFB pred_func;
  147.  
  148.   /* Only used for debugging, but defined unconditionally so individual
  149.      modules can be compiled with -DDEBUG.  */
  150.   char *p_name;
  151.  
  152.   /* The type of this node.  There are two kinds.  The first is real
  153.      predicates ("victims") such as -perm, -print, or -exec.  The
  154.      other kind is operators for combining predicates. */
  155.   enum predicate_type p_type;
  156.  
  157.   /* The precedence of this node.  Only has meaning for operators. */
  158.   enum predicate_precedence p_prec;
  159.  
  160.   /* True if this predicate node produces side effects. */
  161.   boolean side_effects;
  162.  
  163.   /* True if this predicate node requires a stat system call to execute. */
  164.   boolean need_stat;
  165.  
  166.   /* Information needed by the predicate processor.
  167.      Next to each member are listed the predicates that use it. */
  168.   union
  169.   {
  170.     char *str;            /* fstype [i]lname [i]name [i]path */
  171.     struct re_pattern_buffer *regex; /* regex */
  172.     struct exec_val exec_vec;    /* exec ok */
  173.     struct long_val info;    /* atime ctime mtime inum links */
  174.     struct size_val size;    /* size */
  175.     unsigned short uid;        /* user */
  176.     unsigned short gid;        /* group */
  177.     time_t time;        /* newer */
  178.     unsigned long perm;        /* perm */
  179.     unsigned long type;        /* type */
  180.     FILE *stream;        /* fprint fprint0 */
  181.     struct format_val printf_vec; /* printf fprintf */
  182.   } args;
  183.  
  184.   /* The next predicate in the user input sequence,
  185.      which repesents the order in which the user supplied the
  186.      predicates on the command line. */
  187.   struct predicate *pred_next;
  188.  
  189.   /* The right and left branches from this node in the expression
  190.      tree, which represents the order in which the nodes should be
  191.      processed. */
  192.   struct predicate *pred_left;
  193.   struct predicate *pred_right;
  194. };
  195.  
  196. /* The number of seconds in a day. */
  197. #define        DAYSECS        86400
  198.  
  199. extern char *program_name;
  200. extern struct predicate *predicates;
  201. extern struct predicate *last_pred;
  202. extern boolean do_dir_first;
  203. extern int maxdepth;
  204. extern int mindepth;
  205. extern int curdepth;
  206. extern time_t cur_day_start;
  207. extern boolean full_days;
  208. extern boolean no_leaf_check;
  209. extern boolean stay_on_filesystem;
  210. extern boolean stop_at_current_level;
  211. extern boolean have_stat;
  212. extern int exit_status;
  213. extern int path_length;
  214. extern int (*xstat) ();
  215.