diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:30:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:30:35 +0000 |
commit | 378c18e5f024ac5a8aef4cb40d7c9aa9633d144c (patch) | |
tree | 44dfb6ca500d32cabd450649b322a42e70a30683 /misc-utils/lsfd-filter.h | |
parent | Initial commit. (diff) | |
download | util-linux-upstream/2.38.1.tar.xz util-linux-upstream/2.38.1.zip |
Adding upstream version 2.38.1.upstream/2.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'misc-utils/lsfd-filter.h')
-rw-r--r-- | misc-utils/lsfd-filter.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/misc-utils/lsfd-filter.h b/misc-utils/lsfd-filter.h new file mode 100644 index 0000000..db5cbd6 --- /dev/null +++ b/misc-utils/lsfd-filter.h @@ -0,0 +1,43 @@ +/* + * lsfd-filter.c - filtering engine for lsfd + * + * Copyright (C) 2021 Red Hat, Inc. + * Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com> + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ +#ifndef UTIL_LINUX_LSFD_FILTER_H +#define UTIL_LINUX_LSFD_FILTER_H + +#include "libsmartcols.h" +#include <stdio.h> +#include <stdbool.h> + +#define LSFD_FILTER_UNKNOWN_COL_ID -1 + +struct lsfd_filter; + +/* + * @column_name_to_id: a function converting a column name to its id. + * + * @column_name_to_id should return LSFD_FILTER_UNKNOWN_COL_ID if + * an unknown column name is given. + */ +struct lsfd_filter *lsfd_filter_new(const char *const expr, struct libscols_table *tb, + int ncols, + int (*column_name_to_id)(const char *, void *), + struct libscols_column *(*add_column_by_id)(struct libscols_table *, int, void*), + void *data); + +/* Call lsfd_filter_get_errmsg() after lsfd_filter_new() to detect + * whether lsfd_filter_new() is failed or not. Returning NULL means, + * lsfd_filter_new() is successful. */ +const char *lsfd_filter_get_errmsg(struct lsfd_filter *filter); +void lsfd_filter_free(struct lsfd_filter *filter); +bool lsfd_filter_apply(struct lsfd_filter *filter, struct libscols_line *ln); + +/* Dumping AST. */ +void lsfd_filter_dump(struct lsfd_filter *filter, FILE *stream); + +#endif /* UTIL_LINUX_LSFD_FILTER_H */ |