]> mj.ucw.cz Git - libucw.git/commitdiff
Parsing of PLAIN type buckets also ends after buck_len bytes.
authorMartin Mares <mj@ucw.cz>
Fri, 16 Jul 2004 18:32:35 +0000 (18:32 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 16 Jul 2004 18:32:35 +0000 (18:32 +0000)
obj_read_multi() is gone.

lib/buck2obj.c
lib/object.h

index 1daabed91e698b39237ed71f119abde95282004e..e90ff875447eead2125b08e7d8624804df20a612 100644 (file)
@@ -83,11 +83,17 @@ decode_attributes(byte *ptr, byte *end, struct odes *o, uns can_overwrite)
 int
 buck2obj_parse(struct buck2obj_buf *buf, uns buck_type, uns buck_len, struct fastbuf *body, struct odes *o_hdr, uns *body_start, struct odes *o_body)
 {
-  if (buck_type == BUCKET_TYPE_PLAIN)
+  if (buck_type <= BUCKET_TYPE_PLAIN)
   {
-    if (body_start)
+    if (body_start)                    // there is no header part
       *body_start = 0;
-    obj_read_multi(body, o_hdr);       // ignore empty lines, read until EOF or NUL
+    // ignore empty lines and read until the end of the bucket
+    sh_off_t end = btell(body) + buck_len;
+    byte buf[MAX_ATTR_SIZE];
+    while (btell(body) < end && bgets(body, buf, sizeof(buf)))
+      if (buf[0])
+       obj_add_attr(o_hdr, buf[0], buf+1);
+    ASSERT(btell(body) == end);
   }
   else if (buck_type == BUCKET_TYPE_V30)
   {
@@ -186,13 +192,3 @@ obj_read(struct fastbuf *f, struct odes *o)
     }
   return 0;
 }
-
-void
-obj_read_multi(struct fastbuf *f, struct odes *o)
-{
-  /* Read a multi-part object ending with either EOF or a NUL character */
-  byte buf[MAX_ATTR_SIZE];
-  while (bpeekc(f) > 0 && bgets(f, buf, sizeof(buf)))
-    if (buf[0])
-      obj_add_attr(o, buf[0], buf+1);
-}
index 79a9605b9191297382015fb8b76d161372ba0203..01c47dfbbf27b629f5ae01b52589c243f2316717 100644 (file)
@@ -60,7 +60,6 @@ struct odes *obj_read_bucket(struct buck2obj_buf *buf, struct mempool *pool, uns
    */
 
 int obj_read(struct fastbuf *, struct odes *);
-void obj_read_multi(struct fastbuf *, struct odes *);
 
 /* obj2buck.c: Generating buckets from objects */