~ubuntu-branches/ubuntu/vivid/postfix/vivid-proposed

« back to all changes in this revision

Viewing changes to src/util/attr_print0.c

Tags: upstream-2.2.6
ImportĀ upstreamĀ versionĀ 2.2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
/* .IP "ATTR_TYPE_STR (char *, char *)"
52
52
/*      This argument is followed by an attribute name and a null-terminated
53
53
/*      string.
 
54
/* .IP "ATTR_TYPE_DATA (char *, int, char *)"
 
55
/*      This argument is followed by an attribute name, an attribute value
 
56
/*      length, and an attribute value pointer.
54
57
/* .IP "ATTR_TYPE_HASH (HTABLE *)"
55
58
/* .IP "ATTR_TYPE_NAMEVAL (NVTABLE *)"
56
59
/*      The content of the table is sent as a sequence of string-valued
89
92
#include <vstream.h>
90
93
#include <htable.h>
91
94
#include <attr.h>
 
95
#include <base64_code.h>
 
96
 
 
97
#define STR(x) vstring_str(x)
 
98
#define LEN(x) VSTRING_LEN(x)
92
99
 
93
100
/* attr_vprint0 - send attribute list to stream */
94
101
 
102
109
    char   *str_val;
103
110
    HTABLE_INFO **ht_info_list;
104
111
    HTABLE_INFO **ht;
 
112
    int     len_val;
 
113
    static VSTRING *base64_buf;
105
114
 
106
115
    /*
107
116
     * Sanity check.
141
150
            if (msg_verbose)
142
151
                msg_info("send attr %s = %s", attr_name, str_val);
143
152
            break;
 
153
        case ATTR_TYPE_DATA:
 
154
            attr_name = va_arg(ap, char *);
 
155
            vstream_fwrite(fp, attr_name, strlen(attr_name) + 1);
 
156
            len_val = va_arg(ap, int);
 
157
            str_val = va_arg(ap, char *);
 
158
            if (base64_buf == 0)
 
159
                base64_buf = vstring_alloc(10);
 
160
            base64_encode(base64_buf, str_val, len_val);
 
161
            vstream_fwrite(fp, STR(base64_buf), LEN(base64_buf) + 1);
 
162
            if (msg_verbose)
 
163
                msg_info("send attr %s = [data %d bytes]", attr_name, len_val);
 
164
            break;
144
165
        case ATTR_TYPE_HASH:
145
166
            ht_info_list = htable_list(va_arg(ap, HTABLE *));
146
167
            for (ht = ht_info_list; *ht; ht++) {
192
213
                ATTR_TYPE_NUM, ATTR_NAME_NUM, 4711,
193
214
                ATTR_TYPE_LONG, ATTR_NAME_LONG, 1234,
194
215
                ATTR_TYPE_STR, ATTR_NAME_STR, "whoopee",
 
216
                ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee",
195
217
                ATTR_TYPE_HASH, table,
196
218
                ATTR_TYPE_END);
197
219
    attr_print0(VSTREAM_OUT, ATTR_FLAG_NONE,
198
220
                ATTR_TYPE_NUM, ATTR_NAME_NUM, 4711,
199
221
                ATTR_TYPE_LONG, ATTR_NAME_LONG, 1234,
200
222
                ATTR_TYPE_STR, ATTR_NAME_STR, "whoopee",
 
223
                ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee",
201
224
                ATTR_TYPE_END);
202
225
    if (vstream_fflush(VSTREAM_OUT) != 0)
203
226
        msg_fatal("write error: %m");