aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Howell <leo@lwh.jp>2009-09-26 11:44:37 +0900
committerLeo Howell <leo@lwh.jp>2009-09-26 13:24:43 +0900
commit825c45bed29693e9420abecdeb4ebcd03aa3accd (patch)
tree8e7ae369e845083d815b31c62d9f8a80e32cd890
parent69b03a15eb048c05b31a5cc6128c27acc77c1dd5 (diff)
downloadpdf-simple-sign-825c45bed29693e9420abecdeb4ebcd03aa3accd.tar.gz
pdf-simple-sign-825c45bed29693e9420abecdeb4ebcd03aa3accd.tar.xz
pdf-simple-sign-825c45bed29693e9420abecdeb4ebcd03aa3accd.zip
implement bitstream_cat()
-rw-r--r--lpg/libqr/bitstream.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lpg/libqr/bitstream.c b/lpg/libqr/bitstream.c
index a2b2b58..fd58ea3 100644
--- a/lpg/libqr/bitstream.c
+++ b/lpg/libqr/bitstream.c
@@ -201,3 +201,32 @@ int bitstream_pack(struct bitstream * stream,
return 0;
}
+int bitstream_cat(struct bitstream * dest, const struct bitstream * src)
+{
+ size_t count = bitstream_size(src);
+ size_t srcpos;
+
+ if (ensure_available(dest, count) != 0)
+ return -1;
+
+ srcpos = bitstream_tell(src);
+ bitstream_seek((struct bitstream *)src, 0);
+
+ /* uint must be at least 16 bits */
+ for (; count >= 16; count -= 16)
+ bitstream_write(
+ dest,
+ bitstream_read((struct bitstream *)src, 16),
+ 16);
+
+ if (count > 0)
+ bitstream_write(
+ dest,
+ bitstream_read((struct bitstream *)src, count),
+ count);
+
+ bitstream_seek((struct bitstream *)src, srcpos);
+
+ return 0;
+}
+