summaryrefslogtreecommitdiffstats
path: root/bfs.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 /bfs.h
parent70fadadf1fc7e1bd09c3d0f451614a678277409c (diff)
downloadbfs-035dbc05163f897ad74487afbb9d6c778b683b61.tar.xz
Don't use typedefs to avoid struct/enum tags.
Diffstat (limited to 'bfs.h')
-rw-r--r--bfs.h88
1 files changed, 43 insertions, 45 deletions
diff --git a/bfs.h b/bfs.h
index a8efffb..15f25ee 100644
--- a/bfs.h
+++ b/bfs.h
@@ -18,19 +18,14 @@
#include <time.h>
/**
- * The parsed command line.
- */
-typedef struct cmdline cmdline;
-
-/**
* A command line expression.
*/
-typedef struct expression expression;
+struct expr;
/**
* Ephemeral state for evaluating an expression.
*/
-typedef struct eval_state eval_state;
+struct eval_state;
/**
* Expression evaluation function.
@@ -42,8 +37,11 @@ typedef struct eval_state eval_state;
* @return
* The result of the test.
*/
-typedef bool eval_fn(const expression *expr, eval_state *state);
+typedef bool eval_fn(const struct expr *expr, struct eval_state *state);
+/**
+ * The parsed command line.
+ */
struct cmdline {
/** The array of paths to start from. */
const char **roots;
@@ -51,7 +49,7 @@ struct cmdline {
size_t nroots;
/** Color data. */
- color_table *colors;
+ struct color_table *colors;
/** -color option. */
bool color;
@@ -64,7 +62,7 @@ struct cmdline {
int flags;
/** The command line expression. */
- expression *expr;
+ struct expr *expr;
/** The current time. */
struct timespec now;
@@ -73,24 +71,24 @@ struct cmdline {
/**
* Possible types of numeric comparison.
*/
-typedef enum {
+enum cmpflag {
/** Exactly n. */
CMP_EXACT,
/** Less than n. */
CMP_LESS,
/** Greater than n. */
CMP_GREATER,
-} cmpflag;
+};
-struct expression {
+struct expr {
/** The left hand side of the expression. */
- expression *lhs;
+ struct expr *lhs;
/** The right hand side of the expression. */
- expression *rhs;
+ struct expr *rhs;
/** The function that evaluates this expression. */
eval_fn *eval;
/** The comparison flag. */
- cmpflag cmp;
+ enum cmpflag cmp;
/** Optional integer data for this expression. */
int idata;
/** Optional string data for this expression. */
@@ -100,52 +98,52 @@ struct expression {
/**
* Parse the command line.
*/
-cmdline *parse_cmdline(int argc, char *argv[]);
+struct cmdline *parse_cmdline(int argc, char *argv[]);
/**
* Evaluate the command line.
*/
-int eval_cmdline(cmdline *cl);
+int eval_cmdline(struct cmdline *cl);
/**
* Free the parsed command line.
*/
-void free_cmdline(cmdline *cl);
+void free_cmdline(struct cmdline *cl);
// Predicate evaluation functions
-bool eval_true(const expression *expr, eval_state *state);
-bool eval_false(const expression *expr, eval_state *state);
+bool eval_true(const struct expr *expr, struct eval_state *state);
+bool eval_false(const struct expr *expr, struct eval_state *state);
-bool eval_access(const expression *expr, eval_state *state);
+bool eval_access(const struct expr *expr, struct eval_state *state);
-bool eval_amin(const expression *expr, eval_state *state);
-bool eval_atime(const expression *expr, eval_state *state);
-bool eval_cmin(const expression *expr, eval_state *state);
-bool eval_ctime(const expression *expr, eval_state *state);
-bool eval_mmin(const expression *expr, eval_state *state);
-bool eval_mtime(const expression *expr, eval_state *state);
+bool eval_amin(const struct expr *expr, struct eval_state *state);
+bool eval_atime(const struct expr *expr, struct eval_state *state);
+bool eval_cmin(const struct expr *expr, struct eval_state *state);
+bool eval_ctime(const struct expr *expr, struct eval_state *state);
+bool eval_mmin(const struct expr *expr, struct eval_state *state);
+bool eval_mtime(const struct expr *expr, struct eval_state *state);
-bool eval_gid(const expression *expr, eval_state *state);
-bool eval_uid(const expression *expr, eval_state *state);
+bool eval_gid(const struct expr *expr, struct eval_state *state);
+bool eval_uid(const struct expr *expr, struct eval_state *state);
-bool eval_empty(const expression *expr, eval_state *state);
-bool eval_hidden(const expression *expr, eval_state *state);
-bool eval_type(const expression *expr, eval_state *state);
+bool eval_empty(const struct expr *expr, struct eval_state *state);
+bool eval_hidden(const struct expr *expr, struct eval_state *state);
+bool eval_type(const struct expr *expr, struct eval_state *state);
-bool eval_name(const expression *expr, eval_state *state);
-bool eval_path(const expression *expr, eval_state *state);
+bool eval_name(const struct expr *expr, struct eval_state *state);
+bool eval_path(const struct expr *expr, struct eval_state *state);
-bool eval_delete(const expression *expr, eval_state *state);
-bool eval_nohidden(const expression *expr, eval_state *state);
-bool eval_print(const expression *expr, eval_state *state);
-bool eval_print0(const expression *expr, eval_state *state);
-bool eval_prune(const expression *expr, eval_state *state);
-bool eval_quit(const expression *expr, eval_state *state);
+bool eval_delete(const struct expr *expr, struct eval_state *state);
+bool eval_nohidden(const struct expr *expr, struct eval_state *state);
+bool eval_print(const struct expr *expr, struct eval_state *state);
+bool eval_print0(const struct expr *expr, struct eval_state *state);
+bool eval_prune(const struct expr *expr, struct eval_state *state);
+bool eval_quit(const struct expr *expr, struct eval_state *state);
// Operator evaluation functions
-bool eval_not(const expression *expr, eval_state *state);
-bool eval_and(const expression *expr, eval_state *state);
-bool eval_or(const expression *expr, eval_state *state);
-bool eval_comma(const expression *expr, eval_state *state);
+bool eval_not(const struct expr *expr, struct eval_state *state);
+bool eval_and(const struct expr *expr, struct eval_state *state);
+bool eval_or(const struct expr *expr, struct eval_state *state);
+bool eval_comma(const struct expr *expr, struct eval_state *state);
#endif // BFS_H