match_list.h revision 1.2
1/*	$NetBSD: match_list.h,v 1.2 2017/02/14 01:16:49 christos Exp $	*/
2
3#ifndef _MATCH_LIST_H_INCLUDED_
4#define _MATCH_LIST_H_INCLUDED_
5
6/*++
7/* NAME
8/*	match_list 3h
9/* SUMMARY
10/*	generic list-based pattern matching
11/* SYNOPSIS
12/*	#include <match_list.h>
13/* DESCRIPTION
14/* .nf
15
16 /*
17  * Utility library.
18  */
19#include <argv.h>
20#include <vstring.h>
21
22 /*
23  * External interface.
24  */
25typedef struct MATCH_LIST MATCH_LIST;
26
27typedef int (*MATCH_LIST_FN) (MATCH_LIST *, const char *, const char *);
28
29struct MATCH_LIST {
30    char   *pname;			/* used in error messages */
31    int     flags;			/* processing options */
32    ARGV   *patterns;			/* one pattern each */
33    int     match_count;		/* match function/argument count */
34    MATCH_LIST_FN *match_func;		/* match functions */
35    const char **match_args;		/* match arguments */
36    VSTRING *fold_buf;			/* case-folded pattern string */
37    int     error;			/* last operation */
38};
39
40#define MATCH_FLAG_NONE		0
41#define MATCH_FLAG_PARENT	(1<<0)
42#define MATCH_FLAG_RETURN	(1<<1)
43#define MATCH_FLAG_ALL		(MATCH_FLAG_PARENT | MATCH_FLAG_RETURN)
44
45extern MATCH_LIST *match_list_init(const char *, int, const char *, int,...);
46extern int match_list_match(MATCH_LIST *,...);
47extern void match_list_free(MATCH_LIST *);
48
49 /*
50  * The following functions are not part of the public interface. These
51  * functions may be called only through match_list_match().
52  */
53extern int match_string(MATCH_LIST *, const char *, const char *);
54extern int match_hostname(MATCH_LIST *, const char *, const char *);
55extern int match_hostaddr(MATCH_LIST *, const char *, const char *);
56
57/* LICENSE
58/* .ad
59/* .fi
60/*	The Secure Mailer license must be distributed with this software.
61/* AUTHOR(S)
62/*	Wietse Venema
63/*	IBM T.J. Watson Research
64/*	P.O. Box 704
65/*	Yorktown Heights, NY 10598, USA
66/*--*/
67
68#endif
69