Main Page   Modules   Data Structures   File List   Data Fields   Globals  

mask.h File Reference

Implements mask classes as flat function sets. More...

#include "translations.h"

Go to the source code of this file.

Constructors

DLLIMPORT dar_maskdar_mask_create_same_path (char *path, bool case_sensit)
 Matches if string is exactly the given mask (without wildcard expressions).

DLLIMPORT dar_maskdar_mask_create_bool (bool always)
 Always matches or never matches.

DLLIMPORT dar_maskdar_mask_create_and ()
 Evaluates the logical and between two or more masks.

DLLIMPORT dar_maskdar_mask_create_or ()
 Evaluates the logical or between two or more masks.

DLLIMPORT dar_maskdar_mask_create_exclude_dir (char *path, bool case_sensit)
 Matches any file and it's children.

DLLIMPORT dar_maskdar_mask_create_not (dar_mask *mask)
 Negation of another mask.

DLLIMPORT dar_maskdar_mask_create_regular (char *expr, bool case_sensit)
 Full regular expression matching.

DLLIMPORT dar_maskdar_mask_create_simple (char *expr, bool case_sensit)
 Simple text matching similiar to that done on the command line.

DLLIMPORT dar_maskdar_mask_create_simple_path (char *path, bool case_sensit)
 Matches any path and it's children plus any parents of that given path.

DLLIMPORT void dar_mask_destroy (dar_mask *mask)
 Frees memory used by mask object.


Functions

DLLIMPORT void dar_mask_and_add (dar_mask *ref, dar_mask *new_mask)
 Expands a union by adding another mask to an and mask.

DLLIMPORT void dar_mask_and_clear (dar_mask *ref)
 Clears all entries from an and mask.

DLLIMPORT U_I dar_mask_and_size (dar_mask *ref)
 Gets the number of elements in a union.

DLLIMPORT void dar_mask_or_add (dar_mask *ref, dar_mask *new_mask)
 Narrows an intersection by adding another mask to an or mask.

DLLIMPORT void dar_mask_or_clear (dar_mask *ref)
 Clears all entries from an or mask.

DLLIMPORT U_I dar_mask_or_size (dar_mask *ref)
 Gets the number of elements in an intersection.


Detailed Description

Implements mask classes as flat function sets.

Definition in file mask.h.


Function Documentation

DLLIMPORT void dar_mask_and_add dar_mask   ref,
dar_mask   new_mask
 

Expands a union by adding another mask to an and mask.

Note:
It is important that only an and mask is used as the reference argument to this function. If the reference argument is not appropriate, null will be returned.

Definition at line 111 of file mask.cpp.

DLLIMPORT void dar_mask_and_clear dar_mask   ref
 

Clears all entries from an and mask.

Note:
It is important that only an and mask is used as the reference argument to this function. If the reference argument is not appropriate, the invalid reference mask will be returned unmodified.

Definition at line 119 of file mask.cpp.

DLLIMPORT U_I dar_mask_and_size dar_mask   ref
 

Gets the number of elements in a union.

Note:
It is important that only an and mask is used as the reference argument to this function. If the reference argument is not appropriate, the value zero will be returned.

Definition at line 126 of file mask.cpp.

DLLIMPORT dar_mask* dar_mask_create_and  
 

Evaluates the logical and between two or more masks.

Given the paths:

  • /foo
  • /foo/bar
  • /fast
  • /this
We use an and mask to combine two simple masks.

dar_mask* result = dar_mask_create_and();
dar_mask* m1 = dar_mask_create_simple("/f*", TRUE);
dar_mask* m2 = dar_mask_create_simple("*bar", TRUE);
dar_mask_and_add( m1 );
dar_mask_and_add( m2 );
dar_mask_destroy( m1 );
dar_mask_destroy( m2 );

The resulting match will be:

  • /foo/bar

Definition at line 59 of file mask.cpp.

DLLIMPORT dar_mask* dar_mask_create_exclude_dir char *    path,
bool    case_sensit
 

Matches any file and it's children.

Despite the name, this mask does not implicitly exclude. Wrap in a not mask to implement exclusion.

Given the paths:

  • /
  • /foo
  • /foo/bar
  • /foo/this
  • /foo/bar/fast
  • /foo/bar/faster
  • /slow
In this example we want to select only the path "/foo/bar" and exclude everything else. We will attempt that will an exclude directory mask. However, read below for an important warning about this.

dar_mask* result = dar_mask_create_exclude_dir( "/foo/bar", TRUE );

The resulting matches will be:

  • /foo/bar
  • /foo/bar/fast
  • /foo/bar/faster
NOTE WELL that the above example, assuming that we are creating our backup from the root directory ("/") may not work as expected! This is because while "bar" and its children will be accepted, "/" and "/foo" will not, meaning that there will be no directories to attach "bar" to.

To fix this problem, you must (if you really want to save the absolute path) use a simple path mask or save only the relative path information. In such a case:

Given the paths:

  • bar
  • bar/fast
  • bar/faster
You will be able to use an exclude directory mask, passing the string "bar" instead of "/foo/bar".

NOTE FURTHER that if you use a relative path a simple mask will often be easier.

Really, the exclude directory mask is meant for excluding specific paths within a hierarchy. When wrapped in a not mask the combination will provide the expected behavior.

dar_mask* m = dar_mask_create_exclude_dir( "/foo/bar", TRUE );
dar_mask* result = dar_mask_create_not( m );
dar_mask_destroy( m );

Given the original paths, the above code will produce the following matches:

  • /
  • /foo
  • /foo/this
  • /slow

Definition at line 69 of file mask.cpp.

DLLIMPORT dar_mask* dar_mask_create_not dar_mask   mask
 

Negation of another mask.

Useful for selective exclusion.

Given the paths:

  • /foo
  • /foo/bar
  • /fast
  • /this
We can use a simple mask wrapped in a not mask to exclude a desired path.

dar_mask* m = dar_mask_create_simple("/this", TRUE);
dar_mask* result = dar_mask_create_not( m );
dar_mask_destroy( m );

The resulting matches will be:

  • /foo
  • /foo/bar
  • /fast

Definition at line 76 of file mask.cpp.

DLLIMPORT dar_mask* dar_mask_create_or  
 

Evaluates the logical or between two or more masks.

Given the paths:

  • /foo
  • /foo/bar
  • /fast
  • /this
We use an or mask to combine two simple masks.

dar_mask* result = dar_mask_create_or();
dar_mask* m1 = dar_mask_create_simple("/f*", TRUE);
dar_mask* m2 = dar_mask_create_simple("/t*", TRUE);
dar_mask_or_add( m1 );
dar_mask_or_add( m2 );
dar_mask_destroy( m1 );
dar_mask_destroy( m2 );

The resulting matches will be:

  • /foo
  • /foo/bar
  • /fast
  • /this

Definition at line 64 of file mask.cpp.

DLLIMPORT dar_mask* dar_mask_create_regular char *    expr,
bool    case_sensit
 

Full regular expression matching.

See man 7 regex for more information.

Definition at line 83 of file mask.cpp.

DLLIMPORT dar_mask* dar_mask_create_same_path char *    path,
bool    case_sensit
 

Matches if string is exactly the given mask (without wildcard expressions).

Remember to destroy your input path when finished with it!

Definition at line 44 of file mask.cpp.

DLLIMPORT dar_mask* dar_mask_create_simple char *    expr,
bool    case_sensit
 

Simple text matching similiar to that done on the command line.

See man 7 glob for more information.

Definition at line 90 of file mask.cpp.

DLLIMPORT dar_mask* dar_mask_create_simple_path char *    path,
bool    case_sensit
 

Matches any path and it's children plus any parents of that given path.

Given the paths:

  • /
  • /foo
  • /foo/bar
  • /foo/this
  • /foo/bar/fast
  • /foo/bar/faster
  • /slow
In this example, we want to save everything in the directory "bar". Instead of passing the relative path, we want to save the whole tree, but want to exclude any excess data.

dar_mask* result = dar_mask_create_simple_path( "/foo/bar", TRUE );

The resulting matches will be:

  • /
  • /foo
  • /foo/bar
  • /foo/bar/fast
  • /foo/bar/faster
These extra directories would be excluded:
  • /slow
  • /foo/this

Definition at line 97 of file mask.cpp.

DLLIMPORT void dar_mask_destroy dar_mask   mask
 

Frees memory used by mask object.

Works for all mask types.

Definition at line 104 of file mask.cpp.

Referenced by dar_sup_spec_destroy(), and dar_sup_storage_destroy().

DLLIMPORT void dar_mask_or_add dar_mask   ref,
dar_mask   new_mask
 

Narrows an intersection by adding another mask to an or mask.

Note:
It is important that only an or mask is used as the reference argument to this function. If the reference argument is not appropriate, null will be returned.

Definition at line 132 of file mask.cpp.

DLLIMPORT void dar_mask_or_clear dar_mask   ref
 

Clears all entries from an or mask.

Note:
It is important that only an or mask is used as the reference argument to this function. If the reference argument is not appropriate, the invalid reference mask will be returned unmodified.

Definition at line 140 of file mask.cpp.

DLLIMPORT U_I dar_mask_or_size dar_mask   ref
 

Gets the number of elements in an intersection.

Note:
It is important that only an or mask is used as the reference argument to this function. If the reference argument is not appropriate, the value zero will be returned.

Definition at line 147 of file mask.cpp.