aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr
diff options
context:
space:
mode:
authorLeo Howell <leo@lwh.jp>2009-11-14 18:13:58 +0900
committerLeo Howell <leo@lwh.jp>2009-11-14 18:21:20 +0900
commit682c2c553b7083645dd5147cdf3ff8650f08a0fd (patch)
treeb162857e26663af24e0c51ce9228f0dff132367a /lpg/libqr
parent7ccc90b391c269ce3453275ff8725849ea52ccbe (diff)
downloadpdf-simple-sign-682c2c553b7083645dd5147cdf3ff8650f08a0fd.tar.gz
pdf-simple-sign-682c2c553b7083645dd5147cdf3ff8650f08a0fd.tar.xz
pdf-simple-sign-682c2c553b7083645dd5147cdf3ff8650f08a0fd.zip
Store ec level in qr_data struct
Diffstat (limited to 'lpg/libqr')
-rw-r--r--lpg/libqr/code-create.c7
-rw-r--r--lpg/libqr/data-common.h1
-rw-r--r--lpg/libqr/data-create.c3
-rw-r--r--lpg/libqr/qr/code.h10
-rw-r--r--lpg/libqr/qr/data.h8
-rw-r--r--lpg/libqr/qrgen.c4
6 files changed, 17 insertions, 16 deletions
diff --git a/lpg/libqr/code-create.c b/lpg/libqr/code-create.c
index 1a38967..f8ef7b9 100644
--- a/lpg/libqr/code-create.c
+++ b/lpg/libqr/code-create.c
@@ -274,8 +274,7 @@ fail:
goto exit;
}
-struct qr_code * qr_code_create(enum qr_ec_level ec,
- const struct qr_data * data)
+struct qr_code * qr_code_create(const struct qr_data * data)
{
struct qr_code * code;
struct qr_bitstream * bits = 0;
@@ -294,7 +293,7 @@ struct qr_code * qr_code_create(enum qr_ec_level ec,
if (!code->modules)
goto fail;
- bits = make_data(data->version, ec, data->bits);
+ bits = make_data(data->version, data->ec, data->bits);
if (!bits)
goto fail;
@@ -313,7 +312,7 @@ struct qr_code * qr_code_create(enum qr_ec_level ec,
if (mask < 0)
goto fail;
- if (draw_functional(code, ec, mask) != 0)
+ if (draw_functional(code, data->ec, mask) != 0)
goto fail;
exit:
diff --git a/lpg/libqr/data-common.h b/lpg/libqr/data-common.h
index bc2b381..420b3b2 100644
--- a/lpg/libqr/data-common.h
+++ b/lpg/libqr/data-common.h
@@ -7,6 +7,7 @@
struct qr_data {
int version; /* 1 ~ 40 */
+ enum qr_ec_level ec;
struct qr_bitstream * bits;
size_t offset;
};
diff --git a/lpg/libqr/data-create.c b/lpg/libqr/data-create.c
index 2c2737f..27c6d4b 100644
--- a/lpg/libqr/data-create.c
+++ b/lpg/libqr/data-create.c
@@ -3,7 +3,6 @@
*/
/** XXX: check that the data will fit! **/
-/** NOTE: should store ec type in qr_data **/
#include <ctype.h>
#include <stdlib.h>
@@ -174,6 +173,7 @@ static struct qr_data * encode_kanji(struct qr_data * data,
}
struct qr_data * qr_create_data(int version,
+ enum qr_ec_level ec,
enum qr_data_type type,
const char * input,
size_t length)
@@ -188,6 +188,7 @@ struct qr_data * qr_create_data(int version,
return 0;
data->version = version;
+ data->ec = ec;
data->bits = qr_bitstream_create();
data->offset = 0;
diff --git a/lpg/libqr/qr/code.h b/lpg/libqr/qr/code.h
index dba0040..3c14c1f 100644
--- a/lpg/libqr/qr/code.h
+++ b/lpg/libqr/qr/code.h
@@ -4,15 +4,7 @@
#include <stddef.h>
#include "types.h"
-enum qr_ec_level {
- QR_EC_LEVEL_L = 0x1,
- QR_EC_LEVEL_M = 0x0,
- QR_EC_LEVEL_Q = 0x3,
- QR_EC_LEVEL_H = 0x2
-};
-
-struct qr_code * qr_code_create(enum qr_ec_level ec,
- const struct qr_data * data);
+struct qr_code * qr_code_create(const struct qr_data * data);
void qr_code_destroy(struct qr_code *);
diff --git a/lpg/libqr/qr/data.h b/lpg/libqr/qr/data.h
index 5fbdded..39494f4 100644
--- a/lpg/libqr/qr/data.h
+++ b/lpg/libqr/qr/data.h
@@ -15,7 +15,15 @@ enum qr_data_type {
QR_DATA_FNC1 = 9
};
+enum qr_ec_level {
+ QR_EC_LEVEL_L = 0x1,
+ QR_EC_LEVEL_M = 0x0,
+ QR_EC_LEVEL_Q = 0x3,
+ QR_EC_LEVEL_H = 0x2
+};
+
struct qr_data * qr_create_data(int format, /* 1 ~ 40 */
+ enum qr_ec_level ec,
enum qr_data_type type,
const char * input,
size_t length);
diff --git a/lpg/libqr/qrgen.c b/lpg/libqr/qrgen.c
index aee6166..d1aae68 100644
--- a/lpg/libqr/qrgen.c
+++ b/lpg/libqr/qrgen.c
@@ -31,7 +31,7 @@ struct qr_code * create(int version,
len = strlen(input);
- data = qr_create_data(version, dtype, input, len);
+ data = qr_create_data(version, ec, dtype, input, len);
if (!data) {
/* BUG: this could also indicate OOM or
@@ -41,7 +41,7 @@ struct qr_code * create(int version,
exit(1);
}
- code = qr_code_create(ec, data);
+ code = qr_code_create(data);
if (!code) {
perror("Failed to create code");