From c048d63924529b892edd19630672300a65e89365 Mon Sep 17 00:00:00 2001 From: agc Date: Sat, 19 May 2007 06:15:38 +0000 Subject: [PATCH] Add a function to return the virtual offset in the virtdir_t tree. --- share/examples/refuse/virtdir/virtdir.c | 7 +++++++ share/examples/refuse/virtdir/virtdir.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/share/examples/refuse/virtdir/virtdir.c b/share/examples/refuse/virtdir/virtdir.c index ba7658e0ff76..1529f9ef6f2f 100644 --- a/share/examples/refuse/virtdir/virtdir.c +++ b/share/examples/refuse/virtdir/virtdir.c @@ -156,6 +156,13 @@ virtdir_find(virtdir_t *tp, const char *name, size_t namelen) return bsearch(&e, tp->v, tp->c, sizeof(tp->v[0]), compare); } +/* return the virtual offset in the tree */ +int +virtdir_offset(virtdir_t *tp, virt_dirent_t *dp) +{ + return (int)((dp - tp->v)); +} + /* analogous to opendir(3) - open a directory, save information, and * return a pointer to the dynamically allocated structure */ VIRTDIR * diff --git a/share/examples/refuse/virtdir/virtdir.h b/share/examples/refuse/virtdir/virtdir.h index 6e48e17353e5..fb88c801449b 100644 --- a/share/examples/refuse/virtdir/virtdir.h +++ b/share/examples/refuse/virtdir/virtdir.h @@ -75,4 +75,6 @@ VIRTDIR *openvirtdir(virtdir_t *, const char *); virt_dirent_t *readvirtdir(VIRTDIR *); void closevirtdir(VIRTDIR *); +int virtdir_offset(virtdir_t *, virt_dirent_t *); + #endif