From 682c2c553b7083645dd5147cdf3ff8650f08a0fd Mon Sep 17 00:00:00 2001 From: Leo Howell Date: Sat, 14 Nov 2009 18:13:58 +0900 Subject: Store ec level in qr_data struct --- lpg/libqr/code-create.c | 7 +++---- lpg/libqr/data-common.h | 1 + lpg/libqr/data-create.c | 3 ++- lpg/libqr/qr/code.h | 10 +--------- lpg/libqr/qr/data.h | 8 ++++++++ lpg/libqr/qrgen.c | 4 ++-- 6 files changed, 17 insertions(+), 16 deletions(-) (limited to 'lpg') 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 #include @@ -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 #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"); -- cgit v1.2.3-70-g09d2