groups and ignore command and functions. More...
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <pcre.h>
#include <sys/mman.h>
#include "global.h"
#include "interface.h"
#include "waa.h"
#include "est_ops.h"
#include "helper.h"
#include "warnings.h"
#include "direnum.h"
#include "ignore.h"
#include "url.h"
Go to the source code of this file.
Defines | |
#define | RESERVE_IGNORE_ENTRIES (4) |
Functions | |
int | ign___translate_bracketed_expr (char *end_of_buffer, char **src, char **dest) |
Processes a character class in shell ignore patterns. | |
int | ign__compile_pattern (struct ignore_t *ignore) |
Compiles the given pattern for use with PCRE . | |
int | ign___init_pattern_into (char *pattern, char *end, struct ignore_t *ignore) |
Does all necessary steps to use the given ignore_t structure. | |
int | ign__load_list (char *dir) |
-. | |
int | ign___compare_dev (struct sstat_t *st, struct ignore_t *ign) |
Compares the given sstat_t st with the device ignore pattern ign. | |
int | ign___new_group (struct ignore_t *ign, struct grouping_t **result) |
int | ign___load_group (struct ignore_t *ign) |
Loads the grouping definitions, and stores them via a grouping_t. | |
int | ign__is_ignore (struct estat *sts, int *is_ignored) |
-. | |
int | ign__save_ignorelist (char *basedir) |
Writes the ignore list back to disk storage. | |
int | ign__new_pattern (unsigned count, char *pattern[], char *ends, int user_pattern, int position) |
Adds a list of new ignore patterns to the internal list. | |
int | ign___parse_position (char *arg, int *position, int *advance) |
Parses the optional position specification. | |
int | ign___test_single_pattern (struct estat *sts) |
int | ign___test_all_patterns (struct estat *sts) |
int | ign__print_group_stats (FILE *output) |
-. | |
int | ign__work (struct estat *root UNUSED, int argc, char *argv[]) |
-. | |
int | ign__rign (struct estat *root UNUSED, int argc, char *argv[]) |
-. | |
Variables | |
apr_hash_t * | ign___groups = NULL |
All groups, addressed by name. | |
int | ign__max_group_name_len = 6 |
The length of the longest group name, used for formatting the status output. | |
static const char | ign_header_str [] = "%u" |
Header definition - currently only number of entries. | |
static const char | ign__group_take [] = "take" |
static const char | ign__group_ign [] = "ignore" |
const char | ign___parm_delimiter = ',' |
int | max_ignore_entries = 0 |
For how many grouping patterns memory is allocated. | |
int | used_ignore_entries = 0 |
How many grouping patterns are actually used. | |
static struct ignore_t * | ignore_list = NULL |
Allocated array of grouping patterns. | |
static char * | memory |
Place where the patterns are mmap()ed. | |
static const char | pcre_prefix [] = "PCRE:" |
The various strings that define the pattern types. | |
static const char | dev_prefix [] = "DEVICE:" |
static const char | inode_prefix [] = "INODE:" |
static const char | norm_prefix [] = { '.', PATH_SEPARATOR, 0 } |
static const char | wildcard_prefix [] = { PATH_SEPARATOR, '*', '*', 0 } |
static const char | abs_shell_prefix [] = { PATH_SEPARATOR, 0 } |
groups and ignore command and functions.
Definition in file ignore.c.
#define RESERVE_IGNORE_ENTRIES (4) |
Definition at line 636 of file ignore.c.
Referenced by ign__new_pattern().
Compares the given sstat_t
st with the device ignore pattern ign.
Does the less-than, greater-than and/or equal comparision.
Definition at line 1395 of file ignore.c.
References sstat_t::dev, ignore_t::has_minor, ignore_t::major, and ignore_t::minor.
Referenced by ign__is_ignore().
int ign___init_pattern_into | ( | char * | pattern, | |
char * | end, | |||
struct ignore_t * | ignore | |||
) |
Does all necessary steps to use the given ignore_t
structure.
Definition at line 960 of file ignore.c.
References abs_shell_prefix, ignore_t::compare, ignore_t::compare_string, DEBUGP, ignore_t::dev, dev_prefix, ignore_t::dir_only, ignore_t::group_name, ignore_t::has_minor, HAVE_CASE, HAVE_DIR, HAVE_GROUP, HAVE_MODE, HAVE_PATTERN, HAVE_PATTERN_SUBST, hlp__strmnalloc(), hlp__strnalloc(), ign___parm_delimiter, ign__compile_pattern(), ign__group_ign, ign__group_take, ign__max_group_name_len, ignore_t::inode, inode_prefix, ignore_t::is_icase, ignore_t::major, ignore_t::minor, ignore_t::mode_match_and, ignore_t::mode_match_cmp, norm_prefix, PAT_DEV__EQUAL, PAT_DEV__GREATER, PAT_DEV__LESS, PAT_DEV__UNSPECIFIED, ignore_t::pattern, pcre_prefix, PT_DEVICE, PT_INODE, PT_PCRE, PT_SHELL, PT_SHELL_ABS, STOPIF, STOPIF_CODE_ERR, and ignore_t::type.
Referenced by ign__new_pattern().
int ign___load_group | ( | struct ignore_t * | ign | ) |
Loads the grouping definitions, and stores them via a grouping_t.
Definition at line 1456 of file ignore.c.
References grouping_t::auto_props, BUG_ON, CONFIGDIR_GROUP, DEBUGP, global_pool, ignore_t::group_def, ignore_t::group_name, GWD_CONF, hlp__get_word(), hlp__skip_ws(), hlp__strdup(), hlp__string_from_filep(), hlp__strmnalloc(), hlp__strnalloc(), IF_FREE, ign___new_group(), ign__group_ign, ign__group_take, grouping_t::is_ignore, grouping_t::is_take, PATH_SEPARATOR, ignore_t::pattern, SFF_COMMENT, SFF_GET_LINENUM, SFF_RESET_LINENUM, SFF_WHITESPACE, STOPIF, STOPIF_CODE_ERR, url_t::url, grouping_t::url, waa__get_waa_directory(), waa_tmp_path_len, and wc_path.
Referenced by ign__is_ignore().
int ign___new_group | ( | struct ignore_t * | ign, | |
struct grouping_t ** | result | |||
) |
Definition at line 1417 of file ignore.c.
References DEBUGP, global_pool, ignore_t::group_def, ignore_t::group_name, hlp__calloc(), ign___groups, and STOPIF.
Referenced by ign___load_group(), and ign__work().
int ign___parse_position | ( | char * | arg, | |
int * | position, | |||
int * | advance | |||
) |
Parses the optional position specification.
Definition at line 1928 of file ignore.c.
References PATTERN_POSITION_END, PATTERN_POSITION_START, STOPIF_CODE_ERR, and used_ignore_entries.
Referenced by ign__rign(), and ign__work().
int ign___test_all_patterns | ( | struct estat * | sts | ) |
Definition at line 1982 of file ignore.c.
References BUG_ON, estat::entry_status, FS_NEW, ignore_t::group_name, estat::match_pattern, ops__build_path(), opt__is_verbose(), ignore_t::pattern, STOPIF, and STOPIF_CODE_EPIPE.
Referenced by ign__work().
int ign___test_single_pattern | ( | struct estat * | sts | ) |
Definition at line 1962 of file ignore.c.
References BUG_ON, estat::entry_status, FS_NEW, estat::match_pattern, ops__build_path(), opt__is_verbose(), STOPIF, and STOPIF_CODE_EPIPE.
Referenced by ign__work().
int ign___translate_bracketed_expr | ( | char * | end_of_buffer, | |
char ** | src, | |||
char ** | dest | |||
) |
Processes a character class in shell ignore patterns.
Definition at line 673 of file ignore.c.
References STOPIF, and STOPIF_CODE_ERR.
Referenced by ign__compile_pattern().
int ign__compile_pattern | ( | struct ignore_t * | ignore | ) |
Compiles the given pattern for use with PCRE
.
Definition at line 740 of file ignore.c.
References BUG, ignore_t::compare_string, ignore_t::compiled, DEBUGP, ignore_t::extra, hlp__alloc(), hlp__realloc(), ign___translate_bracketed_expr(), ignore_t::is_icase, norm_prefix, PATH_SEPARATOR, ignore_t::pattern, PT_PCRE, PT_SHELL, PT_SHELL_ABS, STOPIF, STOPIF_CODE_ERR, ignore_t::type, wa__warn(), wc_path, wc_path_len, wildcard_prefix, and WRN__IGNPAT_WCBASE.
Referenced by ign___init_pattern_into().
int ign__is_ignore | ( | struct estat * | sts, | |
int * | is_ignored | |||
) |
-.
Tells whether the given entry is to be ignored.
Searches this entry for a take/ignore pattern.
If a parent directory has an ignore entry which might be valid for this directory (like **/*~), it is mentioned in this directory, too - in case of something like dir/a*/b*/* a path level value is given.
As we need to preserve the _order_ of the ignore/take statements, we cannot easily optimize. is_ignored is set to +1 if ignored, 0 if unknown, and -1 if on a take-list (overriding later ignore list).
sts must already have the correct estat::st.mode bits set.
Definition at line 1639 of file ignore.c.
References BUG, ignore_t::compare, ignore_t::compiled, DEBUGP, ignore_t::dev, sstat_t::dev, dir___f_sort_by_inodePP(), ignore_t::dir_only, ignore_t::extra, ignore_t::group_def, ign___compare_dev(), ign___load_group(), sstat_t::ino, ignore_t::inode, grouping_t::is_ignore, estat::match_pattern, sstat_t::mode, ignore_t::mode_match_and, ignore_t::mode_match_cmp, ops__build_path(), estat::parent, PAT_DEV__EQUAL, PAT_DEV__GREATER, PAT_DEV__LESS, estat::path_len, ignore_t::pattern, PT_DEVICE, PT_INODE, PT_PCRE, PT_SHELL, PT_SHELL_ABS, estat::st, ignore_t::stats_matches, ignore_t::stats_tested, STOPIF, STOPIF_CODE_ERR, estat::to_be_ignored, ignore_t::type, UNUSED, and used_ignore_entries.
Referenced by au__action(), prp__s_work(), st__status(), waa__build_tree(), and waa__update_dir().
int ign__load_list | ( | char * | dir | ) |
-.
Loads the ignore list from the WAA.
Definition at line 1309 of file ignore.c.
References DEBUGP, ign__new_pattern(), ign_header_str, memory, PATTERN_POSITION_END, STOPIF, STOPIF_CODE_ERR, used_ignore_entries, WAA__IGNORE_EXT, waa__open_byext(), and WAA__READ.
Referenced by au__prepare_for_added(), ci__work(), df__work(), ign__rign(), ign__work(), and st__work().
int ign__new_pattern | ( | unsigned | count, | |
char * | pattern[], | |||
char * | ends, | |||
int | user_pattern, | |||
int | position | |||
) |
Adds a list of new ignore patterns to the internal list.
Definition at line 1834 of file ignore.c.
References BUG_ON, DEBUGP, hlp__realloc(), ign___init_pattern_into(), ignore_t::is_user_pat, max_ignore_entries, PATTERN_POSITION_END, RESERVE_IGNORE_ENTRIES, STOPIF, and used_ignore_entries.
Referenced by ign__load_list(), ign__rign(), and ign__work().
int ign__print_group_stats | ( | FILE * | output | ) |
-.
Print the grouping statistics.
Definition at line 2010 of file ignore.c.
References ignore_t::group_name, ignore_t::is_user_pat, opt__is_verbose(), ignore_t::pattern, ignore_t::stats_matches, ignore_t::stats_tested, STOPIF_CODE_EPIPE, and used_ignore_entries.
Referenced by ign__work(), and st__work().
int ign__rign | ( | struct estat *root | UNUSED, | |
int | argc, | |||
char * | argv[] | |||
) |
-.
Relativizes the given paths, and stores them.
Definition at line 2182 of file ignore.c.
References ac__Usage_this, FCB__NO_REALPATH, FCB__PUT_DOTSLASH, ign___parse_position(), ign__load_list(), ign__new_pattern(), ign__save_ignorelist(), STOPIF, and waa__find_common_base2().
int ign__save_ignorelist | ( | char * | basedir | ) |
Writes the ignore list back to disk storage.
Definition at line 1766 of file ignore.c.
References DEBUGP, HEADER_LEN, ign_header_str, ignore_t::is_user_pat, ignore_t::pattern, STOPIF, STOPIF_CODE_ERR, used_ignore_entries, waa__close(), waa__delete_byext(), WAA__IGNORE_EXT, waa__open_byext(), WAA__WRITE, and wc_path.
Referenced by ign__rign(), and ign__work().
int ign__work | ( | struct estat *root | UNUSED, | |
int | argc, | |||
char * | argv[] | |||
) |
-.
This is called to append new ignore patterns.
Definition at line 2039 of file ignore.c.
References ac__Usage_this, action, DEBUGP, FS_NEW, ignore_t::group_def, HAVE_GROUP, hlp__strdup(), hlp__string_from_filep(), actionlist_t::i_val, ign___new_group(), ign___parse_position(), ign___test_all_patterns(), ign___test_single_pattern(), ign__load_list(), ign__new_pattern(), ign__print_group_stats(), ign__save_ignorelist(), grouping_t::is_ignore, grouping_t::is_take, actionlist_t::local_callback, OPT__FILTER, OPT__GROUP_STATS, opt__is_verbose(), opt__set_int(), parm_dump, parm_load, parm_test, PATTERN_POSITION_END, PRIO_MUSTHAVE, SFF_WHITESPACE, start_path, start_path_len, STOPIF, url__load_list(), used_ignore_entries, waa__find_common_base(), waa__read_or_build_tree(), and wc_path_len.
const char abs_shell_prefix[] = { PATH_SEPARATOR, 0 } [static] |
Definition at line 667 of file ignore.c.
Referenced by ign___init_pattern_into().
const char dev_prefix[] = "DEVICE:" [static] |
Definition at line 661 of file ignore.c.
Referenced by ign___init_pattern_into().
const char ign___parm_delimiter = ',' |
Definition at line 643 of file ignore.c.
Referenced by ign___init_pattern_into().
const char ign__group_ign[] = "ignore" [static] |
Definition at line 641 of file ignore.c.
Referenced by ign___init_pattern_into(), and ign___load_group().
const char ign__group_take[] = "take" [static] |
Definition at line 640 of file ignore.c.
Referenced by ign___init_pattern_into(), and ign___load_group().
int ign__max_group_name_len = 6 |
The length of the longest group name, used for formatting the status output.
This is initialized to 6, because "ignore" at least takes that much space - and "(none)" too.
Definition at line 633 of file ignore.c.
Referenced by ign___init_pattern_into(), and st__print_status().
const char ign_header_str[] = "%u" [static] |
Header definition - currently only number of entries.
Definition at line 639 of file ignore.c.
Referenced by ign__load_list(), and ign__save_ignorelist().
struct ignore_t* ignore_list = NULL [static] |
const char inode_prefix[] = "INODE:" [static] |
Definition at line 662 of file ignore.c.
Referenced by ign___init_pattern_into().
int max_ignore_entries = 0 |
For how many grouping patterns memory is allocated.
Definition at line 646 of file ignore.c.
Referenced by ign__new_pattern().
char* memory [static] |
Place where the patterns are mmap()ed.
Definition at line 654 of file ignore.c.
Referenced by ign__load_list().
const char norm_prefix[] = { '.', PATH_SEPARATOR, 0 } [static] |
Definition at line 663 of file ignore.c.
Referenced by ign___init_pattern_into(), and ign__compile_pattern().
const char pcre_prefix[] = "PCRE:" [static] |
The various strings that define the pattern types.
Definition at line 660 of file ignore.c.
Referenced by ign___init_pattern_into().
int used_ignore_entries = 0 |
How many grouping patterns are actually used.
Definition at line 648 of file ignore.c.
Referenced by ign___parse_position(), ign__is_ignore(), ign__load_list(), ign__new_pattern(), ign__print_group_stats(), ign__save_ignorelist(), and ign__work().
const char wildcard_prefix[] = { PATH_SEPARATOR, '*', '*', 0 } [static] |
Definition at line 665 of file ignore.c.
Referenced by ign__compile_pattern().