xref: /netbsd-src/external/gpl2/xcvs/dist/lib/cycle-check.h (revision a7c918477dd5f12c1da816ba05caf44eab2d06d6)
1*a7c91847Schristos /* help detect directory cycles efficiently
2*a7c91847Schristos 
3*a7c91847Schristos    Copyright (C) 2003, 2004 Free Software Foundation, Inc.
4*a7c91847Schristos 
5*a7c91847Schristos    This program is free software; you can redistribute it and/or modify
6*a7c91847Schristos    it under the terms of the GNU General Public License as published by
7*a7c91847Schristos    the Free Software Foundation; either version 2, or (at your option)
8*a7c91847Schristos    any later version.
9*a7c91847Schristos 
10*a7c91847Schristos    This program is distributed in the hope that it will be useful,
11*a7c91847Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
12*a7c91847Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*a7c91847Schristos    GNU General Public License for more details.
14*a7c91847Schristos 
15*a7c91847Schristos    You should have received a copy of the GNU General Public License
16*a7c91847Schristos    along with this program; see the file COPYING.
17*a7c91847Schristos    If not, write to the Free Software Foundation,
18*a7c91847Schristos    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19*a7c91847Schristos 
20*a7c91847Schristos /* Written by Jim Meyering */
21*a7c91847Schristos 
22*a7c91847Schristos #ifndef CYCLE_CHECK_H
23*a7c91847Schristos # define CYCLE_CHECK_H 1
24*a7c91847Schristos 
25*a7c91847Schristos # if HAVE_INTTYPES_H
26*a7c91847Schristos #  include <inttypes.h>
27*a7c91847Schristos # endif
28*a7c91847Schristos # if HAVE_STDINT_H
29*a7c91847Schristos #  include <stdint.h>
30*a7c91847Schristos # endif
31*a7c91847Schristos # include <stdbool.h>
32*a7c91847Schristos # include "dev-ino.h"
33*a7c91847Schristos 
34*a7c91847Schristos struct cycle_check_state
35*a7c91847Schristos {
36*a7c91847Schristos   struct dev_ino dev_ino;
37*a7c91847Schristos   uintmax_t chdir_counter;
38*a7c91847Schristos   int magic;
39*a7c91847Schristos };
40*a7c91847Schristos 
41*a7c91847Schristos void cycle_check_init (struct cycle_check_state *state);
42*a7c91847Schristos bool cycle_check (struct cycle_check_state *state, struct stat const *sb);
43*a7c91847Schristos 
44*a7c91847Schristos #endif
45