2 * Generating V33 buckets
4 * (c) 2004, Robert Spalek <robert@ucw.cz>
8 #include "lib/fastbuf.h"
9 #include "lib/obj2buck.h"
10 #include "lib/bucket.h"
11 #include "charset/unistream.h"
19 attr_set_type(uns type)
21 use_v33 = (type == BUCKET_TYPE_V33 || type == BUCKET_TYPE_V33_LIZARD);
25 put_attr(byte *ptr, uns type, byte *val, uns len)
30 memcpy(ptr, val, len);
37 memcpy(ptr, val, len);
45 put_attr_str(byte *ptr, uns type, byte *val)
47 return put_attr(ptr, type, val, strlen(val));
51 put_attr_vformat(byte *ptr, uns type, byte *mask, va_list va)
55 uns len = vsprintf(ptr+1, mask, va);
58 byte tmp[6], *tmp_end = tmp;
59 PUT_UTF8(tmp_end, len+1);
60 uns l = tmp_end - tmp;
61 memmove(ptr+l, ptr+1, len);
75 ptr += vsprintf(ptr, mask, va);
82 put_attr_format(byte *ptr, uns type, char *mask, ...)
86 byte *ret = put_attr_vformat(ptr, type, mask, va);
92 put_attr_num(byte *ptr, uns type, uns val)
96 uns len = sprintf(ptr+1, "%d", val) + 1;
102 ptr += sprintf(ptr, "%c%d\n", type, val);
107 bput_attr(struct fastbuf *b, uns type, byte *val, uns len)
124 bput_attr_str(struct fastbuf *b, uns type, byte *val)
126 bput_attr(b, type, val, strlen(val));
130 bput_attr_vformat(struct fastbuf *b, uns type, byte *mask, va_list va)
134 int len = vsnprintf(NULL, 0, mask, va);
136 die("vsnprintf() does not support size=0");
138 vbprintf(b, mask, va);
144 vbprintf(b, mask, va);
150 bput_attr_format(struct fastbuf *b, uns type, char *mask, ...)
154 bput_attr_vformat(b, type, mask, va);
159 bput_attr_num(struct fastbuf *b, uns type, uns val)
164 uns len = sprintf(tmp, "%d", val);
170 bprintf(b, "%c%d\n", type, val);