110d1cba0SDaniel Eischen /* 210d1cba0SDaniel Eischen * Copyright (c) 1983, 1993 310d1cba0SDaniel Eischen * The Regents of the University of California. All rights reserved. 410d1cba0SDaniel Eischen * 510d1cba0SDaniel Eischen * Copyright (c) 2000 610d1cba0SDaniel Eischen * Daniel Eischen. All rights reserved. 710d1cba0SDaniel Eischen * 810d1cba0SDaniel Eischen * Redistribution and use in source and binary forms, with or without 910d1cba0SDaniel Eischen * modification, are permitted provided that the following conditions 1010d1cba0SDaniel Eischen * are met: 1110d1cba0SDaniel Eischen * 1. Redistributions of source code must retain the above copyright 1210d1cba0SDaniel Eischen * notice, this list of conditions and the following disclaimer. 1310d1cba0SDaniel Eischen * 2. Redistributions in binary form must reproduce the above copyright 1410d1cba0SDaniel Eischen * notice, this list of conditions and the following disclaimer in the 1510d1cba0SDaniel Eischen * documentation and/or other materials provided with the distribution. 1610d1cba0SDaniel Eischen * 3. Neither the name of the University nor the names of its contributors 1710d1cba0SDaniel Eischen * may be used to endorse or promote products derived from this software 1810d1cba0SDaniel Eischen * without specific prior written permission. 1910d1cba0SDaniel Eischen * 2010d1cba0SDaniel Eischen * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2110d1cba0SDaniel Eischen * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2210d1cba0SDaniel Eischen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2310d1cba0SDaniel Eischen * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2410d1cba0SDaniel Eischen * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2510d1cba0SDaniel Eischen * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2610d1cba0SDaniel Eischen * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2710d1cba0SDaniel Eischen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2810d1cba0SDaniel Eischen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2910d1cba0SDaniel Eischen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3010d1cba0SDaniel Eischen * SUCH DAMAGE. 3110d1cba0SDaniel Eischen * 3210d1cba0SDaniel Eischen * $FreeBSD$ 3310d1cba0SDaniel Eischen */ 3410d1cba0SDaniel Eischen 3510d1cba0SDaniel Eischen #ifndef _TELLDIR_H_ 3610d1cba0SDaniel Eischen #define _TELLDIR_H_ 3710d1cba0SDaniel Eischen 3810d1cba0SDaniel Eischen #include <sys/queue.h> 3910d1cba0SDaniel Eischen 4010d1cba0SDaniel Eischen /* 4110d1cba0SDaniel Eischen * One of these structures is malloced to describe the current directory 4210d1cba0SDaniel Eischen * position each time telldir is called. It records the current magic 4310d1cba0SDaniel Eischen * cookie returned by getdirentries and the offset within the buffer 4410d1cba0SDaniel Eischen * associated with that return value. 4510d1cba0SDaniel Eischen */ 4610d1cba0SDaniel Eischen struct ddloc { 4710d1cba0SDaniel Eischen LIST_ENTRY(ddloc) loc_lqe; /* entry in list */ 4810d1cba0SDaniel Eischen long loc_index; /* key associated with structure */ 4910d1cba0SDaniel Eischen long loc_seek; /* magic cookie returned by getdirentries */ 5010d1cba0SDaniel Eischen long loc_loc; /* offset of entry in buffer */ 5110d1cba0SDaniel Eischen }; 5210d1cba0SDaniel Eischen 5310d1cba0SDaniel Eischen /* 5410d1cba0SDaniel Eischen * One of these structures is malloced for each DIR to record telldir 5510d1cba0SDaniel Eischen * positions. 5610d1cba0SDaniel Eischen */ 5710d1cba0SDaniel Eischen struct _telldir { 5810d1cba0SDaniel Eischen LIST_HEAD(, ddloc) td_locq; /* list of locations */ 5910d1cba0SDaniel Eischen long td_loccnt; /* index of entry for sequential readdir's */ 6010d1cba0SDaniel Eischen }; 6110d1cba0SDaniel Eischen 6290c68c17SKonstantin Belousov struct dirent *_readdir_unlocked(DIR *, int); 63d201fe46SDaniel Eischen void _reclaim_telldir(DIR *); 64d201fe46SDaniel Eischen void _seekdir(DIR *, long); 6510d1cba0SDaniel Eischen 6610d1cba0SDaniel Eischen #endif 67