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)
23 case BUCKET_TYPE_PLAIN:
28 case BUCKET_TYPE_V33_LIZARD:
32 die("Don't know how to generate buckets of type %08x", type);
37 put_attr(byte *ptr, uns type, byte *val, uns len)
42 memcpy(ptr, val, len);
49 memcpy(ptr, val, len);
57 put_attr_str(byte *ptr, uns type, byte *val)
59 return put_attr(ptr, type, val, strlen(val));
63 put_attr_vformat(byte *ptr, uns type, byte *mask, va_list va)
67 uns len = vsprintf(ptr+1, mask, va);
70 byte tmp[6], *tmp_end = tmp;
71 PUT_UTF8(tmp_end, len+1);
72 uns l = tmp_end - tmp;
73 memmove(ptr+l, ptr+1, len);
87 ptr += vsprintf(ptr, mask, va);
94 put_attr_format(byte *ptr, uns type, char *mask, ...)
98 byte *ret = put_attr_vformat(ptr, type, mask, va);
104 put_attr_num(byte *ptr, uns type, uns val)
108 uns len = sprintf(ptr+1, "%d", val) + 1;
114 ptr += sprintf(ptr, "%c%d\n", type, val);
119 bput_attr(struct fastbuf *b, uns type, byte *val, uns len)
136 bput_attr_str(struct fastbuf *b, uns type, byte *val)
138 bput_attr(b, type, val, strlen(val));
142 bput_attr_vformat(struct fastbuf *b, uns type, byte *mask, va_list va)
146 int len = vsnprintf(NULL, 0, mask, va);
148 die("vsnprintf() does not support size=0");
150 vbprintf(b, mask, va);
156 vbprintf(b, mask, va);
162 bput_attr_format(struct fastbuf *b, uns type, char *mask, ...)
166 bput_attr_vformat(b, type, mask, va);
171 bput_attr_num(struct fastbuf *b, uns type, uns val)
176 uns len = sprintf(tmp, "%d", val);
182 bprintf(b, "%c%d\n", type, val);