/*++ /* NAME /* attr_scan_plain 3 /* SUMMARY /* recover attributes from byte stream /* SYNOPSIS /* #include <attr.h> /* /* int attr_scan_plain(fp, flags, type, name, ..., ATTR_TYPE_END) /* VSTREAM *fp; /* int flags; /* int type; /* char *name; /* /* int attr_vscan_plain(fp, flags, ap) /* VSTREAM *fp; /* int flags; /* va_list ap; /* /* int attr_scan_more_plain(fp) /* VSTREAM *fp; /* DESCRIPTION /* attr_scan_plain() takes zero or more (name, value) request attributes /* and recovers the attribute values from the byte stream that was /* possibly generated by attr_print_plain(). /* /* attr_vscan_plain() provides an alternative interface that is convenient /* for calling from within a variadic function. /* /* attr_scan_more_plain() returns 0 when a terminator is found /* (and consumes that terminator), returns 1 when more input /* is expected (without consuming input), and returns -1 /* otherwise (error). /* /* The input stream is formatted as follows, where (item)* stands /* for zero or more instances of the specified item, and where /* (item1 | item2) stands for choice: /* /* .in +5 /* attr-list :== (simple-attr | multi-attr)* newline /* .br /* multi-attr :== "{" newline simple-attr* "}" newline /* .br /* simple-attr :== attr-name "=" attr-value newline /* .br /* attr-name :== any string without null or "=" or newline. /* .br /* attr-value :== any string without null or newline. /* .br /* newline :== the ASCII newline character /* .in /* /* All attribute names and attribute values are sent as plain /* strings. Each string must be no longer than 4*var_line_limit /* characters. The formatting rules aim to make implementations in PERL /* and other languages easy. /* /* Normally, attributes must be received in the sequence as specified /* with the attr_scan_plain() argument list. The input stream may /* contain additional attributes at any point in the input stream, /* including additional instances of requested attributes. /* /* Additional input attributes or input attribute instances are silently /* skipped over, unless the ATTR_FLAG_EXTRA processing flag is specified /* (see below). This allows for some flexibility in the evolution of /* protocols while still providing the option of being strict where /* this is desirable. /* /* Arguments: /* .IP fp /* Stream to recover the input attributes from. /* .IP flags /* The bit-wise OR of zero or more of the following. /* .RS /* .IP ATTR_FLAG_MISSING /* Log a warning when the input attribute list terminates before all /* requested attributes are recovered. It is always an error when the /* input stream ends without the newline attribute list terminator. /* .IP ATTR_FLAG_EXTRA /* Log a warning and stop attribute recovery when the input stream /* contains an attribute that was not requested. This includes the /* case of additional instances of a requested attribute. /* .IP ATTR_FLAG_MORE /* After recovering the requested attributes, leave the input stream /* in a state that is usable for more attr_scan_plain() operations /* from the same input attribute list. /* By default, attr_scan_plain() skips forward past the input attribute /* list terminator. /* .IP ATTR_FLAG_PRINTABLE /* Santize received string values with printable(_, '?'). /* .IP ATTR_FLAG_STRICT /* For convenience, this value combines both ATTR_FLAG_MISSING and /* ATTR_FLAG_EXTRA. /* .IP ATTR_FLAG_NONE /* For convenience, this value requests none of the above. /* .RE /* .IP List of attributes followed by terminator: /* .RS /* .IP "RECV_ATTR_INT(const char *name, int *ptr)" /* This argument is followed by an attribute name and an integer pointer. /* .IP "RECV_ATTR_LONG(const char *name, long *ptr)" /* This argument is followed by an attribute name and a long pointer. /* .IP "RECV_ATTR_STR(const char *name, VSTRING *vp)" /* This argument is followed by an attribute name and a VSTRING pointer. /* .IP "RECV_ATTR_STREQ(const char *name, const char *value)" /* The name and value must match what the client sends. /* This attribute does not increment the result value. /* .IP "RECV_ATTR_DATA(const char *name, VSTRING *vp)" /* This argument is followed by an attribute name and a VSTRING pointer. /* .IP "RECV_ATTR_FUNC(ATTR_SCAN_CUSTOM_FN, void *data)" /* This argument is followed by a function pointer and a generic data /* pointer. The caller-specified function returns < 0 in case of /* error. /* .IP "RECV_ATTR_HASH(HTABLE *table)" /* .IP "RECV_ATTR_NAMEVAL(NVTABLE *table)" /* Receive a sequence of attribute names and string values. /* There can be no more than 1024 attributes in a hash table. /* .sp /* The attribute string values are stored in the hash table under /* keys equal to the attribute name (obtained from the input stream). /* Values from the input stream are added to the hash table. Existing /* hash table entries are not replaced. /* .sp /* Note: the SEND_ATTR_HASH or SEND_ATTR_NAMEVAL requests /* format their payload as a multi-attr sequence (see syntax /* above). When the receiver's input does not start with a /* multi-attr delimiter (i.e. the sender did not request /* SEND_ATTR_HASH or SEND_ATTR_NAMEVAL), the receiver will /* store all attribute names and values up to the attribute /* list terminator. In terms of code, this means that the /* RECV_ATTR_HASH or RECV_ATTR_NAMEVAL request must be followed /* by ATTR_TYPE_END. /* .IP ATTR_TYPE_END /* This argument terminates the requested attribute list. /* .RE /* BUGS /* RECV_ATTR_HASH (RECV_ATTR_NAMEVAL) accepts attributes with arbitrary /* names from possibly untrusted sources. /* This is unsafe, unless the resulting table is queried only with /* known to be good attribute names. /* DIAGNOSTICS /* attr_scan_plain() and attr_vscan_plain() return -1 when malformed input /* is detected (string too long, incomplete line, missing end marker). /* Otherwise, the result value is the number of attributes that were /* successfully recovered from the input stream (a hash table counts /* as the number of entries stored into the table). /* /* Panic: interface violation. All system call errors are fatal. /* SEE ALSO /* attr_print_plain(3) send attributes over byte stream. /* 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
/*--*/
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.