1 /*	$NetBSD: mac_expand.h,v 1.4 2022/10/08 16:12:50 christos Exp $	*/
2 
3 #ifndef _MAC_EXPAND_H_INCLUDED_
4 #define _MAC_EXPAND_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	mac_expand 3h
9 /* SUMMARY
10 /*	expand macro references in string
11 /* SYNOPSIS
12 /*	#include <mac_expand.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * Utility library.
18   */
19 #include <vstring.h>
20 #include <mac_parse.h>
21 
22  /*
23   * Features.
24   */
25 #define MAC_EXP_FLAG_NONE	(0)
26 #define MAC_EXP_FLAG_RECURSE	(1<<0)
27 #define MAC_EXP_FLAG_APPEND	(1<<1)
28 #define MAC_EXP_FLAG_SCAN	(1<<2)
29 #define MAC_EXP_FLAG_PRINTABLE  (1<<3)
30 
31  /*
32   * Token codes, public so tha they are available to mac_expand_add_relop()
33   */
34 #define MAC_EXP_OP_TOK_NONE	0	/* Sentinel */
35 #define MAC_EXP_OP_TOK_EQ	1	/* == */
36 #define MAC_EXP_OP_TOK_NE	2	/* != */
37 #define MAC_EXP_OP_TOK_LT	3	/* < */
38 #define MAC_EXP_OP_TOK_LE	4	/* <= */
39 #define MAC_EXP_OP_TOK_GE	5	/* >= */
40 #define MAC_EXP_OP_TOK_GT	6	/* > */
41 
42  /*
43   * Relational operator results. An enum to discourage assuming that 0 is
44   * false, !0 is true.
45   */
46 typedef enum MAC_EXP_OP_RES {
47     MAC_EXP_OP_RES_TRUE,
48     MAC_EXP_OP_RES_FALSE,
49     MAC_EXP_OP_RES_ERROR,
50 } MAC_EXP_OP_RES;
51 
52 
53 extern MAC_EXP_OP_RES mac_exp_op_res_bool[2];
54 
55  /*
56   * Real lookup or just a test?
57   */
58 #define MAC_EXP_MODE_TEST	(0)
59 #define MAC_EXP_MODE_USE	(1)
60 
61 typedef const char *(*MAC_EXP_LOOKUP_FN) (const char *, int, void *);
62 typedef MAC_EXP_OP_RES (*MAC_EXPAND_RELOP_FN) (const char *, int, const char *);
63 
64 extern int mac_expand(VSTRING *, const char *, int, const char *, MAC_EXP_LOOKUP_FN, void *);
65 void    mac_expand_add_relop(int *, const char *, MAC_EXPAND_RELOP_FN);
66 
67 /* LICENSE
68 /* .ad
69 /* .fi
70 /*	The Secure Mailer license must be distributed with this software.
71 /* AUTHOR(S)
72 /*	Wietse Venema
73 /*	IBM T.J. Watson Research
74 /*	P.O. Box 704
75 /*	Yorktown Heights, NY 10598, USA
76 /*
77 /*	Wietse Venema
78 /*	Google, Inc.
79 /*	111 8th Avenue
80 /*	New York, NY 10011, USA
81 /*--*/
82 
83 #endif
84