summaryrefslogtreecommitdiffstats
path: root/bftw.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-04 12:40:43 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-04 12:40:43 -0500
commit035dbc05163f897ad74487afbb9d6c778b683b61 (patch)
treee99dd0ccd3659b5b1e05e601115ee50e1f8301fe /bftw.h
parent70fadadf1fc7e1bd09c3d0f451614a678277409c (diff)
downloadbfs-035dbc05163f897ad74487afbb9d6c778b683b61.tar.xz
Don't use typedefs to avoid struct/enum tags.
Diffstat (limited to 'bftw.h')
-rw-r--r--bftw.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/bftw.h b/bftw.h
index 2082390..1375594 100644
--- a/bftw.h
+++ b/bftw.h
@@ -18,7 +18,7 @@
/**
* Possible file types.
*/
-typedef enum {
+enum bftw_typeflag {
/** Unknown type. */
BFTW_UNKNOWN,
/** Block device. */
@@ -37,17 +37,17 @@ typedef enum {
BFTW_SOCK,
/** An error occurred for this file. */
BFTW_ERROR,
-} bftw_typeflag;
+};
/**
* Possible visit occurrences.
*/
-typedef enum {
+enum bftw_visit {
/** Pre-order visit. */
BFTW_PRE,
/** Post-order visit. */
BFTW_POST,
-} bftw_visit;
+};
/**
* Data about the current file for the bftw() callback.
@@ -61,10 +61,10 @@ struct BFTW {
/** The depth of this file in the traversal. */
size_t depth;
/** Which visit this is. */
- bftw_visit visit;
+ enum bftw_visit visit;
/** The file type. */
- bftw_typeflag typeflag;
+ enum bftw_typeflag typeflag;
/** The errno that occurred, if typeflag == BFTW_ERROR. */
int error;
@@ -77,7 +77,7 @@ struct BFTW {
const char *at_path;
};
-typedef enum {
+enum bftw_action {
/** Keep walking. */
BFTW_CONTINUE,
/** Skip this path's siblings. */
@@ -86,7 +86,7 @@ typedef enum {
BFTW_SKIP_SUBTREE,
/** Stop walking. */
BFTW_STOP,
-} bftw_action;
+};
/**
* Callback function type for bftw().
@@ -98,16 +98,19 @@ typedef enum {
* @return
* An action value.
*/
-typedef bftw_action bftw_fn(struct BFTW *ftwbuf, void *ptr);
+typedef enum bftw_action bftw_fn(struct BFTW *ftwbuf, void *ptr);
-typedef enum {
+/**
+ * Flags that control bftw() behavior.
+ */
+enum bftw_flags {
/** stat() each encountered file. */
BFTW_STAT = 1 << 0,
/** Attempt to recover from encountered errors. */
BFTW_RECOVER = 1 << 1,
/** Visit directories in post-order as well as pre-order. */
BFTW_DEPTH = 1 << 2,
-} bftw_flags;
+};
/**
* Breadth First Tree Walk (or Better File Tree Walk).
@@ -129,6 +132,6 @@ typedef enum {
* @return
* 0 on success, or -1 on failure.
*/
-int bftw(const char *path, bftw_fn *fn, int nopenfd, bftw_flags flags, void *ptr);
+int bftw(const char *path, bftw_fn *fn, int nopenfd, enum bftw_flags flags, void *ptr);
#endif // BFS_BFTW_H