From 7fc960a23eab7fce9f5e0666b1a9b3f5eae832af Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 12 Feb 2019 17:36:31 -0500 Subject: bftw: Switch from taking separate parameters to a parameters struct --- bftw.h | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'bftw.h') diff --git a/bftw.h b/bftw.h index bed5800..6d1850f 100644 --- a/bftw.h +++ b/bftw.h @@ -1,6 +1,6 @@ /**************************************************************************** * bfs * - * Copyright (C) 2015-2018 Tavian Barnes * + * Copyright (C) 2015-2019 Tavian Barnes * * * * Permission to use, copy, modify, and/or distribute this software for any * * purpose with or without fee is hereby granted. * @@ -125,7 +125,7 @@ enum bftw_action { * @return * An action value. */ -typedef enum bftw_action bftw_fn(struct BFTW *ftwbuf, void *ptr); +typedef enum bftw_action bftw_callback(struct BFTW *ftwbuf, void *ptr); /** * Flags that control bftw() behavior. @@ -147,6 +147,20 @@ enum bftw_flags { BFTW_XDEV = 1 << 6, }; +/** + * Structure for holding the arguments passed to bftw(). + */ +struct bftw_args { + /** The callback to invoke. */ + bftw_callback *callback; + /** A pointer which is passed to the callback. */ + void *ptr; + /** The maximum number of file descriptors to keep open. */ + int nopenfd; + /** Flags that control bftw() behaviour. */ + enum bftw_flags flags; +}; + /** * Breadth First Tree Walk (or Better File Tree Walk). * @@ -156,17 +170,11 @@ enum bftw_flags { * * @param path * The starting path. - * @param fn - * The callback to invoke. - * @param nopenfd - * The maximum number of file descriptors to keep open. - * @param flags - * Flags that control bftw() behavior. - * @param ptr - * A generic pointer which is passed to fn(). + * @param args + * The arguments that control the walk. * @return * 0 on success, or -1 on failure. */ -int bftw(const char *path, bftw_fn *fn, int nopenfd, enum bftw_flags flags, void *ptr); +int bftw(const char *path, const struct bftw_args *args); #endif // BFS_BFTW_H -- cgit v1.2.3