From f02995ab2dfba8b686a155118a35ae20a3328b94 Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Fri, 25 Jun 2004 16:58:55 +0000 Subject: [PATCH] it is possible to specify whether the caller only wants the header or also the body --- lib/buck2obj.c | 11 +++++++++-- lib/buck2obj.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/buck2obj.c b/lib/buck2obj.c index ef999f12..4ea6a5cc 100644 --- a/lib/buck2obj.c +++ b/lib/buck2obj.c @@ -119,13 +119,18 @@ decode_attributes(byte *ptr, byte *end, struct odes *o, uns can_overwrite) } struct odes * -buck2obj_convert(struct buck2obj_buf *buf, uns buck_type, struct fastbuf *body) +buck2obj_convert(struct buck2obj_buf *buf, uns buck_type, struct fastbuf *body, uns want_body) { mp_flush(buf->mp); struct odes *o = obj_new(buf->mp); if (buck_type < BUCKET_TYPE_V33) - obj_read_multi(body, o); + { + if (want_body) // ignore empty lines, read until EOF + obj_read_multi(body, o); + else // end on EOF or the first empty line + obj_read(body, o); + } else { /* Compute the length of the bucket. We cannot fetch this attribute @@ -158,6 +163,8 @@ buck2obj_convert(struct buck2obj_buf *buf, uns buck_type, struct fastbuf *body) end = ptr + len; ptr = decode_attributes(ptr, end, o, can_overwrite);// header + if (!want_body) + return o; if (buck_type == BUCKET_TYPE_V33) ; else if (buck_type == BUCKET_TYPE_V33_LIZARD) // decompression diff --git a/lib/buck2obj.h b/lib/buck2obj.h index 87d64d92..f2ca8966 100644 --- a/lib/buck2obj.h +++ b/lib/buck2obj.h @@ -11,7 +11,7 @@ struct buck2obj_buf; struct buck2obj_buf *buck2obj_alloc(uns max_len, struct mempool *mp); void buck2obj_free(struct buck2obj_buf *buf); void buck2obj_realloc(struct buck2obj_buf *buf, uns max_len); -struct odes *buck2obj_convert(struct buck2obj_buf *buf, uns buck_type, struct fastbuf *body); +struct odes *buck2obj_convert(struct buck2obj_buf *buf, uns buck_type, struct fastbuf *body, uns want_body); /* If BCONFIG_CAN_OVERWRITE(body)==2, then the buffer of body has probably * been tampered (unless the bucket is larger than the buffer). In such a * case, you must call bflush(body) before you do anything else than -- 2.39.2