aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr/data-common.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2025-01-10 15:58:57 +0100
committerPřemysl Eric Janouch <p@janouch.name>2025-01-10 16:02:45 +0100
commit9319d14566e5d1bfec617c479b8543a9ee3ad4ea (patch)
treeb0130ae9e5ac2932c88ff99b83c83d23126d91bc /lpg/libqr/data-common.c
parent147b8805247ca23fb96e51694f78439ab24f93a2 (diff)
parentab64314222aca47dd7e52eca2d54d2fad0a58f6c (diff)
downloadpdf-simple-sign-9319d14566e5d1bfec617c479b8543a9ee3ad4ea.tar.gz
pdf-simple-sign-9319d14566e5d1bfec617c479b8543a9ee3ad4ea.tar.xz
pdf-simple-sign-9319d14566e5d1bfec617c479b8543a9ee3ad4ea.zip
Merge remote-tracking branch 'libqr/master'
Diffstat (limited to 'lpg/libqr/data-common.c')
-rw-r--r--lpg/libqr/data-common.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/lpg/libqr/data-common.c b/lpg/libqr/data-common.c
new file mode 100644
index 0000000..af3a766
--- /dev/null
+++ b/lpg/libqr/data-common.c
@@ -0,0 +1,38 @@
+#include <stdlib.h>
+
+#include <qr/bitstream.h>
+#include <qr/data.h>
+
+void qr_data_destroy(struct qr_data * data)
+{
+ qr_bitstream_destroy(data->bits);
+ free(data);
+}
+
+size_t qr_data_size_field_length(int version, enum qr_data_type type)
+{
+ static const size_t QR_SIZE_LENGTHS[3][4] = {
+ { 10, 9, 8, 8 },
+ { 12, 11, 16, 10 },
+ { 14, 13, 16, 12 }
+ };
+ int row, col;
+
+ switch (type) {
+ case QR_DATA_NUMERIC: col = 0; break;
+ case QR_DATA_ALPHA: col = 1; break;
+ case QR_DATA_8BIT: col = 2; break;
+ case QR_DATA_KANJI: col = 3; break;
+ default: return 0;
+ }
+
+ if (version < 10)
+ row = 0;
+ else if (version < 27)
+ row = 1;
+ else
+ row = 2;
+
+ return QR_SIZE_LENGTHS[row][col];
+}
+