gffdBegin, gffdEnd - begin and end a matching sequence
#include <gffd/gffd.h>
int gffdBegin(gffd_context_t ctx);
int gffdEnd(gffd_context_t ctx);
A "matching sequence" is a series of calls which are used to match or prune a set of possible matches for a file. gffdBegin() is used to begin a matching sequence, and causes the context to be filled with the set of all possible matches, each with a score of zero. Subsequent operations will update the scores and/or remove possible matches from the set.
gffdEnd() is used to finished a matching sequence. The calls to the gffdMatchXX(), gffdPruneXX(), gffdGetCount() and gffdGetMatchXX() functions can only occur in between a gffdBegin/gffdEnd pair.
On success, gffdBegin() and gffdEnd() return zero, otherwise they return a negative error code, such as GFFD_E_BAD_PLACE if they are used in the wrong order (e.g. gffdEnd without gffdBegin).
/* begin matching sequence */
gffdBegin(my_gffd);
/* match a filename */
gffdMatchName(my_gffd, "foo.jpeg");
/* prune all matches that have a score of zero */
gffdPruneScore(my_gffd, 0);
/* check if there were any matches */
if (gffdGetCount(my_gffd) >= 1)
{
/* show information for match #0 */
printf("Score: %d\n", gffdGetMatchScore(my_gffd, 0));
printf("Class: %s\n", gffdGetMatchClass(my_gffd, 0));
printf("Type: %s\n", gffdGetMatchType(my_gffd, 0));
}
/* end matching sequence */
gffdEnd(my_gffd);