1 /* $NetBSD: attr.h,v 1.1.1.1 2009/06/23 10:08:58 tron Exp $ */ 2 3 #ifndef _ATTR_H_INCLUDED_ 4 #define _ATTR_H_INCLUDED_ 5 6 /*++ 7 /* NAME 8 /* attr 3h 9 /* SUMMARY 10 /* attribute list manipulations 11 /* SYNOPSIS 12 /* #include "attr.h" 13 DESCRIPTION 14 .nf 15 16 /* 17 * System library. 18 */ 19 #include <stdarg.h> 20 21 /* 22 * Utility library. 23 */ 24 #include <vstream.h> 25 26 /* 27 * Attribute types. See attr_scan(3) for documentation. 28 */ 29 #define ATTR_TYPE_END 0 /* end of data */ 30 #define ATTR_TYPE_INT 1 /* Unsigned integer */ 31 #define ATTR_TYPE_NUM ATTR_TYPE_INT 32 #define ATTR_TYPE_STR 2 /* Character string */ 33 #define ATTR_TYPE_HASH 3 /* Hash table */ 34 #define ATTR_TYPE_NV 3 /* Name-value table */ 35 #define ATTR_TYPE_LONG 4 /* Unsigned long */ 36 #define ATTR_TYPE_DATA 5 /* Binary data */ 37 #define ATTR_TYPE_FUNC 6 /* Function pointer */ 38 39 #define ATTR_HASH_LIMIT 1024 /* Size of hash table */ 40 41 /* 42 * Flags that control processing. See attr_scan(3) for documentation. 43 */ 44 #define ATTR_FLAG_NONE 0 45 #define ATTR_FLAG_MISSING (1<<0) /* Flag missing attribute */ 46 #define ATTR_FLAG_EXTRA (1<<1) /* Flag spurious attribute */ 47 #define ATTR_FLAG_MORE (1<<2) /* Don't skip or terminate */ 48 49 #define ATTR_FLAG_STRICT (ATTR_FLAG_MISSING | ATTR_FLAG_EXTRA) 50 #define ATTR_FLAG_ALL (07) 51 52 /* 53 * Delegation for better data abstraction. 54 */ 55 typedef int (*ATTR_SCAN_MASTER_FN) (VSTREAM *, int, ...); 56 typedef int (*ATTR_SCAN_SLAVE_FN) (ATTR_SCAN_MASTER_FN, VSTREAM *, int, void *); 57 typedef int (*ATTR_PRINT_MASTER_FN) (VSTREAM *, int,...); 58 typedef int (*ATTR_PRINT_SLAVE_FN) (ATTR_PRINT_MASTER_FN, VSTREAM *, int, void *); 59 60 /* 61 * Default to null-terminated, as opposed to base64-encoded. 62 */ 63 #define attr_print attr_print0 64 #define attr_vprint attr_vprint0 65 #define attr_scan attr_scan0 66 #define attr_vscan attr_vscan0 67 68 /* 69 * attr_print64.c. 70 */ 71 extern int attr_print64(VSTREAM *, int,...); 72 extern int attr_vprint64(VSTREAM *, int, va_list); 73 74 /* 75 * attr_scan64.c. 76 */ 77 extern int attr_scan64(VSTREAM *, int,...); 78 extern int attr_vscan64(VSTREAM *, int, va_list); 79 80 /* 81 * attr_print0.c. 82 */ 83 extern int attr_print0(VSTREAM *, int,...); 84 extern int attr_vprint0(VSTREAM *, int, va_list); 85 86 /* 87 * attr_scan0.c. 88 */ 89 extern int attr_scan0(VSTREAM *, int,...); 90 extern int attr_vscan0(VSTREAM *, int, va_list); 91 92 /* 93 * attr_scan_plain.c. 94 */ 95 extern int attr_print_plain(VSTREAM *, int,...); 96 extern int attr_vprint_plain(VSTREAM *, int, va_list); 97 98 /* 99 * attr_print_plain.c. 100 */ 101 extern int attr_scan_plain(VSTREAM *, int,...); 102 extern int attr_vscan_plain(VSTREAM *, int, va_list); 103 104 105 /* 106 * Attribute names for testing the compatibility of the read and write 107 * routines. 108 */ 109 #ifdef TEST 110 #define ATTR_NAME_INT "number" 111 #define ATTR_NAME_STR "string" 112 #define ATTR_NAME_LONG "long_number" 113 #define ATTR_NAME_DATA "data" 114 #endif 115 116 /* LICENSE 117 /* .ad 118 /* .fi 119 /* The Secure Mailer license must be distributed with this software. 120 /* AUTHOR(S) 121 /* Wietse Venema 122 /* IBM T.J. Watson Research 123 /* P.O. Box 704 124 /* Yorktown Heights, NY 10598, USA 125 /*--*/ 126 127 #endif 128