aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr/qrparse.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/qrparse.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/qrparse.c')
-rw-r--r--lpg/libqr/qrparse.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/lpg/libqr/qrparse.c b/lpg/libqr/qrparse.c
new file mode 100644
index 0000000..1b5c80e
--- /dev/null
+++ b/lpg/libqr/qrparse.c
@@ -0,0 +1,59 @@
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <qr/code.h>
+#include <qr/data.h>
+#include <qr/parse.h>
+
+#include "testqr.xbm"
+
+int main(int argc, char ** argv)
+{
+ struct qr_data * data;
+ int ret;
+
+ ret = qr_code_parse(testqr_bits,
+ testqr_width,
+ (testqr_width + CHAR_BIT - 1) / CHAR_BIT,
+ testqr_height,
+ &data);
+
+ fprintf(stderr, "qr_code_parse returned %d\n", ret);
+
+ if (ret == 0) {
+ const char * ec_str, * type_str;
+ char * data_str;
+ size_t data_len;
+ enum qr_data_type data_type;
+
+ fprintf(stderr, "version = %d\n", data->version);
+ switch (data->ec) {
+ case QR_EC_LEVEL_L: ec_str = "L"; break;
+ case QR_EC_LEVEL_M: ec_str = "M"; break;
+ case QR_EC_LEVEL_Q: ec_str = "Q"; break;
+ case QR_EC_LEVEL_H: ec_str = "H"; break;
+ default: ec_str = "(unknown)"; break;
+ }
+ fprintf(stderr, "EC level %s\n", ec_str);
+
+ data_type = qr_parse_data(data, &data_str, &data_len);
+ switch (data_type) {
+ case QR_DATA_INVALID: type_str = "(invalid)"; break;
+ case QR_DATA_ECI: type_str = "ECI"; break;
+ case QR_DATA_NUMERIC: type_str = "numeric"; break;
+ case QR_DATA_ALPHA: type_str = "alpha"; break;
+ case QR_DATA_8BIT: type_str = "8-bit"; break;
+ case QR_DATA_KANJI: type_str = "kanji"; break;
+ case QR_DATA_MIXED: type_str = "mixed"; break;
+ case QR_DATA_FNC1: type_str = "FNC1"; break;
+ default: type_str = "(unknown)"; break;
+ }
+ fprintf(stderr, "Data type: %s; %lu bytes\nContent: %s\n", type_str, (unsigned long) data_len, data_str);
+ free(data_str);
+ qr_data_destroy(data);
+ }
+
+ return 0;
+}
+