home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / f / find12as.zip / DEFS.H < prev    next >
C/C++ Source or Header  |  1992-02-22  |  7KB  |  257 lines

  1. /* Common definitions for the 'find' package
  2.    Copyright (C) 1987, 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. /* MS-DOS port (c) 1990 by Thorsten Ohl, ohl@gnu.ai.mit.edu
  19.    This port is also distributed under the terms of the
  20.    GNU General Public License as published by the
  21.    Free Software Foundation.
  22.  
  23.    Please note that this file is not identical to the
  24.    original GNU release, you should have received this
  25.    code as patch to the official release.
  26.  
  27.    $Header: e:/gnu/find/RCS/defs.h 1.2.0.3 90/09/23 16:10:04 tho Exp $
  28.  */
  29.  
  30. #include "regex.h"
  31.  
  32. typedef char boolean;
  33. #define        true    1
  34. #define        false    0
  35.  
  36. #ifdef MSDOS
  37.  
  38. #define PARSE_ARGS \
  39.   char **argv, int *arg_ptr
  40.  
  41. #define PRED_ARGS \
  42.   char *pathname, struct stat *stat_buf, struct pred_struct *pred_ptr
  43.  
  44. /* Pointer to function returning boolean. */
  45. typedef boolean (*PRED_FCT) (PRED_ARGS);
  46. typedef boolean (*PARSE_FCT) (PARSE_ARGS);
  47.  
  48. #include <stdio.h>
  49. #include <stdlib.h>
  50. #include <time.h>
  51.  
  52. extern struct pred_struct *get_new_pred (void);
  53. extern struct pred_struct *get_new_pred_chk_op (void);
  54. extern struct pred_struct *insert_victim (char (*pred_func)());
  55. extern char *xmalloc (unsigned int n);
  56. extern void usage (char *msg);
  57. extern void error (int status, int errnum, char *message, ...);
  58.  
  59. extern PARSE_FCT find_parser (char *search_name);
  60. extern char no_side_effects (struct pred_struct *pred);
  61. extern boolean parse_close (PARSE_ARGS);
  62. extern boolean parse_open (PARSE_ARGS);
  63. extern boolean parse_print (PARSE_ARGS);
  64.  
  65. extern boolean pred_and (PRED_ARGS);
  66. extern boolean pred_atime (PRED_ARGS);
  67. extern boolean pred_close (PRED_ARGS);
  68. extern boolean pred_ctime (PRED_ARGS);
  69. extern boolean pred_exec (PRED_ARGS);
  70. extern boolean pred_fstype (PRED_ARGS);
  71. extern boolean pred_group (PRED_ARGS);
  72. extern boolean pred_inum (PRED_ARGS);
  73. extern boolean pred_links (PRED_ARGS);
  74. extern boolean pred_ls (PRED_ARGS);
  75. extern boolean pred_mtime (PRED_ARGS);
  76. extern boolean pred_name (PRED_ARGS);
  77. extern boolean pred_negate (PRED_ARGS);
  78. extern boolean pred_newer (PRED_ARGS);
  79. extern boolean pred_nogroup (PRED_ARGS);
  80. extern boolean pred_nouser (PRED_ARGS);
  81. extern boolean pred_ok (PRED_ARGS);
  82. extern boolean pred_open (PRED_ARGS);
  83. extern boolean pred_or (PRED_ARGS);
  84. extern boolean pred_perm (PRED_ARGS);
  85. extern boolean pred_permmask (PRED_ARGS);
  86. extern boolean pred_print (PRED_ARGS);
  87. extern boolean pred_prune (PRED_ARGS);
  88. extern boolean pred_regex (PRED_ARGS);
  89. extern boolean pred_size (PRED_ARGS);
  90. extern boolean pred_type (PRED_ARGS);
  91. extern boolean pred_user (PRED_ARGS);
  92.  
  93. extern boolean insert_exec_ok (boolean (*func) (), PARSE_ARGS);
  94. extern boolean get_num_days (char *str, unsigned long *num_days,
  95.                  enum comparison_type *comp_type);
  96. extern boolean insert_time (PARSE_ARGS, PRED_FCT pred);
  97. extern boolean get_num (char *str, unsigned long *num, short *comp_type);
  98. extern boolean insert_num (PARSE_ARGS, PRED_FCT pred);
  99.  
  100. extern void read_mtab (void);
  101.  
  102. struct pred_struct *get_expr (struct pred_struct **input, short prev_prec);
  103. extern void process_path (char *pathname, char root);
  104.  
  105. extern void main (int argc, char **argv);
  106. extern char *savedir (char *dir, unsigned int name_size);
  107.  
  108. #else /* not MSDOS */
  109.  
  110. /* Pointer to function returning boolean. */
  111. typedef boolean (*PFB)();
  112.  
  113. char *malloc ();
  114. int fprintf ();
  115. int printf ();
  116. long time ();
  117. void exit ();
  118. void free ();
  119.  
  120. PFB find_parser ();
  121. boolean no_side_effects ();
  122. boolean parse_print ();
  123. char *xmalloc ();
  124. struct pred_struct *get_expr ();
  125. struct pred_struct *get_new_pred ();
  126. struct pred_struct *get_new_pred_chk_op ();
  127. struct pred_struct *insert_victim ();
  128. void error ();
  129. void usage ();
  130. void process_path ();
  131.  
  132. #endif /* not MSDOS */
  133.  
  134. #ifdef    DEBUG
  135. void print_tree ();
  136. void print_list ();
  137. #endif    /* DEBUG */
  138.  
  139. /* Argument structures for predicates. */
  140.  
  141. enum comparison_type
  142. {
  143.   COMP_GT,
  144.   COMP_LT,
  145.   COMP_EQ
  146. };
  147.  
  148. enum predicate_type
  149. {
  150.   NO_TYPE,
  151.   VICTIM_TYPE,
  152.   UNI_OP,
  153.   BI_OP,
  154.   OPEN_PAREN,
  155.   CLOSE_PAREN
  156. };
  157.  
  158. enum predicate_precedence
  159. {
  160.   NO_PREC,
  161.   OR_PREC,
  162.   AND_PREC,
  163.   NEGATE_PREC,
  164.   MAX_PREC
  165. };
  166.  
  167. struct long_t
  168. {
  169.   enum comparison_type kind;
  170.   unsigned long l_val;
  171. };
  172.  
  173. struct size_t
  174. {
  175.   short kind;
  176.   boolean block;
  177.   unsigned long size;
  178. };
  179.  
  180. struct exec_t
  181. {
  182.   short *path_loc;
  183.   char **vec;
  184. };
  185.  
  186. struct pred_struct
  187. {
  188.   /* Pointer to the function that implements this predicate.  */
  189. #ifdef MSDOS
  190.   PRED_FCT pred_func;
  191. #else
  192.   PFB pred_func;
  193. #endif
  194. #ifdef    DEBUG
  195.   char *p_name;
  196. #endif
  197.  
  198.   /* The type of this node.  There are two kinds.  The first is real
  199.      predicates ("victims") such as -perm, -print, or -exec.  The
  200.      other kind is operators for combining predicates. */
  201.   enum predicate_type p_type;
  202.  
  203.   /* The precedence of this node.  Only has meaning for operators. */
  204.   enum predicate_precedence p_prec;
  205.  
  206.   /* True if this predicate node produces side effects. */
  207.   boolean side_effects;
  208.  
  209.   /* Information needed by the predicate processor.
  210.      Next to each member are listed the predicates that use it. */
  211.   union
  212.   {
  213.     char *str;            /* name fstype */
  214.     struct re_pattern_buffer *regex; /* regex */
  215.     struct exec_t exec_vec;    /* exec ok */
  216.     struct long_t info;        /* atime ctime mtime inum links */
  217.     struct size_t size;        /* size */
  218.     unsigned short uid;        /* user */
  219.     unsigned short gid;        /* group */
  220.     time_t time;        /* newer */
  221.     unsigned long perm;        /* perm permmask */
  222.     unsigned long type;        /* type */
  223.   } args;
  224.  
  225.   /* The next predicate in the user input sequence,
  226.      which repesents the order in which the user supplied the
  227.      predicates on the command line. */
  228.   struct pred_struct *pred_next;
  229.  
  230.   /* The right and left branches from this node in the expression
  231.      tree, which represents the order in which the nodes should be
  232.      processed. */
  233.   struct pred_struct *pred_left;
  234.   struct pred_struct *pred_right;
  235. };
  236.  
  237. /* The number of seconds in a day. */
  238. #define        DAYSECS        86400
  239.  
  240. /* The number of bytes in a block for -size. */
  241. #define        BLKSIZE        512
  242.  
  243. #ifndef MSDOS            /* errno is declared `volatile'! */
  244. extern int errno;
  245. #endif
  246.  
  247. extern char *program_name;
  248. extern struct pred_struct *predicates;
  249. extern struct pred_struct *last_pred;
  250. extern boolean do_dir_first;
  251. extern unsigned long perm_mask;
  252. extern long cur_day_start;
  253. extern boolean full_days;
  254. extern boolean stay_on_filesystem;
  255. extern boolean stop_at_current_level;
  256. extern int exit_status;
  257.