/*++ /* NAME /* mac_expand 3 /* SUMMARY /* attribute expansion /* SYNOPSIS /* #include <mac_expand.h> /* /* int mac_expand7(result, pattern, flags, filter, lookup, /* dont_expand, context) /* VSTRING *result; /* const char *pattern; /* int flags; /* const char *filter; /* const char *lookup(const char *key, int mode, void *context) /* const bool dont_parse(const char *key, void *context) /* void *context; /* AUXILIARY FUNCTIONS /* int mac_expand(result, pattern, flags, filter, lookup, context) /* VSTRING *result; /* const char *pattern; /* int flags; /* const char *filter; /* const char *lookup(const char *key, int mode, void *context) /* void *context; /* /* typedef MAC_EXP_OP_RES (*MAC_EXPAND_RELOP_FN) ( /* const char *left, /* int tok_val, /* const char *rite) /* /* void mac_expand_add_relop( /* int *tok_list, /* const char *suffix, /* MAC_EXPAND_RELOP_FN relop_eval) /* /* MAC_EXP_OP_RES mac_exp_op_res_bool[2]; / /* typedef int (*MAC_EXPAND_NAMED_FN) ( /* VSTRING *out, /* const char *arg) /* /* void mac_expand_add_named_fn( /* const char *name, /* MAC_EXPAND_NAMED_FN action) /* DESCRIPTION /* This module implements parameter-less named attribute /* expansions, both conditional and unconditional. As of Postfix /* 3.0 this code supports relational expression evaluation. /* /* In this text, an attribute is considered "undefined" when its value /* is a null pointer. Otherwise, the attribute is considered "defined" /* and is expected to have as value a null-terminated string. /* /* In the text below, the legacy form $(...) is equivalent to /* ${...}. The legacy form $(...) may eventually disappear /* from documentation. In the text below, the name in $name /* and ${name...} must contain only characters from the set /* [a-zA-Z0-9_]. /* /* The following substitutions are supported: /* .IP "$name, ${name}" /* Unconditional attribute-based substitution. The result is the /* named attribute value (empty if the attribute is not defined) /* after optional further named attribute substitution. /* .IP "${name?text}, ${name?{text}}" /* Conditional attribute-based substitution. If the named attribute /* value is non-empty, the result is the given text, after /* named attribute expansion and relational expression evaluation. /* Otherwise, the result is empty. Whitespace before or after /* {text} is ignored. /* .IP "${name{text}}" /* Apply the registered function \fIname\fR to the specified text /* after named attribute expansion and expression evaluation, /* and replace this input with the function result. Functions are /* registered with mac_expand_add_named_fn(). /* .IP "${name:text}, ${name:{text}}" /* Conditional attribute-based substitution. If the attribute /* value is empty or undefined, the expansion is the given /* text, after named attribute expansion and relational expression /* evaluation. Otherwise, the result is empty. Whitespace /* before or after {text} is ignored. /* .IP "${name?{text1}:{text2}}, ${name?{text1}:text2}" /* Conditional attribute-based substitution. If the named attribute /* value is non-empty, the result is text1. Otherwise, the /* result is text2. In both cases the result is subject to /* named attribute expansion and relational expression evaluation. /* Whitespace before or after {text1} or {text2} is ignored. /* .IP "${{text1} == ${text2} ? {text3} : {text4}}" /* Relational expression-based substitution. First, the content /* of {text1} and ${text2} is subjected to named attribute and /* relational expression-based substitution. Next, the relational /* expression is evaluated. If it evaluates to "true", the /* result is the content of {text3}, otherwise it is the content /* of {text4}, after named attribute and relational expression-based /* substitution. In addition to ==, this supports !=, <, <=, /* >=, and >. Comparisons are numerical when both operands are /* all digits, otherwise the comparisons are lexicographical. /* /* Arguments: /* .IP result /* Storage for the result of expansion. By default, the result /* is truncated upon entry. /* .IP pattern /* The string to be expanded. /* .IP flags /* Bit-wise OR of zero or more of the following: /* .RS /* .IP MAC_EXP_FLAG_RECURSE /* Expand attributes in lookup results. This should never be /* done with data whose origin is untrusted. /* .IP MAC_EXP_FLAG_APPEND /* Append text to the result buffer without truncating it. /* .IP MAC_EXP_FLAG_SCAN /* Scan the input for named attributes, including named /* attributes in all conditional result values. Do not expand /* named attributes, and do not truncate or write to the result /* argument. /* .IP MAC_EXP_FLAG_PRINTABLE /* Use the printable() function instead of \fIfilter\fR. /* .PP /* The constant MAC_EXP_FLAG_NONE specifies a manifest null value. /* .RE /* .IP filter /* A null pointer, or a null-terminated array of characters that /* are allowed to appear in an expansion. Illegal characters are /* replaced by underscores. /* .IP lookup /* The attribute lookup routine. Arguments are: the attribute name, /* MAC_EXP_MODE_TEST to test the existence of the named attribute /* or MAC_EXP_MODE_USE to use the value of the named attribute, /* and the caller context that was given to mac_expand(). A null /* result value means that the requested attribute was not defined. /* .IP don_parse /* An optional function that disables the MAC_EXP_FLAG_RECURSE /* feature with lookup() results for a specific attribute. Arguments /* are: the attribute name, and the caller context that was given /* to mac_expand(). Specify null to disable this feature. /* .IP context /* Caller context that is passed on to the attribute lookup and /* don_parse routines. /* .PP /* mac_expand_add_relop() registers a function that implements /* support for custom relational operators. Custom operator names /* such as "==xxx" have two parts: a prefix that is identical to /* a built-in operator such as "==", and an application-specified /* suffix such as "xxx". /* /* Arguments: /* .IP tok_list /* A null-terminated list of MAC_EXP_OP_TOK_* values that support /* the custom operator suffix. /* .IP suffix /* A null-terminated alphanumeric string that specifies the custom /* operator suffix. /* .IP relop_eval /* A function that compares two strings according to the /* MAC_EXP_OP_TOK_* value specified with the tok_val argument, /* and that returns non-zero if the custom operator evaluates to /* true, zero otherwise. /* /* mac_exp_op_res_bool provides an array that converts a boolean /* value (0 or 1) to the corresponding MAX_EXP_OP_RES_TRUE or /* MAX_EXP_OP_RES_FALSE value. /* /* mac_expand_add_named_fn() registers a C function that may be /* called as ${name{text}}. The function input is the text after /* attribute expansion and expression evaluation. The function /* should append its output to the specified buffer, and it /* should return either MAC_PARSE_OK or MAC_PARSE_ERROR. /* DIAGNOSTICS /* Fatal errors: out of memory. Warnings: syntax errors, unreasonable /* recursion depth. /* /* The mac_expand() result value is the binary OR of zero or more /* of the following: /* .IP MAC_PARSE_ERROR /* A syntax error was found in \fBpattern\fR, or some attribute had /* an unreasonable nesting depth. /* .IP MAC_PARSE_UNDEF /* An attribute was expanded but its value was not defined. /* SEE ALSO /* mac_parse(3) locate macro references in string. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Wietse Venema /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA /* /* Wietse Venema /* porcupine.org
/*--*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.