From 3d60a4fe8e95194666956fe7e861101f40571630 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 15 Jul 2004 21:52:29 +0000 Subject: [PATCH] Added {b,}put_attr_separator(). --- lib/obj2buck.c | 21 +++++++++++++++++++++ lib/object.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/lib/obj2buck.c b/lib/obj2buck.c index 0ced895b..a38051a5 100644 --- a/lib/obj2buck.c +++ b/lib/obj2buck.c @@ -17,6 +17,7 @@ #include static uns use_v33; +static int hdr_sep; void attr_set_type(uns type) @@ -24,12 +25,17 @@ attr_set_type(uns type) switch (type) { case BUCKET_TYPE_PLAIN: + use_v33 = 0; + hdr_sep = -1; + break; case BUCKET_TYPE_V30: use_v33 = 0; + hdr_sep = '\n'; break; case BUCKET_TYPE_V33: case BUCKET_TYPE_V33_LIZARD: use_v33 = 1; + hdr_sep = 0; break; default: die("Don't know how to generate buckets of type %08x", type); @@ -118,6 +124,14 @@ put_attr_num(byte *ptr, uns type, uns val) return ptr; } +byte * +put_attr_separator(byte *ptr) +{ + if (hdr_sep >= 0) + *ptr++ = hdr_sep; + return ptr; +} + inline void bput_attr(struct fastbuf *b, uns type, byte *val, uns len) { @@ -185,6 +199,13 @@ bput_attr_num(struct fastbuf *b, uns type, uns val) bprintf(b, "%c%d\n", type, val); } +void +bput_attr_separator(struct fastbuf *b) +{ + if (hdr_sep >= 0) + bputc(b, hdr_sep); +} + void obj_write(struct fastbuf *f, struct odes *d) { diff --git a/lib/object.h b/lib/object.h index 9b79f482..79a9605b 100644 --- a/lib/object.h +++ b/lib/object.h @@ -71,12 +71,14 @@ byte *put_attr_str(byte *ptr, uns type, byte *val); byte *put_attr_vformat(byte *ptr, uns type, byte *mask, va_list va); byte *put_attr_format(byte *ptr, uns type, char *mask, ...) __attribute__((format(printf,3,4))); byte *put_attr_num(byte *ptr, uns type, uns val); +byte *put_attr_separator(byte *ptr); void bput_attr(struct fastbuf *b, uns type, byte *val, uns len); void bput_attr_str(struct fastbuf *b, uns type, byte *val); void bput_attr_vformat(struct fastbuf *b, uns type, byte *mask, va_list va); void bput_attr_format(struct fastbuf *b, uns type, char *mask, ...) __attribute__((format(printf,3,4))); void bput_attr_num(struct fastbuf *b, uns type, uns val); +void bput_attr_separator(struct fastbuf *b); void obj_write(struct fastbuf *, struct odes *); void obj_write_nocheck(struct fastbuf *, struct odes *); -- 2.39.5