aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr/qr-bitstream.c
diff options
context:
space:
mode:
authorLeo Howell <leo@lwh.jp>2009-11-01 22:54:33 +0900
committerLeo Howell <leo@lwh.jp>2009-11-01 22:54:33 +0900
commit4eee8658be637fde410f429e69e86b034cd39185 (patch)
tree0de9cd32261559bad15373d7cad4026748d2f356 /lpg/libqr/qr-bitstream.c
parent0b61708d12b30ce6dc174554794d674eb9f99dad (diff)
downloadpdf-simple-sign-4eee8658be637fde410f429e69e86b034cd39185.tar.gz
pdf-simple-sign-4eee8658be637fde410f429e69e86b034cd39185.tar.xz
pdf-simple-sign-4eee8658be637fde410f429e69e86b034cd39185.zip
support for multiple ec blocks
Diffstat (limited to 'lpg/libqr/qr-bitstream.c')
-rw-r--r--lpg/libqr/qr-bitstream.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/lpg/libqr/qr-bitstream.c b/lpg/libqr/qr-bitstream.c
index b223f4c..c752cde 100644
--- a/lpg/libqr/qr-bitstream.c
+++ b/lpg/libqr/qr-bitstream.c
@@ -80,7 +80,7 @@ void qr_bitstream_destroy(struct qr_bitstream * stream)
free(stream);
}
-struct qr_bitstream * qr_bitstream_copy(const struct qr_bitstream * src)
+struct qr_bitstream * qr_bitstream_dup(const struct qr_bitstream * src)
{
struct qr_bitstream * ret;
@@ -210,6 +210,20 @@ int qr_bitstream_cat(struct qr_bitstream * dest, const struct qr_bitstream * src
srcpos = qr_bitstream_tell(src);
qr_bitstream_seek((struct qr_bitstream *)src, 0);
+ qr_bitstream_copy(dest, (struct qr_bitstream *)src, count);
+ qr_bitstream_seek((struct qr_bitstream *)src, srcpos);
+
+ return 0;
+}
+
+int qr_bitstream_copy(struct qr_bitstream * dest,
+ struct qr_bitstream * src,
+ size_t count)
+{
+ if (qr_bitstream_remaining(src) < count)
+ return -1;
+ if (ensure_available(dest, count) != 0)
+ return -1;
/* uint must be at least 16 bits */
for (; count >= 16; count -= 16)
@@ -224,8 +238,6 @@ int qr_bitstream_cat(struct qr_bitstream * dest, const struct qr_bitstream * src
qr_bitstream_read((struct qr_bitstream *)src, count),
count);
- qr_bitstream_seek((struct qr_bitstream *)src, srcpos);
-
return 0;
}