From 1599a28d078f5a2b49ad1307a8db70916bec77bd Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 2 Nov 2006 03:58:38 +0000 Subject: --- Makefile.am | 7 ++++ configure.ac | 58 +++++++++++++++++++++++++++ qrencode.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ qrencode.h | 80 +++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 4 ++ tests/common.h | 44 ++++++++++++++++++++ tests/test_datastream.c | 26 ++++++++++++ 7 files changed, 323 insertions(+) create mode 100644 Makefile.am create mode 100644 configure.ac create mode 100644 qrencode.c create mode 100644 qrencode.h create mode 100644 tests/Makefile.am create mode 100644 tests/common.h create mode 100644 tests/test_datastream.c diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000000..1967fb326d --- /dev/null +++ b/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = . tests + +lib_LTLIBRARIES = libqrencode.la + +libqrencode_la_SOURCES = qrencode.c +libqrencode_la_headers = qrencode.h +libqrencode_la_LDFLAGS = -version-info $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000000..e9aa64da1c --- /dev/null +++ b/configure.ac @@ -0,0 +1,58 @@ +AC_INIT(QRencode, 0.1.0, fukuchi@megaui.net) + +dnl information on the package + +PACKAGE=QRencode +MAJOR_VERSION=0 +MINOR_VERSION=1 +MICRO_VERSION=0 +VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION + +AC_SUBST(PACKAGE) +AC_SUBST(MAJOR_VERSION) +AC_SUBST(MINOR_VERSION) +AC_SUBST(MICRO_VERSION) +AC_SUBST(VERSION) + +AC_CONFIG_SRCDIR([qrencode.c]) + +AC_CONFIG_AUX_DIR(use) + +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AM_INIT_AUTOMAKE(QRencode, VERSION) + +AC_PROG_MAKE_SET +AC_PROG_CC +AC_PROG_INSTALL +AC_DISABLE_STATIC +AC_PROG_LIBTOOL + +CFLAGS="-Wall $CFLAGS $GLIB_CFLAGS $SDL_CFLAGS" +LDFLAGS="$LIBS $GLIB_LIBS $SDL_LIBS" + +AC_HEADER_STDC + +AC_C_CONST +AC_C_INLINE + +AC_PROG_GCC_TRADITIONAL +AC_FUNC_MALLOC +AC_FUNC_STAT +AC_CHECK_FUNCS([atexit memset strdup]) + +AC_CONFIG_FILES([Makefile + tests/Makefile]) + +AC_OUTPUT + +echo "" +echo "Options used to compile and link:" +echo " CC = $CC" +echo " CFLAGS = $CFLAGS" +echo " CPPFLAGS = $CPPFLAGS" +echo " CXX = $CXX" +echo " CXXFLAGS = $CXXFLAGS" +echo " LDFLAGS = $LDFLAGS" +echo "" diff --git a/qrencode.c b/qrencode.c new file mode 100644 index 0000000000..25ca0e2231 --- /dev/null +++ b/qrencode.c @@ -0,0 +1,104 @@ +/* + * qrencode - QR-code encoder + * + * Originally written by Y.Swetake + * Copyright (c)2003-2005 Y.Swetake + * + * Ported to C and modified by Kentaro Fukuchi + * Copyright (c) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include + +#include "qrencode.h" + +typedef struct _QRenc_List QRenc_List; +struct _QRenc_List { + QRenc_EncodeMode mode; + int size; + unsigned char *data; + QRenc_List *next; +}; + +struct _QRenc_DataStream { + QRenc_List *head; + QRenc_List *tail; +}; + +static QRenc_ErrorCorrectionLevel errorCorrectionLevel = QR_EC_LEVEL_L; +static int version = 0; + + +void QRenc_setErrorCorrectionLevel(QRenc_ErrorCorrectionLevel level) +{ + errorCorrectionLevel = level; +} + +QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(void) +{ + return errorCorrectionLevel; +} + +QRenc_DataStream *QRenc_initData(void) +{ + QRenc_DataStream *stream; + + stream = (QRenc_DataStream *)malloc(sizeof(QRenc_DataStream)); + stream->head = NULL; + stream->tail = NULL; + + return stream; +} + +int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, unsigned char *data) +{ + QRenc_List *entry; + + entry = (QRenc_List *)malloc(sizeof(QRenc_List)); + entry->mode = mode; + entry->size = size; + entry->data = (unsigned char *)malloc(size); + memcpy(entry->data, data, size); + entry->next = NULL; + + if(stream->tail == NULL) { + stream->head = entry; + stream->tail = entry; + } else { + stream->tail->next = entry; + stream->tail = entry; + } + + return 0; +} + +void QRenc_freeData(QRenc_DataStream *stream) +{ + QRenc_List *list, *next; + + list = stream->head; + while(list != NULL) { + free(list->data); + next = list->next; + free(list); + list = next; + } + + free(stream); +} diff --git a/qrencode.h b/qrencode.h new file mode 100644 index 0000000000..0d1aeefc11 --- /dev/null +++ b/qrencode.h @@ -0,0 +1,80 @@ +/* + * qrencode - QR-code encoder + * + * Originally written by Y.Swetake + * Copyright (C)2003-2005 Y.Swetake + * + * Ported to C and modified by Kentaro Fukuchi + * Copyright (C) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __QRENCODE_H__ +#define __QRENCODE_H__ + +/* + * Error Correction Level + */ +/** + * Level of error correction. + */ +typedef enum { + QR_EC_LEVEL_L, + QR_EC_LEVEL_M, + QR_EC_LEVEL_Q, + QR_EC_LEVEL_H +} QRenc_ErrorCorrectionLevel; + +/** + * set error correction level. + */ +extern void QRenc_setErrorCorrectionLevel(QRenc_ErrorCorrectionLevel level); +extern QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(void); + +/** + * Version + */ +extern int QRenc_getVersion(void); +extern void QRenc_setVersion(int); + +/** + * Encoding mode + */ +typedef enum { + QR_MODE_NUM, + QR_MODE_AN, + QR_MODE_8, + QR_MODE_KANJI +} QRenc_EncodeMode; + +/* + * Input data stream + */ +/** + * List structure to store input data stream. + */ +typedef struct _QRenc_DataStream QRenc_DataStream; + +extern QRenc_DataStream *QRenc_initData(void); +extern int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, unsigned char *data); +extern void QRenc_freeData(QRenc_DataStream *stream); + +/* + * QRcode output + */ +extern unsigned char *QRenc_encode(QRenc_DataStream *stream); + +#endif /* __QRENCODE_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000000..29aa31b4fe --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,4 @@ +noinst_PROGRAMS = test_datastream + +test_datastream_SOURCES = test_datastream.c +test_datastream_LDADD = ../libqrencode.la diff --git a/tests/common.h b/tests/common.h new file mode 100644 index 0000000000..291e3a8fd6 --- /dev/null +++ b/tests/common.h @@ -0,0 +1,44 @@ +/* + * common part of test units. + */ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include "../qrencode.h" + +#define CHECK(_str_) (printf("_____%s\n",_str_)) +#define RESULT(_args_...) (printf(".....") + printf(_args_)) + +#define testStart(__arg__) (testStartReal(__FUNCTION__, __arg__)) + +static int tests = 0; +static int failed = 0; +static const char *testName = NULL; +static const char *testFunc = NULL; + +void testStartReal(const char *func, const char *name) +{ + tests++; + testName = name; + testFunc = func; + printf("_____%d: %s: %s...\n", tests, func, name); +} + +void testEnd(int result) +{ + printf(".....%d: %s: %s, ", tests, testFunc, testName); + if(result) { + puts("FAILED."); + failed++; + } else { + puts("PASSED."); + } +} + +void report() +{ + printf("Total %d tests, %d fails.\n", tests, failed); +} + +#endif /* __COMMON_H__ */ diff --git a/tests/test_datastream.c b/tests/test_datastream.c new file mode 100644 index 0000000000..332d6068ce --- /dev/null +++ b/tests/test_datastream.c @@ -0,0 +1,26 @@ +#include +#include "common.h" + +void test_freeDataStream(void) +{ + QRenc_DataStream *stream; + unsigned char dummy[8]; + + testStart("Fee DataStream(always passed, but check valgrind."); + stream = QRenc_initData(); + QRenc_appendData(stream, QR_MODE_8, 8, dummy); + QRenc_appendData(stream, QR_MODE_8, 8, dummy); + QRenc_appendData(stream, QR_MODE_8, 8, dummy); + QRenc_freeData(stream); + testEnd(0); +} + +int main(int argc, char **argv) +{ + + test_freeDataStream(); + + report(); + + return 0; +} -- cgit 0.0.5-2-1-g0f52 From 544df61416574d8186e776d3e84442527ee240d1 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 2 Nov 2006 06:12:52 +0000 Subject: --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index 1967fb326d..6e4f8941cc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ +AUTOMAKE_OPTIONS = foreign + SUBDIRS = . tests lib_LTLIBRARIES = libqrencode.la -- cgit 0.0.5-2-1-g0f52 From 10ef4b391c978c79310ef29b4d2a363af2fe14e9 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 2 Nov 2006 11:29:05 +0000 Subject: --- Doxyfile | 1252 +++++++++++++++++++++++++++++++++++++++++++++++ autogen.sh | 17 + qrencode.c | 162 +++++- qrencode.h | 75 ++- tests/Makefile.am | 5 +- tests/test_bitstream.c | 123 +++++ tests/test_datastream.c | 1 - 7 files changed, 1603 insertions(+), 32 deletions(-) create mode 100644 Doxyfile create mode 100755 autogen.sh create mode 100644 tests/test_bitstream.c diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000000..ba77f76f0d --- /dev/null +++ b/Doxyfile @@ -0,0 +1,1252 @@ +# Doxyfile 1.4.7 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = QRencode + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, +# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, +# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, +# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, +# Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# This tag can be used to specify the encoding used in the generated output. +# The encoding is not always determined by the language that is chosen, +# but also whether or not the output is meant for Windows or non-Windows users. +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES +# forces the Windows encoding (this is the default for the Windows binary), +# whereas setting the tag to NO uses a Unix-style encoding (the default for +# all platforms other than Windows). + +USE_WINDOWS_ENCODING = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = NO + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that a graph may be further truncated if the graph's +# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH +# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), +# the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000000..2956c78e2f --- /dev/null +++ b/autogen.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +if [ -d /usr/local/share/aclocal ]; then + ACLOCAL_DIR=/usr/local/share/aclocal +else if [ -d /usr/share/aclocal ]; then + ACLOCAL_DIR=/usr/share/aclocal + fi +fi + +aclocal -I $ACLOCAL_DIR + +libtoolize --automake #--copy +automake --add-missing #--copy + +autoconf diff --git a/qrencode.c b/qrencode.c index 25ca0e2231..14995c0211 100644 --- a/qrencode.c +++ b/qrencode.c @@ -25,25 +25,15 @@ #include #include #include +#include #include "qrencode.h" -typedef struct _QRenc_List QRenc_List; -struct _QRenc_List { - QRenc_EncodeMode mode; - int size; - unsigned char *data; - QRenc_List *next; -}; - -struct _QRenc_DataStream { - QRenc_List *head; - QRenc_List *tail; -}; +/****************************************************************************** + * Error Correction Level + *****************************************************************************/ static QRenc_ErrorCorrectionLevel errorCorrectionLevel = QR_EC_LEVEL_L; -static int version = 0; - void QRenc_setErrorCorrectionLevel(QRenc_ErrorCorrectionLevel level) { @@ -55,6 +45,42 @@ QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(void) return errorCorrectionLevel; } +/****************************************************************************** + * Version (size of the QR-code) + *****************************************************************************/ + +static int version = 0; + +extern int QRenc_getVersion(void) +{ + return version; +} + +extern void QRenc_setVersion(int v) +{ + version = v; +} + +/****************************************************************************** + * Input data stream + *****************************************************************************/ + +typedef struct _QRenc_List QRenc_List; +struct _QRenc_List { + QRenc_EncodeMode mode; + int size; ///< Size of data chunk. + unsigned char *data; ///< Data chunk. + int bits; ///< Number of bits of encoded bit stream. + unsigned char *bdata; ///< Encoded bit stream. + QRenc_List *next; +}; + +struct _QRenc_DataStream { + QRenc_List *head; + QRenc_List *tail; +}; + + QRenc_DataStream *QRenc_initData(void) { QRenc_DataStream *stream; @@ -74,6 +100,9 @@ int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, entry->mode = mode; entry->size = size; entry->data = (unsigned char *)malloc(size); + entry->bits = 0; + entry->bdata = NULL; + memcpy(entry->data, data, size); entry->next = NULL; @@ -96,9 +125,114 @@ void QRenc_freeData(QRenc_DataStream *stream) while(list != NULL) { free(list->data); next = list->next; + if(list->bdata != NULL) { + free(list->bdata); + } free(list); list = next; } free(stream); } + +/****************************************************************************** + * Data conversion + *****************************************************************************/ + +typedef struct { + int size; + unsigned char *data; + + int remain; + unsigned char *head; +} BitStream; + +BitStream *BitStream_new(int size) +{ + BitStream *bstream; + div_t d; + int byte; + + d = div(size, 8); + byte = d.quot + d.rem?1:0; + + bstream = (BitStream *)malloc(sizeof(BitStream)); + bstream->size = size; + bstream->data = (unsigned char *)malloc(byte); + bstream->head = bstream->data; + bstream->remain = 0; + + return bstream; +} + +void BitStream_append(BitStream *bstream, int size, unsigned char *data) +{ + int sb; + int shift; + + sb = size / 8; + + if(bstream->remain == 0) { + memcpy(bstream->head, data, sb); + bstream->head += sb; + if(size & 7) { + *bstream->head = data[sb]; + bstream->remain = 8 - (size - sb * 8); + } + } else { + shift = 8 - bstream->remain; + while(size > 7) { + *bstream->head++ |= *data << shift; + *bstream->head = *data++ >> bstream->remain; + size -= 8; + } + if(size > 0) { + *bstream->head |= *data << shift; + if(size > bstream->remain) { + bstream->head++; + *bstream->head = *data >> bstream->remain; + bstream->remain += 8 - size; + } else { + bstream->remain -= size; + if(bstream->remain == 0) { + bstream->head++; + bstream->remain = 8; + } + } + } + } +} + +void BitStream_free(BitStream *bstream) +{ + free(bstream->data); + free(bstream); +} + +/** + * Convert the input data stream to a bit stream. + * @param stream input data stream. + * @return bit stream. + */ +static BitStream *QRenc_createBitStream(QRenc_DataStream *stream) +{ + QRenc_List *list; + int bits = 0; + BitStream *bstream; + + assert(stream != NULL); + + list = stream->head; + while(list != NULL) { + bits += QRenc_encodeBitStream(list); + list = list->next; + } + + bstream = BitStream_new(bits); + list = stream->head; + while(list != NULL) { + BitStream_append(bstream, list->bits, list->bdata); + } + + return bstream; +} diff --git a/qrencode.h b/qrencode.h index 0d1aeefc11..0e90742b26 100644 --- a/qrencode.h +++ b/qrencode.h @@ -1,4 +1,4 @@ -/* +/** * qrencode - QR-code encoder * * Originally written by Y.Swetake @@ -20,14 +20,16 @@ * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * */ #ifndef __QRENCODE_H__ #define __QRENCODE_H__ -/* +/****************************************************************************** * Error Correction Level - */ + *****************************************************************************/ + /** * Level of error correction. */ @@ -39,42 +41,83 @@ typedef enum { } QRenc_ErrorCorrectionLevel; /** - * set error correction level. + * Get current error correction level. + * @return Current error correcntion level. */ -extern void QRenc_setErrorCorrectionLevel(QRenc_ErrorCorrectionLevel level); extern QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(void); /** - * Version + * Set error correction level of the QR-code that is to be encoded. + * @param level Error correction level. + */ +extern void QRenc_setErrorCorrectionLevel(QRenc_ErrorCorrectionLevel level); + +/****************************************************************************** + * Version (size of the QR-code) + *****************************************************************************/ + +/** + * Get current version. + * @return Current version. */ extern int QRenc_getVersion(void); -extern void QRenc_setVersion(int); /** + * Set version of the QR-code that is to be encoded. + * @param version Version. (0 = auto) + */ +extern void QRenc_setVersion(int version); + +/****************************************************************************** * Encoding mode + *****************************************************************************/ + +/** + * Encoding mode. */ typedef enum { - QR_MODE_NUM, - QR_MODE_AN, - QR_MODE_8, - QR_MODE_KANJI + QR_MODE_NUM, ///< Numeric mode + QR_MODE_AN, ///< Alphabet-numeric mode + QR_MODE_8, ///< 8-bit data mode + QR_MODE_KANJI ///< Kanji (shift-jis) mode } QRenc_EncodeMode; -/* +/****************************************************************************** * Input data stream - */ + *****************************************************************************/ + /** - * List structure to store input data stream. + * Data structure to store input data stream. */ typedef struct _QRenc_DataStream QRenc_DataStream; +/** + * Instantiate a data stream object. + * @return Stream object (initialized). + */ extern QRenc_DataStream *QRenc_initData(void); + +/** + * Append data to the stream object. + * The data is copied and appended to the stream object. + * @param stream Stream object. + * @param mode Encoding mode. + * @param size Size of data (byte). + * @param data A pointer to the memory area of the input data. + * @return Always 0. + */ extern int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, unsigned char *data); + +/** + * Free the stream object. + * All of data chunks in the stream object are freed too. + * @param stream Stream object. + */ extern void QRenc_freeData(QRenc_DataStream *stream); -/* +/****************************************************************************** * QRcode output - */ + *****************************************************************************/ extern unsigned char *QRenc_encode(QRenc_DataStream *stream); #endif /* __QRENCODE_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 29aa31b4fe..3081cf353e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,7 @@ -noinst_PROGRAMS = test_datastream +noinst_PROGRAMS = test_datastream test_bitstream test_datastream_SOURCES = test_datastream.c test_datastream_LDADD = ../libqrencode.la + +test_bitstream_SOURCES = test_bitstream.c +test_bitstream_LDADD = ../libqrencode.la diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c new file mode 100644 index 0000000000..85ef8b3172 --- /dev/null +++ b/tests/test_bitstream.c @@ -0,0 +1,123 @@ +#include +#include +#include "common.h" + +typedef struct { + int size; + unsigned char *data; + + int remain; + unsigned char *head; +} BitStream; + +extern BitStream *BitStream_new(int size); +extern void BitStream_append(BitStream *bstream, int size, unsigned char *data); +extern void BitStream_free(BitStream *bstream); + +void test_1bitStream(void) +{ + unsigned int data; + BitStream *bstream; + int i, flag; + + testStart("1 bit stream"); + bstream = BitStream_new(128); + data = 1; + for(i=0; i<128; i++) { + BitStream_append(bstream, 1, (unsigned char *)&data); + } + + flag = 0; + for(i=0; i<16; i++) { + printf("%02x", bstream->data[i]); + if(bstream->data[i] != 0xff) + flag++; + } + printf("\n"); + + testEnd(flag); +} + +void test_8nbitsStream(void) +{ + unsigned int data; + BitStream *bstream; + unsigned char correct[7]; + + testStart("8n bit stream"); + bstream = BitStream_new(56); + data = 0x8a; + correct[0] = 0x8a; + BitStream_append(bstream, 8, (unsigned char *)&data); + + data = 0xffff; + correct[1] = 0xff; + correct[2] = 0xff; + BitStream_append(bstream, 16, (unsigned char *)&data); + + data = 0x12345678; + correct[3] = 0x78; + correct[4] = 0x56; + correct[5] = 0x34; + correct[6] = 0x12; + BitStream_append(bstream, 32, (unsigned char *)&data); + + testEnd(memcmp(correct, bstream->data, 7)); +} + +void test_varStream(void) +{ + unsigned int data; + BitStream *bstream; + int flag; + unsigned char correct[7]; + int i; + + testStart("Various bit stream"); + bstream = BitStream_new(54); + data = 0x7f; + correct[0] = 0x7f; + BitStream_append(bstream, 7, (unsigned char *)&data); + + data = 0x0555; + correct[0] |= 0x80; + correct[1] = (0x55>>1) | (0x55<<7); + correct[2] = 0x05>>1; + BitStream_append(bstream, 14, (unsigned char *)&data); + + data = 0x12345678; + correct[2] |= 0x78 << 5; + correct[3] = (0x78 >> 3) | (0x56 << 5); + correct[4] = (0x56 >> 3) | (0x34 << 5); + correct[5] = (0x34 >> 3) | (0x12 << 5); + correct[6] = 0x12 >> 3; + BitStream_append(bstream, 29, (unsigned char *)&data); + + data = 0xff; + correct[6] |= (0xff & 0x0f) << 2; + BitStream_append(bstream, 4, (unsigned char *)&data); + + for(i=0; i<7; i++) { + printf("%02x", correct[i]); + } + printf("\n"); + for(i=0; i<7; i++) { + printf("%02x", bstream->data[i]); + } + printf("\n"); + + flag = memcmp(correct, bstream->data, 6); + flag |= (bstream->data[6] & 0x3f) != (correct[6] & 0x3f); + testEnd(flag); +} + +int main(int argc, char **argv) +{ + test_8nbitsStream(); + test_varStream(); + test_1bitStream(); + + report(); + + return 0; +} diff --git a/tests/test_datastream.c b/tests/test_datastream.c index 332d6068ce..a8c4755204 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -17,7 +17,6 @@ void test_freeDataStream(void) int main(int argc, char **argv) { - test_freeDataStream(); report(); -- cgit 0.0.5-2-1-g0f52 From 09af85d698747b98b0f544d7b062ddb62b067373 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 2 Nov 2006 12:12:15 +0000 Subject: --- Makefile.am | 6 ++-- bitstream.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++ bitstream.h | 40 +++++++++++++++++++++ configure.ac | 2 +- qrencode.c | 98 ++++++++++++++------------------------------------ tests/test_bitstream.c | 13 +------ 6 files changed, 164 insertions(+), 87 deletions(-) create mode 100644 bitstream.c create mode 100644 bitstream.h diff --git a/Makefile.am b/Makefile.am index 6e4f8941cc..251dfc368b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,8 @@ SUBDIRS = . tests lib_LTLIBRARIES = libqrencode.la -libqrencode_la_SOURCES = qrencode.c -libqrencode_la_headers = qrencode.h +libqrencode_la_SOURCES = qrencode.c bitstream.c +libqrencode_la_headers = qrencode.h bitstream.h libqrencode_la_LDFLAGS = -version-info $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) + +pkginclude_HEADERS = qrencode.h diff --git a/bitstream.c b/bitstream.c new file mode 100644 index 0000000000..0562378521 --- /dev/null +++ b/bitstream.c @@ -0,0 +1,92 @@ +/* + * qrencode - QR-code encoder + * + * Originally written by Y.Swetake + * Copyright (c)2003-2005 Y.Swetake + * + * Ported to C and modified by Kentaro Fukuchi + * Copyright (c) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include + +#include "bitstream.h" + +BitStream *BitStream_new(int size) +{ + BitStream *bstream; + div_t d; + int byte; + + d = div(size, 8); + byte = d.quot + d.rem?1:0; + + bstream = (BitStream *)malloc(sizeof(BitStream)); + bstream->size = size; + bstream->data = (unsigned char *)malloc(byte); + bstream->head = bstream->data; + bstream->remain = 0; + + return bstream; +} + +void BitStream_append(BitStream *bstream, int size, unsigned char *data) +{ + int sb; + int shift; + + sb = size / 8; + + if(bstream->remain == 0) { + memcpy(bstream->head, data, sb); + bstream->head += sb; + if(size & 7) { + *bstream->head = data[sb]; + bstream->remain = 8 - (size - sb * 8); + } + } else { + shift = 8 - bstream->remain; + while(size > 7) { + *bstream->head++ |= *data << shift; + *bstream->head = *data++ >> bstream->remain; + size -= 8; + } + if(size > 0) { + *bstream->head |= *data << shift; + if(size > bstream->remain) { + bstream->head++; + *bstream->head = *data >> bstream->remain; + bstream->remain += 8 - size; + } else { + bstream->remain -= size; + if(bstream->remain == 0) { + bstream->head++; + bstream->remain = 8; + } + } + } + } +} + +void BitStream_free(BitStream *bstream) +{ + free(bstream->data); + free(bstream); +} diff --git a/bitstream.h b/bitstream.h new file mode 100644 index 0000000000..1caa793058 --- /dev/null +++ b/bitstream.h @@ -0,0 +1,40 @@ +/* + * qrencode - QR-code encoder + * + * Originally written by Y.Swetake + * Copyright (c)2003-2005 Y.Swetake + * + * Ported to C and modified by Kentaro Fukuchi + * Copyright (c) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __BITSTREAM_H__ +#define __BITSTREAM_H__ + +typedef struct { + int size; + unsigned char *data; + + int remain; + unsigned char *head; +} BitStream; + +extern BitStream *BitStream_new(int size); +void BitStream_append(BitStream *bstream, int size, unsigned char *data); +void BitStream_free(BitStream *bstream); + +#endif /* __BITSTREAM_H__ */ diff --git a/configure.ac b/configure.ac index e9aa64da1c..5519702244 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_INIT(QRencode, 0.1.0, fukuchi@megaui.net) dnl information on the package -PACKAGE=QRencode +PACKAGE=qrencode MAJOR_VERSION=0 MINOR_VERSION=1 MICRO_VERSION=0 diff --git a/qrencode.c b/qrencode.c index 14995c0211..0ef806f58c 100644 --- a/qrencode.c +++ b/qrencode.c @@ -28,6 +28,7 @@ #include #include "qrencode.h" +#include "bitstream.h" /****************************************************************************** * Error Correction Level @@ -70,8 +71,7 @@ struct _QRenc_List { QRenc_EncodeMode mode; int size; ///< Size of data chunk. unsigned char *data; ///< Data chunk. - int bits; ///< Number of bits of encoded bit stream. - unsigned char *bdata; ///< Encoded bit stream. + BitStream *bstream; QRenc_List *next; }; @@ -100,8 +100,7 @@ int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, entry->mode = mode; entry->size = size; entry->data = (unsigned char *)malloc(size); - entry->bits = 0; - entry->bdata = NULL; + entry->bstream = NULL; memcpy(entry->data, data, size); entry->next = NULL; @@ -125,8 +124,8 @@ void QRenc_freeData(QRenc_DataStream *stream) while(list != NULL) { free(list->data); next = list->next; - if(list->bdata != NULL) { - free(list->bdata); + if(list->bstream != NULL) { + BitStream_free(list->bstream); } free(list); list = next; @@ -139,76 +138,31 @@ void QRenc_freeData(QRenc_DataStream *stream) * Data conversion *****************************************************************************/ -typedef struct { - int size; - unsigned char *data; - - int remain; - unsigned char *head; -} BitStream; - -BitStream *BitStream_new(int size) -{ - BitStream *bstream; - div_t d; - int byte; - - d = div(size, 8); - byte = d.quot + d.rem?1:0; - bstream = (BitStream *)malloc(sizeof(BitStream)); - bstream->size = size; - bstream->data = (unsigned char *)malloc(byte); - bstream->head = bstream->data; - bstream->remain = 0; - - return bstream; -} - -void BitStream_append(BitStream *bstream, int size, unsigned char *data) +/** + * Convert the data stream in the data chunk to a bit stream. + * @param list + * @return number of bits + */ +static int QRenc_encodeBitStream(QRenc_List *list) { - int sb; - int shift; - - sb = size / 8; - - if(bstream->remain == 0) { - memcpy(bstream->head, data, sb); - bstream->head += sb; - if(size & 7) { - *bstream->head = data[sb]; - bstream->remain = 8 - (size - sb * 8); - } - } else { - shift = 8 - bstream->remain; - while(size > 7) { - *bstream->head++ |= *data << shift; - *bstream->head = *data++ >> bstream->remain; - size -= 8; - } - if(size > 0) { - *bstream->head |= *data << shift; - if(size > bstream->remain) { - bstream->head++; - *bstream->head = *data >> bstream->remain; - bstream->remain += 8 - size; - } else { - bstream->remain -= size; - if(bstream->remain == 0) { - bstream->head++; - bstream->remain = 8; - } - } - } + assert(list != NULL); + switch(list->mode) { + case QR_MODE_NUM: +// return QRenc_encodeModeNum(list); + break; + case QR_MODE_AN: +// return QRenc_encodeModeAn(list); + break; + case QR_MODE_8: +// return QRenc_encodeMode8(list); + break; + case QR_MODE_KANJI: +// return QRenc_encodeModeKanji(list); + break; } } -void BitStream_free(BitStream *bstream) -{ - free(bstream->data); - free(bstream); -} - /** * Convert the input data stream to a bit stream. * @param stream input data stream. @@ -231,7 +185,7 @@ static BitStream *QRenc_createBitStream(QRenc_DataStream *stream) bstream = BitStream_new(bits); list = stream->head; while(list != NULL) { - BitStream_append(bstream, list->bits, list->bdata); + BitStream_append(bstream, list->bstream->size, list->bstream->data); } return bstream; diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 85ef8b3172..e0c9fe1f3f 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -1,18 +1,7 @@ #include #include #include "common.h" - -typedef struct { - int size; - unsigned char *data; - - int remain; - unsigned char *head; -} BitStream; - -extern BitStream *BitStream_new(int size); -extern void BitStream_append(BitStream *bstream, int size, unsigned char *data); -extern void BitStream_free(BitStream *bstream); +#include "../bitstream.h" void test_1bitStream(void) { -- cgit 0.0.5-2-1-g0f52 From 3f3f4d1ef3225ad5a343b42fbc89af25ef2bc34f Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 2 Nov 2006 12:31:40 +0000 Subject: --- bitstream.c | 2 +- tests/test_bitstream.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bitstream.c b/bitstream.c index 0562378521..0a9cdf4eda 100644 --- a/bitstream.c +++ b/bitstream.c @@ -36,7 +36,7 @@ BitStream *BitStream_new(int size) int byte; d = div(size, 8); - byte = d.quot + d.rem?1:0; + byte = d.quot + (d.rem?1:0); bstream = (BitStream *)malloc(sizeof(BitStream)); bstream->size = size; diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index e0c9fe1f3f..8d005b1a0c 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -24,6 +24,8 @@ void test_1bitStream(void) } printf("\n"); + BitStream_free(bstream); + testEnd(flag); } @@ -52,6 +54,8 @@ void test_8nbitsStream(void) BitStream_append(bstream, 32, (unsigned char *)&data); testEnd(memcmp(correct, bstream->data, 7)); + + BitStream_free(bstream); } void test_varStream(void) @@ -97,6 +101,9 @@ void test_varStream(void) flag = memcmp(correct, bstream->data, 6); flag |= (bstream->data[6] & 0x3f) != (correct[6] & 0x3f); + + BitStream_free(bstream); + testEnd(flag); } -- cgit 0.0.5-2-1-g0f52 From 292c1a7644a4d5a27507c80c876c27418d1d7dde Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 6 Nov 2006 08:11:15 +0000 Subject: --- Makefile.am | 4 +- qrencode.c | 189 ++++++++++++++++++++++++++++++++++++++++++----- qrencode.h | 10 +-- qrspec.c | 132 +++++++++++++++++++++++++++++++++ qrspec.h | 66 +++++++++++++++++ qrtest.h | 4 + tests/Makefile.am | 5 +- tests/common.h | 1 + tests/test_datastream.c | 2 +- tests/test_estimatebit.c | 134 +++++++++++++++++++++++++++++++++ 10 files changed, 520 insertions(+), 27 deletions(-) create mode 100644 qrspec.c create mode 100644 qrspec.h create mode 100644 qrtest.h create mode 100644 tests/test_estimatebit.c diff --git a/Makefile.am b/Makefile.am index 251dfc368b..31c9266ee3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,8 +4,8 @@ SUBDIRS = . tests lib_LTLIBRARIES = libqrencode.la -libqrencode_la_SOURCES = qrencode.c bitstream.c -libqrencode_la_headers = qrencode.h bitstream.h +libqrencode_la_SOURCES = qrencode.c bitstream.c qrspec.c +libqrencode_la_headers = qrencode.h bitstream.h qrspec.h libqrencode_la_LDFLAGS = -version-info $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) pkginclude_HEADERS = qrencode.h diff --git a/qrencode.c b/qrencode.c index 0ef806f58c..370c2c91e5 100644 --- a/qrencode.c +++ b/qrencode.c @@ -28,6 +28,7 @@ #include #include "qrencode.h" +#include "qrspec.h" #include "bitstream.h" /****************************************************************************** @@ -69,7 +70,7 @@ extern void QRenc_setVersion(int v) typedef struct _QRenc_List QRenc_List; struct _QRenc_List { QRenc_EncodeMode mode; - int size; ///< Size of data chunk. + int size; ///< Size of data chunk (byte). unsigned char *data; ///< Data chunk. BitStream *bstream; QRenc_List *next; @@ -81,7 +82,7 @@ struct _QRenc_DataStream { }; -QRenc_DataStream *QRenc_initData(void) +QRenc_DataStream *QRenc_newData(void) { QRenc_DataStream *stream; @@ -139,36 +140,194 @@ void QRenc_freeData(QRenc_DataStream *stream) *****************************************************************************/ +/** + * Convert the number data stream to a bit stream. + * @param entry + * @return number of bits + */ +static int QRenc_encodeModeNum(QRenc_List *entry) +{ + int bits; + int words; + int i; + unsigned int val; + + words = entry->size / 3; + bits = words * 8; + switch(entry->size - words * 3) { + case 1: + bits += 4; + break; + case 2: + bits += 7; + break; + default: + break; + } + + entry->bstream = BitStream_new(bits); + + for(i=0; idata[i*3 ] - '0') * 100; + val += (entry->data[i*3+1] - '0') * 10; + val += (entry->data[i*3+2] - '0'); + } +} + /** * Convert the data stream in the data chunk to a bit stream. - * @param list + * @param entry * @return number of bits */ -static int QRenc_encodeBitStream(QRenc_List *list) +static int QRenc_encodeBitStream(QRenc_List *entry) { - assert(list != NULL); - switch(list->mode) { + assert(entry != NULL); + switch(entry->mode) { case QR_MODE_NUM: -// return QRenc_encodeModeNum(list); + return QRenc_encodeModeNum(entry); break; case QR_MODE_AN: -// return QRenc_encodeModeAn(list); +// return QRenc_encodeModeAn(entry); break; case QR_MODE_8: -// return QRenc_encodeMode8(list); +// return QRenc_encodeMode8(entry); break; case QR_MODE_KANJI: -// return QRenc_encodeModeKanji(list); +// return QRenc_encodeModeKanji(entry); break; } } +/** + * Estimates the length of the encoded bit stream of numeric data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsModeNum(QRenc_List *entry) +{ + int w; + int bits; + + w = entry->size / 3; + bits = w * 10; + switch(entry->size - w * 3) { + case 1: + bits += 4; + break; + case 2: + bits += 7; + break; + default: + break; + } + + return bits; +} + +/** + * Estimates the length of the encoded bit stream of alphabet-numeric data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsModeAn(QRenc_List *entry) +{ + int w; + int bits; + + w = entry->size / 2; + bits = w * 11; + if(entry->size & 1) { + bits += 6; + } + + return bits; +} + +/** + * Estimates the length of the encoded bit stream of 8 bit data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsMode8(QRenc_List *entry) +{ + return entry->size * 8; +} + +/** + * Estimates the length of the encoded bit stream of kanji data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsModeKanji(QRenc_List *entry) +{ + return (entry->size / 2) * 13; +} + +/** + * Estimates the length of the encoded bit stream on the current version. + * @param entry + * @param version version of the symbol + * @return number of bits + */ +static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) +{ + int bits = 0; + int l, m; + int num; + + assert(entry != NULL); + switch(entry->mode) { + case QR_MODE_NUM: + bits = QRenc_estimateBitsModeNum(entry); + break; + case QR_MODE_AN: + bits = QRenc_estimateBitsModeAn(entry); + break; + case QR_MODE_8: + bits = QRenc_estimateBitsMode8(entry); + break; + case QR_MODE_KANJI: + bits = QRenc_estimateBitsModeKanji(entry); + break; + } + + l = QRspec_lengthIndicator(entry->mode, version); + m = 1 << l; + num = (bits + m - 1) / m; + + bits += num * (4 + l); // mode indicator (4bits) + length indicator + + return bits; +} + +/** + * Estimates the length of the encoded bit stream of the data stream. + * @param stream data stream + * @param version version of the symbol + * @return number of bits + */ +int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version) +{ + QRenc_List *list; + int bits = 0; + + assert(stream != NULL); + + list = stream->head; + while(list != NULL) { + bits += QRenc_estimateBitStreamSizeOfEntry(list, version); + list = list->next; + } + + return bits; +} + /** * Convert the input data stream to a bit stream. * @param stream input data stream. * @return bit stream. */ -static BitStream *QRenc_createBitStream(QRenc_DataStream *stream) +int QRenc_createBitStream(QRenc_DataStream *stream) { QRenc_List *list; int bits = 0; @@ -182,11 +341,5 @@ static BitStream *QRenc_createBitStream(QRenc_DataStream *stream) list = list->next; } - bstream = BitStream_new(bits); - list = stream->head; - while(list != NULL) { - BitStream_append(bstream, list->bstream->size, list->bstream->data); - } - - return bstream; + return bits; } diff --git a/qrencode.h b/qrencode.h index 0e90742b26..76a7580640 100644 --- a/qrencode.h +++ b/qrencode.h @@ -76,10 +76,10 @@ extern void QRenc_setVersion(int version); * Encoding mode. */ typedef enum { - QR_MODE_NUM, ///< Numeric mode - QR_MODE_AN, ///< Alphabet-numeric mode - QR_MODE_8, ///< 8-bit data mode - QR_MODE_KANJI ///< Kanji (shift-jis) mode + QR_MODE_NUM = 0, ///< Numeric mode + QR_MODE_AN, ///< Alphabet-numeric mode + QR_MODE_8, ///< 8-bit data mode + QR_MODE_KANJI ///< Kanji (shift-jis) mode } QRenc_EncodeMode; /****************************************************************************** @@ -95,7 +95,7 @@ typedef struct _QRenc_DataStream QRenc_DataStream; * Instantiate a data stream object. * @return Stream object (initialized). */ -extern QRenc_DataStream *QRenc_initData(void); +extern QRenc_DataStream *QRenc_newData(void); /** * Append data to the stream object. diff --git a/qrspec.c b/qrspec.c new file mode 100644 index 0000000000..96fd364e8b --- /dev/null +++ b/qrspec.c @@ -0,0 +1,132 @@ +/* + * qrencode - QR-code encoder + * + * Originally written by Y.Swetake + * Copyright (c)2003-2005 Y.Swetake + * + * Ported to C and modified by Kentaro Fukuchi + * Copyright (c) 2006 Kentaro Fukuchi + * + * The following data / specifications are taken from + * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) + * or + * "Automatic identification and data capture techniques -- + * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include + +#include "qrspec.h" + +/****************************************************************************** + * Version and capacity + *****************************************************************************/ + +QRspec_Capacity qrspecCapacity[QRSPEC_VERSION_MAX + 1] = { + { 0, 0, 0, 0, 0, 0}, + { 21, 26, 7, 10, 13, 17}, // 1 + { 25, 44, 10, 16, 22, 28}, + { 29, 70, 15, 26, 36, 44}, + { 33, 100, 20, 36, 52, 64}, + { 37, 134, 26, 48, 72, 88}, // 5 + { 41, 172, 36, 64, 96, 112}, + { 45, 196, 40, 72, 108, 130}, + { 49, 242, 48, 88, 132, 156}, + { 53, 292, 60, 110, 160, 192}, + { 57, 346, 72, 130, 192, 224}, //10 + { 61, 404, 80, 150, 224, 264}, + { 65, 466, 96, 176, 260, 308}, + { 69, 532, 104, 198, 288, 352}, + { 73, 581, 120, 216, 320, 384}, + { 77, 655, 132, 240, 360, 432}, //15 + { 81, 733, 144, 280, 408, 480}, + { 85, 815, 168, 308, 448, 532}, + { 89, 901, 180, 338, 504, 588}, + { 93, 991, 196, 364, 546, 650}, + { 97, 1085, 224, 416, 600, 700}, //20 + {101, 1156, 224, 442, 644, 750}, + {105, 1258, 252, 476, 690, 816}, + {109, 1364, 280, 504, 750, 900}, + {113, 1474, 300, 560, 810, 960}, + {117, 1588, 312, 588, 870, 1050}, //25 + {121, 1706, 336, 644, 952, 1110}, + {125, 1828, 360, 700, 1020, 1200}, + {129, 1921, 390, 728, 1050, 1260}, + {133, 2051, 420, 784, 1140, 1350}, + {137, 2185, 450, 812, 1200, 1440}, //30 + {141, 2323, 480, 868, 1290, 1530}, + {145, 2465, 510, 924, 1350, 1620}, + {149, 2611, 540, 980, 1440, 1710}, + {153, 2761, 570, 1036, 1530, 1800}, + {157, 2876, 570, 1064, 1590, 1890}, //35 + {161, 3034, 600, 1120, 1680, 1980}, + {165, 3196, 630, 1204, 1770, 2100}, + {169, 3362, 660, 1260, 1860, 2220}, + {173, 3532, 720, 1316, 1950, 2310}, + {177, 3706, 750, 1372, 2040, 2430} //40 +}; + +/** + * Return a version number that satisfies the input code length. + * @param size input code length (byte) + * @return version number + */ +int QRspec_getMinVersion(int size) +{ + int i; + + for(i=1; i<= QRSPEC_VERSION_MAX; i++) { + if(qrspecCapacity[i].words >= size) return i; + } + + return -1; +} + +/****************************************************************************** + * Length indicator + *****************************************************************************/ + +static int lengthTableBits[4][3] = { + {10, 12, 14}, + { 9, 11, 13}, + { 8, 16, 16}, + { 8, 10, 12} +}; + +static int lengthTableWords[4][3] = { + {307, 1228, 4915}, + { 93, 372, 1489}, + { 32, 8192, 8192}, + { 19, 78, 315} +}; + +int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version) +{ + int l; + + if(version < 9) { + l = 0; + } else if(version < 26) { + l = 1; + } else { + l = 2; + } + + return lengthTableBits[mode][l]; +} diff --git a/qrspec.h b/qrspec.h new file mode 100644 index 0000000000..b17239f2dd --- /dev/null +++ b/qrspec.h @@ -0,0 +1,66 @@ +/* + * qrencode - QR-code encoder + * + * Originally written by Y.Swetake + * Copyright (c)2003-2005 Y.Swetake + * + * Ported to C and modified by Kentaro Fukuchi + * Copyright (c) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __QRSPEC_H__ +#define __QRSPEC_H__ + +#include "qrencode.h" + +/****************************************************************************** + * Version and capacity + *****************************************************************************/ + +#define QRSPEC_VERSION_MAX 40 + +typedef struct { + int length; //< Edge length of the symbol + int words; //< Data capacity (bytes) + int rsL; + int rsM; + int rsH; + int rsQ; +} QRspec_Capacity; + +extern QRspec_Capacity qrspecCapacity[]; + +/** + * Return a version number that satisfies the input code length. + * @param size input code length (byte) + * @return version number + */ +extern int QRspec_getMinVersion(int size); + +/****************************************************************************** + * Length indicator + *****************************************************************************/ + +/** + * Return the size of lenght indicator for mode and version. + * @param mode + * @param version + * @return the size of the appropriate length indicator (bits). + */ +extern int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version); + +#endif /* __QRSPEC_H__ */ diff --git a/qrtest.h b/qrtest.h new file mode 100644 index 0000000000..8db7c2157e --- /dev/null +++ b/qrtest.h @@ -0,0 +1,4 @@ +#include "qrencode.h" +#include "bitstream.h" + +int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); diff --git a/tests/Makefile.am b/tests/Makefile.am index 3081cf353e..383d6a926d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,10 @@ -noinst_PROGRAMS = test_datastream test_bitstream +noinst_PROGRAMS = test_datastream test_bitstream test_estimatebit test_datastream_SOURCES = test_datastream.c test_datastream_LDADD = ../libqrencode.la test_bitstream_SOURCES = test_bitstream.c test_bitstream_LDADD = ../libqrencode.la + +test_estimatebit_SOURCES = test_estimatebit.c +test_estimatebit_LDADD = ../libqrencode.la diff --git a/tests/common.h b/tests/common.h index 291e3a8fd6..5c7f8210a8 100644 --- a/tests/common.h +++ b/tests/common.h @@ -11,6 +11,7 @@ #define RESULT(_args_...) (printf(".....") + printf(_args_)) #define testStart(__arg__) (testStartReal(__FUNCTION__, __arg__)) +#define testEndExp(__arg__) (testEnd(!(__arg__))) static int tests = 0; static int failed = 0; diff --git a/tests/test_datastream.c b/tests/test_datastream.c index a8c4755204..56d92cfd2d 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -7,7 +7,7 @@ void test_freeDataStream(void) unsigned char dummy[8]; testStart("Fee DataStream(always passed, but check valgrind."); - stream = QRenc_initData(); + stream = QRenc_newData(); QRenc_appendData(stream, QR_MODE_8, 8, dummy); QRenc_appendData(stream, QR_MODE_8, 8, dummy); QRenc_appendData(stream, QR_MODE_8, 8, dummy); diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c new file mode 100644 index 0000000000..49250b0ce8 --- /dev/null +++ b/tests/test_estimatebit.c @@ -0,0 +1,134 @@ +#include +#include +#include +#include "common.h" +#include "../qrtest.h" + +QRenc_DataStream *gstream; + +void test_numbit(void) +{ + QRenc_DataStream *stream; + char num[9]="01234567"; + int bits; + + testStart("Estimation of Numeric stream (8 digits)"); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + bits = QRenc_estimateBitStreamSize(stream, 0); + testEndExp(bits == 41); + + QRenc_appendData(gstream, QR_MODE_NUM, 8, (unsigned char *)num); + QRenc_freeData(stream); +} + +void test_numbit2(void) +{ + QRenc_DataStream *stream; + char num[17]="0123456789012345"; + int bits; + + testStart("Estimation of Numeric stream (16 digits)"); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_NUM, 16, (unsigned char *)num); + bits = QRenc_estimateBitStreamSize(stream, 0); + testEndExp(bits == 68); + + QRenc_appendData(gstream, QR_MODE_NUM, 16, (unsigned char *)num); + QRenc_freeData(stream); +} + +void test_numbit3(void) +{ + QRenc_DataStream *stream; + char *num; + int bits; + + testStart("Estimation of Numeric stream (400 digits)"); + stream = QRenc_newData(); + num = (char *)malloc(401); + memset(num, '1', 400); + num[400] = '\0'; + QRenc_appendData(stream, QR_MODE_NUM, 400, (unsigned char *)num); + bits = QRenc_estimateBitStreamSize(stream, 0); + testEndExp(bits == 1362); + + QRenc_appendData(gstream, QR_MODE_NUM, 400, (unsigned char *)num); + QRenc_freeData(stream); + free(num); +} + +void test_an(void) +{ + QRenc_DataStream *stream; + char str[6]="AC-42"; + int bits; + + testStart("Estimation of Alphabet-Numeric stream (5 chars)"); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); + bits = QRenc_estimateBitStreamSize(stream, 0); + testEndExp(bits == 41); + + QRenc_appendData(gstream, QR_MODE_AN, 5, (unsigned char *)str); + QRenc_freeData(stream); +} + +void test_8(void) +{ + QRenc_DataStream *stream; + char str[9]="12345678"; + int bits; + + testStart("Estimation of 8 bit data stream (8 bytes)"); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_8, 8, (unsigned char *)str); + bits = QRenc_estimateBitStreamSize(stream, 0); + testEndExp(bits == 76); + + QRenc_appendData(gstream, QR_MODE_8, 8, (unsigned char *)str); + QRenc_freeData(stream); +} + +void test_kanji(void) +{ + QRenc_DataStream *stream; + unsigned char str[4]= {0x5f, 0x93, 0xaa, 0xe4}; + int bits; + + testStart("Estimation of Kanji stream (2 chars)"); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_KANJI, 4, (unsigned char *)str); + bits = QRenc_estimateBitStreamSize(stream, 0); + testEndExp(bits == 38); + + QRenc_appendData(gstream, QR_MODE_KANJI, 4, (unsigned char *)str); + QRenc_freeData(stream); +} + +void test_mix(void) +{ + int bits; + + testStart("Estimation of Mixed stream"); + bits = QRenc_estimateBitStreamSize(gstream, 0); + testEndExp(bits == (41 + 68 + 1362 + 41 + 76 + 38)); + QRenc_freeData(gstream); +} + +int main(int argc, char **argv) +{ + gstream = QRenc_newData(); + + test_numbit(); + test_numbit2(); + test_numbit3(); + test_an(); + test_8(); + test_kanji(); + test_mix(); + + report(); + + return 0; +} -- cgit 0.0.5-2-1-g0f52 From 5b9d4622bbf83bc129d9354c1503a41ebf26caef Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 6 Nov 2006 09:25:34 +0000 Subject: --- bitstream.h | 3 + qrencode.c | 185 +++++++++++++++++++++++++++++-------------------- qrspec.c | 15 ++++ qrspec.h | 10 ++- tests/test_bitstream.c | 64 +++++++++++++++++ 5 files changed, 200 insertions(+), 77 deletions(-) diff --git a/bitstream.h b/bitstream.h index 1caa793058..7d881f6746 100644 --- a/bitstream.h +++ b/bitstream.h @@ -37,4 +37,7 @@ extern BitStream *BitStream_new(int size); void BitStream_append(BitStream *bstream, int size, unsigned char *data); void BitStream_free(BitStream *bstream); +#define BitStream_appendBitStream(__arg1__, __arg2__) \ + BitStream_append((__arg1__), ((__arg2__)->size), ((__arg2__)->data)) + #endif /* __BITSTREAM_H__ */ diff --git a/qrencode.c b/qrencode.c index 370c2c91e5..f090fb20a7 100644 --- a/qrencode.c +++ b/qrencode.c @@ -76,6 +76,35 @@ struct _QRenc_List { QRenc_List *next; }; +static QRenc_List *QRenc_newEntry(QRenc_EncodeMode mode, int size, unsigned char *data) +{ + QRenc_List *entry; + + entry = (QRenc_List *)malloc(sizeof(QRenc_List)); + entry->mode = mode; + entry->size = size; + entry->data = (unsigned char *)malloc(size); + memcpy(entry->data, data, size); + entry->bstream = NULL; + entry->next = NULL; + + return entry; +} + +static QRenc_List *QRenc_freeEntry(QRenc_List *entry) +{ + QRenc_List *next; + + next = entry->next; + free(entry->data); + if(entry->bstream) { + BitStream_free(entry->bstream); + } + free(entry); + + return next; +} + struct _QRenc_DataStream { QRenc_List *head; QRenc_List *tail; @@ -97,14 +126,7 @@ int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, { QRenc_List *entry; - entry = (QRenc_List *)malloc(sizeof(QRenc_List)); - entry->mode = mode; - entry->size = size; - entry->data = (unsigned char *)malloc(size); - entry->bstream = NULL; - - memcpy(entry->data, data, size); - entry->next = NULL; + entry = QRenc_newEntry(mode, size, data); if(stream->tail == NULL) { stream->head = entry; @@ -119,85 +141,20 @@ int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, void QRenc_freeData(QRenc_DataStream *stream) { - QRenc_List *list, *next; + QRenc_List *list; list = stream->head; while(list != NULL) { - free(list->data); - next = list->next; - if(list->bstream != NULL) { - BitStream_free(list->bstream); - } - free(list); - list = next; + list = QRenc_freeEntry(list); } free(stream); } /****************************************************************************** - * Data conversion + * Estimation of the version number *****************************************************************************/ - -/** - * Convert the number data stream to a bit stream. - * @param entry - * @return number of bits - */ -static int QRenc_encodeModeNum(QRenc_List *entry) -{ - int bits; - int words; - int i; - unsigned int val; - - words = entry->size / 3; - bits = words * 8; - switch(entry->size - words * 3) { - case 1: - bits += 4; - break; - case 2: - bits += 7; - break; - default: - break; - } - - entry->bstream = BitStream_new(bits); - - for(i=0; idata[i*3 ] - '0') * 100; - val += (entry->data[i*3+1] - '0') * 10; - val += (entry->data[i*3+2] - '0'); - } -} - -/** - * Convert the data stream in the data chunk to a bit stream. - * @param entry - * @return number of bits - */ -static int QRenc_encodeBitStream(QRenc_List *entry) -{ - assert(entry != NULL); - switch(entry->mode) { - case QR_MODE_NUM: - return QRenc_encodeModeNum(entry); - break; - case QR_MODE_AN: -// return QRenc_encodeModeAn(entry); - break; - case QR_MODE_8: -// return QRenc_encodeMode8(entry); - break; - case QR_MODE_KANJI: -// return QRenc_encodeModeKanji(entry); - break; - } -} - /** * Estimates the length of the encoded bit stream of numeric data. * @param entry @@ -322,6 +279,82 @@ int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version) return bits; } +/** + * Estimates the required version number of the symbol. + * @param stream data stream + * @return required version number + */ +static int QRenc_estimateVersion(QRenc_DataStream *stream) +{ + int bits; + int new, prev; + + new = 0; + do { + prev = new; + bits = QRenc_estimateBitStreamSize(stream, prev); + new = QRspec_getMinVersion((bits + 7) / 8); + if (new == -1) { + return -1; + } + } while (new > prev); + + return new; +} + +/****************************************************************************** + * Data conversion + *****************************************************************************/ + + +/** + * Convert the number data stream to a bit stream. + * @param entry + * @return number of bits + */ +static int QRenc_encodeModeNum(QRenc_List *entry) +{ + int words; + QRenc_List *st1, *st2; + int bits1, bits2; + + words = QRspec_maximumWords(QR_MODE_NUM, version); + if(words > entry->size) { + st1 = QRenc_newEntry(QR_MODE_NUM, words, entry->data); + st2 = QRenc_newEntry(QR_MODE_NUM, entry->size - words, &entry->data[words]); + bits1 = QRenc_encodeModeNum(st1); + bits2 = QRenc_encodeModeNum(st2); + entry->bstream = BitStream_new(bits1 + bits2); + BitStream_appendBitStream(entry->bstream, st1->bstream); + BitStream_appendBitStream(entry->bstream, st2->bstream); + } else { + } +} + +/** + * Convert the data stream in the data chunk to a bit stream. + * @param entry + * @return number of bits + */ +static int QRenc_encodeBitStream(QRenc_List *entry) +{ + assert(entry != NULL); + switch(entry->mode) { + case QR_MODE_NUM: + return QRenc_encodeModeNum(entry); + break; + case QR_MODE_AN: +// return QRenc_encodeModeAn(entry); + break; + case QR_MODE_8: +// return QRenc_encodeMode8(entry); + break; + case QR_MODE_KANJI: +// return QRenc_encodeModeKanji(entry); + break; + } +} + /** * Convert the input data stream to a bit stream. * @param stream input data stream. diff --git a/qrspec.c b/qrspec.c index 96fd364e8b..4013b97c2a 100644 --- a/qrspec.c +++ b/qrspec.c @@ -130,3 +130,18 @@ int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version) return lengthTableBits[mode][l]; } + +int QRspec_maximumWords(QRenc_EncodeMode mode, int version) +{ + int l; + + if(version < 9) { + l = 0; + } else if(version < 26) { + l = 1; + } else { + l = 2; + } + + return lengthTableWords[mode][l]; +} diff --git a/qrspec.h b/qrspec.h index b17239f2dd..d22b71f19d 100644 --- a/qrspec.h +++ b/qrspec.h @@ -56,11 +56,19 @@ extern int QRspec_getMinVersion(int size); *****************************************************************************/ /** - * Return the size of lenght indicator for mode and version. + * Return the size of lenght indicator for the mode and version. * @param mode * @param version * @return the size of the appropriate length indicator (bits). */ extern int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version); +/** + * Return the maximum length for the mode and version. + * @param mode + * @param version + * @return the maximum length (words) + */ +extern int QRspec_maximumWords(QRenc_EncodeMode mode, int version); + #endif /* __QRSPEC_H__ */ diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 8d005b1a0c..95342628f7 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -107,11 +107,75 @@ void test_varStream(void) testEnd(flag); } +void test_bitStreamAppend(void) +{ + unsigned int data; + BitStream *bstream, *bs1, *bs2, *bs3, *bs4; + int flag; + unsigned char correct[7]; + int i; + + testStart("Various bit stream"); + bstream = BitStream_new(54); + + bs1 = BitStream_new(7); + data = 0x7f; + correct[0] = 0x7f; + BitStream_append(bs1, 7, (unsigned char *)&data); + + bs2 = BitStream_new(14); + data = 0x0555; + correct[0] |= 0x80; + correct[1] = (0x55>>1) | (0x55<<7); + correct[2] = 0x05>>1; + BitStream_append(bs2, 14, (unsigned char *)&data); + + bs3 = BitStream_new(29); + data = 0x12345678; + correct[2] |= 0x78 << 5; + correct[3] = (0x78 >> 3) | (0x56 << 5); + correct[4] = (0x56 >> 3) | (0x34 << 5); + correct[5] = (0x34 >> 3) | (0x12 << 5); + correct[6] = 0x12 >> 3; + BitStream_append(bs3, 29, (unsigned char *)&data); + + bs4 = BitStream_new(4); + data = 0xff; + correct[6] |= (0xff & 0x0f) << 2; + BitStream_append(bs4, 4, (unsigned char *)&data); + + BitStream_appendBitStream(bstream, bs1); + BitStream_appendBitStream(bstream, bs2); + BitStream_appendBitStream(bstream, bs3); + BitStream_appendBitStream(bstream, bs4); + + for(i=0; i<7; i++) { + printf("%02x", correct[i]); + } + printf("\n"); + for(i=0; i<7; i++) { + printf("%02x", bstream->data[i]); + } + printf("\n"); + + flag = memcmp(correct, bstream->data, 6); + flag |= (bstream->data[6] & 0x3f) != (correct[6] & 0x3f); + + BitStream_free(bstream); + BitStream_free(bs1); + BitStream_free(bs2); + BitStream_free(bs3); + BitStream_free(bs4); + + testEnd(flag); +} + int main(int argc, char **argv) { test_8nbitsStream(); test_varStream(); test_1bitStream(); + test_bitStreamAppend(); report(); -- cgit 0.0.5-2-1-g0f52 From bd3f87156fcff99f1a891663229805abaa1575a1 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 7 Nov 2006 08:20:38 +0000 Subject: --- bitstream.c | 127 +++++++++++++++++++++++---------- bitstream.h | 20 +++--- qrencode.c | 75 ++++++++++++++++--- qrtest.h | 4 +- tests/Makefile.am | 2 +- tests/common.h | 41 +++++++++++ tests/test_bitstream.c | 186 ++++++++++-------------------------------------- tests/test_datastream.c | 23 +++--- 8 files changed, 257 insertions(+), 221 deletions(-) diff --git a/bitstream.c b/bitstream.c index 0a9cdf4eda..fa30820825 100644 --- a/bitstream.c +++ b/bitstream.c @@ -29,60 +29,111 @@ #include "bitstream.h" -BitStream *BitStream_new(int size) +BitStream *BitStream_new(void) { BitStream *bstream; - div_t d; - int byte; - - d = div(size, 8); - byte = d.quot + (d.rem?1:0); bstream = (BitStream *)malloc(sizeof(BitStream)); - bstream->size = size; - bstream->data = (unsigned char *)malloc(byte); - bstream->head = bstream->data; - bstream->remain = 0; + bstream->data = NULL; return bstream; } -void BitStream_append(BitStream *bstream, int size, unsigned char *data) +BitStream *BitStream_newFromNum(int bits, unsigned int num) { - int sb; - int shift; + unsigned int mask; + int i; + char *p; + BitStream *bstream; - sb = size / 8; + bstream = BitStream_new(); + bstream->data = (char *)malloc(bits + 1); - if(bstream->remain == 0) { - memcpy(bstream->head, data, sb); - bstream->head += sb; - if(size & 7) { - *bstream->head = data[sb]; - bstream->remain = 8 - (size - sb * 8); - } - } else { - shift = 8 - bstream->remain; - while(size > 7) { - *bstream->head++ |= *data << shift; - *bstream->head = *data++ >> bstream->remain; - size -= 8; + p = bstream->data; + mask = 1 << (bits - 1); + for(i=0; i 0) { - *bstream->head |= *data << shift; - if(size > bstream->remain) { - bstream->head++; - *bstream->head = *data >> bstream->remain; - bstream->remain += 8 - size; + p++; + mask = mask >> 1; + } + *p = '\0'; + + return bstream; +} + +BitStream *BitStream_newFromBytes(int size, unsigned char *data) +{ + unsigned char mask; + int i, j; + char *p; + BitStream *bstream; + + bstream = BitStream_new(); + bstream->data = (char *)malloc(size * 8 + 1); + + p = bstream->data; + for(i=0; iremain -= size; - if(bstream->remain == 0) { - bstream->head++; - bstream->remain = 8; - } + *p = '0'; } + p++; + mask = mask >> 1; } } + *p = '\0'; + + return bstream; +} + +void BitStream_append(BitStream *bstream, BitStream *arg) +{ + int l1, l2; + char *new; + + if(bstream->data == NULL) { + bstream->data = strdup(arg->data); + return; + } + + l1 = strlen(bstream->data); + l2 = strlen(arg->data); + new = (char *)malloc(l1 + l2 + 1); + strcpy(new, bstream->data); + strcat(new, arg->data); + + free(bstream->data); + bstream->data = new; +} + +void BitStream_appendNum(BitStream *bstream, int bits, unsigned int num) +{ + BitStream *b; + + b = BitStream_newFromNum(bits, num); + BitStream_append(bstream, b); + BitStream_free(b); +} + +void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) +{ + BitStream *b; + + b = BitStream_newFromBytes(size, data); + BitStream_append(bstream, b); + BitStream_free(b); +} + +unsigned int BitStream_size(BitStream *bstream) +{ + return strlen(bstream->data); } void BitStream_free(BitStream *bstream) diff --git a/bitstream.h b/bitstream.h index 7d881f6746..164799caaf 100644 --- a/bitstream.h +++ b/bitstream.h @@ -26,18 +26,16 @@ #define __BITSTREAM_H__ typedef struct { - int size; - unsigned char *data; - - int remain; - unsigned char *head; + char *data; } BitStream; -extern BitStream *BitStream_new(int size); -void BitStream_append(BitStream *bstream, int size, unsigned char *data); -void BitStream_free(BitStream *bstream); - -#define BitStream_appendBitStream(__arg1__, __arg2__) \ - BitStream_append((__arg1__), ((__arg2__)->size), ((__arg2__)->data)) +extern BitStream *BitStream_new(void); +extern BitStream *BitStream_newFromNum(int bits, unsigned int num); +extern BitStream *BitStream_newFromBytes(int size, unsigned char *data); +extern void BitStream_append(BitStream *bstream, BitStream *arg); +extern void BitStream_appendNum(BitStream *bstream, int bits, unsigned int num); +extern void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data); +extern unsigned int BitStream_size(BitStream *bstream); +extern void BitStream_free(BitStream *bstream); #endif /* __BITSTREAM_H__ */ diff --git a/qrencode.c b/qrencode.c index f090fb20a7..ae04922450 100644 --- a/qrencode.c +++ b/qrencode.c @@ -284,7 +284,7 @@ int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version) * @param stream data stream * @return required version number */ -static int QRenc_estimateVersion(QRenc_DataStream *stream) +int QRenc_estimateVersion(QRenc_DataStream *stream) { int bits; int new, prev; @@ -316,19 +316,54 @@ static int QRenc_encodeModeNum(QRenc_List *entry) { int words; QRenc_List *st1, *st2; - int bits1, bits2; + int i; + unsigned int val; + + if(entry->bstream != NULL) { + BitStream_free(entry->bstream); + entry->bstream = NULL; + } words = QRspec_maximumWords(QR_MODE_NUM, version); - if(words > entry->size) { + if(entry->size > words) { st1 = QRenc_newEntry(QR_MODE_NUM, words, entry->data); st2 = QRenc_newEntry(QR_MODE_NUM, entry->size - words, &entry->data[words]); - bits1 = QRenc_encodeModeNum(st1); - bits2 = QRenc_encodeModeNum(st2); - entry->bstream = BitStream_new(bits1 + bits2); - BitStream_appendBitStream(entry->bstream, st1->bstream); - BitStream_appendBitStream(entry->bstream, st2->bstream); + QRenc_encodeModeNum(st1); + QRenc_encodeModeNum(st2); + entry->bstream = BitStream_new(); + BitStream_append(entry->bstream, st1->bstream); + BitStream_append(entry->bstream, st2->bstream); + QRenc_freeEntry(st1); + QRenc_freeEntry(st2); } else { + words = entry->size / 3; + entry->bstream = BitStream_new(); + + val = 0x01; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val); + + for(i=0; idata[i*3 ] - '0') * 100; + val += (entry->data[i*3+1] - '0') * 10; + val += (entry->data[i*3+2] - '0'); + + BitStream_appendNum(entry->bstream, 10, val); + } + + if(entry->size - words * 3 == 1) { + val = entry->data[words*3] - '0'; + BitStream_appendNum(entry->bstream, 4, val); + } else if(entry->size - words * 3 == 2) { + val = (entry->data[words*3 ] - '0') * 10; + val += (entry->data[words*3+1] - '0'); + BitStream_appendNum(entry->bstream, 7, val); + } } + + return BitStream_size(entry->bstream); } /** @@ -352,19 +387,21 @@ static int QRenc_encodeBitStream(QRenc_List *entry) case QR_MODE_KANJI: // return QRenc_encodeModeKanji(entry); break; + default: + break; } + return 0; } /** * Convert the input data stream to a bit stream. * @param stream input data stream. - * @return bit stream. + * @return length of the bit stream. */ -int QRenc_createBitStream(QRenc_DataStream *stream) +static int QRenc_createBitStream(QRenc_DataStream *stream) { QRenc_List *list; int bits = 0; - BitStream *bstream; assert(stream != NULL); @@ -376,3 +413,19 @@ int QRenc_createBitStream(QRenc_DataStream *stream) return bits; } + +BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream) +{ + BitStream *bstream; + QRenc_List *list; + + QRenc_createBitStream(stream); + bstream = BitStream_new(); + list = stream->head; + while(list != NULL) { + BitStream_append(bstream, list->bstream); + list = list->next; + } + + return bstream; +} diff --git a/qrtest.h b/qrtest.h index 8db7c2157e..ec6524a080 100644 --- a/qrtest.h +++ b/qrtest.h @@ -1,4 +1,6 @@ #include "qrencode.h" #include "bitstream.h" -int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); +extern int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); +extern BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream); +extern int QRenc_estimateVersion(QRenc_DataStream *stream); diff --git a/tests/Makefile.am b/tests/Makefile.am index 383d6a926d..cc99048b60 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ test_datastream_SOURCES = test_datastream.c test_datastream_LDADD = ../libqrencode.la test_bitstream_SOURCES = test_bitstream.c -test_bitstream_LDADD = ../libqrencode.la +test_bitstream_LDADD = ../bitstream.o test_estimatebit_SOURCES = test_estimatebit.c test_estimatebit_LDADD = ../libqrencode.la diff --git a/tests/common.h b/tests/common.h index 5c7f8210a8..d67e7d6822 100644 --- a/tests/common.h +++ b/tests/common.h @@ -5,7 +5,9 @@ #ifndef __COMMON_H__ #define __COMMON_H__ +#include #include "../qrencode.h" +#include "../bitstream.h" #define CHECK(_str_) (printf("_____%s\n",_str_)) #define RESULT(_args_...) (printf(".....") + printf(_args_)) @@ -42,4 +44,43 @@ void report() printf("Total %d tests, %d fails.\n", tests, failed); } +char *sprintfBin(int size, unsigned char *data) +{ + int i, j; + unsigned char mask; + int b, r; + char *str, *p; + + str = (char *)malloc(size + 1); + p = str; + b = size / 8; + for(i=0; i> 1; + } + } + r = size - b * 8; + if(r) { + mask = 1 << (r - 1); + for(i=0; i> 1; + } + } + *p = '\0'; + + return str; +} #endif /* __COMMON_H__ */ diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 95342628f7..b0117ccc94 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -3,179 +3,65 @@ #include "common.h" #include "../bitstream.h" -void test_1bitStream(void) +void test_num(void) { - unsigned int data; BitStream *bstream; - int i, flag; - - testStart("1 bit stream"); - bstream = BitStream_new(128); - data = 1; - for(i=0; i<128; i++) { - BitStream_append(bstream, 1, (unsigned char *)&data); - } - - flag = 0; - for(i=0; i<16; i++) { - printf("%02x", bstream->data[i]); - if(bstream->data[i] != 0xff) - flag++; - } - printf("\n"); + unsigned int data = 0x13579bdf; + char correct[] = "0010011010101111001101111011111"; - BitStream_free(bstream); + testStart("New from num"); + bstream = BitStream_newFromNum(31, data); + testEnd(strncmp(correct, bstream->data, 31)); - testEnd(flag); + BitStream_free(bstream); } -void test_8nbitsStream(void) +void test_bytes(void) { - unsigned int data; BitStream *bstream; - unsigned char correct[7]; - - testStart("8n bit stream"); - bstream = BitStream_new(56); - data = 0x8a; - correct[0] = 0x8a; - BitStream_append(bstream, 8, (unsigned char *)&data); - - data = 0xffff; - correct[1] = 0xff; - correct[2] = 0xff; - BitStream_append(bstream, 16, (unsigned char *)&data); - - data = 0x12345678; - correct[3] = 0x78; - correct[4] = 0x56; - correct[5] = 0x34; - correct[6] = 0x12; - BitStream_append(bstream, 32, (unsigned char *)&data); - - testEnd(memcmp(correct, bstream->data, 7)); + unsigned char data[1] = {0x3a}; + char correct[] = "00111010"; + testStart("New from bytes"); + bstream = BitStream_newFromBytes(1, data); + testEnd(strncmp(correct, bstream->data, 8)); BitStream_free(bstream); } -void test_varStream(void) +void test_appendBytes(void) { - unsigned int data; BitStream *bstream; - int flag; - unsigned char correct[7]; - int i; - - testStart("Various bit stream"); - bstream = BitStream_new(54); - data = 0x7f; - correct[0] = 0x7f; - BitStream_append(bstream, 7, (unsigned char *)&data); - - data = 0x0555; - correct[0] |= 0x80; - correct[1] = (0x55>>1) | (0x55<<7); - correct[2] = 0x05>>1; - BitStream_append(bstream, 14, (unsigned char *)&data); - - data = 0x12345678; - correct[2] |= 0x78 << 5; - correct[3] = (0x78 >> 3) | (0x56 << 5); - correct[4] = (0x56 >> 3) | (0x34 << 5); - correct[5] = (0x34 >> 3) | (0x12 << 5); - correct[6] = 0x12 >> 3; - BitStream_append(bstream, 29, (unsigned char *)&data); - - data = 0xff; - correct[6] |= (0xff & 0x0f) << 2; - BitStream_append(bstream, 4, (unsigned char *)&data); - - for(i=0; i<7; i++) { - printf("%02x", correct[i]); - } - printf("\n"); - for(i=0; i<7; i++) { - printf("%02x", bstream->data[i]); - } - printf("\n"); - - flag = memcmp(correct, bstream->data, 6); - flag |= (bstream->data[6] & 0x3f) != (correct[6] & 0x3f); + unsigned char data[8]; + char correct[] = "10001010111111111111111100010010001101000101011001111000"; - BitStream_free(bstream); + testStart("Append Bytes"); + bstream = BitStream_new(); - testEnd(flag); -} + data[0] = 0x8a; + BitStream_appendBytes(bstream, 1, data); -void test_bitStreamAppend(void) -{ - unsigned int data; - BitStream *bstream, *bs1, *bs2, *bs3, *bs4; - int flag; - unsigned char correct[7]; - int i; - - testStart("Various bit stream"); - bstream = BitStream_new(54); - - bs1 = BitStream_new(7); - data = 0x7f; - correct[0] = 0x7f; - BitStream_append(bs1, 7, (unsigned char *)&data); - - bs2 = BitStream_new(14); - data = 0x0555; - correct[0] |= 0x80; - correct[1] = (0x55>>1) | (0x55<<7); - correct[2] = 0x05>>1; - BitStream_append(bs2, 14, (unsigned char *)&data); - - bs3 = BitStream_new(29); - data = 0x12345678; - correct[2] |= 0x78 << 5; - correct[3] = (0x78 >> 3) | (0x56 << 5); - correct[4] = (0x56 >> 3) | (0x34 << 5); - correct[5] = (0x34 >> 3) | (0x12 << 5); - correct[6] = 0x12 >> 3; - BitStream_append(bs3, 29, (unsigned char *)&data); - - bs4 = BitStream_new(4); - data = 0xff; - correct[6] |= (0xff & 0x0f) << 2; - BitStream_append(bs4, 4, (unsigned char *)&data); - - BitStream_appendBitStream(bstream, bs1); - BitStream_appendBitStream(bstream, bs2); - BitStream_appendBitStream(bstream, bs3); - BitStream_appendBitStream(bstream, bs4); - - for(i=0; i<7; i++) { - printf("%02x", correct[i]); - } - printf("\n"); - for(i=0; i<7; i++) { - printf("%02x", bstream->data[i]); - } - printf("\n"); - - flag = memcmp(correct, bstream->data, 6); - flag |= (bstream->data[6] & 0x3f) != (correct[6] & 0x3f); + data[0] = 0xff; + data[1] = 0xff; + BitStream_appendBytes(bstream, 2, data); - BitStream_free(bstream); - BitStream_free(bs1); - BitStream_free(bs2); - BitStream_free(bs3); - BitStream_free(bs4); + data[0] = 0x12; + data[1] = 0x34; + data[2] = 0x56; + data[3] = 0x78; + BitStream_appendBytes(bstream, 4, data); + + testEnd(strncmp(correct, bstream->data, 64)); - testEnd(flag); + BitStream_free(bstream); } + + int main(int argc, char **argv) { - test_8nbitsStream(); - test_varStream(); - test_1bitStream(); - test_bitStreamAppend(); + test_num(); + test_bytes(); + test_appendBytes(); report(); diff --git a/tests/test_datastream.c b/tests/test_datastream.c index 56d92cfd2d..f64324c7e6 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -1,23 +1,28 @@ #include +#include #include "common.h" +#include "../qrtest.h" -void test_freeDataStream(void) +void test_encodeNumeric(void) { QRenc_DataStream *stream; - unsigned char dummy[8]; + char num[9] = "01234567"; + char correct[] = "00010000001000000000110001010110011000011"; + BitStream *bstream; - testStart("Fee DataStream(always passed, but check valgrind."); + testStart("Encoding numeric stream."); stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_8, 8, dummy); - QRenc_appendData(stream, QR_MODE_8, 8, dummy); - QRenc_appendData(stream, QR_MODE_8, 8, dummy); - QRenc_freeData(stream); - testEnd(0); + QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + QRenc_setVersion(QRenc_estimateVersion(stream)); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); } int main(int argc, char **argv) { - test_freeDataStream(); + test_encodeNumeric(); report(); -- cgit 0.0.5-2-1-g0f52 From d6acd7bd6831f3c1306d0fcc8548b9be96b521d7 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 7 Nov 2006 10:34:17 +0000 Subject: --- qrencode.c | 392 ++++++++++++++++++++++++++++++++++++------------ qrencode.h | 74 ++++----- tests/test_datastream.c | 77 +++++++++- 3 files changed, 412 insertions(+), 131 deletions(-) diff --git a/qrencode.c b/qrencode.c index ae04922450..e394effd44 100644 --- a/qrencode.c +++ b/qrencode.c @@ -32,39 +32,7 @@ #include "bitstream.h" /****************************************************************************** - * Error Correction Level - *****************************************************************************/ - -static QRenc_ErrorCorrectionLevel errorCorrectionLevel = QR_EC_LEVEL_L; - -void QRenc_setErrorCorrectionLevel(QRenc_ErrorCorrectionLevel level) -{ - errorCorrectionLevel = level; -} - -QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(void) -{ - return errorCorrectionLevel; -} - -/****************************************************************************** - * Version (size of the QR-code) - *****************************************************************************/ - -static int version = 0; - -extern int QRenc_getVersion(void) -{ - return version; -} - -extern void QRenc_setVersion(int v) -{ - version = v; -} - -/****************************************************************************** - * Input data stream + * Entry of input data stream *****************************************************************************/ typedef struct _QRenc_List QRenc_List; @@ -80,6 +48,10 @@ static QRenc_List *QRenc_newEntry(QRenc_EncodeMode mode, int size, unsigned char { QRenc_List *entry; + if(QRenc_checkData(mode, size, data)) { + return NULL; + } + entry = (QRenc_List *)malloc(sizeof(QRenc_List)); entry->mode = mode; entry->size = size; @@ -105,11 +77,37 @@ static QRenc_List *QRenc_freeEntry(QRenc_List *entry) return next; } +/****************************************************************************** + * Input Data stream + *****************************************************************************/ + struct _QRenc_DataStream { + int version; + QRenc_ErrorCorrectionLevel level; QRenc_List *head; QRenc_List *tail; }; +int QRenc_getVersion(QRenc_DataStream *stream) +{ + return stream->version; +} + +void QRenc_setVersion(QRenc_DataStream *stream, int v) +{ + stream->version = v; +} + +void QRenc_setErrorCorrectionLevel(QRenc_DataStream *stream, QRenc_ErrorCorrectionLevel level) +{ + stream->level = level; +} + +QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(QRenc_DataStream *stream) +{ + return stream->level; +} + QRenc_DataStream *QRenc_newData(void) { @@ -118,6 +116,8 @@ QRenc_DataStream *QRenc_newData(void) stream = (QRenc_DataStream *)malloc(sizeof(QRenc_DataStream)); stream->head = NULL; stream->tail = NULL; + stream->version = 0; + stream->level = QR_EC_LEVEL_L; return stream; } @@ -127,6 +127,9 @@ int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, QRenc_List *entry; entry = QRenc_newEntry(mode, size, data); + if(entry == NULL) { + return -1; + } if(stream->tail == NULL) { stream->head = entry; @@ -152,9 +155,27 @@ void QRenc_freeData(QRenc_DataStream *stream) } /****************************************************************************** - * Estimation of the version number + * Numeric data *****************************************************************************/ +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeNum(int size, const char *data) +{ + int i; + + for(i=0; i '9') + return -1; + } + + return 0; +} + /** * Estimates the length of the encoded bit stream of numeric data. * @param entry @@ -181,6 +202,89 @@ static int QRenc_estimateBitsModeNum(QRenc_List *entry) return bits; } +/** + * Convert the number data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeModeNum(QRenc_List *entry, int version) +{ + int words; + int i; + unsigned int val; + + words = entry->size / 3; + entry->bstream = BitStream_new(); + + val = 0x01; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val); + + for(i=0; idata[i*3 ] - '0') * 100; + val += (entry->data[i*3+1] - '0') * 10; + val += (entry->data[i*3+2] - '0'); + + BitStream_appendNum(entry->bstream, 10, val); + } + + if(entry->size - words * 3 == 1) { + val = entry->data[words*3] - '0'; + BitStream_appendNum(entry->bstream, 4, val); + } else if(entry->size - words * 3 == 2) { + val = (entry->data[words*3 ] - '0') * 10; + val += (entry->data[words*3+1] - '0'); + BitStream_appendNum(entry->bstream, 7, val); + } +} + +/****************************************************************************** + * Alphabet-numeric data + *****************************************************************************/ + +static signed char anTable[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1 +}; + +/** + * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). + * @param c character + * @return value + */ +inline static signed char QRenc_lookAnTable(char c) +{ + if(c & 0x80) { + return -1; + } + return anTable[(int)c]; +} + +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeAn(int size, const char *data) +{ + int i; + + for(i=0; isize / 2; + entry->bstream = BitStream_new(); + + val = 0x02; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), val); + + for(i=0; idata[i*2 ]) * 45; + val += (unsigned int)QRenc_lookAnTable(entry->data[i*2+1]); + + BitStream_appendNum(entry->bstream, 11, val); + } + + if(entry->size & 1) { + val = (unsigned int)QRenc_lookAnTable(entry->data[words * 2]); + + BitStream_appendNum(entry->bstream, 6, val); + } +} + +/****************************************************************************** + * 8 bit data + *****************************************************************************/ + /** * Estimates the length of the encoded bit stream of 8 bit data. * @param entry @@ -210,6 +351,33 @@ static int QRenc_estimateBitsMode8(QRenc_List *entry) return entry->size * 8; } +/** + * Convert the 8bits data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeMode8(QRenc_List *entry, int version) +{ + int i; + unsigned int val; + + entry->bstream = BitStream_new(); + + val = 0x04; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), val); + + for(i=0; isize; i++) { + BitStream_appendNum(entry->bstream, 8, entry->data[i]); + } +} + + +/****************************************************************************** + * Kanji data + *****************************************************************************/ + /** * Estimates the length of the encoded bit stream of kanji data. * @param entry @@ -220,6 +388,64 @@ static int QRenc_estimateBitsModeKanji(QRenc_List *entry) return (entry->size / 2) * 13; } +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeKanji(int size, const unsigned char *data) +{ + int i; + unsigned int val; + + if(size & 1) + return -1; + + for(i=0; i 0x9ffc && val < 0xe040) || val > 0xebbf) { + return -1; + } + } + + return 0; +} + +/****************************************************************************** + * Validation + *****************************************************************************/ + +/** + * Validate the input data + * @param mode + * @param size + * @param data + * @return result + */ +int QRenc_checkData(QRenc_EncodeMode mode, int size, const unsigned char *data) +{ + switch(mode) { + case QR_MODE_NUM: + return QRenc_checkModeNum(size, (const char *)data); + break; + case QR_MODE_AN: + return QRenc_checkModeAn(size, (const char *)data); + break; + case QR_MODE_KANJI: + return QRenc_checkModeKanji(size, data); + break; + default: + break; + } + + return 0; +} + +/****************************************************************************** + * Estimation of the bit length + *****************************************************************************/ + /** * Estimates the length of the encoded bit stream on the current version. * @param entry @@ -306,93 +532,56 @@ int QRenc_estimateVersion(QRenc_DataStream *stream) * Data conversion *****************************************************************************/ - /** - * Convert the number data stream to a bit stream. + * Convert the data stream in the data chunk to a bit stream. * @param entry * @return number of bits */ -static int QRenc_encodeModeNum(QRenc_List *entry) +static int QRenc_encodeBitStream(QRenc_List *entry, int version) { int words; QRenc_List *st1, *st2; - int i; - unsigned int val; + + assert(entry != NULL); if(entry->bstream != NULL) { BitStream_free(entry->bstream); entry->bstream = NULL; } - words = QRspec_maximumWords(QR_MODE_NUM, version); + words = QRspec_maximumWords(entry->mode, version); if(entry->size > words) { - st1 = QRenc_newEntry(QR_MODE_NUM, words, entry->data); - st2 = QRenc_newEntry(QR_MODE_NUM, entry->size - words, &entry->data[words]); - QRenc_encodeModeNum(st1); - QRenc_encodeModeNum(st2); + st1 = QRenc_newEntry(entry->mode, words, entry->data); + st2 = QRenc_newEntry(entry->mode, entry->size - words, &entry->data[words]); + QRenc_encodeBitStream(st1, version); + QRenc_encodeBitStream(st2, version); entry->bstream = BitStream_new(); BitStream_append(entry->bstream, st1->bstream); BitStream_append(entry->bstream, st2->bstream); QRenc_freeEntry(st1); QRenc_freeEntry(st2); } else { - words = entry->size / 3; - entry->bstream = BitStream_new(); - - val = 0x01; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val); - - for(i=0; idata[i*3 ] - '0') * 100; - val += (entry->data[i*3+1] - '0') * 10; - val += (entry->data[i*3+2] - '0'); - - BitStream_appendNum(entry->bstream, 10, val); - } - - if(entry->size - words * 3 == 1) { - val = entry->data[words*3] - '0'; - BitStream_appendNum(entry->bstream, 4, val); - } else if(entry->size - words * 3 == 2) { - val = (entry->data[words*3 ] - '0') * 10; - val += (entry->data[words*3+1] - '0'); - BitStream_appendNum(entry->bstream, 7, val); + switch(entry->mode) { + case QR_MODE_NUM: + QRenc_encodeModeNum(entry, version); + break; + case QR_MODE_AN: + QRenc_encodeModeAn(entry, version); + break; + case QR_MODE_8: + QRenc_encodeMode8(entry, version); + break; + case QR_MODE_KANJI: +// QRenc_encodeModeKanji(entry, version); + break; + default: + break; } } return BitStream_size(entry->bstream); } -/** - * Convert the data stream in the data chunk to a bit stream. - * @param entry - * @return number of bits - */ -static int QRenc_encodeBitStream(QRenc_List *entry) -{ - assert(entry != NULL); - switch(entry->mode) { - case QR_MODE_NUM: - return QRenc_encodeModeNum(entry); - break; - case QR_MODE_AN: -// return QRenc_encodeModeAn(entry); - break; - case QR_MODE_8: -// return QRenc_encodeMode8(entry); - break; - case QR_MODE_KANJI: -// return QRenc_encodeModeKanji(entry); - break; - default: - break; - } - return 0; -} - /** * Convert the input data stream to a bit stream. * @param stream input data stream. @@ -407,13 +596,24 @@ static int QRenc_createBitStream(QRenc_DataStream *stream) list = stream->head; while(list != NULL) { - bits += QRenc_encodeBitStream(list); + bits += QRenc_encodeBitStream(list, stream->version); list = list->next; } return bits; } +/** + * Convert the input data stream to a bit stream. + * When the version number is given and that is not sufficient, it is increased + * automatically. + * @param stream input data stream. + * @return -1 if the input data was too large. Otherwise 0. + */ +static int QRenc_convertData(QRenc_DataStream *stream) +{ +} + BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream) { BitStream *bstream; diff --git a/qrencode.h b/qrencode.h index 76a7580640..cdc48a8671 100644 --- a/qrencode.h +++ b/qrencode.h @@ -27,9 +27,28 @@ #define __QRENCODE_H__ /****************************************************************************** - * Error Correction Level + * Encoding mode + *****************************************************************************/ + +/** + * Encoding mode. + */ +typedef enum { + QR_MODE_NUM = 0, ///< Numeric mode + QR_MODE_AN, ///< Alphabet-numeric mode + QR_MODE_8, ///< 8-bit data mode + QR_MODE_KANJI ///< Kanji (shift-jis) mode +} QRenc_EncodeMode; + +/****************************************************************************** + * Input data stream *****************************************************************************/ +/** + * Data structure to store input data stream. + */ +typedef struct _QRenc_DataStream QRenc_DataStream; + /** * Level of error correction. */ @@ -42,54 +61,32 @@ typedef enum { /** * Get current error correction level. + * @param stream input data stream * @return Current error correcntion level. */ -extern QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(void); +extern QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(QRenc_DataStream *stream); /** * Set error correction level of the QR-code that is to be encoded. + * @param stream input data stream * @param level Error correction level. */ -extern void QRenc_setErrorCorrectionLevel(QRenc_ErrorCorrectionLevel level); - -/****************************************************************************** - * Version (size of the QR-code) - *****************************************************************************/ +extern void QRenc_setErrorCorrectionLevel(QRenc_DataStream *stream, QRenc_ErrorCorrectionLevel level); /** * Get current version. - * @return Current version. + * @param stream input data stream + * @return current version */ -extern int QRenc_getVersion(void); +extern int QRenc_getVersion(QRenc_DataStream *stream); /** * Set version of the QR-code that is to be encoded. - * @param version Version. (0 = auto) - */ -extern void QRenc_setVersion(int version); - -/****************************************************************************** - * Encoding mode - *****************************************************************************/ - -/** - * Encoding mode. + * @param stream input data stream + * @param version version number (0 = auto) */ -typedef enum { - QR_MODE_NUM = 0, ///< Numeric mode - QR_MODE_AN, ///< Alphabet-numeric mode - QR_MODE_8, ///< 8-bit data mode - QR_MODE_KANJI ///< Kanji (shift-jis) mode -} QRenc_EncodeMode; - -/****************************************************************************** - * Input data stream - *****************************************************************************/ +extern void QRenc_setVersion(QRenc_DataStream *stream, int version); -/** - * Data structure to store input data stream. - */ -typedef struct _QRenc_DataStream QRenc_DataStream; /** * Instantiate a data stream object. @@ -104,7 +101,7 @@ extern QRenc_DataStream *QRenc_newData(void); * @param mode Encoding mode. * @param size Size of data (byte). * @param data A pointer to the memory area of the input data. - * @return Always 0. + * @return -1 when the input data is invalid. Otherwise 0. */ extern int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, unsigned char *data); @@ -115,6 +112,15 @@ extern int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int */ extern void QRenc_freeData(QRenc_DataStream *stream); +/** + * Validate the input data + * @param mode + * @param size + * @param data + * @return result + */ +extern int QRenc_checkData(QRenc_EncodeMode mode, int size, const unsigned char *data); + /****************************************************************************** * QRcode output *****************************************************************************/ diff --git a/tests/test_datastream.c b/tests/test_datastream.c index f64324c7e6..75558ff4e8 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -3,6 +3,57 @@ #include "common.h" #include "../qrtest.h" +void test_encode8(void) +{ + QRenc_DataStream *stream; + char str[] = "AC-42"; + char correct[] = "00100000001010011100111011100111001000010"; + BitStream *bstream; + + testStart("Encoding alphabet-numeric stream."); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); + QRenc_setVersion(stream, QRenc_estimateVersion(stream)); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRenc_freeData(stream); + BitStream_free(bstream); +} + +void test_encodeAn(void) +{ + QRenc_DataStream *stream; + char str[] = "AC-42"; + char correct[] = "00100000001010011100111011100111001000010"; + BitStream *bstream; + + testStart("Encoding alphabet-numeric stream."); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); + QRenc_setVersion(stream, QRenc_estimateVersion(stream)); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRenc_freeData(stream); + BitStream_free(bstream); +} + +void test_encodeAn2(void) +{ + QRenc_DataStream *stream; + char str[] = "!,;$%"; + int ret; + + testStart("Encoding alphabet-numeric stream."); + stream = QRenc_newData(); + ret = QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); + testEnd(!ret); + QRenc_freeData(stream); +} + void test_encodeNumeric(void) { QRenc_DataStream *stream; @@ -13,16 +64,40 @@ void test_encodeNumeric(void) testStart("Encoding numeric stream."); stream = QRenc_newData(); QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); - QRenc_setVersion(QRenc_estimateVersion(stream)); + QRenc_setVersion(stream, QRenc_estimateVersion(stream)); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRenc_freeData(stream); + BitStream_free(bstream); +} + +void test_encodeNumeric2(void) +{ + QRenc_DataStream *stream; + char num[] = "0123456789012345"; + char correct[] = "00010000010000000000110001010110011010100110111000010100111010100101"; + BitStream *bstream; + + testStart("Encoding numeric stream."); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_NUM, 16, (unsigned char *)num); + QRenc_setVersion(stream, QRenc_estimateVersion(stream)); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); + QRenc_freeData(stream); + BitStream_free(bstream); } int main(int argc, char **argv) { test_encodeNumeric(); + test_encodeNumeric2(); + test_encodeAn(); + test_encodeAn2(); report(); -- cgit 0.0.5-2-1-g0f52 From af33f64d6a86b77c0f2fed3174e9b10a841c84fc Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 7 Nov 2006 11:32:46 +0000 Subject: --- qrencode.c | 63 ++++++++++++++++++++++++++++++++++++++++++------ qrspec.c | 27 +++++++++++---------- qrspec.h | 2 +- tests/test_datastream.c | 58 ++++++++++++++++++++++++++++++++++++++------ tests/test_estimatebit.c | 17 +++++++++---- 5 files changed, 134 insertions(+), 33 deletions(-) diff --git a/qrencode.c b/qrencode.c index e394effd44..c2f78a4ad6 100644 --- a/qrencode.c +++ b/qrencode.c @@ -108,7 +108,6 @@ QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(QRenc_DataStream *strea return stream->level; } - QRenc_DataStream *QRenc_newData(void) { QRenc_DataStream *stream; @@ -215,7 +214,7 @@ static void QRenc_encodeModeNum(QRenc_List *entry, int version) words = entry->size / 3; entry->bstream = BitStream_new(); - val = 0x01; + val = 0x1; BitStream_appendNum(entry->bstream, 4, val); val = entry->size; @@ -317,7 +316,7 @@ static void QRenc_encodeModeAn(QRenc_List *entry, int version) words = entry->size / 2; entry->bstream = BitStream_new(); - val = 0x02; + val = 0x2; BitStream_appendNum(entry->bstream, 4, val); val = entry->size; @@ -362,7 +361,7 @@ static void QRenc_encodeMode8(QRenc_List *entry, int version) entry->bstream = BitStream_new(); - val = 0x04; + val = 0x4; BitStream_appendNum(entry->bstream, 4, val); val = entry->size; @@ -412,6 +411,37 @@ static int QRenc_checkModeKanji(int size, const unsigned char *data) return 0; } +/** + * Convert the kanji data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeModeKanji(QRenc_List *entry, int version) +{ + int i; + unsigned int val, h; + + entry->bstream = BitStream_new(); + + val = 0x8; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size / 2; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), val); + + for(i=0; isize; i+=2) { + val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1]; + if(val <= 0x9ffc) { + val -= 0x8140; + } else { + val -= 0xc140; + } + h = (val >> 8) * 0xc0; + val = (val & 0xff) + h; + + BitStream_appendNum(entry->bstream, 13, val); + } +} + /****************************************************************************** * Validation *****************************************************************************/ @@ -519,7 +549,7 @@ int QRenc_estimateVersion(QRenc_DataStream *stream) do { prev = new; bits = QRenc_estimateBitStreamSize(stream, prev); - new = QRspec_getMinVersion((bits + 7) / 8); + new = QRspec_getMinimumVersion((bits + 7) / 8); if (new == -1) { return -1; } @@ -572,7 +602,7 @@ static int QRenc_encodeBitStream(QRenc_List *entry, int version) QRenc_encodeMode8(entry, version); break; case QR_MODE_KANJI: -// QRenc_encodeModeKanji(entry, version); + QRenc_encodeModeKanji(entry, version); break; default: break; @@ -612,6 +642,25 @@ static int QRenc_createBitStream(QRenc_DataStream *stream) */ static int QRenc_convertData(QRenc_DataStream *stream) { + int bits; + int ver; + + ver = QRenc_estimateVersion(stream); + QRenc_setVersion(stream, ver); + + for(;;) { + bits = QRenc_createBitStream(stream); + ver = QRspec_getMinimumVersion((bits + 7) / 8); + if(ver < 0) { + return -1; + } else if(ver > QRenc_getVersion(stream)) { + QRenc_setVersion(stream, ver); + } else { + break; + } + } + + return 0; } BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream) @@ -619,7 +668,7 @@ BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream) BitStream *bstream; QRenc_List *list; - QRenc_createBitStream(stream); + QRenc_convertData(stream); bstream = BitStream_new(); list = stream->head; while(list != NULL) { diff --git a/qrspec.c b/qrspec.c index 4013b97c2a..642119953d 100644 --- a/qrspec.c +++ b/qrspec.c @@ -87,7 +87,7 @@ QRspec_Capacity qrspecCapacity[QRSPEC_VERSION_MAX + 1] = { * @param size input code length (byte) * @return version number */ -int QRspec_getMinVersion(int size) +int QRspec_getMinimumVersion(int size) { int i; @@ -109,20 +109,13 @@ static int lengthTableBits[4][3] = { { 8, 10, 12} }; -static int lengthTableWords[4][3] = { - {307, 1228, 4915}, - { 93, 372, 1489}, - { 32, 8192, 8192}, - { 19, 78, 315} -}; - int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version) { int l; - if(version < 9) { + if(version <= 9) { l = 0; - } else if(version < 26) { + } else if(version <= 26) { l = 1; } else { l = 2; @@ -134,14 +127,22 @@ int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version) int QRspec_maximumWords(QRenc_EncodeMode mode, int version) { int l; + int bits; + int words; - if(version < 9) { + if(version <= 9) { l = 0; - } else if(version < 26) { + } else if(version <= 26) { l = 1; } else { l = 2; } - return lengthTableWords[mode][l]; + bits = lengthTableBits[mode][l]; + words = (1 << bits) - 1; + if(mode == QR_MODE_KANJI) { + words *= 2; // the number of bytes is required + } + + return words; } diff --git a/qrspec.h b/qrspec.h index d22b71f19d..4eada1f962 100644 --- a/qrspec.h +++ b/qrspec.h @@ -49,7 +49,7 @@ extern QRspec_Capacity qrspecCapacity[]; * @param size input code length (byte) * @return version number */ -extern int QRspec_getMinVersion(int size); +extern int QRspec_getMinimumVersion(int size); /****************************************************************************** * Length indicator diff --git a/tests/test_datastream.c b/tests/test_datastream.c index 75558ff4e8..19f1eba3b0 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -3,6 +3,24 @@ #include "common.h" #include "../qrtest.h" +void test_encodeKanji(void) +{ + QRenc_DataStream *stream; + unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; + char correct[] = "10000000001001101100111111101010101010"; + BitStream *bstream; + + testStart("Encoding kanji stream."); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_KANJI, 4, (unsigned char *)str); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRenc_freeData(stream); + BitStream_free(bstream); +} + void test_encode8(void) { QRenc_DataStream *stream; @@ -13,7 +31,6 @@ void test_encode8(void) testStart("Encoding alphabet-numeric stream."); stream = QRenc_newData(); QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); - QRenc_setVersion(stream, QRenc_estimateVersion(stream)); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); @@ -32,7 +49,6 @@ void test_encodeAn(void) testStart("Encoding alphabet-numeric stream."); stream = QRenc_newData(); QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); - QRenc_setVersion(stream, QRenc_estimateVersion(stream)); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); @@ -47,7 +63,7 @@ void test_encodeAn2(void) char str[] = "!,;$%"; int ret; - testStart("Encoding alphabet-numeric stream."); + testStart("Encoding INVALID alphabet-numeric stream."); stream = QRenc_newData(); ret = QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); testEnd(!ret); @@ -61,10 +77,9 @@ void test_encodeNumeric(void) char correct[] = "00010000001000000000110001010110011000011"; BitStream *bstream; - testStart("Encoding numeric stream."); + testStart("Encoding numeric stream. (8 digits)"); stream = QRenc_newData(); QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); - QRenc_setVersion(stream, QRenc_estimateVersion(stream)); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); @@ -80,10 +95,9 @@ void test_encodeNumeric2(void) char correct[] = "00010000010000000000110001010110011010100110111000010100111010100101"; BitStream *bstream; - testStart("Encoding numeric stream."); + testStart("Encoding numeric stream. (16 digits)"); stream = QRenc_newData(); QRenc_appendData(stream, QR_MODE_NUM, 16, (unsigned char *)num); - QRenc_setVersion(stream, QRenc_estimateVersion(stream)); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); @@ -92,12 +106,42 @@ void test_encodeNumeric2(void) BitStream_free(bstream); } +void test_encode82(void) +{ + QRenc_DataStream *stream; + unsigned char *data; + BitStream *bstream; + char c1[] = "010011111111"; + char c2[] = "010000000010"; + int flag = 0; + + data = (unsigned char *)malloc(257); + memset(data, 0, 257); + testStart("Encoding byte stream. (257 bytes)"); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_8, 257, data); + bstream = QRenc_mergeBitStream(stream); + if(strncmp(c1, bstream->data, 12)) { + flag++; + } + if(strncmp(c2, bstream->data + 12 + 255*8, 12)) { + flag++; + } + testEnd(flag); + QRenc_freeData(stream); + BitStream_free(bstream); + free(data); +} + int main(int argc, char **argv) { test_encodeNumeric(); test_encodeNumeric2(); + test_encode8(); + test_encode82(); test_encodeAn(); test_encodeAn2(); + test_encodeKanji(); report(); diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index 49250b0ce8..bc1217bf30 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -92,17 +92,24 @@ void test_8(void) void test_kanji(void) { + int res; + QRenc_DataStream *stream; - unsigned char str[4]= {0x5f, 0x93, 0xaa, 0xe4}; + unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; int bits; testStart("Estimation of Kanji stream (2 chars)"); stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_KANJI, 4, (unsigned char *)str); - bits = QRenc_estimateBitStreamSize(stream, 0); - testEndExp(bits == 38); + res = QRenc_appendData(stream, QR_MODE_KANJI, 4, (unsigned char *)str); + if(res < 0) { + printf("Failed to add.\n"); + testEnd(1); + } else { + bits = QRenc_estimateBitStreamSize(stream, 0); + testEndExp(bits == 38); + QRenc_appendData(gstream, QR_MODE_KANJI, 4, (unsigned char *)str); + } - QRenc_appendData(gstream, QR_MODE_KANJI, 4, (unsigned char *)str); QRenc_freeData(stream); } -- cgit 0.0.5-2-1-g0f52 From fd5f10970462f9898f6308607d4706ea52a08a95 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 7 Nov 2006 12:42:33 +0000 Subject: --- bitstream.c | 19 +++++++++++- qrencode.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++-- qrtest.h | 2 +- tests/test_datastream.c | 22 ++++++++++++++ 4 files changed, 120 insertions(+), 4 deletions(-) diff --git a/bitstream.c b/bitstream.c index fa30820825..9b6961e4bb 100644 --- a/bitstream.c +++ b/bitstream.c @@ -72,6 +72,8 @@ BitStream *BitStream_newFromBytes(int size, unsigned char *data) char *p; BitStream *bstream; + assert(data != NULL); + bstream = BitStream_new(); bstream->data = (char *)malloc(size * 8 + 1); @@ -98,6 +100,11 @@ void BitStream_append(BitStream *bstream, BitStream *arg) int l1, l2; char *new; + assert(bstream != NULL); + + if(arg == NULL || arg->data == NULL) { + return; + } if(bstream->data == NULL) { bstream->data = strdup(arg->data); return; @@ -117,6 +124,8 @@ void BitStream_appendNum(BitStream *bstream, int bits, unsigned int num) { BitStream *b; + assert(bstream != NULL); + b = BitStream_newFromNum(bits, num); BitStream_append(bstream, b); BitStream_free(b); @@ -126,6 +135,8 @@ void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) { BitStream *b; + assert(bstream != NULL); + b = BitStream_newFromBytes(size, data); BitStream_append(bstream, b); BitStream_free(b); @@ -133,11 +144,17 @@ void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) unsigned int BitStream_size(BitStream *bstream) { + assert(bstream != NULL); + return strlen(bstream->data); } void BitStream_free(BitStream *bstream) { - free(bstream->data); + assert(bstream != NULL); + + if(bstream->data != NULL) { + free(bstream->data); + } free(bstream); } diff --git a/qrencode.c b/qrencode.c index c2f78a4ad6..dbe5db6ffa 100644 --- a/qrencode.c +++ b/qrencode.c @@ -540,7 +540,7 @@ int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version) * @param stream data stream * @return required version number */ -int QRenc_estimateVersion(QRenc_DataStream *stream) +static int QRenc_estimateVersion(QRenc_DataStream *stream) { int bits; int new, prev; @@ -663,12 +663,70 @@ static int QRenc_convertData(QRenc_DataStream *stream) return 0; } +/** + * Create padding bits for the input stream. + * @param stream input data stream. + * @return padding bit stream. + */ +static BitStream *QRenc_createPaddingBit(QRenc_DataStream *stream) +{ + int bits, maxbits, words, maxwords, i; + QRenc_List *list; + BitStream *bstream; + + if(stream->version <= 0) + return NULL; + + maxwords = qrspecCapacity[stream->version].words; + maxbits = maxwords * 8; + + list = stream->head; + bits = 0; + while(list != NULL) { + bits += BitStream_size(list->bstream); + list = list->next; + } + + words = (bits + 7) / 8; + + if(bits == maxbits) + return NULL; + + if(maxbits - bits < 5) { + bstream = BitStream_new(); + BitStream_appendNum(bstream, maxbits - bits, 0); + return bstream; + } + + bstream = BitStream_new(); + BitStream_appendNum(bstream, words * 8 - bits, 0); + + for(i=0; ihead; while(list != NULL) { @@ -678,3 +736,22 @@ BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream) return bstream; } + +/** + * Merge all bit streams in the input data stream and append padding bits + * @param stream input data stream. + * @return padded merged bit stream + */ + +BitStream *QRenc_getBitStream(QRenc_DataStream *stream) +{ + BitStream *bstream; + + bstream = QRenc_mergeBitStream(stream); + if(bstream == NULL) { + return NULL; + } + BitStream_append(bstream, QRenc_createPaddingBit(stream)); + + return bstream; +} diff --git a/qrtest.h b/qrtest.h index ec6524a080..27cbed5ac6 100644 --- a/qrtest.h +++ b/qrtest.h @@ -3,4 +3,4 @@ extern int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); extern BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream); -extern int QRenc_estimateVersion(QRenc_DataStream *stream); +extern BitStream *QRenc_getBitStream(QRenc_DataStream *stream); diff --git a/tests/test_datastream.c b/tests/test_datastream.c index 19f1eba3b0..1db373b6cb 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -88,6 +88,27 @@ void test_encodeNumeric(void) BitStream_free(bstream); } +void test_encodeNumericPadded(void) +{ + QRenc_DataStream *stream; + char num[9] = "01234567"; + char correct[] = "000100000010000000001100010101100110000110000000"; + BitStream *bstream; + int flag; + + testStart("Encoding numeric stream. (8 digits)(padded)"); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + bstream = QRenc_getBitStream(stream); + flag = strncmp(correct, bstream->data, 48); + if(strlen(bstream->data) != 208) + flag++; + testEnd(flag); + + QRenc_freeData(stream); + BitStream_free(bstream); +} + void test_encodeNumeric2(void) { QRenc_DataStream *stream; @@ -142,6 +163,7 @@ int main(int argc, char **argv) test_encodeAn(); test_encodeAn2(); test_encodeKanji(); + test_encodeNumericPadded(); report(); -- cgit 0.0.5-2-1-g0f52 From 879e2018a937841b25b2cfc7e1f83de2a8719608 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 7 Nov 2006 13:58:17 +0000 Subject: --- qrencode.c | 6 +-- qrencode.h | 2 +- qrspec.c | 98 +++++++++++++++++++++++++------------------------ qrspec.h | 15 +++++--- tests/test_datastream.c | 7 ++-- 5 files changed, 68 insertions(+), 60 deletions(-) diff --git a/qrencode.c b/qrencode.c index dbe5db6ffa..1045516330 100644 --- a/qrencode.c +++ b/qrencode.c @@ -549,7 +549,7 @@ static int QRenc_estimateVersion(QRenc_DataStream *stream) do { prev = new; bits = QRenc_estimateBitStreamSize(stream, prev); - new = QRspec_getMinimumVersion((bits + 7) / 8); + new = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); if (new == -1) { return -1; } @@ -650,7 +650,7 @@ static int QRenc_convertData(QRenc_DataStream *stream) for(;;) { bits = QRenc_createBitStream(stream); - ver = QRspec_getMinimumVersion((bits + 7) / 8); + ver = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); if(ver < 0) { return -1; } else if(ver > QRenc_getVersion(stream)) { @@ -677,7 +677,7 @@ static BitStream *QRenc_createPaddingBit(QRenc_DataStream *stream) if(stream->version <= 0) return NULL; - maxwords = qrspecCapacity[stream->version].words; + maxwords = QRspec_getMaximumCodeLength(stream->version, stream->level); maxbits = maxwords * 8; list = stream->head; diff --git a/qrencode.h b/qrencode.h index cdc48a8671..a4e541757d 100644 --- a/qrencode.h +++ b/qrencode.h @@ -53,7 +53,7 @@ typedef struct _QRenc_DataStream QRenc_DataStream; * Level of error correction. */ typedef enum { - QR_EC_LEVEL_L, + QR_EC_LEVEL_L = 0, QR_EC_LEVEL_M, QR_EC_LEVEL_Q, QR_EC_LEVEL_H diff --git a/qrspec.c b/qrspec.c index 642119953d..236019e184 100644 --- a/qrspec.c +++ b/qrspec.c @@ -39,60 +39,62 @@ *****************************************************************************/ QRspec_Capacity qrspecCapacity[QRSPEC_VERSION_MAX + 1] = { - { 0, 0, 0, 0, 0, 0}, - { 21, 26, 7, 10, 13, 17}, // 1 - { 25, 44, 10, 16, 22, 28}, - { 29, 70, 15, 26, 36, 44}, - { 33, 100, 20, 36, 52, 64}, - { 37, 134, 26, 48, 72, 88}, // 5 - { 41, 172, 36, 64, 96, 112}, - { 45, 196, 40, 72, 108, 130}, - { 49, 242, 48, 88, 132, 156}, - { 53, 292, 60, 110, 160, 192}, - { 57, 346, 72, 130, 192, 224}, //10 - { 61, 404, 80, 150, 224, 264}, - { 65, 466, 96, 176, 260, 308}, - { 69, 532, 104, 198, 288, 352}, - { 73, 581, 120, 216, 320, 384}, - { 77, 655, 132, 240, 360, 432}, //15 - { 81, 733, 144, 280, 408, 480}, - { 85, 815, 168, 308, 448, 532}, - { 89, 901, 180, 338, 504, 588}, - { 93, 991, 196, 364, 546, 650}, - { 97, 1085, 224, 416, 600, 700}, //20 - {101, 1156, 224, 442, 644, 750}, - {105, 1258, 252, 476, 690, 816}, - {109, 1364, 280, 504, 750, 900}, - {113, 1474, 300, 560, 810, 960}, - {117, 1588, 312, 588, 870, 1050}, //25 - {121, 1706, 336, 644, 952, 1110}, - {125, 1828, 360, 700, 1020, 1200}, - {129, 1921, 390, 728, 1050, 1260}, - {133, 2051, 420, 784, 1140, 1350}, - {137, 2185, 450, 812, 1200, 1440}, //30 - {141, 2323, 480, 868, 1290, 1530}, - {145, 2465, 510, 924, 1350, 1620}, - {149, 2611, 540, 980, 1440, 1710}, - {153, 2761, 570, 1036, 1530, 1800}, - {157, 2876, 570, 1064, 1590, 1890}, //35 - {161, 3034, 600, 1120, 1680, 1980}, - {165, 3196, 630, 1204, 1770, 2100}, - {169, 3362, 660, 1260, 1860, 2220}, - {173, 3532, 720, 1316, 1950, 2310}, - {177, 3706, 750, 1372, 2040, 2430} //40 + { 0, 0, { 0, 0, 0, 0}}, + { 21, 26, { 7, 10, 13, 17}}, // 1 + { 25, 44, { 10, 16, 22, 28}}, + { 29, 70, { 15, 26, 36, 44}}, + { 33, 100, { 20, 36, 52, 64}}, + { 37, 134, { 26, 48, 72, 88}}, // 5 + { 41, 172, { 36, 64, 96, 112}}, + { 45, 196, { 40, 72, 108, 130}}, + { 49, 242, { 48, 88, 132, 156}}, + { 53, 292, { 60, 110, 160, 192}}, + { 57, 346, { 72, 130, 192, 224}}, //10 + { 61, 404, { 80, 150, 224, 264}}, + { 65, 466, { 96, 176, 260, 308}}, + { 69, 532, { 104, 198, 288, 352}}, + { 73, 581, { 120, 216, 320, 384}}, + { 77, 655, { 132, 240, 360, 432}}, //15 + { 81, 733, { 144, 280, 408, 480}}, + { 85, 815, { 168, 308, 448, 532}}, + { 89, 901, { 180, 338, 504, 588}}, + { 93, 991, { 196, 364, 546, 650}}, + { 97, 1085, { 224, 416, 600, 700}}, //20 + {101, 1156, { 224, 442, 644, 750}}, + {105, 1258, { 252, 476, 690, 816}}, + {109, 1364, { 280, 504, 750, 900}}, + {113, 1474, { 300, 560, 810, 960}}, + {117, 1588, { 312, 588, 870, 1050}}, //25 + {121, 1706, { 336, 644, 952, 1110}}, + {125, 1828, { 360, 700, 1020, 1200}}, + {129, 1921, { 390, 728, 1050, 1260}}, + {133, 2051, { 420, 784, 1140, 1350}}, + {137, 2185, { 450, 812, 1200, 1440}}, //30 + {141, 2323, { 480, 868, 1290, 1530}}, + {145, 2465, { 510, 924, 1350, 1620}}, + {149, 2611, { 540, 980, 1440, 1710}}, + {153, 2761, { 570, 1036, 1530, 1800}}, + {157, 2876, { 570, 1064, 1590, 1890}}, //35 + {161, 3034, { 600, 1120, 1680, 1980}}, + {165, 3196, { 630, 1204, 1770, 2100}}, + {169, 3362, { 660, 1260, 1860, 2220}}, + {173, 3532, { 720, 1316, 1950, 2310}}, + {177, 3706, { 750, 1372, 2040, 2430}} //40 }; -/** - * Return a version number that satisfies the input code length. - * @param size input code length (byte) - * @return version number - */ -int QRspec_getMinimumVersion(int size) +int QRspec_getMaximumCodeLength(int version, QRenc_ErrorCorrectionLevel level) +{ + return qrspecCapacity[version].words - qrspecCapacity[version].ec[level]; +} + +int QRspec_getMinimumVersion(int size, QRenc_ErrorCorrectionLevel level) { int i; + int words; for(i=1; i<= QRSPEC_VERSION_MAX; i++) { - if(qrspecCapacity[i].words >= size) return i; + words = qrspecCapacity[i].words; - qrspecCapacity[i].ec[level]; + if(words >= size) return i; } return -1; diff --git a/qrspec.h b/qrspec.h index 4eada1f962..428dd1cb96 100644 --- a/qrspec.h +++ b/qrspec.h @@ -36,20 +36,25 @@ typedef struct { int length; //< Edge length of the symbol int words; //< Data capacity (bytes) - int rsL; - int rsM; - int rsH; - int rsQ; + int ec[4]; } QRspec_Capacity; extern QRspec_Capacity qrspecCapacity[]; +/** + * Return maximum data code length (bytes) for the version. + * @param version + * @param level + * @return maximum size (bytes) + */ +extern int QRspec_getMaximumCodeLength(int version, QRenc_ErrorCorrectionLevel level); + /** * Return a version number that satisfies the input code length. * @param size input code length (byte) * @return version number */ -extern int QRspec_getMinimumVersion(int size); +extern int QRspec_getMinimumVersion(int size, QRenc_ErrorCorrectionLevel level); /****************************************************************************** * Length indicator diff --git a/tests/test_datastream.c b/tests/test_datastream.c index 1db373b6cb..9d4152cbfd 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -101,8 +101,9 @@ void test_encodeNumericPadded(void) QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); bstream = QRenc_getBitStream(stream); flag = strncmp(correct, bstream->data, 48); - if(strlen(bstream->data) != 208) - flag++; + printf("%s\n", bstream->data); + if(strlen(bstream->data) != 19 * 8) + flag |= 0x80; testEnd(flag); QRenc_freeData(stream); @@ -159,7 +160,7 @@ int main(int argc, char **argv) test_encodeNumeric(); test_encodeNumeric2(); test_encode8(); - test_encode82(); +// test_encode82(); test_encodeAn(); test_encodeAn2(); test_encodeKanji(); -- cgit 0.0.5-2-1-g0f52 From 3d7b35c16e7360979868ba472b6c0e6d2d3561f8 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 10 Nov 2006 15:19:46 +0000 Subject: --- Makefile.am | 4 +- bitstream.c | 42 ++++++- bitstream.h | 8 +- qrencode.c | 12 +- qrencode.h | 3 - qrspec.c | 102 +++++++++++++++-- qrspec.h | 8 +- qrtest.h | 2 + rscode.c | 295 +++++++++++++++++++++++++++++++++++++++++++++++++ rscode.h | 41 +++++++ tests/Makefile.am | 6 +- tests/test_bitstream.c | 20 ++++ tests/test_qrspec.c | 43 +++++++ 13 files changed, 552 insertions(+), 34 deletions(-) create mode 100644 rscode.c create mode 100644 rscode.h create mode 100644 tests/test_qrspec.c diff --git a/Makefile.am b/Makefile.am index 31c9266ee3..044c2894c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,8 +4,8 @@ SUBDIRS = . tests lib_LTLIBRARIES = libqrencode.la -libqrencode_la_SOURCES = qrencode.c bitstream.c qrspec.c -libqrencode_la_headers = qrencode.h bitstream.h qrspec.h +libqrencode_la_SOURCES = qrencode.c bitstream.c qrspec.c rscode.c +libqrencode_la_headers = qrencode.h bitstream.h qrspec.h rscode.h libqrencode_la_LDFLAGS = -version-info $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) pkginclude_HEADERS = qrencode.h diff --git a/bitstream.c b/bitstream.c index 9b6961e4bb..82493b328c 100644 --- a/bitstream.c +++ b/bitstream.c @@ -1,11 +1,8 @@ /* * qrencode - QR-code encoder * - * Originally written by Y.Swetake - * Copyright (c)2003-2005 Y.Swetake - * - * Ported to C and modified by Kentaro Fukuchi - * Copyright (c) 2006 Kentaro Fukuchi + * Binary sequence class. + * Copyright (C) 2006 Kentaro Fukuchi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -158,3 +155,38 @@ void BitStream_free(BitStream *bstream) } free(bstream); } + +unsigned char *BitStream_toByte(BitStream *bstream) +{ + int i, j, size, bytes; + unsigned char *data, v; + char *p; + + assert(bstream != NULL); + + size = BitStream_size(bstream); + data = (unsigned char *)malloc((size + 7) / 8); + bytes = size / 8; + + p = bstream->data; + for(i=0; i= size) return i; } @@ -148,3 +153,86 @@ int QRspec_maximumWords(QRenc_EncodeMode mode, int version) return words; } + +/****************************************************************************** + * Error correction code + *****************************************************************************/ + +/** + * Table of the error correction code (Reed-Solomon block) + * See Table 12-16 (pp.30-36), JIS X0510:2004. + */ +static int eccTable[QRSPEC_VERSION_MAX+1][4][2] = { + {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}}, + {{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}}, // 1 + {{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}}, + {{ 1, 0}, { 1, 0}, { 2, 0}, { 2, 0}}, + {{ 1, 0}, { 2, 0}, { 2, 0}, { 4, 0}}, + {{ 1, 0}, { 2, 0}, { 2, 2}, { 2, 2}}, // 5 + {{ 2, 0}, { 4, 0}, { 4, 0}, { 4, 0}}, + {{ 2, 0}, { 4, 0}, { 2, 4}, { 4, 1}}, + {{ 2, 0}, { 2, 2}, { 4, 2}, { 4, 2}}, + {{ 2, 0}, { 3, 2}, { 4, 4}, { 4, 4}}, + {{ 2, 2}, { 4, 1}, { 6, 2}, { 6, 2}}, //10 + {{ 4, 0}, { 1, 4}, { 4, 4}, { 3, 8}}, + {{ 2, 2}, { 6, 2}, { 4, 6}, { 7, 4}}, + {{ 4, 0}, { 8, 1}, { 8, 4}, {12, 4}}, + {{ 3, 1}, { 4, 5}, {11, 5}, {11, 5}}, + {{ 5, 1}, { 5, 5}, { 5, 7}, {11, 7}}, //15 + {{ 5, 1}, { 7, 3}, {15, 2}, { 3, 13}}, + {{ 1, 5}, {10, 1}, { 1, 15}, { 2, 17}}, + {{ 5, 1}, { 9, 4}, {17, 1}, { 2, 19}}, + {{ 3, 4}, { 3, 11}, {17, 4}, { 9, 16}}, + {{ 3, 5}, { 3, 13}, {15, 5}, {15, 10}}, //20 + {{ 4, 4}, {17, 0}, {17, 6}, {19, 6}}, + {{ 2, 7}, {17, 0}, { 7, 16}, {34, 0}}, + {{ 4, 5}, { 4, 14}, {11, 14}, {16, 14}}, + {{ 6, 4}, { 6, 14}, {11, 16}, {30, 2}}, + {{ 8, 4}, { 8, 13}, { 7, 22}, {22, 13}}, //25 + {{10, 2}, {19, 4}, {28, 6}, {33, 4}}, + {{ 8, 4}, {22, 3}, { 8, 26}, {12, 28}}, + {{ 3, 10}, { 3, 23}, { 4, 31}, {11, 31}}, + {{ 7, 7}, {21, 7}, { 1, 37}, {19, 26}}, + {{ 5, 10}, {19, 10}, {15, 25}, {23, 25}}, //30 + {{13, 3}, { 2, 29}, {42, 1}, {23, 28}}, + {{17, 0}, {10, 23}, {10, 35}, {19, 35}}, + {{17, 1}, {14, 21}, {29, 19}, {11, 46}}, + {{13, 6}, {14, 23}, {44, 7}, {59, 1}}, + {{12, 7}, {12, 26}, {39, 14}, {22, 41}}, //35 + {{ 6, 14}, { 6, 34}, {46, 10}, { 2, 64}}, + {{17, 4}, {29, 14}, {49, 10}, {24, 46}}, + {{ 4, 18}, {13, 32}, {48, 14}, {42, 32}}, + {{20, 4}, {40, 7}, {43, 22}, {10, 67}}, + {{19, 6}, {18, 31}, {34, 34}, {20, 61}},//40 +}; + +int *QRspec_getEccBlockNum(int version, QRenc_ErrorCorrectionLevel level) +{ + int b1, b2; + int data, ecc; + int *array; + + b1 = eccTable[version][level][0]; + b2 = eccTable[version][level][1]; + + data = QRspec_getMaximumCodeLength(version, level); + ecc = QRspec_getECCLength(version, level); + + array = (int *)malloc(sizeof(int) * 6); + + if(b2 == 0) { + array[0] = b1; + array[1] = data / b1; + array[2] = ecc / b1; + array[3] = array[4] = array[5] = 0; + } else { + array[0] = b1; + array[1] = data / (b1 + b2); + array[2] = ecc / (b1 + b2); + array[3] = b2; + array[4] = array[1] + 1; + array[5] = (ecc - (array[2] * b1)) / b2; + } + + return array; +} diff --git a/qrspec.h b/qrspec.h index 428dd1cb96..be86f00e59 100644 --- a/qrspec.h +++ b/qrspec.h @@ -1,11 +1,7 @@ /* * qrencode - QR-code encoder * - * Originally written by Y.Swetake - * Copyright (c)2003-2005 Y.Swetake - * - * Ported to C and modified by Kentaro Fukuchi - * Copyright (c) 2006 Kentaro Fukuchi + * Copyright (C) 2006 Kentaro Fukuchi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,7 +68,7 @@ extern int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version); * Return the maximum length for the mode and version. * @param mode * @param version - * @return the maximum length (words) + * @return the maximum length (bytes) */ extern int QRspec_maximumWords(QRenc_EncodeMode mode, int version); diff --git a/qrtest.h b/qrtest.h index 27cbed5ac6..9c826541df 100644 --- a/qrtest.h +++ b/qrtest.h @@ -4,3 +4,5 @@ extern int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); extern BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream); extern BitStream *QRenc_getBitStream(QRenc_DataStream *stream); + +extern int *QRspec_getEccBlockNum(int version, QRenc_ErrorCorrectionLevel level); diff --git a/rscode.c b/rscode.c new file mode 100644 index 0000000000..58c1eb9bf7 --- /dev/null +++ b/rscode.c @@ -0,0 +1,295 @@ +/* + * qrencode - QR-code encoder + * + * Reed solomon encoder. This file is taken from Phil Karn's libfec and + * editted and packed into a pair of .c and .h files. + * + * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q + * (libfec is released under the GNU Lesser General Public License.) + * + * Copyright (C) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include "rscode.h" + +/* Stuff specific to the 8-bit symbol version of the general purpose RS codecs + * + */ +typedef unsigned char data_t; + + +/** + * Reed-Solomon codec control block + */ +struct _RS { + int mm; /* Bits per symbol */ + int nn; /* Symbols per block (= (1<= rs->nn) { + x -= rs->nn; + x = (x >> rs->mm) + (x & rs->nn); + } + return x; +} + + +#define MODNN(x) modnn(rs,x) + +#define MM (rs->mm) +#define NN (rs->nn) +#define ALPHA_TO (rs->alpha_to) +#define INDEX_OF (rs->index_of) +#define GENPOLY (rs->genpoly) +#define NROOTS (rs->nroots) +#define FCR (rs->fcr) +#define PRIM (rs->prim) +#define IPRIM (rs->iprim) +#define PAD (rs->pad) +#define A0 (NN) + + +/* Initialize a Reed-Solomon codec + * symsize = symbol size, bits + * gfpoly = Field generator polynomial coefficients + * fcr = first root of RS code generator polynomial, index form + * prim = primitive element to generate polynomial roots + * nroots = RS code generator polynomial degree (number of roots) + * pad = padding bytes at front of shortened block + */ +RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) +{ + RS *rs; + + +/* Common code for intializing a Reed-Solomon control block (char or int symbols) + * Copyright 2004 Phil Karn, KA9Q + * May be used under the terms of the GNU Lesser General Public License (LGPL) + */ +#undef NULL +#define NULL ((void *)0) + + int i, j, sr,root,iprim; + + rs = NULL; + /* Check parameter ranges */ + if(symsize < 0 || symsize > 8*sizeof(data_t)){ + goto done; + } + + if(fcr < 0 || fcr >= (1<= (1<= (1<= ((1<mm = symsize; + rs->nn = (1<pad = pad; + + rs->alpha_to = (data_t *)malloc(sizeof(data_t)*(rs->nn+1)); + if(rs->alpha_to == NULL){ + free(rs); + rs = NULL; + goto done; + } + rs->index_of = (data_t *)malloc(sizeof(data_t)*(rs->nn+1)); + if(rs->index_of == NULL){ + free(rs->alpha_to); + free(rs); + rs = NULL; + goto done; + } + + /* Generate Galois field lookup tables */ + rs->index_of[0] = A0; /* log(zero) = -inf */ + rs->alpha_to[A0] = 0; /* alpha**-inf = 0 */ + sr = 1; + for(i=0;inn;i++){ + rs->index_of[sr] = i; + rs->alpha_to[i] = sr; + sr <<= 1; + if(sr & (1<nn; + } + if(sr != 1){ + /* field generator polynomial is not primitive! */ + free(rs->alpha_to); + free(rs->index_of); + free(rs); + rs = NULL; + goto done; + } + + /* Form RS code generator polynomial from its roots */ + rs->genpoly = (data_t *)malloc(sizeof(data_t)*(nroots+1)); + if(rs->genpoly == NULL){ + free(rs->alpha_to); + free(rs->index_of); + free(rs); + rs = NULL; + goto done; + } + rs->fcr = fcr; + rs->prim = prim; + rs->nroots = nroots; + + /* Find prim-th root of 1, used in decoding */ + for(iprim=1;(iprim % prim) != 0;iprim += rs->nn) + ; + rs->iprim = iprim / prim; + + rs->genpoly[0] = 1; + for (i = 0,root=fcr*prim; i < nroots; i++,root += prim) { + rs->genpoly[i+1] = 1; + + /* Multiply rs->genpoly[] by @**(root + x) */ + for (j = i; j > 0; j--){ + if (rs->genpoly[j] != 0) + rs->genpoly[j] = rs->genpoly[j-1] ^ rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[j]] + root)]; + else + rs->genpoly[j] = rs->genpoly[j-1]; + } + /* rs->genpoly[0] can never be zero */ + rs->genpoly[0] = rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[0]] + root)]; + } + /* convert rs->genpoly[] to index form for quicker encoding */ + for (i = 0; i <= nroots; i++) + rs->genpoly[i] = rs->index_of[rs->genpoly[i]]; + done:; + + return rs; +} + +RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) +{ + RS *rs; + + for(rs = rslist; rs != NULL; rs = rs->next) { + if(rs->mm != symsize) continue; + if(rs->gfpoly != gfpoly) continue; + if(rs->fcr != fcr) continue; + if(rs->prim != prim) continue; + if(rs->nroots != nroots) continue; + if(rs->pad != pad) continue; + + rs->refcount++; + return rs; + } + + rs = init_rs_char(symsize, gfpoly, fcr, prim, nroots, pad); + if(rslist == NULL) { + rslist = rs; + } else { + rs->next = rslist; + rslist = rs; + } + + return rs; +} + + +void free_rs_char(RS *rs) +{ + free(rs->alpha_to); + free(rs->index_of); + free(rs->genpoly); + free(rs); +} + +/* The guts of the Reed-Solomon encoder, meant to be #included + * into a function body with the following typedefs, macros and variables supplied + * according to the code parameters: + + * data_t - a typedef for the data symbol + * data_t data[] - array of NN-NROOTS-PAD and type data_t to be encoded + * data_t parity[] - an array of NROOTS and type data_t to be written with parity symbols + * NROOTS - the number of roots in the RS code generator polynomial, + * which is the same as the number of parity symbols in a block. + Integer variable or literal. + * + * NN - the total number of symbols in a RS block. Integer variable or literal. + * PAD - the number of pad symbols in a block. Integer variable or literal. + * ALPHA_TO - The address of an array of NN elements to convert Galois field + * elements in index (log) form to polynomial form. Read only. + * INDEX_OF - The address of an array of NN elements to convert Galois field + * elements in polynomial form to index (log) form. Read only. + * MODNN - a function to reduce its argument modulo NN. May be inline or a macro. + * GENPOLY - an array of NROOTS+1 elements containing the generator polynomial in index form + + * The memset() and memmove() functions are used. The appropriate header + * file declaring these functions (usually ) must be included by the calling + * program. + + * Copyright 2004, Phil Karn, KA9Q + * May be used under the terms of the GNU Lesser General Public License (LGPL) + */ + +#undef A0 +#define A0 (NN) /* Special reserved value encoding zero in index form */ + +void encode_rs_char(RS *rs, data_t *data, data_t *parity) +{ + int i, j; + data_t feedback; + + memset(parity,0,NROOTS*sizeof(data_t)); + + for(i=0;i +#include +#include "common.h" +#include "../qrspec.h" +#include "../qrtest.h" + +void test_eccTable(void) +{ + int i, j; + int ecc; + int data; + int err = 0; + int *bl; + + testStart("Checking ECC table."); + for(i=1; i Date: Fri, 10 Nov 2006 17:05:02 +0000 Subject: --- tests/test_qrspec.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 5643391147..2540115831 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -4,6 +4,31 @@ #include "../qrspec.h" #include "../qrtest.h" +void print_eccTable(void) +{ + int i, j; + int ecc; + int data; + int *bl; + + for(i=1; i<=QRSPEC_VERSION_MAX; i++) { + printf("Version %2d\n", i); + for(j=0; j<4; j++) { + bl = QRspec_getEccBlockNum(i, j); + data = bl[0] * bl[1] + bl[3] * bl[4]; + ecc = bl[0] * bl[2] + bl[3] * bl[5]; + printf("%3d\t", ecc); + printf("%2d\t", bl[0]); + printf("(%3d, %3d)\n", bl[1]+bl[2], bl[1]); + if(bl[3]>0) { + printf("\t%2d\t", bl[3]); + printf("(%3d, %3d)\n", bl[4]+bl[5], bl[4]); + } + free(bl); + } + } +} + void test_eccTable(void) { int i, j; @@ -13,7 +38,7 @@ void test_eccTable(void) int *bl; testStart("Checking ECC table."); - for(i=1; i Date: Fri, 10 Nov 2006 17:21:43 +0000 Subject: --- Makefile.am | 4 +- datastream.c | 772 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ datastream.h | 34 +++ qrencode.c | 734 +------------------------------------------------------- qrencode.h | 2 - 5 files changed, 810 insertions(+), 736 deletions(-) create mode 100644 datastream.c create mode 100644 datastream.h diff --git a/Makefile.am b/Makefile.am index 044c2894c9..04d3ea0287 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,8 +4,8 @@ SUBDIRS = . tests lib_LTLIBRARIES = libqrencode.la -libqrencode_la_SOURCES = qrencode.c bitstream.c qrspec.c rscode.c -libqrencode_la_headers = qrencode.h bitstream.h qrspec.h rscode.h +libqrencode_la_SOURCES = qrencode.c datastream.c bitstream.c qrspec.c rscode.c +libqrencode_la_headers = qrencode.h datastream.h bitstream.h qrspec.h rscode.h libqrencode_la_LDFLAGS = -version-info $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) pkginclude_HEADERS = qrencode.h diff --git a/datastream.c b/datastream.c new file mode 100644 index 0000000000..6174111caf --- /dev/null +++ b/datastream.c @@ -0,0 +1,772 @@ +/* + * qrencode - QR-code encoder + * + * Copyright (C) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include + +#include "qrencode.h" +#include "qrspec.h" +#include "bitstream.h" +#include "datastream.h" + +/****************************************************************************** + * Entry of input data stream + *****************************************************************************/ + +typedef struct _QRenc_List QRenc_List; +struct _QRenc_List { + QRenc_EncodeMode mode; + int size; ///< Size of data chunk (byte). + unsigned char *data; ///< Data chunk. + BitStream *bstream; + QRenc_List *next; +}; + +static QRenc_List *QRenc_newEntry(QRenc_EncodeMode mode, int size, unsigned char *data) +{ + QRenc_List *entry; + + if(QRenc_checkData(mode, size, data)) { + return NULL; + } + + entry = (QRenc_List *)malloc(sizeof(QRenc_List)); + entry->mode = mode; + entry->size = size; + entry->data = (unsigned char *)malloc(size); + memcpy(entry->data, data, size); + entry->bstream = NULL; + entry->next = NULL; + + return entry; +} + +static QRenc_List *QRenc_freeEntry(QRenc_List *entry) +{ + QRenc_List *next; + + next = entry->next; + free(entry->data); + if(entry->bstream) { + BitStream_free(entry->bstream); + } + free(entry); + + return next; +} + +/****************************************************************************** + * Input Data stream + *****************************************************************************/ + +struct _QRenc_DataStream { + int version; + QRenc_ErrorCorrectionLevel level; + QRenc_List *head; + QRenc_List *tail; +}; + +int QRenc_getVersion(QRenc_DataStream *stream) +{ + return stream->version; +} + +void QRenc_setVersion(QRenc_DataStream *stream, int v) +{ + stream->version = v; +} + +void QRenc_setErrorCorrectionLevel(QRenc_DataStream *stream, QRenc_ErrorCorrectionLevel level) +{ + stream->level = level; +} + +QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(QRenc_DataStream *stream) +{ + return stream->level; +} + +QRenc_DataStream *QRenc_newData(void) +{ + QRenc_DataStream *stream; + + stream = (QRenc_DataStream *)malloc(sizeof(QRenc_DataStream)); + stream->head = NULL; + stream->tail = NULL; + stream->version = 0; + stream->level = QR_EC_LEVEL_L; + + return stream; +} + +int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, unsigned char *data) +{ + QRenc_List *entry; + + entry = QRenc_newEntry(mode, size, data); + if(entry == NULL) { + return -1; + } + + if(stream->tail == NULL) { + stream->head = entry; + stream->tail = entry; + } else { + stream->tail->next = entry; + stream->tail = entry; + } + + return 0; +} + +void QRenc_freeData(QRenc_DataStream *stream) +{ + QRenc_List *list; + + list = stream->head; + while(list != NULL) { + list = QRenc_freeEntry(list); + } + + free(stream); +} + +/****************************************************************************** + * Numeric data + *****************************************************************************/ + +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeNum(int size, const char *data) +{ + int i; + + for(i=0; i '9') + return -1; + } + + return 0; +} + +/** + * Estimates the length of the encoded bit stream of numeric data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsModeNum(QRenc_List *entry) +{ + int w; + int bits; + + w = entry->size / 3; + bits = w * 10; + switch(entry->size - w * 3) { + case 1: + bits += 4; + break; + case 2: + bits += 7; + break; + default: + break; + } + + return bits; +} + +/** + * Convert the number data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeModeNum(QRenc_List *entry, int version) +{ + int words; + int i; + unsigned int val; + + words = entry->size / 3; + entry->bstream = BitStream_new(); + + val = 0x1; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val); + + for(i=0; idata[i*3 ] - '0') * 100; + val += (entry->data[i*3+1] - '0') * 10; + val += (entry->data[i*3+2] - '0'); + + BitStream_appendNum(entry->bstream, 10, val); + } + + if(entry->size - words * 3 == 1) { + val = entry->data[words*3] - '0'; + BitStream_appendNum(entry->bstream, 4, val); + } else if(entry->size - words * 3 == 2) { + val = (entry->data[words*3 ] - '0') * 10; + val += (entry->data[words*3+1] - '0'); + BitStream_appendNum(entry->bstream, 7, val); + } +} + +/****************************************************************************** + * Alphabet-numeric data + *****************************************************************************/ + +static signed char anTable[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1 +}; + +/** + * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). + * @param c character + * @return value + */ +inline static signed char QRenc_lookAnTable(char c) +{ + if(c & 0x80) { + return -1; + } + return anTable[(int)c]; +} + +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeAn(int size, const char *data) +{ + int i; + + for(i=0; isize / 2; + bits = w * 11; + if(entry->size & 1) { + bits += 6; + } + + return bits; +} + +/** + * Convert the alphabet-numeric data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeModeAn(QRenc_List *entry, int version) +{ + int words; + int i; + unsigned int val; + + words = entry->size / 2; + entry->bstream = BitStream_new(); + + val = 0x2; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), val); + + for(i=0; idata[i*2 ]) * 45; + val += (unsigned int)QRenc_lookAnTable(entry->data[i*2+1]); + + BitStream_appendNum(entry->bstream, 11, val); + } + + if(entry->size & 1) { + val = (unsigned int)QRenc_lookAnTable(entry->data[words * 2]); + + BitStream_appendNum(entry->bstream, 6, val); + } +} + +/****************************************************************************** + * 8 bit data + *****************************************************************************/ + +/** + * Estimates the length of the encoded bit stream of 8 bit data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsMode8(QRenc_List *entry) +{ + return entry->size * 8; +} + +/** + * Convert the 8bits data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeMode8(QRenc_List *entry, int version) +{ + int i; + unsigned int val; + + entry->bstream = BitStream_new(); + + val = 0x4; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), val); + + for(i=0; isize; i++) { + BitStream_appendNum(entry->bstream, 8, entry->data[i]); + } +} + + +/****************************************************************************** + * Kanji data + *****************************************************************************/ + +/** + * Estimates the length of the encoded bit stream of kanji data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsModeKanji(QRenc_List *entry) +{ + return (entry->size / 2) * 13; +} + +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeKanji(int size, const unsigned char *data) +{ + int i; + unsigned int val; + + if(size & 1) + return -1; + + for(i=0; i 0x9ffc && val < 0xe040) || val > 0xebbf) { + return -1; + } + } + + return 0; +} + +/** + * Convert the kanji data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeModeKanji(QRenc_List *entry, int version) +{ + int i; + unsigned int val, h; + + entry->bstream = BitStream_new(); + + val = 0x8; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size / 2; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), val); + + for(i=0; isize; i+=2) { + val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1]; + if(val <= 0x9ffc) { + val -= 0x8140; + } else { + val -= 0xc140; + } + h = (val >> 8) * 0xc0; + val = (val & 0xff) + h; + + BitStream_appendNum(entry->bstream, 13, val); + } +} + +/****************************************************************************** + * Validation + *****************************************************************************/ + +/** + * Validate the input data + * @param mode + * @param size + * @param data + * @return result + */ +int QRenc_checkData(QRenc_EncodeMode mode, int size, const unsigned char *data) +{ + switch(mode) { + case QR_MODE_NUM: + return QRenc_checkModeNum(size, (const char *)data); + break; + case QR_MODE_AN: + return QRenc_checkModeAn(size, (const char *)data); + break; + case QR_MODE_KANJI: + return QRenc_checkModeKanji(size, data); + break; + default: + break; + } + + return 0; +} + +/****************************************************************************** + * Estimation of the bit length + *****************************************************************************/ + +/** + * Estimates the length of the encoded bit stream on the current version. + * @param entry + * @param version version of the symbol + * @return number of bits + */ +static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) +{ + int bits = 0; + int l, m; + int num; + + assert(entry != NULL); + switch(entry->mode) { + case QR_MODE_NUM: + bits = QRenc_estimateBitsModeNum(entry); + break; + case QR_MODE_AN: + bits = QRenc_estimateBitsModeAn(entry); + break; + case QR_MODE_8: + bits = QRenc_estimateBitsMode8(entry); + break; + case QR_MODE_KANJI: + bits = QRenc_estimateBitsModeKanji(entry); + break; + } + + l = QRspec_lengthIndicator(entry->mode, version); + m = 1 << l; + num = (bits + m - 1) / m; + + bits += num * (4 + l); // mode indicator (4bits) + length indicator + + return bits; +} + +/** + * Estimates the length of the encoded bit stream of the data stream. + * @param stream data stream + * @param version version of the symbol + * @return number of bits + */ +int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version) +{ + QRenc_List *list; + int bits = 0; + + assert(stream != NULL); + + list = stream->head; + while(list != NULL) { + bits += QRenc_estimateBitStreamSizeOfEntry(list, version); + list = list->next; + } + + return bits; +} + +/** + * Estimates the required version number of the symbol. + * @param stream data stream + * @return required version number + */ +static int QRenc_estimateVersion(QRenc_DataStream *stream) +{ + int bits; + int new, prev; + + new = 0; + do { + prev = new; + bits = QRenc_estimateBitStreamSize(stream, prev); + new = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); + if (new == -1) { + return -1; + } + } while (new > prev); + + return new; +} + +/****************************************************************************** + * Data conversion + *****************************************************************************/ + +/** + * Convert the data stream in the data chunk to a bit stream. + * @param entry + * @return number of bits + */ +static int QRenc_encodeBitStream(QRenc_List *entry, int version) +{ + int words; + QRenc_List *st1, *st2; + + assert(entry != NULL); + + if(entry->bstream != NULL) { + BitStream_free(entry->bstream); + entry->bstream = NULL; + } + + words = QRspec_maximumWords(entry->mode, version); + if(entry->size > words) { + st1 = QRenc_newEntry(entry->mode, words, entry->data); + st2 = QRenc_newEntry(entry->mode, entry->size - words, &entry->data[words]); + QRenc_encodeBitStream(st1, version); + QRenc_encodeBitStream(st2, version); + entry->bstream = BitStream_new(); + BitStream_append(entry->bstream, st1->bstream); + BitStream_append(entry->bstream, st2->bstream); + QRenc_freeEntry(st1); + QRenc_freeEntry(st2); + } else { + switch(entry->mode) { + case QR_MODE_NUM: + QRenc_encodeModeNum(entry, version); + break; + case QR_MODE_AN: + QRenc_encodeModeAn(entry, version); + break; + case QR_MODE_8: + QRenc_encodeMode8(entry, version); + break; + case QR_MODE_KANJI: + QRenc_encodeModeKanji(entry, version); + break; + default: + break; + } + } + + return BitStream_size(entry->bstream); +} + +/** + * Convert the input data stream to a bit stream. + * @param stream input data stream. + * @return length of the bit stream. + */ +static int QRenc_createBitStream(QRenc_DataStream *stream) +{ + QRenc_List *list; + int bits = 0; + + assert(stream != NULL); + + list = stream->head; + while(list != NULL) { + bits += QRenc_encodeBitStream(list, stream->version); + list = list->next; + } + + return bits; +} + +/** + * Convert the input data stream to a bit stream. + * When the version number is given and that is not sufficient, it is increased + * automatically. + * @param stream input data stream. + * @return -1 if the input data was too large. Otherwise 0. + */ +static int QRenc_convertData(QRenc_DataStream *stream) +{ + int bits; + int ver; + + ver = QRenc_estimateVersion(stream); + QRenc_setVersion(stream, ver); + + for(;;) { + bits = QRenc_createBitStream(stream); + ver = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); + if(ver < 0) { + return -1; + } else if(ver > QRenc_getVersion(stream)) { + QRenc_setVersion(stream, ver); + } else { + break; + } + } + + return 0; +} + +/** + * Create padding bits for the input stream. + * @param stream input data stream. + * @return padding bit stream. + */ +static BitStream *QRenc_createPaddingBit(QRenc_DataStream *stream) +{ + int bits, maxbits, words, maxwords, i; + QRenc_List *list; + BitStream *bstream; + + if(stream->version <= 0) + return NULL; + + maxwords = QRspec_getMaximumCodeLength(stream->version, stream->level); + maxbits = maxwords * 8; + + list = stream->head; + bits = 0; + while(list != NULL) { + bits += BitStream_size(list->bstream); + list = list->next; + } + + words = (bits + 7) / 8; + + if(bits == maxbits) + return NULL; + + if(maxbits - bits < 5) { + bstream = BitStream_new(); + BitStream_appendNum(bstream, maxbits - bits, 0); + return bstream; + } + + bstream = BitStream_new(); + BitStream_appendNum(bstream, words * 8 - bits, 0); + + for(i=0; ihead; + while(list != NULL) { + BitStream_append(bstream, list->bstream); + list = list->next; + } + + return bstream; +} + +/** + * Merge all bit streams in the input data stream and append padding bits + * @param stream input data stream. + * @return padded merged bit stream + */ + +BitStream *QRenc_getBitStream(QRenc_DataStream *stream) +{ + BitStream *bstream; + + bstream = QRenc_mergeBitStream(stream); + if(bstream == NULL) { + return NULL; + } + BitStream_append(bstream, QRenc_createPaddingBit(stream)); + + return bstream; +} + +/** + * Pack all bit streams padding bits into a byte array. + * @param stream input data stream. + * @return padded merged byte stream + */ + +unsigned char *QRenc_getByteStream(QRenc_DataStream *stream) +{ + BitStream *bstream; + unsigned char *array; + + bstream = QRenc_getBitStream(stream); + array = BitStream_toByte(bstream); + BitStream_free(bstream); + + return array; +} diff --git a/datastream.h b/datastream.h new file mode 100644 index 0000000000..58ecdf9ca2 --- /dev/null +++ b/datastream.h @@ -0,0 +1,34 @@ +/* + * qrencode - QR-code encoder + * + * Copyright (C) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __DATASTREAM_H__ +#define __DATASTREAM_H__ + +#include "qrencode.h" +#include "bitstream.h" + +/** + * Pack all bit streams padding bits into a byte array. + * @param stream input data stream. + * @return padded merged byte stream + */ +extern unsigned char *QRenc_getByteStream(QRenc_DataStream *stream); + +#endif /* __DATASTREAM_H__ */ diff --git a/qrencode.c b/qrencode.c index 498e744769..59fcecc84a 100644 --- a/qrencode.c +++ b/qrencode.c @@ -1,4 +1,4 @@ -/* +/** * qrencode - QR-code encoder * * Copyright (C) 2006 Kentaro Fukuchi @@ -26,734 +26,4 @@ #include "qrencode.h" #include "qrspec.h" #include "bitstream.h" - -/****************************************************************************** - * Entry of input data stream - *****************************************************************************/ - -typedef struct _QRenc_List QRenc_List; -struct _QRenc_List { - QRenc_EncodeMode mode; - int size; ///< Size of data chunk (byte). - unsigned char *data; ///< Data chunk. - BitStream *bstream; - QRenc_List *next; -}; - -static QRenc_List *QRenc_newEntry(QRenc_EncodeMode mode, int size, unsigned char *data) -{ - QRenc_List *entry; - - if(QRenc_checkData(mode, size, data)) { - return NULL; - } - - entry = (QRenc_List *)malloc(sizeof(QRenc_List)); - entry->mode = mode; - entry->size = size; - entry->data = (unsigned char *)malloc(size); - memcpy(entry->data, data, size); - entry->bstream = NULL; - entry->next = NULL; - - return entry; -} - -static QRenc_List *QRenc_freeEntry(QRenc_List *entry) -{ - QRenc_List *next; - - next = entry->next; - free(entry->data); - if(entry->bstream) { - BitStream_free(entry->bstream); - } - free(entry); - - return next; -} - -/****************************************************************************** - * Input Data stream - *****************************************************************************/ - -struct _QRenc_DataStream { - int version; - QRenc_ErrorCorrectionLevel level; - QRenc_List *head; - QRenc_List *tail; -}; - -int QRenc_getVersion(QRenc_DataStream *stream) -{ - return stream->version; -} - -void QRenc_setVersion(QRenc_DataStream *stream, int v) -{ - stream->version = v; -} - -void QRenc_setErrorCorrectionLevel(QRenc_DataStream *stream, QRenc_ErrorCorrectionLevel level) -{ - stream->level = level; -} - -QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(QRenc_DataStream *stream) -{ - return stream->level; -} - -QRenc_DataStream *QRenc_newData(void) -{ - QRenc_DataStream *stream; - - stream = (QRenc_DataStream *)malloc(sizeof(QRenc_DataStream)); - stream->head = NULL; - stream->tail = NULL; - stream->version = 0; - stream->level = QR_EC_LEVEL_L; - - return stream; -} - -int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, unsigned char *data) -{ - QRenc_List *entry; - - entry = QRenc_newEntry(mode, size, data); - if(entry == NULL) { - return -1; - } - - if(stream->tail == NULL) { - stream->head = entry; - stream->tail = entry; - } else { - stream->tail->next = entry; - stream->tail = entry; - } - - return 0; -} - -void QRenc_freeData(QRenc_DataStream *stream) -{ - QRenc_List *list; - - list = stream->head; - while(list != NULL) { - list = QRenc_freeEntry(list); - } - - free(stream); -} - -/****************************************************************************** - * Numeric data - *****************************************************************************/ - -/** - * Check the input data. - * @param size - * @param data - * @return result - */ -static int QRenc_checkModeNum(int size, const char *data) -{ - int i; - - for(i=0; i '9') - return -1; - } - - return 0; -} - -/** - * Estimates the length of the encoded bit stream of numeric data. - * @param entry - * @return number of bits - */ -static int QRenc_estimateBitsModeNum(QRenc_List *entry) -{ - int w; - int bits; - - w = entry->size / 3; - bits = w * 10; - switch(entry->size - w * 3) { - case 1: - bits += 4; - break; - case 2: - bits += 7; - break; - default: - break; - } - - return bits; -} - -/** - * Convert the number data stream to a bit stream. - * @param entry - */ -static void QRenc_encodeModeNum(QRenc_List *entry, int version) -{ - int words; - int i; - unsigned int val; - - words = entry->size / 3; - entry->bstream = BitStream_new(); - - val = 0x1; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val); - - for(i=0; idata[i*3 ] - '0') * 100; - val += (entry->data[i*3+1] - '0') * 10; - val += (entry->data[i*3+2] - '0'); - - BitStream_appendNum(entry->bstream, 10, val); - } - - if(entry->size - words * 3 == 1) { - val = entry->data[words*3] - '0'; - BitStream_appendNum(entry->bstream, 4, val); - } else if(entry->size - words * 3 == 2) { - val = (entry->data[words*3 ] - '0') * 10; - val += (entry->data[words*3+1] - '0'); - BitStream_appendNum(entry->bstream, 7, val); - } -} - -/****************************************************************************** - * Alphabet-numeric data - *****************************************************************************/ - -static signed char anTable[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1 -}; - -/** - * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). - * @param c character - * @return value - */ -inline static signed char QRenc_lookAnTable(char c) -{ - if(c & 0x80) { - return -1; - } - return anTable[(int)c]; -} - -/** - * Check the input data. - * @param size - * @param data - * @return result - */ -static int QRenc_checkModeAn(int size, const char *data) -{ - int i; - - for(i=0; isize / 2; - bits = w * 11; - if(entry->size & 1) { - bits += 6; - } - - return bits; -} - -/** - * Convert the alphabet-numeric data stream to a bit stream. - * @param entry - */ -static void QRenc_encodeModeAn(QRenc_List *entry, int version) -{ - int words; - int i; - unsigned int val; - - words = entry->size / 2; - entry->bstream = BitStream_new(); - - val = 0x2; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), val); - - for(i=0; idata[i*2 ]) * 45; - val += (unsigned int)QRenc_lookAnTable(entry->data[i*2+1]); - - BitStream_appendNum(entry->bstream, 11, val); - } - - if(entry->size & 1) { - val = (unsigned int)QRenc_lookAnTable(entry->data[words * 2]); - - BitStream_appendNum(entry->bstream, 6, val); - } -} - -/****************************************************************************** - * 8 bit data - *****************************************************************************/ - -/** - * Estimates the length of the encoded bit stream of 8 bit data. - * @param entry - * @return number of bits - */ -static int QRenc_estimateBitsMode8(QRenc_List *entry) -{ - return entry->size * 8; -} - -/** - * Convert the 8bits data stream to a bit stream. - * @param entry - */ -static void QRenc_encodeMode8(QRenc_List *entry, int version) -{ - int i; - unsigned int val; - - entry->bstream = BitStream_new(); - - val = 0x4; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), val); - - for(i=0; isize; i++) { - BitStream_appendNum(entry->bstream, 8, entry->data[i]); - } -} - - -/****************************************************************************** - * Kanji data - *****************************************************************************/ - -/** - * Estimates the length of the encoded bit stream of kanji data. - * @param entry - * @return number of bits - */ -static int QRenc_estimateBitsModeKanji(QRenc_List *entry) -{ - return (entry->size / 2) * 13; -} - -/** - * Check the input data. - * @param size - * @param data - * @return result - */ -static int QRenc_checkModeKanji(int size, const unsigned char *data) -{ - int i; - unsigned int val; - - if(size & 1) - return -1; - - for(i=0; i 0x9ffc && val < 0xe040) || val > 0xebbf) { - return -1; - } - } - - return 0; -} - -/** - * Convert the kanji data stream to a bit stream. - * @param entry - */ -static void QRenc_encodeModeKanji(QRenc_List *entry, int version) -{ - int i; - unsigned int val, h; - - entry->bstream = BitStream_new(); - - val = 0x8; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size / 2; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), val); - - for(i=0; isize; i+=2) { - val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1]; - if(val <= 0x9ffc) { - val -= 0x8140; - } else { - val -= 0xc140; - } - h = (val >> 8) * 0xc0; - val = (val & 0xff) + h; - - BitStream_appendNum(entry->bstream, 13, val); - } -} - -/****************************************************************************** - * Validation - *****************************************************************************/ - -/** - * Validate the input data - * @param mode - * @param size - * @param data - * @return result - */ -int QRenc_checkData(QRenc_EncodeMode mode, int size, const unsigned char *data) -{ - switch(mode) { - case QR_MODE_NUM: - return QRenc_checkModeNum(size, (const char *)data); - break; - case QR_MODE_AN: - return QRenc_checkModeAn(size, (const char *)data); - break; - case QR_MODE_KANJI: - return QRenc_checkModeKanji(size, data); - break; - default: - break; - } - - return 0; -} - -/****************************************************************************** - * Estimation of the bit length - *****************************************************************************/ - -/** - * Estimates the length of the encoded bit stream on the current version. - * @param entry - * @param version version of the symbol - * @return number of bits - */ -static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) -{ - int bits = 0; - int l, m; - int num; - - assert(entry != NULL); - switch(entry->mode) { - case QR_MODE_NUM: - bits = QRenc_estimateBitsModeNum(entry); - break; - case QR_MODE_AN: - bits = QRenc_estimateBitsModeAn(entry); - break; - case QR_MODE_8: - bits = QRenc_estimateBitsMode8(entry); - break; - case QR_MODE_KANJI: - bits = QRenc_estimateBitsModeKanji(entry); - break; - } - - l = QRspec_lengthIndicator(entry->mode, version); - m = 1 << l; - num = (bits + m - 1) / m; - - bits += num * (4 + l); // mode indicator (4bits) + length indicator - - return bits; -} - -/** - * Estimates the length of the encoded bit stream of the data stream. - * @param stream data stream - * @param version version of the symbol - * @return number of bits - */ -int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version) -{ - QRenc_List *list; - int bits = 0; - - assert(stream != NULL); - - list = stream->head; - while(list != NULL) { - bits += QRenc_estimateBitStreamSizeOfEntry(list, version); - list = list->next; - } - - return bits; -} - -/** - * Estimates the required version number of the symbol. - * @param stream data stream - * @return required version number - */ -static int QRenc_estimateVersion(QRenc_DataStream *stream) -{ - int bits; - int new, prev; - - new = 0; - do { - prev = new; - bits = QRenc_estimateBitStreamSize(stream, prev); - new = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); - if (new == -1) { - return -1; - } - } while (new > prev); - - return new; -} - -/****************************************************************************** - * Data conversion - *****************************************************************************/ - -/** - * Convert the data stream in the data chunk to a bit stream. - * @param entry - * @return number of bits - */ -static int QRenc_encodeBitStream(QRenc_List *entry, int version) -{ - int words; - QRenc_List *st1, *st2; - - assert(entry != NULL); - - if(entry->bstream != NULL) { - BitStream_free(entry->bstream); - entry->bstream = NULL; - } - - words = QRspec_maximumWords(entry->mode, version); - if(entry->size > words) { - st1 = QRenc_newEntry(entry->mode, words, entry->data); - st2 = QRenc_newEntry(entry->mode, entry->size - words, &entry->data[words]); - QRenc_encodeBitStream(st1, version); - QRenc_encodeBitStream(st2, version); - entry->bstream = BitStream_new(); - BitStream_append(entry->bstream, st1->bstream); - BitStream_append(entry->bstream, st2->bstream); - QRenc_freeEntry(st1); - QRenc_freeEntry(st2); - } else { - switch(entry->mode) { - case QR_MODE_NUM: - QRenc_encodeModeNum(entry, version); - break; - case QR_MODE_AN: - QRenc_encodeModeAn(entry, version); - break; - case QR_MODE_8: - QRenc_encodeMode8(entry, version); - break; - case QR_MODE_KANJI: - QRenc_encodeModeKanji(entry, version); - break; - default: - break; - } - } - - return BitStream_size(entry->bstream); -} - -/** - * Convert the input data stream to a bit stream. - * @param stream input data stream. - * @return length of the bit stream. - */ -static int QRenc_createBitStream(QRenc_DataStream *stream) -{ - QRenc_List *list; - int bits = 0; - - assert(stream != NULL); - - list = stream->head; - while(list != NULL) { - bits += QRenc_encodeBitStream(list, stream->version); - list = list->next; - } - - return bits; -} - -/** - * Convert the input data stream to a bit stream. - * When the version number is given and that is not sufficient, it is increased - * automatically. - * @param stream input data stream. - * @return -1 if the input data was too large. Otherwise 0. - */ -static int QRenc_convertData(QRenc_DataStream *stream) -{ - int bits; - int ver; - - ver = QRenc_estimateVersion(stream); - QRenc_setVersion(stream, ver); - - for(;;) { - bits = QRenc_createBitStream(stream); - ver = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); - if(ver < 0) { - return -1; - } else if(ver > QRenc_getVersion(stream)) { - QRenc_setVersion(stream, ver); - } else { - break; - } - } - - return 0; -} - -/** - * Create padding bits for the input stream. - * @param stream input data stream. - * @return padding bit stream. - */ -static BitStream *QRenc_createPaddingBit(QRenc_DataStream *stream) -{ - int bits, maxbits, words, maxwords, i; - QRenc_List *list; - BitStream *bstream; - - if(stream->version <= 0) - return NULL; - - maxwords = QRspec_getMaximumCodeLength(stream->version, stream->level); - maxbits = maxwords * 8; - - list = stream->head; - bits = 0; - while(list != NULL) { - bits += BitStream_size(list->bstream); - list = list->next; - } - - words = (bits + 7) / 8; - - if(bits == maxbits) - return NULL; - - if(maxbits - bits < 5) { - bstream = BitStream_new(); - BitStream_appendNum(bstream, maxbits - bits, 0); - return bstream; - } - - bstream = BitStream_new(); - BitStream_appendNum(bstream, words * 8 - bits, 0); - - for(i=0; ihead; - while(list != NULL) { - BitStream_append(bstream, list->bstream); - list = list->next; - } - - return bstream; -} - -/** - * Merge all bit streams in the input data stream and append padding bits - * @param stream input data stream. - * @return padded merged bit stream - */ - -BitStream *QRenc_getBitStream(QRenc_DataStream *stream) -{ - BitStream *bstream; - - bstream = QRenc_mergeBitStream(stream); - if(bstream == NULL) { - return NULL; - } - BitStream_append(bstream, QRenc_createPaddingBit(stream)); - - return bstream; -} - -/** - * Get byte array that includes all data code and error correction code. - * @param stream input data stream. - * @return byte array of data code and error correction code - */ +#include "datastream.h" diff --git a/qrencode.h b/qrencode.h index 9f3a1f9f95..d0f924f0bd 100644 --- a/qrencode.h +++ b/qrencode.h @@ -1,7 +1,6 @@ /** * qrencode - QR-code encoder * - * Ported to C and modified by Kentaro Fukuchi * Copyright (C) 2006 Kentaro Fukuchi * * This program is free software; you can redistribute it and/or modify @@ -17,7 +16,6 @@ * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * */ #ifndef __QRENCODE_H__ -- cgit 0.0.5-2-1-g0f52 From 91aa057a2b881aff7c726b91d65ce36004aa2c75 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 10 Nov 2006 17:27:38 +0000 Subject: --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 04d3ea0287..1a4fb4f224 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,6 +6,6 @@ lib_LTLIBRARIES = libqrencode.la libqrencode_la_SOURCES = qrencode.c datastream.c bitstream.c qrspec.c rscode.c libqrencode_la_headers = qrencode.h datastream.h bitstream.h qrspec.h rscode.h -libqrencode_la_LDFLAGS = -version-info $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) +libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) pkginclude_HEADERS = qrencode.h -- cgit 0.0.5-2-1-g0f52 From 3d527fd14b761e08cfde695914e94cb0b3e7fdcf Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 10 Nov 2006 20:24:07 +0000 Subject: --- datastream.c | 13 +++------ datastream.h | 15 +++++++++++ qrencode.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ qrspec.c | 2 +- qrspec.h | 23 ++++++++++++++++ qrtest.h | 15 ++++++++++- rscode.c | 4 +-- rscode.h | 2 +- tests/Makefile.am | 5 +++- tests/test_qrspec.c | 6 ++--- tests/test_rs.c | 36 +++++++++++++++++++++++++ 11 files changed, 178 insertions(+), 19 deletions(-) create mode 100644 tests/test_rs.c diff --git a/datastream.c b/datastream.c index 6174111caf..d4de57f3d2 100644 --- a/datastream.c +++ b/datastream.c @@ -32,7 +32,6 @@ * Entry of input data stream *****************************************************************************/ -typedef struct _QRenc_List QRenc_List; struct _QRenc_List { QRenc_EncodeMode mode; int size; ///< Size of data chunk (byte). @@ -78,13 +77,6 @@ static QRenc_List *QRenc_freeEntry(QRenc_List *entry) * Input Data stream *****************************************************************************/ -struct _QRenc_DataStream { - int version; - QRenc_ErrorCorrectionLevel level; - QRenc_List *head; - QRenc_List *tail; -}; - int QRenc_getVersion(QRenc_DataStream *stream) { return stream->version; @@ -743,12 +735,15 @@ BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream) BitStream *QRenc_getBitStream(QRenc_DataStream *stream) { BitStream *bstream; + BitStream *padding; bstream = QRenc_mergeBitStream(stream); if(bstream == NULL) { return NULL; } - BitStream_append(bstream, QRenc_createPaddingBit(stream)); + padding = QRenc_createPaddingBit(stream); + BitStream_append(bstream, padding); + BitStream_free(padding); return bstream; } diff --git a/datastream.h b/datastream.h index 58ecdf9ca2..66cd93d936 100644 --- a/datastream.h +++ b/datastream.h @@ -24,6 +24,21 @@ #include "qrencode.h" #include "bitstream.h" +/****************************************************************************** + * Entry of input data stream + *****************************************************************************/ +typedef struct _QRenc_List QRenc_List; + +/****************************************************************************** + * Input Data stream + *****************************************************************************/ +struct _QRenc_DataStream { + int version; + QRenc_ErrorCorrectionLevel level; + QRenc_List *head; + QRenc_List *tail; +}; + /** * Pack all bit streams padding bits into a byte array. * @param stream input data stream. diff --git a/qrencode.c b/qrencode.c index 59fcecc84a..9817bf19ed 100644 --- a/qrencode.c +++ b/qrencode.c @@ -27,3 +27,79 @@ #include "qrspec.h" #include "bitstream.h" #include "datastream.h" +#include "rscode.h" + +/****************************************************************************** + * Raw code + *****************************************************************************/ +typedef struct { + int dataLength; + unsigned char *data; + int eccLength; + unsigned char *ecc; +} RSblock; + +typedef struct { + unsigned char *datacode; + int blocks; + RSblock *rsblock; +} QRRawCode; + +static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el) +{ + RS *rs; + + block->dataLength = dl; + block->data = data; + block->eccLength = el; + block->ecc = (unsigned char *)malloc(el); + + rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); + encode_rs_char(rs, data, block->ecc); +} + +QRRawCode *QRraw_new(QRenc_DataStream *stream) +{ + QRRawCode *raw; + int *spec; + int i; + RSblock *rsblock; + unsigned char *p; + + raw = (QRRawCode *)malloc(sizeof(QRRawCode)); + raw->datacode = QRenc_getByteStream(stream); + spec = QRspec_getEccSpec(stream->version, stream->level); + raw->blocks = QRspec_rsBlockNum(spec); + raw->rsblock = (RSblock *)malloc(sizeof(RSblock) * raw->blocks); + + rsblock = raw->rsblock; + p = raw->datacode; + for(i=0; idatacode); + for(i=0; iblocks; i++) { + free(raw->rsblock[i].ecc); + } + free(raw->rsblock); + free(raw); +} diff --git a/qrspec.c b/qrspec.c index 0febbb9d6b..e557ad0053 100644 --- a/qrspec.c +++ b/qrspec.c @@ -206,7 +206,7 @@ static int eccTable[QRSPEC_VERSION_MAX+1][4][2] = { {{19, 6}, {18, 31}, {34, 34}, {20, 61}},//40 }; -int *QRspec_getEccBlockNum(int version, QRenc_ErrorCorrectionLevel level) +int *QRspec_getEccSpec(int version, QRenc_ErrorCorrectionLevel level) { int b1, b2; int data, ecc; diff --git a/qrspec.h b/qrspec.h index be86f00e59..2ba2936162 100644 --- a/qrspec.h +++ b/qrspec.h @@ -72,4 +72,27 @@ extern int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version); */ extern int QRspec_maximumWords(QRenc_EncodeMode mode, int version); +/****************************************************************************** + * Error correction code + *****************************************************************************/ + +/** + * Return an array of ECC specification. + * @param version + * @param level + * @return an array of ECC specification contains as following: + * {# of type1 blocks, # of data code, # of ecc code, + * # of type2 blocks, # of data code, # of ecc code} + * It can be freed by calling free(). + */ +int *QRspec_getEccSpec(int version, QRenc_ErrorCorrectionLevel level); + +#define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3]) +#define QRspec_rsBlockNum1(__spec__) (__spec__[0]) +#define QRspec_rsDataCodes1(__spec__) (__spec__[1]) +#define QRspec_rsEccCodes1(__spec__) (__spec__[2]) +#define QRspec_rsBlockNum2(__spec__) (__spec__[3]) +#define QRspec_rsDataCodes2(__spec__) (__spec__[4]) +#define QRspec_rsEccCodes2(__spec__) (__spec__[5]) + #endif /* __QRSPEC_H__ */ diff --git a/qrtest.h b/qrtest.h index 9c826541df..ab47c6006c 100644 --- a/qrtest.h +++ b/qrtest.h @@ -5,4 +5,17 @@ extern int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); extern BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream); extern BitStream *QRenc_getBitStream(QRenc_DataStream *stream); -extern int *QRspec_getEccBlockNum(int version, QRenc_ErrorCorrectionLevel level); +typedef struct { + int dataLength; + unsigned char *data; + int eccLength; + unsigned char *ecc; +} RSblock; + +typedef struct { + unsigned char *datacode; + int blocks; + RSblock *rsblock; +} QRRawCode; +extern QRRawCode *QRraw_new(QRenc_DataStream *stream); +extern void QRraw_free(QRRawCode *raw); diff --git a/rscode.c b/rscode.c index 58c1eb9bf7..2f6ea65ae3 100644 --- a/rscode.c +++ b/rscode.c @@ -49,7 +49,6 @@ struct _RS { int iprim; /* prim-th root of 1, index form */ int pad; /* Padding bytes in shortened block */ int gfpoly; - int refcount; struct _RS *next; }; @@ -211,7 +210,6 @@ RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) if(rs->nroots != nroots) continue; if(rs->pad != pad) continue; - rs->refcount++; return rs; } @@ -266,7 +264,7 @@ void free_rs_char(RS *rs) #undef A0 #define A0 (NN) /* Special reserved value encoding zero in index form */ -void encode_rs_char(RS *rs, data_t *data, data_t *parity) +void encode_rs_char(RS *rs, const data_t *data, data_t *parity) { int i, j; data_t feedback; diff --git a/rscode.h b/rscode.h index a6d51a1cba..dd2961d4cd 100644 --- a/rscode.h +++ b/rscode.h @@ -35,7 +35,7 @@ typedef struct _RS RS; /* WARNING: Thread unsafe!!! */ extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad); -extern void encode_rs_char(RS *rs, unsigned char *data, unsigned char *parity); +extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity); extern void free_rs_char(RS *rs); #endif /* __RSCODE_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am index b8b46f7971..71b6f65347 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,5 @@ noinst_PROGRAMS = test_datastream test_bitstream test_estimatebit \ - test_qrspec + test_qrspec test_rs test_datastream_SOURCES = test_datastream.c test_datastream_LDADD = ../libqrencode.la @@ -12,3 +12,6 @@ test_estimatebit_LDADD = ../libqrencode.la test_qrspec_SOURCES = test_qrspec.c test_qrspec_LDADD = ../qrspec.o + +test_rs_SOURCES = test_rs.c +test_rs_LDADD = ../libqrencode.la diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 2540115831..27eee1799b 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -14,7 +14,7 @@ void print_eccTable(void) for(i=1; i<=QRSPEC_VERSION_MAX; i++) { printf("Version %2d\n", i); for(j=0; j<4; j++) { - bl = QRspec_getEccBlockNum(i, j); + bl = QRspec_getEccSpec(i, j); data = bl[0] * bl[1] + bl[3] * bl[4]; ecc = bl[0] * bl[2] + bl[3] * bl[5]; printf("%3d\t", ecc); @@ -40,7 +40,7 @@ void test_eccTable(void) testStart("Checking ECC table."); for(i=1; i<=QRSPEC_VERSION_MAX; i++) { for(j=0; j<4; j++) { - bl = QRspec_getEccBlockNum(i, j); + bl = QRspec_getEccSpec(i, j); data = bl[0] * bl[1] + bl[3] * bl[4]; ecc = bl[0] * bl[2] + bl[3] * bl[5]; if(qrspecCapacity[i].words != data + ecc) { @@ -80,7 +80,7 @@ void test_eccTable2(void) testStart("Checking ECC table(2)"); for(i=0; i<7; i++) { err = 0; - bl = QRspec_getEccBlockNum(correct[i][0], correct[i][1]); + bl = QRspec_getEccSpec(correct[i][0], correct[i][1]); idx = correct[i][2] * 3; if(bl[idx] != correct[i][3]) err++; if(bl[idx+1] + bl[idx+2] != correct[i][4]) err++; diff --git a/tests/test_rs.c b/tests/test_rs.c new file mode 100644 index 0000000000..2486d56689 --- /dev/null +++ b/tests/test_rs.c @@ -0,0 +1,36 @@ +#include +#include +#include "common.h" +#include "../qrtest.h" + +/* See pp. 73 of JIS X0510:2004 */ +void test_rscode1(void) +{ + int i; + QRenc_DataStream *stream; + QRRawCode *code; + static char str[8] = "01234567"; + static unsigned char correct[26] = { + 0x10, 0x20, 0x0c, 0x56, 0x61, 0x80, 0xec, 0x11, 0xec, 0x11, 0xec, 0x11, + 0xec, 0x11, 0xec, 0x11, 0xa5, 0x24, 0xd4, 0xc1, 0xed, 0x36, 0xc7, 0x87, + 0x2c, 0x55}; + + testStart("RS ecc test"); + stream = QRenc_newData(); + QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)str); + QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_M); + code = QRraw_new(stream); + + testEnd(memcmp(correct + 16, code->rsblock[0].ecc, 10)); + QRenc_freeData(stream); + QRraw_free(code); +} + +int main(int argc, char **argv) +{ + test_rscode1(); + + report(); + + return 0; +} -- cgit 0.0.5-2-1-g0f52 From 2214f8264c7ba2067d0b7812cd6a242d770993eb Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 10 Nov 2006 22:36:32 +0000 Subject: --- qrspec.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++ qrspec.h | 12 +++++++ tests/test_qrspec.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 181 insertions(+) diff --git a/qrspec.c b/qrspec.c index e557ad0053..56a2c17d8b 100644 --- a/qrspec.c +++ b/qrspec.c @@ -236,3 +236,94 @@ int *QRspec_getEccSpec(int version, QRenc_ErrorCorrectionLevel level) return array; } + +/****************************************************************************** + * Alignment pattern + *****************************************************************************/ + +static int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = { + { 0, 0}, + { 0, 0}, {18, 0}, {22, 0}, {26, 0}, {30, 0}, // 1- 5 + {34, 0}, {22, 38}, {24, 42}, {26, 46}, {28, 50}, // 6-10 + {30, 54}, {32, 58}, {34, 62}, {26, 46}, {26, 48}, //11-15 + {26, 50}, {30, 54}, {30, 56}, {30, 58}, {34, 62}, //16-20 + {28, 50}, {26, 50}, {30, 54}, {28, 54}, {32, 58}, //21-25 + {30, 58}, {34, 62}, {26, 50}, {30, 54}, {26, 52}, //26-30 + {30, 56}, {34, 60}, {30, 58}, {34, 62}, {30, 54}, //31-35 + {24, 50}, {28, 54}, {32, 58}, {26, 54}, {30, 58}, //35-40 +}; + +QRspec_Alignment *QRspec_getAlignmentPattern(int version) +{ + int length; + int d, w, x, y, cx, cy; + QRspec_Alignment *al; + int *p; + + if(version < 2) return NULL; + + al = (QRspec_Alignment *)malloc(sizeof(QRspec_Alignment)); + + length = qrspecCapacity[version].length; + d = alignmentPattern[version][1] - alignmentPattern[version][0]; + if(d < 0) { + w = 2; + } else { + w = (length - alignmentPattern[version][0]) / d + 2; + } + + al->n = w * w - 3; + al->pos = (int *)malloc(sizeof(int) * al->n * 2); + + if(al->n == 1) { + al->pos[0] = alignmentPattern[version][0]; + al->pos[1] = alignmentPattern[version][0]; + + return al; + } +#if 0 + printf("%d ", version); + cx = alignmentPattern[version][0]; + for(x=0; xpos; + + cx = alignmentPattern[version][0]; + for(x=1; xpos != NULL) { + free(al->pos); + } + free(al); + } +} diff --git a/qrspec.h b/qrspec.h index 2ba2936162..1a7a864f41 100644 --- a/qrspec.h +++ b/qrspec.h @@ -95,4 +95,16 @@ int *QRspec_getEccSpec(int version, QRenc_ErrorCorrectionLevel level); #define QRspec_rsDataCodes2(__spec__) (__spec__[4]) #define QRspec_rsEccCodes2(__spec__) (__spec__[5]) +/****************************************************************************** + * Alignment pattern + *****************************************************************************/ + +typedef struct { + int n; + int *pos; +} QRspec_Alignment; + +extern QRspec_Alignment *QRspec_getAlignmentPattern(int version); +extern void QRspec_freeAlignment(QRspec_Alignment *al); + #endif /* __QRSPEC_H__ */ diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 27eee1799b..8b88a5a036 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -95,11 +95,89 @@ void test_eccTable2(void) testEnd(terr); } +void test_alignment1(void) +{ + QRspec_Alignment *al; + int i; + int err = 0; + int rbpos; + + testStart("Checking alignment pattern table(1)"); + rbpos = 14; + for(i=1; i<=QRSPEC_VERSION_MAX; i++) { + al = QRspec_getAlignmentPattern(i); + if(i == 1) { + if(al != NULL) { + printf("Error in version %d.\n", i); + err++; + } + } else if(i < 7) { + if(al->n != 1) { + printf("Error in version %d.\n", i); + err++; + } + if(al->pos[al->n*2-1] != rbpos) { + printf("Error in version %d.\n", i); + err++; + } + } else if(i < 14) { + if(al->n != 6) { + printf("Error in version %d.(%d)\n", i, al->n); + err++; + } + if(al->pos[al->n*2-1] != rbpos) { + printf("Error in version %d.\n", i); + err++; + } + } else if(i < 21) { + if(al->n != 13) { + printf("Error in version %d.(%d)\n", i, al->n); + err++; + } + if(al->pos[al->n*2-1] != rbpos) { + printf("Error in version %d.\n", i); + err++; + } + } else if(i < 28) { + if(al->n != 22) { + printf("Error in version %d.(%d)\n", i, al->n); + err++; + } + if(al->pos[al->n*2-1] != rbpos) { + printf("Error in version %d.\n", i); + err++; + } + } else if(i < 35) { + if(al->n != 33) { + printf("Error in version %d.(%d)\n", i, al->n); + err++; + } + if(al->pos[al->n*2-1] != rbpos) { + printf("Error in version %d.\n", i); + err++; + } + } else { + if(al->n != 46) { + printf("Error in version %d.(%d)\n", i, al->n); + err++; + } + if(al->pos[al->n*2-1] != rbpos) { + printf("Error in version %d.\n", i); + err++; + } + } + QRspec_freeAlignment(al); + rbpos += 4; + } + testEnd(err); +} + int main(int argc, char **argv) { test_eccTable(); test_eccTable2(); // print_eccTable(); + test_alignment1(); report(); -- cgit 0.0.5-2-1-g0f52 From c78a3e234bf334575768464c4a404072e503781a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 11 Nov 2006 07:53:58 +0000 Subject: --- qrspec.c | 38 +++++++++++++++++++++++++++++++++++++- qrspec.h | 41 ++++++++++++++++++++++++++++++++--------- qrtest.h | 9 +++++++++ tests/test_qrspec.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/test_rs.c | 1 - 5 files changed, 120 insertions(+), 11 deletions(-) diff --git a/qrspec.c b/qrspec.c index 56a2c17d8b..7d940d61ff 100644 --- a/qrspec.c +++ b/qrspec.c @@ -9,7 +9,6 @@ * "Automatic identification and data capture techniques -- * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) * - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -34,6 +33,12 @@ * Version and capacity *****************************************************************************/ +typedef struct { + int length; //< Edge length of the symbol + int words; //< Data capacity (bytes) + int ec[4]; //< Number of ECC code (bytes) +} QRspec_Capacity; + /** * Table of the capacity of symbols * See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004. @@ -241,6 +246,13 @@ int *QRspec_getEccSpec(int version, QRenc_ErrorCorrectionLevel level) * Alignment pattern *****************************************************************************/ +/** + * Positions of alignment patterns. + * This array includes only the second and the third position of the alignment + * patterns. Rest of them can be calculated from the distance between them. + * + * See Table 1 in Appendix E (pp.71) of JIS X0510:2004. + */ static int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = { { 0, 0}, { 0, 0}, {18, 0}, {22, 0}, {26, 0}, {30, 0}, // 1- 5 @@ -282,6 +294,7 @@ QRspec_Alignment *QRspec_getAlignmentPattern(int version) return al; } #if 0 + /* Just for debug purpose */ printf("%d ", version); cx = alignmentPattern[version][0]; for(x=0; x QRSPEC_VERSION_MAX) return 0; + + return versionPattern[version -7]; +} diff --git a/qrspec.h b/qrspec.h index 1a7a864f41..7efba2972d 100644 --- a/qrspec.h +++ b/qrspec.h @@ -27,16 +27,11 @@ * Version and capacity *****************************************************************************/ +/** + * Maximum version (size) of QR-code symbol. + */ #define QRSPEC_VERSION_MAX 40 -typedef struct { - int length; //< Edge length of the symbol - int words; //< Data capacity (bytes) - int ec[4]; -} QRspec_Capacity; - -extern QRspec_Capacity qrspecCapacity[]; - /** * Return maximum data code length (bytes) for the version. * @param version @@ -48,6 +43,7 @@ extern int QRspec_getMaximumCodeLength(int version, QRenc_ErrorCorrectionLevel l /** * Return a version number that satisfies the input code length. * @param size input code length (byte) + * @param level * @return version number */ extern int QRspec_getMinimumVersion(int size, QRenc_ErrorCorrectionLevel level); @@ -99,12 +95,39 @@ int *QRspec_getEccSpec(int version, QRenc_ErrorCorrectionLevel level); * Alignment pattern *****************************************************************************/ +/** + * Array of positions of alignment patterns. + * X and Y coordinates are interleaved into 'pos'. + */ typedef struct { - int n; + int n; //< Number of patterns int *pos; } QRspec_Alignment; +/** + * Return positions of alignment patterns. + * @param version + * @return a QRspec_Alignment object that contains all of positions of alignment + * patterns. + */ extern QRspec_Alignment *QRspec_getAlignmentPattern(int version); + +/** + * Free QRspec_Alignment instance. + * @param al QRspec_Alignment instance. + */ extern void QRspec_freeAlignment(QRspec_Alignment *al); +/****************************************************************************** + * Version information pattern + *****************************************************************************/ + +/** + * Return BCH encoded version information pattern that is used for the symbol + * of version 7 or greater. Use lower 18 bits. + * @param version + * @return BCH coded version information pattern + */ +extern unsigned int QRspec_getVersionPattern(int version); + #endif /* __QRSPEC_H__ */ diff --git a/qrtest.h b/qrtest.h index ab47c6006c..a071505820 100644 --- a/qrtest.h +++ b/qrtest.h @@ -1,6 +1,15 @@ #include "qrencode.h" #include "bitstream.h" +typedef struct { + int length; //< Edge length of the symbol + int words; //< Data capacity (bytes) + int ec[4]; +} QRspec_Capacity; + +extern QRspec_Capacity qrspecCapacity[]; + + extern int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); extern BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream); extern BitStream *QRenc_getBitStream(QRenc_DataStream *stream); diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 8b88a5a036..2236fd1d64 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -172,12 +172,54 @@ void test_alignment1(void) testEnd(err); } +void test_verpat(void) +{ + int version; + unsigned int pattern; + int err = 0; + unsigned int data; + unsigned int code; + int i, c; + unsigned int mask; + + for(version=7; version <= QRSPEC_VERSION_MAX; version++) { + pattern = QRspec_getVersionPattern(version); + if((pattern >> 12) != version) { + printf("Error in version %d.\n", version); + err++; + continue; + } + mask = 0x40; + for(i=0; mask != 0; i++) { + if(version & mask) break; + mask = mask >> 1; + } + c = 6 - i; + data = version << 12; + code = 0x1f25 << c; + mask = 0x40000 >> (6 - c); + for(i=0; i<=c; i++) { + if(mask & data) { + data ^= code; + } + code = code >> 1; + mask = mask >> 1; + } + data = (version << 12) | (data & 0xfff); + if(data != pattern) { + printf("Error in version %d\n", version); + err++; + } + } +} + int main(int argc, char **argv) { test_eccTable(); test_eccTable2(); // print_eccTable(); test_alignment1(); + test_verpat(); report(); diff --git a/tests/test_rs.c b/tests/test_rs.c index 2486d56689..160ac36efe 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -6,7 +6,6 @@ /* See pp. 73 of JIS X0510:2004 */ void test_rscode1(void) { - int i; QRenc_DataStream *stream; QRRawCode *code; static char str[8] = "01234567"; -- cgit 0.0.5-2-1-g0f52 From 47f43158e2232aa98ad29162f6cd5ec937140a69 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 11 Nov 2006 10:03:13 +0000 Subject: --- qrspec.c | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++-- qrspec.h | 11 ++++ qrtest.h | 2 +- tests/test_qrspec.c | 18 +++++ 4 files changed, 210 insertions(+), 5 deletions(-) diff --git a/qrspec.c b/qrspec.c index 7d940d61ff..88f5e722b9 100644 --- a/qrspec.c +++ b/qrspec.c @@ -26,6 +26,7 @@ #include #include +#include #include "qrspec.h" @@ -34,7 +35,7 @@ *****************************************************************************/ typedef struct { - int length; //< Edge length of the symbol + int width; //< Edge length of the symbol int words; //< Data capacity (bytes) int ec[4]; //< Number of ECC code (bytes) } QRspec_Capacity; @@ -267,7 +268,7 @@ static int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = { QRspec_Alignment *QRspec_getAlignmentPattern(int version) { - int length; + int width; int d, w, x, y, cx, cy; QRspec_Alignment *al; int *p; @@ -276,12 +277,12 @@ QRspec_Alignment *QRspec_getAlignmentPattern(int version) al = (QRspec_Alignment *)malloc(sizeof(QRspec_Alignment)); - length = qrspecCapacity[version].length; + width = qrspecCapacity[version].width; d = alignmentPattern[version][1] - alignmentPattern[version][0]; if(d < 0) { w = 2; } else { - w = (length - alignmentPattern[version][0]) / d + 2; + w = (width - alignmentPattern[version][0]) / d + 2; } al->n = w * w - 3; @@ -363,3 +364,178 @@ unsigned int QRspec_getVersionPattern(int version) return versionPattern[version -7]; } + +/****************************************************************************** + * Frame + *****************************************************************************/ + +/** + * Cache of initial frames. + */ +/* C99 says that static storage shall be initalized to a null pointer + * by comipler. */ +static unsigned char *frames[QRSPEC_VERSION_MAX + 1]; + +/** + * Put a finder pattern. + * @param frame + * @param width + * @param ox,oy upper-left coordinate of the pattern + */ +static void putFinderPattern(unsigned char *frame, int width, int ox, int oy) +{ + static unsigned char finder[] = { + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, + 0x81, 0x80, 0x81, 0x81, 0x81, 0x80, 0x81, + 0x81, 0x80, 0x81, 0x81, 0x81, 0x80, 0x81, + 0x81, 0x80, 0x81, 0x81, 0x81, 0x80, 0x81, + 0x81, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + }; + int x, y; + unsigned char *s; + + frame += oy * width + ox; + s = finder; + for(y=0; y<7; y++) { + for(x=0; x<7; x++) { + frame[x] = s[x]; + } + frame += width; + s += 7; + } +} + +/** + * Put an alignment pattern. + * @param frame + * @param width + * @param ox,oy center coordinate of the pattern + */ +static void putAlignmentPattern(unsigned char *frame, int width, int ox, int oy) +{ + static unsigned char finder[] = { + 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x80, 0x80, 0x80, 0x81, + 0x81, 0x80, 0x81, 0x80, 0x81, + 0x81, 0x80, 0x80, 0x80, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, + }; + int x, y; + unsigned char *s; + + frame += (oy - 2) * width + ox - 2; + s = finder; + for(y=0; y<5; y++) { + for(x=0; x<5; x++) { + frame[x] = s[x]; + } + frame += width; + s += 5; + } +} + +static unsigned char *QRspec_createFrame(int version) +{ + unsigned char *frame, *p, *q; + int width; + int x, y; + unsigned int verinfo, mask; + QRspec_Alignment *alignment; + + width = qrspecCapacity[version].width; + frame = (unsigned char *)malloc(width * width); + memset(frame, 0, width * width); + /* Finder pattern */ + putFinderPattern(frame, width, 0, 0); + putFinderPattern(frame, width, width - 7, 0); + putFinderPattern(frame, width, 0, width - 7); + /* Separator */ + p = frame; + q = frame + width * (width - 7); + for(y=0; y<7; y++) { + p[7] = 0x80; + p[width - 8] = 0x80; + q[7] = 0x80; + p += width; + q += width; + } + memset(frame + width * 7, 0x80, 8); + memset(frame + width * 8 - 8, 0x80, 8); + memset(frame + width * (width - 8), 0x80, 8); + /* Mask format information area */ + memset(frame + width * 8, 0x82, 9); + memset(frame + width * 9 - 8, 0x82, 8); + p = frame + 8; + for(y=0; y<8; y++) { + *p = 0x82; + p += width; + } + p = frame + width * (width - 7) + 8; + for(y=0; y<7; y++) { + *p = 0x82; + p += width; + } + /* Timing pattern */ + p = frame + width * 6 + 8; + q = frame + width * 8 + 6; + for(x=1; xn; x++) { + putAlignmentPattern(frame, width, + alignment->pos[x*2], alignment->pos[x*2+1]); + } + QRspec_freeAlignment(alignment); + } + /* Version information */ + if(version >= 7) { + verinfo = QRspec_getVersionPattern(version); + + p = frame + width * (width - 11); + mask = 0x20000; + for(x=0; x<6; x++) { + for(y=0; y<3; y++) { + p[width * y + x] = 0x80 | ((mask & verinfo) != 0); + mask = mask >> 1; + } + } + + p = frame + width - 11; + mask = 0x200; + for(y=0; y<6; y++) { + for(x=0; x<3; x++) { + p[x] = 0x80 | ((mask & verinfo) != 0); + mask = mask >> 1; + } + p += width; + } + } + /* and a little bit... */ + frame[width * (width - 8) + 8] = 0x81; + + return frame; +} + +unsigned char *QRspec_newFrame(int version) +{ + unsigned char *frame; + int width; + + if(version < 1 || version > QRSPEC_VERSION_MAX) return NULL; + + if(frames[version] == NULL) { + frames[version] = QRspec_createFrame(version); + } + width = qrspecCapacity[version].width; + frame = (unsigned char *)malloc(width * width); + memcpy(frame, frames[version], width * width); + + return frame; +} diff --git a/qrspec.h b/qrspec.h index 7efba2972d..5717b55c12 100644 --- a/qrspec.h +++ b/qrspec.h @@ -130,4 +130,15 @@ extern void QRspec_freeAlignment(QRspec_Alignment *al); */ extern unsigned int QRspec_getVersionPattern(int version); +/****************************************************************************** + * Frame + *****************************************************************************/ + +/** + * Return a copy of initialized frame. + * @param version + * @return Array of unsigned char. You can free it by free(). + */ +extern unsigned char *QRspec_newFrame(int version); + #endif /* __QRSPEC_H__ */ diff --git a/qrtest.h b/qrtest.h index a071505820..fa42e250e5 100644 --- a/qrtest.h +++ b/qrtest.h @@ -2,7 +2,7 @@ #include "bitstream.h" typedef struct { - int length; //< Edge length of the symbol + int width; //< Edge length of the symbol int words; //< Data capacity (bytes) int ec[4]; } QRspec_Capacity; diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 2236fd1d64..a0ab77f712 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -213,6 +213,23 @@ void test_verpat(void) } } +void print_newFrame(void) +{ + int width; + int x, y; + unsigned char *frame; + + frame = QRspec_newFrame(7); + width = qrspecCapacity[7].width; + for(y=0; y Date: Sat, 11 Nov 2006 11:56:02 +0000 Subject: --- qrspec.c | 37 +++++++++++++++++++++++++++++++++++++ qrspec.h | 14 +++++++++++++- tests/test_qrspec.c | 20 +++++++++++++++++++- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/qrspec.c b/qrspec.c index 88f5e722b9..11e651e9b7 100644 --- a/qrspec.c +++ b/qrspec.c @@ -365,6 +365,39 @@ unsigned int QRspec_getVersionPattern(int version) return versionPattern[version -7]; } +/****************************************************************************** + * Format information + *****************************************************************************/ + +/* See Table 22 (pp.45) and Appendix C (pp. 65) of JIS X0510:2004 */ +static unsigned int levelIndicator[4] = {1, 0, 3, 2}; + +unsigned int QRspec_getFormatInfo(int mask, QRenc_ErrorCorrectionLevel level) +{ + unsigned int data, ecc, b, code; + int i, c; + + data = (levelIndicator[level] << 13) | (mask << 10); + ecc = data; + b = 1 << 14; + for(i=0; b != 0; i++) { + if(ecc & b) break; + b = b >> 1; + } + c = 4 - i; + code = 0x537 << c ; //10100110111 + b = 1 << (10 + c); + for(i=0; i> 1; + b = b >> 1; + } + + return (data | ecc) ^ 0x5412; +} + /****************************************************************************** * Frame *****************************************************************************/ @@ -539,3 +572,7 @@ unsigned char *QRspec_newFrame(int version) return frame; } + +void QRspec_fillFormatInfo(unsigned char *frame, int version, int mask) +{ +} diff --git a/qrspec.h b/qrspec.h index 5717b55c12..69e481254b 100644 --- a/qrspec.h +++ b/qrspec.h @@ -126,10 +126,22 @@ extern void QRspec_freeAlignment(QRspec_Alignment *al); * Return BCH encoded version information pattern that is used for the symbol * of version 7 or greater. Use lower 18 bits. * @param version - * @return BCH coded version information pattern + * @return BCH encoded version information pattern */ extern unsigned int QRspec_getVersionPattern(int version); +/****************************************************************************** + * Format information + *****************************************************************************/ + +/** + * Return BCH encoded format information pattern. + * @param mask + * @param level + * @return BCH encoded format information pattern + */ +extern unsigned int QRspec_getFormatInfo(int mask, QRenc_ErrorCorrectionLevel level); + /****************************************************************************** * Frame *****************************************************************************/ diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index a0ab77f712..54fb2669e9 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -230,6 +230,23 @@ void print_newFrame(void) free(frame); } +void test_format(void) +{ + unsigned int format; + + testStart("Format info test (mask 101, LEVEL M)"); + format = QRspec_getFormatInfo(5, QR_EC_LEVEL_M); + testEndExp(format == 0x40ce); + + testStart("Format info test (mask 011, LEVEL H)"); + format = QRspec_getFormatInfo(3, QR_EC_LEVEL_H); + testEndExp(format == 0x19d0); + + testStart("Format info test (mask 000, LEVEL L)"); + format = QRspec_getFormatInfo(0, QR_EC_LEVEL_L); + testEndExp(format == 0x77c4); +} + int main(int argc, char **argv) { test_eccTable(); @@ -237,7 +254,8 @@ int main(int argc, char **argv) // print_eccTable(); test_alignment1(); test_verpat(); - print_newFrame(); +// print_newFrame(); + test_format(); report(); -- cgit 0.0.5-2-1-g0f52 From a099b0376838d4430ba5217aeb54a1eb74e4276a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 11 Nov 2006 15:40:22 +0000 Subject: --- qrspec.c | 34 ++++++++++------------------------ tests/test_qrspec.c | 52 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 51 insertions(+), 35 deletions(-) diff --git a/qrspec.c b/qrspec.c index 11e651e9b7..58c9d07e4b 100644 --- a/qrspec.c +++ b/qrspec.c @@ -369,33 +369,19 @@ unsigned int QRspec_getVersionPattern(int version) * Format information *****************************************************************************/ -/* See Table 22 (pp.45) and Appendix C (pp. 65) of JIS X0510:2004 */ -static unsigned int levelIndicator[4] = {1, 0, 3, 2}; +/* See calcFormatInfo in tests/test_qrspec.c */ +static unsigned int formatInfo[4][8] = { + {0x77c4, 0x73c4, 0x7daa, 0x79aa, 0x6318, 0x6318, 0x6976, 0x6976}, + {0x5412, 0x5012, 0x5e7c, 0x5a7c, 0x40ce, 0x40ce, 0x4aa0, 0x4aa0}, + {0x3068, 0x3068, 0x3a06, 0x3a06, 0x24b4, 0x20b4, 0x2eda, 0x2ada}, + {0x13be, 0x13be, 0x19d0, 0x19d0, 0x0762, 0x0362, 0x0d0c, 0x090c} +}; unsigned int QRspec_getFormatInfo(int mask, QRenc_ErrorCorrectionLevel level) { - unsigned int data, ecc, b, code; - int i, c; - - data = (levelIndicator[level] << 13) | (mask << 10); - ecc = data; - b = 1 << 14; - for(i=0; b != 0; i++) { - if(ecc & b) break; - b = b >> 1; - } - c = 4 - i; - code = 0x537 << c ; //10100110111 - b = 1 << (10 + c); - for(i=0; i> 1; - b = b >> 1; - } - - return (data | ecc) ^ 0x5412; + if(mask < 0 || mask > 7) return 0; + + return formatInfo[level][mask]; } /****************************************************************************** diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 54fb2669e9..23f4ed4456 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -230,21 +230,51 @@ void print_newFrame(void) free(frame); } -void test_format(void) +/* See Table 22 (pp.45) and Appendix C (pp. 65) of JIS X0510:2004 */ +static unsigned int levelIndicator[4] = {1, 0, 3, 2}; +static unsigned int calcFormatInfo(int mask, QRenc_ErrorCorrectionLevel level) { - unsigned int format; + unsigned int data, ecc, b, code; + int i, c; - testStart("Format info test (mask 101, LEVEL M)"); - format = QRspec_getFormatInfo(5, QR_EC_LEVEL_M); - testEndExp(format == 0x40ce); + data = (levelIndicator[level] << 13) | (mask << 10); + ecc = data; + b = 1 << 14; + for(i=0; b != 0; i++) { + if(ecc & b) break; + b = b >> 1; + } + c = 4 - i; + code = 0x537 << c ; //10100110111 + b = 1 << (10 + c); + for(i=0; i> 1; + b = b >> 1; + } + + return (data | ecc) ^ 0x5412; +} - testStart("Format info test (mask 011, LEVEL H)"); - format = QRspec_getFormatInfo(3, QR_EC_LEVEL_H); - testEndExp(format == 0x19d0); +void test_format(void) +{ + unsigned int format; + int i, j; + int err = 0; - testStart("Format info test (mask 000, LEVEL L)"); - format = QRspec_getFormatInfo(0, QR_EC_LEVEL_L); - testEndExp(format == 0x77c4); + testStart("Format info test"); + for(i=0; i<4; i++) { + for(j=0; j<8; j++) { + format = calcFormatInfo(j, i); + if(format != QRspec_getFormatInfo(j, i)) { + printf("Level %d, mask %x\n", i, j); + err++; + } + } + } + testEnd(err); } int main(int argc, char **argv) -- cgit 0.0.5-2-1-g0f52 From 60a913bf0ee3614829368ab5bcd35fde66758741 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 11 Nov 2006 18:59:58 +0000 Subject: --- bitstream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitstream.c b/bitstream.c index 82493b328c..4f0668ca42 100644 --- a/bitstream.c +++ b/bitstream.c @@ -178,9 +178,9 @@ unsigned char *BitStream_toByte(BitStream *bstream) } data[i] = v; } - if(size & 8) { + if(size & 7) { v = 0; - for(j=0; j<(size & 8); j++) { + for(j=0; j<(size & 7); j++) { v = v << 1; v |= *p == '1'; p++; -- cgit 0.0.5-2-1-g0f52 From cc939f5855df6572e1bdddb740457184d54a9943 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 11 Nov 2006 19:00:09 +0000 Subject: --- datastream.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datastream.c b/datastream.c index d4de57f3d2..e3fdad2a7a 100644 --- a/datastream.c +++ b/datastream.c @@ -635,7 +635,9 @@ static int QRenc_convertData(QRenc_DataStream *stream) int ver; ver = QRenc_estimateVersion(stream); - QRenc_setVersion(stream, ver); + if(ver > QRenc_getVersion(stream)) { + QRenc_setVersion(stream, ver); + } for(;;) { bits = QRenc_createBitStream(stream); -- cgit 0.0.5-2-1-g0f52 From 874cc6c35d7b51e475006efd4dab803e02abda3d Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 11 Nov 2006 19:14:57 +0000 Subject: --- qrencode.c | 41 +++++++++++++++++++++++++++++++++++++++++ qrtest.h | 7 +++++++ tests/Makefile.am | 5 ++++- tests/test_bitstream.c | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/qrencode.c b/qrencode.c index 9817bf19ed..b15d8531b6 100644 --- a/qrencode.c +++ b/qrencode.c @@ -43,6 +43,11 @@ typedef struct { unsigned char *datacode; int blocks; RSblock *rsblock; + int count; + int dataLength; + int eccLength; + int b1; + int b2; } QRRawCode; static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el) @@ -87,11 +92,47 @@ QRRawCode *QRraw_new(QRenc_DataStream *stream) rsblock++; } + raw->b1 = QRspec_rsBlockNum1(spec); + raw->b2 = QRspec_rsBlockNum2(spec); + raw->dataLength = QRspec_rsBlockNum1(spec) * QRspec_rsDataCodes1(spec) + + QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec); + raw->eccLength = QRspec_rsBlockNum(spec) * QRspec_rsEccCodes1(spec); + raw->count = 0; + free(spec); return raw; } +/** + * Return a code (byte). + * This function can be called iteratively. + * @param raw raw code. + * @return code + */ +unsigned char QRraw_getCode(QRRawCode *raw) +{ + int col, row; + unsigned char ret; + + if(raw->count < raw->dataLength) { + row = raw->count % raw->blocks; + col = raw->count / raw->blocks; + if(col >= raw->rsblock[row].dataLength) { + row += raw->b1; + } + ret = raw->rsblock[row].data[col]; + } else if(raw->count < raw->dataLength + raw->eccLength) { + row = (raw->count - raw->dataLength) % raw->blocks; + col = (raw->count - raw->dataLength) / raw->blocks; + ret = raw->rsblock[row].ecc[col]; + } else { + return 0; + } + raw->count++; + return ret; +} + void QRraw_free(QRRawCode *raw) { int i; diff --git a/qrtest.h b/qrtest.h index fa42e250e5..7bbcf12bab 100644 --- a/qrtest.h +++ b/qrtest.h @@ -25,6 +25,13 @@ typedef struct { unsigned char *datacode; int blocks; RSblock *rsblock; + int count; + int dataLength; + int eccLength; + int b1; + int b2; } QRRawCode; + extern QRRawCode *QRraw_new(QRenc_DataStream *stream); +extern unsigned char QRraw_getCode(QRRawCode *raw); extern void QRraw_free(QRRawCode *raw); diff --git a/tests/Makefile.am b/tests/Makefile.am index 71b6f65347..fb6c61b695 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,5 @@ noinst_PROGRAMS = test_datastream test_bitstream test_estimatebit \ - test_qrspec test_rs + test_qrspec test_rs test_qrencode test_datastream_SOURCES = test_datastream.c test_datastream_LDADD = ../libqrencode.la @@ -15,3 +15,6 @@ test_qrspec_LDADD = ../qrspec.o test_rs_SOURCES = test_rs.c test_rs_LDADD = ../libqrencode.la + +test_qrencode_SOURCES = test_qrencode.c +test_qrencode_LDADD = ../libqrencode.la diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 0959804093..2b0fbfb411 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -74,6 +74,7 @@ void test_toByte(void) testEnd(memcmp(correct, result, 7)); BitStream_free(bstream); + free(result); } int main(int argc, char **argv) -- cgit 0.0.5-2-1-g0f52 From 25b912694d79095fa8c8cd418465a7c195703a95 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sun, 12 Nov 2006 02:40:41 +0000 Subject: --- tests/test_qrencode.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 tests/test_qrencode.c diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c new file mode 100644 index 0000000000..070c12a6ea --- /dev/null +++ b/tests/test_qrencode.c @@ -0,0 +1,87 @@ +#include +#include +#include "common.h" +#include "../qrtest.h" + +void test_iterate() +{ + int i; + QRenc_DataStream *stream; + char num[9] = "01234567"; + unsigned char *data; + QRRawCode *raw; + int err = 0; + + testStart("Test getCode (1-L)"); + stream = QRenc_newData(); + QRenc_setVersion(stream, 1); + QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_L); + QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + + raw = QRraw_new(stream); + data = raw->datacode; + for(i=0; idataLength; i++) { + if(data[i] != QRraw_getCode(raw)) { + err++; + } + } + + QRenc_freeData(stream); + QRraw_free(raw); + testEnd(err); +} + +void test_iterate2() +{ + int i; + QRenc_DataStream *stream; + char num[9] = "01234567"; + QRRawCode *raw; + int err = 0; + unsigned char correct[] = { + 0x10, 0x11, 0xec, 0xec, 0x20, 0xec, 0x11, 0x11, + 0x0c, 0x11, 0xec, 0xec, 0x56, 0xec, 0x11, 0x11, + 0x61, 0x11, 0xec, 0xec, 0x80, 0xec, 0x11, 0x11, + 0xec, 0x11, 0xec, 0xec, 0x11, 0xec, 0x11, 0x11, + 0xec, 0x11, 0xec, 0xec, 0x11, 0xec, 0x11, 0x11, + 0xec, 0x11, 0xec, 0xec, 0x11, 0x11, + 0x5c, 0xde, 0x68, 0x68, 0x4d, 0xb3, 0xdb, 0xdb, + 0xd5, 0x14, 0xe1, 0xe1, 0x5b, 0x2a, 0x1f, 0x1f, + 0x49, 0xc4, 0x78, 0x78, 0xf7, 0xe0, 0x5b, 0x5b, + 0xc3, 0xa7, 0xc1, 0xc1, 0x5d, 0x9a, 0xea, 0xea, + 0x48, 0xad, 0x9d, 0x9d, 0x58, 0xb3, 0x3f, 0x3f, + 0x10, 0xdb, 0xbf, 0xbf, 0xeb, 0xec, 0x05, 0x05, + 0x98, 0x35, 0x83, 0x83, 0xa9, 0x95, 0xa6, 0xa6, + 0xea, 0x7b, 0x8d, 0x8d, 0x04, 0x3c, 0x08, 0x08, + 0x64, 0xce, 0x3e, 0x3e, 0x4d, 0x9b, 0x30, 0x30, + 0x4e, 0x65, 0xd6, 0xd6, 0xe4, 0x53, 0x2c, 0x2c, + 0x46, 0x1d, 0x2e, 0x2e, 0x29, 0x16, 0x27, 0x27 + }; + + testStart("Test getCode (5-H)"); + stream = QRenc_newData(); + QRenc_setVersion(stream, 5); + QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_H); + QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + + raw = QRraw_new(stream); + for(i=0; idataLength; i++) { + if(correct[i] != QRraw_getCode(raw)) { + err++; + } + } + + QRenc_freeData(stream); + QRraw_free(raw); + testEnd(err); +} + +int main(int argc, char **argv) +{ + test_iterate(); + test_iterate2(); + + report(); + + return 0; +} -- cgit 0.0.5-2-1-g0f52 From e32df131842086151b29c1f8bdddee50e0106edb Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sun, 12 Nov 2006 07:04:42 +0000 Subject: --- datastream.c | 28 +++--- qrencode.c | 241 ++++++++++++++++++++++++++++++++++++++++++++++++++ qrspec.c | 140 +++++++++++++++-------------- qrspec.h | 24 ++++- qrtest.h | 4 + tests/test_qrencode.c | 84 ++++++++++++++++++ 6 files changed, 442 insertions(+), 79 deletions(-) diff --git a/datastream.c b/datastream.c index e3fdad2a7a..5a32583491 100644 --- a/datastream.c +++ b/datastream.c @@ -77,6 +77,19 @@ static QRenc_List *QRenc_freeEntry(QRenc_List *entry) * Input Data stream *****************************************************************************/ +QRenc_DataStream *QRenc_newData(void) +{ + QRenc_DataStream *stream; + + stream = (QRenc_DataStream *)malloc(sizeof(QRenc_DataStream)); + stream->head = NULL; + stream->tail = NULL; + stream->version = 0; + stream->level = QR_EC_LEVEL_L; + + return stream; +} + int QRenc_getVersion(QRenc_DataStream *stream) { return stream->version; @@ -97,19 +110,6 @@ QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(QRenc_DataStream *strea return stream->level; } -QRenc_DataStream *QRenc_newData(void) -{ - QRenc_DataStream *stream; - - stream = (QRenc_DataStream *)malloc(sizeof(QRenc_DataStream)); - stream->head = NULL; - stream->tail = NULL; - stream->version = 0; - stream->level = QR_EC_LEVEL_L; - - return stream; -} - int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, unsigned char *data) { QRenc_List *entry; @@ -668,7 +668,7 @@ static BitStream *QRenc_createPaddingBit(QRenc_DataStream *stream) if(stream->version <= 0) return NULL; - maxwords = QRspec_getMaximumCodeLength(stream->version, stream->level); + maxwords = QRspec_getDataLength(stream->version, stream->level); maxbits = maxwords * 8; list = stream->head; diff --git a/qrencode.c b/qrencode.c index b15d8531b6..c8b5f03f02 100644 --- a/qrencode.c +++ b/qrencode.c @@ -144,3 +144,244 @@ void QRraw_free(QRRawCode *raw) free(raw->rsblock); free(raw); } + +/****************************************************************************** + * Frame filling + *****************************************************************************/ + +typedef struct { + int width; + unsigned char *frame; + int x, y; + int dir; + int bit; +} FrameFiller; + +static FrameFiller *FrameFiller_new(int width, unsigned char *frame) +{ + FrameFiller *filler; + + filler = (FrameFiller *)malloc(sizeof(FrameFiller)); + filler->width = width; + filler->frame = frame; + filler->x = width - 1; + filler->y = width - 1; + filler->dir = -1; + filler->bit = -1; + + return filler; +} + +static unsigned char *FrameFiller_next(FrameFiller *filler) +{ + unsigned char *p; + int x, y, w; + + if(filler->bit == -1) { + filler->bit = 0; + return filler->frame + filler->y * filler->width + filler->x; + } + + x = filler->x; + y = filler->y; + p = filler->frame; + w = filler->width; + + if(filler->bit == 0) { + x--; + filler->bit++; + } else { + x++; + y += filler->dir; + filler->bit--; + } + + if(filler->dir < 0) { + if(y < 0) { + y = 0; + x -= 2; + filler->dir = 1; + if(x == 6) { + x--; + y = 9; + } + } + } else { + if(y == w) { + y = w - 1; + x -= 2; + filler->dir = -1; + if(x == 6) { + x--; + y -= 8; + } + } + } + if(x < 0 || y < 0) return NULL; + + filler->x = x; + filler->y = y; + + if(p[y * w + x] & 0x80) { + // This tail recursion could be optimized. + return FrameFiller_next(filler); + } + return &p[y * w + x]; +} + +unsigned char *QRenc_fillerTest(int version) +{ + int width, length; + unsigned char *frame, *p; + FrameFiller *filler; + int i, j; + unsigned char cl = 1; + unsigned char ch = 0; + + width = QRspec_getWidth(version); + frame = QRspec_newFrame(version); + filler = FrameFiller_new(width, frame); + length = QRspec_getDataLength(version, QR_EC_LEVEL_L) + + QRspec_getECCLength(version, QR_EC_LEVEL_L); + + for(i=0; idataLength; i++) { + code = QRraw_getCode(raw); + mask = 0x80; + for(j=0; j<8; j++) { + p = FrameFiller_next(filler); + *p = 0xa0 | ((mask & code) != 0); + mask = mask >> 1; + } + } + /* remainder bits */ + j = QRspec_getRemainder(version); + for(i=0; i> 1; } } @@ -530,14 +542,14 @@ static unsigned char *QRspec_createFrame(int version) mask = 0x200; for(y=0; y<6; y++) { for(x=0; x<3; x++) { - p[x] = 0x80 | ((mask & verinfo) != 0); + p[x] = 0xc0 | ((mask & verinfo) != 0); mask = mask >> 1; } p += width; } } /* and a little bit... */ - frame[width * (width - 8) + 8] = 0x81; + frame[width * (width - 8) + 8] = 0xc1; return frame; } diff --git a/qrspec.h b/qrspec.h index 69e481254b..4ab1f2802d 100644 --- a/qrspec.h +++ b/qrspec.h @@ -38,7 +38,15 @@ * @param level * @return maximum size (bytes) */ -extern int QRspec_getMaximumCodeLength(int version, QRenc_ErrorCorrectionLevel level); +extern int QRspec_getDataLength(int version, QRenc_ErrorCorrectionLevel level); + +/** + * Return maximum error correction code length (bytes) for the version. + * @param version + * @param level + * @return ECC size (bytes) + */ +extern int QRspec_getECCLength(int version, QRenc_ErrorCorrectionLevel level); /** * Return a version number that satisfies the input code length. @@ -48,6 +56,20 @@ extern int QRspec_getMaximumCodeLength(int version, QRenc_ErrorCorrectionLevel l */ extern int QRspec_getMinimumVersion(int size, QRenc_ErrorCorrectionLevel level); +/** + * Return the width of the symbol for the version. + * @param version + * @return width + */ +extern int QRspec_getWidth(int version); + +/** + * Return the numer of remainder bits. + * @param version + * @return number of remainder bits + */ +extern int QRspec_getRemainder(int version); + /****************************************************************************** * Length indicator *****************************************************************************/ diff --git a/qrtest.h b/qrtest.h index 7bbcf12bab..5c0e0c9f09 100644 --- a/qrtest.h +++ b/qrtest.h @@ -4,6 +4,7 @@ typedef struct { int width; //< Edge length of the symbol int words; //< Data capacity (bytes) + int remainder; //< Remainder bit (bits) int ec[4]; } QRspec_Capacity; @@ -35,3 +36,6 @@ typedef struct { extern QRRawCode *QRraw_new(QRenc_DataStream *stream); extern unsigned char QRraw_getCode(QRRawCode *raw); extern void QRraw_free(QRRawCode *raw); + +unsigned char *QRenc_fillerTest(int version); +unsigned char *QRenc_mask(int width, unsigned char *frame, int mask); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 070c12a6ea..5f2ec88d44 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -1,6 +1,7 @@ #include #include #include "common.h" +#include "../qrspec.h" #include "../qrtest.h" void test_iterate() @@ -76,10 +77,93 @@ void test_iterate2() testEnd(err); } +void print_filler(void) +{ + int width; + int x, y; + int version = 5; + unsigned char *frame; + + width = QRspec_getWidth(version); + frame = QRenc_fillerTest(version); + + for(y=0; y Date: Mon, 13 Nov 2006 10:14:29 +0000 Subject: --- Makefile.am | 3 +- datastream.h | 4 +++ qrencode.c | 74 ++++++++++++++++++++++++++++++------------------ qrencode_inner.h | 63 +++++++++++++++++++++++++++++++++++++++++ qrtest.h | 41 --------------------------- tests/test_datastream.c | 3 +- tests/test_estimatebit.c | 3 +- tests/test_qrencode.c | 2 +- tests/test_qrspec.c | 7 ++--- tests/test_rs.c | 2 +- 10 files changed, 124 insertions(+), 78 deletions(-) create mode 100644 qrencode_inner.h delete mode 100644 qrtest.h diff --git a/Makefile.am b/Makefile.am index 1a4fb4f224..6d7f0288ce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,8 @@ SUBDIRS = . tests lib_LTLIBRARIES = libqrencode.la libqrencode_la_SOURCES = qrencode.c datastream.c bitstream.c qrspec.c rscode.c -libqrencode_la_headers = qrencode.h datastream.h bitstream.h qrspec.h rscode.h +libqrencode_la_headers = qrencode.h qrencode_inner.h datastream.h bitstream.h \ + qrspec.h rscode.h libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) pkginclude_HEADERS = qrencode.h diff --git a/datastream.h b/datastream.h index 66cd93d936..9b210120c2 100644 --- a/datastream.h +++ b/datastream.h @@ -46,4 +46,8 @@ struct _QRenc_DataStream { */ extern unsigned char *QRenc_getByteStream(QRenc_DataStream *stream); +extern int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); +extern BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream); +extern BitStream *QRenc_getBitStream(QRenc_DataStream *stream); + #endif /* __DATASTREAM_H__ */ diff --git a/qrencode.c b/qrencode.c index c8b5f03f02..1c344a307d 100644 --- a/qrencode.c +++ b/qrencode.c @@ -22,8 +22,10 @@ #include #include #include +#include #include "qrencode.h" +#include "qrencode_inner.h" #include "qrspec.h" #include "bitstream.h" #include "datastream.h" @@ -32,23 +34,6 @@ /****************************************************************************** * Raw code *****************************************************************************/ -typedef struct { - int dataLength; - unsigned char *data; - int eccLength; - unsigned char *ecc; -} RSblock; - -typedef struct { - unsigned char *datacode; - int blocks; - RSblock *rsblock; - int count; - int dataLength; - int eccLength; - int b1; - int b2; -} QRRawCode; static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el) { @@ -270,11 +255,21 @@ unsigned char *QRenc_fillerTest(int version) } /****************************************************************************** - * Mask + * Masking *****************************************************************************/ +/** + * Demerit coefficients. + * See Section 8.8.2, pp.45, JIS X0510:2004. + */ +#define N1 (3) +#define N2 (3) +#define N3 (40) +#define N4 (10) + #define MASKMAKER(__exp__) \ int x, y;\ + unsigned int b = 0;\ \ for(y=0; y minDemerit) + continue; + + } +} + /****************************************************************************** * QR-code encoding *****************************************************************************/ diff --git a/qrencode_inner.h b/qrencode_inner.h new file mode 100644 index 0000000000..62e4fb97f9 --- /dev/null +++ b/qrencode_inner.h @@ -0,0 +1,63 @@ +/** + * qrencode - QR-code encoder + * + * Copyright (C) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __QRENCODE_INNER_H__ +#define __QRENCODE_INNER_H__ + +/** + * This header file includes definitions for inner use. + */ + +/****************************************************************************** + * Raw code + *****************************************************************************/ +typedef struct { + int dataLength; + unsigned char *data; + int eccLength; + unsigned char *ecc; +} RSblock; + +typedef struct { + unsigned char *datacode; + int blocks; + RSblock *rsblock; + int count; + int dataLength; + int eccLength; + int b1; + int b2; +} QRRawCode; + +extern QRRawCode *QRraw_new(QRenc_DataStream *stream); +extern unsigned char QRraw_getCode(QRRawCode *raw); +extern void QRraw_free(QRRawCode *raw); + +/****************************************************************************** + * Frame filling + *****************************************************************************/ +extern unsigned char *QRenc_fillerTest(int version); + +/****************************************************************************** + * Masking + *****************************************************************************/ +extern unsigned char *QRenc_mask(int width, unsigned char *frame, int mask); + +#endif /* __QRENCODE_INNER_H__ */ diff --git a/qrtest.h b/qrtest.h deleted file mode 100644 index 5c0e0c9f09..0000000000 --- a/qrtest.h +++ /dev/null @@ -1,41 +0,0 @@ -#include "qrencode.h" -#include "bitstream.h" - -typedef struct { - int width; //< Edge length of the symbol - int words; //< Data capacity (bytes) - int remainder; //< Remainder bit (bits) - int ec[4]; -} QRspec_Capacity; - -extern QRspec_Capacity qrspecCapacity[]; - - -extern int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); -extern BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream); -extern BitStream *QRenc_getBitStream(QRenc_DataStream *stream); - -typedef struct { - int dataLength; - unsigned char *data; - int eccLength; - unsigned char *ecc; -} RSblock; - -typedef struct { - unsigned char *datacode; - int blocks; - RSblock *rsblock; - int count; - int dataLength; - int eccLength; - int b1; - int b2; -} QRRawCode; - -extern QRRawCode *QRraw_new(QRenc_DataStream *stream); -extern unsigned char QRraw_getCode(QRRawCode *raw); -extern void QRraw_free(QRRawCode *raw); - -unsigned char *QRenc_fillerTest(int version); -unsigned char *QRenc_mask(int width, unsigned char *frame, int mask); diff --git a/tests/test_datastream.c b/tests/test_datastream.c index 9d4152cbfd..d76256ef48 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -1,7 +1,8 @@ #include #include #include "common.h" -#include "../qrtest.h" +#include "../datastream.h" +#include "../qrencode_inner.h" void test_encodeKanji(void) { diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index bc1217bf30..b002a4da23 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -2,7 +2,8 @@ #include #include #include "common.h" -#include "../qrtest.h" +#include "../datastream.h" +#include "../qrencode_inner.h" QRenc_DataStream *gstream; diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 5f2ec88d44..bf0657dc72 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -1,8 +1,8 @@ #include #include #include "common.h" +#include "../qrencode_inner.h" #include "../qrspec.h" -#include "../qrtest.h" void test_iterate() { diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 23f4ed4456..2ae5383959 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -2,7 +2,6 @@ #include #include "common.h" #include "../qrspec.h" -#include "../qrtest.h" void print_eccTable(void) { @@ -43,12 +42,12 @@ void test_eccTable(void) bl = QRspec_getEccSpec(i, j); data = bl[0] * bl[1] + bl[3] * bl[4]; ecc = bl[0] * bl[2] + bl[3] * bl[5]; - if(qrspecCapacity[i].words != data + ecc) { + if(data + ecc != QRspec_getDataLength(i, j) + QRspec_getECCLength(i, j)) { printf("Error in version %d, level %d: invalid size\n", i, j); printf("%d %d %d %d %d %d\n", bl[0], bl[1], bl[2], bl[3], bl[4], bl[5]); err++; } - if(qrspecCapacity[i].ec[j] != ecc) { + if(ecc != QRspec_getECCLength(i, j)) { printf("Error in version %d, level %d: invalid data\n", i, j); printf("%d %d %d %d %d %d\n", bl[0], bl[1], bl[2], bl[3], bl[4], bl[5]); err++; @@ -220,7 +219,7 @@ void print_newFrame(void) unsigned char *frame; frame = QRspec_newFrame(7); - width = qrspecCapacity[7].width; + width = QRspec_getWidth(7); for(y=0; y #include #include "common.h" -#include "../qrtest.h" +#include "../qrencode_inner.h" /* See pp. 73 of JIS X0510:2004 */ void test_rscode1(void) -- cgit 0.0.5-2-1-g0f52 From e608ef3b6fe6c10e4c2587a36c4aa5f90b529e43 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 14 Nov 2006 00:48:45 +0000 Subject: --- qrencode.c | 40 +++++++++++++++++++++++++++++++++++++++- qrencode_inner.h | 5 +++++ tests/test_qrencode.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/qrencode.c b/qrencode.c index 1c344a307d..d35721f8c2 100644 --- a/qrencode.c +++ b/qrencode.c @@ -254,6 +254,40 @@ unsigned char *QRenc_fillerTest(int version) return frame; } +/****************************************************************************** + * Format information + *****************************************************************************/ + +void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRenc_ErrorCorrectionLevel level) +{ + unsigned int format; + unsigned char v; + int i; + + format = QRspec_getFormatInfo(mask, level); + + for(i=0; i<8; i++) { + v = (unsigned char)(format & 1); + frame[width * 8 + width - 1 - i] = v; + if(i < 6) { + frame[width * i + 8] = v; + } else { + frame[width * (i + 1) + 8] = v; + } + format= format >> 1; + } + for(i=0; i<7; i++) { + v = (unsigned char)(format & 1); + frame[width * (width - 7 + i) + 8] = v; + if(i == 0) { + frame[width * 8 + 7] = v; + } else { + frame[width * 8 + 6 - i] = v; + } + format= format >> 1; + } +} + /****************************************************************************** * Masking *****************************************************************************/ @@ -283,6 +317,7 @@ unsigned char *QRenc_fillerTest(int version) }\ }\ return b; +/* FIXME: this frame lacks format information */ static int QRenc_mask0(int width, const unsigned char *s, unsigned char *d) { @@ -341,6 +376,10 @@ unsigned char *QRenc_mask(int width, unsigned char *frame, int mask) return masked; } +static int QRenc_evaluateN2(int width, unsigned char *frame) +{ +} + unsigned int QRenc_evaluateSymbol(int width, unsigned char *frame) { int i; @@ -399,7 +438,6 @@ unsigned char *QRenc_encode(QRenc_DataStream *stream) } free(filler); /* masking */ - /* put format information */ return frame; } diff --git a/qrencode_inner.h b/qrencode_inner.h index 62e4fb97f9..878b365105 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -55,6 +55,11 @@ extern void QRraw_free(QRRawCode *raw); *****************************************************************************/ extern unsigned char *QRenc_fillerTest(int version); +/****************************************************************************** + * Format information + *****************************************************************************/ +extern void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRenc_ErrorCorrectionLevel level); + /****************************************************************************** * Masking *****************************************************************************/ diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index bf0657dc72..f99fcf5707 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -157,6 +157,54 @@ void print_mask(void) free(frame); } +void test_format(void) +{ + unsigned char *frame; + unsigned int format; + int width; + int i; + unsigned int decode; + + testStart("Test format information(level L,mask 0)"); + width = QRspec_getWidth(1); + frame = QRspec_newFrame(1); + format = QRspec_getFormatInfo(1, QR_EC_LEVEL_L); + QRenc_writeFormatInformation(width, frame, 1, QR_EC_LEVEL_L); + decode = 0; + for(i=0; i<8; i++) { + decode = decode << 1; + decode |= frame[width * 8 + i + (i > 5)] & 1; + } + for(i=0; i<7; i++) { + decode = decode << 1; + decode |= frame[width * ((6 - i) + (i < 1)) + 8] & 1; + } + if(decode != format) { + printf("Upper-left format information is invalid.\n"); + printf("%08x, %08x\n", format, decode); + testEnd(1); + return; + } + decode = 0; + for(i=0; i<7; i++) { + decode = decode << 1; + decode |= frame[width * (width - 1 - i) + 8] & 1; + } + for(i=0; i<8; i++) { + decode = decode << 1; + decode |= frame[width * 8 + width - 8 + i] & 1; + } + if(decode != format) { + printf("Bottom and right format information is invalid.\n"); + printf("%08x, %08x\n", format, decode); + testEnd(1); + return; + } + + + testEnd(0); +} + int main(int argc, char **argv) { test_iterate(); @@ -164,6 +212,7 @@ int main(int argc, char **argv) // print_filler(); test_filler(); // print_mask(); + test_format(); report(); -- cgit 0.0.5-2-1-g0f52 From 5cc550f754eb3fd8c7002006e57df02b9addfcd3 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 15 Nov 2006 13:18:49 +0000 Subject: --- configure.ac | 12 +++-- qrencode.c | 147 ++++++++++++++++++++++++++++++++++++++++++++------ qrencode.h | 1 + qrencode_inner.h | 3 +- qrspec.h | 5 ++ tests/Makefile.am | 6 ++- tests/test_qrencode.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 293 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index 5519702244..db0a250768 100644 --- a/configure.ac +++ b/configure.ac @@ -29,8 +29,13 @@ AC_PROG_INSTALL AC_DISABLE_STATIC AC_PROG_LIBTOOL -CFLAGS="-Wall $CFLAGS $GLIB_CFLAGS $SDL_CFLAGS" -LDFLAGS="$LIBS $GLIB_LIBS $SDL_LIBS" +SDL_REQUIRED_VERSION=1.2.0 +AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_ERROR([*** SDL $SDL_REQUIRED_VERSION or better is required.])) +AC_SUBST(SDL_LIBS) +AC_SUBST(SDL_CFLAGS) + +CFLAGS="-Wall $CFLAGS" +dnl LDFLAGS="$LDFLAGS" AC_HEADER_STDC @@ -38,9 +43,6 @@ AC_C_CONST AC_C_INLINE AC_PROG_GCC_TRADITIONAL -AC_FUNC_MALLOC -AC_FUNC_STAT -AC_CHECK_FUNCS([atexit memset strdup]) AC_CONFIG_FILES([Makefile tests/Makefile]) diff --git a/qrencode.c b/qrencode.c index d35721f8c2..877bc05fb9 100644 --- a/qrencode.c +++ b/qrencode.c @@ -317,7 +317,6 @@ void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRe }\ }\ return b; -/* FIXME: this frame lacks format information */ static int QRenc_mask0(int width, const unsigned char *s, unsigned char *d) { @@ -365,7 +364,7 @@ static MaskMaker *maskMakers[] = { QRenc_mask4, QRenc_mask5, QRenc_mask6, QRenc_mask7 }; -unsigned char *QRenc_mask(int width, unsigned char *frame, int mask) +unsigned char *QRenc_makeMask(int width, unsigned char *frame, int mask) { unsigned char *masked; @@ -376,41 +375,155 @@ unsigned char *QRenc_mask(int width, unsigned char *frame, int mask) return masked; } -static int QRenc_evaluateN2(int width, unsigned char *frame) +static int runLength[QRSPEC_WIDTH_MAX + 1]; + +static int QRenC_calcN1N3(int length, int *runLength) +{ + int i; + int demerit = 0; + int fact; + + for(i=0; i= 5) { + demerit += N1 + (runLength[i] - 5); + } + if((i & 1)) { + if(i >= 3 && i < length-2 && (runLength[i] % 3) == 0) { + fact = runLength[i] / 3; + if(runLength[i-2] == fact && + runLength[i-1] == fact && + runLength[i+1] == fact && + runLength[i+2] == fact) { + if(runLength[i-3] < 0 || runLength[i-3] >= 4 * fact) { + demerit += N3; + } else if(i+3 >= length || runLength[i+3] >= 4 * fact) { + demerit += N3; + } + } + } + } + } + + return demerit; +} + +int QRenc_evaluateSymbol(int width, unsigned char *frame) { + int x, y; + unsigned char *p; + unsigned char b22, w22; + unsigned int i; + int head; + int demerit = 0; + + p = frame; + i = 0; + for(y=0; y 0 && y > 0) { + b22 = p[0] & p[-1] & p[-width] & p [-width-1] & 1; + w22 = (p[0] | p[-1] | p[-width] | p [-width-1] ) & 1; + if(b22 | (w22 ^ 1)) { + demerit += N2; + } + } + if(x == 0 && (p[0] & 1)) { + runLength[0] = -1; + head = 1; + runLength[head] = 1; + } else if(x > 0) { + if((p[0] ^ p[-1]) & 1) { + head++; + runLength[head] = 1; + } else { + runLength[head]++; + } + } + p++; + } + demerit += QRenC_calcN1N3(head+1, runLength); + } + + i = 0; + for(x=0; x 0) { + if((p[0] ^ p[-width]) & 1) { + head++; + runLength[head] = 1; + } else { + runLength[head]++; + } + } + p+=width; + } + demerit += QRenC_calcN1N3(head+1, runLength); + } + + return demerit; } -unsigned int QRenc_evaluateSymbol(int width, unsigned char *frame) +static unsigned char *QRenc_mask(int width, unsigned char *frame, QRenc_ErrorCorrectionLevel level) { int i; - unsigned char *mask[8]; + unsigned char *mask, *bestMask; int minDemerit = INT_MAX; - int minMask; + int bestMaskNum = 0; int blacks; int demerit; + bestMask = NULL; + for(i=0; i<8; i++) { demerit = 0; - mask[i] = (unsigned char *)malloc(width * width); - blacks = maskMakers[i](width, frame, mask[i]); + mask = (unsigned char *)malloc(width * width); + blacks = maskMakers[i](width, frame, mask); blacks = 100 * blacks / (width * width); demerit = (abs(blacks - 50) / 5) * N4; if(demerit > minDemerit) continue; - + demerit += QRenc_evaluateSymbol(width, mask); + if(demerit < minDemerit) { + minDemerit = demerit; + bestMaskNum = i; + if(bestMask != NULL) { + free(bestMask); + } + bestMask = mask; + } else { + free(mask); + } } + + QRenc_writeFormatInformation(width, bestMask, bestMaskNum, level); + + return bestMask; } /****************************************************************************** * QR-code encoding *****************************************************************************/ +int QRenc_getWidth(QRenc_DataStream *stream) +{ + return QRspec_getWidth(QRenc_getVersion(stream)); +} + unsigned char *QRenc_encode(QRenc_DataStream *stream) { int version; int width; QRRawCode *raw; - unsigned char *frame, *p, code, mask; + unsigned char *frame, *masked, *p, code, bit; FrameFiller *filler; int i, j; @@ -421,15 +534,16 @@ unsigned char *QRenc_encode(QRenc_DataStream *stream) filler = FrameFiller_new(width, frame); /* inteleaved data and ecc codes */ - for(i=0; idataLength; i++) { + for(i=0; idataLength + raw->eccLength; i++) { code = QRraw_getCode(raw); - mask = 0x80; + bit = 0x80; for(j=0; j<8; j++) { p = FrameFiller_next(filler); - *p = 0xa0 | ((mask & code) != 0); - mask = mask >> 1; + *p = 0xa0 | ((bit & code) != 0); + bit = bit >> 1; } } + QRraw_free(raw); /* remainder bits */ j = QRspec_getRemainder(version); for(i=0; i Date: Wed, 15 Nov 2006 13:53:18 +0000 Subject: --- configure.ac | 3 +-- tests/Makefile.am | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index db0a250768..6e5c16ec8e 100644 --- a/configure.ac +++ b/configure.ac @@ -31,8 +31,7 @@ AC_PROG_LIBTOOL SDL_REQUIRED_VERSION=1.2.0 AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_ERROR([*** SDL $SDL_REQUIRED_VERSION or better is required.])) -AC_SUBST(SDL_LIBS) -AC_SUBST(SDL_CFLAGS) +AM_CONDITIONAL(HAVE_SDL, test SDL_CFLAGS) CFLAGS="-Wall $CFLAGS" dnl LDFLAGS="$LDFLAGS" diff --git a/tests/Makefile.am b/tests/Makefile.am index b8d2ae1528..8e8f988b51 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,8 @@ +if HAVE_SDL +sdlPROGRAMS = view_qrcode +endif noinst_PROGRAMS = test_datastream test_bitstream test_estimatebit \ - test_qrspec test_rs test_qrencode view_qrcode + test_qrspec test_rs test_qrencode $(sdlPROGRAMS) test_datastream_SOURCES = test_datastream.c test_datastream_LDADD = ../libqrencode.la @@ -19,6 +22,8 @@ test_rs_LDADD = ../libqrencode.la test_qrencode_SOURCES = test_qrencode.c test_qrencode_LDADD = ../libqrencode.la +if HAVE_SDL view_qrcode_SOURCES = view_qrcode.c view_qrcode_CFLAGS= $(SDL_CFLAGS) view_qrcode_LDADD = ../libqrencode.la $(SDL_LIBS) +endif -- cgit 0.0.5-2-1-g0f52 From f09f4bab21817275068194956580aa055d442b5a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 15 Nov 2006 21:53:00 +0000 Subject: --- autogen.sh | 4 +++ tests/view_qrcode.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 tests/view_qrcode.c diff --git a/autogen.sh b/autogen.sh index 2956c78e2f..314a7cd5a6 100755 --- a/autogen.sh +++ b/autogen.sh @@ -9,6 +9,10 @@ else if [ -d /usr/share/aclocal ]; then fi fi +if [ ! -d use]; then + mkdir use +fi + aclocal -I $ACLOCAL_DIR libtoolize --automake #--copy diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c new file mode 100644 index 0000000000..179f78abd1 --- /dev/null +++ b/tests/view_qrcode.c @@ -0,0 +1,91 @@ +#include +#include +#include +#include "common.h" +#include "../qrencode_inner.h" +#include "../qrspec.h" + +SDL_Surface *screen = NULL; +#define WIDTH 400 + +int eventloop(void) +{ + SDL_Event event; + int q = 1; + + while(q) { + while(SDL_PollEvent(&event)) { + if(event.type == SDL_KEYDOWN) { + switch(event.key.keysym.sym) { + case SDLK_SPACE: + q = 0; + break; + case SDLK_ESCAPE: + q = 0; + break; + default: + break; + } + } + if(event.type == SDL_QUIT) { + return -1; + } + } + } + + return 0; +} + +void view_simple(void) +{ + QRenc_DataStream *stream; + char num[9] = "01234567"; + unsigned char *frame, *q; + unsigned int v, *p1, *p2; + int width; + int x, y; + int ox; + int pitch; + + stream = QRenc_newData(); + QRenc_setVersion(stream, 1); + QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_L); + QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + frame = QRenc_encode(stream); + width = QRenc_getWidth(stream); + QRenc_freeData(stream); + pitch = screen->pitch; + q = frame; + SDL_FillRect(screen, NULL, 0xffffff); + for(y=0; ypixels + pitch * (y + 4) * 2 + 32); + p2 = (unsigned int *)(screen->pixels + pitch * ((y + 4) * 2 + 1) + 32); + for(x=0; x Date: Wed, 15 Nov 2006 21:53:33 +0000 Subject: --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index 314a7cd5a6..c2d8b2d83b 100755 --- a/autogen.sh +++ b/autogen.sh @@ -9,7 +9,7 @@ else if [ -d /usr/share/aclocal ]; then fi fi -if [ ! -d use]; then +if [ ! -d use ]; then mkdir use fi -- cgit 0.0.5-2-1-g0f52 -- cgit 0.0.5-2-1-g0f52 From c465ac7003772ee03e61d97d4ea30357e1a889aa Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 16 Nov 2006 03:08:02 +0000 Subject: --- qrencode.c | 26 +++++++++++++++++++++---- qrencode.h | 54 ++++++++++++++++++++++++++++++++------------------- tests/test_qrencode.c | 6 ++++-- tests/view_qrcode.c | 7 ++++--- 4 files changed, 64 insertions(+), 29 deletions(-) diff --git a/qrencode.c b/qrencode.c index 877bc05fb9..4f1b32acce 100644 --- a/qrencode.c +++ b/qrencode.c @@ -513,12 +513,28 @@ static unsigned char *QRenc_mask(int width, unsigned char *frame, QRenc_ErrorCor * QR-code encoding *****************************************************************************/ -int QRenc_getWidth(QRenc_DataStream *stream) +static QRcode *QRenc_newQRcode(int width, unsigned char *data) { - return QRspec_getWidth(QRenc_getVersion(stream)); + QRcode *qrcode; + + qrcode = (QRcode *)malloc(sizeof(QRcode)); + qrcode->width = width; + qrcode->data = data; + + return qrcode; +} + +void QRenc_freeQRcode(QRcode *qrcode) +{ + if(qrcode == NULL) return; + + if(qrcode->data != NULL) { + free(qrcode->data); + } + free(qrcode); } -unsigned char *QRenc_encode(QRenc_DataStream *stream) +QRcode *QRenc_encode(QRenc_DataStream *stream) { int version; int width; @@ -526,6 +542,7 @@ unsigned char *QRenc_encode(QRenc_DataStream *stream) unsigned char *frame, *masked, *p, code, bit; FrameFiller *filler; int i, j; + QRcode *qrcode; version = QRenc_getVersion(stream); width = QRspec_getWidth(version); @@ -553,8 +570,9 @@ unsigned char *QRenc_encode(QRenc_DataStream *stream) free(filler); /* masking */ masked = QRenc_mask(width, frame, QRenc_getErrorCorrectionLevel(stream)); + qrcode = QRenc_newQRcode(width, masked); free(frame); - return masked; + return qrcode; } diff --git a/qrencode.h b/qrencode.h index d957f7b18b..43ed47ab26 100644 --- a/qrencode.h +++ b/qrencode.h @@ -21,10 +21,6 @@ #ifndef __QRENCODE_H__ #define __QRENCODE_H__ -/****************************************************************************** - * Encoding mode - *****************************************************************************/ - /** * Encoding mode. */ @@ -35,6 +31,16 @@ typedef enum { QR_MODE_KANJI ///< Kanji (shift-jis) mode } QRenc_EncodeMode; +/** + * Level of error correction. + */ +typedef enum { + QR_EC_LEVEL_L = 0, + QR_EC_LEVEL_M, + QR_EC_LEVEL_Q, + QR_EC_LEVEL_H +} QRenc_ErrorCorrectionLevel; + /****************************************************************************** * Input data stream *****************************************************************************/ @@ -45,14 +51,10 @@ typedef enum { typedef struct _QRenc_DataStream QRenc_DataStream; /** - * Level of error correction. + * Instantiate a data stream object. + * @return Stream object (initialized). */ -typedef enum { - QR_EC_LEVEL_L = 0, - QR_EC_LEVEL_M, - QR_EC_LEVEL_Q, - QR_EC_LEVEL_H -} QRenc_ErrorCorrectionLevel; +extern QRenc_DataStream *QRenc_newData(void); /** * Get current error correction level. @@ -82,13 +84,6 @@ extern int QRenc_getVersion(QRenc_DataStream *stream); */ extern void QRenc_setVersion(QRenc_DataStream *stream, int version); - -/** - * Instantiate a data stream object. - * @return Stream object (initialized). - */ -extern QRenc_DataStream *QRenc_newData(void); - /** * Append data to the stream object. * The data is copied and appended to the stream object. @@ -119,7 +114,26 @@ extern int QRenc_checkData(QRenc_EncodeMode mode, int size, const unsigned char /****************************************************************************** * QRcode output *****************************************************************************/ -extern int QRenc_getWidth(QRenc_DataStream *stream); -extern unsigned char *QRenc_encode(QRenc_DataStream *stream); + +/** + * QRcode class. + */ +typedef struct { + int width; //< width of the symbol + unsigned char *data; //< symbol data +} QRcode; + +/** + * Create a symbol from the input data stream. + * @param stream input data stream. + * @return an instance of QRcode class. + */ +extern QRcode *QRenc_encode(QRenc_DataStream *stream); + +/** + * Free the instance of QRcode class. + * @param qrcode an instance of QRcode class. + */ +extern void QRenc_freeQRcode(QRcode *qrcode); #endif /* __QRENCODE_H__ */ diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index d04468566a..ea02f789a8 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -318,14 +318,16 @@ void test_encode(void) unsigned char *frame; int err = 0; int x, y, w; + QRcode *qrcode; testStart("Test encode (1-L)"); stream = QRenc_newData(); QRenc_setVersion(stream, 1); QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_L); QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); - frame = QRenc_encode(stream); - w = QRenc_getWidth(stream); + qrcode = QRenc_encode(stream); + w = qrcode->width; + frame = qrcode->data; for(y=0; ywidth; + frame = qrcode->data; QRenc_freeData(stream); pitch = screen->pitch; q = frame; -- cgit 0.0.5-2-1-g0f52 From 8c5c6a0270596ef4979ffd32e419bbb43bc9145e Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 16 Nov 2006 03:10:02 +0000 Subject: --- tests/test_qrencode.c | 2 +- tests/view_qrcode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index ea02f789a8..8188b4a9ec 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -340,7 +340,7 @@ void test_encode(void) } testEnd(err); QRenc_freeData(stream); - free(frame); + QRenc_freeQRcode(qrcode); } int main(int argc, char **argv) diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 5a9a787363..5f28e1df91 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -74,7 +74,7 @@ void view_simple(void) eventloop(); - free(frame); + QRenc_freeQRcode(qrcode); } int main() -- cgit 0.0.5-2-1-g0f52 From bfa12cb840cb6f0dbd03f48bbf76c6ee22f05af0 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 16 Nov 2006 09:20:23 +0000 Subject: --- qrencode.c | 50 ++++++++++++++++++++++- qrencode_inner.h | 3 ++ tests/view_qrcode.c | 112 +++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 141 insertions(+), 24 deletions(-) diff --git a/qrencode.c b/qrencode.c index 4f1b32acce..6b6d94c7a7 100644 --- a/qrencode.c +++ b/qrencode.c @@ -489,9 +489,12 @@ static unsigned char *QRenc_mask(int width, unsigned char *frame, QRenc_ErrorCor blacks = maskMakers[i](width, frame, mask); blacks = 100 * blacks / (width * width); demerit = (abs(blacks - 50) / 5) * N4; - if(demerit > minDemerit) + if(demerit > minDemerit) { + free(mask); continue; + } demerit += QRenc_evaluateSymbol(width, mask); + printf("%d\n", demerit); if(demerit < minDemerit) { minDemerit = demerit; bestMaskNum = i; @@ -576,3 +579,48 @@ QRcode *QRenc_encode(QRenc_DataStream *stream) return qrcode; } + +QRcode *QRenc_encodeMask(QRenc_DataStream *stream, int mask) +{ + int version; + int width; + QRRawCode *raw; + unsigned char *frame, *masked, *p, code, bit; + FrameFiller *filler; + int i, j; + QRcode *qrcode; + + version = QRenc_getVersion(stream); + width = QRspec_getWidth(version); + raw = QRraw_new(stream); + frame = QRspec_newFrame(version); + filler = FrameFiller_new(width, frame); + + /* inteleaved data and ecc codes */ + for(i=0; idataLength + raw->eccLength; i++) { + code = QRraw_getCode(raw); + bit = 0x80; + for(j=0; j<8; j++) { + p = FrameFiller_next(filler); + *p = 0xa0 | ((bit & code) != 0); + bit = bit >> 1; + } + } + QRraw_free(raw); + /* remainder bits */ + j = QRspec_getRemainder(version); + for(i=0; iwidth; - frame = qrcode->data; - QRenc_freeData(stream); - pitch = screen->pitch; - q = frame; - SDL_FillRect(screen, NULL, 0xffffff); - for(y=0; ypixels + pitch * (y + 4) * 2 + 32); - p2 = (unsigned int *)(screen->pixels + pitch * ((y + 4) * 2 + 1) + 32); - for(x=0; xwidth; + frame = qrcode->data; + pitch = screen->pitch; + q = frame; + SDL_FillRect(screen, NULL, 0xffffff); + for(y=0; ypixels + pitch * (y + 4) * 2 + 32); + p2 = (unsigned int *)(screen->pixels + pitch * ((y + 4) * 2 + 1) + 32); + for(x=0; x QRSPEC_VERSION_MAX) + version = QRSPEC_VERSION_MAX; + loop = 0; + break; + case SDLK_LEFT: + version--; + if(version < 1) + version = 1; + loop = 0; + break; + case SDLK_0: + case SDLK_1: + case SDLK_2: + case SDLK_3: + case SDLK_4: + case SDLK_5: + case SDLK_6: + case SDLK_7: + mask = (event.key.keysym.sym - SDLK_0); + loop = 0; + break; + case SDLK_l: + level = QR_EC_LEVEL_L; + loop = 0; + break; + case SDLK_m: + level = QR_EC_LEVEL_M; + loop = 0; + break; + case SDLK_h: + level = QR_EC_LEVEL_H; + loop = 0; + break; + case SDLK_q: + level = QR_EC_LEVEL_Q; + loop = 0; + break; + case SDLK_ESCAPE: + loop = 0; + flag = 0; + break; + default: + break; + } + } + if(event.type == SDL_QUIT) { + loop = 0; + flag = 0; + } + } } } - SDL_Flip(screen); - eventloop(); - - QRenc_freeQRcode(qrcode); + QRenc_freeData(stream); } int main() -- cgit 0.0.5-2-1-g0f52 From a6891c5ad7b6d158f8a9ea855ee89ab2ad9cf1a6 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 16 Nov 2006 10:12:48 +0000 Subject: --- qrencode.c | 1 - qrspec.c | 8 ++++---- tests/test_qrspec.c | 4 +++- tests/view_qrcode.c | 3 +++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/qrencode.c b/qrencode.c index 6b6d94c7a7..5646280ed2 100644 --- a/qrencode.c +++ b/qrencode.c @@ -494,7 +494,6 @@ static unsigned char *QRenc_mask(int width, unsigned char *frame, QRenc_ErrorCor continue; } demerit += QRenc_evaluateSymbol(width, mask); - printf("%d\n", demerit); if(demerit < minDemerit) { minDemerit = demerit; bestMaskNum = i; diff --git a/qrspec.c b/qrspec.c index 6f815d2d92..bbceee56a0 100644 --- a/qrspec.c +++ b/qrspec.c @@ -382,10 +382,10 @@ unsigned int QRspec_getVersionPattern(int version) /* See calcFormatInfo in tests/test_qrspec.c */ static unsigned int formatInfo[4][8] = { - {0x77c4, 0x73c4, 0x7daa, 0x79aa, 0x6318, 0x6318, 0x6976, 0x6976}, - {0x5412, 0x5012, 0x5e7c, 0x5a7c, 0x40ce, 0x40ce, 0x4aa0, 0x4aa0}, - {0x3068, 0x3068, 0x3a06, 0x3a06, 0x24b4, 0x20b4, 0x2eda, 0x2ada}, - {0x13be, 0x13be, 0x19d0, 0x19d0, 0x0762, 0x0362, 0x0d0c, 0x090c} + {0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976}, + {0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0}, + {0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed}, + {0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b} }; unsigned int QRspec_getFormatInfo(int mask, QRenc_ErrorCorrectionLevel level) diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 2ae5383959..d9562da07f 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -246,7 +246,7 @@ static unsigned int calcFormatInfo(int mask, QRenc_ErrorCorrectionLevel level) c = 4 - i; code = 0x537 << c ; //10100110111 b = 1 << (10 + c); - for(i=0; i #include +#include #include #include "common.h" #include "../qrencode_inner.h" @@ -14,6 +15,7 @@ int eventloop(void) int q = 1; while(q) { + usleep(10000); while(SDL_PollEvent(&event)) { if(event.type == SDL_KEYDOWN) { switch(event.key.keysym.sym) { @@ -82,6 +84,7 @@ void view_simple(void) QRenc_freeQRcode(qrcode); loop = 1; while(loop) { + usleep(10000); while(SDL_PollEvent(&event)) { if(event.type == SDL_KEYDOWN) { switch(event.key.keysym.sym) { -- cgit 0.0.5-2-1-g0f52 From 93a395e241445b14c944f42e308ec6cf720d3e28 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 16 Nov 2006 13:33:30 +0000 Subject: --- datastream.c | 42 +++++++++++++++++++++--------------------- datastream.h | 12 ++++++------ qrencode.c | 14 +++++++------- qrencode.h | 33 +++++++++++++++++---------------- qrencode_inner.h | 6 +++--- qrspec.c | 14 +++++++------- qrspec.h | 14 +++++++------- tests/test_datastream.c | 16 ++++++++-------- tests/test_estimatebit.c | 14 +++++++------- tests/test_qrencode.c | 16 ++++++++-------- tests/test_qrspec.c | 2 +- tests/test_rs.c | 4 ++-- tests/view_qrcode.c | 12 ++++++------ 13 files changed, 100 insertions(+), 99 deletions(-) diff --git a/datastream.c b/datastream.c index 5a32583491..85847e741f 100644 --- a/datastream.c +++ b/datastream.c @@ -33,14 +33,14 @@ *****************************************************************************/ struct _QRenc_List { - QRenc_EncodeMode mode; + QRencodeMode mode; int size; ///< Size of data chunk (byte). unsigned char *data; ///< Data chunk. BitStream *bstream; QRenc_List *next; }; -static QRenc_List *QRenc_newEntry(QRenc_EncodeMode mode, int size, unsigned char *data) +static QRenc_List *QRenc_newEntry(QRencodeMode mode, int size, unsigned char *data) { QRenc_List *entry; @@ -77,40 +77,40 @@ static QRenc_List *QRenc_freeEntry(QRenc_List *entry) * Input Data stream *****************************************************************************/ -QRenc_DataStream *QRenc_newData(void) +QRinput *QRenc_newData(void) { - QRenc_DataStream *stream; + QRinput *stream; - stream = (QRenc_DataStream *)malloc(sizeof(QRenc_DataStream)); + stream = (QRinput *)malloc(sizeof(QRinput)); stream->head = NULL; stream->tail = NULL; stream->version = 0; - stream->level = QR_EC_LEVEL_L; + stream->level = QR_ECLEVEL_L; return stream; } -int QRenc_getVersion(QRenc_DataStream *stream) +int QRenc_getVersion(QRinput *stream) { return stream->version; } -void QRenc_setVersion(QRenc_DataStream *stream, int v) +void QRenc_setVersion(QRinput *stream, int v) { stream->version = v; } -void QRenc_setErrorCorrectionLevel(QRenc_DataStream *stream, QRenc_ErrorCorrectionLevel level) +void QRenc_setErrorCorrectionLevel(QRinput *stream, QRecLevel level) { stream->level = level; } -QRenc_ErrorCorrectionLevel QRenc_getErrorCorrectionLevel(QRenc_DataStream *stream) +QRecLevel QRenc_getErrorCorrectionLevel(QRinput *stream) { return stream->level; } -int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, unsigned char *data) +int QRenc_appendData(QRinput *stream, QRencodeMode mode, int size, unsigned char *data) { QRenc_List *entry; @@ -130,7 +130,7 @@ int QRenc_appendData(QRenc_DataStream *stream, QRenc_EncodeMode mode, int size, return 0; } -void QRenc_freeData(QRenc_DataStream *stream) +void QRenc_freeData(QRinput *stream) { QRenc_List *list; @@ -442,7 +442,7 @@ static void QRenc_encodeModeKanji(QRenc_List *entry, int version) * @param data * @return result */ -int QRenc_checkData(QRenc_EncodeMode mode, int size, const unsigned char *data) +int QRenc_checkData(QRencodeMode mode, int size, const unsigned char *data) { switch(mode) { case QR_MODE_NUM: @@ -508,7 +508,7 @@ static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) * @param version version of the symbol * @return number of bits */ -int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version) +int QRenc_estimateBitStreamSize(QRinput *stream, int version) { QRenc_List *list; int bits = 0; @@ -529,7 +529,7 @@ int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version) * @param stream data stream * @return required version number */ -static int QRenc_estimateVersion(QRenc_DataStream *stream) +static int QRenc_estimateVersion(QRinput *stream) { int bits; int new, prev; @@ -606,7 +606,7 @@ static int QRenc_encodeBitStream(QRenc_List *entry, int version) * @param stream input data stream. * @return length of the bit stream. */ -static int QRenc_createBitStream(QRenc_DataStream *stream) +static int QRenc_createBitStream(QRinput *stream) { QRenc_List *list; int bits = 0; @@ -629,7 +629,7 @@ static int QRenc_createBitStream(QRenc_DataStream *stream) * @param stream input data stream. * @return -1 if the input data was too large. Otherwise 0. */ -static int QRenc_convertData(QRenc_DataStream *stream) +static int QRenc_convertData(QRinput *stream) { int bits; int ver; @@ -659,7 +659,7 @@ static int QRenc_convertData(QRenc_DataStream *stream) * @param stream input data stream. * @return padding bit stream. */ -static BitStream *QRenc_createPaddingBit(QRenc_DataStream *stream) +static BitStream *QRenc_createPaddingBit(QRinput *stream) { int bits, maxbits, words, maxwords, i; QRenc_List *list; @@ -709,7 +709,7 @@ static BitStream *QRenc_createPaddingBit(QRenc_DataStream *stream) * @return merged bit stream */ -BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream) +BitStream *QRenc_mergeBitStream(QRinput *stream) { BitStream *bstream; QRenc_List *list; @@ -734,7 +734,7 @@ BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream) * @return padded merged bit stream */ -BitStream *QRenc_getBitStream(QRenc_DataStream *stream) +BitStream *QRenc_getBitStream(QRinput *stream) { BitStream *bstream; BitStream *padding; @@ -756,7 +756,7 @@ BitStream *QRenc_getBitStream(QRenc_DataStream *stream) * @return padded merged byte stream */ -unsigned char *QRenc_getByteStream(QRenc_DataStream *stream) +unsigned char *QRenc_getByteStream(QRinput *stream) { BitStream *bstream; unsigned char *array; diff --git a/datastream.h b/datastream.h index 9b210120c2..42895210fa 100644 --- a/datastream.h +++ b/datastream.h @@ -32,9 +32,9 @@ typedef struct _QRenc_List QRenc_List; /****************************************************************************** * Input Data stream *****************************************************************************/ -struct _QRenc_DataStream { +struct _QRinput { int version; - QRenc_ErrorCorrectionLevel level; + QRecLevel level; QRenc_List *head; QRenc_List *tail; }; @@ -44,10 +44,10 @@ struct _QRenc_DataStream { * @param stream input data stream. * @return padded merged byte stream */ -extern unsigned char *QRenc_getByteStream(QRenc_DataStream *stream); +extern unsigned char *QRenc_getByteStream(QRinput *stream); -extern int QRenc_estimateBitStreamSize(QRenc_DataStream *stream, int version); -extern BitStream *QRenc_mergeBitStream(QRenc_DataStream *stream); -extern BitStream *QRenc_getBitStream(QRenc_DataStream *stream); +extern int QRenc_estimateBitStreamSize(QRinput *stream, int version); +extern BitStream *QRenc_mergeBitStream(QRinput *stream); +extern BitStream *QRenc_getBitStream(QRinput *stream); #endif /* __DATASTREAM_H__ */ diff --git a/qrencode.c b/qrencode.c index 5646280ed2..945aa00b81 100644 --- a/qrencode.c +++ b/qrencode.c @@ -48,7 +48,7 @@ static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el) encode_rs_char(rs, data, block->ecc); } -QRRawCode *QRraw_new(QRenc_DataStream *stream) +QRRawCode *QRraw_new(QRinput *stream) { QRRawCode *raw; int *spec; @@ -226,8 +226,8 @@ unsigned char *QRenc_fillerTest(int version) width = QRspec_getWidth(version); frame = QRspec_newFrame(version); filler = FrameFiller_new(width, frame); - length = QRspec_getDataLength(version, QR_EC_LEVEL_L) - + QRspec_getECCLength(version, QR_EC_LEVEL_L); + length = QRspec_getDataLength(version, QR_ECLEVEL_L) + + QRspec_getECCLength(version, QR_ECLEVEL_L); for(i=0; i 7) return 0; diff --git a/qrspec.h b/qrspec.h index 9b01ea25fc..a375576bfd 100644 --- a/qrspec.h +++ b/qrspec.h @@ -43,7 +43,7 @@ * @param level * @return maximum size (bytes) */ -extern int QRspec_getDataLength(int version, QRenc_ErrorCorrectionLevel level); +extern int QRspec_getDataLength(int version, QRecLevel level); /** * Return maximum error correction code length (bytes) for the version. @@ -51,7 +51,7 @@ extern int QRspec_getDataLength(int version, QRenc_ErrorCorrectionLevel level); * @param level * @return ECC size (bytes) */ -extern int QRspec_getECCLength(int version, QRenc_ErrorCorrectionLevel level); +extern int QRspec_getECCLength(int version, QRecLevel level); /** * Return a version number that satisfies the input code length. @@ -59,7 +59,7 @@ extern int QRspec_getECCLength(int version, QRenc_ErrorCorrectionLevel level); * @param level * @return version number */ -extern int QRspec_getMinimumVersion(int size, QRenc_ErrorCorrectionLevel level); +extern int QRspec_getMinimumVersion(int size, QRecLevel level); /** * Return the width of the symbol for the version. @@ -85,7 +85,7 @@ extern int QRspec_getRemainder(int version); * @param version * @return the size of the appropriate length indicator (bits). */ -extern int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version); +extern int QRspec_lengthIndicator(QRencodeMode mode, int version); /** * Return the maximum length for the mode and version. @@ -93,7 +93,7 @@ extern int QRspec_lengthIndicator(QRenc_EncodeMode mode, int version); * @param version * @return the maximum length (bytes) */ -extern int QRspec_maximumWords(QRenc_EncodeMode mode, int version); +extern int QRspec_maximumWords(QRencodeMode mode, int version); /****************************************************************************** * Error correction code @@ -108,7 +108,7 @@ extern int QRspec_maximumWords(QRenc_EncodeMode mode, int version); * # of type2 blocks, # of data code, # of ecc code} * It can be freed by calling free(). */ -int *QRspec_getEccSpec(int version, QRenc_ErrorCorrectionLevel level); +int *QRspec_getEccSpec(int version, QRecLevel level); #define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3]) #define QRspec_rsBlockNum1(__spec__) (__spec__[0]) @@ -167,7 +167,7 @@ extern unsigned int QRspec_getVersionPattern(int version); * @param level * @return BCH encoded format information pattern */ -extern unsigned int QRspec_getFormatInfo(int mask, QRenc_ErrorCorrectionLevel level); +extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); /****************************************************************************** * Frame diff --git a/tests/test_datastream.c b/tests/test_datastream.c index d76256ef48..a444459009 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -6,7 +6,7 @@ void test_encodeKanji(void) { - QRenc_DataStream *stream; + QRinput *stream; unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; char correct[] = "10000000001001101100111111101010101010"; BitStream *bstream; @@ -24,7 +24,7 @@ void test_encodeKanji(void) void test_encode8(void) { - QRenc_DataStream *stream; + QRinput *stream; char str[] = "AC-42"; char correct[] = "00100000001010011100111011100111001000010"; BitStream *bstream; @@ -42,7 +42,7 @@ void test_encode8(void) void test_encodeAn(void) { - QRenc_DataStream *stream; + QRinput *stream; char str[] = "AC-42"; char correct[] = "00100000001010011100111011100111001000010"; BitStream *bstream; @@ -60,7 +60,7 @@ void test_encodeAn(void) void test_encodeAn2(void) { - QRenc_DataStream *stream; + QRinput *stream; char str[] = "!,;$%"; int ret; @@ -73,7 +73,7 @@ void test_encodeAn2(void) void test_encodeNumeric(void) { - QRenc_DataStream *stream; + QRinput *stream; char num[9] = "01234567"; char correct[] = "00010000001000000000110001010110011000011"; BitStream *bstream; @@ -91,7 +91,7 @@ void test_encodeNumeric(void) void test_encodeNumericPadded(void) { - QRenc_DataStream *stream; + QRinput *stream; char num[9] = "01234567"; char correct[] = "000100000010000000001100010101100110000110000000"; BitStream *bstream; @@ -113,7 +113,7 @@ void test_encodeNumericPadded(void) void test_encodeNumeric2(void) { - QRenc_DataStream *stream; + QRinput *stream; char num[] = "0123456789012345"; char correct[] = "00010000010000000000110001010110011010100110111000010100111010100101"; BitStream *bstream; @@ -131,7 +131,7 @@ void test_encodeNumeric2(void) void test_encode82(void) { - QRenc_DataStream *stream; + QRinput *stream; unsigned char *data; BitStream *bstream; char c1[] = "010011111111"; diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index b002a4da23..39b59d0401 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -5,11 +5,11 @@ #include "../datastream.h" #include "../qrencode_inner.h" -QRenc_DataStream *gstream; +QRinput *gstream; void test_numbit(void) { - QRenc_DataStream *stream; + QRinput *stream; char num[9]="01234567"; int bits; @@ -25,7 +25,7 @@ void test_numbit(void) void test_numbit2(void) { - QRenc_DataStream *stream; + QRinput *stream; char num[17]="0123456789012345"; int bits; @@ -41,7 +41,7 @@ void test_numbit2(void) void test_numbit3(void) { - QRenc_DataStream *stream; + QRinput *stream; char *num; int bits; @@ -61,7 +61,7 @@ void test_numbit3(void) void test_an(void) { - QRenc_DataStream *stream; + QRinput *stream; char str[6]="AC-42"; int bits; @@ -77,7 +77,7 @@ void test_an(void) void test_8(void) { - QRenc_DataStream *stream; + QRinput *stream; char str[9]="12345678"; int bits; @@ -95,7 +95,7 @@ void test_kanji(void) { int res; - QRenc_DataStream *stream; + QRinput *stream; unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; int bits; diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 8188b4a9ec..98f333f6ac 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -7,7 +7,7 @@ void test_iterate() { int i; - QRenc_DataStream *stream; + QRinput *stream; char num[9] = "01234567"; unsigned char *data; QRRawCode *raw; @@ -16,7 +16,7 @@ void test_iterate() testStart("Test getCode (1-L)"); stream = QRenc_newData(); QRenc_setVersion(stream, 1); - QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_L); + QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_L); QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); raw = QRraw_new(stream); @@ -35,7 +35,7 @@ void test_iterate() void test_iterate2() { int i; - QRenc_DataStream *stream; + QRinput *stream; char num[9] = "01234567"; QRRawCode *raw; int err = 0; @@ -62,7 +62,7 @@ void test_iterate2() testStart("Test getCode (5-H)"); stream = QRenc_newData(); QRenc_setVersion(stream, 5); - QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_H); + QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_H); QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); raw = QRraw_new(stream); @@ -168,8 +168,8 @@ void test_format(void) testStart("Test format information(level L,mask 0)"); width = QRspec_getWidth(1); frame = QRspec_newFrame(1); - format = QRspec_getFormatInfo(1, QR_EC_LEVEL_L); - QRenc_writeFormatInformation(width, frame, 1, QR_EC_LEVEL_L); + format = QRspec_getFormatInfo(1, QR_ECLEVEL_L); + QRenc_writeFormatInformation(width, frame, 1, QR_ECLEVEL_L); decode = 0; for(i=0; i<8; i++) { decode = decode << 1; @@ -313,7 +313,7 @@ void test_eval3(void) void test_encode(void) { - QRenc_DataStream *stream; + QRinput *stream; char num[9] = "01234567"; unsigned char *frame; int err = 0; @@ -323,7 +323,7 @@ void test_encode(void) testStart("Test encode (1-L)"); stream = QRenc_newData(); QRenc_setVersion(stream, 1); - QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_L); + QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_L); QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); qrcode = QRenc_encode(stream); w = qrcode->width; diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index d9562da07f..f5806953fc 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -231,7 +231,7 @@ void print_newFrame(void) /* See Table 22 (pp.45) and Appendix C (pp. 65) of JIS X0510:2004 */ static unsigned int levelIndicator[4] = {1, 0, 3, 2}; -static unsigned int calcFormatInfo(int mask, QRenc_ErrorCorrectionLevel level) +static unsigned int calcFormatInfo(int mask, QRecLevel level) { unsigned int data, ecc, b, code; int i, c; diff --git a/tests/test_rs.c b/tests/test_rs.c index b920004c72..ab36bf29a8 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -6,7 +6,7 @@ /* See pp. 73 of JIS X0510:2004 */ void test_rscode1(void) { - QRenc_DataStream *stream; + QRinput *stream; QRRawCode *code; static char str[8] = "01234567"; static unsigned char correct[26] = { @@ -17,7 +17,7 @@ void test_rscode1(void) testStart("RS ecc test"); stream = QRenc_newData(); QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)str); - QRenc_setErrorCorrectionLevel(stream, QR_EC_LEVEL_M); + QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_M); code = QRraw_new(stream); testEnd(memcmp(correct + 16, code->rsblock[0].ecc, 10)); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 8ac2d8b7e3..92aee7a074 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -40,7 +40,7 @@ int eventloop(void) void view_simple(void) { - QRenc_DataStream *stream; + QRinput *stream; char num[9] = "01234567"; unsigned char *frame, *q; unsigned int v, *p1, *p2; @@ -50,7 +50,7 @@ void view_simple(void) int flag = 1; int version = 1; int mask = 0; - QRenc_ErrorCorrectionLevel level = QR_EC_LEVEL_L; + QRecLevel level = QR_ECLEVEL_L; QRcode *qrcode; SDL_Event event; int loop; @@ -112,19 +112,19 @@ void view_simple(void) loop = 0; break; case SDLK_l: - level = QR_EC_LEVEL_L; + level = QR_ECLEVEL_L; loop = 0; break; case SDLK_m: - level = QR_EC_LEVEL_M; + level = QR_ECLEVEL_M; loop = 0; break; case SDLK_h: - level = QR_EC_LEVEL_H; + level = QR_ECLEVEL_H; loop = 0; break; case SDLK_q: - level = QR_EC_LEVEL_Q; + level = QR_ECLEVEL_Q; loop = 0; break; case SDLK_ESCAPE: -- cgit 0.0.5-2-1-g0f52 From 4ee4f8dd7803682b015fc72887d80fecf6d5f874 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 16 Nov 2006 13:44:10 +0000 Subject: --- datastream.c | 10 +++++----- qrencode.h | 8 ++++---- tests/test_datastream.c | 48 ++++++++++++++++++++++---------------------- tests/test_estimatebit.c | 52 ++++++++++++++++++++++++------------------------ tests/test_qrencode.c | 18 ++++++++--------- tests/test_rs.c | 6 +++--- tests/view_qrcode.c | 6 +++--- 7 files changed, 74 insertions(+), 74 deletions(-) diff --git a/datastream.c b/datastream.c index 85847e741f..62e0c2b95f 100644 --- a/datastream.c +++ b/datastream.c @@ -44,7 +44,7 @@ static QRenc_List *QRenc_newEntry(QRencodeMode mode, int size, unsigned char *da { QRenc_List *entry; - if(QRenc_checkData(mode, size, data)) { + if(QRinput_check(mode, size, data)) { return NULL; } @@ -77,7 +77,7 @@ static QRenc_List *QRenc_freeEntry(QRenc_List *entry) * Input Data stream *****************************************************************************/ -QRinput *QRenc_newData(void) +QRinput *QRinput_new(void) { QRinput *stream; @@ -110,7 +110,7 @@ QRecLevel QRenc_getErrorCorrectionLevel(QRinput *stream) return stream->level; } -int QRenc_appendData(QRinput *stream, QRencodeMode mode, int size, unsigned char *data) +int QRinput_append(QRinput *stream, QRencodeMode mode, int size, unsigned char *data) { QRenc_List *entry; @@ -130,7 +130,7 @@ int QRenc_appendData(QRinput *stream, QRencodeMode mode, int size, unsigned char return 0; } -void QRenc_freeData(QRinput *stream) +void QRinput_free(QRinput *stream) { QRenc_List *list; @@ -442,7 +442,7 @@ static void QRenc_encodeModeKanji(QRenc_List *entry, int version) * @param data * @return result */ -int QRenc_checkData(QRencodeMode mode, int size, const unsigned char *data) +int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) { switch(mode) { case QR_MODE_NUM: diff --git a/qrencode.h b/qrencode.h index 329cf21fe1..27032fd4a6 100644 --- a/qrencode.h +++ b/qrencode.h @@ -54,7 +54,7 @@ typedef struct _QRinput QRinput; * Instantiate a data stream object. * @return Stream object (initialized). */ -extern QRinput *QRenc_newData(void); +extern QRinput *QRinput_new(void); /** * Get current error correction level. @@ -93,14 +93,14 @@ extern void QRenc_setVersion(QRinput *stream, int version); * @param data A pointer to the memory area of the input data. * @return -1 when the input data is invalid. Otherwise 0. */ -extern int QRenc_appendData(QRinput *stream, QRencodeMode mode, int size, unsigned char *data); +extern int QRinput_append(QRinput *stream, QRencodeMode mode, int size, unsigned char *data); /** * Free the stream object. * All of data chunks in the stream object are freed too. * @param stream Stream object. */ -extern void QRenc_freeData(QRinput *stream); +extern void QRinput_free(QRinput *stream); /** * Validate the input data @@ -109,7 +109,7 @@ extern void QRenc_freeData(QRinput *stream); * @param data * @return result */ -extern int QRenc_checkData(QRencodeMode mode, int size, const unsigned char *data); +extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data); /****************************************************************************** * QRcode output diff --git a/tests/test_datastream.c b/tests/test_datastream.c index a444459009..f07cf56c4d 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -12,13 +12,13 @@ void test_encodeKanji(void) BitStream *bstream; testStart("Encoding kanji stream."); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_KANJI, 4, (unsigned char *)str); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_KANJI, 4, (unsigned char *)str); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); - QRenc_freeData(stream); + QRinput_free(stream); BitStream_free(bstream); } @@ -30,13 +30,13 @@ void test_encode8(void) BitStream *bstream; testStart("Encoding alphabet-numeric stream."); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); - QRenc_freeData(stream); + QRinput_free(stream); BitStream_free(bstream); } @@ -48,13 +48,13 @@ void test_encodeAn(void) BitStream *bstream; testStart("Encoding alphabet-numeric stream."); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); - QRenc_freeData(stream); + QRinput_free(stream); BitStream_free(bstream); } @@ -65,10 +65,10 @@ void test_encodeAn2(void) int ret; testStart("Encoding INVALID alphabet-numeric stream."); - stream = QRenc_newData(); - ret = QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); + stream = QRinput_new(); + ret = QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); testEnd(!ret); - QRenc_freeData(stream); + QRinput_free(stream); } void test_encodeNumeric(void) @@ -79,13 +79,13 @@ void test_encodeNumeric(void) BitStream *bstream; testStart("Encoding numeric stream. (8 digits)"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); - QRenc_freeData(stream); + QRinput_free(stream); BitStream_free(bstream); } @@ -98,8 +98,8 @@ void test_encodeNumericPadded(void) int flag; testStart("Encoding numeric stream. (8 digits)(padded)"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); bstream = QRenc_getBitStream(stream); flag = strncmp(correct, bstream->data, 48); printf("%s\n", bstream->data); @@ -107,7 +107,7 @@ void test_encodeNumericPadded(void) flag |= 0x80; testEnd(flag); - QRenc_freeData(stream); + QRinput_free(stream); BitStream_free(bstream); } @@ -119,13 +119,13 @@ void test_encodeNumeric2(void) BitStream *bstream; testStart("Encoding numeric stream. (16 digits)"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_NUM, 16, (unsigned char *)num); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num); bstream = QRenc_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); - QRenc_freeData(stream); + QRinput_free(stream); BitStream_free(bstream); } @@ -141,8 +141,8 @@ void test_encode82(void) data = (unsigned char *)malloc(257); memset(data, 0, 257); testStart("Encoding byte stream. (257 bytes)"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_8, 257, data); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_8, 257, data); bstream = QRenc_mergeBitStream(stream); if(strncmp(c1, bstream->data, 12)) { flag++; @@ -151,7 +151,7 @@ void test_encode82(void) flag++; } testEnd(flag); - QRenc_freeData(stream); + QRinput_free(stream); BitStream_free(bstream); free(data); } diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index 39b59d0401..856bb5af51 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -14,13 +14,13 @@ void test_numbit(void) int bits; testStart("Estimation of Numeric stream (8 digits)"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); bits = QRenc_estimateBitStreamSize(stream, 0); testEndExp(bits == 41); - QRenc_appendData(gstream, QR_MODE_NUM, 8, (unsigned char *)num); - QRenc_freeData(stream); + QRinput_append(gstream, QR_MODE_NUM, 8, (unsigned char *)num); + QRinput_free(stream); } void test_numbit2(void) @@ -30,13 +30,13 @@ void test_numbit2(void) int bits; testStart("Estimation of Numeric stream (16 digits)"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_NUM, 16, (unsigned char *)num); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num); bits = QRenc_estimateBitStreamSize(stream, 0); testEndExp(bits == 68); - QRenc_appendData(gstream, QR_MODE_NUM, 16, (unsigned char *)num); - QRenc_freeData(stream); + QRinput_append(gstream, QR_MODE_NUM, 16, (unsigned char *)num); + QRinput_free(stream); } void test_numbit3(void) @@ -46,16 +46,16 @@ void test_numbit3(void) int bits; testStart("Estimation of Numeric stream (400 digits)"); - stream = QRenc_newData(); + stream = QRinput_new(); num = (char *)malloc(401); memset(num, '1', 400); num[400] = '\0'; - QRenc_appendData(stream, QR_MODE_NUM, 400, (unsigned char *)num); + QRinput_append(stream, QR_MODE_NUM, 400, (unsigned char *)num); bits = QRenc_estimateBitStreamSize(stream, 0); testEndExp(bits == 1362); - QRenc_appendData(gstream, QR_MODE_NUM, 400, (unsigned char *)num); - QRenc_freeData(stream); + QRinput_append(gstream, QR_MODE_NUM, 400, (unsigned char *)num); + QRinput_free(stream); free(num); } @@ -66,13 +66,13 @@ void test_an(void) int bits; testStart("Estimation of Alphabet-Numeric stream (5 chars)"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_AN, 5, (unsigned char *)str); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); bits = QRenc_estimateBitStreamSize(stream, 0); testEndExp(bits == 41); - QRenc_appendData(gstream, QR_MODE_AN, 5, (unsigned char *)str); - QRenc_freeData(stream); + QRinput_append(gstream, QR_MODE_AN, 5, (unsigned char *)str); + QRinput_free(stream); } void test_8(void) @@ -82,13 +82,13 @@ void test_8(void) int bits; testStart("Estimation of 8 bit data stream (8 bytes)"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_8, 8, (unsigned char *)str); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_8, 8, (unsigned char *)str); bits = QRenc_estimateBitStreamSize(stream, 0); testEndExp(bits == 76); - QRenc_appendData(gstream, QR_MODE_8, 8, (unsigned char *)str); - QRenc_freeData(stream); + QRinput_append(gstream, QR_MODE_8, 8, (unsigned char *)str); + QRinput_free(stream); } void test_kanji(void) @@ -100,18 +100,18 @@ void test_kanji(void) int bits; testStart("Estimation of Kanji stream (2 chars)"); - stream = QRenc_newData(); - res = QRenc_appendData(stream, QR_MODE_KANJI, 4, (unsigned char *)str); + stream = QRinput_new(); + res = QRinput_append(stream, QR_MODE_KANJI, 4, (unsigned char *)str); if(res < 0) { printf("Failed to add.\n"); testEnd(1); } else { bits = QRenc_estimateBitStreamSize(stream, 0); testEndExp(bits == 38); - QRenc_appendData(gstream, QR_MODE_KANJI, 4, (unsigned char *)str); + QRinput_append(gstream, QR_MODE_KANJI, 4, (unsigned char *)str); } - QRenc_freeData(stream); + QRinput_free(stream); } void test_mix(void) @@ -121,12 +121,12 @@ void test_mix(void) testStart("Estimation of Mixed stream"); bits = QRenc_estimateBitStreamSize(gstream, 0); testEndExp(bits == (41 + 68 + 1362 + 41 + 76 + 38)); - QRenc_freeData(gstream); + QRinput_free(gstream); } int main(int argc, char **argv) { - gstream = QRenc_newData(); + gstream = QRinput_new(); test_numbit(); test_numbit2(); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 98f333f6ac..f71852db04 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -14,10 +14,10 @@ void test_iterate() int err = 0; testStart("Test getCode (1-L)"); - stream = QRenc_newData(); + stream = QRinput_new(); QRenc_setVersion(stream, 1); QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_L); - QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); raw = QRraw_new(stream); data = raw->datacode; @@ -27,7 +27,7 @@ void test_iterate() } } - QRenc_freeData(stream); + QRinput_free(stream); QRraw_free(raw); testEnd(err); } @@ -60,10 +60,10 @@ void test_iterate2() }; testStart("Test getCode (5-H)"); - stream = QRenc_newData(); + stream = QRinput_new(); QRenc_setVersion(stream, 5); QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_H); - QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); raw = QRraw_new(stream); for(i=0; idataLength; i++) { @@ -72,7 +72,7 @@ void test_iterate2() } } - QRenc_freeData(stream); + QRinput_free(stream); QRraw_free(raw); testEnd(err); } @@ -321,10 +321,10 @@ void test_encode(void) QRcode *qrcode; testStart("Test encode (1-L)"); - stream = QRenc_newData(); + stream = QRinput_new(); QRenc_setVersion(stream, 1); QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_L); - QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); qrcode = QRenc_encode(stream); w = qrcode->width; frame = qrcode->data; @@ -339,7 +339,7 @@ void test_encode(void) printf("\n"); } testEnd(err); - QRenc_freeData(stream); + QRinput_free(stream); QRenc_freeQRcode(qrcode); } diff --git a/tests/test_rs.c b/tests/test_rs.c index ab36bf29a8..58ab64ce39 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -15,13 +15,13 @@ void test_rscode1(void) 0x2c, 0x55}; testStart("RS ecc test"); - stream = QRenc_newData(); - QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)str); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)str); QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_M); code = QRraw_new(stream); testEnd(memcmp(correct + 16, code->rsblock[0].ecc, 10)); - QRenc_freeData(stream); + QRinput_free(stream); QRraw_free(code); } diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 92aee7a074..c535b3d4e2 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -55,9 +55,9 @@ void view_simple(void) SDL_Event event; int loop; - stream = QRenc_newData(); + stream = QRinput_new(); - QRenc_appendData(stream, QR_MODE_NUM, 8, (unsigned char *)num); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); while(flag) { QRenc_setVersion(stream, version); @@ -143,7 +143,7 @@ void view_simple(void) } } - QRenc_freeData(stream); + QRinput_free(stream); } int main() -- cgit 0.0.5-2-1-g0f52 From 7685c222ff9a82600edeef553155a6c49bc47865 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 16 Nov 2006 13:47:07 +0000 Subject: --- Makefile.am | 4 +- datastream.c | 769 ----------------------------------------------- datastream.h | 53 ---- qrencode.c | 2 +- qrinput.c | 769 +++++++++++++++++++++++++++++++++++++++++++++++ qrinput.h | 53 ++++ tests/test_datastream.c | 2 +- tests/test_estimatebit.c | 2 +- 8 files changed, 827 insertions(+), 827 deletions(-) delete mode 100644 datastream.c delete mode 100644 datastream.h create mode 100644 qrinput.c create mode 100644 qrinput.h diff --git a/Makefile.am b/Makefile.am index 6d7f0288ce..89cebafdb1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,8 +4,8 @@ SUBDIRS = . tests lib_LTLIBRARIES = libqrencode.la -libqrencode_la_SOURCES = qrencode.c datastream.c bitstream.c qrspec.c rscode.c -libqrencode_la_headers = qrencode.h qrencode_inner.h datastream.h bitstream.h \ +libqrencode_la_SOURCES = qrencode.c qrinput.c bitstream.c qrspec.c rscode.c +libqrencode_la_headers = qrencode.h qrencode_inner.h qrinput.h bitstream.h \ qrspec.h rscode.h libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) diff --git a/datastream.c b/datastream.c deleted file mode 100644 index 62e0c2b95f..0000000000 --- a/datastream.c +++ /dev/null @@ -1,769 +0,0 @@ -/* - * qrencode - QR-code encoder - * - * Copyright (C) 2006 Kentaro Fukuchi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - -#include "qrencode.h" -#include "qrspec.h" -#include "bitstream.h" -#include "datastream.h" - -/****************************************************************************** - * Entry of input data stream - *****************************************************************************/ - -struct _QRenc_List { - QRencodeMode mode; - int size; ///< Size of data chunk (byte). - unsigned char *data; ///< Data chunk. - BitStream *bstream; - QRenc_List *next; -}; - -static QRenc_List *QRenc_newEntry(QRencodeMode mode, int size, unsigned char *data) -{ - QRenc_List *entry; - - if(QRinput_check(mode, size, data)) { - return NULL; - } - - entry = (QRenc_List *)malloc(sizeof(QRenc_List)); - entry->mode = mode; - entry->size = size; - entry->data = (unsigned char *)malloc(size); - memcpy(entry->data, data, size); - entry->bstream = NULL; - entry->next = NULL; - - return entry; -} - -static QRenc_List *QRenc_freeEntry(QRenc_List *entry) -{ - QRenc_List *next; - - next = entry->next; - free(entry->data); - if(entry->bstream) { - BitStream_free(entry->bstream); - } - free(entry); - - return next; -} - -/****************************************************************************** - * Input Data stream - *****************************************************************************/ - -QRinput *QRinput_new(void) -{ - QRinput *stream; - - stream = (QRinput *)malloc(sizeof(QRinput)); - stream->head = NULL; - stream->tail = NULL; - stream->version = 0; - stream->level = QR_ECLEVEL_L; - - return stream; -} - -int QRenc_getVersion(QRinput *stream) -{ - return stream->version; -} - -void QRenc_setVersion(QRinput *stream, int v) -{ - stream->version = v; -} - -void QRenc_setErrorCorrectionLevel(QRinput *stream, QRecLevel level) -{ - stream->level = level; -} - -QRecLevel QRenc_getErrorCorrectionLevel(QRinput *stream) -{ - return stream->level; -} - -int QRinput_append(QRinput *stream, QRencodeMode mode, int size, unsigned char *data) -{ - QRenc_List *entry; - - entry = QRenc_newEntry(mode, size, data); - if(entry == NULL) { - return -1; - } - - if(stream->tail == NULL) { - stream->head = entry; - stream->tail = entry; - } else { - stream->tail->next = entry; - stream->tail = entry; - } - - return 0; -} - -void QRinput_free(QRinput *stream) -{ - QRenc_List *list; - - list = stream->head; - while(list != NULL) { - list = QRenc_freeEntry(list); - } - - free(stream); -} - -/****************************************************************************** - * Numeric data - *****************************************************************************/ - -/** - * Check the input data. - * @param size - * @param data - * @return result - */ -static int QRenc_checkModeNum(int size, const char *data) -{ - int i; - - for(i=0; i '9') - return -1; - } - - return 0; -} - -/** - * Estimates the length of the encoded bit stream of numeric data. - * @param entry - * @return number of bits - */ -static int QRenc_estimateBitsModeNum(QRenc_List *entry) -{ - int w; - int bits; - - w = entry->size / 3; - bits = w * 10; - switch(entry->size - w * 3) { - case 1: - bits += 4; - break; - case 2: - bits += 7; - break; - default: - break; - } - - return bits; -} - -/** - * Convert the number data stream to a bit stream. - * @param entry - */ -static void QRenc_encodeModeNum(QRenc_List *entry, int version) -{ - int words; - int i; - unsigned int val; - - words = entry->size / 3; - entry->bstream = BitStream_new(); - - val = 0x1; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val); - - for(i=0; idata[i*3 ] - '0') * 100; - val += (entry->data[i*3+1] - '0') * 10; - val += (entry->data[i*3+2] - '0'); - - BitStream_appendNum(entry->bstream, 10, val); - } - - if(entry->size - words * 3 == 1) { - val = entry->data[words*3] - '0'; - BitStream_appendNum(entry->bstream, 4, val); - } else if(entry->size - words * 3 == 2) { - val = (entry->data[words*3 ] - '0') * 10; - val += (entry->data[words*3+1] - '0'); - BitStream_appendNum(entry->bstream, 7, val); - } -} - -/****************************************************************************** - * Alphabet-numeric data - *****************************************************************************/ - -static signed char anTable[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1 -}; - -/** - * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). - * @param c character - * @return value - */ -inline static signed char QRenc_lookAnTable(char c) -{ - if(c & 0x80) { - return -1; - } - return anTable[(int)c]; -} - -/** - * Check the input data. - * @param size - * @param data - * @return result - */ -static int QRenc_checkModeAn(int size, const char *data) -{ - int i; - - for(i=0; isize / 2; - bits = w * 11; - if(entry->size & 1) { - bits += 6; - } - - return bits; -} - -/** - * Convert the alphabet-numeric data stream to a bit stream. - * @param entry - */ -static void QRenc_encodeModeAn(QRenc_List *entry, int version) -{ - int words; - int i; - unsigned int val; - - words = entry->size / 2; - entry->bstream = BitStream_new(); - - val = 0x2; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), val); - - for(i=0; idata[i*2 ]) * 45; - val += (unsigned int)QRenc_lookAnTable(entry->data[i*2+1]); - - BitStream_appendNum(entry->bstream, 11, val); - } - - if(entry->size & 1) { - val = (unsigned int)QRenc_lookAnTable(entry->data[words * 2]); - - BitStream_appendNum(entry->bstream, 6, val); - } -} - -/****************************************************************************** - * 8 bit data - *****************************************************************************/ - -/** - * Estimates the length of the encoded bit stream of 8 bit data. - * @param entry - * @return number of bits - */ -static int QRenc_estimateBitsMode8(QRenc_List *entry) -{ - return entry->size * 8; -} - -/** - * Convert the 8bits data stream to a bit stream. - * @param entry - */ -static void QRenc_encodeMode8(QRenc_List *entry, int version) -{ - int i; - unsigned int val; - - entry->bstream = BitStream_new(); - - val = 0x4; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), val); - - for(i=0; isize; i++) { - BitStream_appendNum(entry->bstream, 8, entry->data[i]); - } -} - - -/****************************************************************************** - * Kanji data - *****************************************************************************/ - -/** - * Estimates the length of the encoded bit stream of kanji data. - * @param entry - * @return number of bits - */ -static int QRenc_estimateBitsModeKanji(QRenc_List *entry) -{ - return (entry->size / 2) * 13; -} - -/** - * Check the input data. - * @param size - * @param data - * @return result - */ -static int QRenc_checkModeKanji(int size, const unsigned char *data) -{ - int i; - unsigned int val; - - if(size & 1) - return -1; - - for(i=0; i 0x9ffc && val < 0xe040) || val > 0xebbf) { - return -1; - } - } - - return 0; -} - -/** - * Convert the kanji data stream to a bit stream. - * @param entry - */ -static void QRenc_encodeModeKanji(QRenc_List *entry, int version) -{ - int i; - unsigned int val, h; - - entry->bstream = BitStream_new(); - - val = 0x8; - BitStream_appendNum(entry->bstream, 4, val); - - val = entry->size / 2; - BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), val); - - for(i=0; isize; i+=2) { - val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1]; - if(val <= 0x9ffc) { - val -= 0x8140; - } else { - val -= 0xc140; - } - h = (val >> 8) * 0xc0; - val = (val & 0xff) + h; - - BitStream_appendNum(entry->bstream, 13, val); - } -} - -/****************************************************************************** - * Validation - *****************************************************************************/ - -/** - * Validate the input data - * @param mode - * @param size - * @param data - * @return result - */ -int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) -{ - switch(mode) { - case QR_MODE_NUM: - return QRenc_checkModeNum(size, (const char *)data); - break; - case QR_MODE_AN: - return QRenc_checkModeAn(size, (const char *)data); - break; - case QR_MODE_KANJI: - return QRenc_checkModeKanji(size, data); - break; - default: - break; - } - - return 0; -} - -/****************************************************************************** - * Estimation of the bit length - *****************************************************************************/ - -/** - * Estimates the length of the encoded bit stream on the current version. - * @param entry - * @param version version of the symbol - * @return number of bits - */ -static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) -{ - int bits = 0; - int l, m; - int num; - - assert(entry != NULL); - switch(entry->mode) { - case QR_MODE_NUM: - bits = QRenc_estimateBitsModeNum(entry); - break; - case QR_MODE_AN: - bits = QRenc_estimateBitsModeAn(entry); - break; - case QR_MODE_8: - bits = QRenc_estimateBitsMode8(entry); - break; - case QR_MODE_KANJI: - bits = QRenc_estimateBitsModeKanji(entry); - break; - } - - l = QRspec_lengthIndicator(entry->mode, version); - m = 1 << l; - num = (bits + m - 1) / m; - - bits += num * (4 + l); // mode indicator (4bits) + length indicator - - return bits; -} - -/** - * Estimates the length of the encoded bit stream of the data stream. - * @param stream data stream - * @param version version of the symbol - * @return number of bits - */ -int QRenc_estimateBitStreamSize(QRinput *stream, int version) -{ - QRenc_List *list; - int bits = 0; - - assert(stream != NULL); - - list = stream->head; - while(list != NULL) { - bits += QRenc_estimateBitStreamSizeOfEntry(list, version); - list = list->next; - } - - return bits; -} - -/** - * Estimates the required version number of the symbol. - * @param stream data stream - * @return required version number - */ -static int QRenc_estimateVersion(QRinput *stream) -{ - int bits; - int new, prev; - - new = 0; - do { - prev = new; - bits = QRenc_estimateBitStreamSize(stream, prev); - new = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); - if (new == -1) { - return -1; - } - } while (new > prev); - - return new; -} - -/****************************************************************************** - * Data conversion - *****************************************************************************/ - -/** - * Convert the data stream in the data chunk to a bit stream. - * @param entry - * @return number of bits - */ -static int QRenc_encodeBitStream(QRenc_List *entry, int version) -{ - int words; - QRenc_List *st1, *st2; - - assert(entry != NULL); - - if(entry->bstream != NULL) { - BitStream_free(entry->bstream); - entry->bstream = NULL; - } - - words = QRspec_maximumWords(entry->mode, version); - if(entry->size > words) { - st1 = QRenc_newEntry(entry->mode, words, entry->data); - st2 = QRenc_newEntry(entry->mode, entry->size - words, &entry->data[words]); - QRenc_encodeBitStream(st1, version); - QRenc_encodeBitStream(st2, version); - entry->bstream = BitStream_new(); - BitStream_append(entry->bstream, st1->bstream); - BitStream_append(entry->bstream, st2->bstream); - QRenc_freeEntry(st1); - QRenc_freeEntry(st2); - } else { - switch(entry->mode) { - case QR_MODE_NUM: - QRenc_encodeModeNum(entry, version); - break; - case QR_MODE_AN: - QRenc_encodeModeAn(entry, version); - break; - case QR_MODE_8: - QRenc_encodeMode8(entry, version); - break; - case QR_MODE_KANJI: - QRenc_encodeModeKanji(entry, version); - break; - default: - break; - } - } - - return BitStream_size(entry->bstream); -} - -/** - * Convert the input data stream to a bit stream. - * @param stream input data stream. - * @return length of the bit stream. - */ -static int QRenc_createBitStream(QRinput *stream) -{ - QRenc_List *list; - int bits = 0; - - assert(stream != NULL); - - list = stream->head; - while(list != NULL) { - bits += QRenc_encodeBitStream(list, stream->version); - list = list->next; - } - - return bits; -} - -/** - * Convert the input data stream to a bit stream. - * When the version number is given and that is not sufficient, it is increased - * automatically. - * @param stream input data stream. - * @return -1 if the input data was too large. Otherwise 0. - */ -static int QRenc_convertData(QRinput *stream) -{ - int bits; - int ver; - - ver = QRenc_estimateVersion(stream); - if(ver > QRenc_getVersion(stream)) { - QRenc_setVersion(stream, ver); - } - - for(;;) { - bits = QRenc_createBitStream(stream); - ver = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); - if(ver < 0) { - return -1; - } else if(ver > QRenc_getVersion(stream)) { - QRenc_setVersion(stream, ver); - } else { - break; - } - } - - return 0; -} - -/** - * Create padding bits for the input stream. - * @param stream input data stream. - * @return padding bit stream. - */ -static BitStream *QRenc_createPaddingBit(QRinput *stream) -{ - int bits, maxbits, words, maxwords, i; - QRenc_List *list; - BitStream *bstream; - - if(stream->version <= 0) - return NULL; - - maxwords = QRspec_getDataLength(stream->version, stream->level); - maxbits = maxwords * 8; - - list = stream->head; - bits = 0; - while(list != NULL) { - bits += BitStream_size(list->bstream); - list = list->next; - } - - words = (bits + 7) / 8; - - if(bits == maxbits) - return NULL; - - if(maxbits - bits < 5) { - bstream = BitStream_new(); - BitStream_appendNum(bstream, maxbits - bits, 0); - return bstream; - } - - bstream = BitStream_new(); - BitStream_appendNum(bstream, words * 8 - bits, 0); - - for(i=0; ihead; - while(list != NULL) { - BitStream_append(bstream, list->bstream); - list = list->next; - } - - return bstream; -} - -/** - * Merge all bit streams in the input data stream and append padding bits - * @param stream input data stream. - * @return padded merged bit stream - */ - -BitStream *QRenc_getBitStream(QRinput *stream) -{ - BitStream *bstream; - BitStream *padding; - - bstream = QRenc_mergeBitStream(stream); - if(bstream == NULL) { - return NULL; - } - padding = QRenc_createPaddingBit(stream); - BitStream_append(bstream, padding); - BitStream_free(padding); - - return bstream; -} - -/** - * Pack all bit streams padding bits into a byte array. - * @param stream input data stream. - * @return padded merged byte stream - */ - -unsigned char *QRenc_getByteStream(QRinput *stream) -{ - BitStream *bstream; - unsigned char *array; - - bstream = QRenc_getBitStream(stream); - array = BitStream_toByte(bstream); - BitStream_free(bstream); - - return array; -} diff --git a/datastream.h b/datastream.h deleted file mode 100644 index 42895210fa..0000000000 --- a/datastream.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * qrencode - QR-code encoder - * - * Copyright (C) 2006 Kentaro Fukuchi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __DATASTREAM_H__ -#define __DATASTREAM_H__ - -#include "qrencode.h" -#include "bitstream.h" - -/****************************************************************************** - * Entry of input data stream - *****************************************************************************/ -typedef struct _QRenc_List QRenc_List; - -/****************************************************************************** - * Input Data stream - *****************************************************************************/ -struct _QRinput { - int version; - QRecLevel level; - QRenc_List *head; - QRenc_List *tail; -}; - -/** - * Pack all bit streams padding bits into a byte array. - * @param stream input data stream. - * @return padded merged byte stream - */ -extern unsigned char *QRenc_getByteStream(QRinput *stream); - -extern int QRenc_estimateBitStreamSize(QRinput *stream, int version); -extern BitStream *QRenc_mergeBitStream(QRinput *stream); -extern BitStream *QRenc_getBitStream(QRinput *stream); - -#endif /* __DATASTREAM_H__ */ diff --git a/qrencode.c b/qrencode.c index 945aa00b81..071df9abc7 100644 --- a/qrencode.c +++ b/qrencode.c @@ -28,7 +28,7 @@ #include "qrencode_inner.h" #include "qrspec.h" #include "bitstream.h" -#include "datastream.h" +#include "qrinput.h" #include "rscode.h" /****************************************************************************** diff --git a/qrinput.c b/qrinput.c new file mode 100644 index 0000000000..b46b28b99e --- /dev/null +++ b/qrinput.c @@ -0,0 +1,769 @@ +/* + * qrencode - QR-code encoder + * + * Copyright (C) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include + +#include "qrencode.h" +#include "qrspec.h" +#include "bitstream.h" +#include "qrinput.h" + +/****************************************************************************** + * Entry of input data stream + *****************************************************************************/ + +struct _QRenc_List { + QRencodeMode mode; + int size; ///< Size of data chunk (byte). + unsigned char *data; ///< Data chunk. + BitStream *bstream; + QRenc_List *next; +}; + +static QRenc_List *QRenc_newEntry(QRencodeMode mode, int size, unsigned char *data) +{ + QRenc_List *entry; + + if(QRinput_check(mode, size, data)) { + return NULL; + } + + entry = (QRenc_List *)malloc(sizeof(QRenc_List)); + entry->mode = mode; + entry->size = size; + entry->data = (unsigned char *)malloc(size); + memcpy(entry->data, data, size); + entry->bstream = NULL; + entry->next = NULL; + + return entry; +} + +static QRenc_List *QRenc_freeEntry(QRenc_List *entry) +{ + QRenc_List *next; + + next = entry->next; + free(entry->data); + if(entry->bstream) { + BitStream_free(entry->bstream); + } + free(entry); + + return next; +} + +/****************************************************************************** + * Input Data stream + *****************************************************************************/ + +QRinput *QRinput_new(void) +{ + QRinput *stream; + + stream = (QRinput *)malloc(sizeof(QRinput)); + stream->head = NULL; + stream->tail = NULL; + stream->version = 0; + stream->level = QR_ECLEVEL_L; + + return stream; +} + +int QRenc_getVersion(QRinput *stream) +{ + return stream->version; +} + +void QRenc_setVersion(QRinput *stream, int v) +{ + stream->version = v; +} + +void QRenc_setErrorCorrectionLevel(QRinput *stream, QRecLevel level) +{ + stream->level = level; +} + +QRecLevel QRenc_getErrorCorrectionLevel(QRinput *stream) +{ + return stream->level; +} + +int QRinput_append(QRinput *stream, QRencodeMode mode, int size, unsigned char *data) +{ + QRenc_List *entry; + + entry = QRenc_newEntry(mode, size, data); + if(entry == NULL) { + return -1; + } + + if(stream->tail == NULL) { + stream->head = entry; + stream->tail = entry; + } else { + stream->tail->next = entry; + stream->tail = entry; + } + + return 0; +} + +void QRinput_free(QRinput *stream) +{ + QRenc_List *list; + + list = stream->head; + while(list != NULL) { + list = QRenc_freeEntry(list); + } + + free(stream); +} + +/****************************************************************************** + * Numeric data + *****************************************************************************/ + +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeNum(int size, const char *data) +{ + int i; + + for(i=0; i '9') + return -1; + } + + return 0; +} + +/** + * Estimates the length of the encoded bit stream of numeric data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsModeNum(QRenc_List *entry) +{ + int w; + int bits; + + w = entry->size / 3; + bits = w * 10; + switch(entry->size - w * 3) { + case 1: + bits += 4; + break; + case 2: + bits += 7; + break; + default: + break; + } + + return bits; +} + +/** + * Convert the number data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeModeNum(QRenc_List *entry, int version) +{ + int words; + int i; + unsigned int val; + + words = entry->size / 3; + entry->bstream = BitStream_new(); + + val = 0x1; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val); + + for(i=0; idata[i*3 ] - '0') * 100; + val += (entry->data[i*3+1] - '0') * 10; + val += (entry->data[i*3+2] - '0'); + + BitStream_appendNum(entry->bstream, 10, val); + } + + if(entry->size - words * 3 == 1) { + val = entry->data[words*3] - '0'; + BitStream_appendNum(entry->bstream, 4, val); + } else if(entry->size - words * 3 == 2) { + val = (entry->data[words*3 ] - '0') * 10; + val += (entry->data[words*3+1] - '0'); + BitStream_appendNum(entry->bstream, 7, val); + } +} + +/****************************************************************************** + * Alphabet-numeric data + *****************************************************************************/ + +static signed char anTable[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1 +}; + +/** + * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). + * @param c character + * @return value + */ +inline static signed char QRenc_lookAnTable(char c) +{ + if(c & 0x80) { + return -1; + } + return anTable[(int)c]; +} + +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeAn(int size, const char *data) +{ + int i; + + for(i=0; isize / 2; + bits = w * 11; + if(entry->size & 1) { + bits += 6; + } + + return bits; +} + +/** + * Convert the alphabet-numeric data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeModeAn(QRenc_List *entry, int version) +{ + int words; + int i; + unsigned int val; + + words = entry->size / 2; + entry->bstream = BitStream_new(); + + val = 0x2; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), val); + + for(i=0; idata[i*2 ]) * 45; + val += (unsigned int)QRenc_lookAnTable(entry->data[i*2+1]); + + BitStream_appendNum(entry->bstream, 11, val); + } + + if(entry->size & 1) { + val = (unsigned int)QRenc_lookAnTable(entry->data[words * 2]); + + BitStream_appendNum(entry->bstream, 6, val); + } +} + +/****************************************************************************** + * 8 bit data + *****************************************************************************/ + +/** + * Estimates the length of the encoded bit stream of 8 bit data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsMode8(QRenc_List *entry) +{ + return entry->size * 8; +} + +/** + * Convert the 8bits data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeMode8(QRenc_List *entry, int version) +{ + int i; + unsigned int val; + + entry->bstream = BitStream_new(); + + val = 0x4; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), val); + + for(i=0; isize; i++) { + BitStream_appendNum(entry->bstream, 8, entry->data[i]); + } +} + + +/****************************************************************************** + * Kanji data + *****************************************************************************/ + +/** + * Estimates the length of the encoded bit stream of kanji data. + * @param entry + * @return number of bits + */ +static int QRenc_estimateBitsModeKanji(QRenc_List *entry) +{ + return (entry->size / 2) * 13; +} + +/** + * Check the input data. + * @param size + * @param data + * @return result + */ +static int QRenc_checkModeKanji(int size, const unsigned char *data) +{ + int i; + unsigned int val; + + if(size & 1) + return -1; + + for(i=0; i 0x9ffc && val < 0xe040) || val > 0xebbf) { + return -1; + } + } + + return 0; +} + +/** + * Convert the kanji data stream to a bit stream. + * @param entry + */ +static void QRenc_encodeModeKanji(QRenc_List *entry, int version) +{ + int i; + unsigned int val, h; + + entry->bstream = BitStream_new(); + + val = 0x8; + BitStream_appendNum(entry->bstream, 4, val); + + val = entry->size / 2; + BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), val); + + for(i=0; isize; i+=2) { + val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1]; + if(val <= 0x9ffc) { + val -= 0x8140; + } else { + val -= 0xc140; + } + h = (val >> 8) * 0xc0; + val = (val & 0xff) + h; + + BitStream_appendNum(entry->bstream, 13, val); + } +} + +/****************************************************************************** + * Validation + *****************************************************************************/ + +/** + * Validate the input data + * @param mode + * @param size + * @param data + * @return result + */ +int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) +{ + switch(mode) { + case QR_MODE_NUM: + return QRenc_checkModeNum(size, (const char *)data); + break; + case QR_MODE_AN: + return QRenc_checkModeAn(size, (const char *)data); + break; + case QR_MODE_KANJI: + return QRenc_checkModeKanji(size, data); + break; + default: + break; + } + + return 0; +} + +/****************************************************************************** + * Estimation of the bit length + *****************************************************************************/ + +/** + * Estimates the length of the encoded bit stream on the current version. + * @param entry + * @param version version of the symbol + * @return number of bits + */ +static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) +{ + int bits = 0; + int l, m; + int num; + + assert(entry != NULL); + switch(entry->mode) { + case QR_MODE_NUM: + bits = QRenc_estimateBitsModeNum(entry); + break; + case QR_MODE_AN: + bits = QRenc_estimateBitsModeAn(entry); + break; + case QR_MODE_8: + bits = QRenc_estimateBitsMode8(entry); + break; + case QR_MODE_KANJI: + bits = QRenc_estimateBitsModeKanji(entry); + break; + } + + l = QRspec_lengthIndicator(entry->mode, version); + m = 1 << l; + num = (bits + m - 1) / m; + + bits += num * (4 + l); // mode indicator (4bits) + length indicator + + return bits; +} + +/** + * Estimates the length of the encoded bit stream of the data stream. + * @param stream data stream + * @param version version of the symbol + * @return number of bits + */ +int QRenc_estimateBitStreamSize(QRinput *stream, int version) +{ + QRenc_List *list; + int bits = 0; + + assert(stream != NULL); + + list = stream->head; + while(list != NULL) { + bits += QRenc_estimateBitStreamSizeOfEntry(list, version); + list = list->next; + } + + return bits; +} + +/** + * Estimates the required version number of the symbol. + * @param stream data stream + * @return required version number + */ +static int QRenc_estimateVersion(QRinput *stream) +{ + int bits; + int new, prev; + + new = 0; + do { + prev = new; + bits = QRenc_estimateBitStreamSize(stream, prev); + new = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); + if (new == -1) { + return -1; + } + } while (new > prev); + + return new; +} + +/****************************************************************************** + * Data conversion + *****************************************************************************/ + +/** + * Convert the data stream in the data chunk to a bit stream. + * @param entry + * @return number of bits + */ +static int QRenc_encodeBitStream(QRenc_List *entry, int version) +{ + int words; + QRenc_List *st1, *st2; + + assert(entry != NULL); + + if(entry->bstream != NULL) { + BitStream_free(entry->bstream); + entry->bstream = NULL; + } + + words = QRspec_maximumWords(entry->mode, version); + if(entry->size > words) { + st1 = QRenc_newEntry(entry->mode, words, entry->data); + st2 = QRenc_newEntry(entry->mode, entry->size - words, &entry->data[words]); + QRenc_encodeBitStream(st1, version); + QRenc_encodeBitStream(st2, version); + entry->bstream = BitStream_new(); + BitStream_append(entry->bstream, st1->bstream); + BitStream_append(entry->bstream, st2->bstream); + QRenc_freeEntry(st1); + QRenc_freeEntry(st2); + } else { + switch(entry->mode) { + case QR_MODE_NUM: + QRenc_encodeModeNum(entry, version); + break; + case QR_MODE_AN: + QRenc_encodeModeAn(entry, version); + break; + case QR_MODE_8: + QRenc_encodeMode8(entry, version); + break; + case QR_MODE_KANJI: + QRenc_encodeModeKanji(entry, version); + break; + default: + break; + } + } + + return BitStream_size(entry->bstream); +} + +/** + * Convert the input data stream to a bit stream. + * @param stream input data stream. + * @return length of the bit stream. + */ +static int QRenc_createBitStream(QRinput *stream) +{ + QRenc_List *list; + int bits = 0; + + assert(stream != NULL); + + list = stream->head; + while(list != NULL) { + bits += QRenc_encodeBitStream(list, stream->version); + list = list->next; + } + + return bits; +} + +/** + * Convert the input data stream to a bit stream. + * When the version number is given and that is not sufficient, it is increased + * automatically. + * @param stream input data stream. + * @return -1 if the input data was too large. Otherwise 0. + */ +static int QRenc_convertData(QRinput *stream) +{ + int bits; + int ver; + + ver = QRenc_estimateVersion(stream); + if(ver > QRenc_getVersion(stream)) { + QRenc_setVersion(stream, ver); + } + + for(;;) { + bits = QRenc_createBitStream(stream); + ver = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); + if(ver < 0) { + return -1; + } else if(ver > QRenc_getVersion(stream)) { + QRenc_setVersion(stream, ver); + } else { + break; + } + } + + return 0; +} + +/** + * Create padding bits for the input stream. + * @param stream input data stream. + * @return padding bit stream. + */ +static BitStream *QRenc_createPaddingBit(QRinput *stream) +{ + int bits, maxbits, words, maxwords, i; + QRenc_List *list; + BitStream *bstream; + + if(stream->version <= 0) + return NULL; + + maxwords = QRspec_getDataLength(stream->version, stream->level); + maxbits = maxwords * 8; + + list = stream->head; + bits = 0; + while(list != NULL) { + bits += BitStream_size(list->bstream); + list = list->next; + } + + words = (bits + 7) / 8; + + if(bits == maxbits) + return NULL; + + if(maxbits - bits < 5) { + bstream = BitStream_new(); + BitStream_appendNum(bstream, maxbits - bits, 0); + return bstream; + } + + bstream = BitStream_new(); + BitStream_appendNum(bstream, words * 8 - bits, 0); + + for(i=0; ihead; + while(list != NULL) { + BitStream_append(bstream, list->bstream); + list = list->next; + } + + return bstream; +} + +/** + * Merge all bit streams in the input data stream and append padding bits + * @param stream input data stream. + * @return padded merged bit stream + */ + +BitStream *QRenc_getBitStream(QRinput *stream) +{ + BitStream *bstream; + BitStream *padding; + + bstream = QRenc_mergeBitStream(stream); + if(bstream == NULL) { + return NULL; + } + padding = QRenc_createPaddingBit(stream); + BitStream_append(bstream, padding); + BitStream_free(padding); + + return bstream; +} + +/** + * Pack all bit streams padding bits into a byte array. + * @param stream input data stream. + * @return padded merged byte stream + */ + +unsigned char *QRenc_getByteStream(QRinput *stream) +{ + BitStream *bstream; + unsigned char *array; + + bstream = QRenc_getBitStream(stream); + array = BitStream_toByte(bstream); + BitStream_free(bstream); + + return array; +} diff --git a/qrinput.h b/qrinput.h new file mode 100644 index 0000000000..42895210fa --- /dev/null +++ b/qrinput.h @@ -0,0 +1,53 @@ +/* + * qrencode - QR-code encoder + * + * Copyright (C) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __DATASTREAM_H__ +#define __DATASTREAM_H__ + +#include "qrencode.h" +#include "bitstream.h" + +/****************************************************************************** + * Entry of input data stream + *****************************************************************************/ +typedef struct _QRenc_List QRenc_List; + +/****************************************************************************** + * Input Data stream + *****************************************************************************/ +struct _QRinput { + int version; + QRecLevel level; + QRenc_List *head; + QRenc_List *tail; +}; + +/** + * Pack all bit streams padding bits into a byte array. + * @param stream input data stream. + * @return padded merged byte stream + */ +extern unsigned char *QRenc_getByteStream(QRinput *stream); + +extern int QRenc_estimateBitStreamSize(QRinput *stream, int version); +extern BitStream *QRenc_mergeBitStream(QRinput *stream); +extern BitStream *QRenc_getBitStream(QRinput *stream); + +#endif /* __DATASTREAM_H__ */ diff --git a/tests/test_datastream.c b/tests/test_datastream.c index f07cf56c4d..ccb5d75067 100644 --- a/tests/test_datastream.c +++ b/tests/test_datastream.c @@ -1,7 +1,7 @@ #include #include #include "common.h" -#include "../datastream.h" +#include "../qrinput.h" #include "../qrencode_inner.h" void test_encodeKanji(void) diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index 856bb5af51..f718a2de9f 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -2,7 +2,7 @@ #include #include #include "common.h" -#include "../datastream.h" +#include "../qrinput.h" #include "../qrencode_inner.h" QRinput *gstream; -- cgit 0.0.5-2-1-g0f52 From 1f3df63575dc83ee26e7d8637e20e0c6fab68635 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 16 Nov 2006 14:30:58 +0000 Subject: --- qrencode.c | 10 +-- qrencode.h | 4 +- tests/Makefile.am | 6 +- tests/test_datastream.c | 173 ------------------------------------------------ tests/test_qrencode.c | 4 +- tests/test_qrinput.c | 173 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/view_qrcode.c | 2 +- 7 files changed, 186 insertions(+), 186 deletions(-) delete mode 100644 tests/test_datastream.c create mode 100644 tests/test_qrinput.c diff --git a/qrencode.c b/qrencode.c index 071df9abc7..77b9d0e954 100644 --- a/qrencode.c +++ b/qrencode.c @@ -515,7 +515,7 @@ static unsigned char *QRenc_mask(int width, unsigned char *frame, QRecLevel leve * QR-code encoding *****************************************************************************/ -static QRcode *QRenc_newQRcode(int width, unsigned char *data) +static QRcode *QRcode_new(int width, unsigned char *data) { QRcode *qrcode; @@ -526,7 +526,7 @@ static QRcode *QRenc_newQRcode(int width, unsigned char *data) return qrcode; } -void QRenc_freeQRcode(QRcode *qrcode) +void QRcode_free(QRcode *qrcode) { if(qrcode == NULL) return; @@ -536,7 +536,7 @@ void QRenc_freeQRcode(QRcode *qrcode) free(qrcode); } -QRcode *QRenc_encode(QRinput *stream) +QRcode *QRcode_encodeInput(QRinput *stream) { int version; int width; @@ -572,7 +572,7 @@ QRcode *QRenc_encode(QRinput *stream) free(filler); /* masking */ masked = QRenc_mask(width, frame, QRenc_getErrorCorrectionLevel(stream)); - qrcode = QRenc_newQRcode(width, masked); + qrcode = QRcode_new(width, masked); free(frame); @@ -617,7 +617,7 @@ QRcode *QRenc_encodeMask(QRinput *stream, int mask) masked = (unsigned char *)malloc(width * width); maskMakers[mask](width, frame, masked); QRenc_writeFormatInformation(width, masked, mask, QRenc_getErrorCorrectionLevel(stream)); - qrcode = QRenc_newQRcode(width, masked); + qrcode = QRcode_new(width, masked); free(frame); diff --git a/qrencode.h b/qrencode.h index 27032fd4a6..0af83f878f 100644 --- a/qrencode.h +++ b/qrencode.h @@ -129,12 +129,12 @@ typedef struct { * @param stream input data stream. * @return an instance of QRcode class. */ -extern QRcode *QRenc_encode(QRinput *stream); +extern QRcode *QRcode_encodeInput(QRinput *stream); /** * Free the instance of QRcode class. * @param qrcode an instance of QRcode class. */ -extern void QRenc_freeQRcode(QRcode *qrcode); +extern void QRcode_free(QRcode *qrcode); #endif /* __QRENCODE_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 8e8f988b51..63212592c4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,11 +1,11 @@ if HAVE_SDL sdlPROGRAMS = view_qrcode endif -noinst_PROGRAMS = test_datastream test_bitstream test_estimatebit \ +noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_qrspec test_rs test_qrencode $(sdlPROGRAMS) -test_datastream_SOURCES = test_datastream.c -test_datastream_LDADD = ../libqrencode.la +test_qrinput_SOURCES = test_qrinput.c +test_qrinput_LDADD = ../libqrencode.la test_bitstream_SOURCES = test_bitstream.c test_bitstream_LDADD = ../bitstream.o diff --git a/tests/test_datastream.c b/tests/test_datastream.c deleted file mode 100644 index ccb5d75067..0000000000 --- a/tests/test_datastream.c +++ /dev/null @@ -1,173 +0,0 @@ -#include -#include -#include "common.h" -#include "../qrinput.h" -#include "../qrencode_inner.h" - -void test_encodeKanji(void) -{ - QRinput *stream; - unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; - char correct[] = "10000000001001101100111111101010101010"; - BitStream *bstream; - - testStart("Encoding kanji stream."); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_KANJI, 4, (unsigned char *)str); - bstream = QRenc_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(strcmp(correct, bstream->data)); - QRinput_free(stream); - BitStream_free(bstream); -} - -void test_encode8(void) -{ - QRinput *stream; - char str[] = "AC-42"; - char correct[] = "00100000001010011100111011100111001000010"; - BitStream *bstream; - - testStart("Encoding alphabet-numeric stream."); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); - bstream = QRenc_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(strcmp(correct, bstream->data)); - QRinput_free(stream); - BitStream_free(bstream); -} - -void test_encodeAn(void) -{ - QRinput *stream; - char str[] = "AC-42"; - char correct[] = "00100000001010011100111011100111001000010"; - BitStream *bstream; - - testStart("Encoding alphabet-numeric stream."); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); - bstream = QRenc_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(strcmp(correct, bstream->data)); - QRinput_free(stream); - BitStream_free(bstream); -} - -void test_encodeAn2(void) -{ - QRinput *stream; - char str[] = "!,;$%"; - int ret; - - testStart("Encoding INVALID alphabet-numeric stream."); - stream = QRinput_new(); - ret = QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); - testEnd(!ret); - QRinput_free(stream); -} - -void test_encodeNumeric(void) -{ - QRinput *stream; - char num[9] = "01234567"; - char correct[] = "00010000001000000000110001010110011000011"; - BitStream *bstream; - - testStart("Encoding numeric stream. (8 digits)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - bstream = QRenc_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(strcmp(correct, bstream->data)); - QRinput_free(stream); - BitStream_free(bstream); -} - -void test_encodeNumericPadded(void) -{ - QRinput *stream; - char num[9] = "01234567"; - char correct[] = "000100000010000000001100010101100110000110000000"; - BitStream *bstream; - int flag; - - testStart("Encoding numeric stream. (8 digits)(padded)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - bstream = QRenc_getBitStream(stream); - flag = strncmp(correct, bstream->data, 48); - printf("%s\n", bstream->data); - if(strlen(bstream->data) != 19 * 8) - flag |= 0x80; - testEnd(flag); - - QRinput_free(stream); - BitStream_free(bstream); -} - -void test_encodeNumeric2(void) -{ - QRinput *stream; - char num[] = "0123456789012345"; - char correct[] = "00010000010000000000110001010110011010100110111000010100111010100101"; - BitStream *bstream; - - testStart("Encoding numeric stream. (16 digits)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num); - bstream = QRenc_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(strcmp(correct, bstream->data)); - QRinput_free(stream); - BitStream_free(bstream); -} - -void test_encode82(void) -{ - QRinput *stream; - unsigned char *data; - BitStream *bstream; - char c1[] = "010011111111"; - char c2[] = "010000000010"; - int flag = 0; - - data = (unsigned char *)malloc(257); - memset(data, 0, 257); - testStart("Encoding byte stream. (257 bytes)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_8, 257, data); - bstream = QRenc_mergeBitStream(stream); - if(strncmp(c1, bstream->data, 12)) { - flag++; - } - if(strncmp(c2, bstream->data + 12 + 255*8, 12)) { - flag++; - } - testEnd(flag); - QRinput_free(stream); - BitStream_free(bstream); - free(data); -} - -int main(int argc, char **argv) -{ - test_encodeNumeric(); - test_encodeNumeric2(); - test_encode8(); -// test_encode82(); - test_encodeAn(); - test_encodeAn2(); - test_encodeKanji(); - test_encodeNumericPadded(); - - report(); - - return 0; -} diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index f71852db04..962a0e8454 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -325,7 +325,7 @@ void test_encode(void) QRenc_setVersion(stream, 1); QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_L); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - qrcode = QRenc_encode(stream); + qrcode = QRcode_encodeInput(stream); w = qrcode->width; frame = qrcode->data; for(y=0; y +#include +#include "common.h" +#include "../qrinput.h" +#include "../qrencode_inner.h" + +void test_encodeKanji(void) +{ + QRinput *stream; + unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; + char correct[] = "10000000001001101100111111101010101010"; + BitStream *bstream; + + testStart("Encoding kanji stream."); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_KANJI, 4, (unsigned char *)str); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRinput_free(stream); + BitStream_free(bstream); +} + +void test_encode8(void) +{ + QRinput *stream; + char str[] = "AC-42"; + char correct[] = "00100000001010011100111011100111001000010"; + BitStream *bstream; + + testStart("Encoding alphabet-numeric stream."); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRinput_free(stream); + BitStream_free(bstream); +} + +void test_encodeAn(void) +{ + QRinput *stream; + char str[] = "AC-42"; + char correct[] = "00100000001010011100111011100111001000010"; + BitStream *bstream; + + testStart("Encoding alphabet-numeric stream."); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRinput_free(stream); + BitStream_free(bstream); +} + +void test_encodeAn2(void) +{ + QRinput *stream; + char str[] = "!,;$%"; + int ret; + + testStart("Encoding INVALID alphabet-numeric stream."); + stream = QRinput_new(); + ret = QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); + testEnd(!ret); + QRinput_free(stream); +} + +void test_encodeNumeric(void) +{ + QRinput *stream; + char num[9] = "01234567"; + char correct[] = "00010000001000000000110001010110011000011"; + BitStream *bstream; + + testStart("Encoding numeric stream. (8 digits)"); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRinput_free(stream); + BitStream_free(bstream); +} + +void test_encodeNumericPadded(void) +{ + QRinput *stream; + char num[9] = "01234567"; + char correct[] = "000100000010000000001100010101100110000110000000"; + BitStream *bstream; + int flag; + + testStart("Encoding numeric stream. (8 digits)(padded)"); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); + bstream = QRenc_getBitStream(stream); + flag = strncmp(correct, bstream->data, 48); + printf("%s\n", bstream->data); + if(strlen(bstream->data) != 19 * 8) + flag |= 0x80; + testEnd(flag); + + QRinput_free(stream); + BitStream_free(bstream); +} + +void test_encodeNumeric2(void) +{ + QRinput *stream; + char num[] = "0123456789012345"; + char correct[] = "00010000010000000000110001010110011010100110111000010100111010100101"; + BitStream *bstream; + + testStart("Encoding numeric stream. (16 digits)"); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num); + bstream = QRenc_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRinput_free(stream); + BitStream_free(bstream); +} + +void test_encode82(void) +{ + QRinput *stream; + unsigned char *data; + BitStream *bstream; + char c1[] = "010011111111"; + char c2[] = "010000000010"; + int flag = 0; + + data = (unsigned char *)malloc(257); + memset(data, 0, 257); + testStart("Encoding byte stream. (257 bytes)"); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_8, 257, data); + bstream = QRenc_mergeBitStream(stream); + if(strncmp(c1, bstream->data, 12)) { + flag++; + } + if(strncmp(c2, bstream->data + 12 + 255*8, 12)) { + flag++; + } + testEnd(flag); + QRinput_free(stream); + BitStream_free(bstream); + free(data); +} + +int main(int argc, char **argv) +{ + test_encodeNumeric(); + test_encodeNumeric2(); + test_encode8(); +// test_encode82(); + test_encodeAn(); + test_encodeAn2(); + test_encodeKanji(); + test_encodeNumericPadded(); + + report(); + + return 0; +} diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index c535b3d4e2..6d57c5aab8 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -81,7 +81,7 @@ void view_simple(void) } } SDL_Flip(screen); - QRenc_freeQRcode(qrcode); + QRcode_free(qrcode); loop = 1; while(loop) { usleep(10000); -- cgit 0.0.5-2-1-g0f52 From dc4d232ab2af26fe4dfd35b762888239bf0bc979 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 17 Nov 2006 09:53:50 +0000 Subject: --- qrencode.c | 12 +++++++----- qrencode.h | 30 +----------------------------- qrencode_inner.h | 2 +- qrinput.h | 28 ++++++++++++++++++++++++++++ tests/test_qrencode.c | 5 ++--- tests/test_rs.c | 1 + tests/view_qrcode.c | 4 +--- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/qrencode.c b/qrencode.c index 77b9d0e954..fe62de01af 100644 --- a/qrencode.c +++ b/qrencode.c @@ -536,9 +536,8 @@ void QRcode_free(QRcode *qrcode) free(qrcode); } -QRcode *QRcode_encodeInput(QRinput *stream) +QRcode *QRcode_encodeInput(QRinput *stream, int version, QRecLevel level) { - int version; int width; QRRawCode *raw; unsigned char *frame, *masked, *p, code, bit; @@ -546,6 +545,9 @@ QRcode *QRcode_encodeInput(QRinput *stream) int i, j; QRcode *qrcode; + QRenc_setVersion(stream, version); + QRenc_setErrorCorrectionLevel(stream, level); + version = QRenc_getVersion(stream); width = QRspec_getWidth(version); raw = QRraw_new(stream); @@ -579,9 +581,8 @@ QRcode *QRcode_encodeInput(QRinput *stream) return qrcode; } -QRcode *QRenc_encodeMask(QRinput *stream, int mask) +QRcode *QRenc_encodeMask(QRinput *stream, int version, QRecLevel level, int mask) { - int version; int width; QRRawCode *raw; unsigned char *frame, *masked, *p, code, bit; @@ -589,7 +590,8 @@ QRcode *QRenc_encodeMask(QRinput *stream, int mask) int i, j; QRcode *qrcode; - version = QRenc_getVersion(stream); + QRenc_setVersion(stream, version); + QRenc_setErrorCorrectionLevel(stream, level); width = QRspec_getWidth(version); raw = QRraw_new(stream); frame = QRspec_newFrame(version); diff --git a/qrencode.h b/qrencode.h index 0af83f878f..f8dd624ec0 100644 --- a/qrencode.h +++ b/qrencode.h @@ -56,34 +56,6 @@ typedef struct _QRinput QRinput; */ extern QRinput *QRinput_new(void); -/** - * Get current error correction level. - * @param stream input data stream - * @return Current error correcntion level. - */ -extern QRecLevel QRenc_getErrorCorrectionLevel(QRinput *stream); - -/** - * Set error correction level of the QR-code that is to be encoded. - * @param stream input data stream - * @param level Error correction level. - */ -extern void QRenc_setErrorCorrectionLevel(QRinput *stream, QRecLevel level); - -/** - * Get current version. - * @param stream input data stream - * @return current version - */ -extern int QRenc_getVersion(QRinput *stream); - -/** - * Set version of the QR-code that is to be encoded. - * @param stream input data stream - * @param version version number (0 = auto) - */ -extern void QRenc_setVersion(QRinput *stream, int version); - /** * Append data to the stream object. * The data is copied and appended to the stream object. @@ -129,7 +101,7 @@ typedef struct { * @param stream input data stream. * @return an instance of QRcode class. */ -extern QRcode *QRcode_encodeInput(QRinput *stream); +extern QRcode *QRcode_encodeInput(QRinput *stream, int version, QRecLevel level); /** * Free the instance of QRcode class. diff --git a/qrencode_inner.h b/qrencode_inner.h index 8772f8964f..46c3943e17 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -67,6 +67,6 @@ extern unsigned char *QRenc_makeMask(int width, unsigned char *frame, int mask); extern int QRenc_evaluateSymbol(int width, unsigned char *frame); -QRcode *QRenc_encodeMask(QRinput *stream, int mask); +QRcode *QRenc_encodeMask(QRinput *stream, int version, QRecLevel level, int mask); #endif /* __QRENCODE_INNER_H__ */ diff --git a/qrinput.h b/qrinput.h index 42895210fa..97d1bef7c3 100644 --- a/qrinput.h +++ b/qrinput.h @@ -39,6 +39,34 @@ struct _QRinput { QRenc_List *tail; }; +/** + * Get current error correction level. + * @param stream input data stream + * @return Current error correcntion level. + */ +extern QRecLevel QRenc_getErrorCorrectionLevel(QRinput *stream); + +/** + * Set error correction level of the QR-code that is to be encoded. + * @param stream input data stream + * @param level Error correction level. + */ +extern void QRenc_setErrorCorrectionLevel(QRinput *stream, QRecLevel level); + +/** + * Get current version. + * @param stream input data stream + * @return current version + */ +extern int QRenc_getVersion(QRinput *stream); + +/** + * Set version of the QR-code that is to be encoded. + * @param stream input data stream + * @param version version number (0 = auto) + */ +extern void QRenc_setVersion(QRinput *stream, int version); + /** * Pack all bit streams padding bits into a byte array. * @param stream input data stream. diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 962a0e8454..8e64be3b73 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -3,6 +3,7 @@ #include "common.h" #include "../qrencode_inner.h" #include "../qrspec.h" +#include "../qrinput.h" void test_iterate() { @@ -322,10 +323,8 @@ void test_encode(void) testStart("Test encode (1-L)"); stream = QRinput_new(); - QRenc_setVersion(stream, 1); - QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_L); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - qrcode = QRcode_encodeInput(stream); + qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_L); w = qrcode->width; frame = qrcode->data; for(y=0; y #include "common.h" #include "../qrencode_inner.h" +#include "../qrinput.h" /* See pp. 73 of JIS X0510:2004 */ void test_rscode1(void) diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 6d57c5aab8..04b4df4bfb 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -60,9 +60,7 @@ void view_simple(void) QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); while(flag) { - QRenc_setVersion(stream, version); - QRenc_setErrorCorrectionLevel(stream, level); - qrcode = QRenc_encodeMask(stream, mask); + qrcode = QRenc_encodeMask(stream, version, level, mask); width = qrcode->width; frame = qrcode->data; pitch = screen->pitch; -- cgit 0.0.5-2-1-g0f52 From bb693a04a1e6631183fbccc4a0fe098a06083db2 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 17 Nov 2006 16:59:27 +0000 Subject: --- autogen.sh | 4 ++-- configure.ac | 30 +++++++++--------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/autogen.sh b/autogen.sh index c2d8b2d83b..e0767b76be 100755 --- a/autogen.sh +++ b/autogen.sh @@ -15,7 +15,7 @@ fi aclocal -I $ACLOCAL_DIR -libtoolize --automake #--copy -automake --add-missing #--copy +libtoolize --automake --copy +automake --add-missing --copy autoconf diff --git a/configure.ac b/configure.ac index 6e5c16ec8e..dd44f63dfa 100644 --- a/configure.ac +++ b/configure.ac @@ -1,50 +1,38 @@ -AC_INIT(QRencode, 0.1.0, fukuchi@megaui.net) +AC_INIT(QRencode) -dnl information on the package - -PACKAGE=qrencode MAJOR_VERSION=0 MINOR_VERSION=1 MICRO_VERSION=0 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION - -AC_SUBST(PACKAGE) AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) AC_SUBST(MICRO_VERSION) AC_SUBST(VERSION) AC_CONFIG_SRCDIR([qrencode.c]) - AC_CONFIG_AUX_DIR(use) - AC_CANONICAL_HOST AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE(QRencode, VERSION) +AM_INIT_AUTOMAKE(qrencode, $VERSION) + +AC_DISABLE_STATIC +AC_C_CONST +AC_C_INLINE +AC_HEADER_STDC -AC_PROG_MAKE_SET AC_PROG_CC AC_PROG_INSTALL -AC_DISABLE_STATIC AC_PROG_LIBTOOL + SDL_REQUIRED_VERSION=1.2.0 AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_ERROR([*** SDL $SDL_REQUIRED_VERSION or better is required.])) AM_CONDITIONAL(HAVE_SDL, test SDL_CFLAGS) CFLAGS="-Wall $CFLAGS" -dnl LDFLAGS="$LDFLAGS" - -AC_HEADER_STDC - -AC_C_CONST -AC_C_INLINE - -AC_PROG_GCC_TRADITIONAL -AC_CONFIG_FILES([Makefile - tests/Makefile]) +AC_CONFIG_FILES([Makefile tests/Makefile]) AC_OUTPUT -- cgit 0.0.5-2-1-g0f52 From abc1bb50a81de43e14bfc9fa682fdcc0541dc018 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 17 Nov 2006 18:11:04 +0000 Subject: --- qrencode.c | 28 ++++++++++++++-------------- qrencode.h | 53 ++++++++++++++++++++++++++++------------------------- qrinput.h | 6 +++--- 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/qrencode.c b/qrencode.c index fe62de01af..aace37bf6d 100644 --- a/qrencode.c +++ b/qrencode.c @@ -48,7 +48,7 @@ static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el) encode_rs_char(rs, data, block->ecc); } -QRRawCode *QRraw_new(QRinput *stream) +QRRawCode *QRraw_new(QRinput *input) { QRRawCode *raw; int *spec; @@ -57,8 +57,8 @@ QRRawCode *QRraw_new(QRinput *stream) unsigned char *p; raw = (QRRawCode *)malloc(sizeof(QRRawCode)); - raw->datacode = QRenc_getByteStream(stream); - spec = QRspec_getEccSpec(stream->version, stream->level); + raw->datacode = QRenc_getByteStream(input); + spec = QRspec_getEccSpec(input->version, input->level); raw->blocks = QRspec_rsBlockNum(spec); raw->rsblock = (RSblock *)malloc(sizeof(RSblock) * raw->blocks); @@ -536,7 +536,7 @@ void QRcode_free(QRcode *qrcode) free(qrcode); } -QRcode *QRcode_encodeInput(QRinput *stream, int version, QRecLevel level) +QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level) { int width; QRRawCode *raw; @@ -545,12 +545,12 @@ QRcode *QRcode_encodeInput(QRinput *stream, int version, QRecLevel level) int i, j; QRcode *qrcode; - QRenc_setVersion(stream, version); - QRenc_setErrorCorrectionLevel(stream, level); + QRenc_setVersion(input, version); + QRenc_setErrorCorrectionLevel(input, level); - version = QRenc_getVersion(stream); + version = QRenc_getVersion(input); width = QRspec_getWidth(version); - raw = QRraw_new(stream); + raw = QRraw_new(input); frame = QRspec_newFrame(version); filler = FrameFiller_new(width, frame); @@ -573,7 +573,7 @@ QRcode *QRcode_encodeInput(QRinput *stream, int version, QRecLevel level) } free(filler); /* masking */ - masked = QRenc_mask(width, frame, QRenc_getErrorCorrectionLevel(stream)); + masked = QRenc_mask(width, frame, QRenc_getErrorCorrectionLevel(input)); qrcode = QRcode_new(width, masked); free(frame); @@ -581,7 +581,7 @@ QRcode *QRcode_encodeInput(QRinput *stream, int version, QRecLevel level) return qrcode; } -QRcode *QRenc_encodeMask(QRinput *stream, int version, QRecLevel level, int mask) +QRcode *QRenc_encodeMask(QRinput *input, int version, QRecLevel level, int mask) { int width; QRRawCode *raw; @@ -590,10 +590,10 @@ QRcode *QRenc_encodeMask(QRinput *stream, int version, QRecLevel level, int mask int i, j; QRcode *qrcode; - QRenc_setVersion(stream, version); - QRenc_setErrorCorrectionLevel(stream, level); + QRenc_setVersion(input, version); + QRenc_setErrorCorrectionLevel(input, level); width = QRspec_getWidth(version); - raw = QRraw_new(stream); + raw = QRraw_new(input); frame = QRspec_newFrame(version); filler = FrameFiller_new(width, frame); @@ -618,7 +618,7 @@ QRcode *QRenc_encodeMask(QRinput *stream, int version, QRecLevel level, int mask /* masking */ masked = (unsigned char *)malloc(width * width); maskMakers[mask](width, frame, masked); - QRenc_writeFormatInformation(width, masked, mask, QRenc_getErrorCorrectionLevel(stream)); + QRenc_writeFormatInformation(width, masked, mask, QRenc_getErrorCorrectionLevel(input)); qrcode = QRcode_new(width, masked); free(frame); diff --git a/qrencode.h b/qrencode.h index f8dd624ec0..178950a0bf 100644 --- a/qrencode.h +++ b/qrencode.h @@ -35,51 +35,51 @@ typedef enum { * Level of error correction. */ typedef enum { - QR_ECLEVEL_L = 0, + QR_ECLEVEL_L = 0, ///< lowest QR_ECLEVEL_M, QR_ECLEVEL_Q, - QR_ECLEVEL_H + QR_ECLEVEL_H ///< highest } QRecLevel; /****************************************************************************** - * Input data stream + * Input data *****************************************************************************/ /** - * Data structure to store input data stream. + * Data structure to store input data. */ typedef struct _QRinput QRinput; /** - * Instantiate a data stream object. - * @return Stream object (initialized). + * Instantiate an input data object. + * @return input object (initialized). */ extern QRinput *QRinput_new(void); /** - * Append data to the stream object. - * The data is copied and appended to the stream object. - * @param stream Stream object. - * @param mode Encoding mode. - * @param size Size of data (byte). - * @param data A pointer to the memory area of the input data. - * @return -1 when the input data is invalid. Otherwise 0. + * Append data to the input object. + * The data is copied and appended to the input object. + * @param input input object. + * @param mode encoding mode. + * @param size size of data (byte). + * @param data a pointer to the memory area of the input data. + * @return -1 when the input data is invalid. Otherwise, return 0. */ -extern int QRinput_append(QRinput *stream, QRencodeMode mode, int size, unsigned char *data); +extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, unsigned char *data); /** - * Free the stream object. - * All of data chunks in the stream object are freed too. - * @param stream Stream object. + * Free the input object. + * All of data chunks in the input object are freed too. + * @param input input object. */ -extern void QRinput_free(QRinput *stream); +extern void QRinput_free(QRinput *input); /** - * Validate the input data + * Validate the input data. * @param mode * @param size * @param data - * @return result + * @return result return -1 if the input is invalid. Otherwise, return 0. */ extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data); @@ -91,17 +91,20 @@ extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) * QRcode class. */ typedef struct { - int version; //< version of the symbol - int width; //< width of the symbol - unsigned char *data; //< symbol data + int version; ///< version of the symbol + int width; ///< width of the symbol + unsigned char *data; ///< symbol data } QRcode; /** * Create a symbol from the input data stream. - * @param stream input data stream. + * @param input input data. + * @param version version of the symbol. If 0, the library chooses the minimum + * version for the input data. + * @param level error correction level. * @return an instance of QRcode class. */ -extern QRcode *QRcode_encodeInput(QRinput *stream, int version, QRecLevel level); +extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level); /** * Free the instance of QRcode class. diff --git a/qrinput.h b/qrinput.h index 97d1bef7c3..07f76a6ef6 100644 --- a/qrinput.h +++ b/qrinput.h @@ -18,8 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __DATASTREAM_H__ -#define __DATASTREAM_H__ +#ifndef __QRINPUT_H__ +#define __QRINPUT_H__ #include "qrencode.h" #include "bitstream.h" @@ -78,4 +78,4 @@ extern int QRenc_estimateBitStreamSize(QRinput *stream, int version); extern BitStream *QRenc_mergeBitStream(QRinput *stream); extern BitStream *QRenc_getBitStream(QRinput *stream); -#endif /* __DATASTREAM_H__ */ +#endif /* __QRINPUT_H__ */ -- cgit 0.0.5-2-1-g0f52 From ff80046904831cd83a202ad61009f661b2408f94 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 17 Nov 2006 19:53:02 +0000 Subject: --- tests/test_qrencode.c | 28 ++++++++++++++++++++++++++-- tests/test_qrspec.c | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 8e64be3b73..9685fc58ff 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -321,10 +321,10 @@ void test_encode(void) int x, y, w; QRcode *qrcode; - testStart("Test encode (1-L)"); + testStart("Test encode (1-M)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_L); + qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_M); w = qrcode->width; frame = qrcode->data; for(y=0; ywidth; + frame = qrcode->data; + for(y=0; y Date: Fri, 17 Nov 2006 20:10:07 +0000 Subject: --- qrencode.c | 27 +++++++++++++------------- qrencode.h | 21 ++++++++++++++++++--- qrencode_inner.h | 2 +- qrinput.c | 2 +- qrspec.c | 30 ++++++++++++++--------------- tests/test_qrencode.c | 52 +++++++++++++++++++++++++++++++++++++++------------ tests/view_qrcode.c | 2 +- 7 files changed, 89 insertions(+), 47 deletions(-) diff --git a/qrencode.c b/qrencode.c index aace37bf6d..f7699ecd2d 100644 --- a/qrencode.c +++ b/qrencode.c @@ -267,7 +267,7 @@ void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRe format = QRspec_getFormatInfo(mask, level); for(i=0; i<8; i++) { - v = (unsigned char)(format & 1); + v = (unsigned char)(format & 1) | 0x84; frame[width * 8 + width - 1 - i] = v; if(i < 6) { frame[width * i + 8] = v; @@ -277,7 +277,7 @@ void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRe format= format >> 1; } for(i=0; i<7; i++) { - v = (unsigned char)(format & 1); + v = (unsigned char)(format & 1) | 0x84; frame[width * (width - 7 + i) + 8] = v; if(i == 0) { frame[width * 8 + 7] = v; @@ -307,10 +307,10 @@ void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRe \ for(y=0; y> 1; } } @@ -569,19 +568,19 @@ QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level) j = QRspec_getRemainder(version); for(i=0; i> 1; } } @@ -612,14 +611,14 @@ QRcode *QRenc_encodeMask(QRinput *input, int version, QRecLevel level, int mask) j = QRspec_getRemainder(version); for(i=0; i> 1; } } p = frame + width - 11; - mask = 0x200; + mask = 0x20000; for(y=0; y<6; y++) { for(x=0; x<3; x++) { - p[x] = 0xc0 | ((mask & verinfo) != 0); + p[x] = 0x88 | ((mask & verinfo) != 0); mask = mask >> 1; } p += width; } } /* and a little bit... */ - frame[width * (width - 8) + 8] = 0xc1; + frame[width * (width - 8) + 8] = 0x81; return frame; } diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 9685fc58ff..0f1b08cc0b 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -312,6 +312,33 @@ void test_eval3(void) free(frame); } +unsigned int m1pat[8][21] = { + {0x1fc77f, 0x105c41, 0x174c5d, 0x174b5d, 0x175b5d, 0x104241, 0x1fd57f, + 0x000000, 0x154512, 0x1a16a2, 0x0376ee, 0x19abb2, 0x04eee1, 0x001442, + 0x1fc111, 0x10444b, 0x175d5d, 0x174aae, 0x175ae5, 0x1043b8, 0x1fd2e5}, + {0x1fdd7f, 0x104641, 0x17565d, 0x17415d, 0x17415d, 0x105841, 0x1fd57f, + 0x000a00, 0x146f25, 0x10bc08, 0x09dc44, 0x130118, 0x0e444b, 0x001ee8, + 0x1fdbbb, 0x104ee1, 0x1747f7, 0x174004, 0x17504f, 0x104912, 0x1fd84f}, + {0x1fcb7f, 0x104f41, 0x17505d, 0x17585d, 0x17575d, 0x105141, 0x1fd57f, + 0x001300, 0x17c97c, 0x02b52c, 0x046a9f, 0x01083c, 0x03f290, 0x0017cc, + 0x1fcd60, 0x1057c5, 0x17512c, 0x175920, 0x175694, 0x104036, 0x1fde94}, + {0x1fdb7f, 0x105441, 0x174d5d, 0x17585d, 0x174c5d, 0x104c41, 0x1fd57f, + 0x001800, 0x16e44b, 0x02b52c, 0x12f1f2, 0x1a258a, 0x03f290, 0x001ca1, + 0x1fd0d6, 0x1057c5, 0x174a41, 0x175496, 0x175694, 0x104b5b, 0x1fd322}, + {0x1fd37f, 0x104741, 0x17475d, 0x175f5d, 0x175f5d, 0x105941, 0x1fd57f, + 0x001400, 0x1171f9, 0x0c8dcf, 0x15ed83, 0x108f20, 0x0dca73, 0x001f2f, + 0x1fda7c, 0x1040d9, 0x1759cf, 0x1741c3, 0x174188, 0x10472a, 0x1fd677}, + {0x1fcd7f, 0x105741, 0x17505d, 0x17545d, 0x17475d, 0x104941, 0x1fd57f, + 0x001b00, 0x1059ce, 0x05a95d, 0x046a9f, 0x03001c, 0x0e444b, 0x001fec, + 0x1fcd60, 0x104bb4, 0x17412c, 0x174100, 0x17404f, 0x104816, 0x1fde94}, + {0x1fdd7f, 0x105741, 0x17545d, 0x17445d, 0x17555d, 0x104f41, 0x1fd57f, + 0x000b00, 0x13fd97, 0x05a95d, 0x00f8d6, 0x028604, 0x0e444b, 0x001f2f, + 0x1fd9f2, 0x105bb4, 0x175365, 0x175718, 0x17404f, 0x1048d5, 0x1fda06}, + {0x1fc77f, 0x104841, 0x174e5d, 0x174b5d, 0x174f5d, 0x105041, 0x1fd57f, + 0x000400, 0x12d7a0, 0x1a16a2, 0x0a527c, 0x1d39fb, 0x04eee1, 0x0010d0, + 0x1fc358, 0x10544b, 0x1749cf, 0x1758e7, 0x174ae5, 0x10472a, 0x1fd0ac} +}; + void test_encode(void) { QRinput *stream; @@ -319,27 +346,28 @@ void test_encode(void) unsigned char *frame; int err = 0; int x, y, w; + int mask; QRcode *qrcode; testStart("Test encode (1-M)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_M); - w = qrcode->width; - frame = qrcode->data; - for(y=0; ywidth; + frame = qrcode->data; + for(y=0; y> (20-x)) & 1) != (frame[y*w+x]&1)) { + printf("Diff in mask=%d (%d,%d)\n", mask, x, y); + err++; + } } } - printf("\n"); + QRcode_free(qrcode); } - testEnd(err); QRinput_free(stream); - QRcode_free(qrcode); + testEnd(err); } void print_encode(void) diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 04b4df4bfb..4d59f6a641 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -60,7 +60,7 @@ void view_simple(void) QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); while(flag) { - qrcode = QRenc_encodeMask(stream, version, level, mask); + qrcode = QRcode_encodeMask(stream, version, level, mask); width = qrcode->width; frame = qrcode->data; pitch = screen->pitch; -- cgit 0.0.5-2-1-g0f52 From b78d187fcd0e915ed8daf4ea0f93c2fabcd02e4e Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 17 Nov 2006 20:23:14 +0000 Subject: --- tests/test_bitstream.c | 6 +++--- tests/test_estimatebit.c | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 2b0fbfb411..7b68f025a2 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -81,10 +81,10 @@ int main(int argc, char **argv) { test_num(); test_bytes(); - test_appendBytes(); - test_toByte(); + test_appendBytes(); + test_toByte(); report(); - return 0; + return 0; } diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index f718a2de9f..ad5eb38d69 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -128,15 +128,15 @@ int main(int argc, char **argv) { gstream = QRinput_new(); - test_numbit(); - test_numbit2(); - test_numbit3(); - test_an(); - test_8(); - test_kanji(); + test_numbit(); + test_numbit2(); + test_numbit3(); + test_an(); + test_8(); + test_kanji(); test_mix(); report(); - return 0; + return 0; } -- cgit 0.0.5-2-1-g0f52 From 98ae1dd0d6d6dc655e4c9bde1b611fc3d94a3bed Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 17 Nov 2006 21:28:13 +0000 Subject: --- qrencode.c | 71 +++++++++---------------- qrencode_inner.h | 4 +- qrinput.c | 148 ++++++++++++++++++++++++++-------------------------- qrinput.h | 32 ++++++------ tests/view_qrcode.c | 35 +++++++++---- 5 files changed, 141 insertions(+), 149 deletions(-) diff --git a/qrencode.c b/qrencode.c index f7699ecd2d..3f2dd7c194 100644 --- a/qrencode.c +++ b/qrencode.c @@ -377,7 +377,12 @@ unsigned char *QRenc_makeMask(int width, unsigned char *frame, int mask) static int runLength[QRSPEC_WIDTH_MAX + 1]; -static int QRenC_calcN1N3(int length, int *runLength) +//static int n1; +//static int n2; +//static int n3; +//static int n4; + +static int QRenc_calcN1N3(int length, int *runLength) { int i; int demerit = 0; @@ -386,6 +391,7 @@ static int QRenC_calcN1N3(int length, int *runLength) for(i=0; i= 5) { demerit += N1 + (runLength[i] - 5); + //n1 += N1 + (runLength[i] - 5); } if((i & 1)) { if(i >= 3 && i < length-2 && (runLength[i] % 3) == 0) { @@ -396,8 +402,10 @@ static int QRenC_calcN1N3(int length, int *runLength) runLength[i+2] == fact) { if(runLength[i-3] < 0 || runLength[i-3] >= 4 * fact) { demerit += N3; + //n3 += N3; } else if(i+3 >= length || runLength[i+3] >= 4 * fact) { demerit += N3; + //n3 += N3; } } } @@ -427,6 +435,7 @@ int QRenc_evaluateSymbol(int width, unsigned char *frame) w22 = (p[0] | p[-1] | p[-width] | p [-width-1] ) & 1; if(b22 | (w22 ^ 1)) { demerit += N2; + //n2 += N2; } } if(x == 0 && (p[0] & 1)) { @@ -443,7 +452,7 @@ int QRenc_evaluateSymbol(int width, unsigned char *frame) } p++; } - demerit += QRenC_calcN1N3(head+1, runLength); + demerit += QRenc_calcN1N3(head+1, runLength); } i = 0; @@ -466,7 +475,7 @@ int QRenc_evaluateSymbol(int width, unsigned char *frame) } p+=width; } - demerit += QRenC_calcN1N3(head+1, runLength); + demerit += QRenc_calcN1N3(head+1, runLength); } return demerit; @@ -484,16 +493,19 @@ static unsigned char *QRenc_mask(int width, unsigned char *frame, QRecLevel leve bestMask = NULL; for(i=0; i<8; i++) { +// n1 = n2 = n3 = n4 = 0; demerit = 0; mask = (unsigned char *)malloc(width * width); blacks = maskMakers[i](width, frame, mask); blacks = 100 * blacks / (width * width); demerit = (abs(blacks - 50) / 5) * N4; +// n4 = demerit; if(demerit > minDemerit) { free(mask); continue; } demerit += QRenc_evaluateSymbol(width, mask); +// printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit); if(demerit < minDemerit) { minDemerit = demerit; bestMaskNum = i; @@ -520,6 +532,7 @@ static QRcode *QRcode_new(int version, int width, unsigned char *data) QRcode *qrcode; qrcode = (QRcode *)malloc(sizeof(QRcode)); + qrcode->version = version; qrcode->width = width; qrcode->data = data; @@ -538,46 +551,7 @@ void QRcode_free(QRcode *qrcode) QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level) { - int width; - QRRawCode *raw; - unsigned char *frame, *masked, *p, code, bit; - FrameFiller *filler; - int i, j; - QRcode *qrcode; - - QRenc_setVersion(input, version); - QRenc_setErrorCorrectionLevel(input, level); - - width = QRspec_getWidth(version); - raw = QRraw_new(input); - frame = QRspec_newFrame(version); - filler = FrameFiller_new(width, frame); - - /* inteleaved data and ecc codes */ - for(i=0; idataLength + raw->eccLength; i++) { - code = QRraw_getCode(raw); - bit = 0x80; - for(j=0; j<8; j++) { - p = FrameFiller_next(filler); - *p = 0x02 | ((bit & code) != 0); - bit = bit >> 1; - } - } - QRraw_free(raw); - /* remainder bits */ - j = QRspec_getRemainder(version); - for(i=0; ihead = NULL; - stream->tail = NULL; - stream->version = 0; - stream->level = QR_ECLEVEL_L; + input = (QRinput *)malloc(sizeof(QRinput)); + input->head = NULL; + input->tail = NULL; + input->version = 0; + input->level = QR_ECLEVEL_L; - return stream; + return input; } -int QRenc_getVersion(QRinput *stream) +int QRenc_getVersion(QRinput *input) { - return stream->version; + return input->version; } -void QRenc_setVersion(QRinput *stream, int v) +void QRenc_setVersion(QRinput *input, int v) { - stream->version = v; + input->version = v; } -void QRenc_setErrorCorrectionLevel(QRinput *stream, QRecLevel level) +void QRenc_setErrorCorrectionLevel(QRinput *input, QRecLevel level) { - stream->level = level; + input->level = level; } -QRecLevel QRenc_getErrorCorrectionLevel(QRinput *stream) +QRecLevel QRenc_getErrorCorrectionLevel(QRinput *input) { - return stream->level; + return input->level; } -int QRinput_append(QRinput *stream, QRencodeMode mode, int size, unsigned char *data) +int QRinput_append(QRinput *input, QRencodeMode mode, int size, unsigned char *data) { QRenc_List *entry; @@ -119,27 +119,27 @@ int QRinput_append(QRinput *stream, QRencodeMode mode, int size, unsigned char * return -1; } - if(stream->tail == NULL) { - stream->head = entry; - stream->tail = entry; + if(input->tail == NULL) { + input->head = entry; + input->tail = entry; } else { - stream->tail->next = entry; - stream->tail = entry; + input->tail->next = entry; + input->tail = entry; } return 0; } -void QRinput_free(QRinput *stream) +void QRinput_free(QRinput *input) { QRenc_List *list; - list = stream->head; + list = input->head; while(list != NULL) { list = QRenc_freeEntry(list); } - free(stream); + free(input); } /****************************************************************************** @@ -191,7 +191,7 @@ static int QRenc_estimateBitsModeNum(QRenc_List *entry) } /** - * Convert the number data stream to a bit stream. + * Convert the number data to a bit stream. * @param entry */ static void QRenc_encodeModeNum(QRenc_List *entry, int version) @@ -293,7 +293,7 @@ static int QRenc_estimateBitsModeAn(QRenc_List *entry) } /** - * Convert the alphabet-numeric data stream to a bit stream. + * Convert the alphabet-numeric data to a bit stream. * @param entry */ static void QRenc_encodeModeAn(QRenc_List *entry, int version) @@ -340,7 +340,7 @@ static int QRenc_estimateBitsMode8(QRenc_List *entry) } /** - * Convert the 8bits data stream to a bit stream. + * Convert the 8bits data to a bit stream. * @param entry */ static void QRenc_encodeMode8(QRenc_List *entry, int version) @@ -401,7 +401,7 @@ static int QRenc_checkModeKanji(int size, const unsigned char *data) } /** - * Convert the kanji data stream to a bit stream. + * Convert the kanji data to a bit stream. * @param entry */ static void QRenc_encodeModeKanji(QRenc_List *entry, int version) @@ -503,19 +503,19 @@ static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) } /** - * Estimates the length of the encoded bit stream of the data stream. - * @param stream data stream + * Estimates the length of the encoded bit stream of the data. + * @param input input data * @param version version of the symbol * @return number of bits */ -int QRenc_estimateBitStreamSize(QRinput *stream, int version) +int QRenc_estimateBitStreamSize(QRinput *input, int version) { QRenc_List *list; int bits = 0; - assert(stream != NULL); + assert(input != NULL); - list = stream->head; + list = input->head; while(list != NULL) { bits += QRenc_estimateBitStreamSizeOfEntry(list, version); list = list->next; @@ -526,10 +526,10 @@ int QRenc_estimateBitStreamSize(QRinput *stream, int version) /** * Estimates the required version number of the symbol. - * @param stream data stream + * @param input input data * @return required version number */ -static int QRenc_estimateVersion(QRinput *stream) +static int QRenc_estimateVersion(QRinput *input) { int bits; int new, prev; @@ -537,8 +537,8 @@ static int QRenc_estimateVersion(QRinput *stream) new = 0; do { prev = new; - bits = QRenc_estimateBitStreamSize(stream, prev); - new = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); + bits = QRenc_estimateBitStreamSize(input, prev); + new = QRspec_getMinimumVersion((bits + 7) / 8, input->level); if (new == -1) { return -1; } @@ -552,7 +552,7 @@ static int QRenc_estimateVersion(QRinput *stream) *****************************************************************************/ /** - * Convert the data stream in the data chunk to a bit stream. + * Convert the input data in the data chunk to a bit stream. * @param entry * @return number of bits */ @@ -602,20 +602,20 @@ static int QRenc_encodeBitStream(QRenc_List *entry, int version) } /** - * Convert the input data stream to a bit stream. - * @param stream input data stream. + * Convert the input data to a bit stream. + * @param input input data. * @return length of the bit stream. */ -static int QRenc_createBitStream(QRinput *stream) +static int QRenc_createBitStream(QRinput *input) { QRenc_List *list; int bits = 0; - assert(stream != NULL); + assert(input != NULL); - list = stream->head; + list = input->head; while(list != NULL) { - bits += QRenc_encodeBitStream(list, stream->version); + bits += QRenc_encodeBitStream(list, input->version); list = list->next; } @@ -623,29 +623,29 @@ static int QRenc_createBitStream(QRinput *stream) } /** - * Convert the input data stream to a bit stream. + * Convert the input data to a bit stream. * When the version number is given and that is not sufficient, it is increased * automatically. - * @param stream input data stream. + * @param input input data. * @return -1 if the input data was too large. Otherwise 0. */ -static int QRenc_convertData(QRinput *stream) +static int QRenc_convertData(QRinput *input) { int bits; int ver; - ver = QRenc_estimateVersion(stream); - if(ver > QRenc_getVersion(stream)) { - QRenc_setVersion(stream, ver); + ver = QRenc_estimateVersion(input); + if(ver > QRenc_getVersion(input)) { + QRenc_setVersion(input, ver); } for(;;) { - bits = QRenc_createBitStream(stream); - ver = QRspec_getMinimumVersion((bits + 7) / 8, stream->level); + bits = QRenc_createBitStream(input); + ver = QRspec_getMinimumVersion((bits + 7) / 8, input->level); if(ver < 0) { return -1; - } else if(ver > QRenc_getVersion(stream)) { - QRenc_setVersion(stream, ver); + } else if(ver > QRenc_getVersion(input)) { + QRenc_setVersion(input, ver); } else { break; } @@ -655,23 +655,23 @@ static int QRenc_convertData(QRinput *stream) } /** - * Create padding bits for the input stream. - * @param stream input data stream. + * Create padding bits for the input data. + * @param input input data. * @return padding bit stream. */ -static BitStream *QRenc_createPaddingBit(QRinput *stream) +static BitStream *QRenc_createPaddingBit(QRinput *input) { int bits, maxbits, words, maxwords, i; QRenc_List *list; BitStream *bstream; - if(stream->version <= 0) + if(input->version <= 0) return NULL; - maxwords = QRspec_getDataLength(stream->version, stream->level); + maxwords = QRspec_getDataLength(input->version, input->level); maxbits = maxwords * 8; - list = stream->head; + list = input->head; bits = 0; while(list != NULL) { bits += BitStream_size(list->bstream); @@ -704,22 +704,22 @@ static BitStream *QRenc_createPaddingBit(QRinput *stream) } /** - * Merge all bit streams in the input data stream - * @param stream input data stream. + * Merge all bit streams in the input data. + * @param input input data. * @return merged bit stream */ -BitStream *QRenc_mergeBitStream(QRinput *stream) +BitStream *QRenc_mergeBitStream(QRinput *input) { BitStream *bstream; QRenc_List *list; - if(QRenc_convertData(stream) < 0) { + if(QRenc_convertData(input) < 0) { return NULL; } bstream = BitStream_new(); - list = stream->head; + list = input->head; while(list != NULL) { BitStream_append(bstream, list->bstream); list = list->next; @@ -729,21 +729,21 @@ BitStream *QRenc_mergeBitStream(QRinput *stream) } /** - * Merge all bit streams in the input data stream and append padding bits - * @param stream input data stream. + * Merge all bit streams in the input data and append padding bits + * @param input input data. * @return padded merged bit stream */ -BitStream *QRenc_getBitStream(QRinput *stream) +BitStream *QRenc_getBitStream(QRinput *input) { BitStream *bstream; BitStream *padding; - bstream = QRenc_mergeBitStream(stream); + bstream = QRenc_mergeBitStream(input); if(bstream == NULL) { return NULL; } - padding = QRenc_createPaddingBit(stream); + padding = QRenc_createPaddingBit(input); BitStream_append(bstream, padding); BitStream_free(padding); @@ -752,16 +752,16 @@ BitStream *QRenc_getBitStream(QRinput *stream) /** * Pack all bit streams padding bits into a byte array. - * @param stream input data stream. + * @param input input data. * @return padded merged byte stream */ -unsigned char *QRenc_getByteStream(QRinput *stream) +unsigned char *QRenc_getByteStream(QRinput *input) { BitStream *bstream; unsigned char *array; - bstream = QRenc_getBitStream(stream); + bstream = QRenc_getBitStream(input); array = BitStream_toByte(bstream); BitStream_free(bstream); diff --git a/qrinput.h b/qrinput.h index 07f76a6ef6..70a4fd6b6a 100644 --- a/qrinput.h +++ b/qrinput.h @@ -25,12 +25,12 @@ #include "bitstream.h" /****************************************************************************** - * Entry of input data stream + * Entry of input data *****************************************************************************/ typedef struct _QRenc_List QRenc_List; /****************************************************************************** - * Input Data stream + * Input Data *****************************************************************************/ struct _QRinput { int version; @@ -41,41 +41,41 @@ struct _QRinput { /** * Get current error correction level. - * @param stream input data stream + * @param input input data. * @return Current error correcntion level. */ -extern QRecLevel QRenc_getErrorCorrectionLevel(QRinput *stream); +extern QRecLevel QRenc_getErrorCorrectionLevel(QRinput *input); /** * Set error correction level of the QR-code that is to be encoded. - * @param stream input data stream + * @param input input data. * @param level Error correction level. */ -extern void QRenc_setErrorCorrectionLevel(QRinput *stream, QRecLevel level); +extern void QRenc_setErrorCorrectionLevel(QRinput *input, QRecLevel level); /** * Get current version. - * @param stream input data stream - * @return current version + * @param input input data. + * @return current version. */ -extern int QRenc_getVersion(QRinput *stream); +extern int QRenc_getVersion(QRinput *input); /** * Set version of the QR-code that is to be encoded. - * @param stream input data stream + * @param input input data. * @param version version number (0 = auto) */ -extern void QRenc_setVersion(QRinput *stream, int version); +extern void QRenc_setVersion(QRinput *input, int version); /** * Pack all bit streams padding bits into a byte array. - * @param stream input data stream. + * @param input input data. * @return padded merged byte stream */ -extern unsigned char *QRenc_getByteStream(QRinput *stream); +extern unsigned char *QRenc_getByteStream(QRinput *input); -extern int QRenc_estimateBitStreamSize(QRinput *stream, int version); -extern BitStream *QRenc_mergeBitStream(QRinput *stream); -extern BitStream *QRenc_getBitStream(QRinput *stream); +extern int QRenc_estimateBitStreamSize(QRinput *input, int version); +extern BitStream *QRenc_mergeBitStream(QRinput *input); +extern BitStream *QRenc_getBitStream(QRinput *input); #endif /* __QRINPUT_H__ */ diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 4d59f6a641..6868d33553 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -7,7 +7,6 @@ #include "../qrspec.h" SDL_Surface *screen = NULL; -#define WIDTH 400 int eventloop(void) { @@ -43,17 +42,18 @@ void view_simple(void) QRinput *stream; char num[9] = "01234567"; unsigned char *frame, *q; - unsigned int v, *p1, *p2; int width; int x, y; int pitch; int flag = 1; int version = 1; int mask = 0; + int scale = 4; QRecLevel level = QR_ECLEVEL_L; QRcode *qrcode; SDL_Event event; int loop; + SDL_Rect rect; stream = QRinput_new(); @@ -63,18 +63,18 @@ void view_simple(void) qrcode = QRcode_encodeMask(stream, version, level, mask); width = qrcode->width; frame = qrcode->data; + version = qrcode->version; + screen = SDL_SetVideoMode((width + 8) * scale, (width + 8) * scale, 32, 0); pitch = screen->pitch; q = frame; SDL_FillRect(screen, NULL, 0xffffff); for(y=0; ypixels + pitch * (y + 4) * 2 + 32); - p2 = (unsigned int *)(screen->pixels + pitch * ((y + 4) * 2 + 1) + 32); for(x=0; x Date: Sat, 18 Nov 2006 09:01:31 +0000 Subject: --- Makefile.am | 10 ++++++---- tests/Makefile.am | 15 ++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 89cebafdb1..0d1a9c62ac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,9 +4,11 @@ SUBDIRS = . tests lib_LTLIBRARIES = libqrencode.la -libqrencode_la_SOURCES = qrencode.c qrinput.c bitstream.c qrspec.c rscode.c -libqrencode_la_headers = qrencode.h qrencode_inner.h qrinput.h bitstream.h \ - qrspec.h rscode.h +libqrencode_la_SOURCES = qrencode.c qrencode_inner.h \ + qrinput.c qrinput.h \ + bitstream.c bitstream.h \ + qrspec.c qrspec.h \ + rscode.c rscode.h libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) -pkginclude_HEADERS = qrencode.h +include_HEADERS = qrencode.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 63212592c4..a4c97cd95d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,29 +1,30 @@ if HAVE_SDL sdlPROGRAMS = view_qrcode endif + noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_qrspec test_rs test_qrencode $(sdlPROGRAMS) -test_qrinput_SOURCES = test_qrinput.c +test_qrinput_SOURCES = test_qrinput.c common.h test_qrinput_LDADD = ../libqrencode.la -test_bitstream_SOURCES = test_bitstream.c +test_bitstream_SOURCES = test_bitstream.c common.h test_bitstream_LDADD = ../bitstream.o -test_estimatebit_SOURCES = test_estimatebit.c +test_estimatebit_SOURCES = test_estimatebit.c common.h test_estimatebit_LDADD = ../libqrencode.la -test_qrspec_SOURCES = test_qrspec.c +test_qrspec_SOURCES = test_qrspec.c common.h test_qrspec_LDADD = ../qrspec.o -test_rs_SOURCES = test_rs.c +test_rs_SOURCES = test_rs.c common.h test_rs_LDADD = ../libqrencode.la -test_qrencode_SOURCES = test_qrencode.c +test_qrencode_SOURCES = test_qrencode.c common.h test_qrencode_LDADD = ../libqrencode.la if HAVE_SDL -view_qrcode_SOURCES = view_qrcode.c +view_qrcode_SOURCES = view_qrcode.c common.h view_qrcode_CFLAGS= $(SDL_CFLAGS) view_qrcode_LDADD = ../libqrencode.la $(SDL_LIBS) endif -- cgit 0.0.5-2-1-g0f52 From ee4d7fcf3805000944446d9a4d3aec153ecd5d98 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 18 Nov 2006 09:13:02 +0000 Subject: --- bitstream.c | 35 ++++++++++------------------------- bitstream.h | 2 -- tests/test_bitstream.c | 6 ++++-- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/bitstream.c b/bitstream.c index 4f0668ca42..a56d3ffbe4 100644 --- a/bitstream.c +++ b/bitstream.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "bitstream.h" @@ -36,7 +35,7 @@ BitStream *BitStream_new(void) return bstream; } -BitStream *BitStream_newFromNum(int bits, unsigned int num) +static BitStream *BitStream_newFromNum(int bits, unsigned int num) { unsigned int mask; int i; @@ -62,15 +61,13 @@ BitStream *BitStream_newFromNum(int bits, unsigned int num) return bstream; } -BitStream *BitStream_newFromBytes(int size, unsigned char *data) +static BitStream *BitStream_newFromBytes(int size, unsigned char *data) { unsigned char mask; int i, j; char *p; BitStream *bstream; - assert(data != NULL); - bstream = BitStream_new(); bstream->data = (char *)malloc(size * 8 + 1); @@ -97,8 +94,6 @@ void BitStream_append(BitStream *bstream, BitStream *arg) int l1, l2; char *new; - assert(bstream != NULL); - if(arg == NULL || arg->data == NULL) { return; } @@ -121,8 +116,6 @@ void BitStream_appendNum(BitStream *bstream, int bits, unsigned int num) { BitStream *b; - assert(bstream != NULL); - b = BitStream_newFromNum(bits, num); BitStream_append(bstream, b); BitStream_free(b); @@ -132,8 +125,6 @@ void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) { BitStream *b; - assert(bstream != NULL); - b = BitStream_newFromBytes(size, data); BitStream_append(bstream, b); BitStream_free(b); @@ -141,29 +132,15 @@ void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) unsigned int BitStream_size(BitStream *bstream) { - assert(bstream != NULL); - return strlen(bstream->data); } -void BitStream_free(BitStream *bstream) -{ - assert(bstream != NULL); - - if(bstream->data != NULL) { - free(bstream->data); - } - free(bstream); -} - unsigned char *BitStream_toByte(BitStream *bstream) { int i, j, size, bytes; unsigned char *data, v; char *p; - assert(bstream != NULL); - size = BitStream_size(bstream); data = (unsigned char *)malloc((size + 7) / 8); bytes = size / 8; @@ -190,3 +167,11 @@ unsigned char *BitStream_toByte(BitStream *bstream) return data; } + +void BitStream_free(BitStream *bstream) +{ + if(bstream->data != NULL) { + free(bstream->data); + } + free(bstream); +} diff --git a/bitstream.h b/bitstream.h index e5feb16428..901a21bbc0 100644 --- a/bitstream.h +++ b/bitstream.h @@ -27,8 +27,6 @@ typedef struct { } BitStream; extern BitStream *BitStream_new(void); -extern BitStream *BitStream_newFromNum(int bits, unsigned int num); -extern BitStream *BitStream_newFromBytes(int size, unsigned char *data); extern void BitStream_append(BitStream *bstream, BitStream *arg); extern void BitStream_appendNum(BitStream *bstream, int bits, unsigned int num); extern void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data); diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 7b68f025a2..b918c57523 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -10,7 +10,8 @@ void test_num(void) char correct[] = "0010011010101111001101111011111"; testStart("New from num"); - bstream = BitStream_newFromNum(31, data); + bstream = BitStream_new(); + BitStream_appendNum(bstream, 31, data); testEnd(strncmp(correct, bstream->data, 31)); BitStream_free(bstream); @@ -23,7 +24,8 @@ void test_bytes(void) char correct[] = "00111010"; testStart("New from bytes"); - bstream = BitStream_newFromBytes(1, data); + bstream = BitStream_new(); + BitStream_appendBytes(bstream, 1, data); testEnd(strncmp(correct, bstream->data, 8)); BitStream_free(bstream); } -- cgit 0.0.5-2-1-g0f52 From 65d2dba02b4eed004bcfc07a3590c245056c87cc Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 18 Nov 2006 09:13:39 +0000 Subject: --- qrencode.c | 1 - qrinput.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/qrencode.c b/qrencode.c index 3f2dd7c194..b040785190 100644 --- a/qrencode.c +++ b/qrencode.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "qrencode.h" diff --git a/qrinput.c b/qrinput.c index bb06a8f1d2..83f4eae39b 100644 --- a/qrinput.c +++ b/qrinput.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "qrencode.h" #include "qrspec.h" @@ -477,7 +476,6 @@ static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) int l, m; int num; - assert(entry != NULL); switch(entry->mode) { case QR_MODE_NUM: bits = QRenc_estimateBitsModeNum(entry); @@ -513,8 +511,6 @@ int QRenc_estimateBitStreamSize(QRinput *input, int version) QRenc_List *list; int bits = 0; - assert(input != NULL); - list = input->head; while(list != NULL) { bits += QRenc_estimateBitStreamSizeOfEntry(list, version); @@ -561,8 +557,6 @@ static int QRenc_encodeBitStream(QRenc_List *entry, int version) int words; QRenc_List *st1, *st2; - assert(entry != NULL); - if(entry->bstream != NULL) { BitStream_free(entry->bstream); entry->bstream = NULL; @@ -611,8 +605,6 @@ static int QRenc_createBitStream(QRinput *input) QRenc_List *list; int bits = 0; - assert(input != NULL); - list = input->head; while(list != NULL) { bits += QRenc_encodeBitStream(list, input->version); -- cgit 0.0.5-2-1-g0f52 From 46dd3b7cf21d360cbc91e5455c7685eb15872508 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 18 Nov 2006 14:32:04 +0000 Subject: --- README | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ qrencode_inner.h | 1 + 2 files changed, 54 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000000..3b6bfde5fa --- /dev/null +++ b/README @@ -0,0 +1,53 @@ +libqrencode 1.0.0 - QR Code encoding library + +GENERAL INFORMATION +=================== +Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D +symbology that can be scanned by handy terminals such as a mobile phone with +CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has +high robustness. + +SPECIFICATION +============= +Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial +Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are +not supported: +- ECI and FNC1 mode +- Structured Append Feature +- Micro QR Code +- QR Code model 1 + +INSTALL +======= + +Requirements +------------ +Some test programs or utility tools requires SDL, but the library itself has no +dependencies. You can skip compiling those tools when if you want not to +install programs using SDL. If you are trying to compile this library on MS- +Windows, cygwin or some kinds of UNIX-like environments will be needed. + +Compile & install +----------------- + +Just try + +./configure +make +make install + +This compiles and installs the library and header file to the appropriate +directories. By default, /usr/local/lib and /usr/local/include. You can change +the destination directory by passing some options to the configure script. +Run "./configure --help" to see the list of options. + +Currently no program will be installed. If you want to install a binary +(e.g. view_qrcode), please copy it manually. + +ACKNOWLEDGMENTS +=============== +QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other +countries. + +Reed-Solomon code encoder is written by Phil Karn, KA9Q. +Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q diff --git a/qrencode_inner.h b/qrencode_inner.h index 0328c115a5..570a6360d8 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -28,6 +28,7 @@ /****************************************************************************** * Raw code *****************************************************************************/ + typedef struct { int dataLength; unsigned char *data; -- cgit 0.0.5-2-1-g0f52 From 9074f85da2bf970860ebed0937e96975d6ce5279 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 18 Nov 2006 16:39:50 +0000 Subject: --- COPYING | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ChangeLog | 0 NEWS | 0 README | 22 +++- configure.ac | 2 +- 5 files changed, 361 insertions(+), 2 deletions(-) create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 NEWS diff --git a/COPYING b/COPYING new file mode 100644 index 0000000000..d511905c16 --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000000..e69de29bb2 diff --git a/NEWS b/NEWS new file mode 100644 index 0000000000..e69de29bb2 diff --git a/README b/README index 3b6bfde5fa..a359e02263 100644 --- a/README +++ b/README @@ -7,6 +7,7 @@ symbology that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness. + SPECIFICATION ============= Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial @@ -17,6 +18,7 @@ not supported: - Micro QR Code - QR Code model 1 + INSTALL ======= @@ -29,7 +31,6 @@ Windows, cygwin or some kinds of UNIX-like environments will be needed. Compile & install ----------------- - Just try ./configure @@ -44,6 +45,25 @@ Run "./configure --help" to see the list of options. Currently no program will be installed. If you want to install a binary (e.g. view_qrcode), please copy it manually. + +LICENSING INFORMATION +===================== +Copyright (C) 2006 Kentaro Fukuchi + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License in COPYING file +in this package for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + ACKNOWLEDGMENTS =============== QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other diff --git a/configure.ac b/configure.ac index dd44f63dfa..21d1750c65 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_INIT(QRencode) MAJOR_VERSION=0 -MINOR_VERSION=1 +MINOR_VERSION=9 MICRO_VERSION=0 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 070558d89b93412275512c90801b24fbce4eadff Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sun, 19 Nov 2006 08:44:19 +0000 Subject: --- TODO | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000000..61ba16fc65 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +This package contains + +*.c and *.h files (total): 4364 lines, 104543 bytes. +configure script : 22488 lines, 729111 bytes. + +It's absolutely crazy. -- cgit 0.0.5-2-1-g0f52 From 1e6c9debf41345b019a08de429974ce794ab6d31 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 20 Nov 2006 05:44:32 +0000 Subject: --- qrencode.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qrencode.h b/qrencode.h index 22dd593b34..3c5a4c1f1c 100644 --- a/qrencode.h +++ b/qrencode.h @@ -121,6 +121,22 @@ typedef struct { */ extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level); +/** + * Create a symbol from the string. The library automatically parses the input + * string and encodes in a QR Code symbol. + * @param string input string. It should be NULL terminated. + * @param version version of the symbol. If 0, the library chooses the minimum + * version for the input data. + * @param level error correction level. + * @param hint tell the library how non-alphanumerical characters should be + * encoded. If QR_MODE_KANJI is given, those characters will be + * encoded as Shif-JIS characters. If QR_MODE_8 is given, they wil + * be encoded as is. If you want to embed UTF-8 string, choose this. + * @return an instance of QRcode class. The version of the result QRcode may + * be larger than the designated version. + */ +//extern QRcode *QRcode_encodeString(QRinput *input, int version, QRecLevel level); + /** * Free the instance of QRcode class. * @param qrcode an instance of QRcode class. -- cgit 0.0.5-2-1-g0f52 From 9bd569bffc585bdd01244ea5eddd9994ed9431fa Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 20 Nov 2006 05:48:43 +0000 Subject: --- qrencode.h | 22 +++++++++++----------- qrinput.c | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/qrencode.h b/qrencode.h index 3c5a4c1f1c..a71e08fb81 100644 --- a/qrencode.h +++ b/qrencode.h @@ -65,7 +65,7 @@ extern QRinput *QRinput_new(void); * @param data a pointer to the memory area of the input data. * @return -1 when the input data is invalid. Otherwise, return 0. */ -extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, unsigned char *data); +extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data); /** * Free the input object. @@ -94,15 +94,15 @@ extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) * corresponding module is black. The other bits are meaningless for usual * application, but here the specification is described. * - * 76543210 - * |||||||+- 1=black/0=white - * ||||||+-- data and ecc code area - * |||||+--- format information - * ||||+---- version information - * |||+----- timing pattern - * ||+------ alignment pattern - * |+------- finder pattern and separator - * +-------- non-data modules (format, timing, etc.) + * MSB 76543210 LSB + * |||||||`- 1=black/0=white + * ||||||`-- data and ecc code area + * |||||`--- format information + * ||||`---- version information + * |||`----- timing pattern + * ||`------ alignment pattern + * |`------- finder pattern and separator + * `-------- non-data modules (format, timing, etc.) */ typedef struct { int version; ///< version of the symbol @@ -135,7 +135,7 @@ extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level); * @return an instance of QRcode class. The version of the result QRcode may * be larger than the designated version. */ -//extern QRcode *QRcode_encodeString(QRinput *input, int version, QRecLevel level); +//extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint); /** * Free the instance of QRcode class. diff --git a/qrinput.c b/qrinput.c index 83f4eae39b..5996326d2a 100644 --- a/qrinput.c +++ b/qrinput.c @@ -39,7 +39,7 @@ struct _QRenc_List { QRenc_List *next; }; -static QRenc_List *QRenc_newEntry(QRencodeMode mode, int size, unsigned char *data) +static QRenc_List *QRenc_newEntry(QRencodeMode mode, int size, const unsigned char *data) { QRenc_List *entry; @@ -109,7 +109,7 @@ QRecLevel QRenc_getErrorCorrectionLevel(QRinput *input) return input->level; } -int QRinput_append(QRinput *input, QRencodeMode mode, int size, unsigned char *data) +int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data) { QRenc_List *entry; -- cgit 0.0.5-2-1-g0f52 From 4cb5019b1ad0cd6c125314bbcdc3b88d09afbf07 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 20 Nov 2006 06:22:26 +0000 Subject: --- bitstream.c | 2 +- bitstream.h | 2 +- qrencode.c | 2 +- qrencode.h | 2 +- qrencode_inner.h | 3 ++- qrinput.c | 3 ++- qrinput.h | 3 ++- qrspec.c | 3 ++- qrspec.h | 3 ++- rscode.c | 2 +- rscode.h | 2 +- 11 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bitstream.c b/bitstream.c index a56d3ffbe4..feab875fc8 100644 --- a/bitstream.c +++ b/bitstream.c @@ -1,5 +1,5 @@ /* - * qrencode - QR-code encoder + * qrencode - QR Code encoder * * Binary sequence class. * Copyright (C) 2006 Kentaro Fukuchi diff --git a/bitstream.h b/bitstream.h index 901a21bbc0..25041d2d81 100644 --- a/bitstream.h +++ b/bitstream.h @@ -1,5 +1,5 @@ /* - * qrencode - QR-code encoder + * qrencode - QR Code encoder * * Binary sequence class. * Copyright (C) 2006 Kentaro Fukuchi diff --git a/qrencode.c b/qrencode.c index b040785190..bc4ccbdf6c 100644 --- a/qrencode.c +++ b/qrencode.c @@ -1,5 +1,5 @@ /** - * qrencode - QR-code encoder + * qrencode - QR Code encoder * * Copyright (C) 2006 Kentaro Fukuchi * diff --git a/qrencode.h b/qrencode.h index a71e08fb81..27489cf198 100644 --- a/qrencode.h +++ b/qrencode.h @@ -1,5 +1,5 @@ /** - * qrencode - QR-code encoder + * qrencode - QR Code encoder * * Copyright (C) 2006 Kentaro Fukuchi * diff --git a/qrencode_inner.h b/qrencode_inner.h index 570a6360d8..af0c7a3dd2 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -1,6 +1,7 @@ /** - * qrencode - QR-code encoder + * qrencode - QR Code encoder * + * Header for internal use * Copyright (C) 2006 Kentaro Fukuchi * * This program is free software; you can redistribute it and/or modify diff --git a/qrinput.c b/qrinput.c index 5996326d2a..28a1785b68 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1,6 +1,7 @@ /* - * qrencode - QR-code encoder + * qrencode - QR Code encoder * + * Input data chunk class * Copyright (C) 2006 Kentaro Fukuchi * * This program is free software; you can redistribute it and/or modify diff --git a/qrinput.h b/qrinput.h index 70a4fd6b6a..bc051efb8c 100644 --- a/qrinput.h +++ b/qrinput.h @@ -1,6 +1,7 @@ /* - * qrencode - QR-code encoder + * qrencode - QR Code encoder * + * Input data chunk class * Copyright (C) 2006 Kentaro Fukuchi * * This program is free software; you can redistribute it and/or modify diff --git a/qrspec.c b/qrspec.c index 1cbd0237f3..8557710401 100644 --- a/qrspec.c +++ b/qrspec.c @@ -1,6 +1,7 @@ /* - * qrencode - QR-code encoder + * qrencode - QR Code encoder * + * QR Code specification in convenient format. * Copyright (C) 2006 Kentaro Fukuchi * * The following data / specifications are taken from diff --git a/qrspec.h b/qrspec.h index a375576bfd..f08e13058e 100644 --- a/qrspec.h +++ b/qrspec.h @@ -1,6 +1,7 @@ /* - * qrencode - QR-code encoder + * qrencode - QR Code encoder * + * QR Code specification in convenient format. * Copyright (C) 2006 Kentaro Fukuchi * * This program is free software; you can redistribute it and/or modify diff --git a/rscode.c b/rscode.c index 2f6ea65ae3..e85ef8a2a7 100644 --- a/rscode.c +++ b/rscode.c @@ -1,5 +1,5 @@ /* - * qrencode - QR-code encoder + * qrencode - QR Code encoder * * Reed solomon encoder. This file is taken from Phil Karn's libfec and * editted and packed into a pair of .c and .h files. diff --git a/rscode.h b/rscode.h index dd2961d4cd..948c1f6d6d 100644 --- a/rscode.h +++ b/rscode.h @@ -1,5 +1,5 @@ /* - * qrencode - QR-code encoder + * qrencode - QR Code encoder * * Reed solomon encoder. This file is taken from Phil Karn's libfec and * editted and packed into a pair of .c and .h files. -- cgit 0.0.5-2-1-g0f52 From 151db759a022cf8ebd39f0c4facf9e52bc11606b Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 22 Nov 2006 09:37:32 +0000 Subject: --- bitstream.c | 2 + qrencode.c | 235 ++++++++++++++++++++++++++++++++++++++++++----- qrencode.h | 2 +- qrencode_inner.h | 10 +- qrinput.c | 190 +++++++++++++++++++------------------- qrinput.h | 41 ++++++--- tests/test_estimatebit.c | 14 +-- tests/test_qrencode.c | 153 +++++++++++++++++++++++++++--- tests/test_qrinput.c | 14 +-- tests/test_rs.c | 2 +- 10 files changed, 500 insertions(+), 163 deletions(-) diff --git a/bitstream.c b/bitstream.c index feab875fc8..7e1d41a396 100644 --- a/bitstream.c +++ b/bitstream.c @@ -132,6 +132,8 @@ void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) unsigned int BitStream_size(BitStream *bstream) { + if(bstream->data == NULL) return 0; + return strlen(bstream->data); } diff --git a/qrencode.c b/qrencode.c index bc4ccbdf6c..b4f461130e 100644 --- a/qrencode.c +++ b/qrencode.c @@ -56,7 +56,7 @@ QRRawCode *QRraw_new(QRinput *input) unsigned char *p; raw = (QRRawCode *)malloc(sizeof(QRRawCode)); - raw->datacode = QRenc_getByteStream(input); + raw->datacode = QRinput_getByteStream(input); spec = QRspec_getEccSpec(input->version, input->level); raw->blocks = QRspec_rsBlockNum(spec); raw->rsblock = (RSblock *)malloc(sizeof(RSblock) * raw->blocks); @@ -213,7 +213,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) return &p[y * w + x]; } -unsigned char *QRenc_fillerTest(int version) +unsigned char *QRinput_fillerTest(int version) { int width, length; unsigned char *frame, *p; @@ -257,7 +257,7 @@ unsigned char *QRenc_fillerTest(int version) * Format information *****************************************************************************/ -void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level) +void QRinput_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level) { unsigned int format; unsigned char v; @@ -317,53 +317,53 @@ void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRe }\ return b; -static int QRenc_mask0(int width, const unsigned char *s, unsigned char *d) +static int QRinput_mask0(int width, const unsigned char *s, unsigned char *d) { MASKMAKER((x+y)&1) } -static int QRenc_mask1(int width, const unsigned char *s, unsigned char *d) +static int QRinput_mask1(int width, const unsigned char *s, unsigned char *d) { MASKMAKER(y&1) } -static int QRenc_mask2(int width, const unsigned char *s, unsigned char *d) +static int QRinput_mask2(int width, const unsigned char *s, unsigned char *d) { MASKMAKER(x%3) } -static int QRenc_mask3(int width, const unsigned char *s, unsigned char *d) +static int QRinput_mask3(int width, const unsigned char *s, unsigned char *d) { MASKMAKER((x+y)%3) } -static int QRenc_mask4(int width, const unsigned char *s, unsigned char *d) +static int QRinput_mask4(int width, const unsigned char *s, unsigned char *d) { MASKMAKER(((y/2)+(x/3))&1) } -static int QRenc_mask5(int width, const unsigned char *s, unsigned char *d) +static int QRinput_mask5(int width, const unsigned char *s, unsigned char *d) { MASKMAKER(((x*y)&1)+(x*y)%3) } -static int QRenc_mask6(int width, const unsigned char *s, unsigned char *d) +static int QRinput_mask6(int width, const unsigned char *s, unsigned char *d) { MASKMAKER((((x*y)&1)+(x*y)%3)&1) } -static int QRenc_mask7(int width, const unsigned char *s, unsigned char *d) +static int QRinput_mask7(int width, const unsigned char *s, unsigned char *d) { MASKMAKER((((x*y)%3)+((x+y)&1))&1) } typedef int MaskMaker(int, const unsigned char *, unsigned char *); static MaskMaker *maskMakers[] = { - QRenc_mask0, QRenc_mask1, QRenc_mask2, QRenc_mask3, - QRenc_mask4, QRenc_mask5, QRenc_mask6, QRenc_mask7 + QRinput_mask0, QRinput_mask1, QRinput_mask2, QRinput_mask3, + QRinput_mask4, QRinput_mask5, QRinput_mask6, QRinput_mask7 }; -unsigned char *QRenc_makeMask(int width, unsigned char *frame, int mask) +unsigned char *QRinput_makeMask(int width, unsigned char *frame, int mask) { unsigned char *masked; @@ -381,7 +381,7 @@ static int runLength[QRSPEC_WIDTH_MAX + 1]; //static int n3; //static int n4; -static int QRenc_calcN1N3(int length, int *runLength) +static int QRinput_calcN1N3(int length, int *runLength) { int i; int demerit = 0; @@ -414,7 +414,7 @@ static int QRenc_calcN1N3(int length, int *runLength) return demerit; } -int QRenc_evaluateSymbol(int width, unsigned char *frame) +int QRinput_evaluateSymbol(int width, unsigned char *frame) { int x, y; unsigned char *p; @@ -451,7 +451,7 @@ int QRenc_evaluateSymbol(int width, unsigned char *frame) } p++; } - demerit += QRenc_calcN1N3(head+1, runLength); + demerit += QRinput_calcN1N3(head+1, runLength); } i = 0; @@ -474,13 +474,13 @@ int QRenc_evaluateSymbol(int width, unsigned char *frame) } p+=width; } - demerit += QRenc_calcN1N3(head+1, runLength); + demerit += QRinput_calcN1N3(head+1, runLength); } return demerit; } -static unsigned char *QRenc_mask(int width, unsigned char *frame, QRecLevel level) +static unsigned char *QRinput_mask(int width, unsigned char *frame, QRecLevel level) { int i; unsigned char *mask, *bestMask; @@ -503,7 +503,7 @@ static unsigned char *QRenc_mask(int width, unsigned char *frame, QRecLevel leve free(mask); continue; } - demerit += QRenc_evaluateSymbol(width, mask); + demerit += QRinput_evaluateSymbol(width, mask); // printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit); if(demerit < minDemerit) { minDemerit = demerit; @@ -517,7 +517,7 @@ static unsigned char *QRenc_mask(int width, unsigned char *frame, QRecLevel leve } } - QRenc_writeFormatInformation(width, bestMask, bestMaskNum, level); + QRinput_writeFormatInformation(width, bestMask, bestMaskNum, level); return bestMask; } @@ -562,8 +562,8 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask int i, j; QRcode *qrcode; - QRenc_setVersion(input, version); - QRenc_setErrorCorrectionLevel(input, level); + QRinput_setVersion(input, version); + QRinput_setErrorCorrectionLevel(input, level); width = QRspec_getWidth(version); raw = QRraw_new(input); @@ -590,11 +590,11 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask free(filler); /* masking */ if(mask < 0) { - masked = QRenc_mask(width, frame, level); + masked = QRinput_mask(width, frame, level); } else { masked = (unsigned char *)malloc(width * width); maskMakers[mask](width, frame, masked); - QRenc_writeFormatInformation(width, masked, mask, QRenc_getErrorCorrectionLevel(input)); + QRinput_writeFormatInformation(width, masked, mask, QRinput_getErrorCorrectionLevel(input)); } qrcode = QRcode_new(version, width, masked); @@ -602,3 +602,188 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask return qrcode; } + +static int QRcode_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint); +static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint); +static int QRcode_eat8(const char *string, QRinput *input, int version, QRencodeMode hint); +static int QRcode_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint); + +#define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10) +#define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0) + +static int QRcode_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint) +{ + const char *p; + int run; + int rangeA, range8; + + if(version <= 9) { + range8 = 4; + rangeA = 7; + } else if(version <= 26) { + range8 = 4; + rangeA = 8; + } else { + range8 = 5; + rangeA = 9; + } + p = string; + while(isdigit(*p)) { + p++; + } + run = p - string; + if(run < range8 && (*p & 0x80)) { + return QRcode_eat8(string, input, version, hint); + } + if(run < rangeA && isalnum(*p)) { + return QRcode_eatAn(string, input, version, hint); + } + + QRinput_append(input, QR_MODE_NUM, run, (unsigned char *)string); + return run; +} + +static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint) +{ + const char *p, *q; + int run; + int range, rangeN; + + if(version <= 9) { + range = 6; + rangeN = 13; + } else if(version <= 26) { + range = 7; + rangeN = 15; + } else { + range = 8; + rangeN = 17; + } + p = string; + while(isalnum(*p)) { + if(isdigit(*p)) { + q = p; + while(isdigit(*q)) { + q++; + } + if(q - p >= rangeN) { + break; + } else { + p = q; + } + } else { + p++; + } + } + run = p - string; + if(run < range && (*p & 0x80)) { + return QRcode_eat8(string, input, version, hint); + } + + QRinput_append(input, QR_MODE_AN, run, (unsigned char *)string); + return run; +} + +static int QRcode_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint) +{ + const char *p; + + p = string; + while(QRinput_identifyMode(p) == QR_MODE_KANJI) { + p += 2; + } + QRinput_append(input, QR_MODE_KANJI, p - string, (unsigned char *)string); + return p - string; +} + +static int QRcode_eat8(const char *string, QRinput *input, int version, QRencodeMode hint) +{ + const char *p, *q; + int rangeA, rangeN; + QRencodeMode mode; + + if(version <= 9) { + rangeN = 6; + rangeA = 11; + } else if(version <= 26) { + rangeN = 8; + rangeA = 15; + } else { + rangeN = 9; + rangeA = 16; + } + p = string; + while(1) { + while(*p != '\0') { + mode = QRinput_identifyMode(p); + if(hint == QR_MODE_KANJI && mode == QR_MODE_KANJI) { + break; + } + if(mode != QR_MODE_8) { + break; + } + p++; + } + if(*p == '\0') { + break; + } else if(isdigit(*p)) { + q = p; + while(isdigit(*q)) { + q++; + } + if(q - p >= rangeN) { + break; + } else { + p = q; + } + } else if(isalnum(*p)) { + q = p; + while(isalnum(*q)) { + q++; + } + if(q - p >= rangeA) { + break; + } else { + p = q; + } + } + } + QRinput_append(input, QR_MODE_AN, p - string, (unsigned char *)string); + return p - string; +} + +void QRcode_splitStringToQRinput(const char *string, QRinput *input, + int version, QRencodeMode hint) +{ + int length; + QRencodeMode mode; + + if(*string == '\0') return; + + mode = QRinput_identifyMode(string); + if(mode == QR_MODE_NUM) { + length = QRcode_eatNum(string, input, version, hint); + } else if(mode == QR_MODE_AN) { + length = QRcode_eatAn(string, input, version, hint); + } else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) { + length = QRcode_eatKanji(string, input, version, hint); + } else { + length = QRcode_eat8(string, input, version, hint); + } + if(length == 0) return; + /* Of course this tail recursion could be optimized! Believe gcc. */ + QRcode_splitStringToQRinput(&string[length], input, hint, version); +} + +extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint) +{ + QRinput *input; + + if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) { + return NULL; + } + + input = QRinput_new(); + QRcode_splitStringToQRinput(string, input, version, hint); + return QRcode_encodeInput(input, version, level); +} diff --git a/qrencode.h b/qrencode.h index 27489cf198..8de58610ee 100644 --- a/qrencode.h +++ b/qrencode.h @@ -135,7 +135,7 @@ extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level); * @return an instance of QRcode class. The version of the result QRcode may * be larger than the designated version. */ -//extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint); +extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint); /** * Free the instance of QRcode class. diff --git a/qrencode_inner.h b/qrencode_inner.h index af0c7a3dd2..ce7e088837 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -55,20 +55,22 @@ extern void QRraw_free(QRRawCode *raw); /****************************************************************************** * Frame filling *****************************************************************************/ -extern unsigned char *QRenc_fillerTest(int version); +extern unsigned char *QRinput_fillerTest(int version); /****************************************************************************** * Format information *****************************************************************************/ -extern void QRenc_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); +extern void QRinput_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); /****************************************************************************** * Masking *****************************************************************************/ -extern unsigned char *QRenc_makeMask(int width, unsigned char *frame, int mask); +extern unsigned char *QRinput_makeMask(int width, unsigned char *frame, int mask); -extern int QRenc_evaluateSymbol(int width, unsigned char *frame); +extern int QRinput_evaluateSymbol(int width, unsigned char *frame); QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask); +void QRcode_splitStringToQRinput(const char *string, QRinput *input, + int version, QRencodeMode hint); #endif /* __QRENCODE_INNER_H__ */ diff --git a/qrinput.c b/qrinput.c index 28a1785b68..3835a4040a 100644 --- a/qrinput.c +++ b/qrinput.c @@ -32,23 +32,15 @@ * Entry of input data *****************************************************************************/ -struct _QRenc_List { - QRencodeMode mode; - int size; ///< Size of data chunk (byte). - unsigned char *data; ///< Data chunk. - BitStream *bstream; - QRenc_List *next; -}; - -static QRenc_List *QRenc_newEntry(QRencodeMode mode, int size, const unsigned char *data) +static QRinput_List *QRinput_newEntry(QRencodeMode mode, int size, const unsigned char *data) { - QRenc_List *entry; + QRinput_List *entry; if(QRinput_check(mode, size, data)) { return NULL; } - entry = (QRenc_List *)malloc(sizeof(QRenc_List)); + entry = (QRinput_List *)malloc(sizeof(QRinput_List)); entry->mode = mode; entry->size = size; entry->data = (unsigned char *)malloc(size); @@ -59,9 +51,9 @@ static QRenc_List *QRenc_newEntry(QRencodeMode mode, int size, const unsigned ch return entry; } -static QRenc_List *QRenc_freeEntry(QRenc_List *entry) +static QRinput_List *QRinput_freeEntry(QRinput_List *entry) { - QRenc_List *next; + QRinput_List *next; next = entry->next; free(entry->data); @@ -90,31 +82,31 @@ QRinput *QRinput_new(void) return input; } -int QRenc_getVersion(QRinput *input) +int QRinput_getVersion(QRinput *input) { return input->version; } -void QRenc_setVersion(QRinput *input, int v) +void QRinput_setVersion(QRinput *input, int v) { input->version = v; } -void QRenc_setErrorCorrectionLevel(QRinput *input, QRecLevel level) +void QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level) { input->level = level; } -QRecLevel QRenc_getErrorCorrectionLevel(QRinput *input) +QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input) { return input->level; } int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data) { - QRenc_List *entry; + QRinput_List *entry; - entry = QRenc_newEntry(mode, size, data); + entry = QRinput_newEntry(mode, size, data); if(entry == NULL) { return -1; } @@ -132,11 +124,11 @@ int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned c void QRinput_free(QRinput *input) { - QRenc_List *list; + QRinput_List *list; list = input->head; while(list != NULL) { - list = QRenc_freeEntry(list); + list = QRinput_freeEntry(list); } free(input); @@ -152,7 +144,7 @@ void QRinput_free(QRinput *input) * @param data * @return result */ -static int QRenc_checkModeNum(int size, const char *data) +static int QRinput_checkModeNum(int size, const char *data) { int i; @@ -169,7 +161,7 @@ static int QRenc_checkModeNum(int size, const char *data) * @param entry * @return number of bits */ -static int QRenc_estimateBitsModeNum(QRenc_List *entry) +static int QRinput_estimateBitsModeNum(QRinput_List *entry) { int w; int bits; @@ -194,7 +186,7 @@ static int QRenc_estimateBitsModeNum(QRenc_List *entry) * Convert the number data to a bit stream. * @param entry */ -static void QRenc_encodeModeNum(QRenc_List *entry, int version) +static void QRinput_encodeModeNum(QRinput_List *entry, int version) { int words; int i; @@ -231,7 +223,7 @@ static void QRenc_encodeModeNum(QRenc_List *entry, int version) * Alphabet-numeric data *****************************************************************************/ -static signed char anTable[] = { +signed char QRinput_anTable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, @@ -242,31 +234,18 @@ static signed char anTable[] = { 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1 }; -/** - * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). - * @param c character - * @return value - */ -inline static signed char QRenc_lookAnTable(char c) -{ - if(c & 0x80) { - return -1; - } - return anTable[(int)c]; -} - /** * Check the input data. * @param size * @param data * @return result */ -static int QRenc_checkModeAn(int size, const char *data) +static int QRinput_checkModeAn(int size, const char *data) { int i; for(i=0; ibstream, QRspec_lengthIndicator(QR_MODE_AN, version), val); for(i=0; idata[i*2 ]) * 45; - val += (unsigned int)QRenc_lookAnTable(entry->data[i*2+1]); + val = (unsigned int)QRinput_lookAnTable(entry->data[i*2 ]) * 45; + val += (unsigned int)QRinput_lookAnTable(entry->data[i*2+1]); BitStream_appendNum(entry->bstream, 11, val); } if(entry->size & 1) { - val = (unsigned int)QRenc_lookAnTable(entry->data[words * 2]); + val = (unsigned int)QRinput_lookAnTable(entry->data[words * 2]); BitStream_appendNum(entry->bstream, 6, val); } @@ -334,7 +313,7 @@ static void QRenc_encodeModeAn(QRenc_List *entry, int version) * @param entry * @return number of bits */ -static int QRenc_estimateBitsMode8(QRenc_List *entry) +static int QRinput_estimateBitsMode8(QRinput_List *entry) { return entry->size * 8; } @@ -343,7 +322,7 @@ static int QRenc_estimateBitsMode8(QRenc_List *entry) * Convert the 8bits data to a bit stream. * @param entry */ -static void QRenc_encodeMode8(QRenc_List *entry, int version) +static void QRinput_encodeMode8(QRinput_List *entry, int version) { int i; unsigned int val; @@ -371,7 +350,7 @@ static void QRenc_encodeMode8(QRenc_List *entry, int version) * @param entry * @return number of bits */ -static int QRenc_estimateBitsModeKanji(QRenc_List *entry) +static int QRinput_estimateBitsModeKanji(QRinput_List *entry) { return (entry->size / 2) * 13; } @@ -382,7 +361,7 @@ static int QRenc_estimateBitsModeKanji(QRenc_List *entry) * @param data * @return result */ -static int QRenc_checkModeKanji(int size, const unsigned char *data) +static int QRinput_checkModeKanji(int size, const unsigned char *data) { int i; unsigned int val; @@ -404,7 +383,7 @@ static int QRenc_checkModeKanji(int size, const unsigned char *data) * Convert the kanji data to a bit stream. * @param entry */ -static void QRenc_encodeModeKanji(QRenc_List *entry, int version) +static void QRinput_encodeModeKanji(QRinput_List *entry, int version) { int i; unsigned int val, h; @@ -446,13 +425,13 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) { switch(mode) { case QR_MODE_NUM: - return QRenc_checkModeNum(size, (const char *)data); + return QRinput_checkModeNum(size, (const char *)data); break; case QR_MODE_AN: - return QRenc_checkModeAn(size, (const char *)data); + return QRinput_checkModeAn(size, (const char *)data); break; case QR_MODE_KANJI: - return QRenc_checkModeKanji(size, data); + return QRinput_checkModeKanji(size, data); break; default: break; @@ -461,6 +440,27 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) return 0; } +QRencodeMode QRinput_identifyMode(const char *string) +{ + unsigned char c; + unsigned int word; + + c = string[0]; + + if((unsigned char)((signed char)c - '0') < 10) { + return QR_MODE_NUM; + } else if((QRinput_lookAnTable(c)) >= 0) { + return QR_MODE_AN; + } else { + word = c << 8 | string[1]; + if(word < 0x8140 || (word > 0x9ffc && word < 0xe040) || word > 0xebbf) { + return QR_MODE_KANJI; + } + } + + return QR_MODE_8; +} + /****************************************************************************** * Estimation of the bit length *****************************************************************************/ @@ -471,7 +471,7 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) * @param version version of the symbol * @return number of bits */ -static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) +static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version) { int bits = 0; int l, m; @@ -479,16 +479,16 @@ static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) switch(entry->mode) { case QR_MODE_NUM: - bits = QRenc_estimateBitsModeNum(entry); + bits = QRinput_estimateBitsModeNum(entry); break; case QR_MODE_AN: - bits = QRenc_estimateBitsModeAn(entry); + bits = QRinput_estimateBitsModeAn(entry); break; case QR_MODE_8: - bits = QRenc_estimateBitsMode8(entry); + bits = QRinput_estimateBitsMode8(entry); break; case QR_MODE_KANJI: - bits = QRenc_estimateBitsModeKanji(entry); + bits = QRinput_estimateBitsModeKanji(entry); break; } @@ -507,14 +507,14 @@ static int QRenc_estimateBitStreamSizeOfEntry(QRenc_List *entry, int version) * @param version version of the symbol * @return number of bits */ -int QRenc_estimateBitStreamSize(QRinput *input, int version) +int QRinput_estimateBitStreamSize(QRinput *input, int version) { - QRenc_List *list; + QRinput_List *list; int bits = 0; list = input->head; while(list != NULL) { - bits += QRenc_estimateBitStreamSizeOfEntry(list, version); + bits += QRinput_estimateBitStreamSizeOfEntry(list, version); list = list->next; } @@ -526,7 +526,7 @@ int QRenc_estimateBitStreamSize(QRinput *input, int version) * @param input input data * @return required version number */ -static int QRenc_estimateVersion(QRinput *input) +static int QRinput_estimateVersion(QRinput *input) { int bits; int new, prev; @@ -534,7 +534,7 @@ static int QRenc_estimateVersion(QRinput *input) new = 0; do { prev = new; - bits = QRenc_estimateBitStreamSize(input, prev); + bits = QRinput_estimateBitStreamSize(input, prev); new = QRspec_getMinimumVersion((bits + 7) / 8, input->level); if (new == -1) { return -1; @@ -553,10 +553,10 @@ static int QRenc_estimateVersion(QRinput *input) * @param entry * @return number of bits */ -static int QRenc_encodeBitStream(QRenc_List *entry, int version) +static int QRinput_encodeBitStream(QRinput_List *entry, int version) { int words; - QRenc_List *st1, *st2; + QRinput_List *st1, *st2; if(entry->bstream != NULL) { BitStream_free(entry->bstream); @@ -565,28 +565,28 @@ static int QRenc_encodeBitStream(QRenc_List *entry, int version) words = QRspec_maximumWords(entry->mode, version); if(entry->size > words) { - st1 = QRenc_newEntry(entry->mode, words, entry->data); - st2 = QRenc_newEntry(entry->mode, entry->size - words, &entry->data[words]); - QRenc_encodeBitStream(st1, version); - QRenc_encodeBitStream(st2, version); + st1 = QRinput_newEntry(entry->mode, words, entry->data); + st2 = QRinput_newEntry(entry->mode, entry->size - words, &entry->data[words]); + QRinput_encodeBitStream(st1, version); + QRinput_encodeBitStream(st2, version); entry->bstream = BitStream_new(); BitStream_append(entry->bstream, st1->bstream); BitStream_append(entry->bstream, st2->bstream); - QRenc_freeEntry(st1); - QRenc_freeEntry(st2); + QRinput_freeEntry(st1); + QRinput_freeEntry(st2); } else { switch(entry->mode) { case QR_MODE_NUM: - QRenc_encodeModeNum(entry, version); + QRinput_encodeModeNum(entry, version); break; case QR_MODE_AN: - QRenc_encodeModeAn(entry, version); + QRinput_encodeModeAn(entry, version); break; case QR_MODE_8: - QRenc_encodeMode8(entry, version); + QRinput_encodeMode8(entry, version); break; case QR_MODE_KANJI: - QRenc_encodeModeKanji(entry, version); + QRinput_encodeModeKanji(entry, version); break; default: break; @@ -601,14 +601,14 @@ static int QRenc_encodeBitStream(QRenc_List *entry, int version) * @param input input data. * @return length of the bit stream. */ -static int QRenc_createBitStream(QRinput *input) +static int QRinput_createBitStream(QRinput *input) { - QRenc_List *list; + QRinput_List *list; int bits = 0; list = input->head; while(list != NULL) { - bits += QRenc_encodeBitStream(list, input->version); + bits += QRinput_encodeBitStream(list, input->version); list = list->next; } @@ -622,23 +622,23 @@ static int QRenc_createBitStream(QRinput *input) * @param input input data. * @return -1 if the input data was too large. Otherwise 0. */ -static int QRenc_convertData(QRinput *input) +static int QRinput_convertData(QRinput *input) { int bits; int ver; - ver = QRenc_estimateVersion(input); - if(ver > QRenc_getVersion(input)) { - QRenc_setVersion(input, ver); + ver = QRinput_estimateVersion(input); + if(ver > QRinput_getVersion(input)) { + QRinput_setVersion(input, ver); } for(;;) { - bits = QRenc_createBitStream(input); + bits = QRinput_createBitStream(input); ver = QRspec_getMinimumVersion((bits + 7) / 8, input->level); if(ver < 0) { return -1; - } else if(ver > QRenc_getVersion(input)) { - QRenc_setVersion(input, ver); + } else if(ver > QRinput_getVersion(input)) { + QRinput_setVersion(input, ver); } else { break; } @@ -652,10 +652,10 @@ static int QRenc_convertData(QRinput *input) * @param input input data. * @return padding bit stream. */ -static BitStream *QRenc_createPaddingBit(QRinput *input) +static BitStream *QRinput_createPaddingBit(QRinput *input) { int bits, maxbits, words, maxwords, i; - QRenc_List *list; + QRinput_List *list; BitStream *bstream; if(input->version <= 0) @@ -702,12 +702,12 @@ static BitStream *QRenc_createPaddingBit(QRinput *input) * @return merged bit stream */ -BitStream *QRenc_mergeBitStream(QRinput *input) +BitStream *QRinput_mergeBitStream(QRinput *input) { BitStream *bstream; - QRenc_List *list; + QRinput_List *list; - if(QRenc_convertData(input) < 0) { + if(QRinput_convertData(input) < 0) { return NULL; } @@ -727,16 +727,16 @@ BitStream *QRenc_mergeBitStream(QRinput *input) * @return padded merged bit stream */ -BitStream *QRenc_getBitStream(QRinput *input) +BitStream *QRinput_getBitStream(QRinput *input) { BitStream *bstream; BitStream *padding; - bstream = QRenc_mergeBitStream(input); + bstream = QRinput_mergeBitStream(input); if(bstream == NULL) { return NULL; } - padding = QRenc_createPaddingBit(input); + padding = QRinput_createPaddingBit(input); BitStream_append(bstream, padding); BitStream_free(padding); @@ -749,12 +749,12 @@ BitStream *QRenc_getBitStream(QRinput *input) * @return padded merged byte stream */ -unsigned char *QRenc_getByteStream(QRinput *input) +unsigned char *QRinput_getByteStream(QRinput *input) { BitStream *bstream; unsigned char *array; - bstream = QRenc_getBitStream(input); + bstream = QRinput_getBitStream(input); array = BitStream_toByte(bstream); BitStream_free(bstream); diff --git a/qrinput.h b/qrinput.h index bc051efb8c..5b3e2696b2 100644 --- a/qrinput.h +++ b/qrinput.h @@ -28,7 +28,15 @@ /****************************************************************************** * Entry of input data *****************************************************************************/ -typedef struct _QRenc_List QRenc_List; +typedef struct _QRinput_List QRinput_List; + +struct _QRinput_List { + QRencodeMode mode; + int size; ///< Size of data chunk (byte). + unsigned char *data; ///< Data chunk. + BitStream *bstream; + QRinput_List *next; +}; /****************************************************************************** * Input Data @@ -36,8 +44,8 @@ typedef struct _QRenc_List QRenc_List; struct _QRinput { int version; QRecLevel level; - QRenc_List *head; - QRenc_List *tail; + QRinput_List *head; + QRinput_List *tail; }; /** @@ -45,38 +53,49 @@ struct _QRinput { * @param input input data. * @return Current error correcntion level. */ -extern QRecLevel QRenc_getErrorCorrectionLevel(QRinput *input); +extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input); /** * Set error correction level of the QR-code that is to be encoded. * @param input input data. * @param level Error correction level. */ -extern void QRenc_setErrorCorrectionLevel(QRinput *input, QRecLevel level); +extern void QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level); /** * Get current version. * @param input input data. * @return current version. */ -extern int QRenc_getVersion(QRinput *input); +extern int QRinput_getVersion(QRinput *input); /** * Set version of the QR-code that is to be encoded. * @param input input data. * @param version version number (0 = auto) */ -extern void QRenc_setVersion(QRinput *input, int version); +extern void QRinput_setVersion(QRinput *input, int version); /** * Pack all bit streams padding bits into a byte array. * @param input input data. * @return padded merged byte stream */ -extern unsigned char *QRenc_getByteStream(QRinput *input); +extern unsigned char *QRinput_getByteStream(QRinput *input); + +extern int QRinput_estimateBitStreamSize(QRinput *input, int version); +extern BitStream *QRinput_mergeBitStream(QRinput *input); +extern BitStream *QRinput_getBitStream(QRinput *input); -extern int QRenc_estimateBitStreamSize(QRinput *input, int version); -extern BitStream *QRenc_mergeBitStream(QRinput *input); -extern BitStream *QRenc_getBitStream(QRinput *input); +extern signed char QRinput_anTable[]; +extern QRencodeMode QRinput_identifyMode(const char *string); + +/** + * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). + * @param c character + * @return value + */ +#define QRinput_lookAnTable(__c__) \ + ((__c__ & 0x80)?-1:QRinput_anTable[(int)__c__]) #endif /* __QRINPUT_H__ */ diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index ad5eb38d69..77e9da2157 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -16,7 +16,7 @@ void test_numbit(void) testStart("Estimation of Numeric stream (8 digits)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - bits = QRenc_estimateBitStreamSize(stream, 0); + bits = QRinput_estimateBitStreamSize(stream, 0); testEndExp(bits == 41); QRinput_append(gstream, QR_MODE_NUM, 8, (unsigned char *)num); @@ -32,7 +32,7 @@ void test_numbit2(void) testStart("Estimation of Numeric stream (16 digits)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num); - bits = QRenc_estimateBitStreamSize(stream, 0); + bits = QRinput_estimateBitStreamSize(stream, 0); testEndExp(bits == 68); QRinput_append(gstream, QR_MODE_NUM, 16, (unsigned char *)num); @@ -51,7 +51,7 @@ void test_numbit3(void) memset(num, '1', 400); num[400] = '\0'; QRinput_append(stream, QR_MODE_NUM, 400, (unsigned char *)num); - bits = QRenc_estimateBitStreamSize(stream, 0); + bits = QRinput_estimateBitStreamSize(stream, 0); testEndExp(bits == 1362); QRinput_append(gstream, QR_MODE_NUM, 400, (unsigned char *)num); @@ -68,7 +68,7 @@ void test_an(void) testStart("Estimation of Alphabet-Numeric stream (5 chars)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); - bits = QRenc_estimateBitStreamSize(stream, 0); + bits = QRinput_estimateBitStreamSize(stream, 0); testEndExp(bits == 41); QRinput_append(gstream, QR_MODE_AN, 5, (unsigned char *)str); @@ -84,7 +84,7 @@ void test_8(void) testStart("Estimation of 8 bit data stream (8 bytes)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_8, 8, (unsigned char *)str); - bits = QRenc_estimateBitStreamSize(stream, 0); + bits = QRinput_estimateBitStreamSize(stream, 0); testEndExp(bits == 76); QRinput_append(gstream, QR_MODE_8, 8, (unsigned char *)str); @@ -106,7 +106,7 @@ void test_kanji(void) printf("Failed to add.\n"); testEnd(1); } else { - bits = QRenc_estimateBitStreamSize(stream, 0); + bits = QRinput_estimateBitStreamSize(stream, 0); testEndExp(bits == 38); QRinput_append(gstream, QR_MODE_KANJI, 4, (unsigned char *)str); } @@ -119,7 +119,7 @@ void test_mix(void) int bits; testStart("Estimation of Mixed stream"); - bits = QRenc_estimateBitStreamSize(gstream, 0); + bits = QRinput_estimateBitStreamSize(gstream, 0); testEndExp(bits == (41 + 68 + 1362 + 41 + 76 + 38)); QRinput_free(gstream); } diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 0f1b08cc0b..082c2f1c62 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -16,8 +16,8 @@ void test_iterate() testStart("Test getCode (1-L)"); stream = QRinput_new(); - QRenc_setVersion(stream, 1); - QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_L); + QRinput_setVersion(stream, 1); + QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_L); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); raw = QRraw_new(stream); @@ -62,8 +62,8 @@ void test_iterate2() testStart("Test getCode (5-H)"); stream = QRinput_new(); - QRenc_setVersion(stream, 5); - QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_H); + QRinput_setVersion(stream, 5); + QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_H); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); raw = QRraw_new(stream); @@ -86,7 +86,7 @@ void print_filler(void) unsigned char *frame; width = QRspec_getWidth(version); - frame = QRenc_fillerTest(version); + frame = QRinput_fillerTest(version); for(y=0; yhead; + if(list->mode != QR_MODE_NUM || list->size != 4) { + err++; + } + if(list->next != NULL) { + err++; + } + testEnd(err); + QRinput_free(input); + + testStart("Split test 3: single typed strings (num2)"); + input = QRinput_new(); + QRcode_splitStringToQRinput("12345678901234567890", input, 0, QR_MODE_KANJI); + list = input->head; + if(list->mode != QR_MODE_NUM || list->size != 20) { + err++; + } + if(list->next != NULL) { + err++; + } + testEnd(err); + QRinput_free(input); +} + +void test_split3(void) +{ + QRinput *input; + QRinput_List *list; + int err = 0; + + testStart("Split test 4: single typed strings (an)"); + input = QRinput_new(); + QRcode_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8); + list = input->head; + if(list->mode != QR_MODE_AN || list->size != 5) { + err++; + } + if(list->next != NULL) { + err++; + } + testEnd(err); + QRinput_free(input); + + testStart("Split test 5: num + an"); + input = QRinput_new(); + QRcode_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI); + list = input->head; + if(list->mode != QR_MODE_AN || list->size != 9) { + err++; + } + if(list->next != NULL) { + err++; + } + testEnd(err); + QRinput_free(input); + + testStart("Split test 6: an + num + an"); + input = QRinput_new(); + QRcode_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI); + list = input->head; + if(list->mode != QR_MODE_AN || list->size != 7) { + err++; + } + if(list->next != NULL) { + err++; + } + testEnd(err); + QRinput_free(input); +} + +void test_split4(void) +{ + QRinput *input; + QRinput_List *list; + int err = 0; + + testStart("Split test 7: an and num entries"); + input = QRinput_new(); + QRcode_splitStringToQRinput("abcde1234567890123", input, 0, QR_MODE_8); + list = input->head; + if(list->mode != QR_MODE_AN || list->size != 5) { + printf("fist item is not alnum.\n"); + err++; + } + if(list->next == NULL) { + printf("no second item.\n"); + err++; + } else { + list = list->next; + if(list->mode != QR_MODE_NUM || list->size != 13) { + printf("second item is not number.: %d %d\n", list->mode, list->size); + err++; + } + if(list->next != NULL) { + printf("list is not terminated.\n"); + err++; + } + } + testEnd(err); + QRinput_free(input); +} + int main(int argc, char **argv) { test_iterate(); @@ -406,6 +531,10 @@ int main(int argc, char **argv) test_eval3(); test_encode(); // print_encode(); + test_split1(); + test_split2(); + test_split3(); + test_split4(); report(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index ccb5d75067..e1daea7131 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -14,7 +14,7 @@ void test_encodeKanji(void) testStart("Encoding kanji stream."); stream = QRinput_new(); QRinput_append(stream, QR_MODE_KANJI, 4, (unsigned char *)str); - bstream = QRenc_mergeBitStream(stream); + bstream = QRinput_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); @@ -32,7 +32,7 @@ void test_encode8(void) testStart("Encoding alphabet-numeric stream."); stream = QRinput_new(); QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); - bstream = QRenc_mergeBitStream(stream); + bstream = QRinput_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); @@ -50,7 +50,7 @@ void test_encodeAn(void) testStart("Encoding alphabet-numeric stream."); stream = QRinput_new(); QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); - bstream = QRenc_mergeBitStream(stream); + bstream = QRinput_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); @@ -81,7 +81,7 @@ void test_encodeNumeric(void) testStart("Encoding numeric stream. (8 digits)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - bstream = QRenc_mergeBitStream(stream); + bstream = QRinput_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); @@ -100,7 +100,7 @@ void test_encodeNumericPadded(void) testStart("Encoding numeric stream. (8 digits)(padded)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - bstream = QRenc_getBitStream(stream); + bstream = QRinput_getBitStream(stream); flag = strncmp(correct, bstream->data, 48); printf("%s\n", bstream->data); if(strlen(bstream->data) != 19 * 8) @@ -121,7 +121,7 @@ void test_encodeNumeric2(void) testStart("Encoding numeric stream. (16 digits)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num); - bstream = QRenc_mergeBitStream(stream); + bstream = QRinput_mergeBitStream(stream); printf("%s\n", correct); printf("%s\n", bstream->data); testEnd(strcmp(correct, bstream->data)); @@ -143,7 +143,7 @@ void test_encode82(void) testStart("Encoding byte stream. (257 bytes)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_8, 257, data); - bstream = QRenc_mergeBitStream(stream); + bstream = QRinput_mergeBitStream(stream); if(strncmp(c1, bstream->data, 12)) { flag++; } diff --git a/tests/test_rs.c b/tests/test_rs.c index 2e82edb5d6..f4cf1e609e 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -18,7 +18,7 @@ void test_rscode1(void) testStart("RS ecc test"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)str); - QRenc_setErrorCorrectionLevel(stream, QR_ECLEVEL_M); + QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_M); code = QRraw_new(stream); testEnd(memcmp(correct + 16, code->rsblock[0].ecc, 10)); -- cgit 0.0.5-2-1-g0f52 From 9a231867b34df39dd360c0ee2a941209d8e26fff Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 22 Nov 2006 14:15:38 +0000 Subject: --- qrencode.c | 4 ++-- tests/test_qrencode.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/qrencode.c b/qrencode.c index b4f461130e..71e161b6fe 100644 --- a/qrencode.c +++ b/qrencode.c @@ -719,7 +719,7 @@ static int QRcode_eat8(const char *string, QRinput *input, int version, QRencode if(hint == QR_MODE_KANJI && mode == QR_MODE_KANJI) { break; } - if(mode != QR_MODE_8) { + if(mode != QR_MODE_8 && mode != QR_MODE_KANJI) { break; } p++; @@ -748,7 +748,7 @@ static int QRcode_eat8(const char *string, QRinput *input, int version, QRencode } } } - QRinput_append(input, QR_MODE_AN, p - string, (unsigned char *)string); + QRinput_append(input, QR_MODE_8, p - string, (unsigned char *)string); return p - string; } diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 082c2f1c62..e3990db4f9 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -497,7 +497,7 @@ void test_split4(void) QRcode_splitStringToQRinput("abcde1234567890123", input, 0, QR_MODE_8); list = input->head; if(list->mode != QR_MODE_AN || list->size != 5) { - printf("fist item is not alnum.\n"); + printf("first item is not alnum.\n"); err++; } if(list->next == NULL) { @@ -516,6 +516,54 @@ void test_split4(void) } testEnd(err); QRinput_free(input); + + testStart("Split test 8: bit, an, bit, num"); + input = QRinput_new(); + QRcode_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_8); + list = input->head; + if(list->mode != QR_MODE_8 || list->size != 2) { + printf("first item is not 8bit.\n"); + err++; + } + if(list->next == NULL) { + printf("no second item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_AN || list->size != 11) { + printf("second item is not an: %d %d\n", list->mode, list->size); + printf("%s\n", list->data); + err++; + } + if(list->next == NULL) { + printf("no third item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_8 || list->size != 2) { + printf("third item is not an.\n"); + err++; + } + if(list->next == NULL) { + printf("no fourth item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_NUM || list->size != 6) { + printf("fourth item is not num.\n"); + err++; + } + if(list->next != NULL) { + printf("not terminated.\n"); + err++; + goto EXIT; + } +EXIT: + testEnd(err); + QRinput_free(input); } int main(int argc, char **argv) -- cgit 0.0.5-2-1-g0f52 From d689a84805586261ba0f9f5b3f6a8af028ba6c6c Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 24 Nov 2006 12:08:20 +0000 Subject: --- qrencode.c | 2 +- tests/test_qrencode.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/qrencode.c b/qrencode.c index 71e161b6fe..a4ddc9bdf4 100644 --- a/qrencode.c +++ b/qrencode.c @@ -775,7 +775,7 @@ void QRcode_splitStringToQRinput(const char *string, QRinput *input, QRcode_splitStringToQRinput(&string[length], input, hint, version); } -extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint) +QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint) { QRinput *input; diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index e3990db4f9..94dc84a316 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -566,6 +566,61 @@ EXIT: QRinput_free(input); } +void test_split5(void) +{ + QRinput *input; + QRinput_List *list; + int err = 0; + + testStart("Split test 9: kanji, an, kanji, num"); + input = QRinput_new(); + QRcode_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_KANJI); + list = input->head; + if(list->mode != QR_MODE_KANJI || list->size != 2) { + printf("first item is not kanji.\n"); + err++; + } + if(list->next == NULL) { + printf("no second item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_AN || list->size != 11) { + printf("second item is not an: %d %d\n", list->mode, list->size); + printf("%s\n", list->data); + err++; + } + if(list->next == NULL) { + printf("no third item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_KANJI || list->size != 2) { + printf("third item is not kanji.\n"); + err++; + } + if(list->next == NULL) { + printf("no fourth item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_NUM || list->size != 6) { + printf("fourth item is not num.\n"); + err++; + } + if(list->next != NULL) { + printf("not terminated.\n"); + err++; + goto EXIT; + } +EXIT: + testEnd(err); + QRinput_free(input); +} + int main(int argc, char **argv) { test_iterate(); @@ -583,6 +638,7 @@ int main(int argc, char **argv) test_split2(); test_split3(); test_split4(); + test_split5(); report(); -- cgit 0.0.5-2-1-g0f52 From 7db1a3f2831e36f0d166432f5597bc84a5ffdef7 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 24 Nov 2006 16:28:18 +0000 Subject: --- qrencode.c | 4 +++- qrencode_inner.h | 1 + qrinput.h | 2 +- tests/test_qrencode.c | 26 +++++++++++++++++++++----- tests/view_qrcode.c | 14 ++++++++------ 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/qrencode.c b/qrencode.c index a4ddc9bdf4..3c9f4cbf45 100644 --- a/qrencode.c +++ b/qrencode.c @@ -58,6 +58,7 @@ QRRawCode *QRraw_new(QRinput *input) raw = (QRRawCode *)malloc(sizeof(QRRawCode)); raw->datacode = QRinput_getByteStream(input); spec = QRspec_getEccSpec(input->version, input->level); + raw->version = input->version; raw->blocks = QRspec_rsBlockNum(spec); raw->rsblock = (RSblock *)malloc(sizeof(RSblock) * raw->blocks); @@ -565,8 +566,9 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask QRinput_setVersion(input, version); QRinput_setErrorCorrectionLevel(input, level); - width = QRspec_getWidth(version); raw = QRraw_new(input); + version = raw->version; + width = QRspec_getWidth(version); frame = QRspec_newFrame(version); filler = FrameFiller_new(width, frame); diff --git a/qrencode_inner.h b/qrencode_inner.h index ce7e088837..b31bf3c87e 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -38,6 +38,7 @@ typedef struct { } RSblock; typedef struct { + int version; unsigned char *datacode; int blocks; RSblock *rsblock; diff --git a/qrinput.h b/qrinput.h index 5b3e2696b2..5c249ee076 100644 --- a/qrinput.h +++ b/qrinput.h @@ -92,7 +92,7 @@ extern QRencodeMode QRinput_identifyMode(const char *string); /** * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). - * @param c character + * @param __c__ character * @return value */ #define QRinput_lookAnTable(__c__) \ diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 94dc84a316..43e9036e69 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -370,6 +370,17 @@ void test_encode(void) testEnd(err); } +void test_encode2(void) +{ + QRcode *qrcode; + + testStart("Test encode (2-H)"); + qrcode = QRcode_encodeString("abcdefghijkl123456789012", 0, QR_ECLEVEL_H, QR_MODE_8); + printf("%d\n", qrcode->version); + testEndExp(qrcode->version == 2); + QRcode_free(qrcode); +} + void print_encode(void) { QRinput *stream; @@ -426,6 +437,7 @@ void test_split2(void) testEnd(err); QRinput_free(input); + err = 0; testStart("Split test 3: single typed strings (num2)"); input = QRinput_new(); QRcode_splitStringToQRinput("12345678901234567890", input, 0, QR_MODE_KANJI); @@ -459,6 +471,7 @@ void test_split3(void) testEnd(err); QRinput_free(input); + err = 0; testStart("Split test 5: num + an"); input = QRinput_new(); QRcode_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI); @@ -472,6 +485,7 @@ void test_split3(void) testEnd(err); QRinput_free(input); + err = 0; testStart("Split test 6: an + num + an"); input = QRinput_new(); QRcode_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI); @@ -494,10 +508,10 @@ void test_split4(void) testStart("Split test 7: an and num entries"); input = QRinput_new(); - QRcode_splitStringToQRinput("abcde1234567890123", input, 0, QR_MODE_8); + QRcode_splitStringToQRinput("abcdefghijkl123456789012", input, 0, QR_MODE_8); list = input->head; - if(list->mode != QR_MODE_AN || list->size != 5) { - printf("first item is not alnum.\n"); + if(list->mode != QR_MODE_AN || list->size != 12) { + printf("first item is not alnum: %d %d\n", list->mode, list->size); err++; } if(list->next == NULL) { @@ -505,7 +519,7 @@ void test_split4(void) err++; } else { list = list->next; - if(list->mode != QR_MODE_NUM || list->size != 13) { + if(list->mode != QR_MODE_NUM || list->size != 12) { printf("second item is not number.: %d %d\n", list->mode, list->size); err++; } @@ -517,6 +531,7 @@ void test_split4(void) testEnd(err); QRinput_free(input); + err = 0; testStart("Split test 8: bit, an, bit, num"); input = QRinput_new(); QRcode_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_8); @@ -632,13 +647,14 @@ int main(int argc, char **argv) test_eval(); test_eval2(); test_eval3(); - test_encode(); // print_encode(); test_split1(); test_split2(); test_split3(); test_split4(); test_split5(); + test_encode(); + test_encode2(); report(); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 6868d33553..0e27cd95ae 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -37,10 +37,9 @@ int eventloop(void) return 0; } -void view_simple(void) +void view_simple(const char *str) { QRinput *stream; - char num[9] = "01234567"; unsigned char *frame, *q; int width; int x, y; @@ -56,8 +55,7 @@ void view_simple(void) SDL_Rect rect; stream = QRinput_new(); - - QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); + QRcode_splitStringToQRinput(str, stream, 0, QR_MODE_KANJI); while(flag) { qrcode = QRcode_encodeMask(stream, version, level, mask); @@ -157,14 +155,18 @@ void view_simple(void) QRinput_free(stream); } -int main() +int main(int argc, char **argv) { + if(argc != 2) { + printf("Usage: view_qrcode string\n"); + exit(1); + } if(SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Failed initializing SDL: %s\n", SDL_GetError()); return -1; } - view_simple(); + view_simple(argv[1]); SDL_Quit(); -- cgit 0.0.5-2-1-g0f52 From 61c843c97f2e68f8edd5fe8f47deaa65928863e4 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 25 Nov 2006 02:03:28 +0000 Subject: --- qrencode.c | 37 +++++++++++++++++------------ qrinput.c | 63 ++++++++++++++++++++++++++---------------------- qrinput.h | 5 ++++ tests/test_qrencode.c | 28 ++++++++++++++++++---- tests/test_qrinput.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++- tests/view_qrcode.c | 2 ++ 6 files changed, 152 insertions(+), 49 deletions(-) diff --git a/qrencode.c b/qrencode.c index 3c9f4cbf45..e1fc57088b 100644 --- a/qrencode.c +++ b/qrencode.c @@ -649,18 +649,13 @@ static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencod { const char *p, *q; int run; - int range, rangeN; + int b1, b2; + int la, ln, l8; + + la = QRspec_lengthIndicator(QR_MODE_AN, version); + ln = QRspec_lengthIndicator(QR_MODE_NUM, version); + l8 = QRspec_lengthIndicator(QR_MODE_8, version); - if(version <= 9) { - range = 6; - rangeN = 13; - } else if(version <= 26) { - range = 7; - rangeN = 15; - } else { - range = 8; - rangeN = 17; - } p = string; while(isalnum(*p)) { if(isdigit(*p)) { @@ -668,7 +663,10 @@ static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencod while(isdigit(*q)) { q++; } - if(q - p >= rangeN) { + b1 = 4 + la + QRinput_estimateBitsModeAn(p - string) + + 4 + ln + QRinput_estimateBitsModeNum(q - p); + b2 = 4 + la + QRinput_estimateBitsModeAn(q - string); + if(b2 > b1) { break; } else { p = q; @@ -678,8 +676,13 @@ static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencod } } run = p - string; - if(run < range && (*p & 0x80)) { - return QRcode_eat8(string, input, version, hint); + if(*p & 0x80) { + b1 = 4 + la + QRinput_estimateBitsModeAn(run) + + 4 + l8 + QRinput_estimateBitsMode8(1); + b2 = 4 + l8 + QRinput_estimateBitsMode8(run + 1); + if(b1 > b2) { + return QRcode_eat8(string, input, version, hint); + } } QRinput_append(input, QR_MODE_AN, run, (unsigned char *)string); @@ -780,6 +783,7 @@ void QRcode_splitStringToQRinput(const char *string, QRinput *input, QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint) { QRinput *input; + QRcode *code; if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) { return NULL; @@ -787,5 +791,8 @@ QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QR input = QRinput_new(); QRcode_splitStringToQRinput(string, input, version, hint); - return QRcode_encodeInput(input, version, level); + code = QRcode_encodeInput(input, version, level); + QRinput_free(input); + + return code; } diff --git a/qrinput.c b/qrinput.c index 3835a4040a..2d2b3e19ea 100644 --- a/qrinput.c +++ b/qrinput.c @@ -158,17 +158,17 @@ static int QRinput_checkModeNum(int size, const char *data) /** * Estimates the length of the encoded bit stream of numeric data. - * @param entry + * @param size * @return number of bits */ -static int QRinput_estimateBitsModeNum(QRinput_List *entry) +int QRinput_estimateBitsModeNum(int size) { int w; int bits; - w = entry->size / 3; + w = size / 3; bits = w * 10; - switch(entry->size - w * 3) { + switch(size - w * 3) { case 1: bits += 4; break; @@ -254,17 +254,17 @@ static int QRinput_checkModeAn(int size, const char *data) /** * Estimates the length of the encoded bit stream of alphabet-numeric data. - * @param entry + * @param size * @return number of bits */ -static int QRinput_estimateBitsModeAn(QRinput_List *entry) +int QRinput_estimateBitsModeAn(int size) { int w; int bits; - w = entry->size / 2; + w = size / 2; bits = w * 11; - if(entry->size & 1) { + if(size & 1) { bits += 6; } @@ -310,12 +310,12 @@ static void QRinput_encodeModeAn(QRinput_List *entry, int version) /** * Estimates the length of the encoded bit stream of 8 bit data. - * @param entry + * @param size * @return number of bits */ -static int QRinput_estimateBitsMode8(QRinput_List *entry) +int QRinput_estimateBitsMode8(int size) { - return entry->size * 8; + return size * 8; } /** @@ -347,12 +347,12 @@ static void QRinput_encodeMode8(QRinput_List *entry, int version) /** * Estimates the length of the encoded bit stream of kanji data. - * @param entry + * @param size * @return number of bits */ -static int QRinput_estimateBitsModeKanji(QRinput_List *entry) +int QRinput_estimateBitsModeKanji(int size) { - return (entry->size / 2) * 13; + return (size / 2) * 13; } /** @@ -479,16 +479,16 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version switch(entry->mode) { case QR_MODE_NUM: - bits = QRinput_estimateBitsModeNum(entry); + bits = QRinput_estimateBitsModeNum(entry->size); break; case QR_MODE_AN: - bits = QRinput_estimateBitsModeAn(entry); + bits = QRinput_estimateBitsModeAn(entry->size); break; case QR_MODE_8: - bits = QRinput_estimateBitsMode8(entry); + bits = QRinput_estimateBitsMode8(entry->size); break; case QR_MODE_KANJI: - bits = QRinput_estimateBitsModeKanji(entry); + bits = QRinput_estimateBitsModeKanji(entry->size); break; } @@ -663,7 +663,7 @@ static BitStream *QRinput_createPaddingBit(QRinput *input) maxwords = QRspec_getDataLength(input->version, input->level); maxbits = maxwords * 8; - + list = input->head; bits = 0; while(list != NULL) { @@ -673,18 +673,23 @@ static BitStream *QRinput_createPaddingBit(QRinput *input) words = (bits + 7) / 8; - if(bits == maxbits) - return NULL; - if(maxbits - bits < 5) { - bstream = BitStream_new(); - BitStream_appendNum(bstream, maxbits - bits, 0); - return bstream; + if(maxbits == bits) { + return NULL; + } else { + bstream = BitStream_new(); + BitStream_appendNum(bstream, maxbits - bits, 0); + return bstream; + } } + bits += 4; + words = (bits + 7) / 8; + bstream = BitStream_new(); - BitStream_appendNum(bstream, words * 8 - bits, 0); + BitStream_appendNum(bstream, words * 8 - bits + 4, 0); + /* FIXME: It would be able to add padding bits by more efficient way. */ for(i=0; iversion); + testStart("Test encode (2-H) (no padding test)"); + qrcode = QRcode_encodeString("abcdefghijk123456789012", 0, QR_ECLEVEL_H, QR_MODE_8); testEndExp(qrcode->version == 2); QRcode_free(qrcode); } +void test_encode3(void) +{ + QRcode *code1, *code2; + QRinput *input; + + testStart("Compare encodeString and encodeInput"); + code1 = QRcode_encodeString("0123456", 0, QR_ECLEVEL_L, QR_MODE_8); + input = QRinput_new(); + QRinput_append(input, QR_MODE_NUM, 7, (unsigned char *)"0123456"); + code2 = QRcode_encodeInput(input, 0, QR_ECLEVEL_L); + testEnd(memcmp(code1->data, code2->data, code1->width * code1->width)); + + QRcode_free(code1); + QRcode_free(code2); + QRinput_free(input); +} + void print_encode(void) { QRinput *stream; @@ -508,9 +524,10 @@ void test_split4(void) testStart("Split test 7: an and num entries"); input = QRinput_new(); - QRcode_splitStringToQRinput("abcdefghijkl123456789012", input, 0, QR_MODE_8); + QRcode_splitStringToQRinput("abcdefghijk123456789012", input, 0, QR_MODE_8); + list = input->head; - if(list->mode != QR_MODE_AN || list->size != 12) { + if(list->mode != QR_MODE_AN || list->size != 11) { printf("first item is not alnum: %d %d\n", list->mode, list->size); err++; } @@ -655,6 +672,7 @@ int main(int argc, char **argv) test_split5(); test_encode(); test_encode2(); + test_encode3(); report(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index e1daea7131..2ec5b1f6a1 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -102,7 +102,27 @@ void test_encodeNumericPadded(void) QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); bstream = QRinput_getBitStream(stream); flag = strncmp(correct, bstream->data, 48); - printf("%s\n", bstream->data); + if(strlen(bstream->data) != 19 * 8) + flag |= 0x80; + testEnd(flag); + + QRinput_free(stream); + BitStream_free(bstream); +} + +void test_encodeNumericPadded2(void) +{ + QRinput *stream; + char num[8] = "0123456"; + char correct[] = "000100000001110000001100010101100101100000000000"; + BitStream *bstream; + int flag; + + testStart("Encoding numeric stream. (7 digits)(padded)"); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 7, (unsigned char *)num); + bstream = QRinput_getBitStream(stream); + flag = strncmp(correct, bstream->data, 48); if(strlen(bstream->data) != 19 * 8) flag |= 0x80; testEnd(flag); @@ -129,6 +149,24 @@ void test_encodeNumeric2(void) BitStream_free(bstream); } +void test_encodeNumeric3(void) +{ + QRinput *stream; + char num[9] = "0123456"; + char correct[] = "0001""0000000111""0000001100""0101011001""0110"; + BitStream *bstream; + + testStart("Encoding numeric stream. (7 digits)"); + stream = QRinput_new(); + QRinput_append(stream, QR_MODE_NUM, 7, (unsigned char *)num); + bstream = QRinput_mergeBitStream(stream); + printf("%s\n", correct); + printf("%s\n", bstream->data); + testEnd(strcmp(correct, bstream->data)); + QRinput_free(stream); + BitStream_free(bstream); +} + void test_encode82(void) { QRinput *stream; @@ -156,16 +194,42 @@ void test_encode82(void) free(data); } +void test_encodeAnNum(void) +{ + QRinput *input; + BitStream *bstream; + + testStart("Bit length check of alpha-numeric stream. (11 + 12)"); + input = QRinput_new(); + QRinput_append(input, QR_MODE_AN, 11, (unsigned char *)"abcdefghijk"); + QRinput_append(input, QR_MODE_NUM, 12, (unsigned char *)"123456789012"); + bstream = QRinput_mergeBitStream(input); + testEndExp(strlen(bstream->data) == 128); + QRinput_free(input); + BitStream_free(bstream); + + testStart("Bit length check of alphabet stream. (23)"); + input = QRinput_new(); + QRinput_append(input, QR_MODE_AN, 23, (unsigned char *)"abcdefghijk123456789012"); + bstream = QRinput_mergeBitStream(input); + testEndExp(strlen(bstream->data) == 140); + QRinput_free(input); + BitStream_free(bstream); +} + int main(int argc, char **argv) { test_encodeNumeric(); test_encodeNumeric2(); + test_encodeNumeric3(); test_encode8(); // test_encode82(); test_encodeAn(); test_encodeAn2(); test_encodeKanji(); test_encodeNumericPadded(); + test_encodeNumericPadded2(); + test_encodeAnNum(); report(); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 0e27cd95ae..77d7635cc4 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -5,6 +5,7 @@ #include "common.h" #include "../qrencode_inner.h" #include "../qrspec.h" +#include "../qrinput.h" SDL_Surface *screen = NULL; @@ -57,6 +58,7 @@ void view_simple(const char *str) stream = QRinput_new(); QRcode_splitStringToQRinput(str, stream, 0, QR_MODE_KANJI); + while(flag) { qrcode = QRcode_encodeMask(stream, version, level, mask); width = qrcode->width; -- cgit 0.0.5-2-1-g0f52 From 7f8ae3d9cb15f0e85857d1c1aa9cb934a5b84e97 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 1 Dec 2006 19:21:08 +0000 Subject: --- Makefile.am | 11 ++ configure.ac | 14 ++- libqrencode.pc.in | 9 ++ qrenc.c | 288 ++++++++++++++++++++++++++++++++++++++++++++++++++ qrencode.c | 147 ++++++++++++++------------ qrencode.h | 10 +- qrinput.c | 14 ++- qrspec.c | 4 - qrspec.h | 2 + tests/test_qrencode.c | 217 +++++++++++++++++++++++++++++++------ tests/test_qrinput.c | 27 ++--- tests/view_qrcode.c | 30 +----- 12 files changed, 610 insertions(+), 163 deletions(-) create mode 100644 libqrencode.pc.in create mode 100644 qrenc.c diff --git a/Makefile.am b/Makefile.am index 0d1a9c62ac..879cf3ce01 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,3 +12,14 @@ libqrencode_la_SOURCES = qrencode.c qrencode_inner.h \ libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) include_HEADERS = qrencode.h + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libqrencode.pc + +EXTRA_DIST = libqrencode.pc.in + +if BUILD_TOOLS +bin_PROGRAMS = qrencode +qrencode_SOURCES = qrenc.c +qrencode_LDADD = -lqrencode -lpng +endif diff --git a/configure.ac b/configure.ac index 21d1750c65..1c0561be08 100644 --- a/configure.ac +++ b/configure.ac @@ -27,12 +27,20 @@ AC_PROG_LIBTOOL SDL_REQUIRED_VERSION=1.2.0 -AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_ERROR([*** SDL $SDL_REQUIRED_VERSION or better is required.])) -AM_CONDITIONAL(HAVE_SDL, test SDL_CFLAGS) +AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.])) +AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ]) CFLAGS="-Wall $CFLAGS" -AC_CONFIG_FILES([Makefile tests/Makefile]) +AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile]) + +AC_ARG_WITH([tools], [AC_HELP_STRING([--with-tools], [build utility tools [default=yes]])], + [], [build_tools=yes]) + +if test x$build_tools = xyes ; then + AM_PATH_LIBPNG +fi +AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ]) AC_OUTPUT diff --git a/libqrencode.pc.in b/libqrencode.pc.in new file mode 100644 index 0000000000..da3c8de5e9 --- /dev/null +++ b/libqrencode.pc.in @@ -0,0 +1,9 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libqrencode +Description: A QR Code encoding library +Version: @VERSION@ +Libs: -L${libdir} -lqrencode diff --git a/qrenc.c b/qrenc.c new file mode 100644 index 0000000000..b01bc3cfc3 --- /dev/null +++ b/qrenc.c @@ -0,0 +1,288 @@ +/** + * qrencode - QR Code encoder + * + * QR Code encoding tool + * Copyright (C) 2006 Kentaro Fukuchi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include + +#include "qrencode.h" + +static int kanji = 0; +static int version = 0; +static int size = 3; +static int margin = 4; +static QRecLevel level = QR_ECLEVEL_L; + +enum { + O_HELP, + O_OUTPUT, + O_SIZE, + O_VERSION, + O_LEVEL, + O_MARGIN, + O_INPUT, + O_KANJI +}; + +const struct option options[] = { + {"h", no_argument , NULL, O_HELP}, + {"o", required_argument, NULL, O_OUTPUT}, + {"l", required_argument, NULL, O_LEVEL}, + {"s", required_argument, NULL, O_SIZE}, + {"v", required_argument, NULL, O_VERSION}, + {"m", required_argument, NULL, O_MARGIN}, + {"i", required_argument, NULL, O_INPUT}, + {"k", no_argument , NULL, O_KANJI} +}; + +void usage(void) +{ + fprintf(stderr, +"Usage: qrencode [OPTION]...\n" +" -h : display this message\n" +" -o : set the output file. If it is not specified, the result is\n" +" output to standard output\n" +" -s : specify the size of a dot (pixel) (default=3)\n" +" -v : specify the version of the symbol\n" +" -m : specify the width of margin (default=4)\n" +" -i : specify input text. If it s not specified, get input text\n" +" from standard input\n" +" -k : assume that the input text contains kanji (shift-jis)\n" +); +} + +#define MAX_DATA_SIZE 7090 /* from the specification */ +char *readStdin(void) +{ + char *buffer; + int ret; + + buffer = (char *)malloc(MAX_DATA_SIZE); + ret = fread(buffer, 1, MAX_DATA_SIZE, stdin); + if(ret == 0) { + fprintf(stderr, "No input data.\n"); + exit(1); + } + if(!feof(stdin)) { + fprintf(stderr, "Input data is too large.\n"); + exit(1); + } + + buffer[ret] = '\0'; + + return buffer; +} + +QRcode *encode(const char *intext) +{ + QRencodeMode hint; + + if(kanji) { + hint = QR_MODE_KANJI; + } else { + hint = QR_MODE_8; + } + return QRcode_encodeString(intext, version, level, hint); +} + +void qrencode(const char *intext, const char *outfile) +{ + FILE *fp; + QRcode *qrcode; + png_structp png_ptr; + png_infop info_ptr; + unsigned char *row, *p, *q; + int x, y, xx, yy, bit; + int realwidth; + + qrcode = encode(intext); + if(qrcode == NULL) { + fprintf(stderr, "Failed to encode the input data.\n"); + exit(1); + } + + realwidth = (qrcode->width + margin * 2) * size; + row = (unsigned char *)malloc((realwidth + 7) / 8); + + if(outfile != NULL) { + fp = fopen(outfile, "w"); + if(fp == NULL) { + fprintf(stderr, "Failed to create file: %s\n", outfile); + exit(1); + } + } else { + fp = stdout; + } + + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if(png_ptr == NULL) { + fclose(fp); + fprintf(stderr, "Failed to initialize PNG writer.\n"); + exit(1); + } + + info_ptr = png_create_info_struct(png_ptr); + if(info_ptr == NULL) { + fclose(fp); + fprintf(stderr, "Failed to initialize PNG write.\n"); + exit(1); + } + + if(setjmp(png_jmpbuf(png_ptr))) { + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); + fprintf(stderr, "Failed to write PNG image.\n"); + exit(1); + } + + png_init_io(png_ptr, fp); + png_set_IHDR(png_ptr, info_ptr, + realwidth, realwidth, + 1, + PNG_COLOR_TYPE_GRAY, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + png_write_info(png_ptr, info_ptr); + + /* top margin */ + memset(row, 0xff, (realwidth + 7) / 8); + for(y=0; ydata; + for(y=0; ywidth; y++) { + bit = 7; + memset(row, 0xff, (realwidth + 7) / 8); + q = row; + q += margin * size / 8; + bit = 7 - (margin * size % 8); + for(x=0; xwidth; x++) { + for(xx=0; xxdatacode = QRinput_getByteStream(input); + raw->datacode = p; spec = QRspec_getEccSpec(input->version, input->level); raw->version = input->version; raw->blocks = QRspec_rsBlockNum(spec); @@ -567,6 +572,9 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask QRinput_setErrorCorrectionLevel(input, level); raw = QRraw_new(input); + if(raw == NULL) { + return NULL; + } version = raw->version; width = QRspec_getWidth(version); frame = QRspec_newFrame(version); @@ -617,28 +625,31 @@ static int QRcode_eatNum(const char *string, QRinput *input, int version, QRenco { const char *p; int run; - int rangeA, range8; - - if(version <= 9) { - range8 = 4; - rangeA = 7; - } else if(version <= 26) { - range8 = 4; - rangeA = 8; - } else { - range8 = 5; - rangeA = 9; - } + int dif; + int ln; + + ln = QRspec_lengthIndicator(QR_MODE_NUM, version); + p = string; while(isdigit(*p)) { p++; } run = p - string; - if(run < range8 && (*p & 0x80)) { - return QRcode_eat8(string, input, version, hint); + if(*p & 0x80) { + dif = QRinput_estimateBitsModeNum(run) + 4 + ln + + QRinput_estimateBitsMode8(1) /* + 4 + l8 */ + - QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */; + if(dif > 0) { + return QRcode_eat8(string, input, version, hint); + } } - if(run < rangeA && isalnum(*p)) { - return QRcode_eatAn(string, input, version, hint); + if(isalnum(*p)) { + dif = QRinput_estimateBitsModeNum(run) + 4 + ln + + QRinput_estimateBitsModeAn(1) /* + 4 + la */ + - QRinput_estimateBitsModeAn(run + 1) /* - 4 - la */; + if(dif > 0) { + return QRcode_eatAn(string, input, version, hint); + } } QRinput_append(input, QR_MODE_NUM, run, (unsigned char *)string); @@ -649,12 +660,11 @@ static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencod { const char *p, *q; int run; - int b1, b2; - int la, ln, l8; + int dif; + int la, ln; la = QRspec_lengthIndicator(QR_MODE_AN, version); ln = QRspec_lengthIndicator(QR_MODE_NUM, version); - l8 = QRspec_lengthIndicator(QR_MODE_8, version); p = string; while(isalnum(*p)) { @@ -663,10 +673,10 @@ static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencod while(isdigit(*q)) { q++; } - b1 = 4 + la + QRinput_estimateBitsModeAn(p - string) - + 4 + ln + QRinput_estimateBitsModeNum(q - p); - b2 = 4 + la + QRinput_estimateBitsModeAn(q - string); - if(b2 > b1) { + dif = QRinput_estimateBitsModeAn(p - string) /* + 4 + la */ + + QRinput_estimateBitsModeNum(q - p) + 4 + ln + - QRinput_estimateBitsModeAn(q - string) /* - 4 - la */; + if(dif < 0) { break; } else { p = q; @@ -675,12 +685,14 @@ static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencod p++; } } + run = p - string; + if(*p & 0x80) { - b1 = 4 + la + QRinput_estimateBitsModeAn(run) - + 4 + l8 + QRinput_estimateBitsMode8(1); - b2 = 4 + l8 + QRinput_estimateBitsMode8(run + 1); - if(b1 > b2) { + dif = QRinput_estimateBitsModeAn(run) + 4 + la + + QRinput_estimateBitsMode8(1) /* + 4 + l8 */ + - QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */; + if(dif > 0) { return QRcode_eat8(string, input, version, hint); } } @@ -704,55 +716,52 @@ static int QRcode_eatKanji(const char *string, QRinput *input, int version, QRen static int QRcode_eat8(const char *string, QRinput *input, int version, QRencodeMode hint) { const char *p, *q; - int rangeA, rangeN; QRencodeMode mode; + int dif; + int la, ln; + + la = QRspec_lengthIndicator(QR_MODE_AN, version); + ln = QRspec_lengthIndicator(QR_MODE_NUM, version); - if(version <= 9) { - rangeN = 6; - rangeA = 11; - } else if(version <= 26) { - rangeN = 8; - rangeA = 15; - } else { - rangeN = 9; - rangeA = 16; - } p = string; - while(1) { - while(*p != '\0') { - mode = QRinput_identifyMode(p); - if(hint == QR_MODE_KANJI && mode == QR_MODE_KANJI) { - break; - } - if(mode != QR_MODE_8 && mode != QR_MODE_KANJI) { - break; - } - p++; - } - if(*p == '\0') { + while(*p != '\0') { + mode = QRinput_identifyMode(p); + if(hint == QR_MODE_KANJI && mode == QR_MODE_KANJI) { break; - } else if(isdigit(*p)) { - q = p; - while(isdigit(*q)) { - q++; - } - if(q - p >= rangeN) { - break; - } else { - p = q; - } - } else if(isalnum(*p)) { - q = p; - while(isalnum(*q)) { - q++; - } - if(q - p >= rangeA) { - break; + } + if(mode != QR_MODE_8 && mode != QR_MODE_KANJI) { + if(mode == QR_MODE_NUM) { + q = p; + while(isdigit(*q)) { + q++; + } + dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */ + + QRinput_estimateBitsModeNum(q - p) + 4 + ln + - QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */; + if(dif < 0) { + break; + } else { + p = q; + } } else { - p = q; + q = p; + while(isalnum(*q)) { + q++; + } + dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */ + + QRinput_estimateBitsModeAn(q - p) + 4 + la + - QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */; + if(dif < 0) { + break; + } else { + p = q; + } } + } else { + p++; } } + QRinput_append(input, QR_MODE_8, p - string, (unsigned char *)string); return p - string; } diff --git a/qrencode.h b/qrencode.h index 8de58610ee..380b2d988e 100644 --- a/qrencode.h +++ b/qrencode.h @@ -89,11 +89,12 @@ extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) /** * QRcode class. - * Symbol data is an array contains width*width uchars. Each uchar represents - * a module (dot). If the less significant bit of a uchar is 1, the - * corresponding module is black. The other bits are meaningless for usual - * application, but here the specification is described. + * Symbol data is represented as an array contains width*width uchars. + * Each uchar represents a module (dot). If the less significant bit of + * the uchar is 1, the corresponding module is black. The other bits are + * meaningless for usual application, but here the specification is described. * + *
  * MSB 76543210 LSB
  *     |||||||`- 1=black/0=white
  *     ||||||`-- data and ecc code area
@@ -103,6 +104,7 @@ extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data)
  *     ||`------ alignment pattern
  *     |`------- finder pattern and separator
  *     `-------- non-data modules (format, timing, etc.)
+ * 
*/ typedef struct { int version; ///< version of the symbol diff --git a/qrinput.c b/qrinput.c index 2d2b3e19ea..5555863215 100644 --- a/qrinput.c +++ b/qrinput.c @@ -442,7 +442,7 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) QRencodeMode QRinput_identifyMode(const char *string) { - unsigned char c; + unsigned char c, d; unsigned int word; c = string[0]; @@ -452,9 +452,12 @@ QRencodeMode QRinput_identifyMode(const char *string) } else if((QRinput_lookAnTable(c)) >= 0) { return QR_MODE_AN; } else { - word = c << 8 | string[1]; - if(word < 0x8140 || (word > 0x9ffc && word < 0xe040) || word > 0xebbf) { - return QR_MODE_KANJI; + d = string[1]; + if(d != '\0') { + word = ((unsigned int)c << 8) | d; + if((word >= 0x8140 && word <= 0x9ffc) || (word >= 0xe040 && word <= 0xebbf)) { + return QR_MODE_KANJI; + } } } @@ -762,6 +765,9 @@ unsigned char *QRinput_getByteStream(QRinput *input) unsigned char *array; bstream = QRinput_getBitStream(input); + if(bstream == NULL) { + return NULL; + } array = BitStream_toByte(bstream); BitStream_free(bstream); diff --git a/qrspec.c b/qrspec.c index 8557710401..85b5198fc2 100644 --- a/qrspec.c +++ b/qrspec.c @@ -571,7 +571,3 @@ unsigned char *QRspec_newFrame(int version) return frame; } - -void QRspec_fillFormatInfo(unsigned char *frame, int version, int mask) -{ -} diff --git a/qrspec.h b/qrspec.h index f08e13058e..9f9471fdce 100644 --- a/qrspec.h +++ b/qrspec.h @@ -176,6 +176,8 @@ extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); /** * Return a copy of initialized frame. + * When the same version is requested twice or more, a copy of cached frame + * is returned. * @param version * @return Array of unsigned char. You can free it by free(). */ diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index e3ef32919e..0000842e16 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -5,6 +5,18 @@ #include "../qrspec.h" #include "../qrinput.h" +int inputSize(QRinput *input) +{ + BitStream *bstream; + int size; + + bstream = QRinput_mergeBitStream(input); + size = BitStream_size(bstream); + BitStream_free(bstream); + + return size; +} + void test_iterate() { int i; @@ -397,6 +409,27 @@ void test_encode3(void) QRinput_free(input); } +void test_encodeTooLong(void) +{ + QRcode *code; + char *data; + + testStart("Encode too large data"); + data = (char *)malloc(4300); + memset(data, 'a', 4295); + memset(data + 4295, '0', 4); + data[4299] = '\0'; + + code = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8); + testEndExp(code == NULL); + + if(code != NULL) { + printf("%d, %d\n", code->version, code->width); + QRcode_free(code); + } + free(data); +} + void print_encode(void) { QRinput *stream; @@ -425,7 +458,7 @@ void test_split1(void) QRinput *input; BitStream *stream; - testStart("Split test 1: null string"); + testStart("Split test: null string"); input = QRinput_new(); QRcode_splitStringToQRinput("", input, 0, QR_MODE_8); stream = QRinput_mergeBitStream(input); @@ -440,7 +473,7 @@ void test_split2(void) QRinput_List *list; int err = 0; - testStart("Split test 2: single typed strings (num)"); + testStart("Split test: single typed strings (num)"); input = QRinput_new(); QRcode_splitStringToQRinput("0123", input, 0, QR_MODE_8); list = input->head; @@ -454,7 +487,7 @@ void test_split2(void) QRinput_free(input); err = 0; - testStart("Split test 3: single typed strings (num2)"); + testStart("Split test: single typed strings (num2)"); input = QRinput_new(); QRcode_splitStringToQRinput("12345678901234567890", input, 0, QR_MODE_KANJI); list = input->head; @@ -474,7 +507,7 @@ void test_split3(void) QRinput_List *list; int err = 0; - testStart("Split test 4: single typed strings (an)"); + testStart("Split test: single typed strings (an)"); input = QRinput_new(); QRcode_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8); list = input->head; @@ -488,7 +521,7 @@ void test_split3(void) QRinput_free(input); err = 0; - testStart("Split test 5: num + an"); + testStart("Split test: num + an"); input = QRinput_new(); QRcode_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI); list = input->head; @@ -502,7 +535,7 @@ void test_split3(void) QRinput_free(input); err = 0; - testStart("Split test 6: an + num + an"); + testStart("Split test: an + num + an"); input = QRinput_new(); QRcode_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI); list = input->head; @@ -519,37 +552,71 @@ void test_split3(void) void test_split4(void) { QRinput *input; - QRinput_List *list; - int err = 0; + QRinput *i1, *i2; + int s1, s2, size; +#define CHUNKA "abcdefghijk" +#define CHUNKB "123456" +#define CHUNKC "1234567" - testStart("Split test 7: an and num entries"); + testStart("Split test: an and num entries"); input = QRinput_new(); - QRcode_splitStringToQRinput("abcdefghijk123456789012", input, 0, QR_MODE_8); + QRcode_splitStringToQRinput(CHUNKA/**/CHUNKB, input, 0, QR_MODE_8); + i1 = QRinput_new(); + QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKA/**/CHUNKB); + i2 = QRinput_new(); + QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA); + QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB); + + size = inputSize(input); + s1 = inputSize(i1); + s2 = inputSize(i2); + testEndExp(size == ((s1 < s2)?s1:s2)); + QRinput_free(input); + QRinput_free(i1); + QRinput_free(i2); - list = input->head; - if(list->mode != QR_MODE_AN || list->size != 11) { - printf("first item is not alnum: %d %d\n", list->mode, list->size); - err++; - } - if(list->next == NULL) { - printf("no second item.\n"); - err++; - } else { - list = list->next; - if(list->mode != QR_MODE_NUM || list->size != 12) { - printf("second item is not number.: %d %d\n", list->mode, list->size); - err++; - } - if(list->next != NULL) { - printf("list is not terminated.\n"); - err++; - } - } - testEnd(err); + testStart("Split test: num and an entries"); + input = QRinput_new(); + QRcode_splitStringToQRinput(CHUNKB/**/CHUNKA, input, 0, QR_MODE_8); + i1 = QRinput_new(); + QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKB/**/CHUNKA); + i2 = QRinput_new(); + QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB); + QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA); + + size = inputSize(input); + s1 = inputSize(i1); + s2 = inputSize(i2); + testEndExp(size == ((s1 < s2)?s1:s2)); QRinput_free(input); + QRinput_free(i1); + QRinput_free(i2); - err = 0; - testStart("Split test 8: bit, an, bit, num"); + testStart("Split test: num and an entries (should be splitted)"); + input = QRinput_new(); + QRcode_splitStringToQRinput(CHUNKC/**/CHUNKA, input, 0, QR_MODE_8); + i1 = QRinput_new(); + QRinput_append(i1, QR_MODE_AN, 18, (unsigned char *)CHUNKC/**/CHUNKA); + i2 = QRinput_new(); + QRinput_append(i2, QR_MODE_NUM, 7, (unsigned char *)CHUNKC); + QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA); + + size = inputSize(input); + s1 = inputSize(i1); + s2 = inputSize(i2); + testEndExp(size == ((s1 < s2)?s1:s2)); + QRinput_free(input); + QRinput_free(i1); + QRinput_free(i2); +} + +void test_split5(void) +{ + QRinput *input; + QRinput_List *list; + int err = 0; + + testStart("Split test: bit, an, bit, num"); input = QRinput_new(); QRcode_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_8); list = input->head; @@ -598,13 +665,13 @@ EXIT: QRinput_free(input); } -void test_split5(void) +void test_split6(void) { QRinput *input; QRinput_List *list; int err = 0; - testStart("Split test 9: kanji, an, kanji, num"); + testStart("Split test: kanji, an, kanji, num"); input = QRinput_new(); QRcode_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_KANJI); list = input->head; @@ -653,6 +720,84 @@ EXIT: QRinput_free(input); } +void test_split7(void) +{ + QRinput *input; + QRinput_List *list; + int err = 0; + + testStart("Split test: an and num as bits"); + input = QRinput_new(); + QRcode_splitStringToQRinput("\x82\xd9""abcde\x82\xb0""12345", input, 0, QR_MODE_8); + list = input->head; + if(list->mode != QR_MODE_8 || list->size != 9) { + printf("first item is not 8bit.\n"); + err++; + } + if(list->next == NULL) { + printf("no second item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_NUM || list->size != 5) { + printf("second item is not num: %d %d\n", list->mode, list->size); + err++; + } + if(list->next != NULL) { + printf("not terminated.\n"); + err++; + goto EXIT; + } +EXIT: + testEnd(err); + QRinput_free(input); +} + +void test_split8(void) +{ + QRinput *input; + QRinput_List *list; + int err = 0; + + testStart("Split test: terminated with a half of kanji code"); + input = QRinput_new(); + QRcode_splitStringToQRinput("\x82\xd9""abcdefgh\x82", input, 0, QR_MODE_KANJI); + list = input->head; + if(list->mode != QR_MODE_KANJI || list->size != 2) { + printf("first item is not kanji.\n"); + err++; + } + if(list->next == NULL) { + printf("no second item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_AN || list->size != 8) { + printf("second item is not an: %d %d\n", list->mode, list->size); + err++; + } + if(list->next == NULL) { + printf("no third item.\n"); + err++; + goto EXIT; + } + list = list->next; + if(list->mode != QR_MODE_8 || list->size != 1) { + printf("third item is not bits: %d %d\n", list->mode, list->size); + err++; + } + if(list->next != NULL) { + printf("not terminated.\n"); + err++; + goto EXIT; + } +EXIT: + testEnd(err); + QRinput_free(input); +} + int main(int argc, char **argv) { test_iterate(); @@ -670,9 +815,13 @@ int main(int argc, char **argv) test_split3(); test_split4(); test_split5(); + test_split6(); + test_split7(); + test_split8(); test_encode(); test_encode2(); test_encode3(); + test_encodeTooLong(); report(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 2ec5b1f6a1..57308f4120 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -167,30 +167,25 @@ void test_encodeNumeric3(void) BitStream_free(bstream); } -void test_encode82(void) +void test_encodeTooLong(void) { QRinput *stream; unsigned char *data; BitStream *bstream; - char c1[] = "010011111111"; - char c2[] = "010000000010"; int flag = 0; - data = (unsigned char *)malloc(257); - memset(data, 0, 257); - testStart("Encoding byte stream. (257 bytes)"); + data = (unsigned char *)malloc(7089); + memset(data, 'a', 7089); + + testStart("Encoding long string. (7089 bytes)"); stream = QRinput_new(); - QRinput_append(stream, QR_MODE_8, 257, data); + QRinput_append(stream, QR_MODE_AN, 7089, data); bstream = QRinput_mergeBitStream(stream); - if(strncmp(c1, bstream->data, 12)) { - flag++; - } - if(strncmp(c2, bstream->data + 12 + 255*8, 12)) { - flag++; - } - testEnd(flag); + testEndExp(bstream == NULL); QRinput_free(stream); - BitStream_free(bstream); + if(bstream != NULL) { + BitStream_free(bstream); + } free(data); } @@ -223,7 +218,7 @@ int main(int argc, char **argv) test_encodeNumeric2(); test_encodeNumeric3(); test_encode8(); -// test_encode82(); + test_encodeTooLong(); test_encodeAn(); test_encodeAn2(); test_encodeKanji(); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 77d7635cc4..f1bc6c803c 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -9,35 +9,6 @@ SDL_Surface *screen = NULL; -int eventloop(void) -{ - SDL_Event event; - int q = 1; - - while(q) { - usleep(10000); - while(SDL_PollEvent(&event)) { - if(event.type == SDL_KEYDOWN) { - switch(event.key.keysym.sym) { - case SDLK_SPACE: - q = 0; - break; - case SDLK_ESCAPE: - q = 0; - break; - default: - break; - } - } - if(event.type == SDL_QUIT) { - return -1; - } - } - } - - return 0; -} - void view_simple(const char *str) { QRinput *stream; @@ -64,6 +35,7 @@ void view_simple(const char *str) width = qrcode->width; frame = qrcode->data; version = qrcode->version; + printf("Version %d, Leve %d, Mask %d.\n", version, level, mask); screen = SDL_SetVideoMode((width + 8) * scale, (width + 8) * scale, 32, 0); pitch = screen->pitch; q = frame; -- cgit 0.0.5-2-1-g0f52 From 8ec968806659153ac11c39e0e6c68ec264db659a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 1 Dec 2006 19:40:01 +0000 Subject: --- qrenc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/qrenc.c b/qrenc.c index b01bc3cfc3..15aadd5240 100644 --- a/qrenc.c +++ b/qrenc.c @@ -39,7 +39,6 @@ enum { O_VERSION, O_LEVEL, O_MARGIN, - O_INPUT, O_KANJI }; @@ -50,23 +49,24 @@ const struct option options[] = { {"s", required_argument, NULL, O_SIZE}, {"v", required_argument, NULL, O_VERSION}, {"m", required_argument, NULL, O_MARGIN}, - {"i", required_argument, NULL, O_INPUT}, - {"k", no_argument , NULL, O_KANJI} + {"k", no_argument , NULL, O_KANJI}, + {NULL, 0, NULL, 0} }; void usage(void) { fprintf(stderr, +"qrencode version %s\n" "Usage: qrencode [OPTION]...\n" " -h : display this message\n" " -o : set the output file. If it is not specified, the result is\n" " output to standard output\n" " -s : specify the size of a dot (pixel) (default=3)\n" +" -l {LMQH} : specify error collectin level from L (lowest) to H (highest).\n" " -v : specify the version of the symbol\n" " -m : specify the width of margin (default=4)\n" -" -i : specify input text. If it s not specified, get input text\n" -" from standard input\n" -" -k : assume that the input text contains kanji (shift-jis)\n" +" -k : assume that the input text contains kanji (shift-jis)\n", +VERSION ); } @@ -265,9 +265,6 @@ int main(int argc, char **argv) exit(1); } break; - case O_INPUT: - intext = optarg; - break; case O_KANJI: kanji = 1; break; @@ -278,6 +275,9 @@ int main(int argc, char **argv) } } + if(optind < argc) { + intext = argv[optind]; + } if(intext == NULL) { intext = readStdin(); } -- cgit 0.0.5-2-1-g0f52 From e1a058cdb3266d49b6cffe9e632083e6e7d190f0 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 2 Dec 2006 06:59:26 +0000 Subject: --- README | 12 ++++++------ qrenc.c | 36 +++++++++++++++++++++++------------- tests/test_qrinput.c | 1 - 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/README b/README index a359e02263..85fdc52234 100644 --- a/README +++ b/README @@ -24,10 +24,10 @@ INSTALL Requirements ------------ -Some test programs or utility tools requires SDL, but the library itself has no -dependencies. You can skip compiling those tools when if you want not to -install programs using SDL. If you are trying to compile this library on MS- -Windows, cygwin or some kinds of UNIX-like environments will be needed. +Some test programs or utility tools requires SDL or PNG, but the library itself +has no dependencies. You can skip compiling those tools when if you want not to +install programs using SDL or PNG. If you are trying to compile this library on +MS-Windows, cygwin or some kinds of UNIX-like environments will be needed. Compile & install ----------------- @@ -42,8 +42,8 @@ directories. By default, /usr/local/lib and /usr/local/include. You can change the destination directory by passing some options to the configure script. Run "./configure --help" to see the list of options. -Currently no program will be installed. If you want to install a binary -(e.g. view_qrcode), please copy it manually. +It also installs a binary "qrencode" to /usr/local/bin. If you want not to +install it, give "--without-tools" option to the configure script. LICENSING INFORMATION diff --git a/qrenc.c b/qrenc.c index 15aadd5240..1f8f4a2a7b 100644 --- a/qrenc.c +++ b/qrenc.c @@ -56,16 +56,20 @@ const struct option options[] = { void usage(void) { fprintf(stderr, -"qrencode version %s\n" -"Usage: qrencode [OPTION]...\n" -" -h : display this message\n" -" -o : set the output file. If it is not specified, the result is\n" -" output to standard output\n" -" -s : specify the size of a dot (pixel) (default=3)\n" -" -l {LMQH} : specify error collectin level from L (lowest) to H (highest).\n" -" -v : specify the version of the symbol\n" -" -m : specify the width of margin (default=4)\n" -" -k : assume that the input text contains kanji (shift-jis)\n", +"qrencode version %s\n\n" +"Usage: qrencode [OPTION]... [STRING]\n" +"Encode input data in a QR Code and save as a PNG image.\n\n" +" -h display this message.\n" +" -o FILENAME write PNG image to FILENAME. If '-' is specified, the result\n" +" will be output to standard output.\n" +" -s NUMBER specify the size of dot (pixel). (default=3)\n" +" -l {LMQH} specify error collectin level from L (lowest) to H (highest).\n" +" (default=L)\n" +" -v NUMBER specify the version of the symbol. (default=auto)\n" +" -m NUMBER specify the width of margin. (default=4)\n" +" -k assume that the input text contains kanji (shift-jis).\n" +" [STRING] input data. If it is not specified, data will be taken from\n" +" standard input.\n", VERSION ); } @@ -123,14 +127,14 @@ void qrencode(const char *intext, const char *outfile) realwidth = (qrcode->width + margin * 2) * size; row = (unsigned char *)malloc((realwidth + 7) / 8); - if(outfile != NULL) { + if(outfile[0] == '-' && outfile[1] == '\0') { + fp = stdout; + } else { fp = fopen(outfile, "w"); if(fp == NULL) { fprintf(stderr, "Failed to create file: %s\n", outfile); exit(1); } - } else { - fp = stdout; } png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); @@ -203,6 +207,8 @@ void qrencode(const char *intext, const char *outfile) png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); + free(row); + QRcode_free(qrcode); } int main(int argc, char **argv) @@ -281,6 +287,10 @@ int main(int argc, char **argv) if(intext == NULL) { intext = readStdin(); } + if(outfile == NULL) { + fprintf(stderr, "No output filename is given.\n"); + exit(1); + } qrencode(intext, outfile); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 57308f4120..761e21f9e0 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -172,7 +172,6 @@ void test_encodeTooLong(void) QRinput *stream; unsigned char *data; BitStream *bstream; - int flag = 0; data = (unsigned char *)malloc(7089); memset(data, 'a', 7089); -- cgit 0.0.5-2-1-g0f52 From c7c691a7d29fc7a1503e1dd7a24ff778a3ec9b62 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 2 Dec 2006 07:21:10 +0000 Subject: --- ChangeLog | 2 ++ NEWS | 6 ++++++ README | 7 ++++++- configure.ac | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e69de29bb2..b557f79fc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -0,0 +1,2 @@ +2006.12.02 Kentaro FUKUCHI + * Bumped version to 1.0.0. diff --git a/NEWS b/NEWS index e69de29bb2..057e5183fa 100644 --- a/NEWS +++ b/NEWS @@ -0,0 +1,6 @@ +libqrencode NEWS - Overview of changes +====================================== + +Version 1.0.0 (2006.12.03) +-------------------------- +* The first public release. diff --git a/README b/README index 85fdc52234..d8614be459 100644 --- a/README +++ b/README @@ -48,7 +48,7 @@ install it, give "--without-tools" option to the configure script. LICENSING INFORMATION ===================== -Copyright (C) 2006 Kentaro Fukuchi +Copyright (C) 2006 Kentaro Fukuchi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -63,6 +63,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +Lesser version +-------------- +If you need a Lesser GPLed code in order to embed this to your closed-source +software, please contact us. + ACKNOWLEDGMENTS =============== diff --git a/configure.ac b/configure.ac index 1c0561be08..f078005aea 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_INIT(QRencode) -MAJOR_VERSION=0 -MINOR_VERSION=9 +MAJOR_VERSION=1 +MINOR_VERSION=0 MICRO_VERSION=0 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 9a3b86c4788a342ae74881aa42dad9f14b2a8a41 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 2 Dec 2006 07:37:46 +0000 Subject: --- README | 6 ++++++ TODO | 7 +++++-- qrinput.c | 2 +- qrinput.h | 2 +- qrspec.c | 24 ++++++++++++------------ qrspec.h | 1 + rscode.c | 2 +- rscode.h | 2 +- 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/README b/README index d8614be459..066ea67327 100644 --- a/README +++ b/README @@ -45,6 +45,12 @@ Run "./configure --help" to see the list of options. It also installs a binary "qrencode" to /usr/local/bin. If you want not to install it, give "--without-tools" option to the configure script. +USAGE +===== +Basic usages of this library are written in the header file (qrencode.h). +You can generate a manual of the library by using Doxygen. + +WARNING: This library is thread UNSAFE. LICENSING INFORMATION ===================== diff --git a/TODO b/TODO index 61ba16fc65..6390e901ff 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,9 @@ +Thread unsafe. +Only two functions, QRspec_newFrame() and init_rs() are thread unsafe. + This package contains -*.c and *.h files (total): 4364 lines, 104543 bytes. -configure script : 22488 lines, 729111 bytes. +*.c and *.h files (total): 5379 lines, 129547 bytes. +configure script : 22866 lines, 740829 bytes. It's absolutely crazy. diff --git a/qrinput.c b/qrinput.c index 5555863215..27d788b100 100644 --- a/qrinput.c +++ b/qrinput.c @@ -223,7 +223,7 @@ static void QRinput_encodeModeNum(QRinput_List *entry, int version) * Alphabet-numeric data *****************************************************************************/ -signed char QRinput_anTable[] = { +const signed char QRinput_anTable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, diff --git a/qrinput.h b/qrinput.h index fd2c4e6f95..b130fd861e 100644 --- a/qrinput.h +++ b/qrinput.h @@ -92,7 +92,7 @@ extern int QRinput_estimateBitStreamSize(QRinput *input, int version); extern BitStream *QRinput_mergeBitStream(QRinput *input); extern BitStream *QRinput_getBitStream(QRinput *input); -extern signed char QRinput_anTable[]; +extern const signed char QRinput_anTable[]; extern QRencodeMode QRinput_identifyMode(const char *string); /** diff --git a/qrspec.c b/qrspec.c index 85b5198fc2..8c11803be2 100644 --- a/qrspec.c +++ b/qrspec.c @@ -46,7 +46,7 @@ typedef struct { * Table of the capacity of symbols * See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004. */ -QRspec_Capacity qrspecCapacity[QRSPEC_VERSION_MAX + 1] = { +static const QRspec_Capacity qrspecCapacity[QRSPEC_VERSION_MAX + 1] = { { 0, 0, 0, { 0, 0, 0, 0}}, { 21, 26, 0, { 7, 10, 13, 17}}, // 1 { 25, 44, 7, { 10, 16, 22, 28}}, @@ -127,7 +127,7 @@ int QRspec_getRemainder(int version) * Length indicator *****************************************************************************/ -static int lengthTableBits[4][3] = { +static const int lengthTableBits[4][3] = { {10, 12, 14}, { 9, 11, 13}, { 8, 16, 16}, @@ -180,7 +180,7 @@ int QRspec_maximumWords(QRencodeMode mode, int version) * Table of the error correction code (Reed-Solomon block) * See Table 12-16 (pp.30-36), JIS X0510:2004. */ -static int eccTable[QRSPEC_VERSION_MAX+1][4][2] = { +static const int eccTable[QRSPEC_VERSION_MAX+1][4][2] = { {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}}, {{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}}, // 1 {{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}}, @@ -266,7 +266,7 @@ int *QRspec_getEccSpec(int version, QRecLevel level) * * See Table 1 in Appendix E (pp.71) of JIS X0510:2004. */ -static int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = { +static const int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = { { 0, 0}, { 0, 0}, {18, 0}, {22, 0}, {26, 0}, {30, 0}, // 1- 5 {34, 0}, {22, 38}, {24, 42}, {26, 46}, {28, 50}, // 6-10 @@ -362,7 +362,7 @@ void QRspec_freeAlignment(QRspec_Alignment *al) * Version information pattern (BCH coded). * See Table 1 in Appendix D (pp.68) of JIS X0510:2004. */ -static unsigned int versionPattern[QRSPEC_VERSION_MAX - 6] = { +static const unsigned int versionPattern[QRSPEC_VERSION_MAX - 6] = { 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, 0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, @@ -382,7 +382,7 @@ unsigned int QRspec_getVersionPattern(int version) *****************************************************************************/ /* See calcFormatInfo in tests/test_qrspec.c */ -static unsigned int formatInfo[4][8] = { +static const unsigned int formatInfo[4][8] = { {0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976}, {0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0}, {0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed}, @@ -403,8 +403,8 @@ unsigned int QRspec_getFormatInfo(int mask, QRecLevel level) /** * Cache of initial frames. */ -/* C99 says that static storage shall be initalized to a null pointer - * by comipler. */ +/* C99 says that static storage shall be initialized to a null pointer + * by compiler. */ static unsigned char *frames[QRSPEC_VERSION_MAX + 1]; /** @@ -415,7 +415,7 @@ static unsigned char *frames[QRSPEC_VERSION_MAX + 1]; */ static void putFinderPattern(unsigned char *frame, int width, int ox, int oy) { - static unsigned char finder[] = { + static const unsigned char finder[] = { 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, @@ -425,7 +425,7 @@ static void putFinderPattern(unsigned char *frame, int width, int ox, int oy) 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, }; int x, y; - unsigned char *s; + const unsigned char *s; frame += oy * width + ox; s = finder; @@ -446,7 +446,7 @@ static void putFinderPattern(unsigned char *frame, int width, int ox, int oy) */ static void putAlignmentPattern(unsigned char *frame, int width, int ox, int oy) { - static unsigned char finder[] = { + static const unsigned char finder[] = { 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa0, 0xa0, 0xa0, 0xa1, 0xa1, 0xa0, 0xa1, 0xa0, 0xa1, @@ -454,7 +454,7 @@ static void putAlignmentPattern(unsigned char *frame, int width, int ox, int oy) 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, }; int x, y; - unsigned char *s; + const unsigned char *s; frame += (oy - 2) * width + ox - 2; s = finder; diff --git a/qrspec.h b/qrspec.h index 9f9471fdce..9902869218 100644 --- a/qrspec.h +++ b/qrspec.h @@ -181,6 +181,7 @@ extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); * @param version * @return Array of unsigned char. You can free it by free(). */ +/* WARNING: Thread unsafe!!! */ extern unsigned char *QRspec_newFrame(int version); #endif /* __QRSPEC_H__ */ diff --git a/rscode.c b/rscode.c index e85ef8a2a7..3f9de4a429 100644 --- a/rscode.c +++ b/rscode.c @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Reed solomon encoder. This file is taken from Phil Karn's libfec and + * Reed solomon encoder. This code is taken from Phil Karn's libfec then * editted and packed into a pair of .c and .h files. * * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q diff --git a/rscode.h b/rscode.h index 948c1f6d6d..5858ff0d15 100644 --- a/rscode.h +++ b/rscode.h @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Reed solomon encoder. This file is taken from Phil Karn's libfec and + * Reed solomon encoder. This code is taken from Phil Karn's libfec then * editted and packed into a pair of .c and .h files. * * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q -- cgit 0.0.5-2-1-g0f52 From 62e71fcdbd313bb810a2428809eb488b88cb1b28 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 2 Dec 2006 10:46:07 +0000 Subject: --- Doxyfile | 10 +++++----- qrencode.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/Doxyfile b/Doxyfile index ba77f76f0d..f4aa9431be 100644 --- a/Doxyfile +++ b/Doxyfile @@ -259,21 +259,21 @@ EXTRACT_LOCAL_METHODS = NO # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_CLASSES = NO +HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. -HIDE_FRIEND_COMPOUNDS = NO +HIDE_FRIEND_COMPOUNDS = YES # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. @@ -459,7 +459,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = +INPUT = qrencode.h # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp @@ -468,7 +468,7 @@ INPUT = # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py -FILE_PATTERNS = +FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. diff --git a/qrencode.h b/qrencode.h index 380b2d988e..8cb0098912 100644 --- a/qrencode.h +++ b/qrencode.h @@ -18,6 +18,48 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +/** \mainpage + * Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D + * symbology. + * + *

Encoding

+ * + * There are two ways to encode data: encoding a string or + * encoding a structured data. + * + *

Encoding a string

+ * You can encode a string by calling QRcode_encodeString(). + * The given string is parsed automatically and encoded. If you want to encode + * data that can be represented as a C string style (NUL terminated), you can + * simply use this way. + * + * If the input data contains Kanji (Shift-JIS) characters and you want to + * encode them as Kanji in QR Code, you should give QR_MODE_KANJI as a hint. + * Otherwise, all of non-alphanumeric characters are encoded as 8 bit data. + * + * Please note that a C string can not contain NUL character. If your data + * contains NUL, you should chose the second way. + * + *

Encoding a structured data

+ * You can construct a structured input data manually. If the structure of the + * input data is known, you can use this way. + * At first, you must create a ::QRinput object by QRinput_new(). Then, you can + * add input data to the QRinput object by QRinput_append(). + * Finally you can call QRcode_encodeInput() to encode the QRinput data. + * You can reuse the QRinput data again to encode it in other symbols with + * different parameters. + * + *

Result

+ * The encoded symbol is resulted as a ::QRcode object. It will contain + * its version number, width of the symbol and an array represents the symbol. + * See ::QRcode for the details. You can free the object by QRcode_free(). + * + * Please note that the version of the result may be larger than specified. + * In such cases, the input data would be too large to be encoded in the + * symbol of the specified version. + * + */ + #ifndef __QRENCODE_H__ #define __QRENCODE_H__ @@ -92,7 +134,7 @@ extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) * Symbol data is represented as an array contains width*width uchars. * Each uchar represents a module (dot). If the less significant bit of * the uchar is 1, the corresponding module is black. The other bits are - * meaningless for usual application, but here the specification is described. + * meaningless for usual applications, but here the specification is described. * *
  * MSB 76543210 LSB
@@ -131,9 +173,10 @@ extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level);
  *                version for the input data.
  * @param level error correction level.
  * @param hint tell the library how non-alphanumerical characters should be
- *             encoded. If QR_MODE_KANJI is given, those characters will be
- *             encoded as Shif-JIS characters. If QR_MODE_8 is given, they wil
- *             be encoded as is. If you want to embed UTF-8 string, choose this.
+ *             encoded. If QR_MODE_KANJI is given, kanji characters will be
+ *             encoded as Shif-JIS characters. If QR_MODE_8 is given, all of
+ *             non-alphanumerical characters will be encoded as is. If you want
+ *             to embed UTF-8 string, choose this.
  * @return an instance of QRcode class. The version of the result QRcode may
  *         be larger than the designated version.
  */
-- 
cgit 0.0.5-2-1-g0f52


From 483c48c2afe6c5cce928f47148c0be2865227874 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 4 Dec 2006 13:01:30 +0000
Subject:

---
 TODO | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/TODO b/TODO
index 6390e901ff..6b918633d2 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,9 @@
 Thread unsafe.
-Only two functions, QRspec_newFrame() and init_rs() are thread unsafe.
+Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe.
 
 This package contains
 
-*.c and *.h files (total):  5379 lines, 129547 bytes.
+*.c and *.h files (total):  5422 lines, 131476 bytes.
 configure script         : 22866 lines, 740829 bytes.
 
 It's absolutely crazy.
-- 
cgit 0.0.5-2-1-g0f52


From 8399501ebf09e08ea6e8dc037494399159ccc413 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 4 Dec 2006 16:47:42 +0000
Subject:

---
 qrenc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/qrenc.c b/qrenc.c
index 1f8f4a2a7b..8dfa9946f4 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -133,6 +133,7 @@ void qrencode(const char *intext, const char *outfile)
 		fp = fopen(outfile, "w");
 		if(fp == NULL) {
 			fprintf(stderr, "Failed to create file: %s\n", outfile);
+			perror(NULL);
 			exit(1);
 		}
 	}
@@ -281,16 +282,17 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if(outfile == NULL) {
+		fprintf(stderr, "No output filename is given.\n");
+		exit(1);
+	}
+
 	if(optind < argc) {
 		intext = argv[optind];
 	}
 	if(intext == NULL) {
 		intext = readStdin();
 	}
-	if(outfile == NULL) {
-		fprintf(stderr, "No output filename is given.\n");
-		exit(1);
-	}
 
 	qrencode(intext, outfile);
 
-- 
cgit 0.0.5-2-1-g0f52


From 5c34170c5f03362bc81b7b9d17e5d5b4c0b77475 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 4 Dec 2006 17:12:18 +0000
Subject:

---
 COPYING          | 679 ++++++++++++++++++++++++++++++++++---------------------
 README           |  26 +--
 bitstream.c      |  20 +-
 bitstream.h      |  20 +-
 qrenc.c          |  20 +-
 qrencode.c       |  22 +-
 qrencode.h       |  20 +-
 qrencode_inner.h |  20 +-
 qrinput.c        |  20 +-
 qrinput.h        |  20 +-
 qrspec.c         |  20 +-
 qrspec.h         |  20 +-
 rscode.c         |  20 +-
 rscode.h         |  20 +-
 14 files changed, 557 insertions(+), 390 deletions(-)

diff --git a/COPYING b/COPYING
index d511905c16..2d2d780e60 100644
--- a/COPYING
+++ b/COPYING
@@ -1,221 +1,400 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
 
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+	51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
-			    Preamble
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
 
   The licenses for most software are designed to take away your
 freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
 
   To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard.  To achieve this, non-free programs must
+be allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
 
   The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+  Activities other than copying, distribution and modification are not
 covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
 distribute such modifications or work under the terms of Section 1
 above, provided that you also meet all of these conditions:
 
-    a) You must cause the modified files to carry prominent notices
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
     stating that you changed the files and the date of any change.
 
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
 
 These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
+identifiable sections of that work are not derived from the Library,
 and can be reasonably considered independent and separate works in
 themselves, then this License, and its terms, do not apply to those
 sections when you distribute them as separate works.  But when you
 distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
+on the Library, the distribution of the whole must be on the terms of
 this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
+entire whole, and thus to each and every part regardless of who wrote
+it.
 
 Thus, it is not the intent of this section to claim rights or contest
 your rights to work written entirely by you; rather, the intent is to
 exercise the right to control the distribution of derivative or
-collective works based on the Program.
+collective works based on the Library.
 
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
 a storage or distribution medium does not bring the other work under
 the scope of this License.
 
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
 compelled to copy the source along with the object code.
 
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at least
+    three years, to give the same user the materials specified in
+    Subsection 6a, above, for a charge no more than the cost of
+    performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
 signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
+distribute the Library or its derivative works.  These actions are
 prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
 all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
+the Library or works based on it.
 
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
 restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
+You are not responsible for enforcing compliance by third parties with
 this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
+
+  11. If, as a consequence of a court judgment or allegation of patent
 infringement or for any other reason (not limited to patent issues),
 conditions are imposed on you (whether by court order, agreement or
 otherwise) that contradict the conditions of this License, they do not
 excuse you from the conditions of this License.  If you cannot
 distribute so as to satisfy simultaneously your obligations under this
 License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
 all those who receive copies directly or indirectly through you, then
 the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
+refrain entirely from distribution of the Library.
 
 If any portion of this section is held invalid or unenforceable under
 any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
+apply, and the section as a whole is intended to apply in other
 circumstances.
 
 It is not the purpose of this section to induce you to infringe any
 patents or other property right claims or to contest validity of any
 such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
+integrity of the free software distribution system which is
 implemented by public license practices.  Many people have made
 generous contributions to the wide range of software distributed
 through that system in reliance on consistent application of that
@@ -226,114 +405,106 @@ impose that choice.
 This section is intended to make thoroughly clear what is believed to
 be a consequence of the rest of this License.
 
-  8. If the distribution and/or use of the Program is restricted in
+  12. If the distribution and/or use of the Library is restricted in
 certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
 countries not thus excluded.  In such case, this License incorporates
 the limitation as if written in the body of this License.
 
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+    
     Copyright (C)   
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    This library is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
 
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 Also add information on how to contact you by electronic and paper mail.
 
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary.  Here is a sample; alter the names:
 
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James
+  Random Hacker.
 
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
+  , 1 April 1990
+  Ty Coon, President of Vice
 
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+That's all there is to it!
 
-  , 1 April 1989
-  Ty Coon, President of Vice
 
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
diff --git a/README b/README
index 066ea67327..7004ec2305 100644
--- a/README
+++ b/README
@@ -45,6 +45,7 @@ Run "./configure --help" to see the list of options.
 It also installs a binary "qrencode" to /usr/local/bin. If you want not to
 install it, give "--without-tools" option to the configure script.
 
+
 USAGE
 =====
 Basic usages of this library are written in the header file (qrencode.h).
@@ -52,27 +53,22 @@ You can generate a manual of the library by using Doxygen.
 
 WARNING: This library is thread UNSAFE.
 
+
 LICENSING INFORMATION
 =====================
 Copyright (C) 2006 Kentaro Fukuchi 
 
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2 of the License, or any later version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License in COPYING file
-in this package for more details.
+This library is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2.1 of the License, or any later version.
 
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+This library is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 
-Lesser version
---------------
-If you need a Lesser GPLed code in order to embed this to your closed-source
-software, please contact us.
+You should have received a copy of the GNU Lesser General Public License along
+with this library; if not, write to the Free Software Foundation, Inc., 51
+Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 
 ACKNOWLEDGMENTS
diff --git a/bitstream.c b/bitstream.c
index 7e1d41a396..8f3b4d16a6 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -4,19 +4,19 @@
  * Binary sequence class.
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include 
diff --git a/bitstream.h b/bitstream.h
index 25041d2d81..6228422fb9 100644
--- a/bitstream.h
+++ b/bitstream.h
@@ -4,19 +4,19 @@
  * Binary sequence class.
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef __BITSTREAM_H__
diff --git a/qrenc.c b/qrenc.c
index 8dfa9946f4..cbba889bee 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -4,19 +4,19 @@
  * QR Code encoding tool
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include 
diff --git a/qrencode.c b/qrencode.c
index 74a7b3984a..d6c6ad1b21 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -1,21 +1,21 @@
-/**
+/*
  * qrencode - QR Code encoder
  *
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include 
diff --git a/qrencode.h b/qrencode.h
index 8cb0098912..e1d0db3cf6 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -3,19 +3,19 @@
  *
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /** \mainpage
diff --git a/qrencode_inner.h b/qrencode_inner.h
index b31bf3c87e..28eb833416 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -4,19 +4,19 @@
  * Header for internal use
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef __QRENCODE_INNER_H__
diff --git a/qrinput.c b/qrinput.c
index 27d788b100..02264bc40f 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -4,19 +4,19 @@
  * Input data chunk class
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include 
diff --git a/qrinput.h b/qrinput.h
index b130fd861e..00666a0bef 100644
--- a/qrinput.h
+++ b/qrinput.h
@@ -4,19 +4,19 @@
  * Input data chunk class
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef __QRINPUT_H__
diff --git a/qrspec.c b/qrspec.c
index 8c11803be2..fa5af8488b 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -10,19 +10,19 @@
  * "Automatic identification and data capture techniques -- 
  *  QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include 
diff --git a/qrspec.h b/qrspec.h
index 9902869218..8e407aaaa6 100644
--- a/qrspec.h
+++ b/qrspec.h
@@ -4,19 +4,19 @@
  * QR Code specification in convenient format. 
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef __QRSPEC_H__
diff --git a/rscode.c b/rscode.c
index 3f9de4a429..31717b607e 100644
--- a/rscode.c
+++ b/rscode.c
@@ -9,19 +9,19 @@
  *
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include 
diff --git a/rscode.h b/rscode.h
index 5858ff0d15..38dcae21c9 100644
--- a/rscode.h
+++ b/rscode.h
@@ -9,19 +9,19 @@
  *
  * Copyright (C) 2006 Kentaro Fukuchi
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef __RSCODE_H__
-- 
cgit 0.0.5-2-1-g0f52


From acff5a5c7ac1262385288860967ec24b4fb202ea Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 4 Dec 2006 17:50:22 +0000
Subject:

---
 bitstream.c      | 2 +-
 bitstream.h      | 2 +-
 qrenc.c          | 2 +-
 qrencode.c       | 2 +-
 qrencode.h       | 2 +-
 qrencode_inner.h | 2 +-
 qrinput.c        | 2 +-
 qrinput.h        | 2 +-
 qrspec.c         | 2 +-
 qrspec.h         | 2 +-
 rscode.c         | 2 +-
 rscode.h         | 2 +-
 12 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/bitstream.c b/bitstream.c
index 8f3b4d16a6..c44195977d 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Binary sequence class.
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/bitstream.h b/bitstream.h
index 6228422fb9..ed75551cd3 100644
--- a/bitstream.h
+++ b/bitstream.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Binary sequence class.
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrenc.c b/qrenc.c
index cbba889bee..2775b879b8 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code encoding tool
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrencode.c b/qrencode.c
index d6c6ad1b21..23500d4016 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -1,7 +1,7 @@
 /*
  * qrencode - QR Code encoder
  *
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrencode.h b/qrencode.h
index e1d0db3cf6..8d23798095 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -1,7 +1,7 @@
 /**
  * qrencode - QR Code encoder
  *
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrencode_inner.h b/qrencode_inner.h
index 28eb833416..6fb0f80b7c 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Header for internal use
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrinput.c b/qrinput.c
index 02264bc40f..d7fc3d6d6f 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data chunk class
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrinput.h b/qrinput.h
index 00666a0bef..4360aad20d 100644
--- a/qrinput.h
+++ b/qrinput.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data chunk class
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrspec.c b/qrspec.c
index fa5af8488b..1f8afbbd75 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code specification in convenient format. 
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/qrspec.h b/qrspec.h
index 8e407aaaa6..71f681a9bd 100644
--- a/qrspec.h
+++ b/qrspec.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code specification in convenient format. 
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/rscode.c b/rscode.c
index 31717b607e..15cd1c9d64 100644
--- a/rscode.c
+++ b/rscode.c
@@ -7,7 +7,7 @@
  * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
  * (libfec is released under the GNU Lesser General Public License.)
  *
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/rscode.h b/rscode.h
index 38dcae21c9..e99dbfb2b4 100644
--- a/rscode.h
+++ b/rscode.h
@@ -7,7 +7,7 @@
  * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
  * (libfec is released under the GNU Lesser General Public License.)
  *
- * Copyright (C) 2006 Kentaro Fukuchi
+ * Copyright (C) 2006 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
-- 
cgit 0.0.5-2-1-g0f52


From b958d0f53ff4d2a967274f0d0d68cf02cbb152d2 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 6 Dec 2006 00:19:17 +0000
Subject:

---
 README | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/README b/README
index 7004ec2305..8ef0da0304 100644
--- a/README
+++ b/README
@@ -56,7 +56,7 @@ WARNING: This library is thread UNSAFE.
 
 LICENSING INFORMATION
 =====================
-Copyright (C) 2006 Kentaro Fukuchi 
+Copyright (C) 2006 Kentaro Fukuchi
 
 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
@@ -71,6 +71,19 @@ with this library; if not, write to the Free Software Foundation, Inc., 51
 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 
+CONTACTS
+========
+Visit the homepage at:
+
+http://megaui.net/fukuchi/works/qrencode/index.en.html
+
+for new releases.
+
+Please mail any bug reports, suggestions, comments and questions to
+Kentaro Fukuchi . Questions of license compliance
+are also welcome.
+
+
 ACKNOWLEDGMENTS
 ===============
 QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other
-- 
cgit 0.0.5-2-1-g0f52


From 03c6b6a7e2bed5b280dc5a694dca148d97b7b3d2 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Tue, 12 Dec 2006 04:44:17 +0000
Subject:

---
 rscode.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/rscode.c b/rscode.c
index 15cd1c9d64..6a81e4de1e 100644
--- a/rscode.c
+++ b/rscode.c
@@ -86,7 +86,7 @@ static inline int modnn(RS *rs, int x){
  * nroots = RS code generator polynomial degree (number of roots)
  * pad = padding bytes at front of shortened block
  */
-RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad)
+static RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad)
 {
   RS *rs;
 
@@ -170,6 +170,7 @@ RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad
   rs->fcr = fcr;
   rs->prim = prim;
   rs->nroots = nroots;
+  rs->gfpoly = gfpoly;
 
   /* Find prim-th root of 1, used in decoding */
   for(iprim=1;(iprim % prim) != 0;iprim += rs->nn)
@@ -214,12 +215,8 @@ RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad)
 	}
 
 	rs = init_rs_char(symsize, gfpoly, fcr, prim, nroots, pad);
-	if(rslist == NULL) {
-		rslist = rs;
-	} else {
-		rs->next = rslist;
-		rslist = rs;
-	}
+	rs->next = rslist;
+	rslist = rs;
 
 	return rs;
 }
-- 
cgit 0.0.5-2-1-g0f52


From f17331149a17bfa4e1b73fcea9bdd32c7051557d Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Tue, 12 Dec 2006 08:04:20 +0000
Subject:

---
 NEWS              | 2 +-
 qrenc.c           | 5 +++++
 qrencode.c        | 7 +++----
 tests/Makefile.am | 6 +++++-
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index 057e5183fa..aa1a6e8720 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
-Version 1.0.0 (2006.12.03)
+Version 1.0.0 (2006.12.12)
 --------------------------
 * The first public release.
diff --git a/qrenc.c b/qrenc.c
index 2775b879b8..eb12227ae5 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -282,6 +282,11 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if(argc == 1) {
+		usage();
+		exit(0);
+	}
+
 	if(outfile == NULL) {
 		fprintf(stderr, "No output filename is given.\n");
 		exit(1);
diff --git a/qrencode.c b/qrencode.c
index 23500d4016..58e00a4910 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -436,11 +436,10 @@ int QRinput_evaluateSymbol(int width, unsigned char *frame)
 		runLength[0] = 1;
 		for(x=0; x 0 && y > 0) {
-				b22 = p[0] & p[-1] & p[-width] & p [-width-1] & 1;
-				w22 = (p[0] | p[-1] | p[-width] | p [-width-1] ) & 1;
-				if(b22 | (w22 ^ 1)) {
+				b22 = p[0] & p[-1] & p[-width] & p [-width-1];
+				w22 = p[0] | p[-1] | p[-width] | p [-width-1];
+				if((b22 | (w22 ^ 1))&1) {
 					demerit += N2;
-					//n2 += N2;
 				}
 			}
 			if(x == 0 && (p[0] & 1)) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a4c97cd95d..177c4ce82b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,7 +3,8 @@ sdlPROGRAMS = view_qrcode
 endif
 
 noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \
-				  test_qrspec test_rs test_qrencode $(sdlPROGRAMS)
+				  test_qrspec test_rs test_qrencode prof_qrencode \
+				  $(sdlPROGRAMS)
 
 test_qrinput_SOURCES = test_qrinput.c common.h
 test_qrinput_LDADD = ../libqrencode.la
@@ -23,6 +24,9 @@ test_rs_LDADD = ../libqrencode.la
 test_qrencode_SOURCES = test_qrencode.c common.h
 test_qrencode_LDADD = ../libqrencode.la
 
+prof_qrencode_SOURCES = prof_qrencode.c
+prof_qrencode_LDADD = ../libqrencode.la
+
 if HAVE_SDL
 view_qrcode_SOURCES = view_qrcode.c common.h
 view_qrcode_CFLAGS= $(SDL_CFLAGS)
-- 
cgit 0.0.5-2-1-g0f52


From 49665a1e6b523e035c79e04cf4b90d5a3ad1063d Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 Dec 2006 12:28:41 +0000
Subject:

---
 acinclude.m4 | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 acinclude.m4

diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 0000000000..1432c34cea
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,44 @@
+dnl Test for libpng
+AC_DEFUN([AM_PATH_LIBPNG],
+[
+  if test x$with_libpng != xno && test -z "$LIBPNG"; then
+    AC_MSG_CHECKING(for libpng12)
+    if pkg-config --exists libpng12 ; then
+        AC_MSG_RESULT(yes)
+        PNG='png'
+        PNG_DEP_CFLAGS_PACKAGES=libpng12
+        LIBPNG=`pkg-config --libs libpng12`
+    else
+      AC_MSG_RESULT(no)
+      AC_CHECK_LIB(png, png_read_info,
+        [AC_CHECK_HEADER(png.h,
+          png_ok=yes,
+          png_ok=no)],
+        AC_MSG_WARN(*** PNG library not found), -lz -lm)
+      if test "$png_ok" = yes; then
+        AC_MSG_CHECKING([for png_structp in png.h])
+        AC_TRY_COMPILE([#include ],
+          [png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;],
+          png_ok=yes,
+          png_ok=no)
+        AC_MSG_RESULT($png_ok)
+        if test "$png_ok" = yes; then
+          PNG='png'; LIBPNG='-lpng -lz'
+        else
+          AC_MSG_WARN(*** PNG library is too old)
+        fi
+      else
+       AC_MSG_WARN(*** PNG header file not found)
+      fi
+    fi
+  fi
+
+  if test x$with_libpng != xno && test -z "$LIBPNG"; then
+     AC_MSG_ERROR([
+*** Checks for PNG library failed. You can build the library without it by
+*** passing --without-tools to configure but utility tools are not to be
+*** built.])
+  fi
+
+  AC_SUBST(LIBPNG)
+])
-- 
cgit 0.0.5-2-1-g0f52


From 1027eb72cdebb90a69127e5553e1ec95003a5de7 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 Dec 2006 12:29:23 +0000
Subject:

---
 tests/prof_qrencode.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 tests/prof_qrencode.c

diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c
new file mode 100644
index 0000000000..93ea2869ce
--- /dev/null
+++ b/tests/prof_qrencode.c
@@ -0,0 +1,45 @@
+#include 
+#include 
+#include 
+#include 
+#include "../qrencode.h"
+
+struct timeval tv;
+void timerStart(const char *str)
+{
+	printf("%s: START\n", str);
+	gettimeofday(&tv, NULL);
+}
+
+void timerStop(void)
+{
+	struct timeval tc;
+
+	gettimeofday(&tc, NULL);
+	printf("STOP: %ld msec\n", (tc.tv_sec - tv.tv_sec) * 1000
+			+ (tc.tv_usec - tv.tv_usec) / 1000);
+}
+
+void prof_ver1to10(void)
+{
+	QRcode *code;
+	int i;
+	int version;
+	static char *data = "This is test.";
+
+	timerStart("Version 1 - 10");
+	for(i=0; i<500; i++) {
+		for(version = 0; version < 11; version++) {
+			code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8);
+			QRcode_free(code);
+		}
+	}
+	timerStop();
+}
+
+int main()
+{
+	prof_ver1to10();
+
+	return 0;
+}
-- 
cgit 0.0.5-2-1-g0f52


From 426086f1714629b6909d342388e9ff7581c051ce Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sat, 16 Dec 2006 07:14:46 +0000
Subject:

---
 Makefile.am          |   3 +-
 mqrspec.c            | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++
 mqrspec.h            | 161 ++++++++++++++++++++++++++++++++
 tests/Makefile.am    |   4 +
 tests/test_mqrspec.c | 128 ++++++++++++++++++++++++++
 5 files changed, 550 insertions(+), 1 deletion(-)
 create mode 100644 mqrspec.c
 create mode 100644 mqrspec.h
 create mode 100644 tests/test_mqrspec.c

diff --git a/Makefile.am b/Makefile.am
index 879cf3ce01..2b8464c9b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,7 +8,8 @@ libqrencode_la_SOURCES = qrencode.c qrencode_inner.h \
 						 qrinput.c qrinput.h \
 						 bitstream.c bitstream.h \
 						 qrspec.c qrspec.h \
-						 rscode.c rscode.h
+						 rscode.c rscode.h \
+						 mqrspec.c mqrspec.h
 libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION)
 
 include_HEADERS = qrencode.h
diff --git a/mqrspec.c b/mqrspec.c
new file mode 100644
index 0000000000..0696571357
--- /dev/null
+++ b/mqrspec.c
@@ -0,0 +1,255 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Micor QR Code specification in convenient format. 
+ * Copyright (C) 2006 Kentaro Fukuchi 
+ *
+ * The following data / specifications are taken from
+ * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
+ *  or
+ * "Automatic identification and data capture techniques -- 
+ *  QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include "mqrspec.h"
+
+/******************************************************************************
+ * Version and capacity
+ *****************************************************************************/
+
+typedef struct {
+	int width; //< Edge length of the symbol
+	int ec[3];  //< Number of ECC code (bytes)
+} MQRspec_Capacity;
+
+/**
+ * Table of the capacity of symbols
+ * See Table 1 (pp.10) and Table 8 (pp.113) of Appendix 1, JIS X0510:2004.
+ */
+static const MQRspec_Capacity mqrspecCapacity[MQRSPEC_VERSION_MAX + 1] = {
+	{  0, {0,  0,  0}},
+	{ 11, {2,  0,  0}},
+	{ 13, {5,  6,  0}},
+	{ 15, {6,  8,  0}},
+	{ 17, {8, 10, 14}}
+};
+
+int MQRspec_getDataLength(int version, QRecLevel level)
+{
+	int w;
+
+	w = mqrspecCapacity[version].width - 1;
+	return w * w - 64 - mqrspecCapacity[version].ec[level] * 8;
+}
+
+int MQRspec_getECCLength(int version, QRecLevel level)
+{
+	return mqrspecCapacity[version].ec[level];
+}
+
+int MQRspec_getWidth(int version)
+{
+	return mqrspecCapacity[version].width;
+}
+
+/******************************************************************************
+ * Length indicator
+ *****************************************************************************/
+
+/**
+ * See Table 3 (pp.107) of Appendix 1, JIS X0510:2004.
+ */
+static const int lengthTableBits[4][4] = {
+	{ 3, 4, 5, 6},
+	{ 0, 3, 4, 5},
+	{ 0, 0, 4, 5},
+	{ 0, 0, 3, 4}
+};
+
+int MQRspec_lengthIndicator(QRencodeMode mode, int version)
+{
+	return lengthTableBits[mode][version - 1];
+}
+
+int MQRspec_maximumWords(QRencodeMode mode, int version)
+{
+	int bits;
+	int words;
+
+	bits = lengthTableBits[mode][version - 1];
+	words = (1 << bits) - 1;
+	if(mode == QR_MODE_KANJI) {
+		words *= 2; // the number of bytes is required
+	}
+
+	return words;
+}
+
+/******************************************************************************
+ * Error correction code
+ *****************************************************************************/
+
+/**
+ * Table of the error correction code (Reed-Solomon block)
+ * See Table 8 (pp.113) of Appendix 1, JIS X0510:2004.
+ */
+static const int eccTable[MQRSPEC_VERSION_MAX+1][3] = {
+	{2,  0,  0},
+	{5,  6,  0},
+	{6,  8,  0},
+	{8, 10, 14}
+};
+
+int *MQRspec_getEccSpec(int version, QRecLevel level)
+{
+	return NULL;
+}
+
+/******************************************************************************
+ * Format information
+ *****************************************************************************/
+
+/* See calcFormatInfo in tests/test_mqrspec.c */
+static const unsigned int const formatInfo[4][8] = {
+	{0x4445, 0x55ae, 0x6793, 0x7678, 0x06de, 0x1735, 0x2508, 0x34e3},
+	{0x4172, 0x5099, 0x62a4, 0x734f, 0x03e9, 0x1202, 0x203f, 0x31d4},
+	{0x4e2b, 0x5fc0, 0x6dfd, 0x7c16, 0x0cb0, 0x1d5b, 0x2f66, 0x3e8d},
+	{0x4b1c, 0x5af7, 0x68ca, 0x7921, 0x0987, 0x186c, 0x2a51, 0x3bba}
+};
+
+/* See Table 10 of Appendix 1. (pp.115) */
+static const int const typeTable[MQRSPEC_VERSION_MAX + 1][3] = {
+	{-1, -1, -1},
+	{ 0, -1, -1},
+	{ 1,  2, -1},
+	{ 3,  4, -1},
+	{ 5,  6,  7}
+};
+
+unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level)
+{
+	int type;
+
+	if(mask < 0 || mask > 3) return 0;
+	if(version <= 0 || version > MQRSPEC_VERSION_MAX) return 0;
+	if(level == QR_ECLEVEL_H) return 0;
+	type = typeTable[version][level];
+	if(type < 0) return 0;
+
+	return formatInfo[mask][type];
+}
+
+/******************************************************************************
+ * Frame
+ *****************************************************************************/
+
+/**
+ * Cache of initial frames.
+ */
+/* C99 says that static storage shall be initialized to a null pointer
+ * by compiler. */
+static unsigned char *frames[MQRSPEC_VERSION_MAX + 1];
+
+/**
+ * Put a finder pattern.
+ * @param frame
+ * @param width
+ * @param ox,oy upper-left coordinate of the pattern
+ */
+static void putFinderPattern(unsigned char *frame, int width, int ox, int oy)
+{
+	static const unsigned char finder[] = {
+		0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
+		0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
+		0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
+		0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
+		0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
+		0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
+		0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
+	};
+	int x, y;
+	const unsigned char *s;
+
+	frame += oy * width + ox;
+	s = finder;
+	for(y=0; y<7; y++) {
+		for(x=0; x<7; x++) {
+			frame[x] = s[x];
+		}
+		frame += width;
+		s += 7;
+	}
+}
+
+static unsigned char *MQRspec_createFrame(int version)
+{
+	unsigned char *frame, *p, *q;
+	int width;
+	int x, y;
+
+	width = mqrspecCapacity[version].width;
+	frame = (unsigned char *)malloc(width * width);
+	memset(frame, 0, width * width);
+	/* Finder pattern */
+	putFinderPattern(frame, width, 0, 0);
+	/* Separator */
+	p = frame;
+	for(y=0; y<7; y++) {
+		p[7] = 0xc0;
+		p += width;
+	}
+	memset(frame + width * 7, 0xc0, 8);
+	/* Mask format information area */
+	memset(frame + width * 8 + 1, 0x84, 8);
+	p = frame + width + 8;
+	for(y=0; y<7; y++) {
+		*p = 0x84;
+		p += width;
+	}
+	/* Timing pattern */
+	p = frame + 8;
+	q = frame + width * 8;
+	for(x=1; x MQRSPEC_VERSION_MAX) return NULL;
+
+	if(frames[version] == NULL) {
+		frames[version] = MQRspec_createFrame(version);
+	}
+	width = mqrspecCapacity[version].width;
+	frame = (unsigned char *)malloc(width * width);
+	memcpy(frame, frames[version], width * width);
+
+	return frame;
+}
diff --git a/mqrspec.h b/mqrspec.h
new file mode 100644
index 0000000000..b21adb460f
--- /dev/null
+++ b/mqrspec.h
@@ -0,0 +1,161 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Micro QR Code specification in convenient format. 
+ * Copyright (C) 2006 Kentaro Fukuchi 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __MQRSPEC_H__
+#define __MQRSPEC_H__
+
+#include "qrencode.h"
+
+/******************************************************************************
+ * Version and capacity
+ *****************************************************************************/
+
+/**
+ * Maximum version (size) of QR-code symbol.
+ */
+#define MQRSPEC_VERSION_MAX 4
+
+/**
+ * Maximum width of a symbol
+ */
+#define MQRSPEC_WIDTH_MAX 17
+
+/**
+ * Return maximum data code length (bytes) for the version.
+ * @param version
+ * @param level
+ * @return maximum size (bytes)
+ */
+extern int MQRspec_getDataLength(int version, QRecLevel level);
+
+/**
+ * Return maximum error correction code length (bytes) for the version.
+ * @param version
+ * @param level
+ * @return ECC size (bytes)
+ */
+extern int MQRspec_getECCLength(int version, QRecLevel level);
+
+/**
+ * Return a version number that satisfies the input code length.
+ * @param size input code length (byte)
+ * @param level
+ * @return version number
+ */
+extern int MQRspec_getMinimumVersion(int size, QRecLevel level);
+
+/**
+ * Return the width of the symbol for the version.
+ * @param version
+ * @return width
+ */
+extern int MQRspec_getWidth(int version);
+
+/**
+ * Return the numer of remainder bits.
+ * @param version
+ * @return number of remainder bits
+ */
+extern int MQRspec_getRemainder(int version);
+
+/******************************************************************************
+ * Length indicator
+ *****************************************************************************/
+
+/**
+ * Return the size of lenght indicator for the mode and version.
+ * @param mode
+ * @param version
+ * @return the size of the appropriate length indicator (bits).
+ */
+extern int QRspec_lengthIndicator(QRencodeMode mode, int version);
+
+/**
+ * Return the maximum length for the mode and version.
+ * @param mode
+ * @param version
+ * @return the maximum length (bytes)
+ */
+extern int QRspec_maximumWords(QRencodeMode mode, int version);
+
+/******************************************************************************
+ * Error correction code
+ *****************************************************************************/
+
+/**
+ * Return an array of ECC specification.
+ * @param version
+ * @param level
+ * @return an array of ECC specification contains as following:
+ * {# of type1 blocks, # of data code, # of ecc code,
+ *  # of type2 blocks, # of data code, # of ecc code}
+ * It can be freed by calling free().
+ */
+int *QRspec_getEccSpec(int version, QRecLevel level);
+
+#define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3])
+#define QRspec_rsBlockNum1(__spec__) (__spec__[0])
+#define QRspec_rsDataCodes1(__spec__) (__spec__[1])
+#define QRspec_rsEccCodes1(__spec__) (__spec__[2])
+#define QRspec_rsBlockNum2(__spec__) (__spec__[3])
+#define QRspec_rsDataCodes2(__spec__) (__spec__[4])
+#define QRspec_rsEccCodes2(__spec__) (__spec__[5])
+
+/******************************************************************************
+ * Version information pattern
+ *****************************************************************************/
+
+/**
+ * Return BCH encoded version information pattern that is used for the symbol
+ * of version 7 or greater. Use lower 18 bits.
+ * @param version
+ * @return BCH encoded version information pattern
+ */
+extern unsigned int MQRspec_getVersionPattern(int version);
+
+/******************************************************************************
+ * Format information
+ *****************************************************************************/
+
+/**
+ * Return BCH encoded format information pattern.
+ * @param mask
+ * @param version
+ * @param level
+ * @return BCH encoded format information pattern
+ */
+extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level);
+
+/******************************************************************************
+ * Frame
+ *****************************************************************************/
+
+/**
+ * Return a copy of initialized frame.
+ * When the same version is requested twice or more, a copy of cached frame
+ * is returned.
+ * @param version
+ * @return Array of unsigned char. You can free it by free().
+ */
+/* WARNING: Thread unsafe!!! */
+extern unsigned char *MQRspec_newFrame(int version);
+
+#endif /* __QRSPEC_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 177c4ce82b..119781d115 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,6 +4,7 @@ endif
 
 noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \
 				  test_qrspec test_rs test_qrencode prof_qrencode \
+				  test_mqrspec \
 				  $(sdlPROGRAMS)
 
 test_qrinput_SOURCES = test_qrinput.c common.h
@@ -18,6 +19,9 @@ test_estimatebit_LDADD = ../libqrencode.la
 test_qrspec_SOURCES = test_qrspec.c common.h
 test_qrspec_LDADD = ../qrspec.o
 
+test_mqrspec_SOURCES = test_mqrspec.c common.h
+test_mqrspec_LDADD = ../mqrspec.o
+
 test_rs_SOURCES = test_rs.c common.h
 test_rs_LDADD = ../libqrencode.la
 
diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c
new file mode 100644
index 0000000000..125a5a19d8
--- /dev/null
+++ b/tests/test_mqrspec.c
@@ -0,0 +1,128 @@
+#include 
+#include 
+#include "common.h"
+#include "../mqrspec.h"
+
+unsigned char v4frame[] = {
+	0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc0,0x91,0x90,0x91,0x90,0x91,0x90,0x91,0x90,0x91,
+	0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0xc1,0xc0,0xc1,0xc1,0xc1,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0xc1,0xc0,0xc1,0xc1,0xc1,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0xc1,0xc0,0xc1,0xc1,0xc1,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x91,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+	0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+void test_newFrame(void)
+{
+	int width;
+	unsigned char *frame;
+
+	testStart("Test Version 4 frame");
+	frame = MQRspec_newFrame(4);
+	width = MQRspec_getWidth(4);
+	testEnd(memcmp(frame, v4frame, width * width));
+	free(frame);
+}
+
+/* See Table 10 (pp.115) of Appendix 1, JIS X0510:2004 */
+static unsigned int calcFormatInfo(int type, int mask)
+{
+	unsigned int data, ecc, b, code;
+	int i, c;
+
+	data = (type << 12) | (mask << 10);
+	ecc = data;
+	b = 1 << 14;
+	for(i=0; b != 0; i++) {
+		if(ecc & b) break;
+		b = b >> 1;
+	}
+	c = 4 - i;
+	code = 0x537 << c ; //10100110111
+	b = 1 << (10 + c);
+	for(i=0; i<=c; i++) {
+		if(b & ecc) {
+			ecc ^= code;
+		}
+		code = code >> 1;
+		b = b >> 1;
+	}
+	
+	return (data | ecc) ^ 0x4445;
+}
+
+/* See Table 10 of Appendix 1. (pp.115) */
+static const int typeTable[4][3] = {
+	{ 0, -1, -1},
+	{ 1,  2, -1},
+	{ 3,  4, -1},
+	{ 5,  6,  7}
+};
+
+void test_format(void)
+{
+	unsigned int format;
+	int version, l, mask;
+	int type;
+	int err = 0;
+
+	testStart("Format info test");
+	for(version=1; version<4; version++) {
+		for(l=0; l<3; l++) {
+			for(mask=0; mask<4; mask++) {
+				format = MQRspec_getFormatInfo(mask, version, l);
+				type = typeTable[version - 1][l];
+				if(type == -1) {
+					if(format != 0) {
+						printf("Error in version %d, level %d, mask %d\n",
+								version, l, mask);
+						err++;
+					}
+				} else {
+					if(format != calcFormatInfo(type, mask)) {
+						printf("Error in version %d, level %d, mask %d\n",
+								version, l, mask);
+						err++;
+					}
+				}
+			}
+		}
+	}
+	testEnd(err);
+}
+
+void print_format(void)
+{
+	unsigned int format;
+	int i, j;
+
+	for(i=0; i<4; i++) {
+		for(j=0; j<8; j++) {
+			format = calcFormatInfo(j, i);
+			printf("0x%04x, ", format);
+		}
+		printf("\n");
+	}
+}
+
+int main(int argc, char **argv)
+{
+	test_newFrame();
+	//print_format();
+	test_format();
+
+	report();
+
+	return 0;
+}
-- 
cgit 0.0.5-2-1-g0f52


From 3e6674195df2bb3f1d7ef4ea50050302bd54eda6 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sat, 16 Dec 2006 08:53:17 +0000
Subject:

---
 mqrspec.c            |  9 ++++++++-
 mqrspec.h            | 14 +++-----------
 tests/test_mqrspec.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/mqrspec.c b/mqrspec.c
index 0696571357..2a4c64f319 100644
--- a/mqrspec.c
+++ b/mqrspec.c
@@ -52,12 +52,19 @@ static const MQRspec_Capacity mqrspecCapacity[MQRSPEC_VERSION_MAX + 1] = {
 	{ 17, {8, 10, 14}}
 };
 
+/**
+ * Return data length of the symbol (bits)
+ */
 int MQRspec_getDataLength(int version, QRecLevel level)
 {
 	int w;
+	int ecc;
 
 	w = mqrspecCapacity[version].width - 1;
-	return w * w - 64 - mqrspecCapacity[version].ec[level] * 8;
+	ecc = mqrspecCapacity[version].ec[level];
+	if(ecc == 0) return 0;
+
+	return w * w - 64 - ecc * 8;
 }
 
 int MQRspec_getECCLength(int version, QRecLevel level)
diff --git a/mqrspec.h b/mqrspec.h
index b21adb460f..7bc38063c5 100644
--- a/mqrspec.h
+++ b/mqrspec.h
@@ -86,7 +86,7 @@ extern int MQRspec_getRemainder(int version);
  * @param version
  * @return the size of the appropriate length indicator (bits).
  */
-extern int QRspec_lengthIndicator(QRencodeMode mode, int version);
+extern int MQRspec_lengthIndicator(QRencodeMode mode, int version);
 
 /**
  * Return the maximum length for the mode and version.
@@ -94,7 +94,7 @@ extern int QRspec_lengthIndicator(QRencodeMode mode, int version);
  * @param version
  * @return the maximum length (bytes)
  */
-extern int QRspec_maximumWords(QRencodeMode mode, int version);
+extern int MQRspec_maximumWords(QRencodeMode mode, int version);
 
 /******************************************************************************
  * Error correction code
@@ -109,15 +109,7 @@ extern int QRspec_maximumWords(QRencodeMode mode, int version);
  *  # of type2 blocks, # of data code, # of ecc code}
  * It can be freed by calling free().
  */
-int *QRspec_getEccSpec(int version, QRecLevel level);
-
-#define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3])
-#define QRspec_rsBlockNum1(__spec__) (__spec__[0])
-#define QRspec_rsDataCodes1(__spec__) (__spec__[1])
-#define QRspec_rsEccCodes1(__spec__) (__spec__[2])
-#define QRspec_rsBlockNum2(__spec__) (__spec__[3])
-#define QRspec_rsDataCodes2(__spec__) (__spec__[4])
-#define QRspec_rsEccCodes2(__spec__) (__spec__[5])
+int *MQRspec_getEccSpec(int version, QRecLevel level);
 
 /******************************************************************************
  * Version information pattern
diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c
index 125a5a19d8..5dc43ae51c 100644
--- a/tests/test_mqrspec.c
+++ b/tests/test_mqrspec.c
@@ -116,11 +116,41 @@ void print_format(void)
 	}
 }
 
+/**
+ * See Table 7 of Appendix 1.
+ */
+int datalen[4][3] = {
+	{ 20,   0,  0},
+	{ 40,  32,  0},
+	{ 84,  68,  0},
+	{128, 112, 80},
+};
+
+void test_dataLength(void)
+{
+	int v, l;
+	int bits;
+	int err = 0;
+
+	testStart("Test dataLength");
+	for(v=0; v<4; v++) {
+		for(l=0; l<3; l++) {
+			bits = MQRspec_getDataLength(v+1, l);
+			if(bits != datalen[v][l]) {
+				printf("Error in version %d, level %d.\n", v, l);
+				err++;
+			}
+		}
+	}
+	testEnd(err);
+}
+
 int main(int argc, char **argv)
 {
 	test_newFrame();
 	//print_format();
 	test_format();
+	test_dataLength();
 
 	report();
 
-- 
cgit 0.0.5-2-1-g0f52


From fdea0228073f005370ab7ce85f986a09e71acb9e Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sun, 17 Dec 2006 05:29:37 +0000
Subject:

---
 ChangeLog        | 4 ++++
 qrencode.c       | 1 -
 qrencode_inner.h | 1 -
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b557f79fc5..33afc0bb54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,2 +1,6 @@
+2006.12.17 Kentaro FUKUCHI 
+	* qrencode_inner.h, qrencode.c:
+	  - Removed unused member variable "b2" from QRRawCode.
+
 2006.12.02 Kentaro FUKUCHI 
 	* Bumped version to 1.0.0.
diff --git a/qrencode.c b/qrencode.c
index 58e00a4910..703a4093d5 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -83,7 +83,6 @@ QRRawCode *QRraw_new(QRinput *input)
 	}
 
 	raw->b1 = QRspec_rsBlockNum1(spec);
-	raw->b2 = QRspec_rsBlockNum2(spec);
 	raw->dataLength = QRspec_rsBlockNum1(spec) * QRspec_rsDataCodes1(spec)
 					+ QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec);
 	raw->eccLength = QRspec_rsBlockNum(spec) * QRspec_rsEccCodes1(spec);
diff --git a/qrencode_inner.h b/qrencode_inner.h
index 6fb0f80b7c..7388c4ccc6 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -46,7 +46,6 @@ typedef struct {
 	int dataLength;
 	int eccLength;
 	int b1;
-	int b2;
 } QRRawCode;
 
 extern QRRawCode *QRraw_new(QRinput *input);
-- 
cgit 0.0.5-2-1-g0f52


From 7fd4edd2183581f438577be6e11fb3d9cf4e66d6 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sun, 17 Dec 2006 06:19:19 +0000
Subject:

---
 ChangeLog    |  2 ++
 Makefile.am  |  4 ++--
 acinclude.m4 | 44 --------------------------------------------
 configure.ac |  6 +++---
 4 files changed, 7 insertions(+), 49 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 33afc0bb54..ac96d86b7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 2006.12.17 Kentaro FUKUCHI 
 	* qrencode_inner.h, qrencode.c:
 	  - Removed unused member variable "b2" from QRRawCode.
+	* configure.ac, Makefile.am, acinclude.m4:
+	  - Better configuration of libpng. (now uses pkg-config correctly)
 
 2006.12.02 Kentaro FUKUCHI 
 	* Bumped version to 1.0.0.
diff --git a/Makefile.am b/Makefile.am
index 2b8464c9b7..a8efb4e166 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,6 +21,6 @@ EXTRA_DIST = libqrencode.pc.in
 
 if BUILD_TOOLS
 bin_PROGRAMS = qrencode
-qrencode_SOURCES = qrenc.c
-qrencode_LDADD = -lqrencode -lpng
+qrencode_CFLAGS = $(png_CFLAGS)
+qrencode_LDADD = -lqrencode $(png_LIBS)
 endif
diff --git a/acinclude.m4 b/acinclude.m4
index 1432c34cea..e69de29bb2 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,44 +0,0 @@
-dnl Test for libpng
-AC_DEFUN([AM_PATH_LIBPNG],
-[
-  if test x$with_libpng != xno && test -z "$LIBPNG"; then
-    AC_MSG_CHECKING(for libpng12)
-    if pkg-config --exists libpng12 ; then
-        AC_MSG_RESULT(yes)
-        PNG='png'
-        PNG_DEP_CFLAGS_PACKAGES=libpng12
-        LIBPNG=`pkg-config --libs libpng12`
-    else
-      AC_MSG_RESULT(no)
-      AC_CHECK_LIB(png, png_read_info,
-        [AC_CHECK_HEADER(png.h,
-          png_ok=yes,
-          png_ok=no)],
-        AC_MSG_WARN(*** PNG library not found), -lz -lm)
-      if test "$png_ok" = yes; then
-        AC_MSG_CHECKING([for png_structp in png.h])
-        AC_TRY_COMPILE([#include ],
-          [png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;],
-          png_ok=yes,
-          png_ok=no)
-        AC_MSG_RESULT($png_ok)
-        if test "$png_ok" = yes; then
-          PNG='png'; LIBPNG='-lpng -lz'
-        else
-          AC_MSG_WARN(*** PNG library is too old)
-        fi
-      else
-       AC_MSG_WARN(*** PNG header file not found)
-      fi
-    fi
-  fi
-
-  if test x$with_libpng != xno && test -z "$LIBPNG"; then
-     AC_MSG_ERROR([
-*** Checks for PNG library failed. You can build the library without it by
-*** passing --without-tools to configure but utility tools are not to be
-*** built.])
-  fi
-
-  AC_SUBST(LIBPNG)
-])
diff --git a/configure.ac b/configure.ac
index f078005aea..b65a62e429 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_INIT(QRencode)
 
 MAJOR_VERSION=1
 MINOR_VERSION=0
-MICRO_VERSION=0
+MICRO_VERSION=1
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 AC_SUBST(MAJOR_VERSION)
 AC_SUBST(MINOR_VERSION)
@@ -24,7 +24,7 @@ AC_HEADER_STDC
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
-
+PKG_PROG_PKG_CONFIG
 
 SDL_REQUIRED_VERSION=1.2.0
 AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.]))
@@ -38,7 +38,7 @@ AC_ARG_WITH([tools], [AC_HELP_STRING([--with-tools], [build utility tools [defau
  [], [build_tools=yes])
 
 if test x$build_tools = xyes ; then
-	AM_PATH_LIBPNG
+	PKG_CHECK_MODULES(png, "libpng12")
 fi
 AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ])
 
-- 
cgit 0.0.5-2-1-g0f52


From 307422709d79bb1f5ef66ab1717df924f4c6bd68 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 18 Dec 2006 14:20:57 +0000
Subject:

---
 ChangeLog             |   5 +
 Makefile.am           |   3 +
 mask.c                | 257 ++++++++++++++++++++++++++++
 mask.h                |  31 ++++
 mqrspec.c             |  21 +--
 mqrspec.h             |   5 +-
 qrencode.c            | 459 +++++---------------------------------------------
 qrencode_inner.h      |  31 ++--
 split.c               | 208 +++++++++++++++++++++++
 split.h               |  34 ++++
 tests/test_qrencode.c |  42 ++---
 tests/test_qrinput.c  |   1 +
 tests/view_qrcode.c   |   3 +-
 13 files changed, 634 insertions(+), 466 deletions(-)
 create mode 100644 mask.c
 create mode 100644 mask.h
 create mode 100644 split.c
 create mode 100644 split.h

diff --git a/ChangeLog b/ChangeLog
index ac96d86b7a..0bb3f9a910 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006.12.18 Kentaro FUKUCHI 
+	* mask.[ch], split.[ch]:
+	  - Masking functions and splitString functions are separated from
+	    qrencode.c.
+
 2006.12.17 Kentaro FUKUCHI 
 	* qrencode_inner.h, qrencode.c:
 	  - Removed unused member variable "b2" from QRRawCode.
diff --git a/Makefile.am b/Makefile.am
index a8efb4e166..cdba75d29d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,6 +9,8 @@ libqrencode_la_SOURCES = qrencode.c qrencode_inner.h \
 						 bitstream.c bitstream.h \
 						 qrspec.c qrspec.h \
 						 rscode.c rscode.h \
+						 split.c split.h \
+						 mask.c mask.h \
 						 mqrspec.c mqrspec.h
 libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION)
 
@@ -21,6 +23,7 @@ EXTRA_DIST = libqrencode.pc.in
 
 if BUILD_TOOLS
 bin_PROGRAMS = qrencode
+qrencode_SOURCES = qrenc.c
 qrencode_CFLAGS = $(png_CFLAGS)
 qrencode_LDADD = -lqrencode $(png_LIBS)
 endif
diff --git a/mask.c b/mask.c
new file mode 100644
index 0000000000..728d3fd7df
--- /dev/null
+++ b/mask.c
@@ -0,0 +1,257 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Masking.
+ * Copyright (C) 2006 Kentaro Fukuchi 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include "qrencode.h"
+#include "qrencode_inner.h"
+#include "qrspec.h"
+#include "mask.h"
+
+/**
+ * Demerit coefficients.
+ * See Section 8.8.2, pp.45, JIS X0510:2004.
+ */
+#define N1 (3)
+#define N2 (3)
+#define N3 (40)
+#define N4 (10)
+
+#define MASKMAKER(__exp__) \
+	int x, y;\
+	unsigned int b = 0;\
+\
+	for(y=0; y= 5) {
+			demerit += N1 + (runLength[i] - 5);
+			//n1 += N1 + (runLength[i] - 5);
+		}
+		if((i & 1)) {
+			if(i >= 3 && i < length-2 && (runLength[i] % 3) == 0) {
+				fact = runLength[i] / 3;
+				if(runLength[i-2] == fact &&
+				   runLength[i-1] == fact &&
+				   runLength[i+1] == fact &&
+				   runLength[i+2] == fact) {
+					if(runLength[i-3] < 0 || runLength[i-3] >= 4 * fact) {
+						demerit += N3;
+						//n3 += N3;
+					} else if(i+3 >= length || runLength[i+3] >= 4 * fact) {
+						demerit += N3;
+						//n3 += N3;
+					}
+				}
+			}
+		}
+	}
+
+	return demerit;
+}
+
+int Mask_evaluateSymbol(int width, unsigned char *frame)
+{
+	int x, y;
+	unsigned char *p;
+	unsigned char b22, w22;
+	unsigned int i;
+	int head;
+	int demerit = 0;
+
+	p = frame;
+	i = 0;
+	for(y=0; y 0 && y > 0) {
+				b22 = p[0] & p[-1] & p[-width] & p [-width-1];
+				w22 = p[0] | p[-1] | p[-width] | p [-width-1];
+				if((b22 | (w22 ^ 1))&1) {
+					demerit += N2;
+				}
+			}
+			if(x == 0 && (p[0] & 1)) {
+				runLength[0] = -1;
+				head = 1;
+				runLength[head] = 1;
+			} else if(x > 0) {
+				if((p[0] ^ p[-1]) & 1) {
+					head++;
+					runLength[head] = 1;
+				} else {
+					runLength[head]++;
+				}
+			}
+			p++;
+		}
+		demerit += Mask_calcN1N3(head+1, runLength);
+	}
+
+	i = 0;
+	for(x=0; x 0) {
+				if((p[0] ^ p[-width]) & 1) {
+					head++;
+					runLength[head] = 1;
+				} else {
+					runLength[head]++;
+				}
+			}
+			p+=width;
+		}
+		demerit += Mask_calcN1N3(head+1, runLength);
+	}
+
+	return demerit;
+}
+
+unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
+{
+	int i;
+	unsigned char *mask, *bestMask;
+	int minDemerit = INT_MAX;
+	int bestMaskNum = 0;
+	int blacks;
+	int demerit;
+
+	bestMask = NULL;
+
+	for(i=0; i<8; i++) {
+//		n1 = n2 = n3 = n4 = 0;
+		demerit = 0;
+		mask = (unsigned char *)malloc(width * width);
+		blacks = maskMakers[i](width, frame, mask);
+		blacks = 100 * blacks / (width * width);
+		demerit = (abs(blacks - 50) / 5) * N4;
+//		n4 = demerit;
+		if(demerit > minDemerit) {
+			free(mask);
+			continue;
+		}
+		demerit += Mask_evaluateSymbol(width, mask);
+//		printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit);
+		if(demerit < minDemerit) {
+			minDemerit = demerit;
+			bestMaskNum = i;
+			if(bestMask != NULL) {
+				free(bestMask);
+			}
+			bestMask = mask;
+		} else {
+			free(mask);
+		}
+	}
+
+	QRinput_writeFormatInformation(width, bestMask, bestMaskNum, level);
+
+	return bestMask;
+}
diff --git a/mask.h b/mask.h
new file mode 100644
index 0000000000..c83a983bba
--- /dev/null
+++ b/mask.h
@@ -0,0 +1,31 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Masking.
+ * Copyright (C) 2006 Kentaro Fukuchi 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __MASK_H__
+#define __MASK_H__
+
+#include "qrinput.h"
+
+extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask);
+extern int Mask_evaluateSymbol(int width, unsigned char *frame);
+extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level);
+
+#endif /* __MASK_H__ */
diff --git a/mqrspec.c b/mqrspec.c
index 2a4c64f319..9a32bf0a46 100644
--- a/mqrspec.c
+++ b/mqrspec.c
@@ -52,9 +52,6 @@ static const MQRspec_Capacity mqrspecCapacity[MQRSPEC_VERSION_MAX + 1] = {
 	{ 17, {8, 10, 14}}
 };
 
-/**
- * Return data length of the symbol (bits)
- */
 int MQRspec_getDataLength(int version, QRecLevel level)
 {
 	int w;
@@ -114,19 +111,15 @@ int MQRspec_maximumWords(QRencodeMode mode, int version)
  * Error correction code
  *****************************************************************************/
 
-/**
- * Table of the error correction code (Reed-Solomon block)
- * See Table 8 (pp.113) of Appendix 1, JIS X0510:2004.
- */
-static const int eccTable[MQRSPEC_VERSION_MAX+1][3] = {
-	{2,  0,  0},
-	{5,  6,  0},
-	{6,  8,  0},
-	{8, 10, 14}
-};
-
 int *MQRspec_getEccSpec(int version, QRecLevel level)
 {
+#if 0
+	int data, ecc;
+	int *array;
+
+	data = MQRspec_getDataLength(version, level);
+	ecc = MQRspec_getECCLength(version, level);
+#endif
 	return NULL;
 }
 
diff --git a/mqrspec.h b/mqrspec.h
index 7bc38063c5..2d0c520958 100644
--- a/mqrspec.h
+++ b/mqrspec.h
@@ -39,10 +39,11 @@
 #define MQRSPEC_WIDTH_MAX 17
 
 /**
- * Return maximum data code length (bytes) for the version.
+ * Return maximum data code length (bits) for the version.
+ * Warning: unlike in QRSpec_getDataLength, return in BITS!
  * @param version
  * @param level
- * @return maximum size (bytes)
+ * @return maximum size (bits)
  */
 extern int MQRspec_getDataLength(int version, QRecLevel level);
 
diff --git a/qrencode.c b/qrencode.c
index 703a4093d5..73bef3ab44 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -21,14 +21,16 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "qrencode.h"
 #include "qrencode_inner.h"
 #include "qrspec.h"
+#include "mqrspec.h"
 #include "bitstream.h"
 #include "qrinput.h"
 #include "rscode.h"
+#include "split.h"
+#include "mask.h"
 
 /******************************************************************************
  * Raw code
@@ -134,6 +136,39 @@ void QRraw_free(QRRawCode *raw)
 	free(raw);
 }
 
+/******************************************************************************
+ * Raw code for Micro QR Code
+ *****************************************************************************/
+
+#if 0
+MQRRawCode *MQRraw_new(QRinput *input)
+{
+	MQRRawCode *raw;
+	int i;
+	RSblock *rsblock;
+	unsigned char *p;
+
+	p = QRinput_getByteStream(input);
+	if(p == NULL) {
+		return NULL;
+	}
+
+	raw = (MQRRawCode *)malloc(sizeof(MQRRawCode));
+	raw->datacode = p;
+	raw->version = input->version;
+	raw->rsblock = (RSblock *)malloc(sizeof(RSblock));
+	RSblock_init(raw->rsblock, hoge, p, moge);
+
+
+	raw->dataLength = ;
+	raw->eccLength = ;
+	raw->count = 0;
+
+	return raw;
+}
+#endif
+
+
 /******************************************************************************
  * Frame filling
  *****************************************************************************/
@@ -218,7 +253,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler)
 	return &p[y * w + x];
 }
 
-unsigned char *QRinput_fillerTest(int version)
+unsigned char *FrameFiller_fillerTest(int version)
 {
 	int width, length;
 	unsigned char *frame, *p;
@@ -292,240 +327,6 @@ void QRinput_writeFormatInformation(int width, unsigned char *frame, int mask, Q
 	}
 }
 
-/******************************************************************************
- * Masking
- *****************************************************************************/
-
-/**
- * Demerit coefficients.
- * See Section 8.8.2, pp.45, JIS X0510:2004.
- */
-#define N1 (3)
-#define N2 (3)
-#define N3 (40)
-#define N4 (10)
-
-#define MASKMAKER(__exp__) \
-	int x, y;\
-	unsigned int b = 0;\
-\
-	for(y=0; y= 5) {
-			demerit += N1 + (runLength[i] - 5);
-			//n1 += N1 + (runLength[i] - 5);
-		}
-		if((i & 1)) {
-			if(i >= 3 && i < length-2 && (runLength[i] % 3) == 0) {
-				fact = runLength[i] / 3;
-				if(runLength[i-2] == fact &&
-				   runLength[i-1] == fact &&
-				   runLength[i+1] == fact &&
-				   runLength[i+2] == fact) {
-					if(runLength[i-3] < 0 || runLength[i-3] >= 4 * fact) {
-						demerit += N3;
-						//n3 += N3;
-					} else if(i+3 >= length || runLength[i+3] >= 4 * fact) {
-						demerit += N3;
-						//n3 += N3;
-					}
-				}
-			}
-		}
-	}
-
-	return demerit;
-}
-
-int QRinput_evaluateSymbol(int width, unsigned char *frame)
-{
-	int x, y;
-	unsigned char *p;
-	unsigned char b22, w22;
-	unsigned int i;
-	int head;
-	int demerit = 0;
-
-	p = frame;
-	i = 0;
-	for(y=0; y 0 && y > 0) {
-				b22 = p[0] & p[-1] & p[-width] & p [-width-1];
-				w22 = p[0] | p[-1] | p[-width] | p [-width-1];
-				if((b22 | (w22 ^ 1))&1) {
-					demerit += N2;
-				}
-			}
-			if(x == 0 && (p[0] & 1)) {
-				runLength[0] = -1;
-				head = 1;
-				runLength[head] = 1;
-			} else if(x > 0) {
-				if((p[0] ^ p[-1]) & 1) {
-					head++;
-					runLength[head] = 1;
-				} else {
-					runLength[head]++;
-				}
-			}
-			p++;
-		}
-		demerit += QRinput_calcN1N3(head+1, runLength);
-	}
-
-	i = 0;
-	for(x=0; x 0) {
-				if((p[0] ^ p[-width]) & 1) {
-					head++;
-					runLength[head] = 1;
-				} else {
-					runLength[head]++;
-				}
-			}
-			p+=width;
-		}
-		demerit += QRinput_calcN1N3(head+1, runLength);
-	}
-
-	return demerit;
-}
-
-static unsigned char *QRinput_mask(int width, unsigned char *frame, QRecLevel level)
-{
-	int i;
-	unsigned char *mask, *bestMask;
-	int minDemerit = INT_MAX;
-	int bestMaskNum = 0;
-	int blacks;
-	int demerit;
-
-	bestMask = NULL;
-
-	for(i=0; i<8; i++) {
-//		n1 = n2 = n3 = n4 = 0;
-		demerit = 0;
-		mask = (unsigned char *)malloc(width * width);
-		blacks = maskMakers[i](width, frame, mask);
-		blacks = 100 * blacks / (width * width);
-		demerit = (abs(blacks - 50) / 5) * N4;
-//		n4 = demerit;
-		if(demerit > minDemerit) {
-			free(mask);
-			continue;
-		}
-		demerit += QRinput_evaluateSymbol(width, mask);
-//		printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit);
-		if(demerit < minDemerit) {
-			minDemerit = demerit;
-			bestMaskNum = i;
-			if(bestMask != NULL) {
-				free(bestMask);
-			}
-			bestMask = mask;
-		} else {
-			free(mask);
-		}
-	}
-
-	QRinput_writeFormatInformation(width, bestMask, bestMaskNum, level);
-
-	return bestMask;
-}
-
 /******************************************************************************
  * QR-code encoding
  *****************************************************************************/
@@ -552,11 +353,6 @@ void QRcode_free(QRcode *qrcode)
 	free(qrcode);
 }
 
-QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level)
-{
-	return QRcode_encodeMask(input, version, level, -1);
-}
-
 QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask)
 {
 	int width;
@@ -598,10 +394,9 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask
 	free(filler);
 	/* masking */
 	if(mask < 0) {
-		masked = QRinput_mask(width, frame, level);
+		masked = Mask_mask(width, frame, level);
 	} else {
-		masked = (unsigned char *)malloc(width * width);
-		maskMakers[mask](width, frame, masked);
+		masked = Mask_makeMask(width, frame, mask);
 		QRinput_writeFormatInformation(width, masked, mask, QRinput_getErrorCorrectionLevel(input));
 	}
 	qrcode = QRcode_new(version, width, masked);
@@ -611,181 +406,11 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask
 	return qrcode;
 }
 
-static int QRcode_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int QRcode_eat8(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int QRcode_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint);
-
-#define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10)
-#define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0)
-
-static int QRcode_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint)
-{
-	const char *p;
-	int run;
-	int dif;
-	int ln;
-
-	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
-
-	p = string;
-	while(isdigit(*p)) {
-		p++;
-	}
-	run = p - string;
-	if(*p & 0x80) {
-		dif = QRinput_estimateBitsModeNum(run) + 4 + ln
-			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
-			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
-		if(dif > 0) {
-			return QRcode_eat8(string, input, version, hint);
-		}
-	}
-	if(isalnum(*p)) {
-		dif = QRinput_estimateBitsModeNum(run) + 4 + ln
-			+ QRinput_estimateBitsModeAn(1) /* + 4 + la */
-			- QRinput_estimateBitsModeAn(run + 1) /* - 4 - la */;
-		if(dif > 0) {
-			return QRcode_eatAn(string, input, version, hint);
-		}
-	}
-
-	QRinput_append(input, QR_MODE_NUM, run, (unsigned char *)string);
-	return run;
-}
-
-static int QRcode_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint)
-{
-	const char *p, *q;
-	int run;
-	int dif;
-	int la, ln;
-
-	la = QRspec_lengthIndicator(QR_MODE_AN, version);
-	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
-
-	p = string;
-	while(isalnum(*p)) {
-		if(isdigit(*p)) {
-			q = p;
-			while(isdigit(*q)) {
-				q++;
-			}
-			dif = QRinput_estimateBitsModeAn(p - string) /* + 4 + la */
-				+ QRinput_estimateBitsModeNum(q - p) + 4 + ln
-				- QRinput_estimateBitsModeAn(q - string) /* - 4 - la */;
-			if(dif < 0) {
-				break;
-			} else {
-				p = q;
-			}
-		} else {
-			p++;
-		}
-	}
-
-	run = p - string;
-
-	if(*p & 0x80) {
-		dif = QRinput_estimateBitsModeAn(run) + 4 + la
-			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
-			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
-		if(dif > 0) {
-			return QRcode_eat8(string, input, version, hint);
-		}
-	}
-
-	QRinput_append(input, QR_MODE_AN, run, (unsigned char *)string);
-	return run;
-}
-
-static int QRcode_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint)
-{
-	const char *p;
-
-	p = string;
-	while(QRinput_identifyMode(p) == QR_MODE_KANJI) {
-		p += 2;
-	}
-	QRinput_append(input, QR_MODE_KANJI, p - string, (unsigned char *)string);
-	return p - string;
-}
-
-static int QRcode_eat8(const char *string, QRinput *input, int version, QRencodeMode hint)
+QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level)
 {
-	const char *p, *q;
-	QRencodeMode mode;
-	int dif;
-	int la, ln;
-
-	la = QRspec_lengthIndicator(QR_MODE_AN, version);
-	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
-
-	p = string;
-	while(*p != '\0') {
-		mode = QRinput_identifyMode(p);
-		if(hint == QR_MODE_KANJI && mode == QR_MODE_KANJI) {
-			break;
-		}
-		if(mode != QR_MODE_8 && mode != QR_MODE_KANJI) {
-			if(mode == QR_MODE_NUM) {
-				q = p;
-				while(isdigit(*q)) {
-					q++;
-				}
-				dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */
-					+ QRinput_estimateBitsModeNum(q - p) + 4 + ln
-					- QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */;
-				if(dif < 0) {
-					break;
-				} else {
-					p = q;
-				}
-			} else {
-				q = p;
-				while(isalnum(*q)) {
-					q++;
-				}
-				dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */
-					+ QRinput_estimateBitsModeAn(q - p) + 4 + la
-					- QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */;
-				if(dif < 0) {
-					break;
-				} else {
-					p = q;
-				}
-			}
-		} else {
-			p++;
-		}
-	}
-
-	QRinput_append(input, QR_MODE_8, p - string, (unsigned char *)string);
-	return p - string;
+	return QRcode_encodeMask(input, version, level, -1);
 }
 
-void QRcode_splitStringToQRinput(const char *string, QRinput *input,
-		int version, QRencodeMode hint)
-{
-	int length;
-	QRencodeMode mode;
-
-	if(*string == '\0') return;
-
-	mode = QRinput_identifyMode(string);
-	if(mode == QR_MODE_NUM) {
-		length = QRcode_eatNum(string, input, version, hint);
-	} else if(mode == QR_MODE_AN) {
-		length = QRcode_eatAn(string, input, version, hint);
-	} else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
-		length = QRcode_eatKanji(string, input, version, hint);
-	} else {
-		length = QRcode_eat8(string, input, version, hint);
-	}
-	if(length == 0) return;
-	/* Of course this tail recursion could be optimized! Believe gcc. */
-	QRcode_splitStringToQRinput(&string[length], input, hint, version);
-}
 
 QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint)
 {
@@ -797,7 +422,7 @@ QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QR
 	}
 
 	input = QRinput_new();
-	QRcode_splitStringToQRinput(string, input, version, hint);
+	Split_splitStringToQRinput(string, input, version, hint);
 	code = QRcode_encodeInput(input, version, level);
 	QRinput_free(input);
 
diff --git a/qrencode_inner.h b/qrencode_inner.h
index 7388c4ccc6..d1cb163ab3 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -53,24 +53,31 @@ extern unsigned char QRraw_getCode(QRRawCode *raw);
 extern void QRraw_free(QRRawCode *raw);
 
 /******************************************************************************
- * Frame filling
+ * Raw code for Micro QR Code
  *****************************************************************************/
-extern unsigned char *QRinput_fillerTest(int version);
+
+typedef struct {
+	int version;
+	unsigned char *datacode;
+	RSblock *rsblock;
+	int count;
+	int dataLength;
+	int eccLength;
+} MQRRawCode;
+
+extern MQRRawCode *MQRraw_new(QRinput *input);
+extern unsigned char MQRraw_getCode(MQRRawCode *raw);
+extern void MQRraw_free(MQRRawCode *raw);
 
 /******************************************************************************
- * Format information
+ * Frame filling
  *****************************************************************************/
-extern void QRinput_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
+extern unsigned char *FrameFiller_fillerTest(int version);
 
 /******************************************************************************
- * Masking
+ * Format information
  *****************************************************************************/
-extern unsigned char *QRinput_makeMask(int width, unsigned char *frame, int mask);
-
-extern int QRinput_evaluateSymbol(int width, unsigned char *frame);
-
-QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask);
+extern void QRinput_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
 
-void QRcode_splitStringToQRinput(const char *string, QRinput *input,
-		int version, QRencodeMode hint);
+extern QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask);
 #endif /* __QRENCODE_INNER_H__ */
diff --git a/split.c b/split.c
new file mode 100644
index 0000000000..a4881eea6a
--- /dev/null
+++ b/split.c
@@ -0,0 +1,208 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Input data splitter.
+ * Copyright (C) 2006 Kentaro Fukuchi 
+ *
+ * The following data / specifications are taken from
+ * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
+ *  or
+ * "Automatic identification and data capture techniques -- 
+ *  QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "qrencode.h"
+#include "qrinput.h"
+#include "qrspec.h"
+#include "split.h"
+
+#define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10)
+#define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0)
+
+static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint);
+static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint);
+static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint);
+static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint);
+
+static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint)
+{
+	const char *p;
+	int run;
+	int dif;
+	int ln;
+
+	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
+
+	p = string;
+	while(isdigit(*p)) {
+		p++;
+	}
+	run = p - string;
+	if(*p & 0x80) {
+		dif = QRinput_estimateBitsModeNum(run) + 4 + ln
+			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
+			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
+		if(dif > 0) {
+			return Split_eat8(string, input, version, hint);
+		}
+	}
+	if(isalnum(*p)) {
+		dif = QRinput_estimateBitsModeNum(run) + 4 + ln
+			+ QRinput_estimateBitsModeAn(1) /* + 4 + la */
+			- QRinput_estimateBitsModeAn(run + 1) /* - 4 - la */;
+		if(dif > 0) {
+			return Split_eatAn(string, input, version, hint);
+		}
+	}
+
+	QRinput_append(input, QR_MODE_NUM, run, (unsigned char *)string);
+	return run;
+}
+
+static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint)
+{
+	const char *p, *q;
+	int run;
+	int dif;
+	int la, ln;
+
+	la = QRspec_lengthIndicator(QR_MODE_AN, version);
+	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
+
+	p = string;
+	while(isalnum(*p)) {
+		if(isdigit(*p)) {
+			q = p;
+			while(isdigit(*q)) {
+				q++;
+			}
+			dif = QRinput_estimateBitsModeAn(p - string) /* + 4 + la */
+				+ QRinput_estimateBitsModeNum(q - p) + 4 + ln
+				- QRinput_estimateBitsModeAn(q - string) /* - 4 - la */;
+			if(dif < 0) {
+				break;
+			} else {
+				p = q;
+			}
+		} else {
+			p++;
+		}
+	}
+
+	run = p - string;
+
+	if(*p & 0x80) {
+		dif = QRinput_estimateBitsModeAn(run) + 4 + la
+			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
+			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
+		if(dif > 0) {
+			return Split_eat8(string, input, version, hint);
+		}
+	}
+
+	QRinput_append(input, QR_MODE_AN, run, (unsigned char *)string);
+	return run;
+}
+
+static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint)
+{
+	const char *p;
+
+	p = string;
+	while(QRinput_identifyMode(p) == QR_MODE_KANJI) {
+		p += 2;
+	}
+	QRinput_append(input, QR_MODE_KANJI, p - string, (unsigned char *)string);
+	return p - string;
+}
+
+static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint)
+{
+	const char *p, *q;
+	QRencodeMode mode;
+	int dif;
+	int la, ln;
+
+	la = QRspec_lengthIndicator(QR_MODE_AN, version);
+	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
+
+	p = string;
+	while(*p != '\0') {
+		mode = QRinput_identifyMode(p);
+		if(hint == QR_MODE_KANJI && mode == QR_MODE_KANJI) {
+			break;
+		}
+		if(mode != QR_MODE_8 && mode != QR_MODE_KANJI) {
+			if(mode == QR_MODE_NUM) {
+				q = p;
+				while(isdigit(*q)) {
+					q++;
+				}
+				dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */
+					+ QRinput_estimateBitsModeNum(q - p) + 4 + ln
+					- QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */;
+				if(dif < 0) {
+					break;
+				} else {
+					p = q;
+				}
+			} else {
+				q = p;
+				while(isalnum(*q)) {
+					q++;
+				}
+				dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */
+					+ QRinput_estimateBitsModeAn(q - p) + 4 + la
+					- QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */;
+				if(dif < 0) {
+					break;
+				} else {
+					p = q;
+				}
+			}
+		} else {
+			p++;
+		}
+	}
+
+	QRinput_append(input, QR_MODE_8, p - string, (unsigned char *)string);
+	return p - string;
+}
+
+void Split_splitStringToQRinput(const char *string, QRinput *input,
+		int version, QRencodeMode hint)
+{
+	int length;
+	QRencodeMode mode;
+
+	if(*string == '\0') return;
+
+	mode = QRinput_identifyMode(string);
+	if(mode == QR_MODE_NUM) {
+		length = Split_eatNum(string, input, version, hint);
+	} else if(mode == QR_MODE_AN) {
+		length = Split_eatAn(string, input, version, hint);
+	} else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
+		length = Split_eatKanji(string, input, version, hint);
+	} else {
+		length = Split_eat8(string, input, version, hint);
+	}
+	if(length == 0) return;
+	/* Of course this tail recursion could be optimized! Believe gcc. */
+	Split_splitStringToQRinput(&string[length], input, hint, version);
+}
+
diff --git a/split.h b/split.h
new file mode 100644
index 0000000000..de45bbc8a7
--- /dev/null
+++ b/split.h
@@ -0,0 +1,34 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Input data splitter.
+ * Copyright (C) 2006 Kentaro Fukuchi 
+ *
+ * The following data / specifications are taken from
+ * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
+ *  or
+ * "Automatic identification and data capture techniques -- 
+ *  QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SPLIT_H__
+#define __SPLIT_H__
+
+#include "qrencode.h"
+void Split_splitStringToQRinput(const char *string, QRinput *input,
+		int version, QRencodeMode hint);
+#endif /* __SPLIT_H__ */
diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index 0000842e16..c6cd509a5b 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -4,6 +4,8 @@
 #include "../qrencode_inner.h"
 #include "../qrspec.h"
 #include "../qrinput.h"
+#include "../mask.h"
+#include "../split.h"
 
 int inputSize(QRinput *input)
 {
@@ -98,7 +100,7 @@ void print_filler(void)
 	unsigned char *frame;
 
 	width = QRspec_getWidth(version);
-	frame = QRinput_fillerTest(version);
+	frame = FrameFiller_fillerTest(version);
 
 	for(y=0; yhead;
 	if(list->mode != QR_MODE_NUM || list->size != 4) {
 		err++;
@@ -489,7 +491,7 @@ void test_split2(void)
 	err = 0;
 	testStart("Split test: single typed strings (num2)");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput("12345678901234567890", input, 0, QR_MODE_KANJI);
+	Split_splitStringToQRinput("12345678901234567890", input, 0, QR_MODE_KANJI);
 	list = input->head;
 	if(list->mode != QR_MODE_NUM || list->size != 20) {
 		err++;
@@ -509,7 +511,7 @@ void test_split3(void)
 
 	testStart("Split test: single typed strings (an)");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8);
+	Split_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8);
 	list = input->head;
 	if(list->mode != QR_MODE_AN || list->size != 5) {
 		err++;
@@ -523,7 +525,7 @@ void test_split3(void)
 	err = 0;
 	testStart("Split test: num + an");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI);
+	Split_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI);
 	list = input->head;
 	if(list->mode != QR_MODE_AN || list->size != 9) {
 		err++;
@@ -537,7 +539,7 @@ void test_split3(void)
 	err = 0;
 	testStart("Split test: an + num + an");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI);
+	Split_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI);
 	list = input->head;
 	if(list->mode != QR_MODE_AN || list->size != 7) {
 		err++;
@@ -560,7 +562,7 @@ void test_split4(void)
 
 	testStart("Split test: an and num entries");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput(CHUNKA/**/CHUNKB, input, 0, QR_MODE_8);
+	Split_splitStringToQRinput(CHUNKA/**/CHUNKB, input, 0, QR_MODE_8);
 	i1 = QRinput_new();
 	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKA/**/CHUNKB);
 	i2 = QRinput_new();
@@ -577,7 +579,7 @@ void test_split4(void)
 
 	testStart("Split test: num and an entries");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput(CHUNKB/**/CHUNKA, input, 0, QR_MODE_8);
+	Split_splitStringToQRinput(CHUNKB/**/CHUNKA, input, 0, QR_MODE_8);
 	i1 = QRinput_new();
 	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKB/**/CHUNKA);
 	i2 = QRinput_new();
@@ -594,7 +596,7 @@ void test_split4(void)
 
 	testStart("Split test: num and an entries (should be splitted)");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput(CHUNKC/**/CHUNKA, input, 0, QR_MODE_8);
+	Split_splitStringToQRinput(CHUNKC/**/CHUNKA, input, 0, QR_MODE_8);
 	i1 = QRinput_new();
 	QRinput_append(i1, QR_MODE_AN, 18, (unsigned char *)CHUNKC/**/CHUNKA);
 	i2 = QRinput_new();
@@ -618,7 +620,7 @@ void test_split5(void)
 
 	testStart("Split test: bit, an, bit, num");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_8);
+	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_8);
 	list = input->head;
 	if(list->mode != QR_MODE_8 || list->size != 2) {
 		printf("first item is not 8bit.\n");
@@ -673,7 +675,7 @@ void test_split6(void)
 
 	testStart("Split test: kanji, an, kanji, num");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_KANJI);
+	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_KANJI);
 	list = input->head;
 	if(list->mode != QR_MODE_KANJI || list->size != 2) {
 		printf("first item is not kanji.\n");
@@ -728,7 +730,7 @@ void test_split7(void)
 
 	testStart("Split test: an and num as bits");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput("\x82\xd9""abcde\x82\xb0""12345", input, 0, QR_MODE_8);
+	Split_splitStringToQRinput("\x82\xd9""abcde\x82\xb0""12345", input, 0, QR_MODE_8);
 	list = input->head;
 	if(list->mode != QR_MODE_8 || list->size != 9) {
 		printf("first item is not 8bit.\n");
@@ -762,7 +764,7 @@ void test_split8(void)
 
 	testStart("Split test: terminated with a half of kanji code");
 	input = QRinput_new();
-	QRcode_splitStringToQRinput("\x82\xd9""abcdefgh\x82", input, 0, QR_MODE_KANJI);
+	Split_splitStringToQRinput("\x82\xd9""abcdefgh\x82", input, 0, QR_MODE_KANJI);
 	list = input->head;
 	if(list->mode != QR_MODE_KANJI || list->size != 2) {
 		printf("first item is not kanji.\n");
diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c
index 761e21f9e0..b2eb9f8b39 100644
--- a/tests/test_qrinput.c
+++ b/tests/test_qrinput.c
@@ -3,6 +3,7 @@
 #include "common.h"
 #include "../qrinput.h"
 #include "../qrencode_inner.h"
+#include "../split.h"
 
 void test_encodeKanji(void)
 {
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index f1bc6c803c..1ef915e348 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -6,6 +6,7 @@
 #include "../qrencode_inner.h"
 #include "../qrspec.h"
 #include "../qrinput.h"
+#include "../split.h"
 
 SDL_Surface *screen = NULL;
 
@@ -27,7 +28,7 @@ void view_simple(const char *str)
 	SDL_Rect rect;
 
 	stream = QRinput_new();
-	QRcode_splitStringToQRinput(str, stream, 0, QR_MODE_KANJI);
+	Split_splitStringToQRinput(str, stream, 0, QR_MODE_KANJI);
 
 
 	while(flag) {
-- 
cgit 0.0.5-2-1-g0f52


From 401e3f132d41730c312c79de109e8b585727edaf Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 18 Dec 2006 14:23:43 +0000
Subject:

---
 mask.c                | 2 +-
 qrencode.c            | 4 ++--
 qrencode_inner.h      | 2 +-
 tests/test_qrencode.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/mask.c b/mask.c
index 728d3fd7df..327bc47f44 100644
--- a/mask.c
+++ b/mask.c
@@ -251,7 +251,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
 		}
 	}
 
-	QRinput_writeFormatInformation(width, bestMask, bestMaskNum, level);
+	QRcode_writeFormatInformation(width, bestMask, bestMaskNum, level);
 
 	return bestMask;
 }
diff --git a/qrencode.c b/qrencode.c
index 73bef3ab44..12191e15b9 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -297,7 +297,7 @@ unsigned char *FrameFiller_fillerTest(int version)
  * Format information
  *****************************************************************************/
 
-void QRinput_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level)
+void QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level)
 {
 	unsigned int format;
 	unsigned char v;
@@ -397,7 +397,7 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask
 		masked = Mask_mask(width, frame, level);
 	} else {
 		masked = Mask_makeMask(width, frame, mask);
-		QRinput_writeFormatInformation(width, masked, mask, QRinput_getErrorCorrectionLevel(input));
+		QRcode_writeFormatInformation(width, masked, mask, QRinput_getErrorCorrectionLevel(input));
 	}
 	qrcode = QRcode_new(version, width, masked);
 
diff --git a/qrencode_inner.h b/qrencode_inner.h
index d1cb163ab3..ebce5ab4ea 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -77,7 +77,7 @@ extern unsigned char *FrameFiller_fillerTest(int version);
 /******************************************************************************
  * Format information
  *****************************************************************************/
-extern void QRinput_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
+extern void QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
 
 extern QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask);
 #endif /* __QRENCODE_INNER_H__ */
diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index c6cd509a5b..92b94265ff 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -184,7 +184,7 @@ void test_format(void)
 	width = QRspec_getWidth(1);
 	frame = QRspec_newFrame(1);
 	format = QRspec_getFormatInfo(1, QR_ECLEVEL_L);
-	QRinput_writeFormatInformation(width, frame, 1, QR_ECLEVEL_L);
+	QRcode_writeFormatInformation(width, frame, 1, QR_ECLEVEL_L);
 	decode = 0;
 	for(i=0; i<8; i++) {
 		decode = decode << 1;
-- 
cgit 0.0.5-2-1-g0f52


From 231260ec3657843e752722da6bd8d9964277c182 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Tue, 26 Dec 2006 16:06:42 +0000
Subject:

---
 TODO       |  2 ++
 qrenc.c    | 20 ++++++++++++++++++--
 qrencode.c | 12 ++++++++++++
 qrencode.h |  6 ++++++
 split.c    |  1 -
 5 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/TODO b/TODO
index 6b918633d2..9db496bba4 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,8 @@
 Thread unsafe.
 Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe.
 
+--
+
 This package contains
 
 *.c and *.h files (total):  5422 lines, 131476 bytes.
diff --git a/qrenc.c b/qrenc.c
index eb12227ae5..2bf5fbca45 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -26,6 +26,7 @@
 
 #include "qrencode.h"
 
+static int casesensitive = 0;
 static int kanji = 0;
 static int version = 0;
 static int size = 3;
@@ -39,7 +40,8 @@ enum {
 	O_VERSION,
 	O_LEVEL,
 	O_MARGIN,
-	O_KANJI
+	O_KANJI,
+	O_CASE
 };
 
 const struct option options[] = {
@@ -50,6 +52,7 @@ const struct option options[] = {
 	{"v", required_argument, NULL, O_VERSION},
 	{"m", required_argument, NULL, O_MARGIN},
 	{"k", no_argument      , NULL, O_KANJI},
+	{"c", no_argument      , NULL, O_CASE},
 	{NULL, 0, NULL, 0}
 };
 
@@ -68,6 +71,8 @@ void usage(void)
 "  -v NUMBER    specify the version of the symbol. (default=auto)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
+"  -c           distinguish between uppercase and lowercase of a letter. All\n"
+"               of Alphabet letters will be encoded in 8-bit mode.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
 "               standard input.\n",
 VERSION
@@ -99,13 +104,21 @@ char *readStdin(void)
 QRcode *encode(const char *intext)
 {
 	QRencodeMode hint;
+	QRcode *code;
 
 	if(kanji) {
 		hint = QR_MODE_KANJI;
 	} else {
 		hint = QR_MODE_8;
 	}
-	return QRcode_encodeString(intext, version, level, hint);
+
+	if(casesensitive) {
+		code = QRcode_encodeStringCase(intext, version, level);
+	} else {
+		code = QRcode_encodeString(intext, version, level, hint);
+	}
+
+	return code;
 }
 
 void qrencode(const char *intext, const char *outfile)
@@ -275,6 +288,9 @@ int main(int argc, char **argv)
 			case O_KANJI:
 				kanji = 1;
 				break;
+			case O_CASE:
+				casesensitive = 1;
+				break;
 			default:
 				usage();
 				exit(1);
diff --git a/qrencode.c b/qrencode.c
index 12191e15b9..0bb9f0603e 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -411,6 +411,18 @@ QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level)
 	return QRcode_encodeMask(input, version, level, -1);
 }
 
+QRcode *QRcode_encodeStringCase(const char *string, int version, QRecLevel level)
+{
+	QRinput *input;
+	QRcode *code;
+
+	input = QRinput_new();
+	QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string);
+	code = QRcode_encodeInput(input, version, level);
+	QRinput_free(input);
+
+	return code;
+}
 
 QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint)
 {
diff --git a/qrencode.h b/qrencode.h
index 8d23798095..8611375a4b 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -182,6 +182,12 @@ extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level);
  */
 extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint);
 
+/**
+ * Same to QRcode_qncodeString, but case sensitive.
+ * FIXME: Currently this encodes data entirely in 8-bit mode.
+ */
+extern QRcode *QRcode_encodeStringCase(const char *string, int version, QRecLevel level);
+
 /**
  * Free the instance of QRcode class.
  * @param qrcode an instance of QRcode class.
diff --git a/split.c b/split.c
index a4881eea6a..c0d93a3189 100644
--- a/split.c
+++ b/split.c
@@ -205,4 +205,3 @@ void Split_splitStringToQRinput(const char *string, QRinput *input,
 	/* Of course this tail recursion could be optimized! Believe gcc. */
 	Split_splitStringToQRinput(&string[length], input, hint, version);
 }
-
-- 
cgit 0.0.5-2-1-g0f52


From a4101b53d0fe78128b38312c44f77f1dd0207e20 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 11 Jun 2007 18:06:37 +0000
Subject:

---
 Makefile.am | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index cdba75d29d..c810aa2aab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,8 @@ include_HEADERS = qrencode.h
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libqrencode.pc
 
-EXTRA_DIST = libqrencode.pc.in
+EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \
+			 Makefile.am tests/Makefile.am
 
 if BUILD_TOOLS
 bin_PROGRAMS = qrencode
-- 
cgit 0.0.5-2-1-g0f52


From d56b9ab110c2496b805e52b5fcb2585cde5af8a4 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 10 Dec 2007 06:47:19 +0000
Subject:

---
 Makefile.am      |  2 +-
 configure.ac     |  3 ++-
 qrencode.spec.in | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 2 deletions(-)
 create mode 100644 qrencode.spec.in

diff --git a/Makefile.am b/Makefile.am
index c810aa2aab..5dd03e7382 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,7 @@ pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libqrencode.pc
 
 EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \
-			 Makefile.am tests/Makefile.am
+			 Makefile.am tests/Makefile.am qrencode.spec.in
 
 if BUILD_TOOLS
 bin_PROGRAMS = qrencode
diff --git a/configure.ac b/configure.ac
index b65a62e429..e3789d3afc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,7 @@ AC_C_INLINE
 AC_HEADER_STDC
 
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 PKG_PROG_PKG_CONFIG
@@ -32,7 +33,7 @@ AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ])
 
 CFLAGS="-Wall $CFLAGS"
 
-AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile])
+AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec])
 
 AC_ARG_WITH([tools], [AC_HELP_STRING([--with-tools], [build utility tools [default=yes]])],
  [], [build_tools=yes])
diff --git a/qrencode.spec.in b/qrencode.spec.in
new file mode 100644
index 0000000000..5beb356076
--- /dev/null
+++ b/qrencode.spec.in
@@ -0,0 +1,67 @@
+%define ver @VERSION@
+%define rel 1
+
+Name:           qrencode
+Version:        %{ver}
+Release:        %{rel}%{?dist}
+Summary:        Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D symbology that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness.
+
+Group:          System Environment/Libraries
+License:        LGPL
+URL:            http://megaui.net/fukuchi/works/qrencode/
+Source0:        http://megaui.net/fukuchi/works/qrencode/%{name}-%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+%description
+Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Structured Append Feature, Micro QR Code, QR Code model 1.
+
+%package        devel
+Summary:        Development files for libqrencode
+Group:          Development/Libraries
+Requires:       %{name} = %{version}-%{release}
+
+%description    devel
+Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Structured Append Feature, Micro QR Code, QR Code model 1.
+
+This package contains development files for libqrencode.
+
+%prep
+%setup -q
+
+
+%build
+%configure
+make %{?_smp_mflags}
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT
+rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
+
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%doc COPYING TODO ChangeLog NEWS README
+%{_libdir}/libqrencode.so.*
+%{_bindir}/qrencode
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/qrencode.h
+%{_libdir}/libqrencode.so
+%{_libdir}/pkgconfig/libqrencode.pc
+
+%changelog
+* Tue May 15 2007 Kentaro Fukuchi  1.0.2-2
+- Summary has been synchronized to README.
+* Thu May 09 2007 Katsumi Saito  1.0.2-1
+- Initial RPM release
-- 
cgit 0.0.5-2-1-g0f52

-- 
cgit 0.0.5-2-1-g0f52


From 89fbad95cb1bd25a9102ab4f6e2e65ddcaaa7f29 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 10 Dec 2007 06:57:38 +0000
Subject: Bumped up to version 2.0.0.

---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index e3789d3afc..d3289f8838 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,8 @@
 AC_INIT(QRencode)
 
-MAJOR_VERSION=1
+MAJOR_VERSION=2
 MINOR_VERSION=0
-MICRO_VERSION=1
+MICRO_VERSION=0
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 AC_SUBST(MAJOR_VERSION)
 AC_SUBST(MINOR_VERSION)
-- 
cgit 0.0.5-2-1-g0f52


From 737580ec2ef6e3fa3cbbd5907580b23d27f6dc71 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 10 Dec 2007 07:07:54 +0000
Subject: Merged patches for 1.0.0 series.

---
 ChangeLog  | 25 ++++++++++++++++++++++++-
 NEWS       | 10 ++++++++++
 README     |  2 +-
 TODO       |  2 --
 qrenc.c    |  4 ++--
 qrencode.h |  8 ++++++++
 6 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0bb3f9a910..31b3131e95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,30 @@
-2006.12.18 Kentaro FUKUCHI 
+2007.12.10 Kentaro FUKUCHI 
+	* Merged to main trunk.
 	* mask.[ch], split.[ch]:
 	  - Masking functions and splitString functions are separated from
 	    qrencode.c.
+	* mqrspec.[ch]:
+	  - Specification of Micro QR code has been added, but not used yet.
+
+2007.03.24 Kentaro FUKUCHI 
+	* Bumped version to 1.0.2.
+
+2007.03.24 Kentaro FUKUCHI 
+	* qrencode.c (QRcode_splitStringToQRinput):
+	  - a small bug fix. (Thanks to NANKI Haruo)
+	* qrencode.h:
+	  - "extern "C"" barrier has been added for C++.
+	* test/view_qrcode.c:
+	  - a typo fix.
+
+2006.12.27 Kentaro FUKUCHI 
+	* Bumped version to 1.0.1.
+
+2006.12.27 Kentaro FUKUCHI 
+	* qrenc.c, qrencode.[ch]:
+	  - Added force 8-bit encoding mode.
+	* Makefile.am :
+	  - Automake/Autoconf files have been added to dist-package.
 
 2006.12.17 Kentaro FUKUCHI 
 	* qrencode_inner.h, qrencode.c:
diff --git a/NEWS b/NEWS
index aa1a6e8720..1d9bea431d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,16 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
+Version 1.0.2 (2007.03.24)
+--------------------------
+* A small bug fix. (Thanks to NANKI Haruo)
+* 'extern "C"' barrier has been added to qrencode.h.
+
+Version 1.0.1 (2006.12.27)
+--------------------------
+* Added "force 8-bit encoding mode".
+* Configure script finds libpng's header correctly.
+
 Version 1.0.0 (2006.12.12)
 --------------------------
 * The first public release.
diff --git a/README b/README
index 8ef0da0304..22c7fdd6be 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-libqrencode 1.0.0 - QR Code encoding library
+libqrencode 2.0.0 - QR Code encoding library
 
 GENERAL INFORMATION
 ===================
diff --git a/TODO b/TODO
index 9db496bba4..6b918633d2 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,6 @@
 Thread unsafe.
 Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe.
 
---
-
 This package contains
 
 *.c and *.h files (total):  5422 lines, 131476 bytes.
diff --git a/qrenc.c b/qrenc.c
index 2bf5fbca45..94b69800cc 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -71,8 +71,8 @@ void usage(void)
 "  -v NUMBER    specify the version of the symbol. (default=auto)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
-"  -c           distinguish between uppercase and lowercase of a letter. All\n"
-"               of Alphabet letters will be encoded in 8-bit mode.\n"
+"  -c           encode entire data in 8-bit mode. If your application is\n"
+"               case-sensitive, choose this.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
 "               standard input.\n",
 VERSION
diff --git a/qrencode.h b/qrencode.h
index 8611375a4b..888385f3ab 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -63,6 +63,10 @@
 #ifndef __QRENCODE_H__
 #define __QRENCODE_H__
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
 /**
  * Encoding mode.
  */
@@ -194,4 +198,8 @@ extern QRcode *QRcode_encodeStringCase(const char *string, int version, QRecLeve
  */
 extern void QRcode_free(QRcode *qrcode);
 
+#if defined(__cplusplus)
+}
+#endif
+
 #endif /* __QRENCODE_H__ */
-- 
cgit 0.0.5-2-1-g0f52


From 78664f377b57c38427b2d4f87dfa6eb533c2f88c Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 13 Dec 2007 07:31:10 +0000
Subject: QRcode_writeFormatInformation() now returns number of black modules.

---
 TODO                  |  2 ++
 qrencode.c            | 19 ++++++++++++++++---
 qrencode_inner.h      |  2 +-
 tests/test_qrencode.c | 17 ++++++++++++++++-
 4 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/TODO b/TODO
index 6b918633d2..9efb27f706 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,8 @@
 Thread unsafe.
 Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe.
 
+view_qrcode should support various options like qrencode.
+
 This package contains
 
 *.c and *.h files (total):  5422 lines, 131476 bytes.
diff --git a/qrencode.c b/qrencode.c
index 0bb9f0603e..a66d57445c 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -297,16 +297,22 @@ unsigned char *FrameFiller_fillerTest(int version)
  * Format information
  *****************************************************************************/
 
-void QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level)
+int QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level)
 {
 	unsigned int format;
 	unsigned char v;
 	int i;
+	int blacks = 0;
 
 	format =  QRspec_getFormatInfo(mask, level);
 
 	for(i=0; i<8; i++) {
-		v = (unsigned char)(format & 1) | 0x84;
+		if(format & 1) {
+			blacks += 2;
+			v = 0x85;
+		} else {
+			v = 0x84;
+		}
 		frame[width * 8 + width - 1 - i] = v;
 		if(i < 6) {
 			frame[width * i + 8] = v;
@@ -316,7 +322,12 @@ void QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QR
 		format= format >> 1;
 	}
 	for(i=0; i<7; i++) {
-		v = (unsigned char)(format & 1) | 0x84;
+		if(format & 1) {
+			blacks += 2;
+			v = 0x85;
+		} else {
+			v = 0x84;
+		}
 		frame[width * (width - 7 + i) + 8] = v;
 		if(i == 0) {
 			frame[width * 8 + 7] = v;
@@ -325,6 +336,8 @@ void QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QR
 		}
 		format= format >> 1;
 	}
+
+	return blacks;
 }
 
 /******************************************************************************
diff --git a/qrencode_inner.h b/qrencode_inner.h
index ebce5ab4ea..b7ff64e1dd 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -77,7 +77,7 @@ extern unsigned char *FrameFiller_fillerTest(int version);
 /******************************************************************************
  * Format information
  *****************************************************************************/
-extern void QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
+extern int QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
 
 extern QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask);
 #endif /* __QRENCODE_INNER_H__ */
diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index 92b94265ff..2540fa84b0 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -179,20 +179,26 @@ void test_format(void)
 	int width;
 	int i;
 	unsigned int decode;
+	int blacks, b1 = 0, b2 = 0;
 
 	testStart("Test format information(level L,mask 0)");
 	width = QRspec_getWidth(1);
 	frame = QRspec_newFrame(1);
 	format = QRspec_getFormatInfo(1, QR_ECLEVEL_L);
-	QRcode_writeFormatInformation(width, frame, 1, QR_ECLEVEL_L);
+	blacks = QRcode_writeFormatInformation(width, frame, 1, QR_ECLEVEL_L);
 	decode = 0;
+	for(i=0; i<15; i++) {
+		if((1< 5)] & 1;
+		if(decode & 1) b1++;
 	}
 	for(i=0; i<7; i++) {
 		decode = decode << 1;
 		decode |= frame[width * ((6 - i) + (i < 1)) + 8] & 1;
+		if(decode & 1) b1++;
 	}
 	if(decode != format) {
 		printf("Upper-left format information is invalid.\n");
@@ -204,10 +210,12 @@ void test_format(void)
 	for(i=0; i<7; i++) {
 		decode = decode << 1;
 		decode |= frame[width * (width - 1 - i) + 8] & 1;
+		if(decode & 1) b1++;
 	}
 	for(i=0; i<8; i++) {
 		decode = decode << 1;
 		decode |= frame[width * 8 + width - 8 + i] & 1;
+		if(decode & 1) b1++;
 	}
 	if(decode != format) {
 		printf("Bottom and right format information is invalid.\n");
@@ -216,6 +224,13 @@ void test_format(void)
 		return;
 	}
 
+	if(b2 != blacks || b1 != b2) {
+		printf("Number of dark modules is incorrect.\n");
+		printf("Return value: %d, dark modules in frame: %d, should be: %d\n", blacks, b1, b2);
+		testEnd(1);
+		return;
+	}
+
 	free(frame);
 
 	testEnd(0);
-- 
cgit 0.0.5-2-1-g0f52


From 9efd19c5190d097dade0efa1c58e8629ee42017d Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 13 Dec 2007 07:54:38 +0000
Subject: Mask evaluation bug fixed.

---
 mask.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mask.c b/mask.c
index 327bc47f44..dc8eea0728 100644
--- a/mask.c
+++ b/mask.c
@@ -230,6 +230,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
 		demerit = 0;
 		mask = (unsigned char *)malloc(width * width);
 		blacks = maskMakers[i](width, frame, mask);
+		blacks += QRcode_writeFormatInformation(width, mask, i, level);
 		blacks = 100 * blacks / (width * width);
 		demerit = (abs(blacks - 50) / 5) * N4;
 //		n4 = demerit;
@@ -251,7 +252,5 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
 		}
 	}
 
-	QRcode_writeFormatInformation(width, bestMask, bestMaskNum, level);
-
 	return bestMask;
 }
-- 
cgit 0.0.5-2-1-g0f52


From b429a37c6d7b7732226f21785c130e9d6581333e Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 13 Dec 2007 11:33:34 +0000
Subject: - Case-sensitive mode has been added to QRcode_encodeString(). - "-8"
 option has been added to qrenc.c. - "-c" now encodes in improved
 case-sensitive mode. - test_split*() have been moved to test_split.c.

---
 qrenc.c               |  19 ++-
 qrencode.c            |   6 +-
 qrencode.h            |   8 +-
 split.c               |  47 ++++---
 split.h               |   2 +-
 tests/Makefile.am     |   5 +-
 tests/prof_qrencode.c |   2 +-
 tests/test_qrencode.c | 360 +-------------------------------------------------
 tests/test_split.c    | 341 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/view_qrcode.c   |   2 +-
 10 files changed, 397 insertions(+), 395 deletions(-)
 create mode 100644 tests/test_split.c

diff --git a/qrenc.c b/qrenc.c
index 94b69800cc..245e7544c2 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -27,6 +27,7 @@
 #include "qrencode.h"
 
 static int casesensitive = 0;
+static int eightbit = 0;
 static int kanji = 0;
 static int version = 0;
 static int size = 3;
@@ -41,7 +42,8 @@ enum {
 	O_LEVEL,
 	O_MARGIN,
 	O_KANJI,
-	O_CASE
+	O_CASE,
+	O_8BIT,
 };
 
 const struct option options[] = {
@@ -53,6 +55,7 @@ const struct option options[] = {
 	{"m", required_argument, NULL, O_MARGIN},
 	{"k", no_argument      , NULL, O_KANJI},
 	{"c", no_argument      , NULL, O_CASE},
+	{"8", no_argument      , NULL, O_8BIT},
 	{NULL, 0, NULL, 0}
 };
 
@@ -71,8 +74,9 @@ void usage(void)
 "  -v NUMBER    specify the version of the symbol. (default=auto)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
-"  -c           encode entire data in 8-bit mode. If your application is\n"
-"               case-sensitive, choose this.\n"
+"  -c           encode alphabet characters in 8-bit mode. If your application\n"
+"               is case-sensitive, choose this.\n"
+"  -8           encode entire data in 8-bit mode. -c and -k will be ignored.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
 "               standard input.\n",
 VERSION
@@ -112,10 +116,10 @@ QRcode *encode(const char *intext)
 		hint = QR_MODE_8;
 	}
 
-	if(casesensitive) {
-		code = QRcode_encodeStringCase(intext, version, level);
+	if(eightbit) {
+		code = QRcode_encodeString8bit(intext, version, level);
 	} else {
-		code = QRcode_encodeString(intext, version, level, hint);
+		code = QRcode_encodeString(intext, version, level, hint, casesensitive);
 	}
 
 	return code;
@@ -291,6 +295,9 @@ int main(int argc, char **argv)
 			case O_CASE:
 				casesensitive = 1;
 				break;
+			case O_8BIT:
+				eightbit = 1;
+				break;
 			default:
 				usage();
 				exit(1);
diff --git a/qrencode.c b/qrencode.c
index a66d57445c..050eca4a98 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -424,7 +424,7 @@ QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level)
 	return QRcode_encodeMask(input, version, level, -1);
 }
 
-QRcode *QRcode_encodeStringCase(const char *string, int version, QRecLevel level)
+QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level)
 {
 	QRinput *input;
 	QRcode *code;
@@ -437,7 +437,7 @@ QRcode *QRcode_encodeStringCase(const char *string, int version, QRecLevel level
 	return code;
 }
 
-QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint)
+QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
 {
 	QRinput *input;
 	QRcode *code;
@@ -447,7 +447,7 @@ QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QR
 	}
 
 	input = QRinput_new();
-	Split_splitStringToQRinput(string, input, version, hint);
+	Split_splitStringToQRinput(string, input, version, hint, casesensitive);
 	code = QRcode_encodeInput(input, version, level);
 	QRinput_free(input);
 
diff --git a/qrencode.h b/qrencode.h
index 888385f3ab..c4de380584 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -181,16 +181,16 @@ extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level);
  *             encoded as Shif-JIS characters. If QR_MODE_8 is given, all of
  *             non-alphanumerical characters will be encoded as is. If you want
  *             to embed UTF-8 string, choose this.
+ * @param casesensitive case-sensitive(1) or not(0).
  * @return an instance of QRcode class. The version of the result QRcode may
  *         be larger than the designated version.
  */
-extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint);
+extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
 
 /**
- * Same to QRcode_qncodeString, but case sensitive.
- * FIXME: Currently this encodes data entirely in 8-bit mode.
+ * Same to QRcode_qncodeString, but encode whole data in 8-bit mode.
  */
-extern QRcode *QRcode_encodeStringCase(const char *string, int version, QRecLevel level);
+extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level);
 
 /**
  * Free the instance of QRcode class.
diff --git a/split.c b/split.c
index c0d93a3189..6c334c9fba 100644
--- a/split.c
+++ b/split.c
@@ -33,12 +33,12 @@
 #define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10)
 #define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0)
 
-static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint);
+static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive);
+static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive);
+static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive);
+static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive);
 
-static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint)
+static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive)
 {
 	const char *p;
 	int run;
@@ -57,15 +57,15 @@ static int Split_eatNum(const char *string, QRinput *input, int version, QRencod
 			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
 			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
 		if(dif > 0) {
-			return Split_eat8(string, input, version, hint);
+			return Split_eat8(string, input, version, hint, casesensitive);
 		}
 	}
-	if(isalnum(*p)) {
+	if(isalnum(*p) && !casesensitive) {
 		dif = QRinput_estimateBitsModeNum(run) + 4 + ln
 			+ QRinput_estimateBitsModeAn(1) /* + 4 + la */
 			- QRinput_estimateBitsModeAn(run + 1) /* - 4 - la */;
 		if(dif > 0) {
-			return Split_eatAn(string, input, version, hint);
+			return Split_eatAn(string, input, version, hint, casesensitive);
 		}
 	}
 
@@ -73,13 +73,17 @@ static int Split_eatNum(const char *string, QRinput *input, int version, QRencod
 	return run;
 }
 
-static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint)
+static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive)
 {
 	const char *p, *q;
 	int run;
 	int dif;
 	int la, ln;
 
+	if(casesensitive) {
+		return Split_eat8(string, input, version, hint, casesensitive);
+	}
+
 	la = QRspec_lengthIndicator(QR_MODE_AN, version);
 	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
 
@@ -110,7 +114,7 @@ static int Split_eatAn(const char *string, QRinput *input, int version, QRencode
 			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
 			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
 		if(dif > 0) {
-			return Split_eat8(string, input, version, hint);
+			return Split_eat8(string, input, version, hint, casesensitive);
 		}
 	}
 
@@ -118,7 +122,7 @@ static int Split_eatAn(const char *string, QRinput *input, int version, QRencode
 	return run;
 }
 
-static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint)
+static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive)
 {
 	const char *p;
 
@@ -130,7 +134,7 @@ static int Split_eatKanji(const char *string, QRinput *input, int version, QRenc
 	return p - string;
 }
 
-static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint)
+static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive)
 {
 	const char *p, *q;
 	QRencodeMode mode;
@@ -160,7 +164,7 @@ static int Split_eat8(const char *string, QRinput *input, int version, QRencodeM
 				} else {
 					p = q;
 				}
-			} else {
+			} else if(!casesensitive) {
 				q = p;
 				while(isalnum(*q)) {
 					q++;
@@ -173,6 +177,8 @@ static int Split_eat8(const char *string, QRinput *input, int version, QRencodeM
 				} else {
 					p = q;
 				}
+			} else {
+				p++;
 			}
 		} else {
 			p++;
@@ -184,7 +190,7 @@ static int Split_eat8(const char *string, QRinput *input, int version, QRencodeM
 }
 
 void Split_splitStringToQRinput(const char *string, QRinput *input,
-		int version, QRencodeMode hint)
+		int version, QRencodeMode hint, int casesensitive)
 {
 	int length;
 	QRencodeMode mode;
@@ -193,15 +199,14 @@ void Split_splitStringToQRinput(const char *string, QRinput *input,
 
 	mode = QRinput_identifyMode(string);
 	if(mode == QR_MODE_NUM) {
-		length = Split_eatNum(string, input, version, hint);
-	} else if(mode == QR_MODE_AN) {
-		length = Split_eatAn(string, input, version, hint);
+		length = Split_eatNum(string, input, version, hint, casesensitive);
+	} else if(mode == QR_MODE_AN && !casesensitive) {
+		length = Split_eatAn(string, input, version, hint, casesensitive);
 	} else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
-		length = Split_eatKanji(string, input, version, hint);
+		length = Split_eatKanji(string, input, version, hint, casesensitive);
 	} else {
-		length = Split_eat8(string, input, version, hint);
+		length = Split_eat8(string, input, version, hint, casesensitive);
 	}
 	if(length == 0) return;
-	/* Of course this tail recursion could be optimized! Believe gcc. */
-	Split_splitStringToQRinput(&string[length], input, hint, version);
+	Split_splitStringToQRinput(&string[length], input, hint, version, casesensitive);
 }
diff --git a/split.h b/split.h
index de45bbc8a7..a7b66d6568 100644
--- a/split.h
+++ b/split.h
@@ -30,5 +30,5 @@
 
 #include "qrencode.h"
 void Split_splitStringToQRinput(const char *string, QRinput *input,
-		int version, QRencodeMode hint);
+		int version, QRencodeMode hint, int casesensitive);
 #endif /* __SPLIT_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 119781d115..e2f824ce67 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,7 +4,7 @@ endif
 
 noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \
 				  test_qrspec test_rs test_qrencode prof_qrencode \
-				  test_mqrspec \
+				  test_mqrspec test_split\
 				  $(sdlPROGRAMS)
 
 test_qrinput_SOURCES = test_qrinput.c common.h
@@ -28,6 +28,9 @@ test_rs_LDADD = ../libqrencode.la
 test_qrencode_SOURCES = test_qrencode.c common.h
 test_qrencode_LDADD = ../libqrencode.la
 
+test_split_SOURCES = test_split.c common.h
+test_split_LDADD = ../libqrencode.la
+
 prof_qrencode_SOURCES = prof_qrencode.c
 prof_qrencode_LDADD = ../libqrencode.la
 
diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c
index 93ea2869ce..1f89db65fa 100644
--- a/tests/prof_qrencode.c
+++ b/tests/prof_qrencode.c
@@ -30,7 +30,7 @@ void prof_ver1to10(void)
 	timerStart("Version 1 - 10");
 	for(i=0; i<500; i++) {
 		for(version = 0; version < 11; version++) {
-			code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8);
+			code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0);
 			QRcode_free(code);
 		}
 	}
diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index 2540fa84b0..c1b8a45d8d 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -5,7 +5,6 @@
 #include "../qrspec.h"
 #include "../qrinput.h"
 #include "../mask.h"
-#include "../split.h"
 
 int inputSize(QRinput *input)
 {
@@ -404,7 +403,7 @@ void test_encode2(void)
 	QRcode *qrcode;
 
 	testStart("Test encode (2-H) (no padding test)");
-	qrcode = QRcode_encodeString("abcdefghijk123456789012", 0, QR_ECLEVEL_H, QR_MODE_8);
+	qrcode = QRcode_encodeString("abcdefghijk123456789012", 0, QR_ECLEVEL_H, QR_MODE_8, 0);
 	testEndExp(qrcode->version == 2);
 	QRcode_free(qrcode);
 }
@@ -415,7 +414,7 @@ void test_encode3(void)
 	QRinput *input;
 
 	testStart("Compare encodeString and encodeInput");
-	code1 = QRcode_encodeString("0123456", 0, QR_ECLEVEL_L, QR_MODE_8);
+	code1 = QRcode_encodeString("0123456", 0, QR_ECLEVEL_L, QR_MODE_8, 0);
 	input = QRinput_new();
 	QRinput_append(input, QR_MODE_NUM, 7, (unsigned char *)"0123456");
 	code2 = QRcode_encodeInput(input, 0, QR_ECLEVEL_L);
@@ -437,7 +436,7 @@ void test_encodeTooLong(void)
 	memset(data + 4295, '0', 4);
 	data[4299] = '\0';
 
-	code = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8);
+	code = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 0);
 	testEndExp(code == NULL);
 
 	if(code != NULL) {
@@ -470,351 +469,6 @@ void print_encode(void)
 	QRcode_free(qrcode);
 }
 
-void test_split1(void)
-{
-	QRinput *input;
-	BitStream *stream;
-
-	testStart("Split test: null string");
-	input = QRinput_new();
-	Split_splitStringToQRinput("", input, 0, QR_MODE_8);
-	stream = QRinput_mergeBitStream(input);
-	testEndExp(BitStream_size(stream) == 0);
-	QRinput_free(input);
-	BitStream_free(stream);
-}
-
-void test_split2(void)
-{
-	QRinput *input;
-	QRinput_List *list;
-	int err = 0;
-
-	testStart("Split test: single typed strings (num)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("0123", input, 0, QR_MODE_8);
-	list = input->head;
-	if(list->mode != QR_MODE_NUM || list->size != 4) {
-		err++;
-	}
-	if(list->next != NULL) {
-		err++;
-	}
-	testEnd(err);
-	QRinput_free(input);
-
-	err = 0;
-	testStart("Split test: single typed strings (num2)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("12345678901234567890", input, 0, QR_MODE_KANJI);
-	list = input->head;
-	if(list->mode != QR_MODE_NUM || list->size != 20) {
-		err++;
-	}
-	if(list->next != NULL) {
-		err++;
-	}
-	testEnd(err);
-	QRinput_free(input);
-}
-
-void test_split3(void)
-{
-	QRinput *input;
-	QRinput_List *list;
-	int err = 0;
-
-	testStart("Split test: single typed strings (an)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8);
-	list = input->head;
-	if(list->mode != QR_MODE_AN || list->size != 5) {
-		err++;
-	}
-	if(list->next != NULL) {
-		err++;
-	}
-	testEnd(err);
-	QRinput_free(input);
-
-	err = 0;
-	testStart("Split test: num + an");
-	input = QRinput_new();
-	Split_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI);
-	list = input->head;
-	if(list->mode != QR_MODE_AN || list->size != 9) {
-		err++;
-	}
-	if(list->next != NULL) {
-		err++;
-	}
-	testEnd(err);
-	QRinput_free(input);
-
-	err = 0;
-	testStart("Split test: an + num + an");
-	input = QRinput_new();
-	Split_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI);
-	list = input->head;
-	if(list->mode != QR_MODE_AN || list->size != 7) {
-		err++;
-	}
-	if(list->next != NULL) {
-		err++;
-	}
-	testEnd(err);
-	QRinput_free(input);
-}
-
-void test_split4(void)
-{
-	QRinput *input;
-	QRinput *i1, *i2;
-	int s1, s2, size;
-#define CHUNKA "abcdefghijk"
-#define CHUNKB "123456"
-#define CHUNKC "1234567"
-
-	testStart("Split test: an and num entries");
-	input = QRinput_new();
-	Split_splitStringToQRinput(CHUNKA/**/CHUNKB, input, 0, QR_MODE_8);
-	i1 = QRinput_new();
-	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKA/**/CHUNKB);
-	i2 = QRinput_new();
-	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
-	QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB);
-
-	size = inputSize(input);
-	s1 = inputSize(i1);
-	s2 = inputSize(i2);
-	testEndExp(size == ((s1 < s2)?s1:s2));
-	QRinput_free(input);
-	QRinput_free(i1);
-	QRinput_free(i2);
-
-	testStart("Split test: num and an entries");
-	input = QRinput_new();
-	Split_splitStringToQRinput(CHUNKB/**/CHUNKA, input, 0, QR_MODE_8);
-	i1 = QRinput_new();
-	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKB/**/CHUNKA);
-	i2 = QRinput_new();
-	QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB);
-	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
-
-	size = inputSize(input);
-	s1 = inputSize(i1);
-	s2 = inputSize(i2);
-	testEndExp(size == ((s1 < s2)?s1:s2));
-	QRinput_free(input);
-	QRinput_free(i1);
-	QRinput_free(i2);
-
-	testStart("Split test: num and an entries (should be splitted)");
-	input = QRinput_new();
-	Split_splitStringToQRinput(CHUNKC/**/CHUNKA, input, 0, QR_MODE_8);
-	i1 = QRinput_new();
-	QRinput_append(i1, QR_MODE_AN, 18, (unsigned char *)CHUNKC/**/CHUNKA);
-	i2 = QRinput_new();
-	QRinput_append(i2, QR_MODE_NUM, 7, (unsigned char *)CHUNKC);
-	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
-
-	size = inputSize(input);
-	s1 = inputSize(i1);
-	s2 = inputSize(i2);
-	testEndExp(size == ((s1 < s2)?s1:s2));
-	QRinput_free(input);
-	QRinput_free(i1);
-	QRinput_free(i2);
-}
-
-void test_split5(void)
-{
-	QRinput *input;
-	QRinput_List *list;
-	int err = 0;
-
-	testStart("Split test: bit, an, bit, num");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_8);
-	list = input->head;
-	if(list->mode != QR_MODE_8 || list->size != 2) {
-		printf("first item is not 8bit.\n");
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no second item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_AN || list->size != 11) {
-		printf("second item is not an: %d %d\n", list->mode, list->size);
-		printf("%s\n", list->data);
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no third item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_8 || list->size != 2) {
-		printf("third item is not an.\n");
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no fourth item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_NUM || list->size != 6) {
-		printf("fourth item is not num.\n");
-		err++;
-	}
-	if(list->next != NULL) {
-		printf("not terminated.\n");
-		err++;
-		goto EXIT;
-	}
-EXIT:
-	testEnd(err);
-	QRinput_free(input);
-}
-
-void test_split6(void)
-{
-	QRinput *input;
-	QRinput_List *list;
-	int err = 0;
-
-	testStart("Split test: kanji, an, kanji, num");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_KANJI);
-	list = input->head;
-	if(list->mode != QR_MODE_KANJI || list->size != 2) {
-		printf("first item is not kanji.\n");
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no second item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_AN || list->size != 11) {
-		printf("second item is not an: %d %d\n", list->mode, list->size);
-		printf("%s\n", list->data);
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no third item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_KANJI || list->size != 2) {
-		printf("third item is not kanji.\n");
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no fourth item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_NUM || list->size != 6) {
-		printf("fourth item is not num.\n");
-		err++;
-	}
-	if(list->next != NULL) {
-		printf("not terminated.\n");
-		err++;
-		goto EXIT;
-	}
-EXIT:
-	testEnd(err);
-	QRinput_free(input);
-}
-
-void test_split7(void)
-{
-	QRinput *input;
-	QRinput_List *list;
-	int err = 0;
-
-	testStart("Split test: an and num as bits");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x82\xd9""abcde\x82\xb0""12345", input, 0, QR_MODE_8);
-	list = input->head;
-	if(list->mode != QR_MODE_8 || list->size != 9) {
-		printf("first item is not 8bit.\n");
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no second item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_NUM || list->size != 5) {
-		printf("second item is not num: %d %d\n", list->mode, list->size);
-		err++;
-	}
-	if(list->next != NULL) {
-		printf("not terminated.\n");
-		err++;
-		goto EXIT;
-	}
-EXIT:
-	testEnd(err);
-	QRinput_free(input);
-}
-
-void test_split8(void)
-{
-	QRinput *input;
-	QRinput_List *list;
-	int err = 0;
-
-	testStart("Split test: terminated with a half of kanji code");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x82\xd9""abcdefgh\x82", input, 0, QR_MODE_KANJI);
-	list = input->head;
-	if(list->mode != QR_MODE_KANJI || list->size != 2) {
-		printf("first item is not kanji.\n");
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no second item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_AN || list->size != 8) {
-		printf("second item is not an: %d %d\n", list->mode, list->size);
-		err++;
-	}
-	if(list->next == NULL) {
-		printf("no third item.\n");
-		err++;
-		goto EXIT;
-	}
-	list = list->next;
-	if(list->mode != QR_MODE_8 || list->size != 1) {
-		printf("third item is not bits: %d %d\n", list->mode, list->size);
-		err++;
-	}
-	if(list->next != NULL) {
-		printf("not terminated.\n");
-		err++;
-		goto EXIT;
-	}
-EXIT:
-	testEnd(err);
-	QRinput_free(input);
-}
-
 int main(int argc, char **argv)
 {
 	test_iterate();
@@ -827,14 +481,6 @@ int main(int argc, char **argv)
 	test_eval2();
 	test_eval3();
 //	print_encode();
-	test_split1();
-	test_split2();
-	test_split3();
-	test_split4();
-	test_split5();
-	test_split6();
-	test_split7();
-	test_split8();
 	test_encode();
 	test_encode2();
 	test_encode3();
diff --git a/tests/test_split.c b/tests/test_split.c
new file mode 100644
index 0000000000..2d5fe29707
--- /dev/null
+++ b/tests/test_split.c
@@ -0,0 +1,341 @@
+#include 
+#include 
+#include 
+#include "common.h"
+#include "../qrencode_inner.h"
+#include "../qrspec.h"
+#include "../qrinput.h"
+#include "../mask.h"
+#include "../split.h"
+
+static int inputTest(QRinput_List *list, const char *fmt, ...)
+{
+	va_list ap;
+	int size;
+	QRencodeMode mode;
+	int i, err = 0;
+
+	va_start(ap, fmt);
+	i = 1;
+	while(*fmt) {
+		if(list == NULL) {
+			err = 1;
+			break;
+		}
+		size = va_arg(ap, int);
+		if(list->size != size) {
+			err = 1;
+			break;
+		}
+
+		switch(*fmt++) {
+		case 'n':
+			mode = QR_MODE_NUM;
+			break;
+		case 'a':
+			mode = QR_MODE_AN;
+			break;
+		case 'k':
+			mode = QR_MODE_KANJI;
+			break;
+		case '8':
+			mode = QR_MODE_8;
+			break;
+		default:
+			return -1;
+			break;
+		}
+		if(list->mode != mode) {
+			err = 1;
+			break;
+		}
+		list = list->next;
+		i++;
+	}
+	va_end(ap);
+	if(list != NULL) {
+		err = 1;
+	}
+	if(err) {
+		return -i;
+	}
+	return 0;
+}
+
+int inputSize(QRinput *input)
+{
+	BitStream *bstream;
+	int size;
+
+	bstream = QRinput_mergeBitStream(input);
+	size = BitStream_size(bstream);
+	BitStream_free(bstream);
+
+	return size;
+}
+
+void test_split1(void)
+{
+	QRinput *input;
+	BitStream *stream;
+
+	testStart("Split test: null string");
+	input = QRinput_new();
+	Split_splitStringToQRinput("", input, 0, QR_MODE_8, 0);
+	stream = QRinput_mergeBitStream(input);
+	testEndExp(BitStream_size(stream) == 0);
+	QRinput_free(input);
+	BitStream_free(stream);
+}
+
+void test_split2(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: single typed strings (num)");
+	input = QRinput_new();
+	Split_splitStringToQRinput("0123", input, 0, QR_MODE_8, 0);
+	list = input->head;
+	if(inputTest(list, "n", 4)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+
+	err = 0;
+	testStart("Split test: single typed strings (num2)");
+	input = QRinput_new();
+	Split_splitStringToQRinput("12345678901234567890", input, 0, QR_MODE_KANJI, 0);
+	list = input->head;
+	if(inputTest(list, "n", 20)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
+void test_split3(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: single typed strings (an)");
+	input = QRinput_new();
+	Split_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8, 0);
+	list = input->head;
+	if(inputTest(list, "a", 5)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+
+	err = 0;
+	testStart("Split test: num + an");
+	input = QRinput_new();
+	Split_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI, 0);
+	list = input->head;
+	if(inputTest(list, "a", 9)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+
+	err = 0;
+	testStart("Split test: an + num + an");
+	input = QRinput_new();
+	Split_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI, 0);
+	list = input->head;
+	if(inputTest(list, "a", 7)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
+void test_split4(void)
+{
+	QRinput *input;
+	QRinput *i1, *i2;
+	int s1, s2, size;
+#define CHUNKA "abcdefghijk"
+#define CHUNKB "123456"
+#define CHUNKC "1234567"
+
+	testStart("Split test: an and num entries");
+	input = QRinput_new();
+	Split_splitStringToQRinput(CHUNKA/**/CHUNKB, input, 0, QR_MODE_8, 0);
+	i1 = QRinput_new();
+	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKA/**/CHUNKB);
+	i2 = QRinput_new();
+	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
+	QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB);
+
+	size = inputSize(input);
+	s1 = inputSize(i1);
+	s2 = inputSize(i2);
+	testEndExp(size == ((s1 < s2)?s1:s2));
+	QRinput_free(input);
+	QRinput_free(i1);
+	QRinput_free(i2);
+
+	testStart("Split test: num and an entries");
+	input = QRinput_new();
+	Split_splitStringToQRinput(CHUNKB/**/CHUNKA, input, 0, QR_MODE_8, 0);
+	i1 = QRinput_new();
+	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKB/**/CHUNKA);
+	i2 = QRinput_new();
+	QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB);
+	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
+
+	size = inputSize(input);
+	s1 = inputSize(i1);
+	s2 = inputSize(i2);
+	testEndExp(size == ((s1 < s2)?s1:s2));
+	QRinput_free(input);
+	QRinput_free(i1);
+	QRinput_free(i2);
+
+	testStart("Split test: num and an entries (should be splitted)");
+	input = QRinput_new();
+	Split_splitStringToQRinput(CHUNKC/**/CHUNKA, input, 0, QR_MODE_8, 0);
+	i1 = QRinput_new();
+	QRinput_append(i1, QR_MODE_AN, 18, (unsigned char *)CHUNKC/**/CHUNKA);
+	i2 = QRinput_new();
+	QRinput_append(i2, QR_MODE_NUM, 7, (unsigned char *)CHUNKC);
+	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
+
+	size = inputSize(input);
+	s1 = inputSize(i1);
+	s2 = inputSize(i2);
+	testEndExp(size == ((s1 < s2)?s1:s2));
+	QRinput_free(input);
+	QRinput_free(i1);
+	QRinput_free(i2);
+}
+
+void test_split5(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: bit, an, bit, num");
+	input = QRinput_new();
+	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_8, 0);
+	list = input->head;
+	if(inputTest(list, "8a8n", 2, 11, 2, 6)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
+void test_split6(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: kanji, an, kanji, num");
+	input = QRinput_new();
+	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_KANJI, 0);
+	list = input->head;
+	if(inputTest(list, "kakn", 2, 11, 2, 6)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
+void test_split7(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: an and num as bits");
+	input = QRinput_new();
+	Split_splitStringToQRinput("\x82\xd9""abcde\x82\xb0""12345", input, 0, QR_MODE_8, 0);
+	list = input->head;
+	if(inputTest(list, "8n", 9, 5)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
+void test_split8(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: terminated with a half of kanji code");
+	input = QRinput_new();
+	Split_splitStringToQRinput("\x82\xd9""abcdefgh\x82", input, 0, QR_MODE_KANJI, 0);
+	list = input->head;
+	if(inputTest(list, "ka8", 2, 8, 1)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
+void test_split3c(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: single typed strings (an, case-sensitive)");
+	input = QRinput_new();
+	Split_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8, 1);
+	list = input->head;
+	if(inputTest(list, "8", 5)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+
+	err = 0;
+	testStart("Split test: num + an");
+	input = QRinput_new();
+	Split_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI, 1);
+	list = input->head;
+	if(inputTest(list, "n8", 4, 5)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+
+	err = 0;
+	testStart("Split test: an + num + an");
+	input = QRinput_new();
+	Split_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI, 1);
+	list = input->head;
+	if(inputTest(list, "8", 7)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
+int main(int argc, char **argv)
+{
+	test_split1();
+	test_split2();
+	test_split3();
+	test_split4();
+	test_split5();
+	test_split6();
+	test_split7();
+	test_split8();
+	test_split3c();
+
+	report();
+
+	return 0;
+}
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 1ef915e348..2eb9d13196 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -28,7 +28,7 @@ void view_simple(const char *str)
 	SDL_Rect rect;
 
 	stream = QRinput_new();
-	Split_splitStringToQRinput(str, stream, 0, QR_MODE_KANJI);
+	Split_splitStringToQRinput(str, stream, 0, QR_MODE_KANJI, 0);
 
 
 	while(flag) {
-- 
cgit 0.0.5-2-1-g0f52


From a405a71e0879b31aa4f865630033e82687c7fc0e Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 14 Dec 2007 01:20:21 +0000
Subject: New test according to the specification has been added.

---
 tests/test_qrencode.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)

diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index c1b8a45d8d..f8bad5ec9f 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -446,7 +446,50 @@ void test_encodeTooLong(void)
 	free(data);
 }
 
-void print_encode(void)
+void test_01234567(void)
+{
+	QRinput *stream;
+	char num[9] = "01234567";
+	int i, err = 0;
+	QRcode *qrcode;
+	unsigned char correct[] = {
+0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x84, 0x03, 0x02, 0x03, 0x03, 0xc0, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
+0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x84, 0x03, 0x03, 0x03, 0x03, 0xc0, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
+0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x02, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
+0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x03, 0x02, 0x02, 0x02, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
+0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x03, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
+0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x03, 0xc0, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
+0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x91, 0x90, 0x91, 0x90, 0x91, 0xc0, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
+0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x85, 0x02, 0x02, 0x03, 0x03, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
+0x85, 0x84, 0x85, 0x85, 0x85, 0x85, 0x91, 0x84, 0x84, 0x03, 0x02, 0x02, 0x03, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84,
+0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x90, 0x03, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02,
+0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x91, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03,
+0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x90, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02,
+0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x91, 0x03, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02,
+0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x81, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02,
+0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x84, 0x03, 0x03, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02,
+0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x03,
+0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02,
+0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02,
+0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02,
+0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x84, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02,
+0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x85, 0x03, 0x03, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02};
+
+	testStart("Encode 01234567 in 1-M");
+	stream = QRinput_new();
+	QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
+	qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_M);
+	for(i=0; iwidth * qrcode->width; i++) {
+		if(qrcode->data[i] != correct[i]) {
+			err++;
+		}
+	}
+	testEnd(err);
+	QRinput_free(stream);
+	QRcode_free(qrcode);
+}
+
+void print_01234567(void)
 {
 	QRinput *stream;
 	char num[9] = "01234567";
@@ -456,7 +499,7 @@ void print_encode(void)
 
 	stream = QRinput_new();
 	QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
-	qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_L);
+	qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_M);
 	w = qrcode->width;
 	frame = qrcode->data;
 	for(y=0; y
Date: Fri, 14 Dec 2007 04:27:31 +0000
Subject: * tests/test_qrencode.c:   - New test has been added. *
 tests/view_qrcode.c:   - Options supported.   - Default mask is now -1
 (auto). * Copyright 2007.

---
 ChangeLog           |  20 +++++++
 NEWS                |   7 +++
 README              |   2 +-
 bitstream.c         |   2 +-
 bitstream.h         |   2 +-
 mask.c              |   2 +-
 mask.h              |   2 +-
 mqrspec.c           |   2 +-
 mqrspec.h           |   2 +-
 qrenc.c             |  15 +++--
 qrencode.c          |   2 +-
 qrencode.h          |   2 +-
 qrencode_inner.h    |   2 +-
 qrinput.c           |   2 +-
 qrinput.h           |   2 +-
 qrspec.c            |   2 +-
 qrspec.h            |   2 +-
 rscode.c            |   2 +-
 rscode.h            |   2 +-
 split.c             |   2 +-
 split.h             |   2 +-
 tests/view_qrcode.c | 162 +++++++++++++++++++++++++++++++++++++++++++++-------
 22 files changed, 194 insertions(+), 46 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 31b3131e95..4547a4242d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2007.12.14 Kentaro FUKUCHI 
+	* tests/test_qrencode.c:
+	  - New test has been added.
+	* tests/view_qrcode.c:
+	  - Options supported.
+	  - Default mask is now -1 (auto).
+
+2007.12.13 Kentaro FUKUCHI 
+	* qrencode.[ch]:
+	  - QRcode_writeFormatInformation now returns a number of dark modules.
+	* mask.c:
+	  - The mask evaluation function now writes format information before
+	    evaluation. (Philippe Delcroix)
+	* split.[ch]:
+	  - Case-sensitive mode has been added to QRcode_encodeString().
+	  - "-8" option has been added to qrenc.c.
+	  - "-c" now encodes in improved case-sensitive mode.
+	* tests/test_{split,qrencode}.c:
+	  - test_split*() have been moved to test_split.c.
+
 2007.12.10 Kentaro FUKUCHI 
 	* Merged to main trunk.
 	* mask.[ch], split.[ch]:
diff --git a/NEWS b/NEWS
index 1d9bea431d..ec09e1bf02 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,13 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
+Version 2.0.0 (2007.12.xx)
+--------------------------
+* Code cleanup.
+* The mask evaluation bug has been fixed. (Philippe Delcroix)
+* qrencode's case-sensitive encoding has been improved.
+* "-8" option has been added to qrencode to encode whole data in 8-bit mode.
+
 Version 1.0.2 (2007.03.24)
 --------------------------
 * A small bug fix. (Thanks to NANKI Haruo)
diff --git a/README b/README
index 22c7fdd6be..a6521d916f 100644
--- a/README
+++ b/README
@@ -56,7 +56,7 @@ WARNING: This library is thread UNSAFE.
 
 LICENSING INFORMATION
 =====================
-Copyright (C) 2006 Kentaro Fukuchi
+Copyright (C) 2006,2007 Kentaro Fukuchi
 
 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
diff --git a/bitstream.c b/bitstream.c
index c44195977d..ba3978ad30 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Binary sequence class.
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/bitstream.h b/bitstream.h
index ed75551cd3..ee1b6d8fc0 100644
--- a/bitstream.h
+++ b/bitstream.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Binary sequence class.
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/mask.c b/mask.c
index dc8eea0728..95ea44e81f 100644
--- a/mask.c
+++ b/mask.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Masking.
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/mask.h b/mask.h
index c83a983bba..77d6057646 100644
--- a/mask.h
+++ b/mask.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Masking.
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/mqrspec.c b/mqrspec.c
index 9a32bf0a46..a83cf51331 100644
--- a/mqrspec.c
+++ b/mqrspec.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Micor QR Code specification in convenient format. 
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/mqrspec.h b/mqrspec.h
index 2d0c520958..af0d8d5f67 100644
--- a/mqrspec.h
+++ b/mqrspec.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Micro QR Code specification in convenient format. 
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrenc.c b/qrenc.c
index 245e7544c2..998ba01a95 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code encoding tool
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -46,7 +46,7 @@ enum {
 	O_8BIT,
 };
 
-const struct option options[] = {
+static const struct option options[] = {
 	{"h", no_argument      , NULL, O_HELP},
 	{"o", required_argument, NULL, O_OUTPUT},
 	{"l", required_argument, NULL, O_LEVEL},
@@ -59,7 +59,7 @@ const struct option options[] = {
 	{NULL, 0, NULL, 0}
 };
 
-void usage(void)
+static void usage(void)
 {
 	fprintf(stderr,
 "qrencode version %s\n\n"
@@ -79,12 +79,11 @@ void usage(void)
 "  -8           encode entire data in 8-bit mode. -c and -k will be ignored.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
 "               standard input.\n",
-VERSION
-);
+	VERSION);
 }
 
 #define MAX_DATA_SIZE 7090 /* from the specification */
-char *readStdin(void)
+static char *readStdin(void)
 {
 	char *buffer;
 	int ret;
@@ -105,7 +104,7 @@ char *readStdin(void)
 	return buffer;
 }
 
-QRcode *encode(const char *intext)
+static QRcode *encode(const char *intext)
 {
 	QRencodeMode hint;
 	QRcode *code;
@@ -125,7 +124,7 @@ QRcode *encode(const char *intext)
 	return code;
 }
 
-void qrencode(const char *intext, const char *outfile)
+static void qrencode(const char *intext, const char *outfile)
 {
 	FILE *fp;
 	QRcode *qrcode;
diff --git a/qrencode.c b/qrencode.c
index 050eca4a98..30ecade931 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -1,7 +1,7 @@
 /*
  * qrencode - QR Code encoder
  *
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrencode.h b/qrencode.h
index c4de380584..fdef80e69f 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -1,7 +1,7 @@
 /**
  * qrencode - QR Code encoder
  *
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrencode_inner.h b/qrencode_inner.h
index b7ff64e1dd..035fbe2530 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Header for internal use
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrinput.c b/qrinput.c
index d7fc3d6d6f..2a62a6ff3f 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data chunk class
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrinput.h b/qrinput.h
index 4360aad20d..27c32c2bab 100644
--- a/qrinput.h
+++ b/qrinput.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data chunk class
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrspec.c b/qrspec.c
index 1f8afbbd75..d0572df319 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code specification in convenient format. 
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/qrspec.h b/qrspec.h
index 71f681a9bd..cff32fec26 100644
--- a/qrspec.h
+++ b/qrspec.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code specification in convenient format. 
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/rscode.c b/rscode.c
index 6a81e4de1e..7f8c9671e2 100644
--- a/rscode.c
+++ b/rscode.c
@@ -7,7 +7,7 @@
  * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
  * (libfec is released under the GNU Lesser General Public License.)
  *
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/rscode.h b/rscode.h
index e99dbfb2b4..2f475e72b4 100644
--- a/rscode.h
+++ b/rscode.h
@@ -7,7 +7,7 @@
  * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
  * (libfec is released under the GNU Lesser General Public License.)
  *
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/split.c b/split.c
index 6c334c9fba..25b5fb91c2 100644
--- a/split.c
+++ b/split.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data splitter.
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/split.h b/split.h
index a7b66d6568..b583966ed7 100644
--- a/split.h
+++ b/split.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data splitter.
- * Copyright (C) 2006 Kentaro Fukuchi 
+ * Copyright (C) 2006,2007 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 2eb9d13196..af756b0dbe 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -2,13 +2,66 @@
 #include 
 #include 
 #include 
+#include 
 #include "common.h"
 #include "../qrencode_inner.h"
 #include "../qrspec.h"
 #include "../qrinput.h"
 #include "../split.h"
 
-SDL_Surface *screen = NULL;
+enum {
+	O_HELP,
+	O_SIZE,
+	O_VERSION,
+	O_LEVEL,
+	O_MARGIN,
+	O_KANJI,
+	O_CASE,
+	O_8BIT,
+};
+
+const struct option options[] = {
+	{"h", no_argument      , NULL, O_HELP},
+	{"l", required_argument, NULL, O_LEVEL},
+	{"s", required_argument, NULL, O_SIZE},
+	{"v", required_argument, NULL, O_VERSION},
+	{"m", required_argument, NULL, O_MARGIN},
+	{"k", no_argument      , NULL, O_KANJI},
+	{"c", no_argument      , NULL, O_CASE},
+	{"8", no_argument      , NULL, O_8BIT},
+	{NULL, 0, NULL, 0}
+};
+
+static SDL_Surface *screen = NULL;
+static int casesensitive = 0;
+static int eightbit = 0;
+static int scale = 4;
+static int version = 1;
+static QRecLevel level = QR_ECLEVEL_L;
+static int margin = 4;
+static QRencodeMode hint = QR_MODE_8;
+
+static char levelChar[4] = {'L', 'M', 'Q', 'H'};
+static void usage(void)
+{
+	fprintf(stderr,
+"view_qrcode version %s\n\n"
+"Usage: qrencode [OPTION]... [STRING]\n"
+"Encode input data in a QR Code and save as a PNG image.\n\n"
+"  -h           display this message.\n"
+"  -s NUMBER    specify the size of dot (pixel). (default=3)\n"
+"  -l {LMQH}    specify error collectin level from L (lowest) to H (highest).\n"
+"               (default=L)\n"
+"  -v NUMBER    specify the version of the symbol. (default=auto)\n"
+"  -m NUMBER    specify the width of margin. (default=4)\n"
+"  -k           assume that the input text contains kanji (shift-jis).\n"
+"  -c           encode alphabet characters in 8-bit mode. If your application\n"
+"               is case-sensitive, choose this.\n"
+"  -8           encode entire data in 8-bit mode. -c and -k will be ignored.\n"
+"  [STRING]     input data. If it is not specified, data will be taken from\n"
+"               standard input.\n",
+	VERSION);
+}
 
 void view_simple(const char *str)
 {
@@ -18,33 +71,33 @@ void view_simple(const char *str)
 	int x, y;
 	int pitch;
 	int flag = 1;
-	int version = 1;
-	int mask = 0;
-	int scale = 4;
-	QRecLevel level = QR_ECLEVEL_L;
+	int mask = -1;
 	QRcode *qrcode;
 	SDL_Event event;
 	int loop;
 	SDL_Rect rect;
 
 	stream = QRinput_new();
-	Split_splitStringToQRinput(str, stream, 0, QR_MODE_KANJI, 0);
-
+	if(eightbit) {
+		QRinput_append(stream, QR_MODE_8, strlen(str), (unsigned char *)str);
+	} else {
+		Split_splitStringToQRinput(str, stream, 0, QR_MODE_KANJI, casesensitive);
+	}
 
 	while(flag) {
 		qrcode = QRcode_encodeMask(stream, version, level, mask);
 		width = qrcode->width;
 		frame = qrcode->data;
 		version = qrcode->version;
-		printf("Version %d, Leve %d, Mask %d.\n", version, level, mask);
-		screen = SDL_SetVideoMode((width + 8) * scale, (width + 8) * scale, 32, 0);
+		printf("Version %d, Leve %c, Mask %d.\n", version, levelChar[level], mask);
+		screen = SDL_SetVideoMode((width + margin*2) * scale, (width + margin*2) * scale, 32, 0);
 		pitch = screen->pitch;
 		q = frame;
 		SDL_FillRect(screen, NULL, 0xffffff);
 		for(y=0; y
Date: Fri, 14 Dec 2007 08:11:24 +0000
Subject:

---
 tests/view_qrcode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index af756b0dbe..183489fd95 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -253,7 +253,7 @@ int main(int argc, char **argv)
 				break;
 		}
 	}
-	if(argc == 2) {
+	if(argc == 1) {
 		usage();
 		exit(1);
 	}
-- 
cgit 0.0.5-2-1-g0f52


From ac1e4d5f68a85edd9986e53dbd186f1f8df7ee32 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sat, 15 Dec 2007 14:09:30 +0000
Subject:

---
 NEWS | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/NEWS b/NEWS
index ec09e1bf02..2d9d9e8ba1 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,11 @@ Version 2.0.0 (2007.12.xx)
 * qrencode's case-sensitive encoding has been improved.
 * "-8" option has been added to qrencode to encode whole data in 8-bit mode.
 
+* API changes
+  - QRcode_encodeString() now receives case-sensitive flag.
+  - QRcode_encodeStringCase() has been removed.
+  - QRcode_encodeString8bit() has been added.
+
 Version 1.0.2 (2007.03.24)
 --------------------------
 * A small bug fix. (Thanks to NANKI Haruo)
-- 
cgit 0.0.5-2-1-g0f52


From 13fffb786c23c6fe234f7c303f7a98b1d135a690 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 23 Jan 2008 12:24:33 +0000
Subject: Synchronized to 2.0.0.

---
 ChangeLog            |  28 +++++++++++++++
 Makefile.am          |   4 ++-
 NEWS                 |  24 +++++++++++--
 README               |   2 +-
 TODO                 |   9 +++--
 bitstream.c          |   2 +-
 bitstream.h          |   2 +-
 configure.ac         |   2 +-
 mask.c               |   2 +-
 mask.h               |   2 +-
 mqrspec.c            |   2 +-
 mqrspec.h            |   2 +-
 qrenc.c              |  29 ++++++++-------
 qrencode.1.in        |  58 ++++++++++++++++++++++++++++++
 qrencode.c           |   2 +-
 qrencode.h           |   2 +-
 qrencode_inner.h     |   2 +-
 qrinput.c            |  13 +++----
 qrinput.h            |   2 +-
 qrspec.c             |   2 +-
 qrspec.h             |   2 +-
 rscode.c             |   2 +-
 rscode.h             |   2 +-
 split.c              |  90 +++++++++++++++++++++++++++++++---------------
 split.h              |   2 +-
 tests/common.h       |  13 +++++++
 tests/test_qrinput.c |   6 ++--
 tests/test_split.c   |  57 ++++++++++++++++++++++++++++-
 tests/view_qrcode.c  | 100 ++++++++++++++++++++++++++++++++++-----------------
 29 files changed, 351 insertions(+), 114 deletions(-)
 create mode 100644 qrencode.1.in

diff --git a/ChangeLog b/ChangeLog
index 4547a4242d..f46ae608cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2008.01.23 Kentaro FUKUCHI 
+	* qrencode.1.in, Makefile.am, configure.ac:
+	  - Manpage of qrencode has been added.
+	* qrenc.c, tests/view_qrcode.c:
+	  - Usage message has been updated.
+
+2008.01.18 Kentaro FUKUCHI 
+	* split.c:
+	  - Bug fixes.
+	* tests/test_split.c:
+	  - Followed recent API changes.
+	  - Added new test "test_toupper()".
+	* qrenc.c, tests/view_qrcode.c:
+	  - Source-level compatiblity has been improved.
+	  - view_qrcode now accepts stdin like qrencode.
+	  - Usage message has been updated/fixed.
+	* Copyright year has been updated.
+
+2008.01.16 Kentaro FUKUCHI 
+	* qrinput.c, split.c:
+	  - Case-sensitive mode becomes now default mode.
+	  - Alphabet-Numeric mode now encodes only upper-case alphabet and
+	    numeric characters. If "-i" option is given, split.c converts
+		lower-case characters to upper-case characters at first.
+	* qrenc.c, tests/view_qrcode.c:
+	  - Case-sensitive mode becomes now default mode.
+	  - Option "-i" has been added.
+
 2007.12.14 Kentaro FUKUCHI 
 	* tests/test_qrencode.c:
 	  - New test has been added.
diff --git a/Makefile.am b/Makefile.am
index 5dd03e7382..ee15cb6137 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,8 +19,10 @@ include_HEADERS = qrencode.h
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libqrencode.pc
 
+man1_MANS = qrencode.1
+
 EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \
-			 Makefile.am tests/Makefile.am qrencode.spec.in
+			 Makefile.am tests/Makefile.am qrencode.spec.in qrencode.1.in
 
 if BUILD_TOOLS
 bin_PROGRAMS = qrencode
diff --git a/NEWS b/NEWS
index 2d9d9e8ba1..d8e0bd2389 100644
--- a/NEWS
+++ b/NEWS
@@ -3,16 +3,36 @@ libqrencode NEWS - Overview of changes
 
 Version 2.0.0 (2007.12.xx)
 --------------------------
+Summary:
+* "-i" option to ignore case distinctions has been added to qrencode and
+  view_qrcode.
+* "-c" option (case-sensitive mode) of qrencode is now enabled by default and
+  has been improved. See details in Release Note section.
+* "-8" option has been added to qrencode to encode whole data in 8-bit mode.
+* tests/view_qrcode now accepts various options like qrencode.
 * Code cleanup.
 * The mask evaluation bug has been fixed. (Philippe Delcroix)
-* qrencode's case-sensitive encoding has been improved.
-* "-8" option has been added to qrencode to encode whole data in 8-bit mode.
 
 * API changes
   - QRcode_encodeString() now receives case-sensitive flag.
   - QRcode_encodeStringCase() has been removed.
   - QRcode_encodeString8bit() has been added.
 
+Release Note:
+
+Previously libqrencode encodes lower-case alphabet characters in Alphabet-
+Numeric mode (upper-case alphabet and numeric) by default. According to the
+specification of QR code, however, it is clearly claimed that Alphabet-Numeric
+mode provides only upper-case alphabet (+ numeric and some symbol) characters.
+Since this version, libqrencode distinguishes lower-case and upper-case of
+alphabet characters by default. Because of that, "-c" option of qrencode
+is now deprecated, and "-i" option has been added. By giving "-i", qrencode
+converts lower-case characters to upper-case if possible, then encode a QR code
+symbol. Please read qrencode.h for the details about API changes if you are
+going to use this library.
+
+Many thanks to NANKI Haruo for his suggestions.
+
 Version 1.0.2 (2007.03.24)
 --------------------------
 * A small bug fix. (Thanks to NANKI Haruo)
diff --git a/README b/README
index a6521d916f..8aff41798a 100644
--- a/README
+++ b/README
@@ -56,7 +56,7 @@ WARNING: This library is thread UNSAFE.
 
 LICENSING INFORMATION
 =====================
-Copyright (C) 2006,2007 Kentaro Fukuchi
+Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi
 
 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
diff --git a/TODO b/TODO
index 9efb27f706..1dff2425c8 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,10 @@
 Thread unsafe.
-Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe.
-
-view_qrcode should support various options like qrencode.
+Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe, but
+all of qrencode functions are thread unsafe because of them.
 
 This package contains
 
-*.c and *.h files (total):  5422 lines, 131476 bytes.
-configure script         : 22866 lines, 740829 bytes.
+*.c and *.h files (total):  5916 lines, 146312 bytes.
+configure script         : 22510 lines, 724802 bytes.
 
 It's absolutely crazy.
diff --git a/bitstream.c b/bitstream.c
index ba3978ad30..11c68fe329 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Binary sequence class.
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/bitstream.h b/bitstream.h
index ee1b6d8fc0..95399a5769 100644
--- a/bitstream.h
+++ b/bitstream.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Binary sequence class.
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/configure.ac b/configure.ac
index d3289f8838..72771f155f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@ AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ])
 
 CFLAGS="-Wall $CFLAGS"
 
-AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec])
+AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1])
 
 AC_ARG_WITH([tools], [AC_HELP_STRING([--with-tools], [build utility tools [default=yes]])],
  [], [build_tools=yes])
diff --git a/mask.c b/mask.c
index 95ea44e81f..d85148ab7c 100644
--- a/mask.c
+++ b/mask.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Masking.
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/mask.h b/mask.h
index 77d6057646..6bf39ff6dd 100644
--- a/mask.h
+++ b/mask.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Masking.
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/mqrspec.c b/mqrspec.c
index a83cf51331..6c2c939af4 100644
--- a/mqrspec.c
+++ b/mqrspec.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Micor QR Code specification in convenient format. 
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/mqrspec.h b/mqrspec.h
index af0d8d5f67..c719ceb6dd 100644
--- a/mqrspec.h
+++ b/mqrspec.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Micro QR Code specification in convenient format. 
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrenc.c b/qrenc.c
index 998ba01a95..45d7d837ed 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code encoding tool
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,13 +26,13 @@
 
 #include "qrencode.h"
 
-static int casesensitive = 0;
+static int casesensitive = 1;
 static int eightbit = 0;
-static int kanji = 0;
 static int version = 0;
 static int size = 3;
 static int margin = 4;
 static QRecLevel level = QR_ECLEVEL_L;
+static QRencodeMode hint = QR_MODE_8;
 
 enum {
 	O_HELP,
@@ -43,6 +43,7 @@ enum {
 	O_MARGIN,
 	O_KANJI,
 	O_CASE,
+	O_IGNORECASE,
 	O_8BIT,
 };
 
@@ -55,6 +56,7 @@ static const struct option options[] = {
 	{"m", required_argument, NULL, O_MARGIN},
 	{"k", no_argument      , NULL, O_KANJI},
 	{"c", no_argument      , NULL, O_CASE},
+	{"i", no_argument      , NULL, O_IGNORECASE},
 	{"8", no_argument      , NULL, O_8BIT},
 	{NULL, 0, NULL, 0}
 };
@@ -62,7 +64,8 @@ static const struct option options[] = {
 static void usage(void)
 {
 	fprintf(stderr,
-"qrencode version %s\n\n"
+"qrencode version %s\n"
+"Copyright (C) 2008 Kentaro Fukuchi\n"
 "Usage: qrencode [OPTION]... [STRING]\n"
 "Encode input data in a QR Code and save as a PNG image.\n\n"
 "  -h           display this message.\n"
@@ -74,9 +77,9 @@ static void usage(void)
 "  -v NUMBER    specify the version of the symbol. (default=auto)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
-"  -c           encode alphabet characters in 8-bit mode. If your application\n"
-"               is case-sensitive, choose this.\n"
-"  -8           encode entire data in 8-bit mode. -c and -k will be ignored.\n"
+"  -c           encode lower-case alphabet characters in 8-bit mode. (default)\n"
+"  -i           ignore case distinctions and use only upper-case characters.\n"
+"  -8           encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
 "               standard input.\n",
 	VERSION);
@@ -106,15 +109,8 @@ static char *readStdin(void)
 
 static QRcode *encode(const char *intext)
 {
-	QRencodeMode hint;
 	QRcode *code;
 
-	if(kanji) {
-		hint = QR_MODE_KANJI;
-	} else {
-		hint = QR_MODE_8;
-	}
-
 	if(eightbit) {
 		code = QRcode_encodeString8bit(intext, version, level);
 	} else {
@@ -289,11 +285,14 @@ int main(int argc, char **argv)
 				}
 				break;
 			case O_KANJI:
-				kanji = 1;
+				hint = QR_MODE_KANJI;
 				break;
 			case O_CASE:
 				casesensitive = 1;
 				break;
+			case O_IGNORECASE:
+				casesensitive = 0;
+				break;
 			case O_8BIT:
 				eightbit = 1;
 				break;
diff --git a/qrencode.1.in b/qrencode.1.in
new file mode 100644
index 0000000000..8f1106ca3e
--- /dev/null
+++ b/qrencode.1.in
@@ -0,0 +1,58 @@
+.TH QRENCODE 1 "Jan. 23, 2008" "qrencode @VERSION@"
+.SH NAME
+qrencode \- Encode input data in a QR Code and save as a PNG image.
+.SH SYNOPSIS
+.B "qrencode"
+[OPTION]...
+[STRING]
+
+.SH DESCRIPTION
+Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D
+symbology that can be scanned by handy terminals such as a mobile phone with
+CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has
+high robustness.
+
+Qrencode is a utility software using libqrencode to encode string data in
+a QR Code and save as a PNG image.
+
+.SH OPTIONS
+.TP
+.B \-h
+display help message.
+.TP
+.B \-o FILENAME
+write PNG image to FILENAME. If '-' is specified, the result will be output
+to standard output.
+.TP
+.B \-s NUMBER
+specify the size of dot (pixel). (default=3)
+.TP
+.B \-l {LMQH}
+specify error collectin level from L (lowest) to H (highest). (default=L)
+.TP
+.B \-v NUMBER
+specify the version of the symbol. (default=auto)
+.TP
+.B \-m NUMBER
+specify the width of margin. (default=4)
+.TP
+.B \-k
+assume that the input text contains kanji (shift-jis).
+.TP
+.B \-c
+encode lower-case alphabet characters in 8-bit mode. (default)
+.TP
+.B \-i
+ignore case distinctions and use only upper-case characters.
+.TP
+.B \-8
+encode entire data in 8-bit mode. -k, -c and -i will be ignored.
+.TP
+.B [STRING]
+input data. If it is not specified, data will be taken from standard input.
+
+.SH AUTHOR
+Written by Kentaro Fukuchi.
+
+.SH COPYRIGHT
+Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi.
diff --git a/qrencode.c b/qrencode.c
index 30ecade931..d2fe711ee8 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -1,7 +1,7 @@
 /*
  * qrencode - QR Code encoder
  *
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrencode.h b/qrencode.h
index fdef80e69f..576cf6a509 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -1,7 +1,7 @@
 /**
  * qrencode - QR Code encoder
  *
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrencode_inner.h b/qrencode_inner.h
index 035fbe2530..febde1e163 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Header for internal use
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrinput.c b/qrinput.c
index 2a62a6ff3f..058347db5e 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data chunk class
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -230,8 +230,8 @@ const signed char QRinput_anTable[] = {
 	 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 44, -1, -1, -1, -1, -1,
 	-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
 	25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
-	-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
-	25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1
+	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
 };
 
 /**
@@ -692,13 +692,8 @@ static BitStream *QRinput_createPaddingBit(QRinput *input)
 	bstream = BitStream_new();
 	BitStream_appendNum(bstream, words * 8 - bits + 4, 0);
 
-	/* FIXME: It would be able to add padding bits by more efficient way. */
 	for(i=0; i
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrspec.c b/qrspec.c
index d0572df319..1a2f0d244f 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code specification in convenient format. 
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/qrspec.h b/qrspec.h
index cff32fec26..648c83d7a5 100644
--- a/qrspec.h
+++ b/qrspec.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code specification in convenient format. 
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/rscode.c b/rscode.c
index 7f8c9671e2..09ccf9ab35 100644
--- a/rscode.c
+++ b/rscode.c
@@ -7,7 +7,7 @@
  * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
  * (libfec is released under the GNU Lesser General Public License.)
  *
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/rscode.h b/rscode.h
index 2f475e72b4..b4557829da 100644
--- a/rscode.h
+++ b/rscode.h
@@ -7,7 +7,7 @@
  * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
  * (libfec is released under the GNU Lesser General Public License.)
  *
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/split.c b/split.c
index 25b5fb91c2..4806f669b3 100644
--- a/split.c
+++ b/split.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data splitter.
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
@@ -25,6 +25,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include 
+#include 
 #include "qrencode.h"
 #include "qrinput.h"
 #include "qrspec.h"
@@ -33,12 +35,12 @@
 #define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10)
 #define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0)
 
-static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive);
-static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive);
-static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive);
-static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive);
+static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint);
+static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint);
+static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint);
+static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint);
 
-static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive)
+static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint)
 {
 	const char *p;
 	int run;
@@ -57,15 +59,15 @@ static int Split_eatNum(const char *string, QRinput *input, int version, QRencod
 			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
 			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
 		if(dif > 0) {
-			return Split_eat8(string, input, version, hint, casesensitive);
+			return Split_eat8(string, input, version, hint);
 		}
 	}
-	if(isalnum(*p) && !casesensitive) {
+	if(isalnum(*p)) {
 		dif = QRinput_estimateBitsModeNum(run) + 4 + ln
 			+ QRinput_estimateBitsModeAn(1) /* + 4 + la */
 			- QRinput_estimateBitsModeAn(run + 1) /* - 4 - la */;
 		if(dif > 0) {
-			return Split_eatAn(string, input, version, hint, casesensitive);
+			return Split_eatAn(string, input, version, hint);
 		}
 	}
 
@@ -73,17 +75,13 @@ static int Split_eatNum(const char *string, QRinput *input, int version, QRencod
 	return run;
 }
 
-static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive)
+static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint)
 {
 	const char *p, *q;
 	int run;
 	int dif;
 	int la, ln;
 
-	if(casesensitive) {
-		return Split_eat8(string, input, version, hint, casesensitive);
-	}
-
 	la = QRspec_lengthIndicator(QR_MODE_AN, version);
 	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
 
@@ -109,12 +107,12 @@ static int Split_eatAn(const char *string, QRinput *input, int version, QRencode
 
 	run = p - string;
 
-	if(*p & 0x80) {
+	if(*p && !isalnum(*p)) {
 		dif = QRinput_estimateBitsModeAn(run) + 4 + la
 			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
 			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
 		if(dif > 0) {
-			return Split_eat8(string, input, version, hint, casesensitive);
+			return Split_eat8(string, input, version, hint);
 		}
 	}
 
@@ -122,7 +120,7 @@ static int Split_eatAn(const char *string, QRinput *input, int version, QRencode
 	return run;
 }
 
-static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive)
+static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint)
 {
 	const char *p;
 
@@ -134,7 +132,7 @@ static int Split_eatKanji(const char *string, QRinput *input, int version, QRenc
 	return p - string;
 }
 
-static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint, int casesensitive)
+static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint)
 {
 	const char *p, *q;
 	QRencodeMode mode;
@@ -164,7 +162,7 @@ static int Split_eat8(const char *string, QRinput *input, int version, QRencodeM
 				} else {
 					p = q;
 				}
-			} else if(!casesensitive) {
+			} else {
 				q = p;
 				while(isalnum(*q)) {
 					q++;
@@ -177,8 +175,6 @@ static int Split_eat8(const char *string, QRinput *input, int version, QRencodeM
 				} else {
 					p = q;
 				}
-			} else {
-				p++;
 			}
 		} else {
 			p++;
@@ -189,8 +185,8 @@ static int Split_eat8(const char *string, QRinput *input, int version, QRencodeM
 	return p - string;
 }
 
-void Split_splitStringToQRinput(const char *string, QRinput *input,
-		int version, QRencodeMode hint, int casesensitive)
+static void Split_splitString(const char *string, QRinput *input,
+		int version, QRencodeMode hint)
 {
 	int length;
 	QRencodeMode mode;
@@ -199,14 +195,50 @@ void Split_splitStringToQRinput(const char *string, QRinput *input,
 
 	mode = QRinput_identifyMode(string);
 	if(mode == QR_MODE_NUM) {
-		length = Split_eatNum(string, input, version, hint, casesensitive);
-	} else if(mode == QR_MODE_AN && !casesensitive) {
-		length = Split_eatAn(string, input, version, hint, casesensitive);
+		length = Split_eatNum(string, input, version, hint);
+	} else if(mode == QR_MODE_AN) {
+		length = Split_eatAn(string, input, version, hint);
 	} else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
-		length = Split_eatKanji(string, input, version, hint, casesensitive);
+		length = Split_eatKanji(string, input, version, hint);
 	} else {
-		length = Split_eat8(string, input, version, hint, casesensitive);
+		length = Split_eat8(string, input, version, hint);
 	}
 	if(length == 0) return;
-	Split_splitStringToQRinput(&string[length], input, hint, version, casesensitive);
+	Split_splitString(&string[length], input, version, hint);
+}
+
+static char *dupAndToUpper(const char *str, QRencodeMode hint)
+{
+	char *newstr, *p;
+	QRencodeMode mode;
+
+	newstr = strdup(str);
+	p = newstr;
+	while(*p != '\0') {
+		mode = QRinput_identifyMode(p);
+		if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
+			p += 2;
+		} else {
+			if (*p >= 'a' && *p <= 'z') {
+				*p = (char)((int)*p - 32);
+			}
+			p++;
+		}
+	}
+
+	return newstr;
+}
+
+void Split_splitStringToQRinput(const char *string, QRinput *input,
+		int version, QRencodeMode hint, int casesensitive)
+{
+	char *newstr;
+
+	if(!casesensitive) {
+		newstr = dupAndToUpper(string, hint);
+		Split_splitString(newstr, input, version, hint);
+		free(newstr);
+	} else {
+		Split_splitString(string, input, version, hint);
+	}
 }
diff --git a/split.h b/split.h
index b583966ed7..2ddf5822a3 100644
--- a/split.h
+++ b/split.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data splitter.
- * Copyright (C) 2006,2007 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/tests/common.h b/tests/common.h
index d67e7d6822..05ba2854c4 100644
--- a/tests/common.h
+++ b/tests/common.h
@@ -7,6 +7,7 @@
 
 #include 
 #include "../qrencode.h"
+#include "../qrinput.h"
 #include "../bitstream.h"
 
 #define CHECK(_str_) (printf("_____%s\n",_str_))
@@ -83,4 +84,16 @@ char *sprintfBin(int size, unsigned char *data)
 
 	return str;
 }
+
+static char qrModeChar[4] = {'n', 'a', '8', 'k'};
+void printQrinput(QRinput *input)
+{
+	QRinput_List *list;
+
+	list = input->head;
+	while(list != NULL) {
+		printf("%c(%d)\n", qrModeChar[list->mode], list->size);
+		list = list->next;
+	}
+}
 #endif /* __COMMON_H__ */
diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c
index b2eb9f8b39..cb987ae382 100644
--- a/tests/test_qrinput.c
+++ b/tests/test_qrinput.c
@@ -175,7 +175,7 @@ void test_encodeTooLong(void)
 	BitStream *bstream;
 
 	data = (unsigned char *)malloc(7089);
-	memset(data, 'a', 7089);
+	memset(data, 'A', 7089);
 
 	testStart("Encoding long string. (7089 bytes)");
 	stream = QRinput_new();
@@ -196,7 +196,7 @@ void test_encodeAnNum(void)
 
 	testStart("Bit length check of alpha-numeric stream. (11 + 12)");
 	input = QRinput_new();
-	QRinput_append(input, QR_MODE_AN, 11, (unsigned char *)"abcdefghijk");
+	QRinput_append(input, QR_MODE_AN, 11, (unsigned char *)"ABCDEFGHIJK");
 	QRinput_append(input, QR_MODE_NUM, 12, (unsigned char *)"123456789012");
 	bstream = QRinput_mergeBitStream(input);
 	testEndExp(strlen(bstream->data) == 128);
@@ -205,7 +205,7 @@ void test_encodeAnNum(void)
 
 	testStart("Bit length check of alphabet stream. (23)");
 	input = QRinput_new();
-	QRinput_append(input, QR_MODE_AN, 23, (unsigned char *)"abcdefghijk123456789012");
+	QRinput_append(input, QR_MODE_AN, 23, (unsigned char *)"ABCDEFGHIJK123456789012");
 	bstream = QRinput_mergeBitStream(input);
 	testEndExp(strlen(bstream->data) == 140);
 	QRinput_free(input);
diff --git a/tests/test_split.c b/tests/test_split.c
index 2d5fe29707..dc64ffe1e9 100644
--- a/tests/test_split.c
+++ b/tests/test_split.c
@@ -7,6 +7,7 @@
 #include "../qrinput.h"
 #include "../mask.h"
 #include "../split.h"
+#include "../bitstream.h"
 
 static int inputTest(QRinput_List *list, const char *fmt, ...)
 {
@@ -127,6 +128,7 @@ void test_split3(void)
 	Split_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8, 0);
 	list = input->head;
 	if(inputTest(list, "a", 5)) {
+		printQrinput(input);
 		err++;
 	}
 	testEnd(err);
@@ -160,7 +162,7 @@ void test_split4(void)
 	QRinput *input;
 	QRinput *i1, *i2;
 	int s1, s2, size;
-#define CHUNKA "abcdefghijk"
+#define CHUNKA "ABCDEFGHIJK"
 #define CHUNKB "123456"
 #define CHUNKC "1234567"
 
@@ -244,6 +246,7 @@ void test_split6(void)
 	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_KANJI, 0);
 	list = input->head;
 	if(inputTest(list, "kakn", 2, 11, 2, 6)) {
+		printQrinput(input);
 		err++;
 	}
 	testEnd(err);
@@ -317,6 +320,57 @@ void test_split3c(void)
 	Split_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI, 1);
 	list = input->head;
 	if(inputTest(list, "8", 7)) {
+		printQrinput(input);
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
+void test_toupper(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: check dupAndToUpper (lower->upper)");
+	input = QRinput_new();
+	Split_splitStringToQRinput("abcde", input, 0, QR_MODE_8, 0);
+	list = input->head;
+	if(inputTest(list, "a", 5)) {
+		err++;
+	}
+	if(strncmp((char *)list->data, "ABCDE", list->size)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+
+	err = 0;
+	testStart("Split test: check dupAndToUpper (kanji)");
+	input = QRinput_new();
+	Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, 0, QR_MODE_KANJI, 0);
+	list = input->head;
+	if(inputTest(list, "k", 10)) {
+		printQrinput(input);
+		err++;
+	}
+	if(strncmp((char *)list->data, "\x83n\x83q\x83t\x83w\x83z", list->size)) {
+		err++;
+	}
+	testEnd(err);
+	QRinput_free(input);
+
+	err = 0;
+	testStart("Split test: check dupAndToUpper (8bit)");
+	input = QRinput_new();
+	Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, 0, QR_MODE_8, 0);
+	list = input->head;
+	if(inputTest(list, "8", 10)) {
+		printQrinput(input);
+		err++;
+	}
+	if(strncmp((char *)list->data, "\x83N\x83Q\x83T\x83W\x83Z", list->size)) {
 		err++;
 	}
 	testEnd(err);
@@ -334,6 +388,7 @@ int main(int argc, char **argv)
 	test_split7();
 	test_split8();
 	test_split3c();
+	test_toupper();
 
 	report();
 
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 183489fd95..c8d8a68605 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -9,6 +9,15 @@
 #include "../qrinput.h"
 #include "../split.h"
 
+static SDL_Surface *screen = NULL;
+static int casesensitive = 1;
+static int eightbit = 0;
+static int version = 1;
+static int size = 4;
+static int margin = 4;
+static QRecLevel level = QR_ECLEVEL_L;
+static QRencodeMode hint = QR_MODE_8;
+
 enum {
 	O_HELP,
 	O_SIZE,
@@ -17,6 +26,7 @@ enum {
 	O_MARGIN,
 	O_KANJI,
 	O_CASE,
+	O_IGNORECASE,
 	O_8BIT,
 };
 
@@ -28,41 +38,57 @@ const struct option options[] = {
 	{"m", required_argument, NULL, O_MARGIN},
 	{"k", no_argument      , NULL, O_KANJI},
 	{"c", no_argument      , NULL, O_CASE},
+	{"i", no_argument      , NULL, O_IGNORECASE},
 	{"8", no_argument      , NULL, O_8BIT},
 	{NULL, 0, NULL, 0}
 };
 
-static SDL_Surface *screen = NULL;
-static int casesensitive = 0;
-static int eightbit = 0;
-static int scale = 4;
-static int version = 1;
-static QRecLevel level = QR_ECLEVEL_L;
-static int margin = 4;
-static QRencodeMode hint = QR_MODE_8;
 
 static char levelChar[4] = {'L', 'M', 'Q', 'H'};
 static void usage(void)
 {
 	fprintf(stderr,
-"view_qrcode version %s\n\n"
-"Usage: qrencode [OPTION]... [STRING]\n"
+"view_qrcode version %s\n"
+"Copyright (C) 2008 Kentaro Fukuchi\n"
+"Usage: view_qrcode [OPTION]... [STRING]\n"
 "Encode input data in a QR Code and save as a PNG image.\n\n"
 "  -h           display this message.\n"
-"  -s NUMBER    specify the size of dot (pixel). (default=3)\n"
+"  -s NUMBER    specify the size of dot (pixel). (default=4)\n"
 "  -l {LMQH}    specify error collectin level from L (lowest) to H (highest).\n"
 "               (default=L)\n"
 "  -v NUMBER    specify the version of the symbol. (default=auto)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
-"  -c           encode alphabet characters in 8-bit mode. If your application\n"
-"               is case-sensitive, choose this.\n"
-"  -8           encode entire data in 8-bit mode. -c and -k will be ignored.\n"
+"  -c           encode lower-case alphabet characters in 8-bit mode. (default)\n"
+"  -i           ignore case distinctions and use only upper-case characters.\n"
+"  -8           encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
 "               standard input.\n",
 	VERSION);
 }
 
+#define MAX_DATA_SIZE 7090 /* from the specification */
+static char *readStdin(void)
+{
+	char *buffer;
+	int ret;
+
+	buffer = (char *)malloc(MAX_DATA_SIZE);
+	ret = fread(buffer, 1, MAX_DATA_SIZE, stdin);
+	if(ret == 0) {
+		fprintf(stderr, "No input data.\n");
+		exit(1);
+	}
+	if(!feof(stdin)) {
+		fprintf(stderr, "Input data is too large.\n");
+		exit(1);
+	}
+
+	buffer[ret] = '\0';
+
+	return buffer;
+}
+
 void view_simple(const char *str)
 {
 	QRinput *stream;
@@ -90,16 +116,16 @@ void view_simple(const char *str)
 		frame = qrcode->data;
 		version = qrcode->version;
 		printf("Version %d, Leve %c, Mask %d.\n", version, levelChar[level], mask);
-		screen = SDL_SetVideoMode((width + margin*2) * scale, (width + margin*2) * scale, 32, 0);
+		screen = SDL_SetVideoMode((width + margin*2) * size, (width + margin*2) * size, 32, 0);
 		pitch = screen->pitch;
 		q = frame;
 		SDL_FillRect(screen, NULL, 0xffffff);
 		for(y=0; y
Date: Wed, 23 Jan 2008 16:07:12 +0000
Subject:

---
 ChangeLog | 1 +
 NEWS      | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index f46ae608cb..0bea6fd11d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,7 @@
 	  - test_split*() have been moved to test_split.c.
 
 2007.12.10 Kentaro FUKUCHI 
+	* Bumped version to 2.0.0.
 	* Merged to main trunk.
 	* mask.[ch], split.[ch]:
 	  - Masking functions and splitString functions are separated from
diff --git a/NEWS b/NEWS
index d8e0bd2389..0e2bd502a3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,7 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
-Version 2.0.0 (2007.12.xx)
+Version 2.0.0 (2008.1.24)
 --------------------------
 Summary:
 * "-i" option to ignore case distinctions has been added to qrencode and
@@ -10,6 +10,7 @@ Summary:
   has been improved. See details in Release Note section.
 * "-8" option has been added to qrencode to encode whole data in 8-bit mode.
 * tests/view_qrcode now accepts various options like qrencode.
+* Man page has been added.
 * Code cleanup.
 * The mask evaluation bug has been fixed. (Philippe Delcroix)
 
-- 
cgit 0.0.5-2-1-g0f52

-- 
cgit 0.0.5-2-1-g0f52

-- 
cgit 0.0.5-2-1-g0f52


From 758459550264cbef860707eef414b594347cff0f Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 17 Apr 2008 06:35:45 +0000
Subject:

---
 qrspec.c | 16 +++++++++++++++-
 qrspec.h |  8 +++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/qrspec.c b/qrspec.c
index 1a2f0d244f..8f9b257bfa 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "qrspec.h"
 
@@ -138,6 +139,7 @@ int QRspec_lengthIndicator(QRencodeMode mode, int version)
 {
 	int l;
 
+	if(mode == QR_MODE_STRUCTURE) return 0;
 	if(version <= 9) {
 		l = 0;
 	} else if(version <= 26) {
@@ -155,6 +157,7 @@ int QRspec_maximumWords(QRencodeMode mode, int version)
 	int bits;
 	int words;
 
+	if(mode == QR_MODE_STRUCTURE) return 3;
 	if(version <= 9) {
 		l = 0;
 	} else if(version <= 26) {
@@ -232,11 +235,11 @@ int *QRspec_getEccSpec(int version, QRecLevel level)
 
 	b1 = eccTable[version][level][0];
 	b2 = eccTable[version][level][1];
-
 	data = QRspec_getDataLength(version, level);
 	ecc  = QRspec_getECCLength(version, level);
 
 	array = (int *)malloc(sizeof(int) * 6);
+	if(array == NULL) return NULL;
 
 	if(b2 == 0) {
 		array[0] = b1;
@@ -571,3 +574,14 @@ unsigned char *QRspec_newFrame(int version)
 
 	return frame;
 }
+
+void QRspec_clearCache(void)
+{
+	int i;
+
+	for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
+		if(frames[i] != NULL) {
+			free(frames[i]);
+		}
+	}
+}
diff --git a/qrspec.h b/qrspec.h
index 648c83d7a5..b63b367bc4 100644
--- a/qrspec.h
+++ b/qrspec.h
@@ -178,10 +178,16 @@ extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level);
  * Return a copy of initialized frame.
  * When the same version is requested twice or more, a copy of cached frame
  * is returned.
+ * WARNING: Thread unsafe!!!
  * @param version
  * @return Array of unsigned char. You can free it by free().
  */
-/* WARNING: Thread unsafe!!! */
 extern unsigned char *QRspec_newFrame(int version);
 
+/**
+ * Clear the frame cache. Typically for debug.
+ * WARNING: Thread unsafe!!!
+ */
+extern void QRspec_clearCache(void);
+
 #endif /* __QRSPEC_H__ */
-- 
cgit 0.0.5-2-1-g0f52


From b587b2a55fe23304ff24c4babb45993d43321b23 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 17 Apr 2008 06:35:49 +0000
Subject:

---
 bitstream.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bitstream.c b/bitstream.c
index 11c68fe329..93e88dc5f4 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -132,6 +132,7 @@ void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data)
 
 unsigned int BitStream_size(BitStream *bstream)
 {
+	if(bstream == NULL) return 0;
 	if(bstream->data == NULL) return 0;
 
 	return strlen(bstream->data);
-- 
cgit 0.0.5-2-1-g0f52


From 5600a4771127eb16e35d29ec256fb58ad9ef976b Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 17 Apr 2008 06:37:46 +0000
Subject: 3.0.0rc1 is merged to the main trunk.

---
 ChangeLog                |  79 +++++++-
 NEWS                     |  45 +++++
 README                   |  34 +++-
 TODO                     |   9 +-
 configure.ac             |   2 +-
 qrenc.c                  | 134 ++++++++++---
 qrencode.1.in            |   3 +
 qrencode.c               | 202 +++++++++++++++++--
 qrencode.h               | 269 ++++++++++++++++++++++---
 qrencode_inner.h         |   2 +-
 qrinput.c                | 497 +++++++++++++++++++++++++++++++++++++++++++---
 qrinput.h                |  58 ++++--
 rscode.c                 |   4 +-
 split.c                  |  95 +++++----
 split.h                  |  14 +-
 tests/Makefile.am        |   9 +-
 tests/common.h           |  60 +++++-
 tests/prof_qrencode.c    |  20 +-
 tests/test_all.sh        |   9 +
 tests/test_estimatebit.c |  21 +-
 tests/test_monkey.c      | 277 ++++++++++++++++++++++++++
 tests/test_qrencode.c    | 100 +++++++++-
 tests/test_qrinput.c     | 505 ++++++++++++++++++++++++++++++++++++++++++++++-
 tests/test_split.c       |  76 +++----
 tests/view_qrcode.c      | 194 ++++++++++++++----
 25 files changed, 2442 insertions(+), 276 deletions(-)
 create mode 100755 tests/test_all.sh
 create mode 100644 tests/test_monkey.c

diff --git a/ChangeLog b/ChangeLog
index 0bea6fd11d..d01dd0db4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,80 @@
+2008.04.14 Kentaro FUKUCHI 
+	* Bumped version to 3.0.0.
+	* qrencode.[ch]:
+	  - QRcode_encodeInput() has changed the API. Previously it takes a
+	    QRinput, version and level, but now it takes only a QRinput, because
+		QRinput holds the version and level in it. From 3.0.0, you should set
+		them by calling QRinput_setVersion() and
+		QRinput_setErrorCorrectionLevel(), or use QRinput_new2() to
+		instantiate a QRinput object.
+
+2008.04.14 Kentaro FUKUCHI 
+	* qrspe.c:
+	  - NULL check has been added.
+	* split.[ch]:
+	  - API changed.
+	* qrencode.c:
+	  - Arguments (version and level) are now checked in QRcode_encodeMask().
+	    Internal functions trust the arguments are valid.
+	  - Error checks improved.
+	* qrinput.c:
+	  - Error checks improved.
+	* qrencode.h:
+	  - Documentation improvements.
+
+2008.04.13 Kentaro FUKUCHI 
+	* qrencode.c, qrencode_innter.h, tests/view_qrcode.c:
+	  - Changed API of QRcode_encodeMask().
+	* qrencode.[ch], qrinput.[ch], split.[ch]:
+	  - Some functions now set errno appropriately.
+
+2008.04.09 Kentaro FUKUCHI 
+	* qrencode.h, qrinput.c:
+	  - QRinput_Struct_insertStructuredAppendHeaders() and
+	    QRinput_insertStructuredAppendHeader now returns error, when the input
+		contains too many structured inputs.
+	* qrencode.c:
+	  - QRcode_encodeInputToStructured() now returns NULL when
+	    QRinput_splitQRinputToStruct() fails.
+	* tests/view_qrcode.c:
+	  - Segmentation fault bug has been fixed. (see previous memo)
+
+2008.04.08 Kentaro FUKUCHI 
+	* qrinput.c:
+	  - Fixed a bug in QRinput_estimateBitStreamSizeOfEntry(). It could over-
+	    estimate the size.
+	* rscode.c:
+	  - Optimized the order of the parameters equality test in init_rs().
+	* qrspec.c, qrspec.h:
+	  - Added QRspec_clearCache().
+	* tests/test_estimatebit.c:
+	  - Bug fixed in test_numbit3().
+
+2008.04.07 Kentaro FUKUCHI 
+	* Bumped version to 2.1.0.
+	* Structured append is now supported (patches from Yusuke Mihara):
+	  - Two new types, QRcode_List and QRinput_Struct, have been added.
+	  - Following functions have been added:
+	    - QRcode_encodeStructuredInput()
+	    - QRcode_encodeStringStructured()
+	    - QRcode_encodeString8bitStructured()
+	  - Some functions to handle structured append symbols have been added.
+	    See Doxygen-ized descriptions for the details.
+	* qrenc.c:
+	  - "-S" option has been added for structured append.
+	* split.h:
+	  - "extern" was dropped.
+	* qrinput.h, qrencode.h:
+	  - Moved declarations of QRinput_{get,set}{Version,ErrorCorrectionLevel}
+	    from qrinput.h to qrencode.h. Now they are publicly accessible.
+	* qrencode.h, qrinput.h, qrinput.c:
+	  - Added QRinput_new2().
+	  - QRinput_newEntry(), QRinput_freeEntry have been renamed to
+	    QRinput_List_newEntry(), QRinput_List_freeEntry().
+	* split.c:
+	  - Bug fix: Split_eat8() now eats at least 1 byte. Previously it could
+	    produce a 0-length input entry.
+
 2008.01.23 Kentaro FUKUCHI 
 	* qrencode.1.in, Makefile.am, configure.ac:
 	  - Manpage of qrencode has been added.
@@ -11,7 +88,7 @@
 	  - Followed recent API changes.
 	  - Added new test "test_toupper()".
 	* qrenc.c, tests/view_qrcode.c:
-	  - Source-level compatiblity has been improved.
+	  - Source-level compatibility has been improved.
 	  - view_qrcode now accepts stdin like qrencode.
 	  - Usage message has been updated/fixed.
 	* Copyright year has been updated.
diff --git a/NEWS b/NEWS
index 0e2bd502a3..f17ee1e093 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,51 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
+Version 3.0.0 (2008.4.x)
+------------------------
+Summary:
+* A significant API change that requires to modify user applications.
+* Structured append support has been added. (patches from Yusuke Mihara)
+* "-S" option for structured append has been added to qrencode and view_qrcode.
+
+Release Note:
+
+Now libqrencode supports "structured-append" of symbols. A large data set can
+be split into multiple QR code symbols. The basic usage of structured-append
+is not so different from the single symbol encoding: just call
+QRcode_encodeStringStructured() or QRcode_encodeString8bitStructured() and
+they return a list of symbols. Instead of giving a string, you can encode
+an explicitly typed data. See the manual generated by Doxygen for the detailed
+usage.
+
+Many thanks to Yusuke Mihara, who contributed a patch to add support of
+structured-append to version 1.0.2.
+
+API changes:
+* Incompatible API changes:
+  - QRencode_encodeInput
+* New types:
+  - QRinput_Struct
+  - QRcode_List
+* New functions:
+  - QRinput_new2
+  - QRinput_Struct_new
+  - QRinput_Struct_setParity
+  - QRinput_Struct_appendInput
+  - QRinput_Struct_free
+  - QRinput_Struct_insertStructuredAppendHeaders
+  - QRinput_splitQRinputToStruct
+  - QRcode_encodeStructuredInput
+  - QRcode_encodeStringStructured
+  - QRcode_encodeString8bitStructured
+  - QRcode_List_size
+  - QRcode_List_free
+* Declarations moved to qrencode.h:
+  - QRinput_getErrorCorrectionLevel
+  - QRinput_setErrorCorrectionLevel
+  - QRinput_getVersion
+  - QRinput_setVersion
+
 Version 2.0.0 (2008.1.24)
 --------------------------
 Summary:
diff --git a/README b/README
index 8aff41798a..b56fd70308 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-libqrencode 2.0.0 - QR Code encoding library
+libqrencode 3.0.0 - QR Code encoding library
 
 GENERAL INFORMATION
 ===================
@@ -7,16 +7,27 @@ symbology that can be scanned by handy terminals such as a mobile phone with
 CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has
 high robustness.
 
+Libqrencode accepts a string or a list of data chunks then encodes in a QR Code
+symbol as a bitmap array. While other QR Code applications generate image files,
+using libqrencode allows applications to render QR Code symbols from raw bitmap
+data directly. This library also contains a command-line utility outputs a QR
+Code symbol as a PNG image. It will help lightweight CGI programs.
+
 
 SPECIFICATION
 =============
 Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial
-Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are
-not supported:
+Standards) X0510:2004 or ISO/IEC 18004. Most of features in the specification
+are implemented such as:
+- Numeric, alphabet, Japanese kanji (Shift-JIS) or any 8 bit code can be
+  embedded
+- Optimized encoding of a string
+- Structured-append of symbols
+
+Currently the following features are not supported:
 - ECI and FNC1 mode
-- Structured Append Feature
 - Micro QR Code
-- QR Code model 1
+- QR Code model 1 (deprecated)
 
 
 INSTALL
@@ -24,10 +35,9 @@ INSTALL
 
 Requirements
 ------------
-Some test programs or utility tools requires SDL or PNG, but the library itself
-has no dependencies. You can skip compiling those tools when if you want not to
-install programs using SDL or PNG. If you are trying to compile this library on
-MS-Windows, cygwin or some kinds of UNIX-like environments will be needed.
+Some test programs or utility tools uses SDL or PNG, but the library itself
+has no dependencies. You can skip compiling those tools if you want not to
+install programs using SDL or PNG.
 
 Compile & install
 -----------------
@@ -51,7 +61,7 @@ USAGE
 Basic usages of this library are written in the header file (qrencode.h).
 You can generate a manual of the library by using Doxygen.
 
-WARNING: This library is thread UNSAFE.
+WARNING: Some functions are THREAD UNSAFE. See qrencode.h for the details.
 
 
 LICENSING INFORMATION
@@ -91,3 +101,7 @@ countries.
 
 Reed-Solomon code encoder is written by Phil Karn, KA9Q.
 Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
+
+NANKI Haruo       - improved lower-case characteres encoding
+Philippe Delcroix - improved mask evaluation
+Yusuke Mihara     - structured-append support
diff --git a/TODO b/TODO
index 1dff2425c8..71b4df181d 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,15 @@
 Thread unsafe.
 Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe, but
 all of qrencode functions are thread unsafe because of them.
+Version 3.0 of libqrencode will introduce semaphores to avoid this problem.
+It also requires, however, a kind of init function of libqrencode such as
+QRencode_init().
 
 This package contains
 
-*.c and *.h files (total):  5916 lines, 146312 bytes.
-configure script         : 22510 lines, 724802 bytes.
+*.c and *.h files (total):  7967 lines, 196078 bytes.
+configure script         : 22511 lines, 724922 bytes.
 
 It's absolutely crazy.
+
+This library does not return any error code (just returns NULL silently).
diff --git a/configure.ac b/configure.ac
index 72771f155f..ee2d1c179a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 AC_INIT(QRencode)
 
-MAJOR_VERSION=2
+MAJOR_VERSION=3
 MINOR_VERSION=0
 MICRO_VERSION=0
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
diff --git a/qrenc.c b/qrenc.c
index 45d7d837ed..d29c5bf345 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -31,6 +31,7 @@ static int eightbit = 0;
 static int version = 0;
 static int size = 3;
 static int margin = 4;
+static int structured = 0;
 static QRecLevel level = QR_ECLEVEL_L;
 static QRencodeMode hint = QR_MODE_8;
 
@@ -45,6 +46,7 @@ enum {
 	O_CASE,
 	O_IGNORECASE,
 	O_8BIT,
+	O_STRUCTURED,
 };
 
 static const struct option options[] = {
@@ -58,6 +60,7 @@ static const struct option options[] = {
 	{"c", no_argument      , NULL, O_CASE},
 	{"i", no_argument      , NULL, O_IGNORECASE},
 	{"8", no_argument      , NULL, O_8BIT},
+	{"S", no_argument      , NULL, O_STRUCTURED},
 	{NULL, 0, NULL, 0}
 };
 
@@ -65,17 +68,20 @@ static void usage(void)
 {
 	fprintf(stderr,
 "qrencode version %s\n"
-"Copyright (C) 2008 Kentaro Fukuchi\n"
+"Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi\n"
 "Usage: qrencode [OPTION]... [STRING]\n"
 "Encode input data in a QR Code and save as a PNG image.\n\n"
 "  -h           display this message.\n"
 "  -o FILENAME  write PNG image to FILENAME. If '-' is specified, the result\n"
-"               will be output to standard output.\n"
+"               will be output to standard output. If -S is given, structured\n"
+"               symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n"
+"               if specified, remove a trailing '.png' from FILENAME.\n"
 "  -s NUMBER    specify the size of dot (pixel). (default=3)\n"
 "  -l {LMQH}    specify error collectin level from L (lowest) to H (highest).\n"
 "               (default=L)\n"
 "  -v NUMBER    specify the version of the symbol. (default=auto)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
+"  -S           make structured symbols. Version must be specified.\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
 "  -c           encode lower-case alphabet characters in 8-bit mode. (default)\n"
 "  -i           ignore case distinctions and use only upper-case characters.\n"
@@ -85,7 +91,7 @@ static void usage(void)
 	VERSION);
 }
 
-#define MAX_DATA_SIZE 7090 /* from the specification */
+#define MAX_DATA_SIZE (7090 * 16) /* from the specification */
 static char *readStdin(void)
 {
 	char *buffer;
@@ -107,37 +113,21 @@ static char *readStdin(void)
 	return buffer;
 }
 
-static QRcode *encode(const char *intext)
-{
-	QRcode *code;
-
-	if(eightbit) {
-		code = QRcode_encodeString8bit(intext, version, level);
-	} else {
-		code = QRcode_encodeString(intext, version, level, hint, casesensitive);
-	}
-
-	return code;
-}
-
-static void qrencode(const char *intext, const char *outfile)
+static int writePNG(QRcode *qrcode, const char *outfile)
 {
 	FILE *fp;
-	QRcode *qrcode;
 	png_structp png_ptr;
 	png_infop info_ptr;
 	unsigned char *row, *p, *q;
 	int x, y, xx, yy, bit;
 	int realwidth;
-	
-	qrcode = encode(intext);
-	if(qrcode == NULL) {
-		fprintf(stderr, "Failed to encode the input data.\n");
-		exit(1);
-	}
 
 	realwidth = (qrcode->width + margin * 2) * size;
 	row = (unsigned char *)malloc((realwidth + 7) / 8);
+	if(row == NULL) {
+		fprintf(stderr, "Failed to allocate memory.\n");
+		exit(1);
+	}
 
 	if(outfile[0] == '-' && outfile[1] == '\0') {
 		fp = stdout;
@@ -221,9 +211,93 @@ static void qrencode(const char *intext, const char *outfile)
 
 	fclose(fp);
 	free(row);
+
+	return 0;
+}
+
+static QRcode *encode(const char *intext)
+{
+	QRcode *code;
+
+	if(eightbit) {
+		code = QRcode_encodeString8bit(intext, version, level);
+	} else {
+		code = QRcode_encodeString(intext, version, level, hint, casesensitive);
+	}
+
+	return code;
+}
+
+static void qrencode(const char *intext, const char *outfile)
+{
+	QRcode *qrcode;
+	
+	qrcode = encode(intext);
+	if(qrcode == NULL) {
+		fprintf(stderr, "Failed to encode the input data.\n");
+		exit(1);
+	}
+	writePNG(qrcode, outfile);
 	QRcode_free(qrcode);
 }
 
+static QRcode_List *encodeStructured(const char *intext)
+{
+	QRcode_List *list;
+
+	if(eightbit) {
+		list = QRcode_encodeString8bitStructured(intext, version, level);
+	} else {
+		list = QRcode_encodeStringStructured(intext, version, level, hint, casesensitive);
+	}
+
+	return list;
+}
+
+static void qrencodeStructured(const char *intext, const char *outfile)
+{
+	QRcode_List *qrlist, *p;
+	char filename[FILENAME_MAX];
+	char *base, *q, *suffix = NULL;
+	int i = 1;
+
+	base = strdup(outfile);
+	if(strlen(base) > 4) {
+		q = base + strlen(base) - 4;
+		if(strcasecmp(".png", q) == 0) {
+			suffix = strdup(q);
+			*q = '\0';
+		}
+	}
+	
+	qrlist = encodeStructured(intext);
+	if(qrlist == NULL) {
+		fprintf(stderr, "Failed to encode the input data.\n");
+		exit(1);
+	}
+
+	for(p = qrlist; p != NULL; p = p->next) {
+		if(p->code == NULL) {
+			fprintf(stderr, "Failed to encode the input data.\n");
+			exit(1);
+		}
+		if(suffix) {
+			snprintf(filename, FILENAME_MAX, "%s-%02d%s", base, i, suffix);
+		} else {
+			snprintf(filename, FILENAME_MAX, "%s-%02d", base, i);
+		}
+		writePNG(p->code, filename);
+		i++;
+	}
+
+	free(base);
+	if(suffix) {
+		free(suffix);
+	}
+
+	QRcode_List_free(qrlist);
+}
+
 int main(int argc, char **argv)
 {
 	int opt;
@@ -284,6 +358,8 @@ int main(int argc, char **argv)
 					exit(1);
 				}
 				break;
+			case O_STRUCTURED:
+				structured = 1;
 			case O_KANJI:
 				hint = QR_MODE_KANJI;
 				break;
@@ -320,7 +396,15 @@ int main(int argc, char **argv)
 		intext = readStdin();
 	}
 
-	qrencode(intext, outfile);
+	if(structured) {
+		if(version == 0) {
+			fprintf(stderr, "Version must be specified to encode structured symbols.\n");
+			exit(1);
+		}
+		qrencodeStructured(intext, outfile);
+	} else {
+		qrencode(intext, outfile);
+	}
 
 	return 0;
 }
diff --git a/qrencode.1.in b/qrencode.1.in
index 8f1106ca3e..25344eb3bc 100644
--- a/qrencode.1.in
+++ b/qrencode.1.in
@@ -36,6 +36,9 @@ specify the version of the symbol. (default=auto)
 .B \-m NUMBER
 specify the width of margin. (default=4)
 .TP
+.B \-S
+make structured symbols. Version must be specified.
+.TP
 .B \-k
 assume that the input text contains kanji (shift-jis).
 .TP
diff --git a/qrencode.c b/qrencode.c
index d2fe711ee8..4bc9e50080 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "qrencode.h"
 #include "qrencode_inner.h"
@@ -65,6 +66,10 @@ QRRawCode *QRraw_new(QRinput *input)
 	raw = (QRRawCode *)malloc(sizeof(QRRawCode));
 	raw->datacode = p;
 	spec = QRspec_getEccSpec(input->version, input->level);
+	if(spec == NULL) {
+		free(raw);
+		return NULL;
+	}
 	raw->version = input->version;
 	raw->blocks = QRspec_rsBlockNum(spec);
 	raw->rsblock = (RSblock *)malloc(sizeof(RSblock) * raw->blocks);
@@ -253,6 +258,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler)
 	return &p[y * w + x];
 }
 
+#if 0
 unsigned char *FrameFiller_fillerTest(int version)
 {
 	int width, length;
@@ -292,6 +298,7 @@ unsigned char *FrameFiller_fillerTest(int version)
 
 	return frame;
 }
+#endif
 
 /******************************************************************************
  * Format information
@@ -366,22 +373,27 @@ void QRcode_free(QRcode *qrcode)
 	free(qrcode);
 }
 
-QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask)
+QRcode *QRcode_encodeMask(QRinput *input, int mask)
 {
-	int width;
+	int width, version;
 	QRRawCode *raw;
 	unsigned char *frame, *masked, *p, code, bit;
 	FrameFiller *filler;
 	int i, j;
 	QRcode *qrcode;
 
-	QRinput_setVersion(input, version);
-	QRinput_setErrorCorrectionLevel(input, level);
-
-	raw = QRraw_new(input);
-	if(raw == NULL) {
+	if(input->version < 0 || input->version > QRSPEC_VERSION_MAX) {
+		errno = EINVAL;
+		return NULL;
+	}
+	if(input->level < QR_ECLEVEL_L || input->level > QR_ECLEVEL_H) {
+		errno = EINVAL;
 		return NULL;
 	}
+
+	raw = QRraw_new(input);
+	if(raw == NULL) return NULL;
+
 	version = raw->version;
 	width = QRspec_getWidth(version);
 	frame = QRspec_newFrame(version);
@@ -407,10 +419,10 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask
 	free(filler);
 	/* masking */
 	if(mask < 0) {
-		masked = Mask_mask(width, frame, level);
+		masked = Mask_mask(width, frame, input->level);
 	} else {
 		masked = Mask_makeMask(width, frame, mask);
-		QRcode_writeFormatInformation(width, masked, mask, QRinput_getErrorCorrectionLevel(input));
+		QRcode_writeFormatInformation(width, masked, mask, input->level);
 	}
 	qrcode = QRcode_new(version, width, masked);
 
@@ -419,9 +431,9 @@ QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask
 	return qrcode;
 }
 
-QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level)
+QRcode *QRcode_encodeInput(QRinput *input)
 {
-	return QRcode_encodeMask(input, version, level, -1);
+	return QRcode_encodeMask(input, -1);
 }
 
 QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level)
@@ -429,9 +441,11 @@ QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level
 	QRinput *input;
 	QRcode *code;
 
-	input = QRinput_new();
+	input = QRinput_new2(version, level);
+	if(input == NULL) return NULL;
+
 	QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string);
-	code = QRcode_encodeInput(input, version, level);
+	code = QRcode_encodeInput(input);
 	QRinput_free(input);
 
 	return code;
@@ -441,15 +455,171 @@ QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QR
 {
 	QRinput *input;
 	QRcode *code;
+	int ret;
 
 	if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) {
+		errno = EINVAL;
+		return NULL;
+	}
+
+	input = QRinput_new2(version, level);
+	if(input == NULL) return NULL;
+
+	ret = Split_splitStringToQRinput(string, input, hint, casesensitive);
+	if(ret < 0) {
+		QRinput_free(input);
 		return NULL;
 	}
 
-	input = QRinput_new();
-	Split_splitStringToQRinput(string, input, version, hint, casesensitive);
-	code = QRcode_encodeInput(input, version, level);
+	code = QRcode_encodeInput(input);
 	QRinput_free(input);
 
 	return code;
 }
+
+/******************************************************************************
+ * Structured QR-code encoding
+ *****************************************************************************/
+
+static QRcode_List *QRcode_List_newEntry(void)
+{
+	QRcode_List *entry;
+
+	entry = (QRcode_List *)malloc(sizeof(QRcode_List));
+	if(entry == NULL) return NULL;
+
+	entry->next = NULL;
+	entry->code = NULL;
+
+	return entry;
+}
+
+static void QRcode_List_freeEntry(QRcode_List *entry)
+{
+	if(entry->code != NULL) QRcode_free(entry->code);
+	free(entry);
+}
+
+void QRcode_List_free(QRcode_List *qrlist)
+{
+	QRcode_List *list = qrlist, *next;
+
+	while(list != NULL) {
+		next = list->next;
+		QRcode_List_freeEntry(list);
+		list = next;
+	}
+}
+
+int QRcode_List_size(QRcode_List *qrlist)
+{
+	QRcode_List *list = qrlist;
+	int size = 0;
+
+	while(list != NULL) {
+		size++;
+		list = list->next;
+	}
+
+	return size;
+}
+
+#if 0
+static unsigned char QRcode_parity(const char *str, int size)
+{
+	unsigned char parity = 0;
+	int i;
+
+	for(i=0; ihead;
+
+	while(list != NULL) {
+		if(head == NULL) {
+			head = QRcode_List_newEntry();
+			tail = head;
+		} else {
+			tail->next = QRcode_List_newEntry();
+			tail = tail->next;
+		}
+		tail->code = QRcode_encodeInput(list->input);
+		if(tail->code == NULL) {
+			QRcode_List_free(head);
+			return NULL;
+		}
+		list = list->next;
+	}
+
+	return head;
+}
+
+static QRcode_List *QRcode_encodeInputToStructured(QRinput *input)
+{
+	QRinput_Struct *s;
+	QRcode_List *codes;
+
+	s = QRinput_splitQRinputToStruct(input);
+	if(s == NULL) return NULL;
+
+	codes = QRcode_encodeStructuredInput(s);
+	QRinput_Struct_free(s);
+
+	return codes;
+}
+
+QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level)
+{
+	QRinput *input;
+	QRcode_List *codes;
+	int ret;
+
+	if(version <= 0) return NULL;
+
+	input = QRinput_new2(version, level);
+	if(input == NULL) return NULL;
+
+	ret = QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string);
+	if(ret < 0) {
+		QRinput_free(input);
+		return NULL;
+	}
+	codes = QRcode_encodeInputToStructured(input);
+	QRinput_free(input);
+
+	return codes;
+}
+
+QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
+{
+	QRinput *input;
+	QRcode_List *codes;
+	int ret;
+
+	if(version <= 0) return NULL;
+	if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) {
+		return NULL;
+	}
+
+	input = QRinput_new2(version, level);
+	if(input == NULL) return NULL;
+
+	ret = Split_splitStringToQRinput(string, input, hint, casesensitive);
+	if(ret < 0) {
+		QRinput_free(input);
+		return NULL;
+	}
+	codes = QRcode_encodeInputToStructured(input);
+	QRinput_free(input);
+
+	return codes;
+}
diff --git a/qrencode.h b/qrencode.h
index 576cf6a509..123ba33820 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -22,12 +22,12 @@
  * Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D
  * symbology.
  *
- * 

Encoding

+ * \section encoding Encoding * * There are two ways to encode data: encoding a string or * encoding a structured data. * - *

Encoding a string

+ * \subsection encoding-string Encoding a string * You can encode a string by calling QRcode_encodeString(). * The given string is parsed automatically and encoded. If you want to encode * data that can be represented as a C string style (NUL terminated), you can @@ -36,11 +36,13 @@ * If the input data contains Kanji (Shift-JIS) characters and you want to * encode them as Kanji in QR Code, you should give QR_MODE_KANJI as a hint. * Otherwise, all of non-alphanumeric characters are encoded as 8 bit data. + * If you want to encode a whole string in 8 bit mode, use + * QRcode_encodeString8bit() instead. * * Please note that a C string can not contain NUL character. If your data * contains NUL, you should chose the second way. * - *

Encoding a structured data

+ * \subsection encoding-input Encoding a structured data * You can construct a structured input data manually. If the structure of the * input data is known, you can use this way. * At first, you must create a ::QRinput object by QRinput_new(). Then, you can @@ -49,7 +51,7 @@ * You can reuse the QRinput data again to encode it in other symbols with * different parameters. * - *

Result

+ * \section result Result * The encoded symbol is resulted as a ::QRcode object. It will contain * its version number, width of the symbol and an array represents the symbol. * See ::QRcode for the details. You can free the object by QRcode_free(). @@ -58,6 +60,40 @@ * In such cases, the input data would be too large to be encoded in the * symbol of the specified version. * + * \section structured Structured append + * Libqrencode can generate "Structured-appended" symbols that enables to split + * a large data set into mulitple QR codes. A QR code reader concatenates + * multiple QR code symbols into a string. + * Just like QRcode_encodeString(), you can use QRcode_encodeStringStructured() + * to generate structured-appended symbols. This functions returns an instance + * of ::QRcode_List. The returned list is a singly-linked list of QRcode: you + * can retrieve each QR code in this way: + * + * \code + * QRcode_List *qrcodes; + * QRcode_List *entry; + * QRcode *qrcode; + * + * qrcodes = QRcode_encodeStringStructured(...); + * entry = qrcodes; + * while(entry != NULL) { + * qrcode = entry->code; + * // do something + * entry = entry->next; + * } + * QRcode_List_free(entry); + * \endcode + * + * Instead of using auto-parsing functions, you can construct your own + * structured input. At first, instantiate an object of ::QRinput_Struct + * by calling QRinput_Struct_new(). This object can hold multiple ::QRinput, + * and one QR code is generated for a ::QRinput. + * QRinput_Struct_appendInput() appends a ::QRinput to a ::QRinput_Struct + * object. In order to generate structured-appended symbols, it is required to + * embed headers to each symbol. You can use + * QRinput_Struct_insertStructuredAppendHeaders() to insert appropriate + * headers to each symbol. You should call this function just once before + * encoding symbols. */ #ifndef __QRENCODE_H__ @@ -74,7 +110,8 @@ typedef enum { QR_MODE_NUM = 0, ///< Numeric mode QR_MODE_AN, ///< Alphabet-numeric mode QR_MODE_8, ///< 8-bit data mode - QR_MODE_KANJI ///< Kanji (shift-jis) mode + QR_MODE_KANJI, ///< Kanji (shift-jis) mode + QR_MODE_STRUCTURE, ///< Internal use only } QRencodeMode; /** @@ -88,31 +125,85 @@ typedef enum { } QRecLevel; /****************************************************************************** - * Input data + * Input data (qrinput.c) *****************************************************************************/ /** - * Data structure to store input data. + * Singly linked list to contain input strings. An instance of this class + * contains its version and error correction level too. It is required to + * set them by QRinput_setVersion() and QRinput_setErrorCorrectionLevel(), + * or use QRinput_new2() to instantiate an object. */ typedef struct _QRinput QRinput; /** - * Instantiate an input data object. - * @return input object (initialized). + * Instantiate an input data object. The version is set to 0 (auto-select) + * and the error correction level is set to QR_ECLEVEL_L. + * @return an input object (initialized). On error, NULL is returned and errno + * is set to indicate the error. + * @throw ENOMEM unable to allocate memory. */ extern QRinput *QRinput_new(void); /** - * Append data to the input object. + * Instantiate an input data object. + * @param version version number. + * @param level Error correction level. + * @return an input object (initialized). On error, NULL is returned and errno + * is set to indicate the error. + * @throw ENOMEM unable to allocate memory for input objects. + * @throw EINVAL invalid arguments. + */ +extern QRinput *QRinput_new2(int version, QRecLevel level); + +/** + * Append data to an input object. * The data is copied and appended to the input object. * @param input input object. * @param mode encoding mode. * @param size size of data (byte). * @param data a pointer to the memory area of the input data. - * @return -1 when the input data is invalid. Otherwise, return 0. + * @retval 0 success. + * @retval -1 an error occurred and errno is set to indeicate the error. + * See Execptions for the details. + * @throw ENOMEM unable to allocate memory. + * @throw EINVAL input data is invalid. + * */ extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data); +/** + * Get current version. + * @param input input object. + * @return current version. + */ +extern int QRinput_getVersion(QRinput *input); + +/** + * Set version of the QR-code that is to be encoded. + * @param input input object. + * @param version version number (0 = auto) + * @retval 0 success. + * @retval -1 invalid argument. + */ +extern int QRinput_setVersion(QRinput *input, int version); + +/** + * Get current error correction level. + * @param input input object. + * @return Current error correcntion level. + */ +extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input); + +/** + * Set error correction level of the QR-code that is to be encoded. + * @param input input object. + * @param level Error correction level. + * @retval 0 success. + * @retval -1 invalid argument. + */ +extern int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level); + /** * Free the input object. * All of data chunks in the input object are freed too. @@ -122,15 +213,78 @@ extern void QRinput_free(QRinput *input); /** * Validate the input data. - * @param mode - * @param size - * @param data - * @return result return -1 if the input is invalid. Otherwise, return 0. + * @param mode encoding mode. + * @param size size of data (byte). + * @param data a pointer to the memory area of the input data. + * @retval 0 success. + * @retval -1 invalid arguments. */ extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data); +/** + * Set of QRinput for structured symbols. + */ +typedef struct _QRinput_Struct QRinput_Struct; + +/** + * Instantiate a set of input data object. + * @return an instance of QRinput_Struct. On error, NULL is returned and errno + * is set to indicate the error. + * @throw ENOMEM unable to allocate memory. + */ +extern QRinput_Struct *QRinput_Struct_new(void); + +/** + * Set parity of structured symbols. + * @param s structured input object. + * @param parity parity of s. + */ +extern void QRinput_Struct_setParity(QRinput_Struct *s, unsigned char parity); + +/** + * Append a QRinput object to the set. + * @warning never append the same QRinput object twice. + * @param s structured input object. + * @param input an input object. + * @retval >0 number of input objects in the structure. + * @retval -1 an error occurred. See Exceptions for the details. + * @throw ENOMEM unable to allocate memory. + */ +extern int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input); + +/** + * Free all of QRinput in the set. + * @param s a structured input object. + */ +extern void QRinput_Struct_free(QRinput_Struct *s); + +/** + * Split a QRinput to QRinput_Struct. It calculates a parity, set it, then + * insert structured-append headers. + * @param input input object. Version number and error correction level must be + * set. + * @return a set of input data. On error, NULL is returned, and errno is set + * to indicate the error. See Exceptions for the details. + * @throw ERANGE input data is too large. + * @throw EINVAL invalid input data. + * @throw ENOMEM unable to allocate memory. + */ +extern QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input); + +/** + * Insert structured-append headers to the input structure. It calculates + * a parity and set it if the parity is not set yet. + * @param s input structure + * @retval 0 success. + * @retval -1 an error occurred and errno is set to indeicate the error. + * See Execptions for the details. + * @throw EINVAL invalid input object. + * @throw ENOMEM unable to allocate memory. + */ +extern int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s); + /****************************************************************************** - * QRcode output + * QRcode output (qrencode.c) *****************************************************************************/ /** @@ -138,7 +292,7 @@ extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) * Symbol data is represented as an array contains width*width uchars. * Each uchar represents a module (dot). If the less significant bit of * the uchar is 1, the corresponding module is black. The other bits are - * meaningless for usual applications, but here the specification is described. + * meaningless for usual applications, but here its specification is described. * *
  * MSB 76543210 LSB
@@ -158,23 +312,37 @@ typedef struct {
 	unsigned char *data; ///< symbol data
 } QRcode;
 
+/**
+ * Singly-linked list of QRcode. Used to represent a structured symbols.
+ * A list is terminated with NULL.
+ */
+typedef struct _QRcode_List QRcode_List;
+
+struct _QRcode_List {
+	QRcode *code;
+	QRcode_List *next;
+};
+
 /**
  * Create a symbol from the input data.
+ * @warning This function is THREAD UNSAFE.
  * @param input input data.
- * @param version version of the symbol. If 0, the library chooses the minimum
- *                version for the input data.
- * @param level error correction level.
  * @return an instance of QRcode class. The version of the result QRcode may
- *         be larger than the designated version.
+ *         be larger than the designated version. On error, NULL is returned,
+ *         and errno is set to indicate the error. See Exceptions for the
+ *         details.
+ * @throw EINVAL invalid input object.
+ * @throw ENOMEM unable to allocate memory for input objects.
  */
-extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level);
+extern QRcode *QRcode_encodeInput(QRinput *input);
 
 /**
  * Create a symbol from the string. The library automatically parses the input
  * string and encodes in a QR Code symbol.
- * @param string input string. It should be NULL terminated.
+ * @warning This function is THREAD UNSAFE.
+ * @param string input string. It must be NULL terminated.
  * @param version version of the symbol. If 0, the library chooses the minimum
- *                version for the input data.
+ *                version for the given input data.
  * @param level error correction level.
  * @param hint tell the library how non-alphanumerical characters should be
  *             encoded. If QR_MODE_KANJI is given, kanji characters will be
@@ -183,12 +351,17 @@ extern QRcode *QRcode_encodeInput(QRinput *input, int version, QRecLevel level);
  *             to embed UTF-8 string, choose this.
  * @param casesensitive case-sensitive(1) or not(0).
  * @return an instance of QRcode class. The version of the result QRcode may
- *         be larger than the designated version.
+ *         be larger than the designated version. On error, NULL is returned,
+ *         and errno is set to indicate the error. See Exceptions for the
+ *         details.
+ * @throw EINVAL invalid input object.
+ * @throw ENOMEM unable to allocate memory for input objects.
  */
 extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
 
 /**
- * Same to QRcode_qncodeString, but encode whole data in 8-bit mode.
+ * Same to ::QRcode_qncodeString, but encode whole data in 8-bit mode.
+ * @warning This function is THREAD UNSAFE.
  */
 extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level);
 
@@ -198,6 +371,50 @@ extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLeve
  */
 extern void QRcode_free(QRcode *qrcode);
 
+/**
+ * Create structured symbols from the input data.
+ * @warning This function is THREAD UNSAFE.
+ * @param s
+ * @return a singly-linked list of QRcode.
+ */
+extern QRcode_List *QRcode_encodeStructuredInput(QRinput_Struct *s);
+
+/**
+ * Create structured symbols from the string. The library automatically parses
+ * the input string and encodes in a QR Code symbol.
+ * @warning This function is THREAD UNSAFE.
+ * @param string input string. It should be NULL terminated.
+ * @param version version of the symbol.
+ * @param level error correction level.
+ * @param hint tell the library how non-alphanumerical characters should be
+ *             encoded. If QR_MODE_KANJI is given, kanji characters will be
+ *             encoded as Shif-JIS characters. If QR_MODE_8 is given, all of
+ *             non-alphanumerical characters will be encoded as is. If you want
+ *             to embed UTF-8 string, choose this.
+ * @param casesensitive case-sensitive(1) or not(0).
+ * @return a singly-linked list of QRcode.
+ */
+extern QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
+
+/**
+ * Same to QRcode_qncodeStringStructured, but encode whole data in 8-bit mode.
+ * @warning This function is THREAD UNSAFE.
+ */
+extern QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level);
+
+/**
+ * Return the number of symbols included in a QRcode_List.
+ * @param qrlist a head entry of a QRcode_List.
+ * @return number of symbols in the list.
+ */
+extern int QRcode_List_size(QRcode_List *qrlist);
+
+/**
+ * Free the QRcode_List.
+ * @param qrlist a head entry of a QRcode_List.
+ */
+extern void QRcode_List_free(QRcode_List *qrlist);
+
 #if defined(__cplusplus)
 }
 #endif
diff --git a/qrencode_inner.h b/qrencode_inner.h
index febde1e163..2725a785d1 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -79,5 +79,5 @@ extern unsigned char *FrameFiller_fillerTest(int version);
  *****************************************************************************/
 extern int QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
 
-extern QRcode *QRcode_encodeMask(QRinput *input, int version, QRecLevel level, int mask);
+extern QRcode *QRcode_encodeMask(QRinput *input, int mask);
 #endif /* __QRENCODE_INNER_H__ */
diff --git a/qrinput.c b/qrinput.c
index 058347db5e..68d05a4573 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "qrencode.h"
 #include "qrspec.h"
@@ -32,18 +33,25 @@
  * Entry of input data
  *****************************************************************************/
 
-static QRinput_List *QRinput_newEntry(QRencodeMode mode, int size, const unsigned char *data)
+static QRinput_List *QRinput_List_newEntry(QRencodeMode mode, int size, const unsigned char *data)
 {
 	QRinput_List *entry;
 
 	if(QRinput_check(mode, size, data)) {
+		errno = EINVAL;
 		return NULL;
 	}
 
 	entry = (QRinput_List *)malloc(sizeof(QRinput_List));
+	if(entry == NULL) return NULL;
+
 	entry->mode = mode;
 	entry->size = size;
 	entry->data = (unsigned char *)malloc(size);
+	if(entry->data == NULL) {
+		free(entry);
+		return NULL;
+	}
 	memcpy(entry->data, data, size);
 	entry->bstream = NULL;
 	entry->next = NULL;
@@ -51,7 +59,7 @@ static QRinput_List *QRinput_newEntry(QRencodeMode mode, int size, const unsigne
 	return entry;
 }
 
-static QRinput_List *QRinput_freeEntry(QRinput_List *entry)
+static QRinput_List *QRinput_List_freeEntry(QRinput_List *entry)
 {
 	QRinput_List *next;
 
@@ -65,19 +73,52 @@ static QRinput_List *QRinput_freeEntry(QRinput_List *entry)
 	return next;
 }
 
+static QRinput_List *QRinput_List_dup(QRinput_List *entry)
+{
+	QRinput_List *n;
+
+	n = (QRinput_List *)malloc(sizeof(QRinput_List));
+	if(n == NULL) return NULL;
+
+	n->mode = entry->mode;
+	n->size = entry->size;
+	n->data = (unsigned char *)malloc(n->size);
+	if(n->data == NULL) {
+		free(n);
+		return NULL;
+	}
+	memcpy(n->data, entry->data, entry->size);
+	n->bstream = NULL;
+	n->next = NULL;
+
+	return n;
+}
+
 /******************************************************************************
  * Input Data
  *****************************************************************************/
 
 QRinput *QRinput_new(void)
+{
+	return QRinput_new2(0, QR_ECLEVEL_L);
+}
+
+QRinput *QRinput_new2(int version, QRecLevel level)
 {
 	QRinput *input;
 
+	if(version < 0 || version > QRSPEC_VERSION_MAX || level < QR_ECLEVEL_L || level > QR_ECLEVEL_H) {
+		errno = EINVAL;
+		return NULL;
+	}
+
 	input = (QRinput *)malloc(sizeof(QRinput));
+	if(input == NULL) return NULL;
+
 	input->head = NULL;
 	input->tail = NULL;
-	input->version = 0;
-	input->level = QR_ECLEVEL_L;
+	input->version = version;
+	input->level = level;
 
 	return input;
 }
@@ -87,14 +128,16 @@ int QRinput_getVersion(QRinput *input)
 	return input->version;
 }
 
-void QRinput_setVersion(QRinput *input, int v)
+int QRinput_setVersion(QRinput *input, int version)
 {
-	input->version = v;
-}
+	if(version < 0 || version > QRSPEC_VERSION_MAX) {
+		errno = EINVAL;
+		return -1;
+	}
 
-void QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level)
-{
-	input->level = level;
+	input->version = version;
+
+	return 0;
 }
 
 QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input)
@@ -102,15 +145,20 @@ QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input)
 	return input->level;
 }
 
-int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data)
+int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level)
 {
-	QRinput_List *entry;
-
-	entry = QRinput_newEntry(mode, size, data);
-	if(entry == NULL) {
+	if(level < QR_ECLEVEL_L || level > QR_ECLEVEL_H) {
+		errno = EINVAL;
 		return -1;
 	}
 
+	input->level = level;
+
+	return 0;
+}
+
+static void QRinput_appendEntry(QRinput *input, QRinput_List *entry)
+{
 	if(input->tail == NULL) {
 		input->head = entry;
 		input->tail = entry;
@@ -118,6 +166,47 @@ int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned c
 		input->tail->next = entry;
 		input->tail = entry;
 	}
+	entry->next = NULL;
+}
+
+int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data)
+{
+	QRinput_List *entry;
+
+	entry = QRinput_List_newEntry(mode, size, data);
+	if(entry == NULL) {
+		return -1;
+	}
+
+	QRinput_appendEntry(input, entry);
+
+	return 0;
+}
+
+int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity)
+{
+	QRinput_List *entry;
+	unsigned char buf[3];
+
+	if(size > MAX_STRUCTURED_SYMBOLS) {
+		errno = EINVAL;
+		return -1;
+	}
+	if(index <= 0 || index > MAX_STRUCTURED_SYMBOLS) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	buf[0] = (unsigned char)size;
+	buf[1] = (unsigned char)index;
+	buf[2] = parity;
+	entry = QRinput_List_newEntry(QR_MODE_STRUCTURE, 3, buf);
+	if(entry == NULL) {
+		return -1;
+	}
+
+	entry->next = input->head;
+	input->head = entry;
 
 	return 0;
 }
@@ -128,12 +217,49 @@ void QRinput_free(QRinput *input)
 
 	list = input->head;
 	while(list != NULL) {
-		list = QRinput_freeEntry(list);
+		list = QRinput_List_freeEntry(list);
 	}
 
 	free(input);
 }
 
+static unsigned char QRinput_calcParity(QRinput *input)
+{
+	unsigned char parity = 0;
+	QRinput_List *list;
+	int i;
+
+	list = input->head;
+	while(list != NULL) {
+		if(list->mode != QR_MODE_STRUCTURE) {
+			for(i=list->size-1; i>=0; i--) {
+				parity ^= list->data[i];
+			}
+		}
+		list = list->next;
+	}
+
+	return parity;
+}
+
+QRinput *QRinput_dup(QRinput *input)
+{
+	QRinput *n;
+	QRinput_List *list, *e;
+
+	n = QRinput_new2(input->version, input->level);
+	if(n == NULL) return NULL;
+
+	list = input->head;
+	while(list != NULL) {
+		e = QRinput_List_dup(list);
+		QRinput_appendEntry(n, e);
+		list = list->next;
+	}
+
+	return n;
+}
+
 /******************************************************************************
  * Numeric data
  *****************************************************************************/
@@ -411,18 +537,31 @@ static void QRinput_encodeModeKanji(QRinput_List *entry, int version)
 }
 
 /******************************************************************************
- * Validation
+ * Structured Symbol
  *****************************************************************************/
 
 /**
- * Validate the input data
- * @param mode
- * @param size
- * @param data
- * @return result
+ * Convert a structure symbol code to a bit stream.
+ * @param entry
  */
+static void QRinput_encodeModeStructure(QRinput_List *entry, int version)
+{
+	entry->bstream = BitStream_new();
+
+	BitStream_appendNum(entry->bstream, 4, 0x03);
+	BitStream_appendNum(entry->bstream, 4, entry->data[1] - 1);
+	BitStream_appendNum(entry->bstream, 4, entry->data[0] - 1);
+	BitStream_appendNum(entry->bstream, 8, entry->data[2]);
+}
+
+/******************************************************************************
+ * Validation
+ *****************************************************************************/
+
 int QRinput_check(QRencodeMode mode, int size, const unsigned char *data)
 {
+	if(size <= 0) return -1;
+
 	switch(mode) {
 		case QR_MODE_NUM:
 			return QRinput_checkModeNum(size, (const char *)data);
@@ -433,11 +572,17 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data)
 		case QR_MODE_KANJI:
 			return QRinput_checkModeKanji(size, data);
 			break;
+		case QR_MODE_8:
+			return 0;
+			break;
+		case QR_MODE_STRUCTURE:
+			return 0;
+			break;
 		default:
 			break;
 	}
 
-	return 0;
+	return -1;
 }
 
 QRencodeMode QRinput_identifyMode(const char *string)
@@ -493,11 +638,13 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version
 		case QR_MODE_KANJI:
 			bits = QRinput_estimateBitsModeKanji(entry->size);
 			break;
+		case QR_MODE_STRUCTURE:
+			return STRUCTURE_HEADER_BITS;
 	}
 
 	l = QRspec_lengthIndicator(entry->mode, version);
 	m = 1 << l;
-	num = (bits + m - 1) / m;
+	num = (entry->size + m - 1) / m;
 
 	bits += num * (4 + l); // mode indicator (4bits) + length indicator
 
@@ -539,7 +686,7 @@ static int QRinput_estimateVersion(QRinput *input)
 		prev = new;
 		bits = QRinput_estimateBitStreamSize(input, prev);
 		new = QRspec_getMinimumVersion((bits + 7) / 8, input->level);
-		if (new == -1) {
+		if (new < 0) {
 			return -1;
 		}
 	} while (new > prev);
@@ -547,6 +694,55 @@ static int QRinput_estimateVersion(QRinput *input)
 	return new;
 }
 
+/**
+ * Returns required length in bytes for specified mode, version and bits.
+ * @param mode
+ * @param version
+ * @param bits
+ * @return required length of code words in bytes.
+ */
+int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits)
+{
+	int payload, size, chunks, remain, maxsize;
+
+	payload = bits - 4 - QRspec_lengthIndicator(mode, version);
+	switch(mode) {
+		case QR_MODE_NUM:
+			chunks = payload / 10;
+			remain = payload - chunks * 10;
+			size = chunks * 3;
+			if(remain >= 7) {
+				size += 2;
+			} else if(remain >= 4) {
+				size += 1;
+			}
+			break;
+		case QR_MODE_AN:
+			chunks = payload / 11;
+			remain = payload - chunks * 11;
+			size = chunks * 2;
+			if(remain >= 6) size++;
+			break;
+		case QR_MODE_8:
+			size = payload / 8;
+			break;
+		case QR_MODE_KANJI:
+			size = (payload / 13) * 2;
+			break;
+		case QR_MODE_STRUCTURE:
+			size = payload / 8;
+			break;
+		default:
+			size = 0;
+			break;
+	}
+	maxsize = QRspec_maximumWords(mode, version);
+	if(size < 0) size = 0;
+	if(size > maxsize) size = maxsize;
+
+	return size;
+}
+
 /******************************************************************************
  * Data conversion
  *****************************************************************************/
@@ -568,15 +764,15 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version)
 
 	words = QRspec_maximumWords(entry->mode, version);
 	if(entry->size > words) {
-		st1 = QRinput_newEntry(entry->mode, words, entry->data);
-		st2 = QRinput_newEntry(entry->mode, entry->size - words, &entry->data[words]);
+		st1 = QRinput_List_newEntry(entry->mode, words, entry->data);
+		st2 = QRinput_List_newEntry(entry->mode, entry->size - words, &entry->data[words]);
 		QRinput_encodeBitStream(st1, version);
 		QRinput_encodeBitStream(st2, version);
 		entry->bstream = BitStream_new();
 		BitStream_append(entry->bstream, st1->bstream);
 		BitStream_append(entry->bstream, st2->bstream);
-		QRinput_freeEntry(st1);
-		QRinput_freeEntry(st2);
+		QRinput_List_freeEntry(st1);
+		QRinput_List_freeEntry(st2);
 	} else {
 		switch(entry->mode) {
 			case QR_MODE_NUM:
@@ -591,6 +787,9 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version)
 			case QR_MODE_KANJI:
 				QRinput_encodeModeKanji(entry, version);
 				break;
+			case QR_MODE_STRUCTURE:
+				QRinput_encodeModeStructure(entry, version);
+				break;
 			default:
 				break;
 		}
@@ -661,9 +860,6 @@ static BitStream *QRinput_createPaddingBit(QRinput *input)
 	QRinput_List *list;
 	BitStream *bstream;
 
-	if(input->version <= 0)
-		return NULL;
-
 	maxwords = QRspec_getDataLength(input->version, input->level);
 	maxbits = maxwords * 8;
 
@@ -715,6 +911,8 @@ BitStream *QRinput_mergeBitStream(QRinput *input)
 	}
 
 	bstream = BitStream_new();
+	if(bstream == NULL) return NULL;
+
 	list = input->head;
 	while(list != NULL) {
 		BitStream_append(bstream, list->bstream);
@@ -768,3 +966,238 @@ unsigned char *QRinput_getByteStream(QRinput *input)
 
 	return array;
 }
+
+/******************************************************************************
+ * Structured input data
+ *****************************************************************************/
+
+static QRinput_InputList *QRinput_InputList_newEntry(QRinput *input)
+{
+	QRinput_InputList *entry;
+
+	entry = (QRinput_InputList *)malloc(sizeof(QRinput_InputList));
+	if(entry == NULL) return NULL;
+
+	entry->input = input;
+	entry->next = NULL;
+
+	return entry;
+}
+
+static QRinput_InputList *QRinput_InputList_freeEntry(QRinput_InputList *entry)
+{
+	QRinput_InputList *next;
+
+	next = entry->next;
+	QRinput_free(entry->input);
+	free(entry);
+
+	return next;
+}
+
+QRinput_Struct *QRinput_Struct_new(void)
+{
+	QRinput_Struct *s;
+
+	s = (QRinput_Struct *)malloc(sizeof(QRinput_Struct));
+	if(s == NULL) return NULL;
+
+	s->size = 0;
+	s->parity = -1;
+	s->head = NULL;
+	s->tail = NULL;
+
+	return s;
+}
+
+void QRinput_Struct_setParity(QRinput_Struct *s, unsigned char parity)
+{
+	s->parity = (int)parity;
+}
+
+int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input)
+{
+	QRinput_InputList *e;
+
+	e = QRinput_InputList_newEntry(input);
+	if(e == NULL) return -1;
+
+	s->size++;
+	if(s->tail == NULL) {
+		s->head = e;
+		s->tail = e;
+	} else {
+		s->tail->next = e;
+		s->tail = e;
+	}
+
+	return s->size;
+}
+
+void QRinput_Struct_free(QRinput_Struct *s)
+{
+	QRinput_InputList *list;
+	
+	list = s->head;
+	while(list != NULL) {
+		list = QRinput_InputList_freeEntry(list);
+	}
+
+	free(s);
+}
+
+static unsigned char QRinput_Struct_calcParity(QRinput_Struct *s)
+{
+	QRinput_InputList *list;
+	unsigned char parity = 0;
+
+	list = s->head;
+	while(list != NULL) {
+		parity ^= QRinput_calcParity(list->input);
+		list = list->next;
+	}
+
+	QRinput_Struct_setParity(s, parity);
+
+	return parity;
+}
+
+static int QRinput_List_shrinkEntry(QRinput_List *entry, int bytes)
+{
+	unsigned char *data;
+
+	data = (unsigned char *)malloc(bytes);
+	if(data == NULL) return -1;
+
+	memcpy(data, entry->data, bytes);
+	free(entry->data);
+	entry->data = data;
+	entry->size = bytes;
+
+	return 0;
+}
+
+int QRinput_splitEntry(QRinput_List *entry, int bytes)
+{
+	QRinput_List *e;
+	int ret;
+
+	e = QRinput_List_newEntry(entry->mode, entry->size - bytes, entry->data + bytes);
+	if(e == NULL) {
+		return -1;
+	}
+
+	ret = QRinput_List_shrinkEntry(entry, bytes);
+	if(ret < 0) {
+		QRinput_List_freeEntry(e);
+		return -1;
+	}
+
+	e->next = entry->next;
+	entry->next = e;
+
+	return 0;
+}
+
+QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input)
+{
+	QRinput *p;
+	QRinput_Struct *s;
+	int bits, maxbits, nextbits, bytes;
+	QRinput_List *list, *next, *prev;
+
+	s = QRinput_Struct_new();
+	if(s == NULL) return NULL;
+
+	input = QRinput_dup(input);
+	if(input == NULL) {
+		QRinput_Struct_free(s);
+		return NULL;
+	}
+
+	QRinput_Struct_setParity(s, QRinput_calcParity(input));
+	maxbits = QRspec_getDataLength(input->version, input->level) * 8 - STRUCTURE_HEADER_BITS;
+
+	bits = 0;
+	list = input->head;
+	prev = NULL;
+	while(list != NULL) {
+		nextbits = QRinput_estimateBitStreamSizeOfEntry(list, input->version);
+		if(bits + nextbits <= maxbits) {
+			bits += QRinput_encodeBitStream(list, input->version);
+			prev = list;
+			list = list->next;
+		} else {
+			bytes = QRinput_lengthOfCode(list->mode, input->version, maxbits - bits);
+			if(bytes > 0) {
+				/* Splits this entry into 2 entries. */
+				QRinput_splitEntry(list, bytes);
+				/* First half is the tail of the current input. */
+				next = list->next;
+				list->next = NULL;
+				/* Second half is the head of the next input, p.*/
+				p = QRinput_new2(input->version, input->level);
+				p->head = next;
+				/* Renew QRinput.tail. */
+				p->tail = input->tail;
+				input->tail = list;
+				/* Point to the next entry. */
+				prev = list;
+				list = next;
+			} else {
+				/* Current entry will go to the next input. */
+				prev->next = NULL;
+				p = QRinput_new2(input->version, input->level);
+				p->head = list;
+				p->tail = input->tail;
+				input->tail = prev;
+			}
+			QRinput_Struct_appendInput(s, input);
+			if(s->size > MAX_STRUCTURED_SYMBOLS) {
+				QRinput_Struct_free(s);
+				errno = ERANGE;
+				return NULL;
+			}
+			input = p;
+			bits = 0;
+		}
+	}
+	QRinput_Struct_appendInput(s, input);
+	if(s->size > MAX_STRUCTURED_SYMBOLS) {
+		QRinput_Struct_free(s);
+		errno = ERANGE;
+		return NULL;
+	}
+	if(QRinput_Struct_insertStructuredAppendHeaders(s) < 0) {
+		QRinput_Struct_free(s);
+		return NULL;
+	}
+
+	return s;
+}
+
+int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s)
+{
+	int num, i;
+	QRinput_InputList *list;
+
+	if(s->parity < 0) {
+		QRinput_Struct_calcParity(s);
+	}
+	num = 0;
+	list = s->head;
+	while(list != NULL) {
+		num++;
+		list = list->next;
+	}
+	i = 1;
+	list = s->head;
+	while(list != NULL) {
+		if(QRinput_insertStructuredAppendHeader(list->input, num, i, s->parity))
+			return -1;
+		i++;
+		list = list->next;
+	}
+
+	return 0;
+}
diff --git a/qrinput.h b/qrinput.h
index 9f4ee76e89..38c7a919eb 100644
--- a/qrinput.h
+++ b/qrinput.h
@@ -48,33 +48,35 @@ struct _QRinput {
 	QRinput_List *tail;
 };
 
-/**
- * Get current error correction level.
- * @param input input data.
- * @return Current error correcntion level.
- */
-extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input);
+/******************************************************************************
+ * Structured append input data
+ *****************************************************************************/
+typedef struct _QRinput_InputList QRinput_InputList;
 
-/**
- * Set error correction level of the QR-code that is to be encoded.
- * @param input input data.
- * @param level Error correction level.
- */
-extern void QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level);
+struct _QRinput_InputList {
+	QRinput *input;
+	QRinput_InputList *next;
+};
 
-/**
- * Get current version.
- * @param input input data.
- * @return current version.
- */
-extern int QRinput_getVersion(QRinput *input);
+struct _QRinput_Struct {
+	int size;					///< number of structured symbols
+	int parity;
+	QRinput_InputList *head;
+	QRinput_InputList *tail;
+};
 
 /**
- * Set version of the QR-code that is to be encoded.
+ * Insert a structured-append header to the head of the input data.
  * @param input input data.
- * @param version version number (0 = auto)
+ * @param size number of structured symbols.
+ * @param index index number of the symbol. (1 <= index <= size)
+ * @param parity parity among input data. (NOTE: each symbol of a set of structured symbols has the same parity data)
+ * @retval 0 success.
+ * @retval -1 error occurred and errno is set to indeicate the error. See Execptions for the details.
+ * @throw EINVAL invalid parameter.
+ * @throw ENOMEM unable to allocate memory.
  */
-extern void QRinput_setVersion(QRinput *input, int version);
+extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity);
 
 /**
  * Pack all bit streams padding bits into a byte array.
@@ -83,6 +85,7 @@ extern void QRinput_setVersion(QRinput *input, int version);
  */
 extern unsigned char *QRinput_getByteStream(QRinput *input);
 
+
 extern int QRinput_estimateBitsModeNum(int size);
 extern int QRinput_estimateBitsModeAn(int size);
 extern int QRinput_estimateBitsMode8(int size);
@@ -91,6 +94,9 @@ extern int QRinput_estimateBitsModeKanji(int size);
 extern int QRinput_estimateBitStreamSize(QRinput *input, int version);
 extern BitStream *QRinput_mergeBitStream(QRinput *input);
 extern BitStream *QRinput_getBitStream(QRinput *input);
+extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits);
+extern QRinput *QRinput_dup(QRinput *input);
+extern int QRinput_splitEntry(QRinput_List *entry, int bytes);
 
 extern const signed char QRinput_anTable[];
 extern QRencodeMode QRinput_identifyMode(const char *string);
@@ -103,4 +109,14 @@ extern QRencodeMode QRinput_identifyMode(const char *string);
 #define QRinput_lookAnTable(__c__) \
 	((__c__ & 0x80)?-1:QRinput_anTable[(int)__c__])
 
+/**
+ * Length of a segment of structured-append header.
+ */
+#define STRUCTURE_HEADER_BITS 20
+
+/**
+ * Maximum number of symbols in a set of structured-appended symbols.
+ */
+#define MAX_STRUCTURED_SYMBOLS 16
+
 #endif /* __QRINPUT_H__ */
diff --git a/rscode.c b/rscode.c
index 09ccf9ab35..8f9f5dc4ad 100644
--- a/rscode.c
+++ b/rscode.c
@@ -204,12 +204,12 @@ RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad)
 	RS *rs;
 
 	for(rs = rslist; rs != NULL; rs = rs->next) {
+		if(rs->nroots != nroots) continue;
+		if(rs->pad != pad) continue;
 		if(rs->mm != symsize) continue;
 		if(rs->gfpoly != gfpoly) continue;
 		if(rs->fcr != fcr) continue;
 		if(rs->prim != prim) continue;
-		if(rs->nroots != nroots) continue;
-		if(rs->pad != pad) continue;
 
 		return rs;
 	}
diff --git a/split.c b/split.c
index 4806f669b3..ecf70fe796 100644
--- a/split.c
+++ b/split.c
@@ -35,19 +35,20 @@
 #define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10)
 #define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0)
 
-static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint);
-static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint);
+static int Split_eatNum(const char *string, QRinput *input, QRencodeMode hint);
+static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint);
+static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint);
+static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint);
 
-static int Split_eatNum(const char *string, QRinput *input, int version, QRencodeMode hint)
+static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint)
 {
 	const char *p;
+	int ret;
 	int run;
 	int dif;
 	int ln;
 
-	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
+	ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version);
 
 	p = string;
 	while(isdigit(*p)) {
@@ -59,7 +60,7 @@ static int Split_eatNum(const char *string, QRinput *input, int version, QRencod
 			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
 			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
 		if(dif > 0) {
-			return Split_eat8(string, input, version, hint);
+			return Split_eat8(string, input, hint);
 		}
 	}
 	if(isalnum(*p)) {
@@ -67,23 +68,26 @@ static int Split_eatNum(const char *string, QRinput *input, int version, QRencod
 			+ QRinput_estimateBitsModeAn(1) /* + 4 + la */
 			- QRinput_estimateBitsModeAn(run + 1) /* - 4 - la */;
 		if(dif > 0) {
-			return Split_eatAn(string, input, version, hint);
+			return Split_eatAn(string, input, hint);
 		}
 	}
 
-	QRinput_append(input, QR_MODE_NUM, run, (unsigned char *)string);
+	ret = QRinput_append(input, QR_MODE_NUM, run, (unsigned char *)string);
+	if(ret < 0) return -1;
+
 	return run;
 }
 
-static int Split_eatAn(const char *string, QRinput *input, int version, QRencodeMode hint)
+static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint)
 {
 	const char *p, *q;
+	int ret;
 	int run;
 	int dif;
 	int la, ln;
 
-	la = QRspec_lengthIndicator(QR_MODE_AN, version);
-	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
+	la = QRspec_lengthIndicator(QR_MODE_AN, input->version);
+	ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version);
 
 	p = string;
 	while(isalnum(*p)) {
@@ -112,37 +116,46 @@ static int Split_eatAn(const char *string, QRinput *input, int version, QRencode
 			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
 			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
 		if(dif > 0) {
-			return Split_eat8(string, input, version, hint);
+			return Split_eat8(string, input, hint);
 		}
 	}
 
-	QRinput_append(input, QR_MODE_AN, run, (unsigned char *)string);
+	ret = QRinput_append(input, QR_MODE_AN, run, (unsigned char *)string);
+	if(ret < 0) return -1;
+
 	return run;
 }
 
-static int Split_eatKanji(const char *string, QRinput *input, int version, QRencodeMode hint)
+static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint)
 {
 	const char *p;
+	int ret;
+	int run;
 
 	p = string;
 	while(QRinput_identifyMode(p) == QR_MODE_KANJI) {
 		p += 2;
 	}
-	QRinput_append(input, QR_MODE_KANJI, p - string, (unsigned char *)string);
-	return p - string;
+	run = p - string;
+	ret = QRinput_append(input, QR_MODE_KANJI, run, (unsigned char *)string);
+	if(ret < 0) return -1;
+
+	return run;
 }
 
-static int Split_eat8(const char *string, QRinput *input, int version, QRencodeMode hint)
+static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint)
 {
 	const char *p, *q;
 	QRencodeMode mode;
+	int ret;
+	int run;
 	int dif;
 	int la, ln;
 
-	la = QRspec_lengthIndicator(QR_MODE_AN, version);
-	ln = QRspec_lengthIndicator(QR_MODE_NUM, version);
+	la = QRspec_lengthIndicator(QR_MODE_AN, input->version);
+	ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version);
 
-	p = string;
+	p = string + 1;
 	while(*p != '\0') {
 		mode = QRinput_identifyMode(p);
 		if(hint == QR_MODE_KANJI && mode == QR_MODE_KANJI) {
@@ -181,30 +194,34 @@ static int Split_eat8(const char *string, QRinput *input, int version, QRencodeM
 		}
 	}
 
-	QRinput_append(input, QR_MODE_8, p - string, (unsigned char *)string);
-	return p - string;
+	run = p - string;
+	ret = QRinput_append(input, QR_MODE_8, run, (unsigned char *)string);
+	if(ret < 0) return -1;
+
+	return run;
 }
 
-static void Split_splitString(const char *string, QRinput *input,
-		int version, QRencodeMode hint)
+static int Split_splitString(const char *string, QRinput *input,
+		QRencodeMode hint)
 {
 	int length;
 	QRencodeMode mode;
 
-	if(*string == '\0') return;
+	if(*string == '\0') return 0;
 
 	mode = QRinput_identifyMode(string);
 	if(mode == QR_MODE_NUM) {
-		length = Split_eatNum(string, input, version, hint);
+		length = Split_eatNum(string, input, hint);
 	} else if(mode == QR_MODE_AN) {
-		length = Split_eatAn(string, input, version, hint);
+		length = Split_eatAn(string, input, hint);
 	} else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
-		length = Split_eatKanji(string, input, version, hint);
+		length = Split_eatKanji(string, input, hint);
 	} else {
-		length = Split_eat8(string, input, version, hint);
+		length = Split_eat8(string, input, hint);
 	}
-	if(length == 0) return;
-	Split_splitString(&string[length], input, version, hint);
+	if(length == 0) return 0;
+	if(length < 0) return -1;
+	return Split_splitString(&string[length], input, hint);
 }
 
 static char *dupAndToUpper(const char *str, QRencodeMode hint)
@@ -213,6 +230,8 @@ static char *dupAndToUpper(const char *str, QRencodeMode hint)
 	QRencodeMode mode;
 
 	newstr = strdup(str);
+	if(newstr == NULL) return NULL;
+
 	p = newstr;
 	while(*p != '\0') {
 		mode = QRinput_identifyMode(p);
@@ -229,16 +248,20 @@ static char *dupAndToUpper(const char *str, QRencodeMode hint)
 	return newstr;
 }
 
-void Split_splitStringToQRinput(const char *string, QRinput *input,
-		int version, QRencodeMode hint, int casesensitive)
+int Split_splitStringToQRinput(const char *string, QRinput *input,
+		QRencodeMode hint, int casesensitive)
 {
 	char *newstr;
+	int ret;
 
 	if(!casesensitive) {
 		newstr = dupAndToUpper(string, hint);
-		Split_splitString(newstr, input, version, hint);
+		if(newstr == NULL) return -1;
+		ret = Split_splitString(newstr, input, hint);
 		free(newstr);
 	} else {
-		Split_splitString(string, input, version, hint);
+		ret = Split_splitString(string, input, hint);
 	}
+
+	return ret;
 }
diff --git a/split.h b/split.h
index 2ddf5822a3..4ff9540f48 100644
--- a/split.h
+++ b/split.h
@@ -29,6 +29,16 @@
 #define __SPLIT_H__
 
 #include "qrencode.h"
-void Split_splitStringToQRinput(const char *string, QRinput *input,
-		int version, QRencodeMode hint, int casesensitive);
+
+/**
+ * Split the input string (null terminated) into QRinput.
+ * @param string input string
+ * @param hint give QR_MODE_KANJI if the input string contains Kanji character encoded in Shift-JIS. If not, give QR_MODE_8.
+ * @param casesensitive 0 for case-insensitive encoding (all alphabet characters are replaced to UPPER-CASE CHARACTERS.
+ * @retval 0 success.
+ * @retval -1 an error occurred.
+ */
+extern int Split_splitStringToQRinput(const char *string, QRinput *input,
+		QRencodeMode hint, int casesensitive);
+
 #endif /* __SPLIT_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e2f824ce67..bbfe88623c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,20 +4,20 @@ endif
 
 noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \
 				  test_qrspec test_rs test_qrencode prof_qrencode \
-				  test_mqrspec test_split\
+				  test_mqrspec test_split test_monkey\
 				  $(sdlPROGRAMS)
 
 test_qrinput_SOURCES = test_qrinput.c common.h
 test_qrinput_LDADD = ../libqrencode.la
 
 test_bitstream_SOURCES = test_bitstream.c common.h
-test_bitstream_LDADD = ../bitstream.o
+test_bitstream_LDADD = ../libqrencode.la
 
 test_estimatebit_SOURCES = test_estimatebit.c common.h
 test_estimatebit_LDADD = ../libqrencode.la
 
 test_qrspec_SOURCES = test_qrspec.c common.h
-test_qrspec_LDADD = ../qrspec.o
+test_qrspec_LDADD = ../libqrencode.la
 
 test_mqrspec_SOURCES = test_mqrspec.c common.h
 test_mqrspec_LDADD = ../mqrspec.o
@@ -31,6 +31,9 @@ test_qrencode_LDADD = ../libqrencode.la
 test_split_SOURCES = test_split.c common.h
 test_split_LDADD = ../libqrencode.la
 
+test_monkey_SOURCES = test_monkey.c common.h
+test_monkey_LDADD = ../libqrencode.la
+
 prof_qrencode_SOURCES = prof_qrencode.c
 prof_qrencode_LDADD = ../libqrencode.la
 
diff --git a/tests/common.h b/tests/common.h
index 05ba2854c4..5b6312aea8 100644
--- a/tests/common.h
+++ b/tests/common.h
@@ -10,22 +10,54 @@
 #include "../qrinput.h"
 #include "../bitstream.h"
 
-#define CHECK(_str_) (printf("_____%s\n",_str_))
-#define RESULT(_args_...) (printf(".....") + printf(_args_))
-
 #define testStart(__arg__) (testStartReal(__FUNCTION__, __arg__))
 #define testEndExp(__arg__) (testEnd(!(__arg__)))
 
 static int tests = 0;
 static int failed = 0;
+static int assertionFailed = 0;
+static int assertionNum = 0;
 static const char *testName = NULL;
 static const char *testFunc = NULL;
+char levelChar[4] = {'L', 'M', 'Q', 'H'};
+char *modeStr[5] = {"nm", "an", "8", "kj", "st"};
+
+void printQRinput(QRinput *input)
+{
+	QRinput_List *list;
+	BitStream *b;
+	int i;
+
+	printf("QRinput info:\n");
+	printf(" version: %d\n", input->version);
+	printf(" level  : %c\n", levelChar[input->level]);
+	list = input->head;
+	i = 0;
+	while(list != NULL) {
+		i++;
+		list = list->next;
+	}
+	printf("  chunks: %d\n", i);
+	b = QRinput_mergeBitStream(input);
+	printf("  bitstream-size: %d\n", BitStream_size(b));
+	BitStream_free(b);
+
+	list = input->head;
+	i = 0;
+	while(list != NULL) {
+		printf("\t#%d: mode = %s, size = %d\n", i, modeStr[list->mode], list->size);
+		i++;
+		list = list->next;
+	}
+}
 
 void testStartReal(const char *func, const char *name)
 {
 	tests++;
 	testName = name;
 	testFunc = func;
+	assertionFailed = 0;
+	assertionNum = 0;
 	printf("_____%d: %s: %s...\n", tests, func, name);
 }
 
@@ -40,9 +72,31 @@ void testEnd(int result)
 	}
 }
 
+#define assert_exp(__exp__, __msg__...) \
+(void)({assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__msg__);}})
+
+#define assert_zero(__exp__, __msg__...) assert_exp((__exp__) == 0, __msg__)
+#define assert_nonzero(__exp__, __msg__...) assert_exp((__exp__) != 0, __msg__)
+#define assert_null(__ptr__, __msg__...) assert_exp((__ptr__) == NULL, __msg__)
+#define assert_nonnull(__ptr__, __msg__...) assert_exp((__ptr__) != NULL, __msg__)
+#define assert_equal(__e1__, __e2__, __msg__...) assert_exp((__e1__) == (__e2__), __msg__)
+#define assert_notequal(__e1__, __e2__, __msg__...) assert_exp((__e1__) != (__e2__), __msg__)
+
+void testFinish(void)
+{
+	printf(".....%d: %s: %s, ", tests, testFunc, testName);
+	if(assertionFailed) {
+		printf("FAILED. (%d assertions failed.)\n", assertionFailed);
+		failed++;
+	} else {
+		printf("PASSED. (%d assertions passed.)\n", assertionNum);
+	}
+}
+
 void report()
 {
 	printf("Total %d tests, %d fails.\n", tests, failed);
+	if(failed) exit(-1);
 }
 
 char *sprintfBin(int size, unsigned char *data)
diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c
index 1f89db65fa..c938cffa9c 100644
--- a/tests/prof_qrencode.c
+++ b/tests/prof_qrencode.c
@@ -27,7 +27,7 @@ void prof_ver1to10(void)
 	int version;
 	static char *data = "This is test.";
 
-	timerStart("Version 1 - 10");
+	timerStart("Version 1 - 10 (500 symbols for each)");
 	for(i=0; i<500; i++) {
 		for(version = 0; version < 11; version++) {
 			code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0);
@@ -37,9 +37,27 @@ void prof_ver1to10(void)
 	timerStop();
 }
 
+void prof_ver31to40(void)
+{
+	QRcode *code;
+	int i;
+	int version;
+	static char *data = "This is test.";
+
+	timerStart("Version 31 - 40 (50 symbols for each)");
+	for(i=0; i<50; i++) {
+		for(version = 31; version < 41; version++) {
+			code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0);
+			QRcode_free(code);
+		}
+	}
+	timerStop();
+}
+
 int main()
 {
 	prof_ver1to10();
+	prof_ver31to40();
 
 	return 0;
 }
diff --git a/tests/test_all.sh b/tests/test_all.sh
new file mode 100755
index 0000000000..eddc87c777
--- /dev/null
+++ b/tests/test_all.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+./test_bitstream
+./test_estimatebit
+./test_qrencode
+./test_qrinput
+./test_qrspec
+./test_rs
+./test_split
+./test_monkey
diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c
index 77e9da2157..e649d651ed 100644
--- a/tests/test_estimatebit.c
+++ b/tests/test_estimatebit.c
@@ -52,7 +52,8 @@ void test_numbit3(void)
 	num[400] = '\0';
 	QRinput_append(stream, QR_MODE_NUM, 400, (unsigned char *)num);
 	bits = QRinput_estimateBitStreamSize(stream, 0);
-	testEndExp(bits == 1362);
+	/* 4 + 10 + 133*10 + 4 = 1348 */
+	testEndExp(bits == 1348);
 
 	QRinput_append(gstream, QR_MODE_NUM, 400, (unsigned char *)num);
 	QRinput_free(stream);
@@ -91,6 +92,21 @@ void test_8(void)
 	QRinput_free(stream);
 }
 
+void test_structure(void)
+{
+	QRinput *stream;
+	int bits;
+
+	testStart("Estimation of a structure-append header");
+	stream = QRinput_new();
+	QRinput_insertStructuredAppendHeader(stream, 10, 1, 0);
+	bits = QRinput_estimateBitStreamSize(stream, 1);
+	testEndExp(bits == 20);
+
+	QRinput_insertStructuredAppendHeader(gstream, 10, 1, 0);
+	QRinput_free(stream);
+}
+
 void test_kanji(void)
 {
 	int res;
@@ -120,7 +136,7 @@ void test_mix(void)
 
 	testStart("Estimation of Mixed stream");
 	bits = QRinput_estimateBitStreamSize(gstream, 0);
-	testEndExp(bits == (41 + 68 + 1362 + 41 + 76 + 38));
+	testEndExp(bits == (41 + 68 + 1348 + 41 + 76 + 38 + 20));
 	QRinput_free(gstream);
 }
 
@@ -134,6 +150,7 @@ int main(int argc, char **argv)
 	test_an();
 	test_8();
 	test_kanji();
+	test_structure();
 	test_mix();
 
 	report();
diff --git a/tests/test_monkey.c b/tests/test_monkey.c
new file mode 100644
index 0000000000..5f272f3d6c
--- /dev/null
+++ b/tests/test_monkey.c
@@ -0,0 +1,277 @@
+#include 
+#include 
+#include "common.h"
+#include "../qrinput.h"
+#include "../qrencode_inner.h"
+#include "../split.h"
+#include "../qrspec.h"
+
+#define MAX_LENGTH 7091
+static char data[MAX_LENGTH];
+static char check[MAX_LENGTH];
+
+static char *AN = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
+
+#define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0))
+
+int fill8bitData(void)
+{
+	int len, i;
+
+	len = 1 + (int)drand((MAX_LENGTH - 2));
+	for(i=0; ihead;
+	i = 0;
+	while(list != NULL) {
+		memcpy(check + i, list->data, list->size);
+		i += list->size;
+		list = list->next;
+	}
+	if(i != len) {
+		printf("#%d: length is not correct. (%d should be %d)\n", num, i, len);
+	}
+
+	check[i] = '\0';
+	ret = memcmp(data, check, len);
+	if(ret != 0) {
+		printf("#%d: data mismatched.\n", num);
+		list = input->head;
+		i = 0;
+		while(list != NULL) {
+			ret = memcmp(data + i, list->data, list->size);
+			printf("wrong chunk:\n");
+			printf(" position: %d\n", i);
+			printf(" mode    : %d\n", list->mode);
+			printf(" size    : %d\n", list->size);
+			printf(" data    : %.*s\n", list->size, list->data);
+			i += list->size;
+			list = list->next;
+		}
+		exit(1);
+	}
+	QRinput_free(input);
+}
+
+void monkey_split_an(int loop)
+{
+	int i;
+
+	puts("Monkey test: Split_splitStringToQRinput() - AlphaNumeric string.");
+	srand(0);
+	for(i=0; ihead;
+	i = 0;
+	while(list != NULL) {
+		memcpy(check + i, list->data, list->size);
+		i += list->size;
+		list = list->next;
+	}
+	if(i != len) {
+		printf("#%d: length is not correct. (%d should be %d)\n", num, i, len);
+	}
+
+	check[i] = '\0';
+	ret = memcmp(data, check, len);
+	if(ret != 0) {
+		printf("#%d: data mismatched.\n", num);
+		list = input->head;
+		i = 0;
+		while(list != NULL) {
+			ret = memcmp(data + i, list->data, list->size);
+			printf("wrong chunk:\n");
+			printf(" position: %d\n", i);
+			printf(" mode    : %d\n", list->mode);
+			printf(" size    : %d\n", list->size);
+			printf(" data    : %.*s\n", list->size, list->data);
+			i += list->size;
+			list = list->next;
+		}
+		exit(1);
+	}
+	QRinput_free(input);
+}
+
+void monkey_split_8(int loop)
+{
+	int i;
+
+	puts("Monkey test: Split_splitStringToQRinput() - 8bit char string.");
+	srand(0);
+	for(i=0; ihead;
+	i = 0;
+	while(list != NULL) {
+		memcpy(check + i, list->data, list->size);
+		i += list->size;
+		list = list->next;
+	}
+	if(i != len) {
+		printf("#%d: length is not correct. (%d should be %d)\n", num, i, len);
+	}
+
+	check[i] = '\0';
+	ret = memcmp(data, check, len);
+	if(ret != 0) {
+		printf("#%d: data mismatched.\n", num);
+		list = input->head;
+		i = 0;
+		while(list != NULL) {
+			ret = memcmp(data + i, list->data, list->size);
+			printf("wrong chunk:\n");
+			printf(" position: %d\n", i);
+			printf(" mode    : %d\n", list->mode);
+			printf(" size    : %d\n", list->size);
+			printf(" data    : %.*s\n", list->size, list->data);
+			i += list->size;
+			list = list->next;
+		}
+		exit(1);
+	}
+	QRinput_free(input);
+}
+
+void monkey_split_kanji(int loop)
+{
+	int i;
+
+	puts("Monkey test: Split_splitStringToQRinput() - kanji string.");
+	srand(0);
+	for(i=0; ihead;
+	i = 0;
+	while(il != NULL) {
+		if(il->input->version != version) {
+			printf("Test: version %d, level %c\n", version, levelChar[level]);
+			printf("wrong version number.\n");
+			printQRinput(il->input);
+			exit(1);
+		}
+		i++;
+		il = il->next;
+	}
+	codes = QRcode_encodeStructuredInput(s);
+	list = codes;
+	il = s->head;
+	c = 0;
+	while(list != NULL) {
+		if(list->code->version != version) {
+			printf("Test: version %d, level %c\n", version, levelChar[level]);
+			printf("code #%d\n", c);
+			printf("Version mismatch: %d should be %d\n", list->code->version, version);
+			printf("max bits: %d\n", QRspec_getDataLength(version, level) * 8 - 20);
+			printQRinput(il->input);
+			exit(1);
+		}
+		list = list->next;
+		il = il->next;
+		c++;
+	}
+
+	QRinput_free(input);
+	QRinput_Struct_free(s);
+	QRcode_List_free(codes);
+}
+
+void monkey_split_structure(int loop)
+{
+	int i;
+
+	puts("Monkey test: QRinput_splitQRinputToStruct.");
+	srand(0);
+	for(i=0; iwidth;
 		frame = qrcode->data;
 		for(y=0; ydata, code2->data, code1->width * code1->width));
 
 	QRcode_free(code1);
@@ -476,9 +480,9 @@ void test_01234567(void)
 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x85, 0x03, 0x03, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02};
 
 	testStart("Encode 01234567 in 1-M");
-	stream = QRinput_new();
+	stream = QRinput_new2(1, QR_ECLEVEL_M);
 	QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
-	qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_M);
+	qrcode = QRcode_encodeInput(stream);
 	for(i=0; iwidth * qrcode->width; i++) {
 		if(qrcode->data[i] != correct[i]) {
 			err++;
@@ -497,9 +501,9 @@ void print_01234567(void)
 	int x, y, w;
 	QRcode *qrcode;
 
-	stream = QRinput_new();
+	stream = QRinput_new2(1, QR_ECLEVEL_M);
 	QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
-	qrcode = QRcode_encodeInput(stream, 1, QR_ECLEVEL_M);
+	qrcode = QRcode_encodeInput(stream);
 	w = qrcode->width;
 	frame = qrcode->data;
 	for(y=0; yversion = -1;
+	input->level = QR_ECLEVEL_L;
+	code = QRcode_encodeInput(input);
+	assert_null(code, "invalid version(-1)  was not checked.\n");
+	if(code != NULL) QRcode_free(code);
+
+	input->version = 41;
+	input->level = QR_ECLEVEL_L;
+	code = QRcode_encodeInput(input);
+	assert_null(code, "invalid version(41) access was not checked.\n");
+	if(code != NULL) QRcode_free(code);
+
+	input->version = 1;
+	input->level = QR_ECLEVEL_H + 1;
+	code = QRcode_encodeInput(input);
+	assert_null(code, "invalid level(H+1) access was not checked.\n");
+	if(code != NULL) QRcode_free(code);
+
+	input->version = 1;
+	input->level = -1;
+	code = QRcode_encodeInput(input);
+	assert_null(code, "invalid level(-1) access was not checked.\n");
+	if(code != NULL) QRcode_free(code);
+
+	QRinput_free(input);
+
+	testFinish();
+}
+
+void test_struct_semilong(void)
+{
+	QRcode_List *codes, *list;
+	char *str = "asdfasdfasdfasdfasdfASDFASDASDFASDFAsdfasdfasdfasdASDFASDFADSADadsfasdf";
+	int num;
+
+	testStart("Testing semi-long structured-append symbols");
+	codes = QRcode_encodeString8bitStructured(str, 1, QR_ECLEVEL_L);
+	list = codes;
+	num = 0;
+	while(list != NULL) {
+		num++;
+		assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version);
+		list = list->next;
+	}
+	testFinish();
+	QRcode_List_free(codes);
+}
+
+void test_struct_example(void)
+{
+	QRcode_List *codes, *list;
+	char *str = "an example of four Structured Append symbols,";
+	int num;
+
+	testStart("Testing the example of structured-append symbols");
+	codes = QRcode_encodeString8bitStructured(str, 1, QR_ECLEVEL_M);
+	list = codes;
+	num = 0;
+	while(list != NULL) {
+		num++;
+		assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version);
+		list = list->next;
+	}
+	assert_equal(num, 4, "number of symbols is %d (4 expected).", num);
+	testFinish();
+	QRcode_List_free(codes);
+}
+
 int main(int argc, char **argv)
 {
 	test_iterate();
 	test_iterate2();
 //	print_filler();
-	test_filler();
+//	test_filler();
 //	print_mask();
 	test_format();
 	test_eval();
@@ -528,8 +608,12 @@ int main(int argc, char **argv)
 	test_encode3();
 	test_encodeTooLong();
 	test_01234567();
+	test_invalid_input();
 //	print_01234567();
+	test_struct_example();
+	test_struct_semilong();
 
+	QRspec_clearCache();
 	report();
 
 	return 0;
diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c
index cb987ae382..e554f54ac2 100644
--- a/tests/test_qrinput.c
+++ b/tests/test_qrinput.c
@@ -1,5 +1,6 @@
 #include 
 #include 
+#include 
 #include "common.h"
 #include "../qrinput.h"
 #include "../qrencode_inner.h"
@@ -27,12 +28,12 @@ void test_encode8(void)
 {
 	QRinput *stream;
 	char str[] = "AC-42";
-	char correct[] = "00100000001010011100111011100111001000010";
+	char correct[] = "0100000001010100000101000011001011010011010000110010";
 	BitStream *bstream;
 
-	testStart("Encoding alphabet-numeric stream.");
+	testStart("Encoding 8bit stream.");
 	stream = QRinput_new();
-	QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str);
+	QRinput_append(stream, QR_MODE_8, 5, (unsigned char *)str);
 	bstream = QRinput_mergeBitStream(stream);
 	printf("%s\n", correct);
 	printf("%s\n", bstream->data);
@@ -41,6 +42,27 @@ void test_encode8(void)
 	BitStream_free(bstream);
 }
 
+void test_encode8_versionup(void)
+{
+	QRinput *stream;
+	BitStream *bstream;
+	char *str;
+	int version;
+
+	testStart("Encoding 8bit stream. (auto-version up test)");
+	str = (char *)malloc(2900);
+	memset(str, 0xff, 2900);
+	stream = QRinput_new();
+	QRinput_append(stream, QR_MODE_8, 2900, (unsigned char *)str);
+	bstream = QRinput_mergeBitStream(stream);
+	version = QRinput_getVersion(stream);
+	assert_equal(version, 40, "Version is %d (40 expected).\n", version);
+	testFinish();
+	QRinput_free(stream);
+	BitStream_free(bstream);
+	free(str);
+}
+
 void test_encodeAn(void)
 {
 	QRinput *stream;
@@ -90,6 +112,27 @@ void test_encodeNumeric(void)
 	BitStream_free(bstream);
 }
 
+void test_encodeNumeric_versionup(void)
+{
+	QRinput *stream;
+	BitStream *bstream;
+	char *str;
+	int version;
+
+	testStart("Encoding numeric stream. (auto-version up test)");
+	str = (char *)malloc(1050);
+	memset(str, '1', 1050);
+	stream = QRinput_new2(0, QR_ECLEVEL_L);
+	QRinput_append(stream, QR_MODE_NUM, 1050, (unsigned char *)str);
+	bstream = QRinput_mergeBitStream(stream);
+	version = QRinput_getVersion(stream);
+	assert_equal(version, 14, "Version is %d (14 expected).", version);
+	testFinish();
+	QRinput_free(stream);
+	BitStream_free(bstream);
+	free(str);
+}
+
 void test_encodeNumericPadded(void)
 {
 	QRinput *stream;
@@ -174,12 +217,12 @@ void test_encodeTooLong(void)
 	unsigned char *data;
 	BitStream *bstream;
 
-	data = (unsigned char *)malloc(7089);
-	memset(data, 'A', 7089);
+	data = (unsigned char *)malloc(4297);
+	memset(data, 'A', 4297);
 
-	testStart("Encoding long string. (7089 bytes)");
+	testStart("Encoding long string. (4297 bytes of alphanumeric)");
 	stream = QRinput_new();
-	QRinput_append(stream, QR_MODE_AN, 7089, data);
+	QRinput_append(stream, QR_MODE_AN, 4297, data);
 	bstream = QRinput_mergeBitStream(stream);
 	testEndExp(bstream == NULL);
 	QRinput_free(stream);
@@ -212,12 +255,448 @@ void test_encodeAnNum(void)
 	BitStream_free(bstream);
 }
 
+void test_struct_listop(void)
+{
+	QRinput_Struct *s;
+	QRinput *inputs[5];
+	QRinput_InputList *l;
+	int i, ret;
+
+	testStart("QRinput_Struct list operation test.");
+	s = QRinput_Struct_new();
+	QRinput_Struct_setParity(s, 10);
+	assert_nonnull(s, "QRinput_Struct_new() failed.");
+	assert_equal(s->parity, 10, "QRinput_Struct_setParity() failed.");
+
+	for(i=0; i<5; i++) {
+		inputs[i] = QRinput_new();
+		QRinput_append(inputs[i], QR_MODE_AN, 5, (unsigned char *)"ABCDE");
+		ret = QRinput_Struct_appendInput(s, inputs[i]);
+	}
+	assert_equal(ret, 5, "QRinput_Struct_appendInput() returns wrong num?");
+	assert_equal(s->size, 5, "QRiput_Struct.size counts wrong number.");
+
+	l = s->head;
+	i = 0;
+	while(l != NULL) {
+		assert_equal(l->input, inputs[i], "QRinput_Struct input list order would be wrong?");
+		l = l->next;
+		i++;
+	}
+
+	QRinput_Struct_free(s);
+	testFinish();
+}
+
+void test_insertStructuredAppendHeader(void)
+{
+	QRinput *stream;
+	char correct[] = "0011000011111010010101000000000101000001";
+	BitStream *bstream;
+	int ret;
+
+	testStart("Insert a structured-append header");
+	stream = QRinput_new();
+	QRinput_append(stream, QR_MODE_8, 1, (unsigned char *)"A");
+	ret = QRinput_insertStructuredAppendHeader(stream, 16, 1, 0xa5);
+	assert_zero(ret, "QRinput_insertStructuredAppendHeader() returns nonzero.\n");
+	bstream = QRinput_mergeBitStream(stream);
+	assert_nonnull(bstream->data, "Bstream->data is null.");
+	assert_zero(strcmp(correct, bstream->data), "bitstream is wrong.");
+	testFinish();
+
+	QRinput_free(stream);
+	BitStream_free(bstream);
+}
+
+void test_insertStructuredAppendHeader_error(void)
+{
+	QRinput *stream;
+	int ret;
+
+	testStart("Insert a structured-append header (errors expected)");
+	stream = QRinput_new();
+	QRinput_append(stream, QR_MODE_8, 1, (unsigned char *)"A");
+	ret = QRinput_insertStructuredAppendHeader(stream, 17, 1, 0xa5);
+	assert_equal(-1, ret, "QRinput_insertStructuredAppendHeader() returns 0.");
+	assert_equal(EINVAL, errno, "errno is not set correctly (%d returned).", errno);
+	ret = QRinput_insertStructuredAppendHeader(stream, 16, 17, 0xa5);
+	assert_equal(-1, ret, "QRinput_insertStructuredAppendHeader() returns 0.");
+	assert_equal(EINVAL, errno, "errno is not set correctly (%d returned).", errno);
+	ret = QRinput_insertStructuredAppendHeader(stream, 16, 0, 0xa5);
+	assert_equal(-1, ret, "QRinput_insertStructuredAppendHeader() returns 0.");
+	assert_equal(EINVAL, errno, "errno is not set correctly (%d returned).", errno);
+	testFinish();
+
+	QRinput_free(stream);
+}
+
+void test_struct_insertStructuredAppendHeaders(void)
+{
+	QRinput *input;
+	QRinput_Struct *s;
+	QRinput_InputList *p;
+	int i;
+
+	testStart("Insert structured-append headers to a QRinput_Struct.");
+	s = QRinput_Struct_new();
+	for(i=0; i<10; i++) {
+		input = QRinput_new();
+		QRinput_append(input, QR_MODE_8, 1, (unsigned char *)"A");
+		QRinput_Struct_appendInput(s, input);
+	}
+	QRinput_Struct_insertStructuredAppendHeaders(s);
+	p = s->head;
+	i = 1;
+	while(p != NULL) {
+		assert_equal(p->input->head->mode, QR_MODE_STRUCTURE, "a structured-append header is not inserted.");
+		assert_equal(p->input->head->data[0], 10, "size of the structured-header is wrong: #%d, %d should be %d\n", i, p->input->head->data[0], 10);
+		assert_equal(p->input->head->data[1], i, "index of the structured-header is wrong: #%d, %d should be %d\n", i, p->input->head->data[1], i);
+		assert_equal(p->input->head->data[2], 0, "parity of the structured-header is wrong: #%d\n", i);
+		p = p->next;
+		i++;
+	}
+	testFinish();
+	QRinput_Struct_free(s);
+}
+
+static int check_lengthOfCode(QRencodeMode mode, char *data, int size, int version)
+{
+	QRinput *input;
+	BitStream *b;
+	int bits;
+	int bytes;
+
+	input = QRinput_new();
+	QRinput_setVersion(input, version);
+	QRinput_append(input, mode, size, (unsigned char *)data);
+	b = QRinput_mergeBitStream(input);
+	bits = BitStream_size(b);
+	bytes = QRinput_lengthOfCode(mode, version, bits);
+	QRinput_free(input);
+	BitStream_free(b);
+
+	return bytes;
+}
+
+void test_lengthOfCode_num(void)
+{
+	int i, bytes;
+	char *data;
+
+	data = (char *)malloc(8000);
+	for(i=0; i<8000; i++) {
+		data[i] = '0' + i % 10;
+	}
+
+	testStart("Checking length of code (numeric)");
+	for(i=1; i<=9; i++) {
+		bytes = check_lengthOfCode(QR_MODE_NUM, data, i, 1);
+		assert_equal(i, bytes, "lengthOfCode failed. (QR_MODE_NUM, version:1, size:%d)\n", i);
+	}
+	for(i=1023; i<=1025; i++) {
+		bytes = check_lengthOfCode(QR_MODE_NUM, data, i, 1);
+		assert_equal(1023, bytes, "lengthOfCode failed. (QR_MODE_NUM, version:1, size:%d)\n", i);
+	}
+	testFinish();
+	free(data);
+}
+
+void test_lengthOfCode_kanji(void)
+{
+	int i, bytes;
+	char str[4]= {0x93, 0x5f,0xe4, 0xaa};
+
+	testStart("Checking length of code (kanji)");
+	for(i=2; i<=4; i+=2) {
+		bytes = check_lengthOfCode(QR_MODE_KANJI, str, i, 1);
+		assert_equal(i, bytes, "lengthOfCode failed. (QR_MODE_KANJI, version:1, size:%d)\n", i);
+	}
+	testFinish();
+}
+
+void test_struct_split_example(void)
+{
+	QRinput *input;
+	QRinput_Struct *s;
+	QRinput_InputList *e;
+	QRinput_List *l;
+	char *str[4] = {
+		"an example ",
+		"of four Str",
+		"uctured Appe",
+		"nd symbols,"};
+	int i;
+	BitStream *bstream;
+
+	testStart("Testing the example of structured-append symbols");
+	s = QRinput_Struct_new();
+	for(i=0; i<4; i++) {
+		input = QRinput_new2(1, QR_ECLEVEL_M);
+		QRinput_append(input, QR_MODE_8, strlen(str[i]), (unsigned char *)str[i]);
+		QRinput_Struct_appendInput(s, input);
+	}
+	QRinput_Struct_insertStructuredAppendHeaders(s);
+	e = s->head;
+	i = 0;
+	while(e != NULL) {
+		bstream = QRinput_mergeBitStream(e->input);
+		BitStream_free(bstream);
+		l = e->input->head->next;
+		assert_equal(l->mode, QR_MODE_8, "#%d: wrong mode (%d).\n", i, l->mode);
+		assert_equal(e->input->level, QR_ECLEVEL_M, "#%d: wrong level (%d).\n", i, e->input->level);
+
+		e = e->next;
+		i++;
+	}
+	testFinish();
+	QRinput_Struct_free(s);
+}
+
+void test_struct_split_tooLarge(void)
+{
+	QRinput *input;
+	QRinput_Struct *s;
+	char *str;
+	int errsv;
+
+	testStart("Testing structured-append symbols. (too large data)");
+	str = (char *)malloc(128);
+	memset(str, 'a', 128);
+	input = QRinput_new2(1, QR_ECLEVEL_H);
+	QRinput_append(input, QR_MODE_8, 128, (unsigned char *)str);
+	s = QRinput_splitQRinputToStruct(input);
+	errsv = errno;
+	assert_null(s, "returns non-null.");
+	assert_equal(errsv, ERANGE, "did not return ERANGE.");
+	testFinish();
+	if(s != NULL) QRinput_Struct_free(s);
+	QRinput_free(input);
+	free(str);
+}
+
+void test_splitentry(void)
+{
+	QRinput *i1, *i2;
+	QRinput_List *e;
+	char *str = "abcdefghij";
+	int size1, size2, i;
+	unsigned char *d1, *d2;
+
+	testStart("Testing QRinput_splitEntry. (next == NULL)");
+	i1 = QRinput_new();
+	QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str);
+
+	i2 = QRinput_dup(i1);
+	e = i2->head;
+
+	e = i2->head;
+	QRinput_splitEntry(e, 4);
+
+	size1 = size2 = 0;
+	e = i1->head;
+	while(e != NULL) {
+		size1 += e->size;
+		e = e->next;
+	}
+	e = i2->head;
+	while(e != NULL) {
+		size2 += e->size;
+		e = e->next;
+	}
+
+	d1 = (unsigned char *)malloc(size1);
+	e = i1->head;
+	i = 0;
+	while(e != NULL) {
+		memcpy(&d1[i], e->data, e->size);
+		i += e->size;
+		e = e->next;
+	}
+	d2 = (unsigned char *)malloc(size2);
+	e = i2->head;
+	i = 0;
+	while(e != NULL) {
+		memcpy(&d2[i], e->data, e->size);
+		i += e->size;
+		e = e->next;
+	}
+
+	assert_equal(size1, size2, "sizes are different. (%d:%d)\n", size1, size2);
+	assert_equal(i2->head->size, 4, "split failed (first half)");
+	assert_equal(i2->head->next->size, 6, "split failed(second half)");
+	assert_zero(memcmp(d1, d2, size1), "strings are different.");
+	QRinput_free(i1);
+	QRinput_free(i2);
+	free(d1);
+	free(d2);
+
+	testFinish();
+}
+
+void test_splitentry2(void)
+{
+	QRinput *i1, *i2;
+	QRinput_List *e;
+	char *str = "abcdefghij";
+	int size1, size2, i;
+	unsigned char *d1, *d2;
+
+	testStart("Testing QRinput_splitEntry. (next != NULL)");
+	i1 = QRinput_new();
+	QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str);
+	QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str);
+
+	i2 = QRinput_dup(i1);
+	e = i2->head;
+
+	e = i2->head;
+	QRinput_splitEntry(e, 4);
+
+	size1 = size2 = 0;
+	e = i1->head;
+	while(e != NULL) {
+		size1 += e->size;
+		e = e->next;
+	}
+	e = i2->head;
+	while(e != NULL) {
+		size2 += e->size;
+		e = e->next;
+	}
+
+	d1 = (unsigned char *)malloc(size1);
+	e = i1->head;
+	i = 0;
+	while(e != NULL) {
+		memcpy(&d1[i], e->data, e->size);
+		i += e->size;
+		e = e->next;
+	}
+	d2 = (unsigned char *)malloc(size2);
+	e = i2->head;
+	i = 0;
+	while(e != NULL) {
+		memcpy(&d2[i], e->data, e->size);
+		i += e->size;
+		e = e->next;
+	}
+
+	assert_equal(size1, size2, "sizes are different. (%d:%d)\n", size1, size2);
+	assert_equal(i2->head->size, 4, "split failed (first half)");
+	assert_equal(i2->head->next->size, 6, "split failed(second half)");
+	assert_zero(memcmp(d1, d2, size1), "strings are different.");
+	QRinput_free(i1);
+	QRinput_free(i2);
+	free(d1);
+	free(d2);
+
+	testFinish();
+}
+
+void test_splitentry3(void)
+{
+	QRinput *input;
+	QRinput_Struct *s;
+	QRinput_List *e00, *e01, *e10, *e11;
+	QRinput_InputList *list;
+	char *str = "abcdefghijklmno";
+
+	testStart("Testing QRinput_splitEntry. (does not split an entry)");
+	/* version 1 symbol contains 152 bit (19 byte) data.
+	 * 20 bits for a structured-append header, so 132 bits can be used.
+	 * 15 bytes of 8-bit data is suitable for the symbol.
+	 * (mode(4) + length(8) + data(120) == 132.)
+	 */
+	input = QRinput_new2(1, QR_ECLEVEL_L);
+	QRinput_append(input, QR_MODE_8, strlen(str), (unsigned char *)str);
+	QRinput_append(input, QR_MODE_8, strlen(str), (unsigned char *)str);
+	s = QRinput_splitQRinputToStruct(input);
+	list = s->head;
+	e00 = list->input->head;
+	e01 = e00->next;
+	list = list->next;
+	e10 = list->input->head;
+	e11 = e00->next;
+	
+	assert_equal(e00->mode, QR_MODE_STRUCTURE, "Structure header is missing?");
+	assert_equal(e01->mode, QR_MODE_8, "no data?!");
+	assert_null(e01->next, "Input list is not terminated!\n");
+	assert_equal(e10->mode, QR_MODE_STRUCTURE, "Structure header is missing?");
+	assert_equal(e11->mode, QR_MODE_8, "no data?!");
+	assert_null(e11->next, "Input list is not terminated!\n");
+
+	QRinput_free(input);
+	QRinput_Struct_free(s);
+	testFinish();
+}
+
+void test_parity(void)
+{
+	QRinput *input;
+	QRinput_Struct *s;
+	char *text = "an example of four Structured Append symbols,";
+	char *str[4] = {
+		"an example ",
+		"of four Str",
+		"uctured Appe",
+		"nd symbols,"};
+	unsigned char p1, p2;
+	int i, len;
+
+	testStart("Testing parity calc.");
+	s = QRinput_Struct_new();
+	for(i=0; i<4; i++) {
+		input = QRinput_new2(1, QR_ECLEVEL_M);
+		QRinput_append(input, QR_MODE_8, strlen(str[i]), (unsigned char *)str[i]);
+		QRinput_Struct_appendInput(s, input);
+	}
+	QRinput_Struct_insertStructuredAppendHeaders(s);
+	p1 = s->parity;
+
+	p2 = 0;
+	len = strlen(text);
+	for(i=0; iparity;
+
+	p2 = 0;
+	len = strlen(text);
+	for(i=0; ihead;
 	if(inputTest(list, "n", 4)) {
 		err++;
@@ -107,8 +107,8 @@ void test_split2(void)
 
 	err = 0;
 	testStart("Split test: single typed strings (num2)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("12345678901234567890", input, 0, QR_MODE_KANJI, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("12345678901234567890", input, QR_MODE_KANJI, 0);
 	list = input->head;
 	if(inputTest(list, "n", 20)) {
 		err++;
@@ -124,8 +124,8 @@ void test_split3(void)
 	int err = 0;
 
 	testStart("Split test: single typed strings (an)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("ab:-E", input, QR_MODE_8, 0);
 	list = input->head;
 	if(inputTest(list, "a", 5)) {
 		printQrinput(input);
@@ -136,8 +136,8 @@ void test_split3(void)
 
 	err = 0;
 	testStart("Split test: num + an");
-	input = QRinput_new();
-	Split_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("0123abcde", input, QR_MODE_KANJI, 0);
 	list = input->head;
 	if(inputTest(list, "a", 9)) {
 		err++;
@@ -147,8 +147,8 @@ void test_split3(void)
 
 	err = 0;
 	testStart("Split test: an + num + an");
-	input = QRinput_new();
-	Split_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("Ab345fg", input, QR_MODE_KANJI, 0);
 	list = input->head;
 	if(inputTest(list, "a", 7)) {
 		err++;
@@ -167,8 +167,8 @@ void test_split4(void)
 #define CHUNKC "1234567"
 
 	testStart("Split test: an and num entries");
-	input = QRinput_new();
-	Split_splitStringToQRinput(CHUNKA/**/CHUNKB, input, 0, QR_MODE_8, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput(CHUNKA/**/CHUNKB, input, QR_MODE_8, 0);
 	i1 = QRinput_new();
 	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKA/**/CHUNKB);
 	i2 = QRinput_new();
@@ -184,8 +184,8 @@ void test_split4(void)
 	QRinput_free(i2);
 
 	testStart("Split test: num and an entries");
-	input = QRinput_new();
-	Split_splitStringToQRinput(CHUNKB/**/CHUNKA, input, 0, QR_MODE_8, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput(CHUNKB/**/CHUNKA, input, QR_MODE_8, 0);
 	i1 = QRinput_new();
 	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKB/**/CHUNKA);
 	i2 = QRinput_new();
@@ -201,8 +201,8 @@ void test_split4(void)
 	QRinput_free(i2);
 
 	testStart("Split test: num and an entries (should be splitted)");
-	input = QRinput_new();
-	Split_splitStringToQRinput(CHUNKC/**/CHUNKA, input, 0, QR_MODE_8, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput(CHUNKC/**/CHUNKA, input, QR_MODE_8, 0);
 	i1 = QRinput_new();
 	QRinput_append(i1, QR_MODE_AN, 18, (unsigned char *)CHUNKC/**/CHUNKA);
 	i2 = QRinput_new();
@@ -225,8 +225,8 @@ void test_split5(void)
 	int err = 0;
 
 	testStart("Split test: bit, an, bit, num");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_8, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, QR_MODE_8, 0);
 	list = input->head;
 	if(inputTest(list, "8a8n", 2, 11, 2, 6)) {
 		err++;
@@ -242,8 +242,8 @@ void test_split6(void)
 	int err = 0;
 
 	testStart("Split test: kanji, an, kanji, num");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, 0, QR_MODE_KANJI, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, QR_MODE_KANJI, 0);
 	list = input->head;
 	if(inputTest(list, "kakn", 2, 11, 2, 6)) {
 		printQrinput(input);
@@ -260,8 +260,8 @@ void test_split7(void)
 	int err = 0;
 
 	testStart("Split test: an and num as bits");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x82\xd9""abcde\x82\xb0""12345", input, 0, QR_MODE_8, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("\x82\xd9""abcde\x82\xb0""12345", input, QR_MODE_8, 0);
 	list = input->head;
 	if(inputTest(list, "8n", 9, 5)) {
 		err++;
@@ -277,8 +277,8 @@ void test_split8(void)
 	int err = 0;
 
 	testStart("Split test: terminated with a half of kanji code");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x82\xd9""abcdefgh\x82", input, 0, QR_MODE_KANJI, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("\x82\xd9""abcdefgh\x82", input, QR_MODE_KANJI, 0);
 	list = input->head;
 	if(inputTest(list, "ka8", 2, 8, 1)) {
 		err++;
@@ -294,8 +294,8 @@ void test_split3c(void)
 	int err = 0;
 
 	testStart("Split test: single typed strings (an, case-sensitive)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("ab:-E", input, 0, QR_MODE_8, 1);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("ab:-E", input, QR_MODE_8, 1);
 	list = input->head;
 	if(inputTest(list, "8", 5)) {
 		err++;
@@ -305,8 +305,8 @@ void test_split3c(void)
 
 	err = 0;
 	testStart("Split test: num + an");
-	input = QRinput_new();
-	Split_splitStringToQRinput("0123abcde", input, 0, QR_MODE_KANJI, 1);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("0123abcde", input, QR_MODE_KANJI, 1);
 	list = input->head;
 	if(inputTest(list, "n8", 4, 5)) {
 		err++;
@@ -316,8 +316,8 @@ void test_split3c(void)
 
 	err = 0;
 	testStart("Split test: an + num + an");
-	input = QRinput_new();
-	Split_splitStringToQRinput("Ab345fg", input, 0, QR_MODE_KANJI, 1);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("Ab345fg", input, QR_MODE_KANJI, 1);
 	list = input->head;
 	if(inputTest(list, "8", 7)) {
 		printQrinput(input);
@@ -334,8 +334,8 @@ void test_toupper(void)
 	int err = 0;
 
 	testStart("Split test: check dupAndToUpper (lower->upper)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("abcde", input, 0, QR_MODE_8, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("abcde", input, QR_MODE_8, 0);
 	list = input->head;
 	if(inputTest(list, "a", 5)) {
 		err++;
@@ -348,8 +348,8 @@ void test_toupper(void)
 
 	err = 0;
 	testStart("Split test: check dupAndToUpper (kanji)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, 0, QR_MODE_KANJI, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, QR_MODE_KANJI, 0);
 	list = input->head;
 	if(inputTest(list, "k", 10)) {
 		printQrinput(input);
@@ -363,8 +363,8 @@ void test_toupper(void)
 
 	err = 0;
 	testStart("Split test: check dupAndToUpper (8bit)");
-	input = QRinput_new();
-	Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, 0, QR_MODE_8, 0);
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, QR_MODE_8, 0);
 	list = input->head;
 	if(inputTest(list, "8", 10)) {
 		printQrinput(input);
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index c8d8a68605..3f10ff7fc9 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -3,10 +3,9 @@
 #include 
 #include 
 #include 
-#include "common.h"
-#include "../qrencode_inner.h"
 #include "../qrspec.h"
 #include "../qrinput.h"
+#include "../qrencode_inner.h"
 #include "../split.h"
 
 static SDL_Surface *screen = NULL;
@@ -15,9 +14,13 @@ static int eightbit = 0;
 static int version = 1;
 static int size = 4;
 static int margin = 4;
+static int structured = 0;
 static QRecLevel level = QR_ECLEVEL_L;
 static QRencodeMode hint = QR_MODE_8;
 
+static char **textv;
+static int textc;
+
 enum {
 	O_HELP,
 	O_SIZE,
@@ -28,9 +31,10 @@ enum {
 	O_CASE,
 	O_IGNORECASE,
 	O_8BIT,
+	O_STRUCTURED,
 };
 
-const struct option options[] = {
+static const struct option options[] = {
 	{"h", no_argument      , NULL, O_HELP},
 	{"l", required_argument, NULL, O_LEVEL},
 	{"s", required_argument, NULL, O_SIZE},
@@ -40,6 +44,7 @@ const struct option options[] = {
 	{"c", no_argument      , NULL, O_CASE},
 	{"i", no_argument      , NULL, O_IGNORECASE},
 	{"8", no_argument      , NULL, O_8BIT},
+	{"S", no_argument      , NULL, O_STRUCTURED},
 	{NULL, 0, NULL, 0}
 };
 
@@ -58,6 +63,7 @@ static void usage(void)
 "               (default=L)\n"
 "  -v NUMBER    specify the version of the symbol. (default=auto)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
+"  -S           make structured symbols. Version must be specified.\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
 "  -c           encode lower-case alphabet characters in 8-bit mode. (default)\n"
 "  -i           ignore case distinctions and use only upper-case characters.\n"
@@ -67,7 +73,7 @@ static void usage(void)
 	VERSION);
 }
 
-#define MAX_DATA_SIZE 7090 /* from the specification */
+#define MAX_DATA_SIZE (7090 * 16) /* from the specification */
 static char *readStdin(void)
 {
 	char *buffer;
@@ -89,49 +95,131 @@ static char *readStdin(void)
 	return buffer;
 }
 
-void view_simple(const char *str)
+static void draw_QRcode(QRcode *qrcode, int ox, int oy)
 {
-	QRinput *stream;
-	unsigned char *frame, *q;
-	int width;
-	int x, y;
 	int pitch;
-	int flag = 1;
-	int mask = -1;
-	QRcode *qrcode;
-	SDL_Event event;
-	int loop;
+	int x, y, width;
+	unsigned char *p;
 	SDL_Rect rect;
 
-	stream = QRinput_new();
-	if(eightbit) {
-		QRinput_append(stream, QR_MODE_8, strlen(str), (unsigned char *)str);
+	ox += margin * size;
+	oy += margin * size;
+	width = qrcode->width;
+	p = qrcode->data;
+	pitch = screen->pitch;
+	for(y=0; yversion;
+	width = (qrcode->width + margin * 2) * size;
+
+	screen = SDL_SetVideoMode(width, width, 32, 0);
+	SDL_FillRect(screen, NULL, 0xffffff);
+	draw_QRcode(qrcode, 0, 0);
+	SDL_Flip(screen);
+	QRcode_free(qrcode);
+}
+
+void draw_structuredQRcode(QRinput_Struct *s, int mask)
+{
+	int i, w, h, n, x, y;
+	int swidth;
+	QRcode_List *qrcodes, *p;
+
+	qrcodes = QRcode_encodeStructuredInput(s);
+	swidth = (qrcodes->code->width + margin * 2) * size;
+	n = QRcode_List_size(qrcodes);
+	w = (n < 4)?n:4;
+	h = (n - 1) / 4 + 1;
+
+	screen = SDL_SetVideoMode(swidth * w, swidth * h, 32, 0);
+	SDL_FillRect(screen, NULL, 0xffffff);
+
+	p = qrcodes;
+	for(i=0; icode, x, y);
+		p = p->next;
+	}
+	SDL_Flip(screen);
+	QRcode_List_free(qrcodes);
+}
+
+void draw_structuredQRcodeFromText(int argc, char **argv, int mask)
+{
+	QRinput_Struct *s;
+	QRinput *input;
+	int i;
+
+	s = QRinput_Struct_new();
+	for(i=0; iwidth;
-		frame = qrcode->data;
-		version = qrcode->version;
-		printf("Version %d, Leve %c, Mask %d.\n", version, levelChar[level], mask);
-		screen = SDL_SetVideoMode((width + margin*2) * size, (width + margin*2) * size, 32, 0);
-		pitch = screen->pitch;
-		q = frame;
-		SDL_FillRect(screen, NULL, 0xffffff);
-		for(y=0; y 1)) {
+		view_multiText(argv + optind, argc - optind);
+	} else {
+		view_simple(intext);
+	}
 
 	SDL_Quit();
 
-- 
cgit 0.0.5-2-1-g0f52


From d9a4c4c86eafba4717d84dd4de67ae85cb1d3668 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 17 Apr 2008 14:34:32 +0000
Subject:

---
 tests/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index bbfe88623c..f31c5dbc54 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,7 +20,7 @@ test_qrspec_SOURCES = test_qrspec.c common.h
 test_qrspec_LDADD = ../libqrencode.la
 
 test_mqrspec_SOURCES = test_mqrspec.c common.h
-test_mqrspec_LDADD = ../mqrspec.o
+test_mqrspec_LDADD = ../libqrencode.la
 
 test_rs_SOURCES = test_rs.c common.h
 test_rs_LDADD = ../libqrencode.la
-- 
cgit 0.0.5-2-1-g0f52


From 608b948889d6b54ff6db81036454d3c3f02ba5ab Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Tue, 22 Apr 2008 04:57:34 +0000
Subject: 3.0.0rc2 is merged to the main trunk.

---
 ChangeLog             | 16 +++++++++
 Makefile.am           |  3 +-
 NEWS                  |  5 +--
 TODO                  | 15 ++++-----
 configure.ac          | 16 ++++++++-
 qrencode.h            |  1 +
 qrinput.c             | 31 ++---------------
 qrinput.h             |  1 -
 split.c               | 93 ++++++++++++++++++++++++++++++++-------------------
 tests/test_qrencode.c | 19 +++++++++--
 tests/test_qrinput.c  |  6 +++-
 tests/test_split.c    | 19 +++++++++++
 12 files changed, 144 insertions(+), 81 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d01dd0db4b..e1ed4ffb2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2008.04.20 Kentaro FUKUCHI 
+	* qrencode.h:
+	  - QR_MODE_NUL has been added to QRencodeMode. Basically it is used only
+	    by Split_identifyMode().
+	* qrinput.[ch], split.c]:
+	  - QRinput_identifyMode() has been moved to split.c, changed to static
+	    and now needs a hint.
+	* split.c:
+	  - Auto-splitting has been improved.
+	* qrinput.c:
+	  - A memory leak has been fixed.
+	* configure.ac:
+	  - The "--enable-gprof" and "--enable-gcov" options have been added.
+	* Makefile.am:
+	  - man1_MANS has been moved into the "if BUILD_TOOLS - endif" block.
+
 2008.04.14 Kentaro FUKUCHI 
 	* Bumped version to 3.0.0.
 	* qrencode.[ch]:
diff --git a/Makefile.am b/Makefile.am
index ee15cb6137..23713104b3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,8 +19,6 @@ include_HEADERS = qrencode.h
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libqrencode.pc
 
-man1_MANS = qrencode.1
-
 EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \
 			 Makefile.am tests/Makefile.am qrencode.spec.in qrencode.1.in
 
@@ -29,4 +27,5 @@ bin_PROGRAMS = qrencode
 qrencode_SOURCES = qrenc.c
 qrencode_CFLAGS = $(png_CFLAGS)
 qrencode_LDADD = -lqrencode $(png_LIBS)
+man1_MANS = qrencode.1
 endif
diff --git a/NEWS b/NEWS
index f17ee1e093..b9e9390077 100644
--- a/NEWS
+++ b/NEWS
@@ -4,9 +4,10 @@ libqrencode NEWS - Overview of changes
 Version 3.0.0 (2008.4.x)
 ------------------------
 Summary:
-* A significant API change that requires to modify user applications.
+* A significant API change was made that requires to modify user applications.
 * Structured append support has been added. (patches from Yusuke Mihara)
-* "-S" option for structured append has been added to qrencode and view_qrcode.
+* The "-S" option for structured append has been added to qrencode and
+  view_qrcode.
 
 Release Note:
 
diff --git a/TODO b/TODO
index 71b4df181d..7bfdc1c93d 100644
--- a/TODO
+++ b/TODO
@@ -1,15 +1,12 @@
 Thread unsafe.
 Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe, but
-all of qrencode functions are thread unsafe because of them.
-Version 3.0 of libqrencode will introduce semaphores to avoid this problem.
-It also requires, however, a kind of init function of libqrencode such as
-QRencode_init().
+most of qrencode functions are thread unsafe because of them.
 
 This package contains
-
-*.c and *.h files (total):  7967 lines, 196078 bytes.
-configure script         : 22511 lines, 724922 bytes.
-
+*.c and *.h files (total):  8012 lines, 197484 bytes.
+configure script         : 22539 lines, 725612 bytes.
 It's absolutely crazy.
 
-This library does not return any error code (just returns NULL silently).
+Documents (not only the README, but also the manual of the library) needs
+revision of grammer, spell or to resolve ambiguity or incomplete descriptions.
+Feel really free to send us your revision.
diff --git a/configure.ac b/configure.ac
index ee2d1c179a..9acfeb7a5e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,13 +36,27 @@ CFLAGS="-Wall $CFLAGS"
 AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1])
 
 AC_ARG_WITH([tools], [AC_HELP_STRING([--with-tools], [build utility tools [default=yes]])],
- [], [build_tools=yes])
+ [build_tools=$withval], [build_tools=yes])
 
 if test x$build_tools = xyes ; then
 	PKG_CHECK_MODULES(png, "libpng12")
 fi
 AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ])
 
+AC_ARG_ENABLE([gprof], [AC_HELP_STRING([--enable-gprof], [generate extra code to write profile information suitable for gprof [default=no]])],
+ [], [enable_gprof=no])
+
+AC_ARG_ENABLE([gcov], [AC_HELP_STRING([--enable-gcov], [generate extra code to write coverage information suitable for gcov [default=no]])],
+ [], [enable_gcov=no])
+
+if test $enable_gprof = yes; then
+	CFLAGS="$CFLAGS -g -pg"
+fi
+
+if test $enable_gcov = yes; then
+	CFLAGS="$CFLAGS --coverage"
+fi
+
 AC_OUTPUT
 
 echo ""
diff --git a/qrencode.h b/qrencode.h
index 123ba33820..209eb26083 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -107,6 +107,7 @@ extern "C" {
  * Encoding mode.
  */
 typedef enum {
+	QR_MODE_NUL = -1,	///< Terminator (NUL character)
 	QR_MODE_NUM = 0,	///< Numeric mode
 	QR_MODE_AN,			///< Alphabet-numeric mode
 	QR_MODE_8,			///< 8-bit data mode
diff --git a/qrinput.c b/qrinput.c
index 68d05a4573..0958b09afa 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -585,30 +585,6 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data)
 	return -1;
 }
 
-QRencodeMode QRinput_identifyMode(const char *string)
-{
-	unsigned char c, d;
-	unsigned int word;
-
-	c = string[0];
-
-	if((unsigned char)((signed char)c - '0') < 10) {
-		return QR_MODE_NUM;
-	} else if((QRinput_lookAnTable(c)) >= 0) {
-		return QR_MODE_AN;
-	} else {
-		d = string[1];
-		if(d != '\0') {
-			word = ((unsigned int)c << 8) | d;
-			if((word >= 0x8140 && word <= 0x9ffc) || (word >= 0xe040 && word <= 0xebbf)) {
-				return QR_MODE_KANJI;
-			}
-		}
-	}
-
-	return QR_MODE_8;
-}
-
 /******************************************************************************
  * Estimation of the bit length
  *****************************************************************************/
@@ -640,6 +616,8 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version
 			break;
 		case QR_MODE_STRUCTURE:
 			return STRUCTURE_HEADER_BITS;
+		default:
+			return 0;
 	}
 
 	l = QRspec_lengthIndicator(entry->mode, version);
@@ -1153,11 +1131,6 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input)
 				input->tail = prev;
 			}
 			QRinput_Struct_appendInput(s, input);
-			if(s->size > MAX_STRUCTURED_SYMBOLS) {
-				QRinput_Struct_free(s);
-				errno = ERANGE;
-				return NULL;
-			}
 			input = p;
 			bits = 0;
 		}
diff --git a/qrinput.h b/qrinput.h
index 38c7a919eb..3c0211a165 100644
--- a/qrinput.h
+++ b/qrinput.h
@@ -99,7 +99,6 @@ extern QRinput *QRinput_dup(QRinput *input);
 extern int QRinput_splitEntry(QRinput_List *entry, int bytes);
 
 extern const signed char QRinput_anTable[];
-extern QRencodeMode QRinput_identifyMode(const char *string);
 
 /**
  * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19).
diff --git a/split.c b/split.c
index ecf70fe796..471e87dd50 100644
--- a/split.c
+++ b/split.c
@@ -35,6 +35,31 @@
 #define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10)
 #define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0)
 
+static QRencodeMode Split_identifyMode(const char *string, QRencodeMode hint)
+{
+	unsigned char c, d;
+	unsigned int word;
+
+	c = string[0];
+
+	if(c == '\0') return QR_MODE_NUL;
+	if((unsigned char)((signed char)c - '0') < 10) {
+		return QR_MODE_NUM;
+	} else if((QRinput_lookAnTable(c)) >= 0) {
+		return QR_MODE_AN;
+	} else if(hint == QR_MODE_KANJI) {
+		d = string[1];
+		if(d != '\0') {
+			word = ((unsigned int)c << 8) | d;
+			if((word >= 0x8140 && word <= 0x9ffc) || (word >= 0xe040 && word <= 0xebbf)) {
+				return QR_MODE_KANJI;
+			}
+		}
+	}
+
+	return QR_MODE_8;
+}
+
 static int Split_eatNum(const char *string, QRinput *input, QRencodeMode hint);
 static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint);
 static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint);
@@ -47,6 +72,7 @@ static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint)
 	int run;
 	int dif;
 	int ln;
+	QRencodeMode mode;
 
 	ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version);
 
@@ -55,7 +81,8 @@ static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint)
 		p++;
 	}
 	run = p - string;
-	if(*p & 0x80) {
+	mode = Split_identifyMode(p, hint);
+	if(mode == QR_MODE_8) {
 		dif = QRinput_estimateBitsModeNum(run) + 4 + ln
 			+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
 			- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
@@ -63,7 +90,7 @@ static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint)
 			return Split_eat8(string, input, hint);
 		}
 	}
-	if(isalnum(*p)) {
+	if(mode == QR_MODE_AN) {
 		dif = QRinput_estimateBitsModeNum(run) + 4 + ln
 			+ QRinput_estimateBitsModeAn(1) /* + 4 + la */
 			- QRinput_estimateBitsModeAn(run + 1) /* - 4 - la */;
@@ -133,7 +160,7 @@ static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint)
 	int run;
 
 	p = string;
-	while(QRinput_identifyMode(p) == QR_MODE_KANJI) {
+	while(Split_identifyMode(p, hint) == QR_MODE_KANJI) {
 		p += 2;
 	}
 	run = p - string;
@@ -157,37 +184,35 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint)
 
 	p = string + 1;
 	while(*p != '\0') {
-		mode = QRinput_identifyMode(p);
-		if(hint == QR_MODE_KANJI && mode == QR_MODE_KANJI) {
+		mode = Split_identifyMode(p, hint);
+		if(mode == QR_MODE_KANJI) {
 			break;
 		}
-		if(mode != QR_MODE_8 && mode != QR_MODE_KANJI) {
-			if(mode == QR_MODE_NUM) {
-				q = p;
-				while(isdigit(*q)) {
-					q++;
-				}
-				dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */
-					+ QRinput_estimateBitsModeNum(q - p) + 4 + ln
-					- QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */;
-				if(dif < 0) {
-					break;
-				} else {
-					p = q;
-				}
+		if(mode == QR_MODE_NUM) {
+			q = p;
+			while(isdigit(*q)) {
+				q++;
+			}
+			dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */
+				+ QRinput_estimateBitsModeNum(q - p) + 4 + ln
+				- QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */;
+			if(dif < 0) {
+				break;
+			} else {
+				p = q;
+			}
+		} else if(mode == QR_MODE_AN) {
+			q = p;
+			while(isalnum(*q)) {
+				q++;
+			}
+			dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */
+				+ QRinput_estimateBitsModeAn(q - p) + 4 + la
+				- QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */;
+			if(dif < 0) {
+				break;
 			} else {
-				q = p;
-				while(isalnum(*q)) {
-					q++;
-				}
-				dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */
-					+ QRinput_estimateBitsModeAn(q - p) + 4 + la
-					- QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */;
-				if(dif < 0) {
-					break;
-				} else {
-					p = q;
-				}
+				p = q;
 			}
 		} else {
 			p++;
@@ -209,7 +234,7 @@ static int Split_splitString(const char *string, QRinput *input,
 
 	if(*string == '\0') return 0;
 
-	mode = QRinput_identifyMode(string);
+	mode = Split_identifyMode(string, hint);
 	if(mode == QR_MODE_NUM) {
 		length = Split_eatNum(string, input, hint);
 	} else if(mode == QR_MODE_AN) {
@@ -234,8 +259,8 @@ static char *dupAndToUpper(const char *str, QRencodeMode hint)
 
 	p = newstr;
 	while(*p != '\0') {
-		mode = QRinput_identifyMode(p);
-		if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
+		mode = Split_identifyMode(p, hint);
+		if(mode == QR_MODE_KANJI) {
 			p += 2;
 		} else {
 			if (*p >= 'a' && *p <= 'z') {
diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index 9baea3d49c..868d835119 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -557,7 +557,7 @@ void test_struct_semilong(void)
 {
 	QRcode_List *codes, *list;
 	char *str = "asdfasdfasdfasdfasdfASDFASDASDFASDFAsdfasdfasdfasdASDFASDFADSADadsfasdf";
-	int num;
+	int num, size;
 
 	testStart("Testing semi-long structured-append symbols");
 	codes = QRcode_encodeString8bitStructured(str, 1, QR_ECLEVEL_L);
@@ -568,8 +568,23 @@ void test_struct_semilong(void)
 		assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version);
 		list = list->next;
 	}
-	testFinish();
+	size = QRcode_List_size(codes);
+	assert_equal(num, size, "QRcode_List_size returns wrong size?");
 	QRcode_List_free(codes);
+
+	codes = QRcode_encodeStringStructured(str, 1, QR_ECLEVEL_L, QR_MODE_8, 1);
+	list = codes;
+	num = 0;
+	while(list != NULL) {
+		num++;
+		assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version);
+		list = list->next;
+	}
+	size = QRcode_List_size(codes);
+	assert_equal(num, size, "QRcode_List_size returns wrong size?");
+	QRcode_List_free(codes);
+
+	testFinish();
 }
 
 void test_struct_example(void)
diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c
index e554f54ac2..cae465e4b0 100644
--- a/tests/test_qrinput.c
+++ b/tests/test_qrinput.c
@@ -10,18 +10,22 @@ void test_encodeKanji(void)
 {
 	QRinput *stream;
 	unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa};
+	unsigned char *buf;
 	char correct[] = "10000000001001101100111111101010101010";
 	BitStream *bstream;
 
 	testStart("Encoding kanji stream.");
+	buf = (unsigned char *)malloc(4);
+	memcpy(buf, str, 4);
 	stream = QRinput_new();
-	QRinput_append(stream, QR_MODE_KANJI, 4, (unsigned char *)str);
+	QRinput_append(stream, QR_MODE_KANJI, 4, buf);
 	bstream = QRinput_mergeBitStream(stream);
 	printf("%s\n", correct);
 	printf("%s\n", bstream->data);
 	testEnd(strcmp(correct, bstream->data));
 	QRinput_free(stream);
 	BitStream_free(bstream);
+	free(buf);
 }
 
 void test_encode8(void)
diff --git a/tests/test_split.c b/tests/test_split.c
index 7e2a903a59..065ddf8d52 100644
--- a/tests/test_split.c
+++ b/tests/test_split.c
@@ -377,6 +377,24 @@ void test_toupper(void)
 	QRinput_free(input);
 }
 
+void test_splitNum8(void)
+{
+	QRinput *input;
+	QRinput_List *list;
+	int err = 0;
+
+	testStart("Split test: num and 8bit to 8bit");
+	input = QRinput_new2(0, QR_ECLEVEL_L);
+	Split_splitStringToQRinput("1abcdefg", input, QR_MODE_8, 1);
+	list = input->head;
+	if(inputTest(list, "8", 8)) {
+		err++;
+		printQRinput(input);
+	}
+	testEnd(err);
+	QRinput_free(input);
+}
+
 int main(int argc, char **argv)
 {
 	test_split1();
@@ -389,6 +407,7 @@ int main(int argc, char **argv)
 	test_split8();
 	test_split3c();
 	test_toupper();
+	test_splitNum8();
 
 	report();
 
-- 
cgit 0.0.5-2-1-g0f52

-- 
cgit 0.0.5-2-1-g0f52


From 8bae17bf467ac3a47e599dcd0007c8c505e065cf Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 23 Apr 2008 13:34:08 +0000
Subject:

---
 ChangeLog | 4 ++++
 split.c   | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e1ed4ffb2b..845f8ecb83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008.04.23 Kentaro FUKUCHI 
+	* split.c:
+	  - Split_identifyMode() now uses isdigit() and isalnum macros.
+
 2008.04.20 Kentaro FUKUCHI 
 	* qrencode.h:
 	  - QR_MODE_NUL has been added to QRencodeMode. Basically it is used only
diff --git a/split.c b/split.c
index 471e87dd50..12b3cd9d6c 100644
--- a/split.c
+++ b/split.c
@@ -43,9 +43,9 @@ static QRencodeMode Split_identifyMode(const char *string, QRencodeMode hint)
 	c = string[0];
 
 	if(c == '\0') return QR_MODE_NUL;
-	if((unsigned char)((signed char)c - '0') < 10) {
+	if(isdigit(c)) {
 		return QR_MODE_NUM;
-	} else if((QRinput_lookAnTable(c)) >= 0) {
+	} else if(isalnum(c)) {
 		return QR_MODE_AN;
 	} else if(hint == QR_MODE_KANJI) {
 		d = string[1];
-- 
cgit 0.0.5-2-1-g0f52


From 7dbf4f65f96e54be1b87bc0935ce3dd5c5675167 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 23 Apr 2008 14:51:12 +0000
Subject: QRinput_splitQRinputToStruct() now returns NULL when version = 0.

---
 qrinput.c            |  7 +++++++
 tests/test_qrinput.c | 23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/qrinput.c b/qrinput.c
index 0958b09afa..91f5f172f2 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -601,6 +601,8 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version
 	int l, m;
 	int num;
 
+	if(version == 0) version = 1;
+
 	switch(entry->mode) {
 		case QR_MODE_NUM:
 			bits = QRinput_estimateBitsModeNum(entry->size);
@@ -1096,6 +1098,11 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input)
 	QRinput_Struct_setParity(s, QRinput_calcParity(input));
 	maxbits = QRspec_getDataLength(input->version, input->level) * 8 - STRUCTURE_HEADER_BITS;
 
+	if(maxbits <= 0) {
+		QRinput_Struct_free(s);
+		return NULL;
+	}
+
 	bits = 0;
 	list = input->head;
 	prev = NULL;
diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c
index cae465e4b0..867116fb9f 100644
--- a/tests/test_qrinput.c
+++ b/tests/test_qrinput.c
@@ -479,6 +479,28 @@ void test_struct_split_tooLarge(void)
 	free(str);
 }
 
+void test_struct_split_invalidVersion(void)
+{
+	QRinput *input;
+	QRinput_Struct *s;
+	char *str;
+	int errsv;
+
+	testStart("Testing structured-append symbols. (invalid version 0)");
+	str = (char *)malloc(128);
+	memset(str, 'a', 128);
+	input = QRinput_new2(0, QR_ECLEVEL_H);
+	QRinput_append(input, QR_MODE_8, 128, (unsigned char *)str);
+	s = QRinput_splitQRinputToStruct(input);
+	errsv = errno;
+	assert_null(s, "returns non-null.");
+	assert_equal(errsv, ERANGE, "did not return ERANGE.");
+	testFinish();
+	if(s != NULL) QRinput_Struct_free(s);
+	QRinput_free(input);
+	free(str);
+}
+
 void test_splitentry(void)
 {
 	QRinput *i1, *i2;
@@ -718,6 +740,7 @@ int main(int argc, char **argv)
 	test_splitentry3();
 	test_struct_split_example();
 	test_struct_split_tooLarge();
+	test_struct_split_invalidVersion();
 	test_parity();
 	test_parity2();
 
-- 
cgit 0.0.5-2-1-g0f52


From 94393e58c70d0f98fc50cd7033eb638c22580a48 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 23 Apr 2008 14:54:04 +0000
Subject:

---
 ChangeLog           |  5 +++++
 qrenc.c             |  4 ++++
 tests/view_qrcode.c | 57 ++++++++++++++++++++++++++++++++++++++++++-----------
 3 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 845f8ecb83..7d8fd1a22d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 2008.04.23 Kentaro FUKUCHI 
 	* split.c:
 	  - Split_identifyMode() now uses isdigit() and isalnum macros.
+	* qrinput.c:
+	  - Error checks have been improved.
+	* qrenc.c, tests/view_qrcode.c:
+	  - Return value checks have been added.
+	  - Structured-append encode with version 0 now returns error.
 
 2008.04.20 Kentaro FUKUCHI 
 	* qrencode.h:
diff --git a/qrenc.c b/qrenc.c
index d29c5bf345..a3c11a64f1 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -262,6 +262,10 @@ static void qrencodeStructured(const char *intext, const char *outfile)
 	int i = 1;
 
 	base = strdup(outfile);
+	if(base == NULL) {
+		fprintf(stderr, "Failed to allocate memory.\n");
+		exit(1);
+	}
 	if(strlen(base) > 4) {
 		q = base + strlen(base) - 4;
 		if(strcasecmp(".png", q) == 0) {
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 3f10ff7fc9..43e80b3126 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -3,6 +3,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "../qrspec.h"
 #include "../qrinput.h"
 #include "../qrencode_inner.h"
@@ -61,7 +62,7 @@ static void usage(void)
 "  -s NUMBER    specify the size of dot (pixel). (default=4)\n"
 "  -l {LMQH}    specify error collectin level from L (lowest) to H (highest).\n"
 "               (default=L)\n"
-"  -v NUMBER    specify the version of the symbol. (default=auto)\n"
+"  -v NUMBER    specify the version of the symbol. (default=1)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
 "  -S           make structured symbols. Version must be specified.\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
@@ -127,6 +128,8 @@ void draw_singleQRcode(QRinput *stream, int mask)
 	QRinput_setVersion(stream, version);
 	QRinput_setErrorCorrectionLevel(stream, level);
 	qrcode = QRcode_encodeMask(stream, mask);
+	if(qrcode == NULL) return;
+
 	version = qrcode->version;
 	width = (qrcode->width + margin * 2) * size;
 
@@ -144,6 +147,8 @@ void draw_structuredQRcode(QRinput_Struct *s, int mask)
 	QRcode_List *qrcodes, *p;
 
 	qrcodes = QRcode_encodeStructuredInput(s);
+	if(qrcodes == NULL) return;
+
 	swidth = (qrcodes->code->width + margin * 2) * size;
 	n = QRcode_List_size(qrcodes);
 	w = (n < 4)?n:4;
@@ -167,24 +172,41 @@ void draw_structuredQRcodeFromText(int argc, char **argv, int mask)
 {
 	QRinput_Struct *s;
 	QRinput *input;
-	int i;
+	int i, ret;
 
 	s = QRinput_Struct_new();
+	if(s == NULL) {
+		fprintf(stderr, "Failed to allocate memory.\n");
+		exit(1);
+	}
 	for(i=0; i 1)) {
 		view_multiText(argv + optind, argc - optind);
 	} else {
-- 
cgit 0.0.5-2-1-g0f52


From e33c97259730db51e4037a7f7016dcff7cb69a4a Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 23 Apr 2008 15:45:35 +0000
Subject:

---
 ChangeLog           | 3 +++
 NEWS                | 2 ++
 qrencode.c          | 4 ++--
 qrencode.h          | 2 +-
 tests/test_monkey.c | 2 +-
 tests/view_qrcode.c | 2 +-
 6 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7d8fd1a22d..2a3452f32b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@
 	* qrenc.c, tests/view_qrcode.c:
 	  - Return value checks have been added.
 	  - Structured-append encode with version 0 now returns error.
+	* qrencode.[ch]:
+	  - QRencode_encodeStructuredInput() -> QRencode_encodeInputStructured()
+	    (for consistency with other QRencode_encode*Structured() functions)
 
 2008.04.20 Kentaro FUKUCHI 
 	* qrencode.h:
diff --git a/NEWS b/NEWS
index b9e9390077..a264da2acb 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Summary:
 * Structured append support has been added. (patches from Yusuke Mihara)
 * The "-S" option for structured append has been added to qrencode and
   view_qrcode.
+* Some functions now set errno to indicate errors.
+* Some bug fixes.
 
 Release Note:
 
diff --git a/qrencode.c b/qrencode.c
index 4bc9e50080..0546ef08e1 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -538,7 +538,7 @@ static unsigned char QRcode_parity(const char *str, int size)
 }
 #endif
 
-QRcode_List *QRcode_encodeStructuredInput(QRinput_Struct *s)
+QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s)
 {
 	QRcode_List *head = NULL;
 	QRcode_List *tail = NULL;
@@ -571,7 +571,7 @@ static QRcode_List *QRcode_encodeInputToStructured(QRinput *input)
 	s = QRinput_splitQRinputToStruct(input);
 	if(s == NULL) return NULL;
 
-	codes = QRcode_encodeStructuredInput(s);
+	codes = QRcode_encodeInputStructured(s);
 	QRinput_Struct_free(s);
 
 	return codes;
diff --git a/qrencode.h b/qrencode.h
index 209eb26083..a79ee70067 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -378,7 +378,7 @@ extern void QRcode_free(QRcode *qrcode);
  * @param s
  * @return a singly-linked list of QRcode.
  */
-extern QRcode_List *QRcode_encodeStructuredInput(QRinput_Struct *s);
+extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s);
 
 /**
  * Create structured symbols from the string. The library automatically parses
diff --git a/tests/test_monkey.c b/tests/test_monkey.c
index 5f272f3d6c..4e0d6fbd59 100644
--- a/tests/test_monkey.c
+++ b/tests/test_monkey.c
@@ -224,7 +224,7 @@ void test_split_structure(void)
 		i++;
 		il = il->next;
 	}
-	codes = QRcode_encodeStructuredInput(s);
+	codes = QRcode_encodeInputStructured(s);
 	list = codes;
 	il = s->head;
 	c = 0;
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 43e80b3126..8b4b619bfa 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -146,7 +146,7 @@ void draw_structuredQRcode(QRinput_Struct *s, int mask)
 	int swidth;
 	QRcode_List *qrcodes, *p;
 
-	qrcodes = QRcode_encodeStructuredInput(s);
+	qrcodes = QRcode_encodeInputStructured(s);
 	if(qrcodes == NULL) return;
 
 	swidth = (qrcodes->code->width + margin * 2) * size;
-- 
cgit 0.0.5-2-1-g0f52


From 4f2327818041344547aac7f012fa213363471125 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 23 Apr 2008 16:00:29 +0000
Subject:

---
 README | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/README b/README
index b56fd70308..9af4ee027c 100644
--- a/README
+++ b/README
@@ -61,7 +61,14 @@ USAGE
 Basic usages of this library are written in the header file (qrencode.h).
 You can generate a manual of the library by using Doxygen.
 
-WARNING: Some functions are THREAD UNSAFE. See qrencode.h for the details.
+
+WARNINGS
+========
+Some functions are THREAD UNSAFE. See qrencode.h for the details.
+
+Carefully use the qrencode command if it is used by a web application (CGI).
+For example, giving "-s" option with too large number to qrencode may cause DoS.
+You should limit the parameter by your application.
 
 
 LICENSING INFORMATION
-- 
cgit 0.0.5-2-1-g0f52


From d9fefcdaf64a92990d231d86857d896220b42ca5 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 30 Apr 2008 06:11:18 +0000
Subject: Merged 3.0.0 release.

---
 ChangeLog   | 27 +++++++++++++++++++++------
 Makefile.am |  6 +++---
 NEWS        |  7 ++++---
 3 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2a3452f32b..029c1e803e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008.04.30 Kentaro FUKUCHI 
+	* Version 3.0.0 has been released.
+
+2008.04.23 Kentaro FUKUCHI 
+	* Version 3.0.0rc3 has been released.
+	  - This will probably be the final release candidate, if all goes well.
+
 2008.04.23 Kentaro FUKUCHI 
 	* split.c:
 	  - Split_identifyMode() now uses isdigit() and isalnum macros.
@@ -9,6 +16,11 @@
 	* qrencode.[ch]:
 	  - QRencode_encodeStructuredInput() -> QRencode_encodeInputStructured()
 	    (for consistency with other QRencode_encode*Structured() functions)
+	* mask.c:
+	  - A code block never called has been eliminated.
+
+2008.04.14 Kentaro FUKUCHI 
+	* Version 3.0.0rc2 has been released.
 
 2008.04.20 Kentaro FUKUCHI 
 	* qrencode.h:
@@ -26,15 +38,18 @@
 	* Makefile.am:
 	  - man1_MANS has been moved into the "if BUILD_TOOLS - endif" block.
 
+2008.04.14 Kentaro FUKUCHI 
+	* Version 3.0.0rc1 has been released.
+
 2008.04.14 Kentaro FUKUCHI 
 	* Bumped version to 3.0.0.
 	* qrencode.[ch]:
 	  - QRcode_encodeInput() has changed the API. Previously it takes a
 	    QRinput, version and level, but now it takes only a QRinput, because
-		QRinput holds the version and level in it. From 3.0.0, you should set
-		them by calling QRinput_setVersion() and
-		QRinput_setErrorCorrectionLevel(), or use QRinput_new2() to
-		instantiate a QRinput object.
+	    QRinput holds the version and level in it. From 3.0.0, you should set
+	    them by calling QRinput_setVersion() and
+	    QRinput_setErrorCorrectionLevel(), or use QRinput_new2() to
+	    instantiate a QRinput object.
 
 2008.04.14 Kentaro FUKUCHI 
 	* qrspe.c:
@@ -60,7 +75,7 @@
 	* qrencode.h, qrinput.c:
 	  - QRinput_Struct_insertStructuredAppendHeaders() and
 	    QRinput_insertStructuredAppendHeader now returns error, when the input
-		contains too many structured inputs.
+	    contains too many structured inputs.
 	* qrencode.c:
 	  - QRcode_encodeInputToStructured() now returns NULL when
 	    QRinput_splitQRinputToStruct() fails.
@@ -126,7 +141,7 @@
 	  - Case-sensitive mode becomes now default mode.
 	  - Alphabet-Numeric mode now encodes only upper-case alphabet and
 	    numeric characters. If "-i" option is given, split.c converts
-		lower-case characters to upper-case characters at first.
+	    lower-case characters to upper-case characters at first.
 	* qrenc.c, tests/view_qrcode.c:
 	  - Case-sensitive mode becomes now default mode.
 	  - Option "-i" has been added.
diff --git a/Makefile.am b/Makefile.am
index 23713104b3..e613046b23 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,8 +10,7 @@ libqrencode_la_SOURCES = qrencode.c qrencode_inner.h \
 						 qrspec.c qrspec.h \
 						 rscode.c rscode.h \
 						 split.c split.h \
-						 mask.c mask.h \
-						 mqrspec.c mqrspec.h
+						 mask.c mask.h
 libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION)
 
 include_HEADERS = qrencode.h
@@ -20,7 +19,8 @@ pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libqrencode.pc
 
 EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \
-			 Makefile.am tests/Makefile.am qrencode.spec.in qrencode.1.in
+			 Makefile.am tests/Makefile.am qrencode.spec.in qrencode.1.in \
+			 Doxyfile tests/test_all.sh
 
 if BUILD_TOOLS
 bin_PROGRAMS = qrencode
diff --git a/NEWS b/NEWS
index a264da2acb..73911407a6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,11 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
-Version 3.0.0 (2008.4.x)
-------------------------
+Version 3.0.0 (2008.4.30)
+-------------------------
 Summary:
-* A significant API change was made that requires to modify user applications.
+* The interface of QRencode_encodeInput() has been changed. User applications
+  using it must be modified.
 * Structured append support has been added. (patches from Yusuke Mihara)
 * The "-S" option for structured append has been added to qrencode and
   view_qrcode.
-- 
cgit 0.0.5-2-1-g0f52


From b22ee29063d3dfeec7c2190eda202246defa98d3 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 30 Apr 2008 16:51:58 +0000
Subject:

---
 ChangeLog        | 4 ++++
 qrencode.spec.in | 1 +
 2 files changed, 5 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 029c1e803e..fb4b644992 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008.05.01 Kentaro FUKUCHI 
+	* qrencode.spec.in:
+	  - Added the man page to the files section.
+
 2008.04.30 Kentaro FUKUCHI 
 	* Version 3.0.0 has been released.
 
diff --git a/qrencode.spec.in b/qrencode.spec.in
index 5beb356076..ded17ad0b0 100644
--- a/qrencode.spec.in
+++ b/qrencode.spec.in
@@ -53,6 +53,7 @@ rm -rf $RPM_BUILD_ROOT
 %doc COPYING TODO ChangeLog NEWS README
 %{_libdir}/libqrencode.so.*
 %{_bindir}/qrencode
+%{_mandir}/man1/qrencode.1.gz
 
 %files devel
 %defattr(-,root,root,-)
-- 
cgit 0.0.5-2-1-g0f52


From 517f20d68af6c30cc0a943ad4d45d0f2e144b562 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 30 Apr 2008 16:55:26 +0000
Subject:

---
 Makefile.am | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index e613046b23..3cb8dc3c6e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,9 @@ libqrencode_la_SOURCES = qrencode.c qrencode_inner.h \
 						 qrspec.c qrspec.h \
 						 rscode.c rscode.h \
 						 split.c split.h \
-						 mask.c mask.h
+						 mask.c mask.h \
+						 mqrspec.c mqrspec.h
+
 libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION)
 
 include_HEADERS = qrencode.h
-- 
cgit 0.0.5-2-1-g0f52


From a19b9fb58b6ea8ab7933b2756cef7c9ca13ef835 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 8 May 2008 20:10:43 +0000
Subject: Synced to 3.0.1.

---
 ChangeLog        | 8 ++++++++
 NEWS             | 5 +++++
 qrenc.c          | 2 +-
 qrencode.spec.in | 2 ++
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index fb4b644992..9452b8838f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008.05.09 Kentaro FUKUCHI 
+	* qrenc.c:
+	  - Now qrencode writes an image file in binary mode for non-POSIX
+	    platform, such as MS-Windows. (bug report from Paul Janssens)
+	* Makefile.am:
+	  - tests/test_all.sh has been added.
+	* Version 3.0.1 has been released.
+
 2008.05.01 Kentaro FUKUCHI 
 	* qrencode.spec.in:
 	  - Added the man page to the files section.
diff --git a/NEWS b/NEWS
index 73911407a6..2be4f54abb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
+Version 3.0.1 (2008.5.9)
+------------------------
+* A bug fix for non-POSIX platform. (Thanks to Paul Janssens)
+* The RPM spec file now packages the man page correctly.
+
 Version 3.0.0 (2008.4.30)
 -------------------------
 Summary:
diff --git a/qrenc.c b/qrenc.c
index a3c11a64f1..c74dddbe2e 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -132,7 +132,7 @@ static int writePNG(QRcode *qrcode, const char *outfile)
 	if(outfile[0] == '-' && outfile[1] == '\0') {
 		fp = stdout;
 	} else {
-		fp = fopen(outfile, "w");
+		fp = fopen(outfile, "wb");
 		if(fp == NULL) {
 			fprintf(stderr, "Failed to create file: %s\n", outfile);
 			perror(NULL);
diff --git a/qrencode.spec.in b/qrencode.spec.in
index ded17ad0b0..f19021f1cf 100644
--- a/qrencode.spec.in
+++ b/qrencode.spec.in
@@ -62,6 +62,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/pkgconfig/libqrencode.pc
 
 %changelog
+* Fri May 01 2008 Kentaro Fukuchi  3.0.1-1
+- The man page has been packaged correctly.
 * Tue May 15 2007 Kentaro Fukuchi  1.0.2-2
 - Summary has been synchronized to README.
 * Thu May 09 2007 Katsumi Saito  1.0.2-1
-- 
cgit 0.0.5-2-1-g0f52


From deea28ad91a669e2a9643bf4ff4d320c0b58d57e Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 8 May 2008 20:22:53 +0000
Subject:

---
 ChangeLog         | 2 ++
 tests/test_all.sh | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9452b8838f..bde6e04160 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
 	    platform, such as MS-Windows. (bug report from Paul Janssens)
 	* Makefile.am:
 	  - tests/test_all.sh has been added.
+	* tests/test_all.sh:
+	  - Now it exits immediately if any test fails.
 	* Version 3.0.1 has been released.
 
 2008.05.01 Kentaro FUKUCHI 
diff --git a/tests/test_all.sh b/tests/test_all.sh
index eddc87c777..c71f28d80a 100755
--- a/tests/test_all.sh
+++ b/tests/test_all.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -e
 ./test_bitstream
 ./test_estimatebit
 ./test_qrencode
-- 
cgit 0.0.5-2-1-g0f52


From f8898ad7f20579831bf15230406eda805254e8b7 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Tue, 13 May 2008 17:33:38 +0000
Subject:

---
 ChangeLog             |  5 +++++
 bitstream.c           | 10 +++++-----
 mqrspec.c             |  4 ++--
 qrinput.c             | 14 +++++++-------
 rscode.c              |  6 +++---
 tests/common.h        |  2 +-
 tests/prof_qrencode.c |  4 ++--
 tests/test_monkey.c   |  4 ++--
 tests/test_mqrspec.c  |  4 ++--
 tests/test_qrencode.c |  8 ++++----
 tests/test_qrinput.c  | 18 +++++++-----------
 tests/test_qrspec.c   | 16 ++++++++--------
 tests/test_rs.c       |  2 +-
 13 files changed, 49 insertions(+), 48 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bde6e04160..b35c70f2ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008.05.14 Kentaro FUKUCHI 
+	* various files:
+	  - Some compile-time warnings/erros with g++ have been fixed.
+	    (Thanks to wangsai)
+
 2008.05.09 Kentaro FUKUCHI 
 	* qrenc.c:
 	  - Now qrencode writes an image file in binary mode for non-POSIX
diff --git a/bitstream.c b/bitstream.c
index 93e88dc5f4..029ceac9be 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -92,7 +92,7 @@ static BitStream *BitStream_newFromBytes(int size, unsigned char *data)
 void BitStream_append(BitStream *bstream, BitStream *arg)
 {
 	int l1, l2;
-	char *new;
+	char *data;
 
 	if(arg == NULL || arg->data == NULL) {
 		return;
@@ -104,12 +104,12 @@ void BitStream_append(BitStream *bstream, BitStream *arg)
 
 	l1 = strlen(bstream->data);
 	l2 = strlen(arg->data);
-	new = (char *)malloc(l1 + l2 + 1);
-	strcpy(new, bstream->data);
-	strcat(new, arg->data);
+	data = (char *)malloc(l1 + l2 + 1);
+	strcpy(data, bstream->data);
+	strcat(data, arg->data);
 
 	free(bstream->data);
-	bstream->data = new;
+	bstream->data = data;
 }
 
 void BitStream_appendNum(BitStream *bstream, int bits, unsigned int num)
diff --git a/mqrspec.c b/mqrspec.c
index 6c2c939af4..79fb563e8c 100644
--- a/mqrspec.c
+++ b/mqrspec.c
@@ -128,7 +128,7 @@ int *MQRspec_getEccSpec(int version, QRecLevel level)
  *****************************************************************************/
 
 /* See calcFormatInfo in tests/test_mqrspec.c */
-static const unsigned int const formatInfo[4][8] = {
+static const unsigned int formatInfo[4][8] = {
 	{0x4445, 0x55ae, 0x6793, 0x7678, 0x06de, 0x1735, 0x2508, 0x34e3},
 	{0x4172, 0x5099, 0x62a4, 0x734f, 0x03e9, 0x1202, 0x203f, 0x31d4},
 	{0x4e2b, 0x5fc0, 0x6dfd, 0x7c16, 0x0cb0, 0x1d5b, 0x2f66, 0x3e8d},
@@ -136,7 +136,7 @@ static const unsigned int const formatInfo[4][8] = {
 };
 
 /* See Table 10 of Appendix 1. (pp.115) */
-static const int const typeTable[MQRSPEC_VERSION_MAX + 1][3] = {
+static const int typeTable[MQRSPEC_VERSION_MAX + 1][3] = {
 	{-1, -1, -1},
 	{ 0, -1, -1},
 	{ 1,  2, -1},
diff --git a/qrinput.c b/qrinput.c
index 91f5f172f2..f5d7d9051d 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -659,19 +659,19 @@ int QRinput_estimateBitStreamSize(QRinput *input, int version)
 static int QRinput_estimateVersion(QRinput *input)
 {
 	int bits;
-	int new, prev;
+	int version, prev;
 
-	new = 0;
+	version = 0;
 	do {
-		prev = new;
+		prev = version;
 		bits = QRinput_estimateBitStreamSize(input, prev);
-		new = QRspec_getMinimumVersion((bits + 7) / 8, input->level);
-		if (new < 0) {
+		version = QRspec_getMinimumVersion((bits + 7) / 8, input->level);
+		if (version < 0) {
 			return -1;
 		}
-	} while (new > prev);
+	} while (version > prev);
 
-	return new;
+	return version;
 }
 
 /**
diff --git a/rscode.c b/rscode.c
index 8f9f5dc4ad..7eafe42086 100644
--- a/rscode.c
+++ b/rscode.c
@@ -95,14 +95,14 @@ static RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots,
  * Copyright 2004 Phil Karn, KA9Q
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
  */
-#undef NULL
-#define NULL ((void *)0)
+//#undef NULL
+//#define NULL ((void *)0)
 
   int i, j, sr,root,iprim;
 
   rs = NULL;
   /* Check parameter ranges */
-  if(symsize < 0 || symsize > 8*sizeof(data_t)){
+  if(symsize < 0 || symsize > (int)8*sizeof(data_t)){
     goto done;
   }
 
diff --git a/tests/common.h b/tests/common.h
index 5b6312aea8..aa6c83f4da 100644
--- a/tests/common.h
+++ b/tests/common.h
@@ -20,7 +20,7 @@ static int assertionNum = 0;
 static const char *testName = NULL;
 static const char *testFunc = NULL;
 char levelChar[4] = {'L', 'M', 'Q', 'H'};
-char *modeStr[5] = {"nm", "an", "8", "kj", "st"};
+const char *modeStr[5] = {"nm", "an", "8", "kj", "st"};
 
 void printQRinput(QRinput *input)
 {
diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c
index c938cffa9c..c82535ceef 100644
--- a/tests/prof_qrencode.c
+++ b/tests/prof_qrencode.c
@@ -25,7 +25,7 @@ void prof_ver1to10(void)
 	QRcode *code;
 	int i;
 	int version;
-	static char *data = "This is test.";
+	static const char *data = "This is test.";
 
 	timerStart("Version 1 - 10 (500 symbols for each)");
 	for(i=0; i<500; i++) {
@@ -42,7 +42,7 @@ void prof_ver31to40(void)
 	QRcode *code;
 	int i;
 	int version;
-	static char *data = "This is test.";
+	static const char *data = "This is test.";
 
 	timerStart("Version 31 - 40 (50 symbols for each)");
 	for(i=0; i<50; i++) {
diff --git a/tests/test_monkey.c b/tests/test_monkey.c
index 4e0d6fbd59..ece7061ff6 100644
--- a/tests/test_monkey.c
+++ b/tests/test_monkey.c
@@ -10,7 +10,7 @@
 static char data[MAX_LENGTH];
 static char check[MAX_LENGTH];
 
-static char *AN = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
+static const char *AN = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
 
 #define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0))
 
@@ -201,7 +201,7 @@ void test_split_structure(void)
 	int len, c, i;
 
 	version = (int)drand(40) + 1;
-	level = (int)drand(4);
+	level = (QRecLevel)drand(4);
 
 	len = fill8bitData();
 
diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c
index 5dc43ae51c..665b940354 100644
--- a/tests/test_mqrspec.c
+++ b/tests/test_mqrspec.c
@@ -81,7 +81,7 @@ void test_format(void)
 	for(version=1; version<4; version++) {
 		for(l=0; l<3; l++) {
 			for(mask=0; mask<4; mask++) {
-				format = MQRspec_getFormatInfo(mask, version, l);
+				format = MQRspec_getFormatInfo(mask, version, (QRecLevel)l);
 				type = typeTable[version - 1][l];
 				if(type == -1) {
 					if(format != 0) {
@@ -135,7 +135,7 @@ void test_dataLength(void)
 	testStart("Test dataLength");
 	for(v=0; v<4; v++) {
 		for(l=0; l<3; l++) {
-			bits = MQRspec_getDataLength(v+1, l);
+			bits = MQRspec_getDataLength(v+1, (QRecLevel)l);
 			if(bits != datalen[v][l]) {
 				printf("Error in version %d, level %d.\n", v, l);
 				err++;
diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index 868d835119..5ff4c3b89f 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -537,13 +537,13 @@ void test_invalid_input(void)
 	if(code != NULL) QRcode_free(code);
 
 	input->version = 1;
-	input->level = QR_ECLEVEL_H + 1;
+	input->level = (QRecLevel)(QR_ECLEVEL_H + 1);
 	code = QRcode_encodeInput(input);
 	assert_null(code, "invalid level(H+1) access was not checked.\n");
 	if(code != NULL) QRcode_free(code);
 
 	input->version = 1;
-	input->level = -1;
+	input->level = (QRecLevel)-1;
 	code = QRcode_encodeInput(input);
 	assert_null(code, "invalid level(-1) access was not checked.\n");
 	if(code != NULL) QRcode_free(code);
@@ -556,7 +556,7 @@ void test_invalid_input(void)
 void test_struct_semilong(void)
 {
 	QRcode_List *codes, *list;
-	char *str = "asdfasdfasdfasdfasdfASDFASDASDFASDFAsdfasdfasdfasdASDFASDFADSADadsfasdf";
+	const char *str = "asdfasdfasdfasdfasdfASDFASDASDFASDFAsdfasdfasdfasdASDFASDFADSADadsfasdf";
 	int num, size;
 
 	testStart("Testing semi-long structured-append symbols");
@@ -590,7 +590,7 @@ void test_struct_semilong(void)
 void test_struct_example(void)
 {
 	QRcode_List *codes, *list;
-	char *str = "an example of four Structured Append symbols,";
+	const char *str = "an example of four Structured Append symbols,";
 	int num;
 
 	testStart("Testing the example of structured-append symbols");
diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c
index 867116fb9f..5c8bc0c632 100644
--- a/tests/test_qrinput.c
+++ b/tests/test_qrinput.c
@@ -425,11 +425,7 @@ void test_struct_split_example(void)
 	QRinput_Struct *s;
 	QRinput_InputList *e;
 	QRinput_List *l;
-	char *str[4] = {
-		"an example ",
-		"of four Str",
-		"uctured Appe",
-		"nd symbols,"};
+	const char *str[4] = { "an example ", "of four Str", "uctured Appe", "nd symbols,"};
 	int i;
 	BitStream *bstream;
 
@@ -505,7 +501,7 @@ void test_splitentry(void)
 {
 	QRinput *i1, *i2;
 	QRinput_List *e;
-	char *str = "abcdefghij";
+	const char *str = "abcdefghij";
 	int size1, size2, i;
 	unsigned char *d1, *d2;
 
@@ -564,7 +560,7 @@ void test_splitentry2(void)
 {
 	QRinput *i1, *i2;
 	QRinput_List *e;
-	char *str = "abcdefghij";
+	const char *str = "abcdefghij";
 	int size1, size2, i;
 	unsigned char *d1, *d2;
 
@@ -626,7 +622,7 @@ void test_splitentry3(void)
 	QRinput_Struct *s;
 	QRinput_List *e00, *e01, *e10, *e11;
 	QRinput_InputList *list;
-	char *str = "abcdefghijklmno";
+	const char *str = "abcdefghijklmno";
 
 	testStart("Testing QRinput_splitEntry. (does not split an entry)");
 	/* version 1 symbol contains 152 bit (19 byte) data.
@@ -661,8 +657,8 @@ void test_parity(void)
 {
 	QRinput *input;
 	QRinput_Struct *s;
-	char *text = "an example of four Structured Append symbols,";
-	char *str[4] = {
+	const char *text = "an example of four Structured Append symbols,";
+	const char *str[4] = {
 		"an example ",
 		"of four Str",
 		"uctured Appe",
@@ -694,7 +690,7 @@ void test_parity2(void)
 {
 	QRinput *input;
 	QRinput_Struct *s;
-	char *text = "an example of four Structured Append symbols,";
+	const char *text = "an example of four Structured Append symbols,";
 	unsigned char p1, p2;
 	int i, len;
 
diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c
index bab107339e..61dab54bb2 100644
--- a/tests/test_qrspec.c
+++ b/tests/test_qrspec.c
@@ -13,7 +13,7 @@ void print_eccTable(void)
 	for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
 		printf("Version %2d\n", i);
 		for(j=0; j<4; j++) {
-			bl = QRspec_getEccSpec(i, j);
+			bl = QRspec_getEccSpec(i, (QRecLevel)j);
 			data = bl[0] * bl[1] + bl[3] * bl[4];
 			ecc  = bl[0] * bl[2] + bl[3] * bl[5];
 			printf("%3d\t", ecc);
@@ -39,15 +39,15 @@ void test_eccTable(void)
 	testStart("Checking ECC table.");
 	for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
 		for(j=0; j<4; j++) {
-			bl = QRspec_getEccSpec(i, j);
+			bl = QRspec_getEccSpec(i, (QRecLevel)j);
 			data = bl[0] * bl[1] + bl[3] * bl[4];
 			ecc  = bl[0] * bl[2] + bl[3] * bl[5];
-			if(data + ecc != QRspec_getDataLength(i, j) + QRspec_getECCLength(i, j)) {
+			if(data + ecc != QRspec_getDataLength(i, (QRecLevel)j) + QRspec_getECCLength(i, (QRecLevel)j)) {
 				printf("Error in version %d, level %d: invalid size\n", i, j);
 				printf("%d %d %d %d %d %d\n", bl[0], bl[1], bl[2], bl[3], bl[4], bl[5]);
 				err++;
 			}
-			if(ecc != QRspec_getECCLength(i, j)) {
+			if(ecc != QRspec_getECCLength(i, (QRecLevel)j)) {
 				printf("Error in version %d, level %d: invalid data\n", i, j);
 				printf("%d %d %d %d %d %d\n", bl[0], bl[1], bl[2], bl[3], bl[4], bl[5]);
 				err++;
@@ -79,7 +79,7 @@ void test_eccTable2(void)
 	testStart("Checking ECC table(2)");
 	for(i=0; i<7; i++) {
 		err = 0;
-		bl = QRspec_getEccSpec(correct[i][0], correct[i][1]);
+		bl = QRspec_getEccSpec(correct[i][0], (QRecLevel)correct[i][1]);
 		idx = correct[i][2] * 3;
 		if(bl[idx] != correct[i][3]) err++;
 		if(bl[idx+1] + bl[idx+2] != correct[i][4]) err++;
@@ -183,7 +183,7 @@ void test_verpat(void)
 
 	for(version=7; version <= QRSPEC_VERSION_MAX; version++) {
 		pattern = QRspec_getVersionPattern(version);
-		if((pattern >> 12) != version) {
+		if((pattern >> 12) != (unsigned int)version) {
 			printf("Error in version %d.\n", version);
 			err++;
 			continue;
@@ -266,9 +266,9 @@ void test_format(void)
 	testStart("Format info test");
 	for(i=0; i<4; i++) {
 		for(j=0; j<8; j++) {
-			format = calcFormatInfo(j, i);
+			format = calcFormatInfo(j, (QRecLevel)i);
 //			printf("0x%04x, ", format);
-			if(format != QRspec_getFormatInfo(j, i)) {
+			if(format != QRspec_getFormatInfo(j, (QRecLevel)i)) {
 				printf("Level %d, mask %x\n", i, j);
 				err++;
 			}
diff --git a/tests/test_rs.c b/tests/test_rs.c
index f4cf1e609e..81a36513ec 100644
--- a/tests/test_rs.c
+++ b/tests/test_rs.c
@@ -9,7 +9,7 @@ void test_rscode1(void)
 {
 	QRinput *stream;
 	QRRawCode *code;
-	static char str[8] = "01234567";
+	static const char str[9] = "01234567";
 	static unsigned char correct[26] = {
 		0x10, 0x20, 0x0c, 0x56, 0x61, 0x80, 0xec, 0x11, 0xec, 0x11, 0xec, 0x11,
 		0xec, 0x11, 0xec, 0x11, 0xa5, 0x24, 0xd4, 0xc1, 0xed, 0x36, 0xc7, 0x87,
-- 
cgit 0.0.5-2-1-g0f52


From 49d90cbbd111fc8119a422fb693e8aeeeb2fae2a Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sat, 17 May 2008 22:19:24 +0000
Subject:

---
 ChangeLog           |  9 +++++++++
 Makefile.am         |  6 +++++-
 NEWS                |  5 +++++
 configure.ac        | 29 ++++++++++++++++++++---------
 qrencode.spec.in    |  8 ++++----
 qrspec.c            | 14 +++++++-------
 tests/view_qrcode.c |  6 +++---
 7 files changed, 53 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b35c70f2ef..4d645cb925 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008.05.18 Kentaro FUKUCHI 
+	* qrspec.c:
+	  - The bit order of "Version information" has been corrected. (Thanks to
+	    Paul Janssesn)
+	* configure.ac, Makefile.am:
+	  - The "--without-tests" has been added to the configure script.
+	* qrencode.spec.in:
+	  - Uses "--without-tests".
+
 2008.05.14 Kentaro FUKUCHI 
 	* various files:
 	  - Some compile-time warnings/erros with g++ have been fixed.
diff --git a/Makefile.am b/Makefile.am
index 3cb8dc3c6e..2547f8394b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,10 @@
 AUTOMAKE_OPTIONS = foreign
 
-SUBDIRS = . tests
+SUBDIRS = .
+
+if BUILD_TESTS
+SUBDIRS += tests
+endif
 
 lib_LTLIBRARIES = libqrencode.la
 
diff --git a/NEWS b/NEWS
index 2be4f54abb..2ececfee35 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
+Version 3.0.2 (2008.5.x)
+------------------------
+* Some compile-time warnings/erros with g++ have been fixed. (Thanks to wangsai)
+* The bit order of "Version information" has been corrected.
+
 Version 3.0.1 (2008.5.9)
 ------------------------
 * A bug fix for non-POSIX platform. (Thanks to Paul Janssens)
diff --git a/configure.ac b/configure.ac
index 9acfeb7a5e..1e7c1491b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_INIT(QRencode)
 
 MAJOR_VERSION=3
 MINOR_VERSION=0
-MICRO_VERSION=0
+MICRO_VERSION=2
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 AC_SUBST(MAJOR_VERSION)
 AC_SUBST(MINOR_VERSION)
@@ -27,28 +27,39 @@ AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 PKG_PROG_PKG_CONFIG
 
-SDL_REQUIRED_VERSION=1.2.0
-AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.]))
-AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ])
-
-CFLAGS="-Wall $CFLAGS"
-
 AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1])
 
+dnl --with-tools
 AC_ARG_WITH([tools], [AC_HELP_STRING([--with-tools], [build utility tools [default=yes]])],
  [build_tools=$withval], [build_tools=yes])
-
+AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ])
 if test x$build_tools = xyes ; then
 	PKG_CHECK_MODULES(png, "libpng12")
 fi
-AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ])
 
+dnl --with-tests
+AC_ARG_WITH([tests], [AC_HELP_STRING([--with-tests], [build tests [default=yes]])],
+ [build_tests=$withval], [build_tests=yes])
+AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes" ])
+
+if test x$build_tests = xyes ; then
+	SDL_REQUIRED_VERSION=1.2.0
+	AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.]))
+fi
+AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ])
+
+
+dnl --enable-gprof
 AC_ARG_ENABLE([gprof], [AC_HELP_STRING([--enable-gprof], [generate extra code to write profile information suitable for gprof [default=no]])],
  [], [enable_gprof=no])
 
+dnl --enable-gcov
 AC_ARG_ENABLE([gcov], [AC_HELP_STRING([--enable-gcov], [generate extra code to write coverage information suitable for gcov [default=no]])],
  [], [enable_gcov=no])
 
+dnl set CFLAGS
+CFLAGS="-Wall $CFLAGS"
+
 if test $enable_gprof = yes; then
 	CFLAGS="$CFLAGS -g -pg"
 fi
diff --git a/qrencode.spec.in b/qrencode.spec.in
index f19021f1cf..f03947ade6 100644
--- a/qrencode.spec.in
+++ b/qrencode.spec.in
@@ -7,13 +7,13 @@ Release:        %{rel}%{?dist}
 Summary:        Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D symbology that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness.
 
 Group:          System Environment/Libraries
-License:        LGPL
+License:        LGPLv2+
 URL:            http://megaui.net/fukuchi/works/qrencode/
 Source0:        http://megaui.net/fukuchi/works/qrencode/%{name}-%{version}.tar.gz
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 %description
-Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Structured Append Feature, Micro QR Code, QR Code model 1.
+Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Micro QR Code, QR Code model 1.
 
 %package        devel
 Summary:        Development files for libqrencode
@@ -21,7 +21,7 @@ Group:          Development/Libraries
 Requires:       %{name} = %{version}-%{release}
 
 %description    devel
-Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Structured Append Feature, Micro QR Code, QR Code model 1.
+Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Micro QR Code, QR Code model 1.
 
 This package contains development files for libqrencode.
 
@@ -30,7 +30,7 @@ This package contains development files for libqrencode.
 
 
 %build
-%configure
+%configure --without-tests
 make %{?_smp_mflags}
 
 
diff --git a/qrspec.c b/qrspec.c
index 8f9b257bfa..b32b3b8cad 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -475,7 +475,7 @@ static unsigned char *QRspec_createFrame(int version)
 	unsigned char *frame, *p, *q;
 	int width;
 	int x, y;
-	unsigned int verinfo, mask;
+	unsigned int verinfo, v;
 	QRspec_Alignment *alignment;
 
 	width = qrspecCapacity[version].width;
@@ -534,20 +534,20 @@ static unsigned char *QRspec_createFrame(int version)
 		verinfo = QRspec_getVersionPattern(version);
 
 		p = frame + width * (width - 11);
-		mask = 0x20000;
+		v = verinfo;
 		for(x=0; x<6; x++) {
 			for(y=0; y<3; y++) {
-				p[width * y + x] = 0x88 | ((mask & verinfo) != 0);
-				mask = mask >> 1;
+				p[width * y + x] = 0x88 | (v & 1);
+				v = v >> 1;
 			}
 		}
 
 		p = frame + width - 11;
-		mask = 0x20000;
+		v = verinfo;
 		for(y=0; y<6; y++) {
 			for(x=0; x<3; x++) {
-				p[x] = 0x88 | ((mask & verinfo) != 0);
-				mask = mask >> 1;
+				p[x] = 0x88 | (v & 1);
+				v = v >> 1;
 			}
 			p += width;
 		}
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 8b4b619bfa..0cf71895a7 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -191,12 +191,12 @@ void draw_structuredQRcodeFromText(int argc, char **argv, int mask)
 			ret = Split_splitStringToQRinput(argv[i], input, hint, casesensitive);
 		}
 		if(ret < 0) {
-			perror("Encoding the input string:");
+			perror("Encoding the input string");
 			exit(1);
 		}
 		ret = QRinput_Struct_appendInput(s, input);
 		if(ret < 0) {
-			perror("Encoding the input string:");
+			perror("Encoding the input string");
 			exit(1);
 		}
 	}
@@ -333,7 +333,7 @@ void view_simple(const char *str)
 		ret = Split_splitStringToQRinput(str, input, hint, casesensitive);
 	}
 	if(ret < 0) {
-		perror("Encoding the input string:");
+		perror("Encoding the input string");
 		exit(1);
 	}
 
-- 
cgit 0.0.5-2-1-g0f52


From 3ee90bb4cfefb42fd8aa617590ceb9ff938b3fe0 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sat, 17 May 2008 22:21:31 +0000
Subject: Merged to 3.0.2.

---
 TODO     | 2 +-
 mask.c   | 4 ----
 rscode.c | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/TODO b/TODO
index 7bfdc1c93d..8564ee9a4b 100644
--- a/TODO
+++ b/TODO
@@ -3,7 +3,7 @@ Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe, but
 most of qrencode functions are thread unsafe because of them.
 
 This package contains
-*.c and *.h files (total):  8012 lines, 197484 bytes.
+*.c and *.h files (total):  8077 lines, 198863 bytes.
 configure script         : 22539 lines, 725612 bytes.
 It's absolutely crazy.
 
diff --git a/mask.c b/mask.c
index d85148ab7c..ffe74ec81f 100644
--- a/mask.c
+++ b/mask.c
@@ -234,10 +234,6 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
 		blacks = 100 * blacks / (width * width);
 		demerit = (abs(blacks - 50) / 5) * N4;
 //		n4 = demerit;
-		if(demerit > minDemerit) {
-			free(mask);
-			continue;
-		}
 		demerit += Mask_evaluateSymbol(width, mask);
 //		printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit);
 		if(demerit < minDemerit) {
diff --git a/rscode.c b/rscode.c
index 7eafe42086..d0cdd6624e 100644
--- a/rscode.c
+++ b/rscode.c
@@ -102,7 +102,7 @@ static RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots,
 
   rs = NULL;
   /* Check parameter ranges */
-  if(symsize < 0 || symsize > (int)8*sizeof(data_t)){
+  if(symsize < 0 || symsize > (int)(8*sizeof(data_t))){
     goto done;
   }
 
-- 
cgit 0.0.5-2-1-g0f52


From 376aac3060be777b49eb84e0ee197c33636cba73 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sat, 17 May 2008 23:09:54 +0000
Subject:

---
 ChangeLog | 21 +++++++++++----------
 NEWS      |  9 ++++++---
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4d645cb925..9ce122e56b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,12 @@
 2008.05.18 Kentaro FUKUCHI 
 	* qrspec.c:
-	  - The bit order of "Version information" has been corrected. (Thanks to
-	    Paul Janssesn)
+	  - The bit order of "Version information" has been corrected.
+	    (Thanks to Paul Janssesn)
 	* configure.ac, Makefile.am:
 	  - The "--without-tests" has been added to the configure script.
 	* qrencode.spec.in:
 	  - Uses "--without-tests".
+	* Version 3.0.2 has been released.
 
 2008.05.14 Kentaro FUKUCHI 
 	* various files:
@@ -52,8 +53,8 @@
 
 2008.04.20 Kentaro FUKUCHI 
 	* qrencode.h:
-	  - QR_MODE_NUL has been added to QRencodeMode. Basically it is used only
-	    by Split_identifyMode().
+	  - QR_MODE_NUL has been added to QRencodeMode. Basically it is used
+	    only by Split_identifyMode().
 	* qrinput.[ch], split.c]:
 	  - QRinput_identifyMode() has been moved to split.c, changed to static
 	    and now needs a hint.
@@ -74,8 +75,8 @@
 	* qrencode.[ch]:
 	  - QRcode_encodeInput() has changed the API. Previously it takes a
 	    QRinput, version and level, but now it takes only a QRinput, because
-	    QRinput holds the version and level in it. From 3.0.0, you should set
-	    them by calling QRinput_setVersion() and
+	    QRinput holds the version and level in it. From 3.0.0, you should
+	    set them by calling QRinput_setVersion() and
 	    QRinput_setErrorCorrectionLevel(), or use QRinput_new2() to
 	    instantiate a QRinput object.
 
@@ -102,8 +103,8 @@
 2008.04.09 Kentaro FUKUCHI 
 	* qrencode.h, qrinput.c:
 	  - QRinput_Struct_insertStructuredAppendHeaders() and
-	    QRinput_insertStructuredAppendHeader now returns error, when the input
-	    contains too many structured inputs.
+	    QRinput_insertStructuredAppendHeader now returns error, when the
+	    input contains too many structured inputs.
 	* qrencode.c:
 	  - QRcode_encodeInputToStructured() now returns NULL when
 	    QRinput_splitQRinputToStruct() fails.
@@ -112,8 +113,8 @@
 
 2008.04.08 Kentaro FUKUCHI 
 	* qrinput.c:
-	  - Fixed a bug in QRinput_estimateBitStreamSizeOfEntry(). It could over-
-	    estimate the size.
+	  - Fixed a bug in QRinput_estimateBitStreamSizeOfEntry(). It could
+	    overestimate the size.
 	* rscode.c:
 	  - Optimized the order of the parameters equality test in init_rs().
 	* qrspec.c, qrspec.h:
diff --git a/NEWS b/NEWS
index 2ececfee35..ad770fc6e1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,13 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
-Version 3.0.2 (2008.5.x)
-------------------------
-* Some compile-time warnings/erros with g++ have been fixed. (Thanks to wangsai)
+Version 3.0.2 (2008.5.18)
+-------------------------
+* Some compile-time warnings/erros with g++ have been fixed.
+  (Thanks to wangsai)
 * The bit order of "Version information" has been corrected.
+  Symbols greater than version 6 were affected. (Thanks to Paul Janssesn)
+* The "--without-tests" option has been added to the configure script.
 
 Version 3.0.1 (2008.5.9)
 ------------------------
-- 
cgit 0.0.5-2-1-g0f52


From cc64d18ffbc5ae0a7d7aa3e253351fa6d88b8d3f Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 26 May 2008 05:15:40 +0000
Subject: getopt_long_only has been replaced with getopt_long.

---
 qrenc.c | 84 +++++++++++++++++++++++++++++++----------------------------------
 1 file changed, 40 insertions(+), 44 deletions(-)

diff --git a/qrenc.c b/qrenc.c
index c74dddbe2e..5b7e0b9b1c 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -35,40 +35,31 @@ static int structured = 0;
 static QRecLevel level = QR_ECLEVEL_L;
 static QRencodeMode hint = QR_MODE_8;
 
-enum {
-	O_HELP,
-	O_OUTPUT,
-	O_SIZE,
-	O_VERSION,
-	O_LEVEL,
-	O_MARGIN,
-	O_KANJI,
-	O_CASE,
-	O_IGNORECASE,
-	O_8BIT,
-	O_STRUCTURED,
-};
-
 static const struct option options[] = {
-	{"h", no_argument      , NULL, O_HELP},
-	{"o", required_argument, NULL, O_OUTPUT},
-	{"l", required_argument, NULL, O_LEVEL},
-	{"s", required_argument, NULL, O_SIZE},
-	{"v", required_argument, NULL, O_VERSION},
-	{"m", required_argument, NULL, O_MARGIN},
-	{"k", no_argument      , NULL, O_KANJI},
-	{"c", no_argument      , NULL, O_CASE},
-	{"i", no_argument      , NULL, O_IGNORECASE},
-	{"8", no_argument      , NULL, O_8BIT},
-	{"S", no_argument      , NULL, O_STRUCTURED},
+	{"help"         , no_argument      , NULL, 'h'},
+	{"output"       , required_argument, NULL, 'o'},
+	{"level"        , required_argument, NULL, 'l'},
+	{"size"         , required_argument, NULL, 's'},
+	{"symversion"   , required_argument, NULL, 'v'},
+	{"margin"       , required_argument, NULL, 'm'},
+	{"structured"   , no_argument      , NULL, 'S'},
+	{"kanji"        , no_argument      , NULL, 'k'},
+	{"casesensitive", no_argument      , NULL, 'c'},
+	{"ignorecase"   , no_argument      , NULL, 'i'},
+	{"8bit"         , no_argument      , NULL, '8'},
+	{"version"      , no_argument      , NULL, 'V'},
 	{NULL, 0, NULL, 0}
 };
 
-static void usage(void)
+static char *optstring = "ho:l:s:v:m:Skci8V";
+
+static void usage(int help)
 {
 	fprintf(stderr,
 "qrencode version %s\n"
-"Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi\n"
+"Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi\n", VERSION);
+	if(help) {
+		fprintf(stderr,
 "Usage: qrencode [OPTION]... [STRING]\n"
 "Encode input data in a QR Code and save as a PNG image.\n\n"
 "  -h           display this message.\n"
@@ -87,8 +78,9 @@ static void usage(void)
 "  -i           ignore case distinctions and use only upper-case characters.\n"
 "  -8           encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
-"               standard input.\n",
-	VERSION);
+"               standard input.\n"
+		);
+	}
 }
 
 #define MAX_DATA_SIZE (7090 * 16) /* from the specification */
@@ -308,30 +300,30 @@ int main(int argc, char **argv)
 	char *outfile = NULL;
 	char *intext = NULL;
 
-	while((opt = getopt_long_only(argc, argv, "", options, NULL)) != -1) {
+	while((opt = getopt_long(argc, argv, optstring, options, NULL)) != -1) {
 		switch(opt) {
-			case O_HELP:
-				usage();
+			case 'h':
+				usage(1);
 				exit(0);
 				break;
-			case O_OUTPUT:
+			case 'o':
 				outfile = optarg;
 				break;
-			case O_SIZE:
+			case 's':
 				size = atoi(optarg);
 				if(size <= 0) {
 					fprintf(stderr, "Invalid size: %d\n", size);
 					exit(1);
 				}
 				break;
-			case O_VERSION:
+			case 'v':
 				version = atoi(optarg);
 				if(version < 0) {
 					fprintf(stderr, "Invalid version: %d\n", version);
 					exit(1);
 				}
 				break;
-			case O_LEVEL:
+			case 'l':
 				switch(*optarg) {
 					case 'l':
 					case 'L':
@@ -355,36 +347,40 @@ int main(int argc, char **argv)
 						break;
 				}
 				break;
-			case O_MARGIN:
+			case 'm':
 				margin = atoi(optarg);
 				if(margin < 0) {
 					fprintf(stderr, "Invalid margin: %d\n", margin);
 					exit(1);
 				}
 				break;
-			case O_STRUCTURED:
+			case 'S':
 				structured = 1;
-			case O_KANJI:
+			case 'k':
 				hint = QR_MODE_KANJI;
 				break;
-			case O_CASE:
+			case 'c':
 				casesensitive = 1;
 				break;
-			case O_IGNORECASE:
+			case 'i':
 				casesensitive = 0;
 				break;
-			case O_8BIT:
+			case '8':
 				eightbit = 1;
 				break;
+			case 'V':
+				usage(0);
+				exit(0);
+				break;
 			default:
-				usage();
+				usage(1);
 				exit(1);
 				break;
 		}
 	}
 
 	if(argc == 1) {
-		usage();
+		usage(1);
 		exit(0);
 	}
 
-- 
cgit 0.0.5-2-1-g0f52


From 3775550eefb30ef7e3c58733e0018c3fd6ee3a8f Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 26 May 2008 07:57:45 +0000
Subject:

---
 ChangeLog | 6 ++++++
 NEWS      | 6 ++++++
 README    | 3 ++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9ce122e56b..ac0dfd0953 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008.05.26 Kentaro FUKUCHI 
+	* qrenc.c:
+	  - getopt_long_only() has been replaced with getopt_long() which is
+	    widely available. (Thanks to Gavan Fantom)
+	  - Now it accepts long options.
+
 2008.05.18 Kentaro FUKUCHI 
 	* qrspec.c:
 	  - The bit order of "Version information" has been corrected.
diff --git a/NEWS b/NEWS
index ad770fc6e1..2bb8fd4520 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
+Version 3.0.3 (2008.5.x)
+-------------------------
+* Portability enhancement. (Thanks to Gavan Fantom)
+* The command line tool "qrencode" now accepts long options. See the man page
+  or give "--help" option to it.
+
 Version 3.0.2 (2008.5.18)
 -------------------------
 * Some compile-time warnings/erros with g++ have been fixed.
diff --git a/README b/README
index 9af4ee027c..37a7ae518d 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-libqrencode 3.0.0 - QR Code encoding library
+libqrencode 3.0.3 - QR Code encoding library
 
 GENERAL INFORMATION
 ===================
@@ -112,3 +112,4 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
 NANKI Haruo       - improved lower-case characteres encoding
 Philippe Delcroix - improved mask evaluation
 Yusuke Mihara     - structured-append support
+Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom - bug report / suggestion
-- 
cgit 0.0.5-2-1-g0f52


From ba23400303a09994682b7eec63f7ef264817816a Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 2 Jun 2008 17:51:04 +0000
Subject: Merged to 3.0.3.

---
 ChangeLog           |  15 ++++++-
 NEWS                |  23 ++++++++--
 autogen.sh          |   2 +
 configure.ac        |   3 +-
 qrenc.c             |  60 +++++++++++++++++++++----
 qrencode.1.in       |  34 ++++++++++-----
 tests/view_qrcode.c | 123 +++++++++++++++++++++++++++++++++-------------------
 7 files changed, 189 insertions(+), 71 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ac0dfd0953..0acb1c587e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,21 @@
-2008.05.26 Kentaro FUKUCHI 
+2008.06.03 Kentaro FUKUCHI 
+	* Merged to the main trunk.
+
+2008.06.01 Kentaro FUKUCHI 
 	* qrenc.c:
+	  - Now it does not show the full usage when unrecognized options are
+	    given.
+	  - When "--help" is given, it displays the long usage.
+	* Version 3.0.3 has been released.
+
+2008.05.26 Kentaro FUKUCHI 
+	* qrenc.c, tests/view_qrcode.c:
 	  - getopt_long_only() has been replaced with getopt_long() which is
 	    widely available. (Thanks to Gavan Fantom)
 	  - Now it accepts long options.
+	* qrencode.1.in:
+	  - followed the above changes.
+	* Bumped version to 3.0.3.
 
 2008.05.18 Kentaro FUKUCHI 
 	* qrspec.c:
diff --git a/NEWS b/NEWS
index 2bb8fd4520..bd3d065df4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,27 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
-Version 3.0.3 (2008.5.x)
--------------------------
+Version 3.0.3 (2008.6.1)
+------------------------
 * Portability enhancement. (Thanks to Gavan Fantom)
 * The command line tool "qrencode" now accepts long options. See the man page
-  or give "--help" option to it.
+  for the detailed instruction.
+
+Release Note:
+
+This release improves the portability of our command line tool "qrencode".
+The library is not changed so that any applications using libqrencode are not
+affected.
+
+From this release, qrencode accepts "long" options, such as "--help". See the
+manpage for the detailed instructions.
+
+Qrencode now uses getopt_long() instead of getopt_long_only() which is not
+available in some operating systems. If the getopt_long() is not provided or
+the implementation of it is not compatible with GNU's one, please try
+qrencode-3.0.3-gnulib, that contains the source code of the getopt_long().
+Gnulib version is a test release. If you feel happy with it, please let us know
+and the future releases will include gnulib.
 
 Version 3.0.2 (2008.5.18)
 -------------------------
@@ -22,7 +38,6 @@ Version 3.0.1 (2008.5.9)
 
 Version 3.0.0 (2008.4.30)
 -------------------------
-Summary:
 * The interface of QRencode_encodeInput() has been changed. User applications
   using it must be modified.
 * Structured append support has been added. (patches from Yusuke Mihara)
diff --git a/autogen.sh b/autogen.sh
index e0767b76be..c002b4e828 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -13,6 +13,8 @@ if [ ! -d use ]; then
     mkdir use
 fi
 
+autoheader
+
 aclocal -I $ACLOCAL_DIR
 
 libtoolize --automake --copy
diff --git a/configure.ac b/configure.ac
index 1e7c1491b9..9993f4ec61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_INIT(QRencode)
 
 MAJOR_VERSION=3
 MINOR_VERSION=0
-MICRO_VERSION=2
+MICRO_VERSION=3
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 AC_SUBST(MAJOR_VERSION)
 AC_SUBST(MINOR_VERSION)
@@ -10,6 +10,7 @@ AC_SUBST(MICRO_VERSION)
 AC_SUBST(VERSION)
 
 AC_CONFIG_SRCDIR([qrencode.c])
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR(use)
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
diff --git a/qrenc.c b/qrenc.c
index 5b7e0b9b1c..6aa074ea04 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 
+#include "config.h"
 #include "qrencode.h"
 
 static int casesensitive = 1;
@@ -53,16 +54,51 @@ static const struct option options[] = {
 
 static char *optstring = "ho:l:s:v:m:Skci8V";
 
-static void usage(int help)
+static void usage(int help, int longopt)
 {
 	fprintf(stderr,
 "qrencode version %s\n"
 "Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi\n", VERSION);
 	if(help) {
-		fprintf(stderr,
+		if(longopt) {
+			fprintf(stderr,
+"Usage: qrencode [OPTION]... [STRING]\n"
+"Encode input data in a QR Code and save as a PNG image.\n\n"
+"  -h, --help   display the help message. -h displays only the help of short\n"
+"               options.\n\n"
+"  -o FILENAME, --output=FILENAME\n"
+"               write PNG image to FILENAME. If '-' is specified, the result\n"
+"               will be output to standard output. If -S is given, structured\n"
+"               symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n"
+"               if specified, remove a trailing '.png' from FILENAME.\n\n"
+"  -s NUMBER, --size=NUMBER\n"
+"               specify the size of dot (pixel). (default=3)\n\n"
+"  -l {LMQH}, --level={LMQH}\n"
+"               specify error collectin level from L (lowest) to H (highest).\n"
+"               (default=L)\n\n"
+"  -v NUMBER, --symversion=NUMBER\n"
+"               specify the version of the symbol. (default=auto)\n\n"
+"  -m NUMBER, --margin=NUMBER\n"
+"               specify the width of margin. (default=4)\n\n"
+"  -S, --structured\n"
+"               make structured symbols. Version must be specified.\n\n"
+"  -k, --kanji  assume that the input text contains kanji (shift-jis).\n\n"
+"  -c, --casesensitive\n"
+"               encode lower-case alphabet characters in 8-bit mode. (default)\n\n"
+"  -i, --ignorecase\n"
+"               ignore case distinctions and use only upper-case characters.\n\n"
+"  -8, -8bit    encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n"
+"  -V, --version\n"
+"               display the version number and copyrights of the qrencode.\n\n"
+"  [STRING]     input data. If it is not specified, data will be taken from\n"
+"               standard input.\n"
+			);
+		} else {
+			fprintf(stderr,
 "Usage: qrencode [OPTION]... [STRING]\n"
 "Encode input data in a QR Code and save as a PNG image.\n\n"
 "  -h           display this message.\n"
+"  --help       display the usage of long options.\n"
 "  -o FILENAME  write PNG image to FILENAME. If '-' is specified, the result\n"
 "               will be output to standard output. If -S is given, structured\n"
 "               symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n"
@@ -77,9 +113,11 @@ static void usage(int help)
 "  -c           encode lower-case alphabet characters in 8-bit mode. (default)\n"
 "  -i           ignore case distinctions and use only upper-case characters.\n"
 "  -8           encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n"
+"  -V           display the version number and copyrights of the qrencode.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
 "               standard input.\n"
-		);
+			);
+		}
 	}
 }
 
@@ -296,14 +334,18 @@ static void qrencodeStructured(const char *intext, const char *outfile)
 
 int main(int argc, char **argv)
 {
-	int opt;
+	int opt, lindex = -1;
 	char *outfile = NULL;
 	char *intext = NULL;
 
-	while((opt = getopt_long(argc, argv, optstring, options, NULL)) != -1) {
+	while((opt = getopt_long(argc, argv, optstring, options, &lindex)) != -1) {
 		switch(opt) {
 			case 'h':
-				usage(1);
+				if(lindex == 0) {
+					usage(1, 1);
+				} else {
+					usage(1, 0);
+				}
 				exit(0);
 				break;
 			case 'o':
@@ -369,18 +411,18 @@ int main(int argc, char **argv)
 				eightbit = 1;
 				break;
 			case 'V':
-				usage(0);
+				usage(0, 0);
 				exit(0);
 				break;
 			default:
-				usage(1);
+				fprintf(stderr, "Try `qrencode --help' for more information.\n");
 				exit(1);
 				break;
 		}
 	}
 
 	if(argc == 1) {
-		usage(1);
+		usage(1, 0);
 		exit(0);
 	}
 
diff --git a/qrencode.1.in b/qrencode.1.in
index 25344eb3bc..08cd13cb83 100644
--- a/qrencode.1.in
+++ b/qrencode.1.in
@@ -17,43 +17,55 @@ a QR Code and save as a PNG image.
 
 .SH OPTIONS
 .TP
-.B \-h
+.B \-h, --help
 display help message.
 .TP
-.B \-o FILENAME
+.B \-o FILENAME, --output=FILENAME
 write PNG image to FILENAME. If '-' is specified, the result will be output
 to standard output.
 .TP
-.B \-s NUMBER
+.B \-s NUMBER, --size=NUMBER
 specify the size of dot (pixel). (default=3)
 .TP
-.B \-l {LMQH}
+.B \-l {LMQH}, --level={LMQH}
 specify error collectin level from L (lowest) to H (highest). (default=L)
 .TP
-.B \-v NUMBER
+.B \-v NUMBER, --symversion=NUMBER
 specify the version of the symbol. (default=auto)
 .TP
-.B \-m NUMBER
+.B \-m NUMBER, --margin=NUMBER
 specify the width of margin. (default=4)
 .TP
-.B \-S
+.B \-S, --structured
 make structured symbols. Version must be specified.
 .TP
-.B \-k
+.B \-k, --kanji
 assume that the input text contains kanji (shift-jis).
 .TP
-.B \-c
+.B \-c, --casesensitive
 encode lower-case alphabet characters in 8-bit mode. (default)
 .TP
-.B \-i
+.B \-i, --ignorecase
 ignore case distinctions and use only upper-case characters.
 .TP
-.B \-8
+.B \-8, --8bit
 encode entire data in 8-bit mode. -k, -c and -i will be ignored.
 .TP
+.B \-V, --version
+display the version number and copyrights of the qrencode.
+.TP
 .B [STRING]
 input data. If it is not specified, data will be taken from standard input.
 
+.SH EXAMPLES
+.TP
+.B qrencode -l L -v 1 -o output.png 'Hello, world!'
+encode into a symbol version 1, level L.
+.TP
+.B qrencode -iSv 1 --output=output.png
+read standard input and encode it into a structured-appended symbols in
+case-insensitive mode.
+
 .SH AUTHOR
 Written by Kentaro Fukuchi.
 
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 0cf71895a7..3a1b9e35bb 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include "../config.h"
 #include "../qrspec.h"
 #include "../qrinput.h"
 #include "../qrencode_inner.h"
@@ -22,56 +23,80 @@ static QRencodeMode hint = QR_MODE_8;
 static char **textv;
 static int textc;
 
-enum {
-	O_HELP,
-	O_SIZE,
-	O_VERSION,
-	O_LEVEL,
-	O_MARGIN,
-	O_KANJI,
-	O_CASE,
-	O_IGNORECASE,
-	O_8BIT,
-	O_STRUCTURED,
-};
-
 static const struct option options[] = {
-	{"h", no_argument      , NULL, O_HELP},
-	{"l", required_argument, NULL, O_LEVEL},
-	{"s", required_argument, NULL, O_SIZE},
-	{"v", required_argument, NULL, O_VERSION},
-	{"m", required_argument, NULL, O_MARGIN},
-	{"k", no_argument      , NULL, O_KANJI},
-	{"c", no_argument      , NULL, O_CASE},
-	{"i", no_argument      , NULL, O_IGNORECASE},
-	{"8", no_argument      , NULL, O_8BIT},
-	{"S", no_argument      , NULL, O_STRUCTURED},
+	{"help"         , no_argument      , NULL, 'h'},
+	{"level"        , required_argument, NULL, 'l'},
+	{"size"         , required_argument, NULL, 's'},
+	{"symversion"   , required_argument, NULL, 'v'},
+	{"margin"       , required_argument, NULL, 'm'},
+	{"structured"   , no_argument      , NULL, 'S'},
+	{"kanji"        , no_argument      , NULL, 'k'},
+	{"casesensitive", no_argument      , NULL, 'c'},
+	{"ignorecase"   , no_argument      , NULL, 'i'},
+	{"8bit"         , no_argument      , NULL, '8'},
+	{"version"      , no_argument      , NULL, 'V'},
 	{NULL, 0, NULL, 0}
 };
 
+static char *optstring = "ho:l:s:v:m:Skci8V";
 
 static char levelChar[4] = {'L', 'M', 'Q', 'H'};
-static void usage(void)
+static void usage(int help, int longopt)
 {
 	fprintf(stderr,
 "view_qrcode version %s\n"
-"Copyright (C) 2008 Kentaro Fukuchi\n"
+"Copyright (C) 2008 Kentaro Fukuchi\n", VERSION);
+	if(help) {
+		if(longopt) {
+			fprintf(stderr,
+"Usage: view_qrcode [OPTION]... [STRING]\n"
+"Encode input data in a QR Code and display.\n\n"
+"  -h, --help   display the help message. -h displays only the help of short\n"
+"               options.\n\n"
+"  -s NUMBER, --size=NUMBER\n"
+"               specify the size of dot (pixel). (default=3)\n\n"
+"  -l {LMQH}, --level={LMQH}\n"
+"               specify error collectin level from L (lowest) to H (highest).\n"
+"               (default=L)\n\n"
+"  -v NUMBER, --symversion=NUMBER\n"
+"               specify the version of the symbol. (default=auto)\n\n"
+"  -m NUMBER, --margin=NUMBER\n"
+"               specify the width of margin. (default=4)\n\n"
+"  -S, --structured\n"
+"               make structured symbols. Version must be specified.\n\n"
+"  -k, --kanji  assume that the input text contains kanji (shift-jis).\n\n"
+"  -c, --casesensitive\n"
+"               encode lower-case alphabet characters in 8-bit mode. (default)\n\n"
+"  -i, --ignorecase\n"
+"               ignore case distinctions and use only upper-case characters.\n\n"
+"  -8, -8bit    encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n"
+"  -V, --version\n"
+"               display the version number and copyrights of the qrencode.\n\n"
+"  [STRING]     input data. If it is not specified, data will be taken from\n"
+"               standard input.\n"
+			);
+		} else {
+			fprintf(stderr,
 "Usage: view_qrcode [OPTION]... [STRING]\n"
-"Encode input data in a QR Code and save as a PNG image.\n\n"
+"Encode input data in a QR Code and display.\n\n"
 "  -h           display this message.\n"
-"  -s NUMBER    specify the size of dot (pixel). (default=4)\n"
+"  --help       display the usage of long options.\n"
+"  -s NUMBER    specify the size of dot (pixel). (default=3)\n"
 "  -l {LMQH}    specify error collectin level from L (lowest) to H (highest).\n"
 "               (default=L)\n"
-"  -v NUMBER    specify the version of the symbol. (default=1)\n"
+"  -v NUMBER    specify the version of the symbol. (default=auto)\n"
 "  -m NUMBER    specify the width of margin. (default=4)\n"
 "  -S           make structured symbols. Version must be specified.\n"
 "  -k           assume that the input text contains kanji (shift-jis).\n"
 "  -c           encode lower-case alphabet characters in 8-bit mode. (default)\n"
 "  -i           ignore case distinctions and use only upper-case characters.\n"
 "  -8           encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n"
+"  -V           display the version number and copyrights of the qrencode.\n"
 "  [STRING]     input data. If it is not specified, data will be taken from\n"
-"               standard input.\n",
-	VERSION);
+"               standard input.\n"
+			);
+		}
+	}
 }
 
 #define MAX_DATA_SIZE (7090 * 16) /* from the specification */
@@ -352,30 +377,34 @@ void view_multiText(char **argv, int argc)
 
 int main(int argc, char **argv)
 {
-	int opt;
+	int opt, lindex = -1;
 	char *intext = NULL;
 
-	while((opt = getopt_long_only(argc, argv, "", options, NULL)) != -1) {
+	while((opt = getopt_long(argc, argv, optstring, options, &lindex)) != -1) {
 		switch(opt) {
-			case O_HELP:
-				usage();
+			case 'h':
+				if(lindex == 0) {
+					usage(1, 1);
+				} else {
+					usage(1, 0);
+				}
 				exit(0);
 				break;
-			case O_SIZE:
+			case 's':
 				size = atoi(optarg);
 				if(size <= 0) {
 					fprintf(stderr, "Invalid size: %d\n", size);
 					exit(1);
 				}
 				break;
-			case O_VERSION:
+			case 'v':
 				version = atoi(optarg);
 				if(version < 0) {
 					fprintf(stderr, "Invalid version: %d\n", version);
 					exit(1);
 				}
 				break;
-			case O_LEVEL:
+			case 'l':
 				switch(*optarg) {
 					case 'l':
 					case 'L':
@@ -399,35 +428,39 @@ int main(int argc, char **argv)
 						break;
 				}
 				break;
-			case O_MARGIN:
+			case 'm':
 				margin = atoi(optarg);
 				if(margin < 0) {
 					fprintf(stderr, "Invalid margin: %d\n", margin);
 					exit(1);
 				}
 				break;
-			case O_STRUCTURED:
+			case 'S':
 				structured = 1;
-			case O_KANJI:
+			case 'k':
 				hint = QR_MODE_KANJI;
 				break;
-			case O_CASE:
+			case 'c':
 				casesensitive = 1;
 				break;
-			case O_IGNORECASE:
+			case 'i':
 				casesensitive = 0;
 				break;
-			case O_8BIT:
+			case '8':
 				eightbit = 1;
 				break;
+			case 'V':
+				usage(0, 0);
+				exit(0);
+				break;
 			default:
-				usage();
+				fprintf(stderr, "Try `view_qrcode --help' for more information.\n");
 				exit(1);
 				break;
 		}
 	}
 	if(argc == 1) {
-		usage();
+		usage(1, 0);
 		exit(0);
 	}
 
-- 
cgit 0.0.5-2-1-g0f52


From 53aaa72c43822444dfcd9495a8137ed9777b2849 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 12 Sep 2008 01:25:21 +0000
Subject: Unused var 'pitch' has been removed.

---
 tests/view_qrcode.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 3a1b9e35bb..14a1ec3fba 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -123,7 +123,6 @@ static char *readStdin(void)
 
 static void draw_QRcode(QRcode *qrcode, int ox, int oy)
 {
-	int pitch;
 	int x, y, width;
 	unsigned char *p;
 	SDL_Rect rect;
@@ -132,7 +131,6 @@ static void draw_QRcode(QRcode *qrcode, int ox, int oy)
 	oy += margin * size;
 	width = qrcode->width;
 	p = qrcode->data;
-	pitch = screen->pitch;
 	for(y=0; y
Date: Fri, 12 Sep 2008 01:25:58 +0000
Subject:

---
 ChangeLog | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 0acb1c587e..b2f0cc9529 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008.09.12 Kentaro FUKUCHI 
+	* tests/view_qrcode.c:
+	  - Unused variable 'pitch' has been removed from draw_QRcode().
+
 2008.06.03 Kentaro FUKUCHI 
 	* Merged to the main trunk.
 
-- 
cgit 0.0.5-2-1-g0f52


From a3ee2d4a2b0b231e43149c5f682cf4284d4637dd Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 10 Oct 2008 18:37:37 +0000
Subject: Darwin workaround.

---
 ChangeLog  | 4 ++++
 autogen.sh | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index b2f0cc9529..983a6cb649 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008.10.11 Kentaro FUKUCHI 
+	* autogen.sh:
+	  - Darwin workaround.
+
 2008.09.12 Kentaro FUKUCHI 
 	* tests/view_qrcode.c:
 	  - Unused variable 'pitch' has been removed from draw_QRcode().
diff --git a/autogen.sh b/autogen.sh
index c002b4e828..c5626577a9 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -2,6 +2,12 @@
 
 set -e
 
+if [ `uname -s` = Darwin ]; then
+    LIBTOOLIZE=glibtoolize
+else
+    LIBTOOLIZE=libtoolize
+fi
+
 if [ -d /usr/local/share/aclocal ]; then
     ACLOCAL_DIR=/usr/local/share/aclocal
 else if [ -d /usr/share/aclocal ]; then
@@ -17,7 +23,7 @@ autoheader
 
 aclocal -I $ACLOCAL_DIR
 
-libtoolize --automake --copy
+$LIBTOOLIZE --automake --copy
 automake --add-missing --copy
 
 autoconf
-- 
cgit 0.0.5-2-1-g0f52


From c7b998e5ac2519b78c9531a35dcda6e30342687f Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 10 Oct 2008 19:09:47 +0000
Subject: 	* configure.ac: 	  - Now config.h offers "__STATIC"
 macro becomes "static" when 	    "--without-tests" is specified. This macro
 is useful for functions 		that are called from test programs but
 not from other library codes. 	* qrinput.c: 	  - Very little performance
 improvement.

---
 ChangeLog    |  6 ++++++
 configure.ac | 10 ++++++++++
 qrinput.c    | 28 ++++++++++------------------
 3 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 983a6cb649..20975d6752 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
 2008.10.11 Kentaro FUKUCHI 
 	* autogen.sh:
 	  - Darwin workaround.
+	* configure.ac:
+	  - Now config.h offers "__STATIC" macro becomes "static" when
+	    "--without-tests" is specified. This macro is useful for functions
+		that are called from test programs but not from other library codes.
+	* qrinput.c:
+	  - Very little performance improvement.
 
 2008.09.12 Kentaro FUKUCHI 
 	* tests/view_qrcode.c:
diff --git a/configure.ac b/configure.ac
index 9993f4ec61..18f489d1b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,16 @@ dnl --with-tests
 AC_ARG_WITH([tests], [AC_HELP_STRING([--with-tests], [build tests [default=yes]])],
  [build_tests=$withval], [build_tests=yes])
 AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes" ])
+AH_VERBATIM([tests],
+[/* Define to 'static' if no test programs will be compiled. */
+   #define __STATIC static
+   ])
+if test x$build_tests = xyes ; then
+echo "#define __STATIC" >>confdefs.h
+else
+echo "#define __STATIC static" >>confdefs.h
+fi
+
 
 if test x$build_tests = xyes ; then
 	SDL_REQUIRED_VERSION=1.2.0
diff --git a/qrinput.c b/qrinput.c
index f5d7d9051d..2ca1305a29 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 
+#include "config.h"
 #include "qrencode.h"
 #include "qrspec.h"
 #include "bitstream.h"
@@ -832,34 +833,25 @@ static int QRinput_convertData(QRinput *input)
 /**
  * Create padding bits for the input data.
  * @param input input data.
+ * @param size size of merged input bit stream.
  * @return padding bit stream.
  */
-static BitStream *QRinput_createPaddingBit(QRinput *input)
+__STATIC BitStream *QRinput_createPaddingBit(QRinput *input, int bits)
 {
-	int bits, maxbits, words, maxwords, i;
-	QRinput_List *list;
+	int maxbits, words, maxwords, i;
 	BitStream *bstream;
 
 	maxwords = QRspec_getDataLength(input->version, input->level);
 	maxbits = maxwords * 8;
 
-	list = input->head;
-	bits = 0;
-	while(list != NULL) {
-		bits += BitStream_size(list->bstream);
-		list = list->next;
+	if(maxbits == bits) {
+		return NULL;
 	}
 
-	words = (bits + 7) / 8;
-
 	if(maxbits - bits < 5) {
-		if(maxbits == bits) {
-			return NULL;
-		} else {
-			bstream = BitStream_new();
-			BitStream_appendNum(bstream, maxbits - bits, 0);
-			return bstream;
-		}
+		bstream = BitStream_new();
+		BitStream_appendNum(bstream, maxbits - bits, 0);
+		return bstream;
 	}
 
 	bits += 4;
@@ -917,7 +909,7 @@ BitStream *QRinput_getBitStream(QRinput *input)
 	if(bstream == NULL) {
 		return NULL;
 	}
-	padding = QRinput_createPaddingBit(input);
+	padding = QRinput_createPaddingBit(input, BitStream_size(bstream));
 	if(padding != NULL) {
 		BitStream_append(bstream, padding);
 		BitStream_free(padding);
-- 
cgit 0.0.5-2-1-g0f52


From cd3dbc3446846a40f10e53621212975b96273d12 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 10 Oct 2008 19:57:17 +0000
Subject: Code cleanups.

---
 ChangeLog | 2 ++
 mask.c    | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 20975d6752..ccd2c0d8a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,8 @@
 		that are called from test programs but not from other library codes.
 	* qrinput.c:
 	  - Very little performance improvement.
+	* mask.c:
+	  - Code cleanups.
 
 2008.09.12 Kentaro FUKUCHI 
 	* tests/view_qrcode.c:
diff --git a/mask.c b/mask.c
index ffe74ec81f..bd0abd086a 100644
--- a/mask.c
+++ b/mask.c
@@ -154,12 +154,10 @@ int Mask_evaluateSymbol(int width, unsigned char *frame)
 	int x, y;
 	unsigned char *p;
 	unsigned char b22, w22;
-	unsigned int i;
 	int head;
 	int demerit = 0;
 
 	p = frame;
-	i = 0;
 	for(y=0; y
Date: Fri, 10 Oct 2008 20:10:46 +0000
Subject: Followed changes of mask.c and qrencode.c

---
 tests/test_qrencode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index 5ff4c3b89f..827ee513e5 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -153,7 +153,7 @@ void print_mask(void)
 	frame = (unsigned char *)malloc(width * width);
 	memset(frame, 0x20, width * width);
 	for(mask=0; mask<8; mask++) {
-		masked = Mask_makeMask(width, frame, mask);
+		masked = Mask_makeMask(width, frame, mask, QR_ECLEVEL_L);
 		p = masked;
 		printf("mask %d:\n", mask);
 		for(y=0; y
Date: Fri, 10 Oct 2008 20:11:02 +0000
Subject: Unneeded #include "qrencode_inner.h" have been removed.

---
 tests/test_estimatebit.c | 1 -
 tests/test_monkey.c      | 1 -
 tests/test_split.c       | 1 -
 tests/view_qrcode.c      | 2 +-
 4 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c
index e649d651ed..4e65eb630c 100644
--- a/tests/test_estimatebit.c
+++ b/tests/test_estimatebit.c
@@ -3,7 +3,6 @@
 #include 
 #include "common.h"
 #include "../qrinput.h"
-#include "../qrencode_inner.h"
 
 QRinput *gstream;
 
diff --git a/tests/test_monkey.c b/tests/test_monkey.c
index ece7061ff6..46b55257ae 100644
--- a/tests/test_monkey.c
+++ b/tests/test_monkey.c
@@ -2,7 +2,6 @@
 #include 
 #include "common.h"
 #include "../qrinput.h"
-#include "../qrencode_inner.h"
 #include "../split.h"
 #include "../qrspec.h"
 
diff --git a/tests/test_split.c b/tests/test_split.c
index 065ddf8d52..60bb4a8dd2 100644
--- a/tests/test_split.c
+++ b/tests/test_split.c
@@ -2,7 +2,6 @@
 #include 
 #include 
 #include "common.h"
-#include "../qrencode_inner.h"
 #include "../qrspec.h"
 #include "../qrinput.h"
 #include "../mask.h"
diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c
index 14a1ec3fba..89a4a324d7 100644
--- a/tests/view_qrcode.c
+++ b/tests/view_qrcode.c
@@ -7,8 +7,8 @@
 #include "../config.h"
 #include "../qrspec.h"
 #include "../qrinput.h"
-#include "../qrencode_inner.h"
 #include "../split.h"
+#include "../qrencode_inner.h"
 
 static SDL_Surface *screen = NULL;
 static int casesensitive = 1;
-- 
cgit 0.0.5-2-1-g0f52


From ce7aa9bed5520648c9d8891bcb19adb21c81c752 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 10 Oct 2008 20:11:57 +0000
Subject: * qrencode_inner.h:   - Now this header is called only by test
 programs. * qrencode.c, qrencode_inner.h:   - Some definitions and declares
 written in qrencode_inner.h have been     moved into qrencode.c:   -
 QRraw_*() have been declared as __STATIC. * mask.[ch], qrencode.c,
 qrencode_inner.h:   - Mask_makeMask() now requires QRecLevel.   -
 QRencode_writeFormatInformation() has been renamed and moved to    
 Mask_writeFormatInformation(), and become __STATIC.

---
 ChangeLog        | 14 +++++++++
 mask.c           | 52 +++++++++++++++++++++++++++++++---
 mask.h           |  3 +-
 qrencode.c       | 86 ++++++++++++++++++++++----------------------------------
 qrencode_inner.h | 16 +++++++----
 5 files changed, 107 insertions(+), 64 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ccd2c0d8a4..fab1c4434b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2008.10.11 Kentaro FUKUCHI 
+	* qrencode_inner.h:
+	  - Now this header is called only by test programs.
+	* qrencode.c, qrencode_inner.h:
+	  - Some definitions and declares written in qrencode_inner.h have been
+	    moved into qrencode.c:
+	  - QRraw_*() have been declared as __STATIC.
+	* mask.[ch], qrencode.c, qrencode_inner.h:
+	  - Mask_makeMask() now requires QRecLevel.
+	  - QRencode_writeFormatInformation() has been renamed and moved to
+	    Mask_writeFormatInformation(), and become __STATIC.
+	* tests/*.c:
+	  - Unneeded #include "qrencode_inner.h" have been removed.
+
 2008.10.11 Kentaro FUKUCHI 
 	* autogen.sh:
 	  - Darwin workaround.
diff --git a/mask.c b/mask.c
index bd0abd086a..c34699c9fb 100644
--- a/mask.c
+++ b/mask.c
@@ -21,11 +21,54 @@
 
 #include 
 #include 
+#include "config.h"
 #include "qrencode.h"
-#include "qrencode_inner.h"
 #include "qrspec.h"
 #include "mask.h"
 
+__STATIC int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level)
+{
+	unsigned int format;
+	unsigned char v;
+	int i;
+	int blacks = 0;
+
+	format =  QRspec_getFormatInfo(mask, level);
+
+	for(i=0; i<8; i++) {
+		if(format & 1) {
+			blacks += 2;
+			v = 0x85;
+		} else {
+			v = 0x84;
+		}
+		frame[width * 8 + width - 1 - i] = v;
+		if(i < 6) {
+			frame[width * i + 8] = v;
+		} else {
+			frame[width * (i + 1) + 8] = v;
+		}
+		format= format >> 1;
+	}
+	for(i=0; i<7; i++) {
+		if(format & 1) {
+			blacks += 2;
+			v = 0x85;
+		} else {
+			v = 0x84;
+		}
+		frame[width * (width - 7 + i) + 8] = v;
+		if(i == 0) {
+			frame[width * 8 + 7] = v;
+		} else {
+			frame[width * 8 + 6 - i] = v;
+		}
+		format= format >> 1;
+	}
+
+	return blacks;
+}
+
 /**
  * Demerit coefficients.
  * See Section 8.8.2, pp.45, JIS X0510:2004.
@@ -98,13 +141,14 @@ static MaskMaker *maskMakers[] = {
 	Mask_mask4, Mask_mask5, Mask_mask6, Mask_mask7
 };
 
-unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask)
+unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level)
 {
 	unsigned char *masked;
 
 	masked = (unsigned char *)malloc(width * width);
 
 	maskMakers[mask](width, frame, masked);
+	Mask_writeFormatInformation(width, masked, mask, level);
 
 	return masked;
 }
@@ -149,7 +193,7 @@ static int Mask_calcN1N3(int length, int *runLength)
 	return demerit;
 }
 
-int Mask_evaluateSymbol(int width, unsigned char *frame)
+__STATIC int Mask_evaluateSymbol(int width, unsigned char *frame)
 {
 	int x, y;
 	unsigned char *p;
@@ -227,7 +271,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
 		demerit = 0;
 		mask = (unsigned char *)malloc(width * width);
 		blacks = maskMakers[i](width, frame, mask);
-		blacks += QRcode_writeFormatInformation(width, mask, i, level);
+		blacks += Mask_writeFormatInformation(width, mask, i, level);
 		blacks = 100 * blacks / (width * width);
 		demerit = (abs(blacks - 50) / 5) * N4;
 //		n4 = demerit;
diff --git a/mask.h b/mask.h
index 6bf39ff6dd..b3b544692e 100644
--- a/mask.h
+++ b/mask.h
@@ -24,8 +24,7 @@
 
 #include "qrinput.h"
 
-extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask);
-extern int Mask_evaluateSymbol(int width, unsigned char *frame);
+extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level);
 extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level);
 
 #endif /* __MASK_H__ */
diff --git a/qrencode.c b/qrencode.c
index 0546ef08e1..18d90dc826 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -23,8 +23,8 @@
 #include 
 #include 
 
+#include "config.h"
 #include "qrencode.h"
-#include "qrencode_inner.h"
 #include "qrspec.h"
 #include "mqrspec.h"
 #include "bitstream.h"
@@ -37,6 +37,24 @@
  * Raw code
  *****************************************************************************/
 
+typedef struct {
+	int dataLength;
+	unsigned char *data;
+	int eccLength;
+	unsigned char *ecc;
+} RSblock;
+
+typedef struct {
+	int version;
+	unsigned char *datacode;
+	int blocks;
+	RSblock *rsblock;
+	int count;
+	int dataLength;
+	int eccLength;
+	int b1;
+} QRRawCode;
+
 static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el)
 {
 	RS *rs;
@@ -50,7 +68,7 @@ static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el)
 	encode_rs_char(rs, data, block->ecc);
 }
 
-QRRawCode *QRraw_new(QRinput *input)
+__STATIC QRRawCode *QRraw_new(QRinput *input)
 {
 	QRRawCode *raw;
 	int *spec;
@@ -106,7 +124,7 @@ QRRawCode *QRraw_new(QRinput *input)
  * @param raw raw code.
  * @return code
  */
-unsigned char QRraw_getCode(QRRawCode *raw)
+__STATIC unsigned char QRraw_getCode(QRRawCode *raw)
 {
 	int col, row;
 	unsigned char ret;
@@ -129,7 +147,7 @@ unsigned char QRraw_getCode(QRRawCode *raw)
 	return ret;
 }
 
-void QRraw_free(QRRawCode *raw)
+__STATIC void QRraw_free(QRRawCode *raw)
 {
 	int i;
 
@@ -146,6 +164,15 @@ void QRraw_free(QRRawCode *raw)
  *****************************************************************************/
 
 #if 0
+typedef struct {
+	int version;
+	unsigned char *datacode;
+	RSblock *rsblock;
+	int count;
+	int dataLength;
+	int eccLength;
+} MQRRawCode;
+
 MQRRawCode *MQRraw_new(QRinput *input)
 {
 	MQRRawCode *raw;
@@ -300,52 +327,6 @@ unsigned char *FrameFiller_fillerTest(int version)
 }
 #endif
 
-/******************************************************************************
- * Format information
- *****************************************************************************/
-
-int QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level)
-{
-	unsigned int format;
-	unsigned char v;
-	int i;
-	int blacks = 0;
-
-	format =  QRspec_getFormatInfo(mask, level);
-
-	for(i=0; i<8; i++) {
-		if(format & 1) {
-			blacks += 2;
-			v = 0x85;
-		} else {
-			v = 0x84;
-		}
-		frame[width * 8 + width - 1 - i] = v;
-		if(i < 6) {
-			frame[width * i + 8] = v;
-		} else {
-			frame[width * (i + 1) + 8] = v;
-		}
-		format= format >> 1;
-	}
-	for(i=0; i<7; i++) {
-		if(format & 1) {
-			blacks += 2;
-			v = 0x85;
-		} else {
-			v = 0x84;
-		}
-		frame[width * (width - 7 + i) + 8] = v;
-		if(i == 0) {
-			frame[width * 8 + 7] = v;
-		} else {
-			frame[width * 8 + 6 - i] = v;
-		}
-		format= format >> 1;
-	}
-
-	return blacks;
-}
 
 /******************************************************************************
  * QR-code encoding
@@ -373,7 +354,7 @@ void QRcode_free(QRcode *qrcode)
 	free(qrcode);
 }
 
-QRcode *QRcode_encodeMask(QRinput *input, int mask)
+__STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask)
 {
 	int width, version;
 	QRRawCode *raw;
@@ -421,8 +402,7 @@ QRcode *QRcode_encodeMask(QRinput *input, int mask)
 	if(mask < 0) {
 		masked = Mask_mask(width, frame, input->level);
 	} else {
-		masked = Mask_makeMask(width, frame, mask);
-		QRcode_writeFormatInformation(width, masked, mask, input->level);
+		masked = Mask_makeMask(width, frame, mask, input->level);
 	}
 	qrcode = QRcode_new(version, width, masked);
 
diff --git a/qrencode_inner.h b/qrencode_inner.h
index 2725a785d1..608f09d2e7 100644
--- a/qrencode_inner.h
+++ b/qrencode_inner.h
@@ -1,7 +1,7 @@
 /**
  * qrencode - QR Code encoder
  *
- * Header for internal use
+ * Header for test use
  * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
@@ -23,7 +23,7 @@
 #define __QRENCODE_INNER_H__
 
 /**
- * This header file includes definitions for inner use.
+ * This header file includes definitions for test use.
  */
 
 /******************************************************************************
@@ -75,9 +75,15 @@ extern void MQRraw_free(MQRRawCode *raw);
 extern unsigned char *FrameFiller_fillerTest(int version);
 
 /******************************************************************************
- * Format information
+ * QR-code encoding
  *****************************************************************************/
-extern int QRcode_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
-
 extern QRcode *QRcode_encodeMask(QRinput *input, int mask);
+
+/******************************************************************************
+ * Mask
+ *****************************************************************************/
+
+extern int Mask_evaluateSymbol(int width, unsigned char *frame);
+extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
+
 #endif /* __QRENCODE_INNER_H__ */
-- 
cgit 0.0.5-2-1-g0f52

-- 
cgit 0.0.5-2-1-g0f52


From 4d3c669782ce8ca86a0aa5ec46cb065f3ad8a6fb Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 31 Oct 2008 09:42:46 +0000
Subject: Follows the C99 standard.

---
 ChangeLog      | 5 +++++
 tests/common.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index fab1c4434b..67be533de0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008.10.31 Kentaro FUKUCHI 
+	* tests/commo.h:
+	  - __FUNCTION__ has been replaced with __func__, to follow the C99
+	    standard.
+
 2008.10.11 Kentaro FUKUCHI 
 	* qrencode_inner.h:
 	  - Now this header is called only by test programs.
diff --git a/tests/common.h b/tests/common.h
index aa6c83f4da..bbfcacec73 100644
--- a/tests/common.h
+++ b/tests/common.h
@@ -10,7 +10,7 @@
 #include "../qrinput.h"
 #include "../bitstream.h"
 
-#define testStart(__arg__) (testStartReal(__FUNCTION__, __arg__))
+#define testStart(__arg__) (testStartReal(__func__, __arg__))
 #define testEndExp(__arg__) (testEnd(!(__arg__)))
 
 static int tests = 0;
-- 
cgit 0.0.5-2-1-g0f52


From cc3a6a93b3d05fc0ed40fb1b4410cb860445935a Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 31 Oct 2008 10:04:57 +0000
Subject: Follows the C99 standard.

---
 ChangeLog      |  2 ++
 tests/common.h | 18 +++++++++---------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 67be533de0..8ea059ae76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 	* tests/commo.h:
 	  - __FUNCTION__ has been replaced with __func__, to follow the C99
 	    standard.
+	  - The way of variadic macros has been changed, to follow the C99
+	    standard.
 
 2008.10.11 Kentaro FUKUCHI 
 	* qrencode_inner.h:
diff --git a/tests/common.h b/tests/common.h
index bbfcacec73..a29d2f6793 100644
--- a/tests/common.h
+++ b/tests/common.h
@@ -72,15 +72,15 @@ void testEnd(int result)
 	}
 }
 
-#define assert_exp(__exp__, __msg__...) \
-(void)({assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__msg__);}})
-
-#define assert_zero(__exp__, __msg__...) assert_exp((__exp__) == 0, __msg__)
-#define assert_nonzero(__exp__, __msg__...) assert_exp((__exp__) != 0, __msg__)
-#define assert_null(__ptr__, __msg__...) assert_exp((__ptr__) == NULL, __msg__)
-#define assert_nonnull(__ptr__, __msg__...) assert_exp((__ptr__) != NULL, __msg__)
-#define assert_equal(__e1__, __e2__, __msg__...) assert_exp((__e1__) == (__e2__), __msg__)
-#define assert_notequal(__e1__, __e2__, __msg__...) assert_exp((__e1__) != (__e2__), __msg__)
+#define assert_exp(__exp__, ...) \
+(void)({assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__VA_ARGS__);}})
+
+#define assert_zero(__exp__, ...) assert_exp((__exp__) == 0, __VA_ARGS__)
+#define assert_nonzero(__exp__, ...) assert_exp((__exp__) != 0, __VA_ARGS__)
+#define assert_null(__ptr__, ...) assert_exp((__ptr__) == NULL, __VA_ARGS__)
+#define assert_nonnull(__ptr__, ...) assert_exp((__ptr__) != NULL, __VA_ARGS__)
+#define assert_equal(__e1__, __e2__, ...) assert_exp((__e1__) == (__e2__), __VA_ARGS__)
+#define assert_notequal(__e1__, __e2__, ...) assert_exp((__e1__) != (__e2__), __VA_ARGS__)
 
 void testFinish(void)
 {
-- 
cgit 0.0.5-2-1-g0f52


From f78d8ec8b60c1c29fa98a7287d88b0310b716c2f Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 5 Jan 2009 17:31:30 +0000
Subject: - exit(1) -> exit(EXIT_FAILURE) (splint warning) - NULL check of
 malloc has been added (splint warning)

---
 qrenc.c | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/qrenc.c b/qrenc.c
index 6aa074ea04..c15b38adad 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -128,14 +128,18 @@ static char *readStdin(void)
 	int ret;
 
 	buffer = (char *)malloc(MAX_DATA_SIZE);
+	if(buffer == NULL) {
+		fprintf(stderr, "Memory allocation failed.\n");
+		exit(EXIT_FAILURE);
+	}
 	ret = fread(buffer, 1, MAX_DATA_SIZE, stdin);
 	if(ret == 0) {
 		fprintf(stderr, "No input data.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
-	if(!feof(stdin)) {
+	if(feof(stdin) == 0) {
 		fprintf(stderr, "Input data is too large.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	buffer[ret] = '\0';
@@ -156,7 +160,7 @@ static int writePNG(QRcode *qrcode, const char *outfile)
 	row = (unsigned char *)malloc((realwidth + 7) / 8);
 	if(row == NULL) {
 		fprintf(stderr, "Failed to allocate memory.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	if(outfile[0] == '-' && outfile[1] == '\0') {
@@ -166,7 +170,7 @@ static int writePNG(QRcode *qrcode, const char *outfile)
 		if(fp == NULL) {
 			fprintf(stderr, "Failed to create file: %s\n", outfile);
 			perror(NULL);
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	}
 
@@ -174,21 +178,21 @@ static int writePNG(QRcode *qrcode, const char *outfile)
 	if(png_ptr == NULL) {
 		fclose(fp);
 		fprintf(stderr, "Failed to initialize PNG writer.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	info_ptr = png_create_info_struct(png_ptr);
 	if(info_ptr == NULL) {
 		fclose(fp);
 		fprintf(stderr, "Failed to initialize PNG write.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	if(setjmp(png_jmpbuf(png_ptr))) {
 		png_destroy_write_struct(&png_ptr, &info_ptr);
 		fclose(fp);
 		fprintf(stderr, "Failed to write PNG image.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	png_init_io(png_ptr, fp);
@@ -265,7 +269,7 @@ static void qrencode(const char *intext, const char *outfile)
 	qrcode = encode(intext);
 	if(qrcode == NULL) {
 		fprintf(stderr, "Failed to encode the input data.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	writePNG(qrcode, outfile);
 	QRcode_free(qrcode);
@@ -294,7 +298,7 @@ static void qrencodeStructured(const char *intext, const char *outfile)
 	base = strdup(outfile);
 	if(base == NULL) {
 		fprintf(stderr, "Failed to allocate memory.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	if(strlen(base) > 4) {
 		q = base + strlen(base) - 4;
@@ -307,13 +311,13 @@ static void qrencodeStructured(const char *intext, const char *outfile)
 	qrlist = encodeStructured(intext);
 	if(qrlist == NULL) {
 		fprintf(stderr, "Failed to encode the input data.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	for(p = qrlist; p != NULL; p = p->next) {
 		if(p->code == NULL) {
 			fprintf(stderr, "Failed to encode the input data.\n");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 		if(suffix) {
 			snprintf(filename, FILENAME_MAX, "%s-%02d%s", base, i, suffix);
@@ -355,14 +359,14 @@ int main(int argc, char **argv)
 				size = atoi(optarg);
 				if(size <= 0) {
 					fprintf(stderr, "Invalid size: %d\n", size);
-					exit(1);
+					exit(EXIT_FAILURE);
 				}
 				break;
 			case 'v':
 				version = atoi(optarg);
 				if(version < 0) {
 					fprintf(stderr, "Invalid version: %d\n", version);
-					exit(1);
+					exit(EXIT_FAILURE);
 				}
 				break;
 			case 'l':
@@ -385,7 +389,7 @@ int main(int argc, char **argv)
 						break;
 					default:
 						fprintf(stderr, "Invalid level: %s\n", optarg);
-						exit(1);
+						exit(EXIT_FAILURE);
 						break;
 				}
 				break;
@@ -393,7 +397,7 @@ int main(int argc, char **argv)
 				margin = atoi(optarg);
 				if(margin < 0) {
 					fprintf(stderr, "Invalid margin: %d\n", margin);
-					exit(1);
+					exit(EXIT_FAILURE);
 				}
 				break;
 			case 'S':
@@ -416,7 +420,7 @@ int main(int argc, char **argv)
 				break;
 			default:
 				fprintf(stderr, "Try `qrencode --help' for more information.\n");
-				exit(1);
+				exit(EXIT_FAILURE);
 				break;
 		}
 	}
@@ -428,7 +432,7 @@ int main(int argc, char **argv)
 
 	if(outfile == NULL) {
 		fprintf(stderr, "No output filename is given.\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	if(optind < argc) {
@@ -441,7 +445,7 @@ int main(int argc, char **argv)
 	if(structured) {
 		if(version == 0) {
 			fprintf(stderr, "Version must be specified to encode structured symbols.\n");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 		qrencodeStructured(intext, outfile);
 	} else {
-- 
cgit 0.0.5-2-1-g0f52


From cb286eccd2996796d1232514bd541f1a30f451b4 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 5 Jan 2009 17:38:44 +0000
Subject: - NULL check of malloc's return value. (splint warning) - a type
 mismatch fixed. (splint warning)

---
 mask.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mask.c b/mask.c
index c34699c9fb..5be4561135 100644
--- a/mask.c
+++ b/mask.c
@@ -80,7 +80,7 @@ __STATIC int Mask_writeFormatInformation(int width, unsigned char *frame, int ma
 
 #define MASKMAKER(__exp__) \
 	int x, y;\
-	unsigned int b = 0;\
+	int b = 0;\
 \
 	for(y=0; y
Date: Tue, 24 Mar 2009 06:55:15 +0000
Subject: Document fixes.

---
 qrencode.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/qrencode.h b/qrencode.h
index a79ee70067..a7292feb11 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -45,9 +45,9 @@
  * \subsection encoding-input Encoding a structured data
  * You can construct a structured input data manually. If the structure of the
  * input data is known, you can use this way.
- * At first, you must create a ::QRinput object by QRinput_new(). Then, you can
- * add input data to the QRinput object by QRinput_append().
- * Finally you can call QRcode_encodeInput() to encode the QRinput data.
+ * At first, create a ::QRinput object by QRinput_new(). Then add input data
+ * to the QRinput object by QRinput_append(). Finally call QRcode_encodeInput()
+ * to encode the QRinput data.
  * You can reuse the QRinput data again to encode it in other symbols with
  * different parameters.
  *
@@ -57,7 +57,7 @@
  * See ::QRcode for the details. You can free the object by QRcode_free().
  *
  * Please note that the version of the result may be larger than specified.
- * In such cases, the input data would be too large to be encoded in the
+ * In such cases, the input data would be too large to be encoded in a
  * symbol of the specified version.
  *
  * \section structured Structured append
-- 
cgit 0.0.5-2-1-g0f52


From 98313e14d7d1e43cf46a16daa6b7c7480be8f67e Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Tue, 24 Mar 2009 16:02:03 +0000
Subject: --without-tests becomes default.

---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 18f489d1b6..7699fe7da5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,8 +39,8 @@ if test x$build_tools = xyes ; then
 fi
 
 dnl --with-tests
-AC_ARG_WITH([tests], [AC_HELP_STRING([--with-tests], [build tests [default=yes]])],
- [build_tests=$withval], [build_tests=yes])
+AC_ARG_WITH([tests], [AC_HELP_STRING([--with-tests], [build tests [default=no]])],
+ [build_tests=$withval], [build_tests=no])
 AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes" ])
 AH_VERBATIM([tests],
 [/* Define to 'static' if no test programs will be compiled. */
-- 
cgit 0.0.5-2-1-g0f52


From 3d9e9bad4cf5d1e3c80cfa61e28b8a289caf65e9 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Tue, 24 Mar 2009 16:04:07 +0000
Subject:

---
 ChangeLog | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 8ea059ae76..8a178c216b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009.03.25 Kentaro FUKUCHI 
+	* configure.ac:
+	  - Test codes are not compiled by default.
+
 2008.10.31 Kentaro FUKUCHI 
 	* tests/commo.h:
 	  - __FUNCTION__ has been replaced with __func__, to follow the C99
-- 
cgit 0.0.5-2-1-g0f52


From 1c3b5fd7e566caf12720eccdd127fb7b1f005886 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Tue, 24 Mar 2009 16:21:16 +0000
Subject: Checks return value from malloc().

---
 bitstream.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 bitstream.h |  6 +++---
 2 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/bitstream.c b/bitstream.c
index 029ceac9be..ca9f85abd6 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -30,6 +30,8 @@ BitStream *BitStream_new(void)
 	BitStream *bstream;
 
 	bstream = (BitStream *)malloc(sizeof(BitStream));
+	if(bstream == NULL) return NULL;
+
 	bstream->data = NULL;
 
 	return bstream;
@@ -43,7 +45,13 @@ static BitStream *BitStream_newFromNum(int bits, unsigned int num)
 	BitStream *bstream;
 
 	bstream = BitStream_new();
+	if(bstream == NULL) return NULL;
+
 	bstream->data = (char *)malloc(bits + 1);
+	if(bstream->data == NULL) {
+		BitStream_free(bstream);
+		return NULL;
+	}
 
 	p = bstream->data;
 	mask = 1 << (bits - 1);
@@ -69,7 +77,13 @@ static BitStream *BitStream_newFromBytes(int size, unsigned char *data)
 	BitStream *bstream;
 
 	bstream = BitStream_new();
+	if(bstream == NULL) return NULL;
+
 	bstream->data = (char *)malloc(size * 8 + 1);
+	if(bstream->data == NULL) {
+		BitStream_free(bstream);
+		return NULL;
+	}
 
 	p = bstream->data;
 	for(i=0; idata == NULL) {
-		return;
+		return -1;
 	}
 	if(bstream->data == NULL) {
 		bstream->data = strdup(arg->data);
-		return;
+		if(bstream->data == NULL) {
+			return -1;
+		}
+		return 0;
 	}
 
 	l1 = strlen(bstream->data);
 	l2 = strlen(arg->data);
 	data = (char *)malloc(l1 + l2 + 1);
+	if(data == NULL) {
+		return -1;
+	}
 	strcpy(data, bstream->data);
 	strcat(data, arg->data);
 
 	free(bstream->data);
 	bstream->data = data;
+
+	return 0;
 }
 
-void BitStream_appendNum(BitStream *bstream, int bits, unsigned int num)
+int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num)
 {
 	BitStream *b;
+	int ret;
+
+	if(bits == 0) return -1;
 
 	b = BitStream_newFromNum(bits, num);
-	BitStream_append(bstream, b);
+	if(b == NULL) return -1;
+
+	ret = BitStream_append(bstream, b);
 	BitStream_free(b);
+
+	return ret;
 }
 
-void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data)
+int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data)
 {
 	BitStream *b;
+	int ret;
+
+	if(size == 0) return -1;
 
 	b = BitStream_newFromBytes(size, data);
-	BitStream_append(bstream, b);
+	if(b == NULL) return -1;
+
+	ret = BitStream_append(bstream, b);
 	BitStream_free(b);
+
+	return ret;
 }
 
 unsigned int BitStream_size(BitStream *bstream)
@@ -135,7 +171,7 @@ unsigned int BitStream_size(BitStream *bstream)
 	if(bstream == NULL) return 0;
 	if(bstream->data == NULL) return 0;
 
-	return strlen(bstream->data);
+	return (int)strlen(bstream->data);
 }
 
 unsigned char *BitStream_toByte(BitStream *bstream)
@@ -146,6 +182,10 @@ unsigned char *BitStream_toByte(BitStream *bstream)
 
 	size = BitStream_size(bstream);
 	data = (unsigned char *)malloc((size + 7) / 8);
+	if(data == NULL) {
+		return NULL;
+	}
+
 	bytes = size  / 8;
 
 	p = bstream->data;
diff --git a/bitstream.h b/bitstream.h
index 95399a5769..d95f6e7a7e 100644
--- a/bitstream.h
+++ b/bitstream.h
@@ -27,9 +27,9 @@ typedef struct {
 } BitStream;
 
 extern BitStream *BitStream_new(void);
-extern void BitStream_append(BitStream *bstream, BitStream *arg);
-extern void BitStream_appendNum(BitStream *bstream, int bits, unsigned int num);
-extern void BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data);
+extern int BitStream_append(BitStream *bstream, BitStream *arg);
+extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num);
+extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data);
 extern unsigned int BitStream_size(BitStream *bstream);
 extern unsigned char *BitStream_toByte(BitStream *bstream);
 extern void BitStream_free(BitStream *bstream);
-- 
cgit 0.0.5-2-1-g0f52


From d97ae65c09419ca1a1b6fa409ac28ccb393bcb9f Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 30 Apr 2009 06:26:30 +0000
Subject: Documentation.

---
 ChangeLog | 3 +++
 README    | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8a178c216b..9466a033bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 2009.03.25 Kentaro FUKUCHI 
 	* configure.ac:
 	  - Test codes are not compiled by default.
+	* bitstream.[ch]:
+	  - Now functions strictly check return value from malloc() and return
+	    error if it fails.
 
 2008.10.31 Kentaro FUKUCHI 
 	* tests/commo.h:
diff --git a/README b/README
index 37a7ae518d..30d0842d65 100644
--- a/README
+++ b/README
@@ -8,10 +8,10 @@ CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has
 high robustness.
 
 Libqrencode accepts a string or a list of data chunks then encodes in a QR Code
-symbol as a bitmap array. While other QR Code applications generate image files,
-using libqrencode allows applications to render QR Code symbols from raw bitmap
-data directly. This library also contains a command-line utility outputs a QR
-Code symbol as a PNG image. It will help lightweight CGI programs.
+symbol as a bitmap array. While other QR Code applications generate an image
+file, using libqrencode allows applications to render QR Code symbols from raw
+bitmap data directly. This library also contains a command-line utility outputs
+a QR Code symbol as a PNG image. It will help light-weight CGI programs.
 
 
 SPECIFICATION
-- 
cgit 0.0.5-2-1-g0f52


From d61e2771b013b9baf91d50ac6e7bad5d1b4bad02 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 30 Apr 2009 09:26:02 +0000
Subject: * bistream.[ch]:   - Internal representation of BitStream has been
 changed from     NUL-terminated to unsigned char array. * tests/common.h,
 tests/test_{bitstream,qrinput}.c:   - Some test sequences have been updated
 (see above).

---
 ChangeLog              |  7 +++++
 bitstream.c            | 78 ++++++++++++++++++++++++++++++++------------------
 bitstream.h            |  5 ++--
 tests/common.h         | 18 ++++++++++++
 tests/test_bitstream.c |  7 +++--
 tests/test_qrinput.c   | 48 +++++++++++++++++++------------
 6 files changed, 111 insertions(+), 52 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9466a033bf..f1f84ff983 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009.04.30 Kentaro FUKUCHI 
+	* bistream.[ch]:
+	  - Internal representation of BitStream has been changed from
+	    NUL-terminated to unsigned char array.
+	* tests/common.h, tests/test_{bitstream,qrinput}.c:
+	  - Some test sequences have been updated (see above).
+
 2009.03.25 Kentaro FUKUCHI 
 	* configure.ac:
 	  - Test codes are not compiled by default.
diff --git a/bitstream.c b/bitstream.c
index ca9f85abd6..8528e0ca1a 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -32,23 +32,45 @@ BitStream *BitStream_new(void)
 	bstream = (BitStream *)malloc(sizeof(BitStream));
 	if(bstream == NULL) return NULL;
 
+	bstream->length = 0;
 	bstream->data = NULL;
 
 	return bstream;
 }
 
+static int BitStream_allocate(BitStream *bstream, int length)
+{
+	unsigned char *data;
+
+	if(bstream == NULL) {
+		return -1;
+	}
+
+	data = (unsigned char *)malloc(length);
+	if(data == NULL) {
+		return -1;
+	}
+
+	if(bstream->data) {
+		free(bstream->data);
+	}
+	bstream->length = length;
+	bstream->data = data;
+
+	return 0;
+}
+
 static BitStream *BitStream_newFromNum(int bits, unsigned int num)
 {
 	unsigned int mask;
 	int i;
-	char *p;
+	unsigned char *p;
 	BitStream *bstream;
 
 	bstream = BitStream_new();
 	if(bstream == NULL) return NULL;
 
-	bstream->data = (char *)malloc(bits + 1);
-	if(bstream->data == NULL) {
+	if(BitStream_allocate(bstream, bits)) {
 		BitStream_free(bstream);
 		return NULL;
 	}
@@ -57,14 +79,13 @@ static BitStream *BitStream_newFromNum(int bits, unsigned int num)
 	mask = 1 << (bits - 1);
 	for(i=0; i> 1;
 	}
-	*p = '\0';
 
 	return bstream;
 }
@@ -73,14 +94,13 @@ static BitStream *BitStream_newFromBytes(int size, unsigned char *data)
 {
 	unsigned char mask;
 	int i, j;
-	char *p;
+	unsigned char *p;
 	BitStream *bstream;
 
 	bstream = BitStream_new();
 	if(bstream == NULL) return NULL;
 
-	bstream->data = (char *)malloc(size * 8 + 1);
-	if(bstream->data == NULL) {
+	if(BitStream_allocate(bstream, size * 8)) {
 		BitStream_free(bstream);
 		return NULL;
 	}
@@ -90,45 +110,45 @@ static BitStream *BitStream_newFromBytes(int size, unsigned char *data)
 		mask = 0x80;
 		for(j=0; j<8; j++) {
 			if(data[i] & mask) {
-				*p = '1';
+				*p = 1;
 			} else {
-				*p = '0';
+				*p = 0;
 			}
 			p++;
 			mask = mask >> 1;
 		}
 	}
-	*p = '\0';
 
 	return bstream;
 }
 
 int BitStream_append(BitStream *bstream, BitStream *arg)
 {
-	size_t l1, l2;
-	char *data;
+	unsigned char *data;
 
-	if(arg == NULL || arg->data == NULL) {
+	if(arg == NULL) {
 		return -1;
 	}
-	if(bstream->data == NULL) {
-		bstream->data = strdup(arg->data);
-		if(bstream->data == NULL) {
+	if(arg->length == 0) {
+		return 0;
+	}
+	if(bstream->length == 0) {
+		if(BitStream_allocate(bstream, arg->length)) {
 			return -1;
 		}
+		memcpy(bstream->data, arg->data, arg->length);
 		return 0;
 	}
 
-	l1 = strlen(bstream->data);
-	l2 = strlen(arg->data);
-	data = (char *)malloc(l1 + l2 + 1);
+	data = (char *)malloc(bstream->length + arg->length);
 	if(data == NULL) {
 		return -1;
 	}
-	strcpy(data, bstream->data);
-	strcat(data, arg->data);
+	memcpy(data, bstream->data, bstream->length);
+	memcpy(data + bstream->length, arg->data, arg->length);
 
 	free(bstream->data);
+	bstream->length += arg->length;
 	bstream->data = data;
 
 	return 0;
@@ -139,7 +159,7 @@ int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num)
 	BitStream *b;
 	int ret;
 
-	if(bits == 0) return -1;
+	if(bits == 0) return 0;
 
 	b = BitStream_newFromNum(bits, num);
 	if(b == NULL) return -1;
@@ -155,7 +175,7 @@ int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data)
 	BitStream *b;
 	int ret;
 
-	if(size == 0) return -1;
+	if(size == 0) return 0;
 
 	b = BitStream_newFromBytes(size, data);
 	if(b == NULL) return -1;
@@ -166,6 +186,7 @@ int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data)
 	return ret;
 }
 
+/*
 unsigned int BitStream_size(BitStream *bstream)
 {
 	if(bstream == NULL) return 0;
@@ -173,12 +194,13 @@ unsigned int BitStream_size(BitStream *bstream)
 
 	return (int)strlen(bstream->data);
 }
+*/
 
 unsigned char *BitStream_toByte(BitStream *bstream)
 {
 	int i, j, size, bytes;
 	unsigned char *data, v;
-	char *p;
+	unsigned char *p;
 
 	size = BitStream_size(bstream);
 	data = (unsigned char *)malloc((size + 7) / 8);
@@ -193,7 +215,7 @@ unsigned char *BitStream_toByte(BitStream *bstream)
 		v = 0;
 		for(j=0; j<8; j++) {
 			v = v << 1;
-			v |= *p == '1';
+			v |= *p;
 			p++;
 		}
 		data[i] = v;
@@ -202,7 +224,7 @@ unsigned char *BitStream_toByte(BitStream *bstream)
 		v = 0;
 		for(j=0; j<(size & 7); j++) {
 			v = v << 1;
-			v |= *p == '1';
+			v |= *p;
 			p++;
 		}
 		data[bytes] = v;
diff --git a/bitstream.h b/bitstream.h
index d95f6e7a7e..d8a110416a 100644
--- a/bitstream.h
+++ b/bitstream.h
@@ -23,14 +23,15 @@
 #define __BITSTREAM_H__
 
 typedef struct {
-	char *data;
+	int length;
+	unsigned char *data;
 } BitStream;
 
 extern BitStream *BitStream_new(void);
 extern int BitStream_append(BitStream *bstream, BitStream *arg);
 extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num);
 extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data);
-extern unsigned int BitStream_size(BitStream *bstream);
+#define BitStream_size(__bstream__) (__bstream__->length)
 extern unsigned char *BitStream_toByte(BitStream *bstream);
 extern void BitStream_free(BitStream *bstream);
 
diff --git a/tests/common.h b/tests/common.h
index a29d2f6793..469a97ac2c 100644
--- a/tests/common.h
+++ b/tests/common.h
@@ -99,6 +99,24 @@ void report()
 	if(failed) exit(-1);
 }
 
+int cmpBin(char *correct, BitStream *bstream)
+{
+	int len, i, bit;
+
+	len = strlen(correct);
+	if(len != BitStream_size(bstream)) {
+		printf("Length is not match: %d, %d expected.\n", BitStream_size(bstream), len);
+		return -1;
+	}
+
+	for(i=0; idata[i] != bit) return -1;
+	}
+
+	return 0;
+}
+
 char *sprintfBin(int size, unsigned char *data)
 {
 	int i, j;
diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c
index b918c57523..bccc90172d 100644
--- a/tests/test_bitstream.c
+++ b/tests/test_bitstream.c
@@ -12,7 +12,7 @@ void test_num(void)
 	testStart("New from num");
 	bstream = BitStream_new();
 	BitStream_appendNum(bstream, 31, data);
-	testEnd(strncmp(correct, bstream->data, 31));
+	testEnd(cmpBin(correct, bstream));
 
 	BitStream_free(bstream);
 }
@@ -26,7 +26,7 @@ void test_bytes(void)
 	testStart("New from bytes");
 	bstream = BitStream_new();
 	BitStream_appendBytes(bstream, 1, data);
-	testEnd(strncmp(correct, bstream->data, 8));
+	testEnd(cmpBin(correct, bstream));
 	BitStream_free(bstream);
 }
 
@@ -52,7 +52,8 @@ void test_appendBytes(void)
 	data[3] = 0x78;
 	BitStream_appendBytes(bstream, 4, data);
 
-	testEnd(strncmp(correct, bstream->data, 64));
+	testEnd(cmpBin(correct, bstream));
+
 
 	BitStream_free(bstream);
 }
diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c
index 5c8bc0c632..fa7bf9c755 100644
--- a/tests/test_qrinput.c
+++ b/tests/test_qrinput.c
@@ -22,7 +22,7 @@ void test_encodeKanji(void)
 	bstream = QRinput_mergeBitStream(stream);
 	printf("%s\n", correct);
 	printf("%s\n", bstream->data);
-	testEnd(strcmp(correct, bstream->data));
+	testEnd(cmpBin(correct, bstream));
 	QRinput_free(stream);
 	BitStream_free(bstream);
 	free(buf);
@@ -41,7 +41,7 @@ void test_encode8(void)
 	bstream = QRinput_mergeBitStream(stream);
 	printf("%s\n", correct);
 	printf("%s\n", bstream->data);
-	testEnd(strcmp(correct, bstream->data));
+	testEnd(cmpBin(correct, bstream));
 	QRinput_free(stream);
 	BitStream_free(bstream);
 }
@@ -80,7 +80,7 @@ void test_encodeAn(void)
 	bstream = QRinput_mergeBitStream(stream);
 	printf("%s\n", correct);
 	printf("%s\n", bstream->data);
-	testEnd(strcmp(correct, bstream->data));
+	testEnd(cmpBin(correct, bstream));
 	QRinput_free(stream);
 	BitStream_free(bstream);
 }
@@ -111,7 +111,7 @@ void test_encodeNumeric(void)
 	bstream = QRinput_mergeBitStream(stream);
 	printf("%s\n", correct);
 	printf("%s\n", bstream->data);
-	testEnd(strcmp(correct, bstream->data));
+	testEnd(cmpBin(correct, bstream));
 	QRinput_free(stream);
 	BitStream_free(bstream);
 }
@@ -141,17 +141,22 @@ void test_encodeNumericPadded(void)
 {
 	QRinput *stream;
 	char num[9] = "01234567";
-	char correct[] = "000100000010000000001100010101100110000110000000";
+	char *correct;
+	char *correctHead = "000100000010000000001100010101100110000110000000";
 	BitStream *bstream;
-	int flag;
+	int flag, i;
 
 	testStart("Encoding numeric stream. (8 digits)(padded)");
 	stream = QRinput_new();
 	QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
 	bstream = QRinput_getBitStream(stream);
-	flag = strncmp(correct, bstream->data, 48);
-	if(strlen(bstream->data) != 19 * 8)
-		flag |= 0x80;
+	correct = (char *)malloc(19 * 8 + 1);
+	correct[0] = '\0';
+	strcat(correct, correctHead);
+	for(i=0; i<13; i++) {
+		strcat(correct, (i&1)?"00010001":"11101100");
+	}
+	flag = cmpBin(correct, bstream);
 	testEnd(flag);
 
 	QRinput_free(stream);
@@ -162,17 +167,22 @@ void test_encodeNumericPadded2(void)
 {
 	QRinput *stream;
 	char num[8] = "0123456";
-	char correct[] = "000100000001110000001100010101100101100000000000";
+	char *correct;
+	char *correctHead = "000100000001110000001100010101100101100000000000";
 	BitStream *bstream;
-	int flag;
+	int flag, i;
 
 	testStart("Encoding numeric stream. (7 digits)(padded)");
 	stream = QRinput_new();
 	QRinput_append(stream, QR_MODE_NUM, 7, (unsigned char *)num);
 	bstream = QRinput_getBitStream(stream);
-	flag = strncmp(correct, bstream->data, 48);
-	if(strlen(bstream->data) != 19 * 8)
-		flag |= 0x80;
+	correct = (char *)malloc(19 * 8 + 1);
+	correct[0] = '\0';
+	strcat(correct, correctHead);
+	for(i=0; i<13; i++) {
+		strcat(correct, (i&1)?"00010001":"11101100");
+	}
+	flag = cmpBin(correct, bstream);
 	testEnd(flag);
 
 	QRinput_free(stream);
@@ -192,7 +202,7 @@ void test_encodeNumeric2(void)
 	bstream = QRinput_mergeBitStream(stream);
 	printf("%s\n", correct);
 	printf("%s\n", bstream->data);
-	testEnd(strcmp(correct, bstream->data));
+	testEnd(cmpBin(correct, bstream));
 	QRinput_free(stream);
 	BitStream_free(bstream);
 }
@@ -210,7 +220,7 @@ void test_encodeNumeric3(void)
 	bstream = QRinput_mergeBitStream(stream);
 	printf("%s\n", correct);
 	printf("%s\n", bstream->data);
-	testEnd(strcmp(correct, bstream->data));
+	testEnd(cmpBin(correct, bstream));
 	QRinput_free(stream);
 	BitStream_free(bstream);
 }
@@ -246,7 +256,7 @@ void test_encodeAnNum(void)
 	QRinput_append(input, QR_MODE_AN, 11, (unsigned char *)"ABCDEFGHIJK");
 	QRinput_append(input, QR_MODE_NUM, 12, (unsigned char *)"123456789012");
 	bstream = QRinput_mergeBitStream(input);
-	testEndExp(strlen(bstream->data) == 128);
+	testEndExp(BitStream_size(bstream) == 128);
 	QRinput_free(input);
 	BitStream_free(bstream);
 
@@ -254,7 +264,7 @@ void test_encodeAnNum(void)
 	input = QRinput_new();
 	QRinput_append(input, QR_MODE_AN, 23, (unsigned char *)"ABCDEFGHIJK123456789012");
 	bstream = QRinput_mergeBitStream(input);
-	testEndExp(strlen(bstream->data) == 140);
+	testEndExp(BitStream_size(bstream) == 140);
 	QRinput_free(input);
 	BitStream_free(bstream);
 }
@@ -306,7 +316,7 @@ void test_insertStructuredAppendHeader(void)
 	assert_zero(ret, "QRinput_insertStructuredAppendHeader() returns nonzero.\n");
 	bstream = QRinput_mergeBitStream(stream);
 	assert_nonnull(bstream->data, "Bstream->data is null.");
-	assert_zero(strcmp(correct, bstream->data), "bitstream is wrong.");
+	assert_zero(cmpBin(correct, bstream), "bitstream is wrong.");
 	testFinish();
 
 	QRinput_free(stream);
-- 
cgit 0.0.5-2-1-g0f52


From 10f960ef0a278b333c29cb023acbb397d31f86ae Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Fri, 1 May 2009 08:02:32 +0000
Subject:

---
 ChangeLog     |  7 +++++--
 NEWS          | 16 ++++++++++++++++
 README        |  4 ++--
 bitstream.c   |  4 ++--
 bitstream.h   |  2 +-
 configure.ac  |  4 ++--
 mask.c        |  2 +-
 mask.h        |  2 +-
 qrenc.c       |  4 ++--
 qrencode.1.in |  2 +-
 qrencode.h    |  2 +-
 qrinput.c     |  2 +-
 12 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f1f84ff983..332487bcc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009.05.01 Kentaro FUKUCHI 
+	* Bumped vertion to 3.1.0.
+
 2009.04.30 Kentaro FUKUCHI 
 	* bistream.[ch]:
 	  - Internal representation of BitStream has been changed from
@@ -7,7 +10,7 @@
 
 2009.03.25 Kentaro FUKUCHI 
 	* configure.ac:
-	  - Test codes are not compiled by default.
+	  - "--without-tests" has become default setting.
 	* bitstream.[ch]:
 	  - Now functions strictly check return value from malloc() and return
 	    error if it fails.
@@ -39,7 +42,7 @@
 	* configure.ac:
 	  - Now config.h offers "__STATIC" macro becomes "static" when
 	    "--without-tests" is specified. This macro is useful for functions
-		that are called from test programs but not from other library codes.
+		called from test programs but not from other library codes.
 	* qrinput.c:
 	  - Very little performance improvement.
 	* mask.c:
diff --git a/NEWS b/NEWS
index bd3d065df4..9961013e23 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,22 @@
 libqrencode NEWS - Overview of changes
 ======================================
 
+Version 3.1.0 (2009.5.x)
+------------------------
+* Various code cleanups and performance improves.
+* Strict error checks have been added.
+* "--without-tests" has become default setting. Specify "--with-tests" to
+  compile test programs.
+
+Release Note:
+
+This release focuses on the code cleanup and performance improve. Encoding time
+has been improved, drastically in large symbols. Basically this update only
+changes its internal code. The API is not changed, no need to recompile user
+applications that includes only qrencode.h. If your application refers the
+internal data representation (not recommended), see ChangeLog for further
+information.
+
 Version 3.0.3 (2008.6.1)
 ------------------------
 * Portability enhancement. (Thanks to Gavan Fantom)
diff --git a/README b/README
index 30d0842d65..f99ad69bf0 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-libqrencode 3.0.3 - QR Code encoding library
+libqrencode 3.1.0 - QR Code encoding library
 
 GENERAL INFORMATION
 ===================
@@ -73,7 +73,7 @@ You should limit the parameter by your application.
 
 LICENSING INFORMATION
 =====================
-Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi
+Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
 
 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
diff --git a/bitstream.c b/bitstream.c
index 8528e0ca1a..c50aa4ccd0 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Binary sequence class.
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -140,7 +140,7 @@ int BitStream_append(BitStream *bstream, BitStream *arg)
 		return 0;
 	}
 
-	data = (char *)malloc(bstream->length + arg->length);
+	data = (unsigned char *)malloc(bstream->length + arg->length);
 	if(data == NULL) {
 		return -1;
 	}
diff --git a/bitstream.h b/bitstream.h
index d8a110416a..5a5ac90496 100644
--- a/bitstream.h
+++ b/bitstream.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Binary sequence class.
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/configure.ac b/configure.ac
index 7699fe7da5..098e1f71b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,8 @@
 AC_INIT(QRencode)
 
 MAJOR_VERSION=3
-MINOR_VERSION=0
-MICRO_VERSION=3
+MINOR_VERSION=1
+MICRO_VERSION=0
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 AC_SUBST(MAJOR_VERSION)
 AC_SUBST(MINOR_VERSION)
diff --git a/mask.c b/mask.c
index 5be4561135..14f4afe830 100644
--- a/mask.c
+++ b/mask.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Masking.
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/mask.h b/mask.h
index b3b544692e..1c227ab627 100644
--- a/mask.h
+++ b/mask.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Masking.
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrenc.c b/qrenc.c
index c15b38adad..8a7be9baf7 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code encoding tool
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -58,7 +58,7 @@ static void usage(int help, int longopt)
 {
 	fprintf(stderr,
 "qrencode version %s\n"
-"Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi\n", VERSION);
+"Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi\n", VERSION);
 	if(help) {
 		if(longopt) {
 			fprintf(stderr,
diff --git a/qrencode.1.in b/qrencode.1.in
index 08cd13cb83..85b26047bc 100644
--- a/qrencode.1.in
+++ b/qrencode.1.in
@@ -70,4 +70,4 @@ case-insensitive mode.
 Written by Kentaro Fukuchi.
 
 .SH COPYRIGHT
-Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi.
+Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi.
diff --git a/qrencode.h b/qrencode.h
index a7292feb11..0ff2b08143 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -1,7 +1,7 @@
 /**
  * qrencode - QR Code encoder
  *
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrinput.c b/qrinput.c
index 2ca1305a29..7b633c41fe 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * Input data chunk class
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
-- 
cgit 0.0.5-2-1-g0f52


From d725a78369a4914ec641564d7de8a22c32442655 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Wed, 13 May 2009 12:26:05 +0000
Subject: Merged from 3.1.0.

---
 ChangeLog              | 15 +++++++++++++--
 NEWS                   |  1 +
 bitstream.c            | 13 +++----------
 qrinput.c              |  1 +
 tests/test_bitstream.c | 15 +++++++++++++++
 tests/test_qrinput.c   |  2 ++
 6 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 332487bcc3..b7718f4d20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009.05.12 Kentaro FUKUCHI 
+	* bitstream.c:
+	  - BitStream_toByte() had returned non-NULL for an empty BitStream.
+	* tests/test_bitstream.c:
+	  - test_null() has been added.
+	* qrinput.c:
+	  - A possible memory leak has been eliminated. It happend when a wrong
+	    version number was given.
+	* tests/test_qriput.c:
+	  - Memory leaks have been eliminated.
+
 2009.05.01 Kentaro FUKUCHI 
 	* Bumped vertion to 3.1.0.
 
@@ -109,7 +120,7 @@
 
 2008.04.23 Kentaro FUKUCHI 
 	* split.c:
-	  - Split_identifyMode() now uses isdigit() and isalnum macros.
+	  - Split_identifyMode() now uses isdigit() and isalnum() macros.
 	* qrinput.c:
 	  - Error checks have been improved.
 	* qrenc.c, tests/view_qrcode.c:
@@ -128,7 +139,7 @@
 	* qrencode.h:
 	  - QR_MODE_NUL has been added to QRencodeMode. Basically it is used
 	    only by Split_identifyMode().
-	* qrinput.[ch], split.c]:
+	* qrinput.[ch], split.c:
 	  - QRinput_identifyMode() has been moved to split.c, changed to static
 	    and now needs a hint.
 	* split.c:
diff --git a/NEWS b/NEWS
index 9961013e23..01a63dd20f 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Version 3.1.0 (2009.5.x)
 * Strict error checks have been added.
 * "--without-tests" has become default setting. Specify "--with-tests" to
   compile test programs.
+* Some minor bugs have been fixed.
 
 Release Note:
 
diff --git a/bitstream.c b/bitstream.c
index c50aa4ccd0..fe97d44dbc 100644
--- a/bitstream.c
+++ b/bitstream.c
@@ -186,16 +186,6 @@ int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data)
 	return ret;
 }
 
-/*
-unsigned int BitStream_size(BitStream *bstream)
-{
-	if(bstream == NULL) return 0;
-	if(bstream->data == NULL) return 0;
-
-	return (int)strlen(bstream->data);
-}
-*/
-
 unsigned char *BitStream_toByte(BitStream *bstream)
 {
 	int i, j, size, bytes;
@@ -203,6 +193,9 @@ unsigned char *BitStream_toByte(BitStream *bstream)
 	unsigned char *p;
 
 	size = BitStream_size(bstream);
+	if(size == 0) {
+		return NULL;
+	}
 	data = (unsigned char *)malloc((size + 7) / 8);
 	if(data == NULL) {
 		return NULL;
diff --git a/qrinput.c b/qrinput.c
index 7b633c41fe..56f5f45a0e 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -1092,6 +1092,7 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input)
 
 	if(maxbits <= 0) {
 		QRinput_Struct_free(s);
+		QRinput_free(input);
 		return NULL;
 	}
 
diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c
index bccc90172d..8eb0466164 100644
--- a/tests/test_bitstream.c
+++ b/tests/test_bitstream.c
@@ -3,6 +3,20 @@
 #include "common.h"
 #include "../bitstream.h"
 
+void test_null(void)
+{
+	BitStream *bstream;
+
+	testStart("Empty stream");
+	bstream = BitStream_new();
+	assert_zero(BitStream_size(bstream), "Size of empty BitStream is not 0.");
+	assert_null(BitStream_toByte(bstream), "BitStream_toByte returned non-NULL.");
+
+	testFinish();
+
+	BitStream_free(bstream);
+}
+
 void test_num(void)
 {
 	BitStream *bstream;
@@ -82,6 +96,7 @@ void test_toByte(void)
 
 int main(int argc, char **argv)
 {
+	test_null();
 	test_num();
 	test_bytes();
 	test_appendBytes();
diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c
index fa7bf9c755..c032e31441 100644
--- a/tests/test_qrinput.c
+++ b/tests/test_qrinput.c
@@ -159,6 +159,7 @@ void test_encodeNumericPadded(void)
 	flag = cmpBin(correct, bstream);
 	testEnd(flag);
 
+	free(correct);
 	QRinput_free(stream);
 	BitStream_free(bstream);
 }
@@ -185,6 +186,7 @@ void test_encodeNumericPadded2(void)
 	flag = cmpBin(correct, bstream);
 	testEnd(flag);
 
+	free(correct);
 	QRinput_free(stream);
 	BitStream_free(bstream);
 }
-- 
cgit 0.0.5-2-1-g0f52


From 51447782aca2e0f213793cf6d1d3c70bc53be4c7 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 May 2009 02:25:56 +0000
Subject: Break when malloc fails.

---
 mask.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mask.c b/mask.c
index 14f4afe830..01477ef12a 100644
--- a/mask.c
+++ b/mask.c
@@ -271,6 +271,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
 //		n1 = n2 = n3 = n4 = 0;
 		demerit = 0;
 		mask = (unsigned char *)malloc(width * width);
+		if(mask == NULL) break;
 		blacks = maskMakers[i](width, frame, mask);
 		blacks += Mask_writeFormatInformation(width, mask, i, level);
 		blacks = 100 * blacks / (width * width);
-- 
cgit 0.0.5-2-1-g0f52


From b62c82560eecc5610db5ded90f628199679352cb Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 May 2009 02:51:54 +0000
Subject: More return value checks. Mainly for ENOMEM error.

---
 ChangeLog  |   4 ++
 qrencode.c |  18 ++++++--
 qrinput.c  | 138 +++++++++++++++++++++++++++++++++++++++++++++++--------------
 qrspec.c   |  22 ++++++++--
 4 files changed, 145 insertions(+), 37 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b7718f4d20..4c00980b42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009.05.14 Kentaro FUKUCHI 
+	* qrinput.c, qrencode.c, qrspe.c:
+	  - More return value checks. Mainly for ENOMEM error.
+
 2009.05.12 Kentaro FUKUCHI 
 	* bitstream.c:
 	  - BitStream_toByte() had returned non-NULL for an empty BitStream.
diff --git a/qrencode.c b/qrencode.c
index 18d90dc826..845155a4f2 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -218,6 +218,7 @@ static FrameFiller *FrameFiller_new(int width, unsigned char *frame)
 	FrameFiller *filler;
 
 	filler = (FrameFiller *)malloc(sizeof(FrameFiller));
+	if(filler == NULL) return NULL;
 	filler->width = width;
 	filler->frame = frame;
 	filler->x = width - 1;
@@ -348,9 +349,7 @@ void QRcode_free(QRcode *qrcode)
 {
 	if(qrcode == NULL) return;
 
-	if(qrcode->data != NULL) {
-		free(qrcode->data);
-	}
+	free(qrcode->data);
 	free(qrcode);
 }
 
@@ -378,7 +377,16 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask)
 	version = raw->version;
 	width = QRspec_getWidth(version);
 	frame = QRspec_newFrame(version);
+	if(frame == NULL) {
+		QRraw_free(raw);
+		return NULL;
+	}
 	filler = FrameFiller_new(width, frame);
+	if(filler == NULL) {
+		QRraw_free(raw);
+		free(frame);
+		return NULL;
+	}
 
 	/* inteleaved data and ecc codes */
 	for(i=0; idataLength + raw->eccLength; i++) {
@@ -404,6 +412,10 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask)
 	} else {
 		masked = Mask_makeMask(width, frame, mask, input->level);
 	}
+	if(masked == NULL) {
+		free(frame);
+		return NULL;
+	}
 	qrcode = QRcode_new(version, width, masked);
 
 	free(frame);
diff --git a/qrinput.c b/qrinput.c
index 56f5f45a0e..ef1174eb51 100644
--- a/qrinput.c
+++ b/qrinput.c
@@ -254,6 +254,10 @@ QRinput *QRinput_dup(QRinput *input)
 	list = input->head;
 	while(list != NULL) {
 		e = QRinput_List_dup(list);
+		if(e == NULL) {
+			QRinput_free(n);
+			return NULL;
+		}
 		QRinput_appendEntry(n, e);
 		list = list->next;
 	}
@@ -312,38 +316,53 @@ int QRinput_estimateBitsModeNum(int size)
 /**
  * Convert the number data to a bit stream.
  * @param entry
+ * @retval 0 success
+ * @retval -1 an error occurred and errno is set to indeicate the error.
+ *            See Execptions for the details.
+ * @throw ENOMEM unable to allocate memory.
  */
-static void QRinput_encodeModeNum(QRinput_List *entry, int version)
+static int QRinput_encodeModeNum(QRinput_List *entry, int version)
 {
-	int words;
-	int i;
+	int words, i, ret;
 	unsigned int val;
 
 	words = entry->size / 3;
 	entry->bstream = BitStream_new();
+	if(entry->bstream == NULL) return -1;
 
 	val = 0x1;
-	BitStream_appendNum(entry->bstream, 4, val);
+	ret = BitStream_appendNum(entry->bstream, 4, val);
+	if(ret < 0) goto ABORT;
 	
 	val = entry->size;
-	BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val);
+	ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val);
+	if(ret < 0) goto ABORT;
 
 	for(i=0; idata[i*3  ] - '0') * 100;
 		val += (entry->data[i*3+1] - '0') * 10;
 		val += (entry->data[i*3+2] - '0');
 
-		BitStream_appendNum(entry->bstream, 10, val);
+		ret = BitStream_appendNum(entry->bstream, 10, val);
+		if(ret < 0) goto ABORT;
 	}
 
 	if(entry->size - words * 3 == 1) {
 		val = entry->data[words*3] - '0';
-		BitStream_appendNum(entry->bstream, 4, val);
+		ret = BitStream_appendNum(entry->bstream, 4, val);
+		if(ret < 0) goto ABORT;
 	} else if(entry->size - words * 3 == 2) {
 		val  = (entry->data[words*3  ] - '0') * 10;
 		val += (entry->data[words*3+1] - '0');
 		BitStream_appendNum(entry->bstream, 7, val);
+		if(ret < 0) goto ABORT;
 	}
+
+	return 0;
+ABORT:
+	BitStream_free(entry->bstream);
+	entry->bstream = NULL;
+	return -1;
 }
 
 /******************************************************************************
@@ -401,34 +420,48 @@ int QRinput_estimateBitsModeAn(int size)
 /**
  * Convert the alphabet-numeric data to a bit stream.
  * @param entry
+ * @retval 0 success
+ * @retval -1 an error occurred and errno is set to indeicate the error.
+ *            See Execptions for the details.
+ * @throw ENOMEM unable to allocate memory.
  */
-static void QRinput_encodeModeAn(QRinput_List *entry, int version)
+static int QRinput_encodeModeAn(QRinput_List *entry, int version)
 {
-	int words;
-	int i;
+	int words, i, ret;
 	unsigned int val;
 
 	words = entry->size / 2;
 	entry->bstream = BitStream_new();
+	if(entry->bstream == NULL) return -1;
 
 	val = 0x2;
-	BitStream_appendNum(entry->bstream, 4, val);
+	ret = BitStream_appendNum(entry->bstream, 4, val);
+	if(ret < 0) goto ABORT;
 	
 	val = entry->size;
-	BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), val);
+	ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), val);
+	if(ret < 0) goto ABORT;
 
 	for(i=0; idata[i*2  ]) * 45;
 		val += (unsigned int)QRinput_lookAnTable(entry->data[i*2+1]);
 
-		BitStream_appendNum(entry->bstream, 11, val);
+		ret = BitStream_appendNum(entry->bstream, 11, val);
+		if(ret < 0) goto ABORT;
 	}
 
 	if(entry->size & 1) {
 		val = (unsigned int)QRinput_lookAnTable(entry->data[words * 2]);
 
-		BitStream_appendNum(entry->bstream, 6, val);
+		ret = BitStream_appendNum(entry->bstream, 6, val);
+		if(ret < 0) goto ABORT;
 	}
+
+	return 0;
+ABORT:
+	BitStream_free(entry->bstream);
+	entry->bstream = NULL;
+	return -1;
 }
 
 /******************************************************************************
@@ -448,23 +481,37 @@ int QRinput_estimateBitsMode8(int size)
 /**
  * Convert the 8bits data to a bit stream.
  * @param entry
+ * @retval 0 success
+ * @retval -1 an error occurred and errno is set to indeicate the error.
+ *            See Execptions for the details.
+ * @throw ENOMEM unable to allocate memory.
  */
-static void QRinput_encodeMode8(QRinput_List *entry, int version)
+static int QRinput_encodeMode8(QRinput_List *entry, int version)
 {
-	int i;
+	int ret, i;
 	unsigned int val;
 
 	entry->bstream = BitStream_new();
+	if(entry->bstream == NULL) return -1;
 
 	val = 0x4;
-	BitStream_appendNum(entry->bstream, 4, val);
+	ret = BitStream_appendNum(entry->bstream, 4, val);
+	if(ret < 0) goto ABORT;
 	
 	val = entry->size;
-	BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), val);
+	ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), val);
+	if(ret < 0) goto ABORT;
 
 	for(i=0; isize; i++) {
-		BitStream_appendNum(entry->bstream, 8, entry->data[i]);
+		ret = BitStream_appendNum(entry->bstream, 8, entry->data[i]);
+		if(ret < 0) goto ABORT;
 	}
+
+	return 0;
+ABORT:
+	BitStream_free(entry->bstream);
+	entry->bstream = NULL;
+	return -1;
 }
 
 
@@ -509,19 +556,26 @@ static int QRinput_checkModeKanji(int size, const unsigned char *data)
 /**
  * Convert the kanji data to a bit stream.
  * @param entry
+ * @retval 0 success
+ * @retval -1 an error occurred and errno is set to indeicate the error.
+ *            See Execptions for the details.
+ * @throw ENOMEM unable to allocate memory.
  */
-static void QRinput_encodeModeKanji(QRinput_List *entry, int version)
+static int QRinput_encodeModeKanji(QRinput_List *entry, int version)
 {
-	int i;
+	int ret, i;
 	unsigned int val, h;
 
 	entry->bstream = BitStream_new();
+	if(entry->bstream == NULL) return -1;
 
 	val = 0x8;
-	BitStream_appendNum(entry->bstream, 4, val);
+	ret = BitStream_appendNum(entry->bstream, 4, val);
+	if(ret < 0) goto ABORT;
 	
 	val = entry->size / 2;
-	BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), val);
+	ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), val);
+	if(ret < 0) goto ABORT;
 
 	for(i=0; isize; i+=2) {
 		val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1];
@@ -533,8 +587,15 @@ static void QRinput_encodeModeKanji(QRinput_List *entry, int version)
 		h = (val >> 8) * 0xc0;
 		val = (val & 0xff) + h;
 
-		BitStream_appendNum(entry->bstream, 13, val);
+		ret = BitStream_appendNum(entry->bstream, 13, val);
+		if(ret < 0) goto ABORT;
 	}
+
+	return 0;
+ABORT:
+	BitStream_free(entry->bstream);
+	entry->bstream = NULL;
+	return -1;
 }
 
 /******************************************************************************
@@ -544,15 +605,32 @@ static void QRinput_encodeModeKanji(QRinput_List *entry, int version)
 /**
  * Convert a structure symbol code to a bit stream.
  * @param entry
+ * @retval 0 success
+ * @retval -1 an error occurred and errno is set to indeicate the error.
+ *            See Execptions for the details.
+ * @throw ENOMEM unable to allocate memory.
  */
-static void QRinput_encodeModeStructure(QRinput_List *entry, int version)
+static int QRinput_encodeModeStructure(QRinput_List *entry, int version)
 {
+	int ret;
+
 	entry->bstream = BitStream_new();
+	if(entry->bstream == NULL) return -1;
 
-	BitStream_appendNum(entry->bstream, 4, 0x03);
-	BitStream_appendNum(entry->bstream, 4, entry->data[1] - 1);
-	BitStream_appendNum(entry->bstream, 4, entry->data[0] - 1);
-	BitStream_appendNum(entry->bstream, 8, entry->data[2]);
+	ret = BitStream_appendNum(entry->bstream, 4, 0x03);
+	if(ret < 0) goto ABORT;
+	ret = BitStream_appendNum(entry->bstream, 4, entry->data[1] - 1);
+	if(ret < 0) goto ABORT;
+	ret = BitStream_appendNum(entry->bstream, 4, entry->data[0] - 1);
+	if(ret < 0) goto ABORT;
+	ret = BitStream_appendNum(entry->bstream, 8, entry->data[2]);
+	if(ret < 0) goto ABORT;
+
+	return 0;
+ABORT:
+	BitStream_free(entry->bstream);
+	entry->bstream = NULL;
+	return -1;
 }
 
 /******************************************************************************
@@ -731,7 +809,7 @@ int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits)
 /**
  * Convert the input data in the data chunk to a bit stream.
  * @param entry
- * @return number of bits
+ * @return number of bits (>0) or -1 for failure.
  */
 static int QRinput_encodeBitStream(QRinput_List *entry, int version)
 {
diff --git a/qrspec.c b/qrspec.c
index b32b3b8cad..abcc449680 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -291,6 +291,7 @@ QRspec_Alignment *QRspec_getAlignmentPattern(int version)
 	if(version < 2) return NULL;
 
 	al = (QRspec_Alignment *)malloc(sizeof(QRspec_Alignment));
+	if(al == NULL) return NULL;
 
 	width = qrspecCapacity[version].width;
 	d = alignmentPattern[version][1] - alignmentPattern[version][0];
@@ -302,6 +303,10 @@ QRspec_Alignment *QRspec_getAlignmentPattern(int version)
 
 	al->n = w * w - 3;
 	al->pos = (int *)malloc(sizeof(int) * al->n * 2);
+	if(al->pos == NULL) {
+		free(al);
+		return NULL;
+	}
 
 	if(al->n == 1) {
 		al->pos[0] = alignmentPattern[version][0];
@@ -480,6 +485,8 @@ static unsigned char *QRspec_createFrame(int version)
 
 	width = qrspecCapacity[version].width;
 	frame = (unsigned char *)malloc(width * width);
+	if(frame == NULL) return NULL;
+
 	memset(frame, 0, width * width);
 	/* Finder pattern */
 	putFinderPattern(frame, width, 0, 0);
@@ -522,7 +529,10 @@ static unsigned char *QRspec_createFrame(int version)
 	}
 	/* Alignment pattern */
 	alignment = QRspec_getAlignmentPattern(version);
-	if(alignment != NULL) {
+	if(version >= 2) {
+		if(alignment == NULL) {
+			goto ABORT;
+		}
 		for(x=0; xn; x++) {
 			putAlignmentPattern(frame, width,
 					alignment->pos[x*2], alignment->pos[x*2+1]);
@@ -556,6 +566,9 @@ static unsigned char *QRspec_createFrame(int version)
 	frame[width * (width - 8) + 8] = 0x81;
 
 	return frame;
+ABORT:
+	free(frame);
+	return NULL;
 }
 
 unsigned char *QRspec_newFrame(int version)
@@ -568,8 +581,11 @@ unsigned char *QRspec_newFrame(int version)
 	if(frames[version] == NULL) {
 		frames[version] = QRspec_createFrame(version);
 	}
+	if(frames[version] == NULL) return NULL;
+
 	width = qrspecCapacity[version].width;
 	frame = (unsigned char *)malloc(width * width);
+	if(frame == NULL) return NULL;
 	memcpy(frame, frames[version], width * width);
 
 	return frame;
@@ -580,8 +596,6 @@ void QRspec_clearCache(void)
 	int i;
 
 	for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
-		if(frames[i] != NULL) {
-			free(frames[i]);
-		}
+		free(frames[i]);
 	}
 }
-- 
cgit 0.0.5-2-1-g0f52


From 9600e4d116631d293fb0d026de7c8427aa131a5c Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 May 2009 03:05:01 +0000
Subject: QRspec_getEccSpec() now accepts an int array instead to return
 multiple values instead of returning dynamic allocated array.

---
 ChangeLog           |  3 +++
 qrencode.c          | 10 ++--------
 qrspec.c            | 28 +++++++++++-----------------
 qrspec.h            |  5 ++---
 tests/test_qrspec.c | 43 ++++++++++++++++++++-----------------------
 5 files changed, 38 insertions(+), 51 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4c00980b42..f9c87b950d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 2009.05.14 Kentaro FUKUCHI 
 	* qrinput.c, qrencode.c, qrspe.c:
 	  - More return value checks. Mainly for ENOMEM error.
+	* qrspe.[ch], qrencode.c, tests/test_qrspec.c:
+	  - QRspec_getEccSpec() now accepts an int array instead to return multiple
+	    values instead of returning dynamic allocated array.
 
 2009.05.12 Kentaro FUKUCHI 
 	* bitstream.c:
diff --git a/qrencode.c b/qrencode.c
index 845155a4f2..fa8daebe69 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -71,7 +71,7 @@ static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el)
 __STATIC QRRawCode *QRraw_new(QRinput *input)
 {
 	QRRawCode *raw;
-	int *spec;
+	int spec[6];
 	int i;
 	RSblock *rsblock;
 	unsigned char *p;
@@ -83,11 +83,7 @@ __STATIC QRRawCode *QRraw_new(QRinput *input)
 
 	raw = (QRRawCode *)malloc(sizeof(QRRawCode));
 	raw->datacode = p;
-	spec = QRspec_getEccSpec(input->version, input->level);
-	if(spec == NULL) {
-		free(raw);
-		return NULL;
-	}
+	QRspec_getEccSpec(input->version, input->level, spec);
 	raw->version = input->version;
 	raw->blocks = QRspec_rsBlockNum(spec);
 	raw->rsblock = (RSblock *)malloc(sizeof(RSblock) * raw->blocks);
@@ -113,8 +109,6 @@ __STATIC QRRawCode *QRraw_new(QRinput *input)
 	raw->eccLength = QRspec_rsBlockNum(spec) * QRspec_rsEccCodes1(spec);
 	raw->count = 0;
 
-	free(spec);
-
 	return raw;
 }
 
diff --git a/qrspec.c b/qrspec.c
index abcc449680..06bf2bb16f 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -227,35 +227,29 @@ static const int eccTable[QRSPEC_VERSION_MAX+1][4][2] = {
 	{{19,  6}, {18, 31}, {34, 34}, {20, 61}},//40
 };
 
-int *QRspec_getEccSpec(int version, QRecLevel level)
+void QRspec_getEccSpec(int version, QRecLevel level, int spec[6])
 {
 	int b1, b2;
 	int data, ecc;
-	int *array;
 
 	b1 = eccTable[version][level][0];
 	b2 = eccTable[version][level][1];
 	data = QRspec_getDataLength(version, level);
 	ecc  = QRspec_getECCLength(version, level);
 
-	array = (int *)malloc(sizeof(int) * 6);
-	if(array == NULL) return NULL;
-
 	if(b2 == 0) {
-		array[0] = b1;
-		array[1] = data / b1;
-		array[2] = ecc / b1;
-		array[3] = array[4] = array[5] = 0;
+		spec[0] = b1;
+		spec[1] = data / b1;
+		spec[2] = ecc / b1;
+		spec[3] = spec[4] = spec[5] = 0;
 	} else {
-		array[0] = b1;
-		array[1] = data / (b1 + b2);
-		array[2] = ecc  / (b1 + b2);
-		array[3] = b2;
-		array[4] = array[1] + 1;
-		array[5] = (ecc - (array[2] * b1)) / b2;
+		spec[0] = b1;
+		spec[1] = data / (b1 + b2);
+		spec[2] = ecc  / (b1 + b2);
+		spec[3] = b2;
+		spec[4] = spec[1] + 1;
+		spec[5] = (ecc - (spec[2] * b1)) / b2;
 	}
-
-	return array;
 }
 
 /******************************************************************************
diff --git a/qrspec.h b/qrspec.h
index b63b367bc4..c557f36b6a 100644
--- a/qrspec.h
+++ b/qrspec.h
@@ -104,12 +104,11 @@ extern int QRspec_maximumWords(QRencodeMode mode, int version);
  * Return an array of ECC specification.
  * @param version
  * @param level
- * @return an array of ECC specification contains as following:
+ * @param spec an array of ECC specification contains as following:
  * {# of type1 blocks, # of data code, # of ecc code,
  *  # of type2 blocks, # of data code, # of ecc code}
- * It can be freed by calling free().
  */
-int *QRspec_getEccSpec(int version, QRecLevel level);
+void QRspec_getEccSpec(int version, QRecLevel level, int spec[6]);
 
 #define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3])
 #define QRspec_rsBlockNum1(__spec__) (__spec__[0])
diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c
index 61dab54bb2..8c3a7198d4 100644
--- a/tests/test_qrspec.c
+++ b/tests/test_qrspec.c
@@ -8,22 +8,21 @@ void print_eccTable(void)
 	int i, j;
 	int ecc;
 	int data;
-	int *bl;
+	int spec[6];
 
 	for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
 		printf("Version %2d\n", i);
 		for(j=0; j<4; j++) {
-			bl = QRspec_getEccSpec(i, (QRecLevel)j);
-			data = bl[0] * bl[1] + bl[3] * bl[4];
-			ecc  = bl[0] * bl[2] + bl[3] * bl[5];
+			QRspec_getEccSpec(i, (QRecLevel)j, spec);
+			data = spec[0] * spec[1] + spec[3] * spec[4];
+			ecc  = spec[0] * spec[2] + spec[3] * spec[5];
 			printf("%3d\t", ecc);
-			printf("%2d\t", bl[0]);
-			printf("(%3d, %3d)\n", bl[1]+bl[2], bl[1]);
-			if(bl[3]>0) {
-				printf("\t%2d\t", bl[3]);
-				printf("(%3d, %3d)\n", bl[4]+bl[5], bl[4]);
+			printf("%2d\t", spec[0]);
+			printf("(%3d, %3d)\n", spec[1]+spec[2], spec[1]);
+			if(spec[3]>0) {
+				printf("\t%2d\t", spec[3]);
+				printf("(%3d, %3d)\n", spec[4]+spec[5], spec[4]);
 			}
-			free(bl);
 		}
 	}
 }
@@ -34,25 +33,24 @@ void test_eccTable(void)
 	int ecc;
 	int data;
 	int err = 0;
-	int *bl;
+	int spec[6];
 
 	testStart("Checking ECC table.");
 	for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
 		for(j=0; j<4; j++) {
-			bl = QRspec_getEccSpec(i, (QRecLevel)j);
-			data = bl[0] * bl[1] + bl[3] * bl[4];
-			ecc  = bl[0] * bl[2] + bl[3] * bl[5];
+			QRspec_getEccSpec(i, (QRecLevel)j, spec);
+			data = spec[0] * spec[1] + spec[3] * spec[4];
+			ecc  = spec[0] * spec[2] + spec[3] * spec[5];
 			if(data + ecc != QRspec_getDataLength(i, (QRecLevel)j) + QRspec_getECCLength(i, (QRecLevel)j)) {
 				printf("Error in version %d, level %d: invalid size\n", i, j);
-				printf("%d %d %d %d %d %d\n", bl[0], bl[1], bl[2], bl[3], bl[4], bl[5]);
+				printf("%d %d %d %d %d %d\n", spec[0], spec[1], spec[2], spec[3], spec[4], spec[5]);
 				err++;
 			}
 			if(ecc != QRspec_getECCLength(i, (QRecLevel)j)) {
 				printf("Error in version %d, level %d: invalid data\n", i, j);
-				printf("%d %d %d %d %d %d\n", bl[0], bl[1], bl[2], bl[3], bl[4], bl[5]);
+				printf("%d %d %d %d %d %d\n", spec[0], spec[1], spec[2], spec[3], spec[4], spec[5]);
 				err++;
 			}
-			free(bl);
 		}
 	}
 	testEnd(err);
@@ -64,7 +62,7 @@ void test_eccTable2(void)
 	int idx;
 	int err;
 	int terr = 0;
-	int *bl;
+	int spec[6];
 
 	const int correct[7][6] = {
 		{ 8,  1, 0,  2, 60, 38},
@@ -79,17 +77,16 @@ void test_eccTable2(void)
 	testStart("Checking ECC table(2)");
 	for(i=0; i<7; i++) {
 		err = 0;
-		bl = QRspec_getEccSpec(correct[i][0], (QRecLevel)correct[i][1]);
+		QRspec_getEccSpec(correct[i][0], (QRecLevel)correct[i][1], spec);
 		idx = correct[i][2] * 3;
-		if(bl[idx] != correct[i][3]) err++;
-		if(bl[idx+1] + bl[idx+2] != correct[i][4]) err++;
-		if(bl[idx+1] != correct[i][5]) err++;
+		if(spec[idx] != correct[i][3]) err++;
+		if(spec[idx+1] + spec[idx+2] != correct[i][4]) err++;
+		if(spec[idx+1] != correct[i][5]) err++;
 		if(err) {
 			printf("Error in version %d, level %d: invalid data\n",
 					correct[i][0], correct[i][1]);
 			terr++;
 		}
-		free(bl);
 	}
 	testEnd(terr);
 }
-- 
cgit 0.0.5-2-1-g0f52


From 81f7840ac59ed17f8b2dd1a5d6b5f0535b11a99d Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 May 2009 04:55:24 +0000
Subject:

---
 ChangeLog | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f9c87b950d..59a77bc5e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
 	* qrspe.[ch], qrencode.c, tests/test_qrspec.c:
 	  - QRspec_getEccSpec() now accepts an int array instead to return multiple
 	    values instead of returning dynamic allocated array.
+	* mask.c:
+	  - More return value checks from malloc().
 
 2009.05.12 Kentaro FUKUCHI 
 	* bitstream.c:
-- 
cgit 0.0.5-2-1-g0f52


From e05cdc4244ec57da0ac83b26d093997ec788e215 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 May 2009 05:06:38 +0000
Subject: Added "--enable-mudflap" otpion.

---
 ChangeLog    | 2 ++
 configure.ac | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 59a77bc5e3..f833f6269e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
 	    values instead of returning dynamic allocated array.
 	* mask.c:
 	  - More return value checks from malloc().
+	* configure.ac:
+	  - Added "--enable-mudflap" option.
 
 2009.05.12 Kentaro FUKUCHI 
 	* bitstream.c:
diff --git a/configure.ac b/configure.ac
index 098e1f71b0..2e5ff75b92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,6 +68,10 @@ dnl --enable-gcov
 AC_ARG_ENABLE([gcov], [AC_HELP_STRING([--enable-gcov], [generate extra code to write coverage information suitable for gcov [default=no]])],
  [], [enable_gcov=no])
 
+dnl --enable-mudflap
+AC_ARG_ENABLE([mudflap], [AC_HELP_STRING([--enable-mudflap], [generate extra code to check memory leaks [default=no]])],
+ [], [enable_mudflap=no])
+
 dnl set CFLAGS
 CFLAGS="-Wall $CFLAGS"
 
@@ -79,6 +83,11 @@ if test $enable_gcov = yes; then
 	CFLAGS="$CFLAGS --coverage"
 fi
 
+if test $enable_mudflap = yes; then
+	CFLAGS="$CFLAGS -fmudflap"
+	LDFLAGS="$LDFLAGS -lmudflap"
+fi
+
 AC_OUTPUT
 
 echo ""
-- 
cgit 0.0.5-2-1-g0f52


From 489d2fb939f53a8db971c5737cd3b67ee903db13 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 May 2009 05:11:46 +0000
Subject: - Added free_rs_cache() for debug purpose. - More return value checks
 from malloc().

---
 ChangeLog |  4 +++-
 rscode.c  | 18 ++++++++++++++++--
 rscode.h  |  1 +
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f833f6269e..3f9966c15b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,10 +4,12 @@
 	* qrspe.[ch], qrencode.c, tests/test_qrspec.c:
 	  - QRspec_getEccSpec() now accepts an int array instead to return multiple
 	    values instead of returning dynamic allocated array.
-	* mask.c:
+	* mask.c, rscode.c:
 	  - More return value checks from malloc().
 	* configure.ac:
 	  - Added "--enable-mudflap" option.
+	* rscode.[ch]:
+	  - Added free_rs_cache() for debug purpose.
 
 2009.05.12 Kentaro FUKUCHI 
 	* bitstream.c:
diff --git a/rscode.c b/rscode.c
index d0cdd6624e..ef2e59d82a 100644
--- a/rscode.c
+++ b/rscode.c
@@ -52,7 +52,7 @@ struct _RS {
 	struct _RS *next;
 };
 
-RS *rslist = NULL;
+static RS *rslist = NULL;
 
 static inline int modnn(RS *rs, int x){
 	while (x >= rs->nn) {
@@ -211,13 +211,15 @@ RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad)
 		if(rs->fcr != fcr) continue;
 		if(rs->prim != prim) continue;
 
-		return rs;
+		goto DONE;
 	}
 
 	rs = init_rs_char(symsize, gfpoly, fcr, prim, nroots, pad);
+	if(rs == NULL) goto DONE;
 	rs->next = rslist;
 	rslist = rs;
 
+DONE:
 	return rs;
 }
 
@@ -230,6 +232,18 @@ void free_rs_char(RS *rs)
 	free(rs);
 }
 
+void free_rs_cache(void)
+{
+	RS *rs, *next;
+
+	rs = rslist;
+	while(rs != NULL) {
+		next = rs->next;
+		free_rs_char(rs);
+		rs = next;
+	}
+}
+
 /* The guts of the Reed-Solomon encoder, meant to be #included
  * into a function body with the following typedefs, macros and variables supplied
  * according to the code parameters:
diff --git a/rscode.h b/rscode.h
index b4557829da..b4eea35d16 100644
--- a/rscode.h
+++ b/rscode.h
@@ -37,5 +37,6 @@ typedef struct _RS RS;
 extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad);
 extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity);
 extern void free_rs_char(RS *rs);
+extern void free_rs_cache(void);
 
 #endif /* __RSCODE_H__ */
-- 
cgit 0.0.5-2-1-g0f52


From 2aaf42a6008eeadffef45f25274cfb8fa8022926 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 May 2009 05:15:09 +0000
Subject: Call free_rs_cache() at the end of the tests.

---
 ChangeLog             | 2 ++
 tests/test_monkey.c   | 2 ++
 tests/test_qrencode.c | 3 +++
 tests/test_rs.c       | 2 ++
 4 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 3f9966c15b..b8c9799e1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@
 	  - Added "--enable-mudflap" option.
 	* rscode.[ch]:
 	  - Added free_rs_cache() for debug purpose.
+	* tests/test_{monkey,qrencode,rs}.c:
+	  - Call free_rs_cache() at the end of the tests.
 
 2009.05.12 Kentaro FUKUCHI 
 	* bitstream.c:
diff --git a/tests/test_monkey.c b/tests/test_monkey.c
index 46b55257ae..e0a1a4cf2d 100644
--- a/tests/test_monkey.c
+++ b/tests/test_monkey.c
@@ -4,6 +4,7 @@
 #include "../qrinput.h"
 #include "../split.h"
 #include "../qrspec.h"
+#include "../rscode.h"
 
 #define MAX_LENGTH 7091
 static char data[MAX_LENGTH];
@@ -269,6 +270,7 @@ int main(int argc, char **argv)
 	monkey_split_structure(loop);
 
 	QRspec_clearCache();
+	free_rs_cache();
 
 	report();
 
diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c
index 827ee513e5..86b155d752 100644
--- a/tests/test_qrencode.c
+++ b/tests/test_qrencode.c
@@ -5,6 +5,7 @@
 #include "../qrspec.h"
 #include "../qrinput.h"
 #include "../mask.h"
+#include "../rscode.h"
 
 int inputSize(QRinput *input)
 {
@@ -629,6 +630,8 @@ int main(int argc, char **argv)
 	test_struct_semilong();
 
 	QRspec_clearCache();
+	free_rs_cache();
+
 	report();
 
 	return 0;
diff --git a/tests/test_rs.c b/tests/test_rs.c
index 81a36513ec..60e9a48763 100644
--- a/tests/test_rs.c
+++ b/tests/test_rs.c
@@ -3,6 +3,7 @@
 #include "common.h"
 #include "../qrencode_inner.h"
 #include "../qrinput.h"
+#include "../rscode.h"
 
 /* See pp. 73 of JIS X0510:2004 */
 void test_rscode1(void)
@@ -30,6 +31,7 @@ int main(int argc, char **argv)
 {
 	test_rscode1();
 
+	free_rs_cache();
 	report();
 
 	return 0;
-- 
cgit 0.0.5-2-1-g0f52


From 7c7ead77849f324a2c7a2f25563d0a70ad136e8d Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Thu, 14 May 2009 05:18:48 +0000
Subject: QRraw_new() and RSblock_init() have been improved. Eliminated
 unnecessary calls of init_rs().

---
 ChangeLog  |  3 +++
 qrencode.c | 70 ++++++++++++++++++++++++++++++++++++++++----------------------
 2 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b8c9799e1a..3400c3ab0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,9 @@
 	  - Added free_rs_cache() for debug purpose.
 	* tests/test_{monkey,qrencode,rs}.c:
 	  - Call free_rs_cache() at the end of the tests.
+	* qrencode.c:
+	  - QRraw_new() and RSblock_init() have been improved.
+	  - Eliminated unnecessary calls of init_rs().
 
 2009.05.12 Kentaro FUKUCHI 
 	* bitstream.c:
diff --git a/qrencode.c b/qrencode.c
index fa8daebe69..d84bb7f636 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -55,53 +55,73 @@ typedef struct {
 	int b1;
 } QRRawCode;
 
-static void RSblock_init(RSblock *block, int dl, unsigned char *data, int el)
+static int RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int el, RS *rs)
 {
-	RS *rs;
-
 	block->dataLength = dl;
 	block->data = data;
 	block->eccLength = el;
 	block->ecc = (unsigned char *)malloc(el);
+	if(block->ecc == NULL) return -1;
 
-	rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el);
 	encode_rs_char(rs, data, block->ecc);
+
+	return 0;
+}
+
+static void RSblock_init(RSblock *blocks, int spec[6], unsigned char *data)
+{
+	int i;
+	RSblock *block;
+	unsigned char *p;
+	RS *rs;
+	int el, dl;
+
+	dl = QRspec_rsDataCodes1(spec);
+	el = QRspec_rsEccCodes1(spec);
+	rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el);
+	block = blocks;
+	p = data;
+	for(i=0; idatacode = QRinput_getByteStream(input);
+	if(raw->datacode == NULL) {
+		free(raw);
 		return NULL;
 	}
 
-	raw = (QRRawCode *)malloc(sizeof(QRRawCode));
-	raw->datacode = p;
 	QRspec_getEccSpec(input->version, input->level, spec);
+
 	raw->version = input->version;
 	raw->blocks = QRspec_rsBlockNum(spec);
 	raw->rsblock = (RSblock *)malloc(sizeof(RSblock) * raw->blocks);
-
-	rsblock = raw->rsblock;
-	p = raw->datacode;
-	for(i=0; irsblock == NULL) {
+		free(raw->datacode);
+		free(raw);
+		return NULL;
 	}
+	RSblock_init(raw->rsblock, spec, raw->datacode);
 
 	raw->b1 = QRspec_rsBlockNum1(spec);
 	raw->dataLength = QRspec_rsBlockNum1(spec) * QRspec_rsDataCodes1(spec)
-- 
cgit 0.0.5-2-1-g0f52

-- 
cgit 0.0.5-2-1-g0f52


From 8670cd5c6d70f62a409d50376c60184d1a361a1e Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Sat, 16 May 2009 03:04:33 +0000
Subject: Copyright year updated.

---
 qrencode.c | 2 +-
 qrspec.c   | 2 +-
 qrspec.h   | 2 +-
 rscode.c   | 2 +-
 rscode.h   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/qrencode.c b/qrencode.c
index d84bb7f636..1fddca3b54 100644
--- a/qrencode.c
+++ b/qrencode.c
@@ -1,7 +1,7 @@
 /*
  * qrencode - QR Code encoder
  *
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/qrspec.c b/qrspec.c
index 06bf2bb16f..5e9b708ca5 100644
--- a/qrspec.c
+++ b/qrspec.c
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code specification in convenient format. 
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * The following data / specifications are taken from
  * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
diff --git a/qrspec.h b/qrspec.h
index c557f36b6a..04ebb16676 100644
--- a/qrspec.h
+++ b/qrspec.h
@@ -2,7 +2,7 @@
  * qrencode - QR Code encoder
  *
  * QR Code specification in convenient format. 
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/rscode.c b/rscode.c
index ef2e59d82a..35948d9c82 100644
--- a/rscode.c
+++ b/rscode.c
@@ -7,7 +7,7 @@
  * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
  * (libfec is released under the GNU Lesser General Public License.)
  *
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/rscode.h b/rscode.h
index b4eea35d16..aea9400a60 100644
--- a/rscode.h
+++ b/rscode.h
@@ -7,7 +7,7 @@
  * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
  * (libfec is released under the GNU Lesser General Public License.)
  *
- * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi 
+ * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
-- 
cgit 0.0.5-2-1-g0f52


From 8b61f0e9bd45232a7fd0ff268dcb780aae8668c8 Mon Sep 17 00:00:00 2001
From: fukuchi 
Date: Mon, 18 May 2009 10:50:58 +0000
Subject: Merged from 3.1.0 branch.

---
 ChangeLog    | 17 +++++++++++++++--
 Makefile.am  |  4 ++--
 autogen.sh   |  5 +++--
 configure.ac |  1 +
 qrencode.h   | 16 ++++++++--------
 5 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3400c3ab0a..2b49206225 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,18 @@
+2009.05.18 Kentaro FUKUCHI 
+	* Merged from 3.1.0 branch.
+
+2009.05.16 Kentaro FUKUCHI 
+	* qrencode.h:
+	  - Indenting improvement.
+	* Makefile.am:
+	  - qrencode.spec has been added to EXTRA_DIST.
+
 2009.05.14 Kentaro FUKUCHI 
 	* qrinput.c, qrencode.c, qrspe.c:
 	  - More return value checks. Mainly for ENOMEM error.
 	* qrspe.[ch], qrencode.c, tests/test_qrspec.c:
-	  - QRspec_getEccSpec() now accepts an int array instead to return multiple
-	    values instead of returning dynamic allocated array.
+	  - QRspec_getEccSpec() now accepts an int array instead to return
+	    multiple values instead of returning dynamic allocated array.
 	* mask.c, rscode.c:
 	  - More return value checks from malloc().
 	* configure.ac:
@@ -15,6 +24,10 @@
 	* qrencode.c:
 	  - QRraw_new() and RSblock_init() have been improved.
 	  - Eliminated unnecessary calls of init_rs().
+	* autogen.sh, configure.ac:
+	  - Darwin workarounds.
+	* tests/common.h, tests/test_bitstream.c:
+	  - New tests have been added.
 
 2009.05.12 Kentaro FUKUCHI 
 	* bitstream.c:
diff --git a/Makefile.am b/Makefile.am
index 2547f8394b..d8bdd1e6ec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,8 +25,8 @@ pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libqrencode.pc
 
 EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \
-			 Makefile.am tests/Makefile.am qrencode.spec.in qrencode.1.in \
-			 Doxyfile tests/test_all.sh
+			 Makefile.am tests/Makefile.am qrencode.spec.in qrencode.spec \
+			 qrencode.1.in Doxyfile tests/test_all.sh
 
 if BUILD_TOOLS
 bin_PROGRAMS = qrencode
diff --git a/autogen.sh b/autogen.sh
index c5626577a9..d1b1955707 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -10,9 +10,10 @@ fi
 
 if [ -d /usr/local/share/aclocal ]; then
     ACLOCAL_DIR=/usr/local/share/aclocal
-else if [ -d /usr/share/aclocal ]; then
+elif [ -d /opt/local/share/aclocal ]; then
+    ACLOCAL_DIR=/opt/local/share/aclocal
+elif [ -d /usr/share/aclocal ]; then
     ACLOCAL_DIR=/usr/share/aclocal
-    fi
 fi
 
 if [ ! -d use ]; then
diff --git a/configure.ac b/configure.ac
index 2e5ff75b92..9ae82f9da3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,6 +12,7 @@ AC_SUBST(VERSION)
 AC_CONFIG_SRCDIR([qrencode.c])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR(use)
+AC_CONFIG_MACRO_DIR([m4])
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 
diff --git a/qrencode.h b/qrencode.h
index 0ff2b08143..a87af3ce3c 100644
--- a/qrencode.h
+++ b/qrencode.h
@@ -107,12 +107,12 @@ extern "C" {
  * Encoding mode.
  */
 typedef enum {
-	QR_MODE_NUL = -1,	///< Terminator (NUL character)
-	QR_MODE_NUM = 0,	///< Numeric mode
-	QR_MODE_AN,			///< Alphabet-numeric mode
-	QR_MODE_8,			///< 8-bit data mode
-	QR_MODE_KANJI,		///< Kanji (shift-jis) mode
-	QR_MODE_STRUCTURE,	///< Internal use only
+	QR_MODE_NUL = -1,  ///< Terminator (NUL character)
+	QR_MODE_NUM = 0,   ///< Numeric mode
+	QR_MODE_AN,        ///< Alphabet-numeric mode
+	QR_MODE_8,         ///< 8-bit data mode
+	QR_MODE_KANJI,     ///< Kanji (shift-jis) mode
+	QR_MODE_STRUCTURE, ///< Internal use only
 } QRencodeMode;
 
 /**
@@ -308,8 +308,8 @@ extern int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s);
  * 
*/ typedef struct { - int version; ///< version of the symbol - int width; ///< width of the symbol + int version; ///< version of the symbol + int width; ///< width of the symbol unsigned char *data; ///< symbol data } QRcode; -- cgit 0.0.5-2-1-g0f52 From f207e4ab05d33c33418ca71dbe32206d5cb8a730 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 May 2009 10:51:55 +0000 Subject: Merged from 3.1.0 branch. --- tests/common.h | 13 ++++++++++--- tests/test_bitstream.c | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/tests/common.h b/tests/common.h index 469a97ac2c..e902091dd2 100644 --- a/tests/common.h +++ b/tests/common.h @@ -99,11 +99,10 @@ void report() if(failed) exit(-1); } -int cmpBin(char *correct, BitStream *bstream) +int ncmpBin(char *correct, BitStream *bstream, int len) { - int len, i, bit; + int i, bit; - len = strlen(correct); if(len != BitStream_size(bstream)) { printf("Length is not match: %d, %d expected.\n", BitStream_size(bstream), len); return -1; @@ -117,6 +116,14 @@ int cmpBin(char *correct, BitStream *bstream) return 0; } +int cmpBin(char *correct, BitStream *bstream) +{ + int len; + + len = strlen(correct); + return ncmpBin(correct, bstream, len); +} + char *sprintfBin(int size, unsigned char *data) { int i, j; diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 8eb0466164..6719aa0d6a 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -44,6 +44,28 @@ void test_bytes(void) BitStream_free(bstream); } +void test_appendNum(void) +{ + BitStream *bstream; + char correct[] = "10001010111111111111111100010010001101000101011001111000"; + + testStart("Append Num"); + bstream = BitStream_new(); + + BitStream_appendNum(bstream, 8, 0x0000008a); + assert_zero(ncmpBin(correct, bstream, 8), "Internal data is incorrect."); + + BitStream_appendNum(bstream, 16, 0x0000ffff); + assert_zero(ncmpBin(correct, bstream, 24), "Internal data is incorrect."); + + BitStream_appendNum(bstream, 32, 0x12345678); + + assert_zero(cmpBin(correct, bstream), "Internal data is incorrect."); + testFinish(); + + BitStream_free(bstream); +} + void test_appendBytes(void) { BitStream *bstream; @@ -55,10 +77,12 @@ void test_appendBytes(void) data[0] = 0x8a; BitStream_appendBytes(bstream, 1, data); + assert_zero(ncmpBin(correct, bstream, 8), "Internal data is incorrect."); data[0] = 0xff; data[1] = 0xff; BitStream_appendBytes(bstream, 2, data); + assert_zero(ncmpBin(correct, bstream, 24), "Internal data is incorrect."); data[0] = 0x12; data[1] = 0x34; @@ -66,8 +90,8 @@ void test_appendBytes(void) data[3] = 0x78; BitStream_appendBytes(bstream, 4, data); - testEnd(cmpBin(correct, bstream)); - + assert_zero(cmpBin(correct, bstream), "Internal data is incorrect."); + testFinish(); BitStream_free(bstream); } @@ -80,7 +104,7 @@ void test_toByte(void) }; unsigned char *result; - testStart("Convert to byte array"); + testStart("Convert to a byte array"); bstream = BitStream_new(); BitStream_appendBytes(bstream, 1, &correct[0]); @@ -94,13 +118,31 @@ void test_toByte(void) free(result); } +void test_size(void) +{ + BitStream *bstream; + + testStart("size check"); + bstream = BitStream_new(); + assert_equal(BitStream_size(bstream), 0, "Initialized BitStream is not 0 length"); + BitStream_appendNum(bstream, 1, 0); + assert_equal(BitStream_size(bstream), 1, "Size incorrect. (first append)"); + BitStream_appendNum(bstream, 2, 0); + assert_equal(BitStream_size(bstream), 3, "Size incorrect. (second append)"); + testFinish(); + + BitStream_free(bstream); +} + int main(int argc, char **argv) { test_null(); test_num(); test_bytes(); + test_appendNum(); test_appendBytes(); test_toByte(); + test_size(); report(); -- cgit 0.0.5-2-1-g0f52 From 04eeb01135d5db065e942decbc2fd246b09281fc Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 May 2009 11:00:54 +0000 Subject: Code cleaning up. --- mqrspec.c | 20 +++++++++++++++++--- mqrspec.h | 13 +++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/mqrspec.c b/mqrspec.c index 79fb563e8c..855ec0d0c2 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Micor QR Code specification in convenient format. - * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) @@ -28,6 +28,7 @@ #include #include #include +#include #include "mqrspec.h" @@ -111,7 +112,7 @@ int MQRspec_maximumWords(QRencodeMode mode, int version) * Error correction code *****************************************************************************/ -int *MQRspec_getEccSpec(int version, QRecLevel level) +void MQRspec_getEccSpec(int version, QRecLevel level) { #if 0 int data, ecc; @@ -120,7 +121,6 @@ int *MQRspec_getEccSpec(int version, QRecLevel level) data = MQRspec_getDataLength(version, level); ecc = MQRspec_getECCLength(version, level); #endif - return NULL; } /****************************************************************************** @@ -207,6 +207,8 @@ static unsigned char *MQRspec_createFrame(int version) width = mqrspecCapacity[version].width; frame = (unsigned char *)malloc(width * width); + if(frame == NULL) return NULL; + memset(frame, 0, width * width); /* Finder pattern */ putFinderPattern(frame, width, 0, 0); @@ -247,9 +249,21 @@ unsigned char *MQRspec_newFrame(int version) if(frames[version] == NULL) { frames[version] = MQRspec_createFrame(version); } + if(frames[version] == NULL) return NULL; + width = mqrspecCapacity[version].width; frame = (unsigned char *)malloc(width * width); + if(frame == NULL) return NULL; memcpy(frame, frames[version], width * width); return frame; } + +void MQRspec_clearCache(void) +{ + int i; + + for(i=1; i<=MQRSPEC_VERSION_MAX; i++) { + free(frames[i]); + } +} diff --git a/mqrspec.h b/mqrspec.h index c719ceb6dd..c0368b0104 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -105,12 +105,11 @@ extern int MQRspec_maximumWords(QRencodeMode mode, int version); * Return an array of ECC specification. * @param version * @param level - * @return an array of ECC specification contains as following: + * @param spec an array of ECC specification contains as following: * {# of type1 blocks, # of data code, # of ecc code, * # of type2 blocks, # of data code, # of ecc code} - * It can be freed by calling free(). */ -int *MQRspec_getEccSpec(int version, QRecLevel level); +void MQRspec_getEccSpec(int version, QRecLevel level); /****************************************************************************** * Version information pattern @@ -145,10 +144,16 @@ extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level * Return a copy of initialized frame. * When the same version is requested twice or more, a copy of cached frame * is returned. + * WARNING: Thread unsafe!!! * @param version * @return Array of unsigned char. You can free it by free(). */ -/* WARNING: Thread unsafe!!! */ extern unsigned char *MQRspec_newFrame(int version); +/** + * Clear the frame cache. Typically for debug. + * WARNING: Thread unsafe!!! + */ +extern void QRspec_clearCache(void); + #endif /* __QRSPEC_H__ */ -- cgit 0.0.5-2-1-g0f52 From e95358b165a9ff20fa12b35aba4f47b8d7d9c54c Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 May 2009 15:52:14 +0000 Subject: New test tool "create_frame_pattern" has been added. --- ChangeLog | 4 ++ tests/Makefile.am | 6 +- tests/create_frame_pattern.c | 161 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 tests/create_frame_pattern.c diff --git a/ChangeLog b/ChangeLog index 2b49206225..5666bf634d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009.05.20 Kentaro FUKUCHI + * tests/create_frame_pattern.c, tests/Makefile.am: + - New test tool "create_frame_pattern" has been added. + 2009.05.18 Kentaro FUKUCHI * Merged from 3.1.0 branch. diff --git a/tests/Makefile.am b/tests/Makefile.am index f31c5dbc54..baabf98ec7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ endif noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_qrspec test_rs test_qrencode prof_qrencode \ - test_mqrspec test_split test_monkey\ + test_mqrspec test_split test_monkey create_frame_pattern \ $(sdlPROGRAMS) test_qrinput_SOURCES = test_qrinput.c common.h @@ -37,6 +37,10 @@ test_monkey_LDADD = ../libqrencode.la prof_qrencode_SOURCES = prof_qrencode.c prof_qrencode_LDADD = ../libqrencode.la +create_frame_pattern_SOURCES = create_frame_pattern.c +create_frame_pattern_CFLAGS = $(png_CFLAGS) +create_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) + if HAVE_SDL view_qrcode_SOURCES = view_qrcode.c common.h view_qrcode_CFLAGS= $(SDL_CFLAGS) diff --git a/tests/create_frame_pattern.c b/tests/create_frame_pattern.c new file mode 100644 index 0000000000..353cd824af --- /dev/null +++ b/tests/create_frame_pattern.c @@ -0,0 +1,161 @@ +#include +#include +#include +#include "common.h" +#include "../qrspec.h" + +void append_pattern(int version, FILE *fp) +{ + int width; + unsigned char *frame; + + frame = QRspec_newFrame(version); + width = QRspec_getWidth(version); + fwrite(frame, width * width, 1, fp); + free(frame); +} + +static int writePNG(unsigned char *frame, int width, const char *outfile) +{ + FILE *fp; + png_structp png_ptr; + png_infop info_ptr; + unsigned char *row, *p, *q; + int x, y, xx, yy, bit; + int realwidth; + const int margin = 0; + const int size = 1; + + realwidth = (width + margin * 2) * size; + row = (unsigned char *)malloc((realwidth + 7) / 8); + if(row == NULL) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(EXIT_FAILURE); + } + + if(outfile[0] == '-' && outfile[1] == '\0') { + fp = stdout; + } else { + fp = fopen(outfile, "wb"); + if(fp == NULL) { + fprintf(stderr, "Failed to create file: %s\n", outfile); + perror(NULL); + exit(EXIT_FAILURE); + } + } + + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if(png_ptr == NULL) { + fclose(fp); + fprintf(stderr, "Failed to initialize PNG writer.\n"); + exit(EXIT_FAILURE); + } + + info_ptr = png_create_info_struct(png_ptr); + if(info_ptr == NULL) { + fclose(fp); + fprintf(stderr, "Failed to initialize PNG write.\n"); + exit(EXIT_FAILURE); + } + + if(setjmp(png_jmpbuf(png_ptr))) { + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); + fprintf(stderr, "Failed to write PNG image.\n"); + exit(EXIT_FAILURE); + } + + png_init_io(png_ptr, fp); + png_set_IHDR(png_ptr, info_ptr, + realwidth, realwidth, + 1, + PNG_COLOR_TYPE_GRAY, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + png_write_info(png_ptr, info_ptr); + + /* top margin */ + memset(row, 0xff, (realwidth + 7) / 8); + for(y=0; y Date: Wed, 20 May 2009 06:32:16 +0000 Subject: --- tests/create_frame_pattern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/create_frame_pattern.c b/tests/create_frame_pattern.c index 353cd824af..0c39eaeff8 100644 --- a/tests/create_frame_pattern.c +++ b/tests/create_frame_pattern.c @@ -143,7 +143,7 @@ void write_pattern(const char *filename) perror("Failed to open a file to write:"); abort(); } - for(i=1; i Date: Wed, 20 May 2009 15:08:16 +0000 Subject: Merged from 3.1.0. --- ChangeLog | 89 +++++++++++++++- NEWS | 4 +- bitstream.c | 4 +- configure.ac | 2 +- mask.c | 13 +-- qrenc.c | 9 +- qrencode.c | 132 ++++++++++++++++-------- qrencode.h | 13 ++- qrencode_inner.h | 11 +- qrinput.c | 241 ++++++++++++++++++++++++++++--------------- qrinput.h | 22 +--- qrspec.c | 143 ++++++++----------------- qrspec.h | 37 ++----- rscode.c | 2 +- split.c | 7 +- split.h | 7 +- tests/Makefile.am | 2 + tests/common.h | 27 ++++- tests/create_frame_pattern.c | 13 ++- tests/prof_qrencode.c | 5 + tests/test_bitstream.c | 2 +- tests/test_monkey.c | 66 ++++++++++-- tests/test_qrencode.c | 60 +++++++++++ tests/test_qrinput.c | 39 ++++++- tests/test_qrspec.c | 212 +++++++++++++++++++------------------ tests/test_split.c | 2 +- tests/view_qrcode.c | 36 ++++--- 27 files changed, 766 insertions(+), 434 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5666bf634d..4f2bc415a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,20 +1,103 @@ +2009.05.20 Kentaro FUKUCHI + * Merged from 3.1.0 branch. (rev 2248:HEAD) + +2009.05.20 Kentaro FUKUCHI + * qrenc.c, qrinput.c, qrencode.c: + - Some compile warnings cleared. + * qrencode.c, tests/test_qrencode.c: + - NULL check of an input arg has been added to + QRcode_encodeString8bit(). + - NULL check test and empty string test have been added for + QRcode_encodeString8bit(). + * qrinput.h, qrencode_inner.h, split.c: + - Copyright year updates. + * split.[ch]: + - Split_splitStringToQRinput() set errno EINVAL if input string is + NULL or empty. + - Documentation improved. + * qrenc.c: + - perror() is now used to show the details of some errors. + * qrencode.[ch]: + - Some functions now set errno appropriately. + - Typo fixes. + 2009.05.20 Kentaro FUKUCHI * tests/create_frame_pattern.c, tests/Makefile.am: - New test tool "create_frame_pattern" has been added. + * tests/test_qrspec.c: + - test_alignment1() has been replaced with test_newframe(). + test_newframe() compares newly created frames with frame pattern + data created by create_frame_pattern. + * tests/frame, tests/Makefile.am: + - Pattern file "frame" has been added to EXTRA_DIST. + * mask.c: + - Very small improvement. Unnecessary malloc()s are reduced. + * tests/test_qrencode.c: + - Two new tests have been added. + * split.c: + - NULL check and string length check have been added. + * qrspec.c, tests/test_qrinput.c: + - Forgotten padding bits bug has been fixed. (enbugged at 2009.5.18) + - New test for the bug above has been added. + * qrspec.[ch], qrencode_inner.h: + - Some function becomes __STATIC and their declarations have been + moved to qrencode_inner.h. + * tests/prof_qrencode.c: + - Now liberates all heap at the end of the program. + +2009.05.19 Kentaro FUKUCHI + * qrencode.c, qrencode_inner.h: + - calloc() is now used to initialize rsblock. + - Number of malloc()s in RSblock_initBlock() has been integrated to + one malloc() in QRraw_new(). + * rscode.c: + - A very small code improvement. + * qrinput.[ch]: + - More return value checks. + - Code cleanups. + * tests/common.h, tests/test_{split,monkey,qrinput}.c: + - Tests improved. + * qrspec.[ch], tests/test_qrspec.c: + - Code cleanups. + - QRspec_rs{Data,Ecc}Length() have been added. + * tests/view_qrcode.c: + - Code cleanups. + - Disabled mask setting in structured mode. + * tests/common.h: + - assert_nothing() has been added. + * qrinput.c, qrencode.c, tests/test_*.c: + - Various *_free() now allow NULL pointer. (nothing performed) + * qrspec.[ch]: + - Alignment pattern is now put by QRspec_putAlignmentPattern(). + QRspec_getAlignmentPattern() and QRspec_freeAlignment() have been + removed. + +2009.05.18 Kentaro FUKUCHI + * qrencode.c: + - More return value checks. + * bitstream.c: + - BitStream_free() allows NULL pointer (nothing performed). + * qrinput.c: + - QRinput_List_freeEntry() and QRinput_free() allow NULL pointer. + - QRinput_createPaddingBit() has been replaced with + QRinput_appendPaddingBit(). + - QRinput_convertData() now sets errno to EINVAL when input is too + large. + - More return value checks. Mainly for ENOMEM error. 2009.05.18 Kentaro FUKUCHI * Merged from 3.1.0 branch. 2009.05.16 Kentaro FUKUCHI * qrencode.h: - - Indenting improvement. + - Indent improvement. * Makefile.am: - qrencode.spec has been added to EXTRA_DIST. 2009.05.14 Kentaro FUKUCHI * qrinput.c, qrencode.c, qrspe.c: - More return value checks. Mainly for ENOMEM error. - * qrspe.[ch], qrencode.c, tests/test_qrspec.c: + * qrspec.[ch], qrencode.c, tests/test_qrspec.c: - QRspec_getEccSpec() now accepts an int array instead to return multiple values instead of returning dynamic allocated array. * mask.c, rscode.c: @@ -50,7 +133,7 @@ 2009.04.30 Kentaro FUKUCHI * bistream.[ch]: - Internal representation of BitStream has been changed from - NUL-terminated to unsigned char array. + NUL-terminated string to unsigned char array. * tests/common.h, tests/test_{bitstream,qrinput}.c: - Some test sequences have been updated (see above). diff --git a/NEWS b/NEWS index 01a63dd20f..a77a56f8ea 100644 --- a/NEWS +++ b/NEWS @@ -4,10 +4,10 @@ libqrencode NEWS - Overview of changes Version 3.1.0 (2009.5.x) ------------------------ * Various code cleanups and performance improves. -* Strict error checks have been added. +* Strict internal error checks have been added. * "--without-tests" has become default setting. Specify "--with-tests" to compile test programs. -* Some minor bugs have been fixed. +* Some memory leak bugs have been fixed. Release Note: diff --git a/bitstream.c b/bitstream.c index fe97d44dbc..36a8ee6e2b 100644 --- a/bitstream.c +++ b/bitstream.c @@ -228,8 +228,8 @@ unsigned char *BitStream_toByte(BitStream *bstream) void BitStream_free(BitStream *bstream) { - if(bstream->data != NULL) { + if(bstream != NULL) { free(bstream->data); + free(bstream); } - free(bstream); } diff --git a/configure.ac b/configure.ac index 9ae82f9da3..f89ecf08ea 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_INIT(QRencode) MAJOR_VERSION=3 MINOR_VERSION=1 MICRO_VERSION=0 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION +VERSION=$MAJOR_VERSION.$MINOR_VERSION.${MICRO_VERSION}rc1 AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) AC_SUBST(MICRO_VERSION) diff --git a/mask.c b/mask.c index 01477ef12a..9bf1279eff 100644 --- a/mask.c +++ b/mask.c @@ -20,6 +20,7 @@ */ #include +#include #include #include "config.h" #include "qrencode.h" @@ -265,13 +266,13 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) int blacks; int demerit; + mask = (unsigned char *)malloc(width * width); + if(mask == NULL) return NULL; bestMask = NULL; for(i=0; i<8; i++) { // n1 = n2 = n3 = n4 = 0; demerit = 0; - mask = (unsigned char *)malloc(width * width); - if(mask == NULL) break; blacks = maskMakers[i](width, frame, mask); blacks += Mask_writeFormatInformation(width, mask, i, level); blacks = 100 * blacks / (width * width); @@ -285,11 +286,11 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) if(bestMask != NULL) { free(bestMask); } - bestMask = mask; - } else { - free(mask); + bestMask = (unsigned char *)malloc(width * width); + if(bestMask == NULL) break; + memcpy(bestMask, mask, width * width); } } - + free(mask); return bestMask; } diff --git a/qrenc.c b/qrenc.c index 8a7be9baf7..c68aec3178 100644 --- a/qrenc.c +++ b/qrenc.c @@ -149,7 +149,7 @@ static char *readStdin(void) static int writePNG(QRcode *qrcode, const char *outfile) { - FILE *fp; + static FILE *fp; // avoid clobbering by setjmp. png_structp png_ptr; png_infop info_ptr; unsigned char *row, *p, *q; @@ -176,21 +176,18 @@ static int writePNG(QRcode *qrcode, const char *outfile) png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if(png_ptr == NULL) { - fclose(fp); fprintf(stderr, "Failed to initialize PNG writer.\n"); exit(EXIT_FAILURE); } info_ptr = png_create_info_struct(png_ptr); if(info_ptr == NULL) { - fclose(fp); fprintf(stderr, "Failed to initialize PNG write.\n"); exit(EXIT_FAILURE); } if(setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); fprintf(stderr, "Failed to write PNG image.\n"); exit(EXIT_FAILURE); } @@ -268,7 +265,7 @@ static void qrencode(const char *intext, const char *outfile) qrcode = encode(intext); if(qrcode == NULL) { - fprintf(stderr, "Failed to encode the input data.\n"); + perror("Failed to encode the input data:"); exit(EXIT_FAILURE); } writePNG(qrcode, outfile); @@ -310,7 +307,7 @@ static void qrencodeStructured(const char *intext, const char *outfile) qrlist = encodeStructured(intext); if(qrlist == NULL) { - fprintf(stderr, "Failed to encode the input data.\n"); + perror("Failed to encode the input data:"); exit(EXIT_FAILURE); } diff --git a/qrencode.c b/qrencode.c index 1fddca3b54..765c449b47 100644 --- a/qrencode.c +++ b/qrencode.c @@ -47,6 +47,7 @@ typedef struct { typedef struct { int version; unsigned char *datacode; + unsigned char *ecccode; int blocks; RSblock *rsblock; int count; @@ -55,52 +56,60 @@ typedef struct { int b1; } QRRawCode; -static int RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int el, RS *rs) +static void RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int el, unsigned char *ecc, RS *rs) { block->dataLength = dl; block->data = data; block->eccLength = el; - block->ecc = (unsigned char *)malloc(el); - if(block->ecc == NULL) return -1; + block->ecc = ecc; - encode_rs_char(rs, data, block->ecc); - - return 0; + encode_rs_char(rs, data, ecc); } -static void RSblock_init(RSblock *blocks, int spec[6], unsigned char *data) +static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsigned char *ecc) { int i; RSblock *block; - unsigned char *p; + unsigned char *dp, *ep; RS *rs; int el, dl; dl = QRspec_rsDataCodes1(spec); el = QRspec_rsEccCodes1(spec); rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); + if(rs == NULL) return -1; + block = blocks; - p = data; + dp = data; + ep = ecc; for(i=0; iversion, input->level, spec); raw->version = input->version; - raw->blocks = QRspec_rsBlockNum(spec); - raw->rsblock = (RSblock *)malloc(sizeof(RSblock) * raw->blocks); - if(raw->rsblock == NULL) { + raw->b1 = QRspec_rsBlockNum1(spec); + raw->dataLength = QRspec_rsDataLength(spec); + raw->eccLength = QRspec_rsEccLength(spec); + raw->ecccode = (unsigned char *)malloc(raw->eccLength); + if(raw->ecccode == NULL) { free(raw->datacode); free(raw); return NULL; } - RSblock_init(raw->rsblock, spec, raw->datacode); - raw->b1 = QRspec_rsBlockNum1(spec); - raw->dataLength = QRspec_rsBlockNum1(spec) * QRspec_rsDataCodes1(spec) - + QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec); - raw->eccLength = QRspec_rsBlockNum(spec) * QRspec_rsEccCodes1(spec); + raw->blocks = QRspec_rsBlockNum(spec); + raw->rsblock = (RSblock *)calloc(sizeof(RSblock), raw->blocks); + if(raw->rsblock == NULL) { + QRraw_free(raw); + return NULL; + } + ret = RSblock_init(raw->rsblock, spec, raw->datacode, raw->ecccode); + if(ret < 0) { + QRraw_free(raw); + return NULL; + } + raw->count = 0; return raw; @@ -163,14 +181,14 @@ __STATIC unsigned char QRraw_getCode(QRRawCode *raw) __STATIC void QRraw_free(QRRawCode *raw) { - int i; - - free(raw->datacode); - for(i=0; iblocks; i++) { - free(raw->rsblock[i].ecc); + if(raw != NULL) { + free(raw->datacode); + free(raw->ecccode); + if(raw->rsblock != NULL) { + free(raw->rsblock); + } + free(raw); } - free(raw->rsblock); - free(raw); } /****************************************************************************** @@ -352,6 +370,8 @@ static QRcode *QRcode_new(int version, int width, unsigned char *data) QRcode *qrcode; qrcode = (QRcode *)malloc(sizeof(QRcode)); + if(qrcode == NULL) return NULL; + qrcode->version = version; qrcode->width = width; qrcode->data = data; @@ -361,10 +381,10 @@ static QRcode *QRcode_new(int version, int width, unsigned char *data) void QRcode_free(QRcode *qrcode) { - if(qrcode == NULL) return; - - free(qrcode->data); - free(qrcode); + if(qrcode != NULL) { + free(qrcode->data); + free(qrcode); + } } __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) @@ -380,7 +400,7 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) errno = EINVAL; return NULL; } - if(input->level < QR_ECLEVEL_L || input->level > QR_ECLEVEL_H) { + if(input->level > QR_ECLEVEL_H) { errno = EINVAL; return NULL; } @@ -446,11 +466,21 @@ QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level { QRinput *input; QRcode *code; + int ret; + + if(string == NULL) { + errno = EINVAL; + return NULL; + } input = QRinput_new2(version, level); if(input == NULL) return NULL; - QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string); + ret = QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string); + if(ret < 0) { + QRinput_free(input); + return NULL; + } code = QRcode_encodeInput(input); QRinput_free(input); @@ -502,8 +532,10 @@ static QRcode_List *QRcode_List_newEntry(void) static void QRcode_List_freeEntry(QRcode_List *entry) { - if(entry->code != NULL) QRcode_free(entry->code); - free(entry); + if(entry != NULL) { + QRcode_free(entry->code); + free(entry); + } } void QRcode_List_free(QRcode_List *qrlist) @@ -548,25 +580,32 @@ QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s) { QRcode_List *head = NULL; QRcode_List *tail = NULL; + QRcode_List *entry; QRinput_InputList *list = s->head; while(list != NULL) { if(head == NULL) { - head = QRcode_List_newEntry(); + entry = QRcode_List_newEntry(); + if(entry == NULL) goto ABORT; + head = entry; tail = head; } else { - tail->next = QRcode_List_newEntry(); + entry = QRcode_List_newEntry(); + if(entry == NULL) goto ABORT; + tail->next = entry; tail = tail->next; } tail->code = QRcode_encodeInput(list->input); if(tail->code == NULL) { - QRcode_List_free(head); - return NULL; + goto ABORT; } list = list->next; } return head; +ABORT: + QRcode_List_free(head); + return NULL; } static QRcode_List *QRcode_encodeInputToStructured(QRinput *input) @@ -589,7 +628,10 @@ QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRcode_List *codes; int ret; - if(version <= 0) return NULL; + if(version <= 0) { + errno = EINVAL; + return NULL; + } input = QRinput_new2(version, level); if(input == NULL) return NULL; @@ -611,8 +653,12 @@ QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRec QRcode_List *codes; int ret; - if(version <= 0) return NULL; + if(version <= 0) { + errno = EINVAL; + return NULL; + } if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) { + errno = EINVAL; return NULL; } diff --git a/qrencode.h b/qrencode.h index a87af3ce3c..342df3bd6e 100644 --- a/qrencode.h +++ b/qrencode.h @@ -107,7 +107,7 @@ extern "C" { * Encoding mode. */ typedef enum { - QR_MODE_NUL = -1, ///< Terminator (NUL character) + QR_MODE_NUL = -1, ///< Terminator (NUL character). Internal use only QR_MODE_NUM = 0, ///< Numeric mode QR_MODE_AN, ///< Alphabet-numeric mode QR_MODE_8, ///< 8-bit data mode @@ -244,7 +244,7 @@ extern void QRinput_Struct_setParity(QRinput_Struct *s, unsigned char parity); /** * Append a QRinput object to the set. - * @warning never append the same QRinput object twice. + * @warning never append the same QRinput object twice or more. * @param s structured input object. * @param input an input object. * @retval >0 number of input objects in the structure. @@ -361,7 +361,7 @@ extern QRcode *QRcode_encodeInput(QRinput *input); extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); /** - * Same to ::QRcode_qncodeString, but encode whole data in 8-bit mode. + * Same to QRcode_encodeString(), but encode whole data in 8-bit mode. * @warning This function is THREAD UNSAFE. */ extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level); @@ -393,12 +393,15 @@ extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s); * non-alphanumerical characters will be encoded as is. If you want * to embed UTF-8 string, choose this. * @param casesensitive case-sensitive(1) or not(0). - * @return a singly-linked list of QRcode. + * @return a singly-linked list of QRcode. On error, NULL is returned, and + * errno is set to indicate the error. See Exceptions for the details. + * @throw EINVAL invalid input object. + * @throw ENOMEM unable to allocate memory for input objects. */ extern QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); /** - * Same to QRcode_qncodeStringStructured, but encode whole data in 8-bit mode. + * Same to QRcode_encodeStringStructured(), but encode whole data in 8-bit mode. * @warning This function is THREAD UNSAFE. */ extern QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level); diff --git a/qrencode_inner.h b/qrencode_inner.h index 608f09d2e7..b6d4990342 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Header for test use - * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,13 @@ /** * This header file includes definitions for test use. */ +extern BitStream *QRinput_mergeBitStream(QRinput *input); +extern BitStream *QRinput_getBitStream(QRinput *input); +extern int QRinput_estimateBitStreamSize(QRinput *input, int version); +extern int QRinput_splitEntry(QRinput_List *entry, int bytes); +extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); +extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); + /****************************************************************************** * Raw code @@ -40,6 +47,7 @@ typedef struct { typedef struct { int version; unsigned char *datacode; + unsigned char *ecccode; int blocks; RSblock *rsblock; int count; @@ -79,6 +87,7 @@ extern unsigned char *FrameFiller_fillerTest(int version); *****************************************************************************/ extern QRcode *QRcode_encodeMask(QRinput *input, int mask); + /****************************************************************************** * Mask *****************************************************************************/ diff --git a/qrinput.c b/qrinput.c index ef1174eb51..cc10e5ab72 100644 --- a/qrinput.c +++ b/qrinput.c @@ -60,18 +60,13 @@ static QRinput_List *QRinput_List_newEntry(QRencodeMode mode, int size, const un return entry; } -static QRinput_List *QRinput_List_freeEntry(QRinput_List *entry) +static void QRinput_List_freeEntry(QRinput_List *entry) { - QRinput_List *next; - - next = entry->next; - free(entry->data); - if(entry->bstream) { + if(entry != NULL) { + free(entry->data); BitStream_free(entry->bstream); + free(entry); } - free(entry); - - return next; } static QRinput_List *QRinput_List_dup(QRinput_List *entry) @@ -108,7 +103,7 @@ QRinput *QRinput_new2(int version, QRecLevel level) { QRinput *input; - if(version < 0 || version > QRSPEC_VERSION_MAX || level < QR_ECLEVEL_L || level > QR_ECLEVEL_H) { + if(version < 0 || version > QRSPEC_VERSION_MAX || level > QR_ECLEVEL_H) { errno = EINVAL; return NULL; } @@ -148,7 +143,7 @@ QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input) int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level) { - if(level < QR_ECLEVEL_L || level > QR_ECLEVEL_H) { + if(level > QR_ECLEVEL_H) { errno = EINVAL; return -1; } @@ -184,7 +179,18 @@ int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned c return 0; } -int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity) +/** + * Insert a structured-append header to the head of the input data. + * @param input input data. + * @param size number of structured symbols. + * @param index index number of the symbol. (1 <= index <= size) + * @param parity parity among input data. (NOTE: each symbol of a set of structured symbols has the same parity data) + * @retval 0 success. + * @retval -1 error occurred and errno is set to indeicate the error. See Execptions for the details. + * @throw EINVAL invalid parameter. + * @throw ENOMEM unable to allocate memory. + */ +__STATIC int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity) { QRinput_List *entry; unsigned char buf[3]; @@ -214,14 +220,17 @@ int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, un void QRinput_free(QRinput *input) { - QRinput_List *list; - - list = input->head; - while(list != NULL) { - list = QRinput_List_freeEntry(list); + QRinput_List *list, *next; + + if(input != NULL) { + list = input->head; + while(list != NULL) { + next = list->next; + QRinput_List_freeEntry(list); + list = next; + } + free(input); } - - free(input); } static unsigned char QRinput_calcParity(QRinput *input) @@ -369,7 +378,7 @@ ABORT: * Alphabet-numeric data *****************************************************************************/ -const signed char QRinput_anTable[] = { +const signed char QRinput_anTable[128] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, @@ -610,7 +619,7 @@ ABORT: * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ -static int QRinput_encodeModeStructure(QRinput_List *entry, int version) +static int QRinput_encodeModeStructure(QRinput_List *entry) { int ret; @@ -716,7 +725,7 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version * @param version version of the symbol * @return number of bits */ -int QRinput_estimateBitStreamSize(QRinput *input, int version) +__STATIC int QRinput_estimateBitStreamSize(QRinput *input, int version) { QRinput_List *list; int bits = 0; @@ -760,7 +769,7 @@ static int QRinput_estimateVersion(QRinput *input) * @param bits * @return required length of code words in bytes. */ -int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) +__STATIC int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) { int payload, size, chunks, remain, maxsize; @@ -813,8 +822,8 @@ int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) */ static int QRinput_encodeBitStream(QRinput_List *entry, int version) { - int words; - QRinput_List *st1, *st2; + int words, ret; + QRinput_List *st1 = NULL, *st2 = NULL; if(entry->bstream != NULL) { BitStream_free(entry->bstream); @@ -824,56 +833,75 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version) words = QRspec_maximumWords(entry->mode, version); if(entry->size > words) { st1 = QRinput_List_newEntry(entry->mode, words, entry->data); + if(st1 == NULL) goto ABORT; st2 = QRinput_List_newEntry(entry->mode, entry->size - words, &entry->data[words]); - QRinput_encodeBitStream(st1, version); - QRinput_encodeBitStream(st2, version); + if(st2 == NULL) goto ABORT; + + ret = QRinput_encodeBitStream(st1, version); + if(ret < 0) goto ABORT; + ret = QRinput_encodeBitStream(st2, version); + if(ret < 0) goto ABORT; entry->bstream = BitStream_new(); - BitStream_append(entry->bstream, st1->bstream); - BitStream_append(entry->bstream, st2->bstream); + if(entry->bstream == NULL) goto ABORT; + ret = BitStream_append(entry->bstream, st1->bstream); + if(ret < 0) goto ABORT; + ret = BitStream_append(entry->bstream, st2->bstream); + if(ret < 0) goto ABORT; QRinput_List_freeEntry(st1); QRinput_List_freeEntry(st2); } else { + ret = 0; switch(entry->mode) { case QR_MODE_NUM: - QRinput_encodeModeNum(entry, version); + ret = QRinput_encodeModeNum(entry, version); break; case QR_MODE_AN: - QRinput_encodeModeAn(entry, version); + ret = QRinput_encodeModeAn(entry, version); break; case QR_MODE_8: - QRinput_encodeMode8(entry, version); + ret = QRinput_encodeMode8(entry, version); break; case QR_MODE_KANJI: - QRinput_encodeModeKanji(entry, version); + ret = QRinput_encodeModeKanji(entry, version); break; case QR_MODE_STRUCTURE: - QRinput_encodeModeStructure(entry, version); + ret = QRinput_encodeModeStructure(entry); break; default: break; } + if(ret < 0) return -1; } return BitStream_size(entry->bstream); +ABORT: + QRinput_List_freeEntry(st1); + QRinput_List_freeEntry(st2); + return -1; } /** * Convert the input data to a bit stream. * @param input input data. - * @return length of the bit stream. + * @retval 0 success + * @retval -1 an error occurred and errno is set to indeicate the error. + * See Execptions for the details. + * @throw ENOMEM unable to allocate memory. */ static int QRinput_createBitStream(QRinput *input) { QRinput_List *list; - int bits = 0; + int bits, total = 0; list = input->head; while(list != NULL) { - bits += QRinput_encodeBitStream(list, input->version); + bits = QRinput_encodeBitStream(list, input->version); + if(bits < 0) return -1; + total += bits; list = list->next; } - return bits; + return total; } /** @@ -881,7 +909,11 @@ static int QRinput_createBitStream(QRinput *input) * When the version number is given and that is not sufficient, it is increased * automatically. * @param input input data. - * @return -1 if the input data was too large. Otherwise 0. + * @retval 0 success + * @retval -1 an error occurred and errno is set to indeicate the error. + * See Execptions for the details. + * @throw ENOMEM unable to allocate memory. + * @throw EINVAL input is too large. */ static int QRinput_convertData(QRinput *input) { @@ -895,8 +927,10 @@ static int QRinput_convertData(QRinput *input) for(;;) { bits = QRinput_createBitStream(input); + if(bits < 0) return -1; ver = QRspec_getMinimumVersion((bits + 7) / 8, input->level); if(ver < 0) { + errno = EINVAL; return -1; } else if(ver > QRinput_getVersion(input)) { QRinput_setVersion(input, ver); @@ -909,40 +943,64 @@ static int QRinput_convertData(QRinput *input) } /** - * Create padding bits for the input data. + * Append padding bits for the input data. + * @param bstream Bitstream to be appended. * @param input input data. - * @param size size of merged input bit stream. - * @return padding bit stream. + * @retval 0 success + * @retval -1 an error occurred and errno is set to indeicate the error. + * See Execptions for the details. + * @throw ENOMEM unable to allocate memory. */ -__STATIC BitStream *QRinput_createPaddingBit(QRinput *input, int bits) +static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) { - int maxbits, words, maxwords, i; - BitStream *bstream; + int bits, maxbits, words, maxwords, i, ret; + BitStream *padding; + unsigned char *padbuf; + int padlen; + bits = BitStream_size(bstream); maxwords = QRspec_getDataLength(input->version, input->level); maxbits = maxwords * 8; if(maxbits == bits) { - return NULL; + return 0; } if(maxbits - bits < 5) { - bstream = BitStream_new(); - BitStream_appendNum(bstream, maxbits - bits, 0); - return bstream; + ret = BitStream_appendNum(bstream, maxbits - bits, 0); + goto DONE; } bits += 4; words = (bits + 7) / 8; - bstream = BitStream_new(); - BitStream_appendNum(bstream, words * 8 - bits + 4, 0); - - for(i=0; i 1) { + padbuf = (unsigned char *)malloc(padlen); + if(padbuf == NULL) { + ret = -1; + goto DONE; + } + for(i=0; ihead; while(list != NULL) { - BitStream_append(bstream, list->bstream); + ret = BitStream_append(bstream, list->bstream); + if(ret < 0) { + BitStream_free(bstream); + return NULL; + } list = list->next; } @@ -978,19 +1041,19 @@ BitStream *QRinput_mergeBitStream(QRinput *input) * @return padded merged bit stream */ -BitStream *QRinput_getBitStream(QRinput *input) +__STATIC BitStream *QRinput_getBitStream(QRinput *input) { BitStream *bstream; - BitStream *padding; + int ret; bstream = QRinput_mergeBitStream(input); if(bstream == NULL) { return NULL; } - padding = QRinput_createPaddingBit(input, BitStream_size(bstream)); - if(padding != NULL) { - BitStream_append(bstream, padding); - BitStream_free(padding); + ret = QRinput_appendPaddingBit(bstream, input); + if(ret < 0) { + BitStream_free(bstream); + return NULL; } return bstream; @@ -1034,15 +1097,12 @@ static QRinput_InputList *QRinput_InputList_newEntry(QRinput *input) return entry; } -static QRinput_InputList *QRinput_InputList_freeEntry(QRinput_InputList *entry) +static void QRinput_InputList_freeEntry(QRinput_InputList *entry) { - QRinput_InputList *next; - - next = entry->next; - QRinput_free(entry->input); - free(entry); - - return next; + if(entry != NULL) { + QRinput_free(entry->input); + free(entry); + } } QRinput_Struct *QRinput_Struct_new(void) @@ -1086,14 +1146,17 @@ int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input) void QRinput_Struct_free(QRinput_Struct *s) { - QRinput_InputList *list; + QRinput_InputList *list, *next; - list = s->head; - while(list != NULL) { - list = QRinput_InputList_freeEntry(list); + if(s != NULL) { + list = s->head; + while(list != NULL) { + next = list->next; + QRinput_InputList_freeEntry(list); + list = next; + } + free(s); } - - free(s); } static unsigned char QRinput_Struct_calcParity(QRinput_Struct *s) @@ -1127,7 +1190,7 @@ static int QRinput_List_shrinkEntry(QRinput_List *entry, int bytes) return 0; } -int QRinput_splitEntry(QRinput_List *entry, int bytes) +__STATIC int QRinput_splitEntry(QRinput_List *entry, int bytes) { QRinput_List *e; int ret; @@ -1153,7 +1216,7 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) { QRinput *p; QRinput_Struct *s; - int bits, maxbits, nextbits, bytes; + int bits, maxbits, nextbits, bytes, ret; QRinput_List *list, *next, *prev; s = QRinput_Struct_new(); @@ -1180,19 +1243,23 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) while(list != NULL) { nextbits = QRinput_estimateBitStreamSizeOfEntry(list, input->version); if(bits + nextbits <= maxbits) { - bits += QRinput_encodeBitStream(list, input->version); + ret = QRinput_encodeBitStream(list, input->version); + if(ret < 0) goto ABORT; + bits += ret; prev = list; list = list->next; } else { bytes = QRinput_lengthOfCode(list->mode, input->version, maxbits - bits); if(bytes > 0) { /* Splits this entry into 2 entries. */ - QRinput_splitEntry(list, bytes); + ret = QRinput_splitEntry(list, bytes); + if(ret < 0) goto ABORT; /* First half is the tail of the current input. */ next = list->next; list->next = NULL; /* Second half is the head of the next input, p.*/ p = QRinput_new2(input->version, input->level); + if(p == NULL) goto ABORT; p->head = next; /* Renew QRinput.tail. */ p->tail = input->tail; @@ -1204,11 +1271,13 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) /* Current entry will go to the next input. */ prev->next = NULL; p = QRinput_new2(input->version, input->level); + if(p == NULL) goto ABORT; p->head = list; p->tail = input->tail; input->tail = prev; } - QRinput_Struct_appendInput(s, input); + ret = QRinput_Struct_appendInput(s, input); + if(ret < 0) goto ABORT; input = p; bits = 0; } @@ -1219,12 +1288,18 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) errno = ERANGE; return NULL; } - if(QRinput_Struct_insertStructuredAppendHeaders(s) < 0) { + ret = QRinput_Struct_insertStructuredAppendHeaders(s); + if(ret < 0) { QRinput_Struct_free(s); return NULL; } return s; + +ABORT: + QRinput_free(input); + QRinput_Struct_free(s); + return NULL; } int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s) diff --git a/qrinput.h b/qrinput.h index 3c0211a165..21ced70430 100644 --- a/qrinput.h +++ b/qrinput.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -65,19 +65,6 @@ struct _QRinput_Struct { QRinput_InputList *tail; }; -/** - * Insert a structured-append header to the head of the input data. - * @param input input data. - * @param size number of structured symbols. - * @param index index number of the symbol. (1 <= index <= size) - * @param parity parity among input data. (NOTE: each symbol of a set of structured symbols has the same parity data) - * @retval 0 success. - * @retval -1 error occurred and errno is set to indeicate the error. See Execptions for the details. - * @throw EINVAL invalid parameter. - * @throw ENOMEM unable to allocate memory. - */ -extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); - /** * Pack all bit streams padding bits into a byte array. * @param input input data. @@ -91,14 +78,9 @@ extern int QRinput_estimateBitsModeAn(int size); extern int QRinput_estimateBitsMode8(int size); extern int QRinput_estimateBitsModeKanji(int size); -extern int QRinput_estimateBitStreamSize(QRinput *input, int version); -extern BitStream *QRinput_mergeBitStream(QRinput *input); -extern BitStream *QRinput_getBitStream(QRinput *input); -extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); extern QRinput *QRinput_dup(QRinput *input); -extern int QRinput_splitEntry(QRinput_List *entry, int bytes); -extern const signed char QRinput_anTable[]; +extern const signed char QRinput_anTable[128]; /** * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). diff --git a/qrspec.c b/qrspec.c index 5e9b708ca5..1a04a95423 100644 --- a/qrspec.c +++ b/qrspec.c @@ -30,6 +30,7 @@ #include #include +#include "config.h" #include "qrspec.h" /****************************************************************************** @@ -227,7 +228,7 @@ static const int eccTable[QRSPEC_VERSION_MAX+1][4][2] = { {{19, 6}, {18, 31}, {34, 34}, {20, 61}},//40 }; -void QRspec_getEccSpec(int version, QRecLevel level, int spec[6]) +void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]) { int b1, b2; int data, ecc; @@ -241,14 +242,13 @@ void QRspec_getEccSpec(int version, QRecLevel level, int spec[6]) spec[0] = b1; spec[1] = data / b1; spec[2] = ecc / b1; - spec[3] = spec[4] = spec[5] = 0; + spec[3] = spec[4] = 0; } else { spec[0] = b1; spec[1] = data / (b1 + b2); spec[2] = ecc / (b1 + b2); spec[3] = b2; spec[4] = spec[1] + 1; - spec[5] = (ecc - (spec[2] * b1)) / b2; } } @@ -275,19 +275,41 @@ static const int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = { {24, 50}, {28, 54}, {32, 58}, {26, 54}, {30, 58}, //35-40 }; -QRspec_Alignment *QRspec_getAlignmentPattern(int version) +/** + * Put an alignment marker. + * @param frame + * @param width + * @param ox,oy center coordinate of the pattern + */ +static void QRspec_putAlignmentMarker(unsigned char *frame, int width, int ox, int oy) { - int width; - int d, w, x, y, cx, cy; - QRspec_Alignment *al; - int *p; + static const unsigned char finder[] = { + 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, + 0xa1, 0xa0, 0xa0, 0xa0, 0xa1, + 0xa1, 0xa0, 0xa1, 0xa0, 0xa1, + 0xa1, 0xa0, 0xa0, 0xa0, 0xa1, + 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, + }; + int x, y; + const unsigned char *s; - if(version < 2) return NULL; + frame += (oy - 2) * width + ox - 2; + s = finder; + for(y=0; y<5; y++) { + for(x=0; x<5; x++) { + frame[x] = s[x]; + } + frame += width; + s += 5; + } +} + +__STATIC void QRspec_putAlignmentPattern(int version, unsigned char *frame, int width) +{ + int d, w, x, y, cx, cy; - al = (QRspec_Alignment *)malloc(sizeof(QRspec_Alignment)); - if(al == NULL) return NULL; + if(version < 2) return; - width = qrspecCapacity[version].width; d = alignmentPattern[version][1] - alignmentPattern[version][0]; if(d < 0) { w = 2; @@ -295,65 +317,29 @@ QRspec_Alignment *QRspec_getAlignmentPattern(int version) w = (width - alignmentPattern[version][0]) / d + 2; } - al->n = w * w - 3; - al->pos = (int *)malloc(sizeof(int) * al->n * 2); - if(al->pos == NULL) { - free(al); - return NULL; - } - - if(al->n == 1) { - al->pos[0] = alignmentPattern[version][0]; - al->pos[1] = alignmentPattern[version][0]; - - return al; + if(w * w - 3 == 1) { + x = alignmentPattern[version][0]; + y = alignmentPattern[version][0]; + QRspec_putAlignmentMarker(frame, width, x, y); + return; } -#if 0 - /* Just for debug purpose */ - printf("%d ", version); - cx = alignmentPattern[version][0]; - for(x=0; xpos; cx = alignmentPattern[version][0]; for(x=1; xpos != NULL) { - free(al->pos); - } - free(al); - } } /****************************************************************************** @@ -440,34 +426,6 @@ static void putFinderPattern(unsigned char *frame, int width, int ox, int oy) } } -/** - * Put an alignment pattern. - * @param frame - * @param width - * @param ox,oy center coordinate of the pattern - */ -static void putAlignmentPattern(unsigned char *frame, int width, int ox, int oy) -{ - static const unsigned char finder[] = { - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa0, 0xa0, 0xa0, 0xa1, - 0xa1, 0xa0, 0xa1, 0xa0, 0xa1, - 0xa1, 0xa0, 0xa0, 0xa0, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - }; - int x, y; - const unsigned char *s; - - frame += (oy - 2) * width + ox - 2; - s = finder; - for(y=0; y<5; y++) { - for(x=0; x<5; x++) { - frame[x] = s[x]; - } - frame += width; - s += 5; - } -} static unsigned char *QRspec_createFrame(int version) { @@ -475,7 +433,6 @@ static unsigned char *QRspec_createFrame(int version) int width; int x, y; unsigned int verinfo, v; - QRspec_Alignment *alignment; width = qrspecCapacity[version].width; frame = (unsigned char *)malloc(width * width); @@ -522,17 +479,8 @@ static unsigned char *QRspec_createFrame(int version) q += width; } /* Alignment pattern */ - alignment = QRspec_getAlignmentPattern(version); - if(version >= 2) { - if(alignment == NULL) { - goto ABORT; - } - for(x=0; xn; x++) { - putAlignmentPattern(frame, width, - alignment->pos[x*2], alignment->pos[x*2+1]); - } - QRspec_freeAlignment(alignment); - } + QRspec_putAlignmentPattern(version, frame, width); + /* Version information */ if(version >= 7) { verinfo = QRspec_getVersionPattern(version); @@ -560,9 +508,6 @@ static unsigned char *QRspec_createFrame(int version) frame[width * (width - 8) + 8] = 0x81; return frame; -ABORT: - free(frame); - return NULL; } unsigned char *QRspec_newFrame(int version) diff --git a/qrspec.h b/qrspec.h index 04ebb16676..a544e9b107 100644 --- a/qrspec.h +++ b/qrspec.h @@ -106,9 +106,9 @@ extern int QRspec_maximumWords(QRencodeMode mode, int version); * @param level * @param spec an array of ECC specification contains as following: * {# of type1 blocks, # of data code, # of ecc code, - * # of type2 blocks, # of data code, # of ecc code} + * # of type2 blocks, # of data code} */ -void QRspec_getEccSpec(int version, QRecLevel level, int spec[6]); +void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]); #define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3]) #define QRspec_rsBlockNum1(__spec__) (__spec__[0]) @@ -116,34 +116,13 @@ void QRspec_getEccSpec(int version, QRecLevel level, int spec[6]); #define QRspec_rsEccCodes1(__spec__) (__spec__[2]) #define QRspec_rsBlockNum2(__spec__) (__spec__[3]) #define QRspec_rsDataCodes2(__spec__) (__spec__[4]) -#define QRspec_rsEccCodes2(__spec__) (__spec__[5]) +#define QRspec_rsEccCodes2(__spec__) (__spec__[2]) -/****************************************************************************** - * Alignment pattern - *****************************************************************************/ - -/** - * Array of positions of alignment patterns. - * X and Y coordinates are interleaved into 'pos'. - */ -typedef struct { - int n; //< Number of patterns - int *pos; -} QRspec_Alignment; - -/** - * Return positions of alignment patterns. - * @param version - * @return a QRspec_Alignment object that contains all of positions of alignment - * patterns. - */ -extern QRspec_Alignment *QRspec_getAlignmentPattern(int version); - -/** - * Free QRspec_Alignment instance. - * @param al QRspec_Alignment instance. - */ -extern void QRspec_freeAlignment(QRspec_Alignment *al); +#define QRspec_rsDataLength(__spec__) \ + ((QRspec_rsBlockNum1(__spec__) * QRspec_rsDataCodes1(__spec__)) + \ + (QRspec_rsBlockNum2(__spec__) * QRspec_rsDataCodes2(__spec__))) +#define QRspec_rsEccLength(__spec__) \ + (QRspec_rsBlockNum(__spec__) * QRspec_rsEccCodes1(__spec__)) /****************************************************************************** * Version information pattern diff --git a/rscode.c b/rscode.c index 35948d9c82..c92f6f23fc 100644 --- a/rscode.c +++ b/rscode.c @@ -204,8 +204,8 @@ RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) RS *rs; for(rs = rslist; rs != NULL; rs = rs->next) { - if(rs->nroots != nroots) continue; if(rs->pad != pad) continue; + if(rs->nroots != nroots) continue; if(rs->mm != symsize) continue; if(rs->gfpoly != gfpoly) continue; if(rs->fcr != fcr) continue; diff --git a/split.c b/split.c index 12b3cd9d6c..4bb8e55b1c 100644 --- a/split.c +++ b/split.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) @@ -27,6 +27,7 @@ #include #include +#include #include "qrencode.h" #include "qrinput.h" #include "qrspec.h" @@ -279,6 +280,10 @@ int Split_splitStringToQRinput(const char *string, QRinput *input, char *newstr; int ret; + if(string == NULL || *string == '\0') { + errno = EINVAL; + return -1; + } if(!casesensitive) { newstr = dupAndToUpper(string, hint); if(newstr == NULL) return -1; diff --git a/split.h b/split.h index 4ff9540f48..6a495e4910 100644 --- a/split.h +++ b/split.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) @@ -36,7 +36,10 @@ * @param hint give QR_MODE_KANJI if the input string contains Kanji character encoded in Shift-JIS. If not, give QR_MODE_8. * @param casesensitive 0 for case-insensitive encoding (all alphabet characters are replaced to UPPER-CASE CHARACTERS. * @retval 0 success. - * @retval -1 an error occurred. + * @retval -1 an error occurred. errno is set to indicate the error. See + * Exceptions for the details. + * @throw EINVAL invalid input object. + * @throw ENOMEM unable to allocate memory for input objects. */ extern int Split_splitStringToQRinput(const char *string, QRinput *input, QRencodeMode hint, int casesensitive); diff --git a/tests/Makefile.am b/tests/Makefile.am index baabf98ec7..98c0da4bcb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,6 +7,8 @@ noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_mqrspec test_split test_monkey create_frame_pattern \ $(sdlPROGRAMS) +EXTRA_DIST = frame + test_qrinput_SOURCES = test_qrinput.c common.h test_qrinput_LDADD = ../libqrencode.la diff --git a/tests/common.h b/tests/common.h index e902091dd2..6156c7cb46 100644 --- a/tests/common.h +++ b/tests/common.h @@ -9,6 +9,7 @@ #include "../qrencode.h" #include "../qrinput.h" #include "../bitstream.h" +#include "../qrencode_inner.h" #define testStart(__arg__) (testStartReal(__func__, __arg__)) #define testEndExp(__arg__) (testEnd(!(__arg__))) @@ -23,6 +24,23 @@ char levelChar[4] = {'L', 'M', 'Q', 'H'}; const char *modeStr[5] = {"nm", "an", "8", "kj", "st"}; void printQRinput(QRinput *input) +{ + QRinput_List *list; + unsigned char *p; + int i; + + list = input->head; + while(list != NULL) { + p = list->data; + for(i=0; isize; i++) { + printf("0x%02x,", list->data[i]); + } + list = list->next; + } + printf("\n"); +} + +void printQRinputInfo(QRinput *input) { QRinput_List *list; BitStream *b; @@ -39,8 +57,10 @@ void printQRinput(QRinput *input) } printf(" chunks: %d\n", i); b = QRinput_mergeBitStream(input); - printf(" bitstream-size: %d\n", BitStream_size(b)); - BitStream_free(b); + if(b != NULL) { + printf(" bitstream-size: %d\n", BitStream_size(b)); + BitStream_free(b); + } list = input->head; i = 0; @@ -73,7 +93,7 @@ void testEnd(int result) } #define assert_exp(__exp__, ...) \ -(void)({assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__VA_ARGS__);}}) +{assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__VA_ARGS__);}} #define assert_zero(__exp__, ...) assert_exp((__exp__) == 0, __VA_ARGS__) #define assert_nonzero(__exp__, ...) assert_exp((__exp__) != 0, __VA_ARGS__) @@ -81,6 +101,7 @@ void testEnd(int result) #define assert_nonnull(__ptr__, ...) assert_exp((__ptr__) != NULL, __VA_ARGS__) #define assert_equal(__e1__, __e2__, ...) assert_exp((__e1__) == (__e2__), __VA_ARGS__) #define assert_notequal(__e1__, __e2__, ...) assert_exp((__e1__) != (__e2__), __VA_ARGS__) +#define assert_nothing(__exp__, ...) {printf(__VA_ARGS__); __exp__;} void testFinish(void) { diff --git a/tests/create_frame_pattern.c b/tests/create_frame_pattern.c index 0c39eaeff8..786309fe52 100644 --- a/tests/create_frame_pattern.c +++ b/tests/create_frame_pattern.c @@ -1,3 +1,12 @@ +/* + * This tool creates a frame pattern data for debug purpose used by + * test_qrspec. test_qrspec and create_frame_pattern uses the same function + * of libqrencode. This means the test is meaningless if test_qrspec is run + * with a pattern data created by create_frame_pattern of the same version. + * In order to test it correctly, create a pattern data by the tool of the + * previous version, or use the frame data attached to the package. + */ + #include #include #include @@ -11,13 +20,13 @@ void append_pattern(int version, FILE *fp) frame = QRspec_newFrame(version); width = QRspec_getWidth(version); - fwrite(frame, width * width, 1, fp); + fwrite(frame, 1, width * width, fp); free(frame); } static int writePNG(unsigned char *frame, int width, const char *outfile) { - FILE *fp; + static FILE *fp; png_structp png_ptr; png_infop info_ptr; unsigned char *row, *p, *q; diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index c82535ceef..a7e302807d 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -3,6 +3,8 @@ #include #include #include "../qrencode.h" +#include "../qrspec.h" +#include "../rscode.h" struct timeval tv; void timerStart(const char *str) @@ -59,5 +61,8 @@ int main() prof_ver1to10(); prof_ver31to40(); + QRspec_clearCache(); + free_rs_cache(); + return 0; } diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 6719aa0d6a..8c853777cf 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -11,7 +11,7 @@ void test_null(void) bstream = BitStream_new(); assert_zero(BitStream_size(bstream), "Size of empty BitStream is not 0."); assert_null(BitStream_toByte(bstream), "BitStream_toByte returned non-NULL."); - + assert_nothing(BitStream_free(NULL), "Check BitStream_free(NULL).\n"); testFinish(); BitStream_free(bstream); diff --git a/tests/test_monkey.c b/tests/test_monkey.c index e0a1a4cf2d..8986fe7212 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -1,5 +1,6 @@ #include #include +#include #include "common.h" #include "../qrinput.h" #include "../split.h" @@ -40,7 +41,16 @@ void test_split_an(int num) data[len] = '\0'; input = QRinput_new2(0, QR_ECLEVEL_L); - Split_splitStringToQRinput(data, input, QR_MODE_8, 1); + if(input == NULL) { + perror("test_split_an aborted at QRinput_new2():"); + return; + } + ret = Split_splitStringToQRinput(data, input, QR_MODE_8, 1); + if(ret < 0) { + perror("test_split_an aborted at Split_splitStringToQRinput():"); + QRinput_free(input); + return; + } list = input->head; i = 0; while(list != NULL) { @@ -93,7 +103,16 @@ void test_split_8(int num) len = fill8bitData(); input = QRinput_new2(0, QR_ECLEVEL_L); - Split_splitStringToQRinput(data, input, QR_MODE_8, 1); + if(input == NULL) { + perror("test_split_8 aborted at QRinput_new2():"); + return; + } + ret = Split_splitStringToQRinput(data, input, QR_MODE_8, 1); + if(ret < 0) { + perror("test_split_8 aborted at Split_splitStringToQRinput():"); + QRinput_free(input); + return; + } list = input->head; i = 0; while(list != NULL) { @@ -146,7 +165,16 @@ void test_split_kanji(int num) len = fill8bitData(); input = QRinput_new2(0, QR_ECLEVEL_L); - Split_splitStringToQRinput(data, input, QR_MODE_KANJI, 1); + if(input == NULL) { + perror("test_split_kanji aborted at QRinput_new2():"); + return; + } + ret = Split_splitStringToQRinput(data, input, QR_MODE_KANJI, 1); + if(ret < 0) { + perror("test_split_kanji aborted at Split_splitStringToQRinput():"); + QRinput_free(input); + return; + } list = input->head; i = 0; while(list != NULL) { @@ -190,7 +218,7 @@ void monkey_split_kanji(int loop) } } -void test_split_structure(void) +void test_split_structure(int num) { QRinput *input; QRinput_Struct *s; @@ -198,7 +226,7 @@ void test_split_structure(void) QRinput_InputList *il; int version; QRecLevel level; - int len, c, i; + int len, c, i, ret; version = (int)drand(40) + 1; level = (QRecLevel)drand(4); @@ -206,9 +234,21 @@ void test_split_structure(void) len = fill8bitData(); input = QRinput_new2(version, level); - Split_splitStringToQRinput(data, input, QR_MODE_KANJI, 1); + if(input == NULL) { + perror("test_split_structure aborted at QRinput_new2():"); + return; + } + ret = Split_splitStringToQRinput(data, input, QR_MODE_KANJI, 1); + if(ret < 0) { + perror("test_split_structure aborted at Split_splitStringToQRinput():"); + QRinput_free(input); + return; + } s = QRinput_splitQRinputToStruct(input); if(s == NULL) { + if(errno != 0 && errno != ERANGE) { + perror("test_split_structure aborted at QRinput_splitQRinputToStruct():"); + } QRinput_free(input); return; } @@ -218,23 +258,31 @@ void test_split_structure(void) if(il->input->version != version) { printf("Test: version %d, level %c\n", version, levelChar[level]); printf("wrong version number.\n"); - printQRinput(il->input); + printQRinputInfo(il->input); exit(1); } i++; il = il->next; } codes = QRcode_encodeInputStructured(s); + if(codes == NULL) { + perror("test_split_structure aborted at QRcode_encodeInputStructured():"); + QRinput_free(input); + QRinput_Struct_free(s); + return; + } list = codes; il = s->head; c = 0; while(list != NULL) { if(list->code->version != version) { + printf("#%d: data mismatched.\n", num); printf("Test: version %d, level %c\n", version, levelChar[level]); printf("code #%d\n", c); printf("Version mismatch: %d should be %d\n", list->code->version, version); printf("max bits: %d\n", QRspec_getDataLength(version, level) * 8 - 20); - printQRinput(il->input); + printQRinputInfo(il->input); + printQRinput(input); exit(1); } list = list->next; @@ -254,7 +302,7 @@ void monkey_split_structure(int loop) puts("Monkey test: QRinput_splitQRinputToStruct."); srand(0); for(i=0; idata[size - i - 1]; + } + assert_zero(c, "Padding bits are not zero."); + testFinish(); + + QRinput_free(input); + BitStream_free(bstream); +} + void test_encodeNumeric2(void) { QRinput *stream; @@ -421,11 +446,11 @@ void test_lengthOfCode_num(void) void test_lengthOfCode_kanji(void) { int i, bytes; - char str[4]= {0x93, 0x5f,0xe4, 0xaa}; + unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; testStart("Checking length of code (kanji)"); for(i=2; i<=4; i+=2) { - bytes = check_lengthOfCode(QR_MODE_KANJI, str, i, 1); + bytes = check_lengthOfCode(QR_MODE_KANJI, (char *)str, i, 1); assert_equal(i, bytes, "lengthOfCode failed. (QR_MODE_KANJI, version:1, size:%d)\n", i); } testFinish(); @@ -723,6 +748,14 @@ void test_parity2(void) QRinput_Struct_free(s); } +void test_null_free(void) +{ + testStart("Testing free NULL pointers"); + assert_nothing(QRinput_free(NULL), "Check QRinput_free(NULL).\n"); + assert_nothing(QRinput_Struct_free(NULL), "Check QRinput_Struct_free(NULL).\n"); + testFinish(); +} + int main(int argc, char **argv) { test_encodeNumeric(); @@ -738,6 +771,7 @@ int main(int argc, char **argv) test_encodeNumericPadded(); test_encodeNumericPadded2(); test_encodeAnNum(); + test_padding(); test_struct_listop(); test_insertStructuredAppendHeader(); test_insertStructuredAppendHeader_error(); @@ -751,6 +785,7 @@ int main(int argc, char **argv) test_struct_split_invalidVersion(); test_parity(); test_parity2(); + test_null_free(); report(); diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 8c3a7198d4..792915f80c 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -8,20 +8,28 @@ void print_eccTable(void) int i, j; int ecc; int data; - int spec[6]; + int spec[5]; for(i=1; i<=QRSPEC_VERSION_MAX; i++) { printf("Version %2d\n", i); for(j=0; j<4; j++) { QRspec_getEccSpec(i, (QRecLevel)j, spec); - data = spec[0] * spec[1] + spec[3] * spec[4]; - ecc = spec[0] * spec[2] + spec[3] * spec[5]; + data = QRspec_rsBlockNum1(spec) * QRspec_rsDataCodes1(spec) + + QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec); + ecc = QRspec_rsBlockNum1(spec) * QRspec_rsEccCodes1(spec) + + QRspec_rsBlockNum2(spec) * QRspec_rsEccCodes2(spec); printf("%3d\t", ecc); - printf("%2d\t", spec[0]); - printf("(%3d, %3d)\n", spec[1]+spec[2], spec[1]); - if(spec[3]>0) { - printf("\t%2d\t", spec[3]); - printf("(%3d, %3d)\n", spec[4]+spec[5], spec[4]); + printf("%2d\t", QRspec_rsBlockNum1(spec)); + printf("(%3d, %3d, %3d)\n", + QRspec_rsDataCodes1(spec) + QRspec_rsEccCodes1(spec), + QRspec_rsDataCodes1(spec), + QRspec_rsEccCodes1(spec)); + if(QRspec_rsBlockNum2(spec) > 0) { + printf("\t%2d\t", QRspec_rsBlockNum2(spec)); + printf("(%3d, %3d, %3d)\n", + QRspec_rsDataCodes2(spec) + QRspec_rsEccCodes2(spec), + QRspec_rsDataCodes2(spec), + QRspec_rsEccCodes2(spec)); } } } @@ -33,22 +41,24 @@ void test_eccTable(void) int ecc; int data; int err = 0; - int spec[6]; + int spec[5]; testStart("Checking ECC table."); for(i=1; i<=QRSPEC_VERSION_MAX; i++) { for(j=0; j<4; j++) { QRspec_getEccSpec(i, (QRecLevel)j, spec); - data = spec[0] * spec[1] + spec[3] * spec[4]; - ecc = spec[0] * spec[2] + spec[3] * spec[5]; + data = QRspec_rsBlockNum1(spec) * QRspec_rsDataCodes1(spec) + + QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec); + ecc = QRspec_rsBlockNum1(spec) * QRspec_rsEccCodes1(spec) + + QRspec_rsBlockNum2(spec) * QRspec_rsEccCodes2(spec); if(data + ecc != QRspec_getDataLength(i, (QRecLevel)j) + QRspec_getECCLength(i, (QRecLevel)j)) { printf("Error in version %d, level %d: invalid size\n", i, j); - printf("%d %d %d %d %d %d\n", spec[0], spec[1], spec[2], spec[3], spec[4], spec[5]); + printf("%d %d %d %d %d %d\n", spec[0], spec[1], spec[2], spec[3], spec[4], spec[2]); err++; } if(ecc != QRspec_getECCLength(i, (QRecLevel)j)) { printf("Error in version %d, level %d: invalid data\n", i, j); - printf("%d %d %d %d %d %d\n", spec[0], spec[1], spec[2], spec[3], spec[4], spec[5]); + printf("%d %d %d %d %d %d\n", spec[0], spec[1], spec[2], spec[3], spec[4], spec[2]); err++; } } @@ -59,10 +69,7 @@ void test_eccTable(void) void test_eccTable2(void) { int i; - int idx; - int err; - int terr = 0; - int spec[6]; + int spec[5]; const int correct[7][6] = { { 8, 1, 0, 2, 60, 38}, @@ -76,97 +83,103 @@ void test_eccTable2(void) testStart("Checking ECC table(2)"); for(i=0; i<7; i++) { - err = 0; QRspec_getEccSpec(correct[i][0], (QRecLevel)correct[i][1], spec); - idx = correct[i][2] * 3; - if(spec[idx] != correct[i][3]) err++; - if(spec[idx+1] + spec[idx+2] != correct[i][4]) err++; - if(spec[idx+1] != correct[i][5]) err++; - if(err) { - printf("Error in version %d, level %d: invalid data\n", - correct[i][0], correct[i][1]); - terr++; + if(correct[i][2] == 0) { + assert_equal(QRspec_rsBlockNum1(spec), correct[i][3], + "Error in version %d, level %d. rsBlockNum1 was %d, expected %d.\n", + correct[i][0], correct[i][1], + QRspec_rsBlockNum1(spec), correct[i][3]); + assert_equal(QRspec_rsDataCodes1(spec) + QRspec_rsEccCodes1(spec), correct[i][4], + "Error in version %d, level %d. rsDataCodes1 + rsEccCodes1 was %d, expected %d.\n", + correct[i][0], correct[i][1], + QRspec_rsDataCodes1(spec) + QRspec_rsEccCodes1(spec), correct[i][4]); + assert_equal(QRspec_rsDataCodes1(spec), correct[i][5], + "Error in version %d, level %d. rsDataCodes1 was %d, expected %d.\n", + correct[i][0], correct[i][1], + QRspec_rsDataCodes1(spec), correct[i][5]); + } else { + assert_equal(QRspec_rsBlockNum2(spec), correct[i][3], + "Error in version %d, level %d. rsBlockNum2 was %d, expected %d.\n", + correct[i][0], correct[i][1], + QRspec_rsBlockNum2(spec), correct[i][3]); + assert_equal(QRspec_rsDataCodes2(spec) + QRspec_rsEccCodes2(spec), correct[i][4], + "Error in version %d, level %d. rsDataCodes2 + rsEccCodes2 was %d, expected %d.\n", + correct[i][0], correct[i][1], + QRspec_rsDataCodes2(spec) + QRspec_rsEccCodes2(spec), correct[i][4]); + assert_equal(QRspec_rsDataCodes2(spec), correct[i][5], + "Error in version %d, level %d. rsDataCodes2 was %d, expected %d.\n", + correct[i][0], correct[i][1], + QRspec_rsDataCodes2(spec), correct[i][5]); } } - testEnd(terr); + testFinish(); } -void test_alignment1(void) +void test_newframe(void) { - QRspec_Alignment *al; - int i; - int err = 0; - int rbpos; + unsigned char buf[QRSPEC_WIDTH_MAX * QRSPEC_WIDTH_MAX]; + int i, width; + size_t len; + FILE *fp; + unsigned char *frame; - testStart("Checking alignment pattern table(1)"); - rbpos = 14; + testStart("Checking newly created frame."); + fp = fopen("frame", "rb"); + if(fp == NULL) { + perror("Failed to open \"frame\":"); + abort(); + } for(i=1; i<=QRSPEC_VERSION_MAX; i++) { - al = QRspec_getAlignmentPattern(i); - if(i == 1) { - if(al != NULL) { - printf("Error in version %d.\n", i); - err++; - } - } else if(i < 7) { - if(al->n != 1) { - printf("Error in version %d.\n", i); - err++; - } - if(al->pos[al->n*2-1] != rbpos) { - printf("Error in version %d.\n", i); - err++; - } - } else if(i < 14) { - if(al->n != 6) { - printf("Error in version %d.(%d)\n", i, al->n); - err++; - } - if(al->pos[al->n*2-1] != rbpos) { - printf("Error in version %d.\n", i); - err++; - } - } else if(i < 21) { - if(al->n != 13) { - printf("Error in version %d.(%d)\n", i, al->n); - err++; - } - if(al->pos[al->n*2-1] != rbpos) { - printf("Error in version %d.\n", i); - err++; - } - } else if(i < 28) { - if(al->n != 22) { - printf("Error in version %d.(%d)\n", i, al->n); - err++; - } - if(al->pos[al->n*2-1] != rbpos) { - printf("Error in version %d.\n", i); - err++; - } - } else if(i < 35) { - if(al->n != 33) { - printf("Error in version %d.(%d)\n", i, al->n); - err++; - } - if(al->pos[al->n*2-1] != rbpos) { - printf("Error in version %d.\n", i); - err++; - } - } else { - if(al->n != 46) { - printf("Error in version %d.(%d)\n", i, al->n); - err++; + frame = QRspec_newFrame(i); + width = QRspec_getWidth(i); + len = fread(buf, 1, width * width, fp); + if((int)len != width * width) { + perror("Failed to read the pattern file:"); + abort(); + } + assert_zero(memcmp(frame, buf, len), "frame pattern mismatch (version %d)\n", i); + free(frame); + } + + testFinish(); + fclose(fp); +} + +#if 0 +/* This test is used to check positions of alignment pattern. See Appendix E + * (pp.71) of JIS X0510:2004 and compare to the output. Before comment out + * this test, change the value of the pattern marker's center dot from 0xa1 + * to 0xb1 (QRspec_putAlignmentMarker() : finder). + */ +void test_alignment(void) +{ + unsigned char *frame; + int i, x, y, width, c; + + testStart("Checking alignment pattern."); + for(i=2; i<=QRSPEC_VERSION_MAX; i++) { + printf("%2d", i); + frame = QRspec_newFrame(i); + width = QRspec_getWidth(i); + c = 0; + for(x=0; xpos[al->n*2-1] != rbpos) { - printf("Error in version %d.\n", i); - err++; + } + printf("|%2d| 6", c); + y = width - 7; + for(x=0; x < width; x++) { + if(frame[y * width + x] == 0xb1) { + printf(", %3d", x); } } - QRspec_freeAlignment(al); - rbpos += 4; + printf("\n"); + free(frame); } - testEnd(err); + testFinish(); } +#endif void test_verpat(void) { @@ -279,12 +292,15 @@ int main(int argc, char **argv) { test_eccTable(); test_eccTable2(); -// print_eccTable(); - test_alignment1(); + //print_eccTable(); + test_newframe(); + //test_alignment(); test_verpat(); - print_newFrame(); + //print_newFrame(); test_format(); + QRspec_clearCache(); + report(); return 0; diff --git a/tests/test_split.c b/tests/test_split.c index 60bb4a8dd2..4c28e171fd 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -388,7 +388,7 @@ void test_splitNum8(void) list = input->head; if(inputTest(list, "8", 8)) { err++; - printQRinput(input); + printQRinputInfo(input); } testEnd(err); QRinput_free(input); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 89a4a324d7..ed86183c68 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -45,7 +45,7 @@ static void usage(int help, int longopt) { fprintf(stderr, "view_qrcode version %s\n" -"Copyright (C) 2008 Kentaro Fukuchi\n", VERSION); +"Copyright (C) 2008, 2009 Kentaro Fukuchi\n", VERSION); if(help) { if(longopt) { fprintf(stderr, @@ -163,7 +163,7 @@ void draw_singleQRcode(QRinput *stream, int mask) QRcode_free(qrcode); } -void draw_structuredQRcode(QRinput_Struct *s, int mask) +void draw_structuredQRcode(QRinput_Struct *s) { int i, w, h, n, x, y; int swidth; @@ -191,7 +191,7 @@ void draw_structuredQRcode(QRinput_Struct *s, int mask) QRcode_List_free(qrcodes); } -void draw_structuredQRcodeFromText(int argc, char **argv, int mask) +void draw_structuredQRcodeFromText(int argc, char **argv) { QRinput_Struct *s; QRinput *input; @@ -228,11 +228,11 @@ void draw_structuredQRcodeFromText(int argc, char **argv, int mask) fprintf(stderr, "Too many inputs.\n"); } - draw_structuredQRcode(s, mask); + draw_structuredQRcode(s); QRinput_Struct_free(s); } -void draw_structuredQRcodeFromQRinput(QRinput *stream, int mask) +void draw_structuredQRcodeFromQRinput(QRinput *stream) { QRinput_Struct *s; @@ -240,7 +240,7 @@ void draw_structuredQRcodeFromQRinput(QRinput *stream, int mask) QRinput_setErrorCorrectionLevel(stream, level); s = QRinput_splitQRinputToStruct(stream); if(s != NULL) { - draw_structuredQRcode(s, mask); + draw_structuredQRcode(s); QRinput_Struct_free(s); } else { fprintf(stderr, "Input data is too large for this setting.\n"); @@ -256,15 +256,19 @@ void view(int mode, QRinput *input) while(flag) { if(mode) { - draw_structuredQRcodeFromText(textc, textv, mask); + draw_structuredQRcodeFromText(textc, textv); } else { if(structured) { - draw_structuredQRcodeFromQRinput(input, mask); + draw_structuredQRcodeFromQRinput(input); } else { draw_singleQRcode(input, mask); } } - printf("Version %d, Level %c, Mask %d.\n", version, levelChar[level], mask); + if(mode || structured) { + printf("Version %d, Level %c.\n", version, levelChar[level]); + } else { + printf("Version %d, Level %c, Mask %d.\n", version, levelChar[level], mask); + } loop = 1; while(loop) { usleep(10000); @@ -300,12 +304,16 @@ void view(int mode, QRinput *input) case SDLK_5: case SDLK_6: case SDLK_7: - mask = (event.key.keysym.sym - SDLK_0); - loop = 0; + if(!mode && !structured) { + mask = (event.key.keysym.sym - SDLK_0); + loop = 0; + } break; case SDLK_8: - mask = -1; - loop = 0; + if(!mode && !structured) { + mask = -1; + loop = 0; + } break; case SDLK_l: level = QR_ECLEVEL_L; @@ -474,7 +482,7 @@ int main(int argc, char **argv) return -1; } if(structured && version < 1) { - fprintf(stderr, "Version number must be larger than 0.\n"); + fprintf(stderr, "Version number must be greater than 0 to encode structured symbols.\n"); exit(1); } if(structured && (argc - optind > 1)) { -- cgit 0.0.5-2-1-g0f52 From 99808095ada0a69194e346581639dc5f65c425ea Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 May 2009 16:08:19 +0000 Subject: MQR things. --- mqrspec.c | 15 ---- mqrspec.h | 20 +---- tests/create_mqr_frame_pattern.c | 170 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+), 32 deletions(-) create mode 100644 tests/create_mqr_frame_pattern.c diff --git a/mqrspec.c b/mqrspec.c index 855ec0d0c2..30a27a1e87 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -108,21 +108,6 @@ int MQRspec_maximumWords(QRencodeMode mode, int version) return words; } -/****************************************************************************** - * Error correction code - *****************************************************************************/ - -void MQRspec_getEccSpec(int version, QRecLevel level) -{ -#if 0 - int data, ecc; - int *array; - - data = MQRspec_getDataLength(version, level); - ecc = MQRspec_getECCLength(version, level); -#endif -} - /****************************************************************************** * Format information *****************************************************************************/ diff --git a/mqrspec.h b/mqrspec.h index c0368b0104..56ac139239 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Micro QR Code specification in convenient format. - * Copyright (C) 2006, 2007, 2008 Kentaro Fukuchi + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -97,20 +97,6 @@ extern int MQRspec_lengthIndicator(QRencodeMode mode, int version); */ extern int MQRspec_maximumWords(QRencodeMode mode, int version); -/****************************************************************************** - * Error correction code - *****************************************************************************/ - -/** - * Return an array of ECC specification. - * @param version - * @param level - * @param spec an array of ECC specification contains as following: - * {# of type1 blocks, # of data code, # of ecc code, - * # of type2 blocks, # of data code, # of ecc code} - */ -void MQRspec_getEccSpec(int version, QRecLevel level); - /****************************************************************************** * Version information pattern *****************************************************************************/ @@ -154,6 +140,6 @@ extern unsigned char *MQRspec_newFrame(int version); * Clear the frame cache. Typically for debug. * WARNING: Thread unsafe!!! */ -extern void QRspec_clearCache(void); +extern void MQRspec_clearCache(void); -#endif /* __QRSPEC_H__ */ +#endif /* __MQRSPEC_H__ */ diff --git a/tests/create_mqr_frame_pattern.c b/tests/create_mqr_frame_pattern.c new file mode 100644 index 0000000000..cad1f9c513 --- /dev/null +++ b/tests/create_mqr_frame_pattern.c @@ -0,0 +1,170 @@ +/* + * This tool creates a frame pattern data for debug purpose used by + * test_qrspec. test_qrspec and create_frame_pattern uses the same function + * of libqrencode. This means the test is meaningless if test_qrspec is run + * with a pattern data created by create_frame_pattern of the same version. + * In order to test it correctly, create a pattern data by the tool of the + * previous version, or use the frame data attached to the package. + */ + +#include +#include +#include +#include "common.h" +#include "../mqrspec.h" + +void append_pattern(int version, FILE *fp) +{ + int width; + unsigned char *frame; + + frame = MQRspec_newFrame(version); + width = MQRspec_getWidth(version); + fwrite(frame, 1, width * width, fp); + free(frame); +} + +static int writePNG(unsigned char *frame, int width, const char *outfile) +{ + static FILE *fp; + png_structp png_ptr; + png_infop info_ptr; + unsigned char *row, *p, *q; + int x, y, xx, yy, bit; + int realwidth; + const int margin = 0; + const int size = 1; + + realwidth = (width + margin * 2) * size; + row = (unsigned char *)malloc((realwidth + 7) / 8); + if(row == NULL) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(EXIT_FAILURE); + } + + if(outfile[0] == '-' && outfile[1] == '\0') { + fp = stdout; + } else { + fp = fopen(outfile, "wb"); + if(fp == NULL) { + fprintf(stderr, "Failed to create file: %s\n", outfile); + perror(NULL); + exit(EXIT_FAILURE); + } + } + + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if(png_ptr == NULL) { + fclose(fp); + fprintf(stderr, "Failed to initialize PNG writer.\n"); + exit(EXIT_FAILURE); + } + + info_ptr = png_create_info_struct(png_ptr); + if(info_ptr == NULL) { + fclose(fp); + fprintf(stderr, "Failed to initialize PNG write.\n"); + exit(EXIT_FAILURE); + } + + if(setjmp(png_jmpbuf(png_ptr))) { + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); + fprintf(stderr, "Failed to write PNG image.\n"); + exit(EXIT_FAILURE); + } + + png_init_io(png_ptr, fp); + png_set_IHDR(png_ptr, info_ptr, + realwidth, realwidth, + 1, + PNG_COLOR_TYPE_GRAY, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + png_write_info(png_ptr, info_ptr); + + /* top margin */ + memset(row, 0xff, (realwidth + 7) / 8); + for(y=0; y Date: Wed, 20 May 2009 16:08:46 +0000 Subject: Some warnings cleared. --- ChangeLog | 4 ++++ tests/Makefile.am | 7 ++++++- tests/prof_qrencode.c | 2 +- tests/test_bitstream.c | 2 +- tests/test_mqrspec.c | 4 +++- tests/test_qrencode.c | 2 +- tests/test_qrinput.c | 2 +- tests/test_qrspec.c | 2 +- tests/test_split.c | 2 +- 9 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f2bc415a7..ed7ea0ffce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009.05.20 Kentaro FUKUCHI * Merged from 3.1.0 branch. (rev 2248:HEAD) + * mqrspec.[ch], tests/create_mqr_frame_pattern.c: + - MQRspec_getEccSpec() has been deleted. + * tests/create_mqr_frame_pattern.c, tests/Makefile.am: + - Newly added. 2009.05.20 Kentaro FUKUCHI * qrenc.c, qrinput.c, qrencode.c: diff --git a/tests/Makefile.am b/tests/Makefile.am index 98c0da4bcb..b606c34e2c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,8 @@ endif noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_qrspec test_rs test_qrencode prof_qrencode \ - test_mqrspec test_split test_monkey create_frame_pattern \ + test_mqrspec test_split test_monkey \ + create_frame_pattern create_mqr_frame_pattern \ $(sdlPROGRAMS) EXTRA_DIST = frame @@ -43,6 +44,10 @@ create_frame_pattern_SOURCES = create_frame_pattern.c create_frame_pattern_CFLAGS = $(png_CFLAGS) create_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) +create_mqr_frame_pattern_SOURCES = create_mqr_frame_pattern.c +create_mqr_frame_pattern_CFLAGS = $(png_CFLAGS) +create_mqr_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) + if HAVE_SDL view_qrcode_SOURCES = view_qrcode.c common.h view_qrcode_CFLAGS= $(SDL_CFLAGS) diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index a7e302807d..9230f07b05 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -56,7 +56,7 @@ void prof_ver31to40(void) timerStop(); } -int main() +int main(void) { prof_ver1to10(); prof_ver31to40(); diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 8c853777cf..cac4174c6e 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -134,7 +134,7 @@ void test_size(void) BitStream_free(bstream); } -int main(int argc, char **argv) +int main(void) { test_null(); test_num(); diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index 665b940354..56a4e74d41 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -145,13 +145,15 @@ void test_dataLength(void) testEnd(err); } -int main(int argc, char **argv) +int main(void) { test_newFrame(); //print_format(); test_format(); test_dataLength(); + MQRspec_clearCache(); + report(); return 0; diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index ccafc59edb..341190e1d9 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -663,7 +663,7 @@ void test_null_free(void) testFinish(); } -int main(int argc, char **argv) +int main(void) { test_iterate(); test_iterate2(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index fdc18b39ba..15d9a0e0ac 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -756,7 +756,7 @@ void test_null_free(void) testFinish(); } -int main(int argc, char **argv) +int main(void) { test_encodeNumeric(); test_encodeNumeric2(); diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 792915f80c..40c64d6569 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -288,7 +288,7 @@ void test_format(void) testEnd(err); } -int main(int argc, char **argv) +int main(void) { test_eccTable(); test_eccTable2(); diff --git a/tests/test_split.c b/tests/test_split.c index 4c28e171fd..8c9a5254af 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -394,7 +394,7 @@ void test_splitNum8(void) QRinput_free(input); } -int main(int argc, char **argv) +int main(void) { test_split1(); test_split2(); -- cgit 0.0.5-2-1-g0f52 From 7fa6a8b02ff4375fb0aa0eb54738ad7000b0cc32 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 May 2009 17:17:14 +0000 Subject: Compiler warnings cleared. --- tests/test_estimatebit.c | 2 +- tests/test_rs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index 4e65eb630c..bcae3f6273 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -139,7 +139,7 @@ void test_mix(void) QRinput_free(gstream); } -int main(int argc, char **argv) +int main(void) { gstream = QRinput_new(); diff --git a/tests/test_rs.c b/tests/test_rs.c index 60e9a48763..7ea2695ad8 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -27,7 +27,7 @@ void test_rscode1(void) QRraw_free(code); } -int main(int argc, char **argv) +int main(void) { test_rscode1(); -- cgit 0.0.5-2-1-g0f52 From e45af97fd13d034f87412925f09f054c04aa4e10 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 May 2009 17:17:58 +0000 Subject: Frame test improved. (All versions are now tested) --- tests/test_mqrspec.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index 56a4e74d41..f6839c067e 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -25,14 +25,19 @@ unsigned char v4frame[] = { void test_newFrame(void) { - int width; + int width, i, y; unsigned char *frame; - testStart("Test Version 4 frame"); - frame = MQRspec_newFrame(4); - width = MQRspec_getWidth(4); - testEnd(memcmp(frame, v4frame, width * width)); - free(frame); + testStart("Test empty frames"); + for(i=1; i Date: Wed, 20 May 2009 17:19:07 +0000 Subject: Mask module for Micro QR Code has been added. --- Makefile.am | 3 +- mmask.c | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++ mmask.h | 28 +++++++++ tests/Makefile.am | 8 ++- tests/test_mmask.c | 48 +++++++++++++++ 5 files changed, 253 insertions(+), 2 deletions(-) create mode 100644 mmask.c create mode 100644 mmask.h create mode 100644 tests/test_mmask.c diff --git a/Makefile.am b/Makefile.am index d8bdd1e6ec..7972a0aa26 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,8 @@ libqrencode_la_SOURCES = qrencode.c qrencode_inner.h \ rscode.c rscode.h \ split.c split.h \ mask.c mask.h \ - mqrspec.c mqrspec.h + mqrspec.c mqrspec.h \ + mmask.c mmask.h libqrencode_la_LDFLAGS = -version-number $(MAJOR_VERSION):$(MINOR_VERSION):$(MICRO_VERSION) diff --git a/mmask.c b/mmask.c new file mode 100644 index 0000000000..c81db684aa --- /dev/null +++ b/mmask.c @@ -0,0 +1,168 @@ +/* + * qrencode - QR Code encoder + * + * Masking for Micro QR Code. + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include "config.h" +#include "qrencode.h" +#include "mqrspec.h" +#include "mmask.h" + +__STATIC void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level) +{ + unsigned int format; + unsigned char v; + int i; + + format = MQRspec_getFormatInfo(mask, version, level); + + for(i=0; i<8; i++) { + v = 0x84 | (format & 1); + frame[width * (i + 1)+ 8] = v; + format= format >> 1; + } + for(i=0; i<7; i++) { + v = 0x84 | (format & 1); + frame[width * 8 + 8 - i] = v; + format= format >> 1; + } +} + +#define MASKMAKER(__exp__) \ + int x, y;\ +\ + for(y=0; y maxScore) { + maxScore = score; + bestMaskNum = i; + free(bestMask); + bestMask = mask; + mask = (unsigned char *)malloc(width * width); + if(mask == NULL) break; + } + } + free(mask); + return bestMask; +} diff --git a/mmask.h b/mmask.h new file mode 100644 index 0000000000..1353afec15 --- /dev/null +++ b/mmask.h @@ -0,0 +1,28 @@ +/* + * qrencode - QR Code encoder + * + * Masking for Micro QR Code. + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __MMASK_H__ +#define __MMASK_H__ + +extern unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level); + +#endif /* __MMASK_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am index b606c34e2c..209e709d99 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ endif noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_qrspec test_rs test_qrencode prof_qrencode \ - test_mqrspec test_split test_monkey \ + test_mqrspec test_split test_monkey test_mask test_mmask \ create_frame_pattern create_mqr_frame_pattern \ $(sdlPROGRAMS) @@ -37,6 +37,12 @@ test_split_LDADD = ../libqrencode.la test_monkey_SOURCES = test_monkey.c common.h test_monkey_LDADD = ../libqrencode.la +test_mask_SOURCES = test_mask.c common.h +test_mask_LDADD = ../libqrencode.la + +test_mmask_SOURCES = test_mmask.c common.h +test_mmask_LDADD = ../libqrencode.la + prof_qrencode_SOURCES = prof_qrencode.c prof_qrencode_LDADD = ../libqrencode.la diff --git a/tests/test_mmask.c b/tests/test_mmask.c new file mode 100644 index 0000000000..5eda64d2c1 --- /dev/null +++ b/tests/test_mmask.c @@ -0,0 +1,48 @@ +#include +#include +#include "common.h" +#include "../mmask.h" +#include "../mqrspec.h" + +void print_mask(int mask) +{ + const int w = 8; + unsigned char frame[w * w], *masked, *p; + int x, y; + + memset(frame, 0, w * w); + masked = MMask_makeMaskedFrame(w, frame, mask); + p = masked; + for(y=0; y Date: Wed, 20 May 2009 17:21:06 +0000 Subject: Code cleanups. Unnecessary memcpy has been eliminated. --- mask.c | 29 ++++++++++++++++++++--------- mask.h | 2 -- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/mask.c b/mask.c index 9bf1279eff..a5d9fb5d4c 100644 --- a/mask.c +++ b/mask.c @@ -34,7 +34,7 @@ __STATIC int Mask_writeFormatInformation(int width, unsigned char *frame, int ma int i; int blacks = 0; - format = QRspec_getFormatInfo(mask, level); + format = QRspec_getFormatInfo(mask, level); for(i=0; i<8; i++) { if(format & 1) { @@ -136,12 +136,25 @@ static int Mask_mask7(int width, const unsigned char *s, unsigned char *d) MASKMAKER((((x*y)%3)+((x+y)&1))&1) } +#define maskNum (8) typedef int MaskMaker(int, const unsigned char *, unsigned char *); -static MaskMaker *maskMakers[] = { +static MaskMaker *maskMakers[maskNum] = { Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3, Mask_mask4, Mask_mask5, Mask_mask6, Mask_mask7 }; +__STATIC unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask) +{ + unsigned char *masked; + + masked = (unsigned char *)malloc(width * width); + if(masked == NULL) return NULL; + + maskMakers[mask](width, frame, masked); + + return masked; +} + unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level) { unsigned char *masked; @@ -270,7 +283,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) if(mask == NULL) return NULL; bestMask = NULL; - for(i=0; i<8; i++) { + for(i=0; i Date: Wed, 20 May 2009 17:22:59 +0000 Subject: New test program has been added. --- ChangeLog | 6 ++++++ qrencode_inner.h | 6 +++++- tests/test_mask.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/test_mask.c diff --git a/ChangeLog b/ChangeLog index ed7ea0ffce..0425d63a1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,12 @@ - MQRspec_getEccSpec() has been deleted. * tests/create_mqr_frame_pattern.c, tests/Makefile.am: - Newly added. + * mask.[ch], tests/test_mask.c, qrencode_inner.h: + - Code cleanups. + - Unnecessary memcpy has been eliminated. + - New test program has been added. + * mmask.[ch], qrencode_inner.h, tests/test_mmask.c, Makefile.am, tests/Makefile.am: + - Mask module for Micro QR Code has been added. 2009.05.20 Kentaro FUKUCHI * qrenc.c, qrinput.c, qrencode.c: diff --git a/qrencode_inner.h b/qrencode_inner.h index b6d4990342..cdad55c537 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -87,12 +87,16 @@ extern unsigned char *FrameFiller_fillerTest(int version); *****************************************************************************/ extern QRcode *QRcode_encodeMask(QRinput *input, int mask); - /****************************************************************************** * Mask *****************************************************************************/ extern int Mask_evaluateSymbol(int width, unsigned char *frame); extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); + +extern int MMask_evaluateSymbol(int width, unsigned char *frame); +extern int MMask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask); #endif /* __QRENCODE_INNER_H__ */ diff --git a/tests/test_mask.c b/tests/test_mask.c new file mode 100644 index 0000000000..39e949b249 --- /dev/null +++ b/tests/test_mask.c @@ -0,0 +1,48 @@ +#include +#include +#include "common.h" +#include "../mask.h" +#include "../qrspec.h" + +void print_mask(int mask) +{ + const int w = 8; + unsigned char frame[w * w], *masked, *p; + int x, y; + + memset(frame, 0, w * w); + masked = Mask_makeMaskedFrame(w, frame, mask); + p = masked; + for(y=0; y Date: Wed, 20 May 2009 17:46:39 +0000 Subject: Test improved. --- tests/test_all.sh | 3 ++ tests/test_mask.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++---- tests/test_mmask.c | 80 +++++++++++++++++++++++++++++++++++---- 3 files changed, 177 insertions(+), 14 deletions(-) diff --git a/tests/test_all.sh b/tests/test_all.sh index c71f28d80a..06de1d4b02 100755 --- a/tests/test_all.sh +++ b/tests/test_all.sh @@ -6,4 +6,7 @@ ./test_qrspec ./test_rs ./test_split +./test_mask +./test_mqrspec +./test_mmask ./test_monkey diff --git a/tests/test_mask.c b/tests/test_mask.c index 39e949b249..698bb116e9 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -4,9 +4,69 @@ #include "../mask.h" #include "../qrspec.h" +char dot[2] = {'_', '#'}; +static char *maskPatterns[8] = { + /* (i + j) mod 2 = 0 */ + "#_#_#_" + "_#_#_#" + "#_#_#_" + "_#_#_#" + "#_#_#_" + "_#_#_#", + /* i mod 2 = 0 */ + "######" + "______" + "######" + "______" + "######" + "______", + /* j mod 3 = 0 */ + "#__#__" + "#__#__" + "#__#__" + "#__#__" + "#__#__" + "#__#__", + /* (i + j) mod 3 = 0 */ + "#__#__" + "__#__#" + "_#__#_" + "#__#__" + "__#__#" + "_#__#_", + /* ((i div 2) + (j div 3)) mod 2 = 0 */ + "###___" + "###___" + "___###" + "___###" + "###___" + "###___", + /* (ij) mod 2 + (ij) mod 3 = 0 */ + "######" + "#_____" + "#__#__" + "#_#_#_" + "#__#__" + "#_____", + /* ((ij) mod 2 + (ij) mod 3) mod 2 = 0 */ + "######" + "###___" + "##_##_" + "#_#_#_" + "#_##_#" + "#___##", + /* ((ij) mod 3 + (i+j) mod 2) mod 2 = 0 */ + "#_#_#_" + "___###" + "#___##" + "_#_#_#" + "###___" + "_###__" +}; + void print_mask(int mask) { - const int w = 8; + const int w = 6; unsigned char frame[w * w], *masked, *p; int x, y; @@ -15,11 +75,7 @@ void print_mask(int mask) p = masked; for(y=0; y Date: Wed, 20 May 2009 18:56:01 +0000 Subject: MQRraw_* has been implemented. Code cleanups. Struct QRRaw_code is slightly changed. New test has been added. --- ChangeLog | 7 +++++ qrencode.c | 85 +++++++++++++++++++++++++++++++++++++-------------- qrencode_inner.h | 11 ++++--- tests/test_qrencode.c | 38 +++++++++++++++++++++++ 4 files changed, 113 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0425d63a1a..c84cdc8293 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009.05.21 Kentaro FUKUCHI + * qrencode.c, qrencode_inner.h: + - MQRraw_* has been implemented. + - Code cleanups. Struct QRRaw_code is slightly changed. + * tests/test_qrencode.c: + - Added new test. + 2009.05.20 Kentaro FUKUCHI * Merged from 3.1.0 branch. (rev 2248:HEAD) * mqrspec.[ch], tests/create_mqr_frame_pattern.c: diff --git a/qrencode.c b/qrencode.c index 765c449b47..1457f81a00 100644 --- a/qrencode.c +++ b/qrencode.c @@ -46,14 +46,14 @@ typedef struct { typedef struct { int version; + int dataLength; + int eccLength; unsigned char *datacode; unsigned char *ecccode; + int b1; int blocks; RSblock *rsblock; int count; - int dataLength; - int eccLength; - int b1; } QRRawCode; static void RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int el, unsigned char *ecc, RS *rs) @@ -184,9 +184,7 @@ __STATIC void QRraw_free(QRRawCode *raw) if(raw != NULL) { free(raw->datacode); free(raw->ecccode); - if(raw->rsblock != NULL) { - free(raw->rsblock); - } + free(raw->rsblock); free(raw); } } @@ -195,42 +193,83 @@ __STATIC void QRraw_free(QRRawCode *raw) * Raw code for Micro QR Code *****************************************************************************/ -#if 0 typedef struct { int version; + int dataLength; + int eccLength; unsigned char *datacode; + unsigned char *ecccode; RSblock *rsblock; int count; - int dataLength; - int eccLength; } MQRRawCode; -MQRRawCode *MQRraw_new(QRinput *input) +__STATIC void MQRraw_free(MQRRawCode *raw); +__STATIC MQRRawCode *MQRraw_new(QRinput *input) { MQRRawCode *raw; - int i; - RSblock *rsblock; - unsigned char *p; + RS *rs; + + raw = (MQRRawCode *)malloc(sizeof(MQRRawCode)); + if(raw == NULL) return NULL; - p = QRinput_getByteStream(input); - if(p == NULL) { + raw->version = input->version; + raw->dataLength = MQRspec_getDataLength(input->version, input->level); + raw->eccLength = MQRspec_getECCLength(input->version, input->level); + raw->datacode = QRinput_getByteStream(input); + if(raw->datacode == NULL) { + free(raw); + return NULL; + } + raw->ecccode = (unsigned char *)malloc(raw->eccLength); + if(raw->ecccode == NULL) { + free(raw->datacode); + free(raw); return NULL; } - raw = (MQRRawCode *)malloc(sizeof(MQRRawCode)); - raw->datacode = p; - raw->version = input->version; - raw->rsblock = (RSblock *)malloc(sizeof(RSblock)); - RSblock_init(raw->rsblock, hoge, p, moge); + rs = init_rs(8, 0x11d, 0, 1, raw->eccLength, 255 - raw->dataLength - raw->eccLength); + if(rs == NULL) { + MQRraw_free(raw); + return NULL; + } + RSblock_initBlock(raw->rsblock, raw->dataLength, raw->datacode, raw->eccLength, raw->ecccode, rs); - raw->dataLength = ; - raw->eccLength = ; raw->count = 0; return raw; } -#endif + +/** + * Return a code (byte). + * This function can be called iteratively. + * @param raw raw code. + * @return code + */ +__STATIC unsigned char MQRraw_getCode(MQRRawCode *raw) +{ + unsigned char ret; + + if(raw->count < raw->dataLength) { + ret = raw->datacode[raw->count]; + } else if(raw->count < raw->dataLength + raw->eccLength) { + ret = raw->ecccode[raw->count - raw->dataLength]; + } else { + return 0; + } + raw->count++; + return ret; +} + +__STATIC void MQRraw_free(MQRRawCode *raw) +{ + if(raw != NULL) { + free(raw->datacode); + free(raw->ecccode); + free(raw->rsblock); + free(raw); + } +} /****************************************************************************** diff --git a/qrencode_inner.h b/qrencode_inner.h index cdad55c537..8010f25acc 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -46,14 +46,14 @@ typedef struct { typedef struct { int version; + int dataLength; + int eccLength; unsigned char *datacode; unsigned char *ecccode; + int b1; int blocks; RSblock *rsblock; int count; - int dataLength; - int eccLength; - int b1; } QRRawCode; extern QRRawCode *QRraw_new(QRinput *input); @@ -66,11 +66,12 @@ extern void QRraw_free(QRRawCode *raw); typedef struct { int version; + int dataLength; + int eccLength; unsigned char *datacode; + unsigned char *ecccode; RSblock *rsblock; int count; - int dataLength; - int eccLength; } MQRRawCode; extern MQRRawCode *MQRraw_new(QRinput *input); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 341190e1d9..1c8d2e664f 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -19,6 +19,43 @@ int inputSize(QRinput *input) return size; } +void test_qrraw_new(void) +{ + int i; + QRinput *stream; + char num[9] = "01234567"; + QRRawCode *raw; + + testStart("Test QRRaw_new()"); + stream = QRinput_new(); + QRinput_setVersion(stream, 10); + QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_Q); + QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); + + raw = QRraw_new(stream); + assert_nonnull(raw, "Failed QRraw_new().\n"); + assert_zero(raw->count, "QRraw.count = %d != 0\n", raw->count); + assert_equal(raw->version, 10, "QRraw.version was not expected.\n"); + assert_equal(raw->dataLength, 19 * 6 + 20 * 2, "QRraw.dataLength was not expected.\n"); + assert_equal(raw->eccLength, 24 * 8, "QRraw.dataLength was not expected.\n"); + assert_equal(raw->b1, 6, "QRraw.b1 was not expected.\n"); + assert_equal(raw->blocks, 8, "QRraw.blocks was not expected.\n"); + + for(i=0; ib1; i++) { + assert_equal(raw->rsblock[i].dataLength, 19, "QRraw.rsblock[].dataLength was not expected.\n"); + } + for(i=raw->b1; iblocks; i++) { + assert_equal(raw->rsblock[i].dataLength, 20, "QRraw.rsblock[].dataLength was not expected.\n"); + } + for(i=0; iblocks; i++) { + assert_equal(raw->rsblock[i].eccLength, 24, "QRraw.rsblock[].eccLength was not expected.\n"); + } + + QRinput_free(stream); + QRraw_free(raw); + testFinish(); +} + void test_iterate() { int i; @@ -688,6 +725,7 @@ int main(void) test_struct_example(); test_struct_semilong(); test_null_free(); + test_qrraw_new(); QRspec_clearCache(); free_rs_cache(); -- cgit 0.0.5-2-1-g0f52 From c071daf9a07abb802364a3dc47906c342b072525 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 29 May 2009 16:32:31 +0000 Subject: New option "--enable-thread-safety" has been added. This option is enabled by default. --- ChangeLog | 5 +++++ configure.ac | 10 ++++++++++ libqrencode.pc.in | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c84cdc8293..609f9e0999 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009.05.30 Kentaro FUKUCHI + * configure.ac, libqrencode.pc.in: + - New option "--enable-thread-safety" has been added. This option is + enabled by default. + 2009.05.21 Kentaro FUKUCHI * qrencode.c, qrencode_inner.h: - MQRraw_* has been implemented. diff --git a/configure.ac b/configure.ac index f89ecf08ea..5eb1d890d4 100644 --- a/configure.ac +++ b/configure.ac @@ -31,6 +31,10 @@ PKG_PROG_PKG_CONFIG AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1]) +dnl --enable-thread-safety +AC_ARG_ENABLE([thread-safety], [AC_HELP_STRING([--enable-thread-safety], [make the library thread-safe. [default=yes]])], + [], [enable_thread_safety=yes]) + dnl --with-tools AC_ARG_WITH([tools], [AC_HELP_STRING([--with-tools], [build utility tools [default=yes]])], [build_tools=$withval], [build_tools=yes]) @@ -76,6 +80,12 @@ AC_ARG_ENABLE([mudflap], [AC_HELP_STRING([--enable-mudflap], [generate extra cod dnl set CFLAGS CFLAGS="-Wall $CFLAGS" +if test $enable_thread_safety = yes; then + AC_CHECK_LIB([pthread], [pthread_mutex_init]) + LIBPTHREAD=-lpthread +fi +AC_SUBST(LIBPTHREAD) + if test $enable_gprof = yes; then CFLAGS="$CFLAGS -g -pg" fi diff --git a/libqrencode.pc.in b/libqrencode.pc.in index da3c8de5e9..c640f274fd 100644 --- a/libqrencode.pc.in +++ b/libqrencode.pc.in @@ -6,4 +6,4 @@ includedir=@includedir@ Name: libqrencode Description: A QR Code encoding library Version: @VERSION@ -Libs: -L${libdir} -lqrencode +Libs: -L${libdir} -lqrencode @LIBPTHREAD@ -- cgit 0.0.5-2-1-g0f52 From 2dca5f4753d2d36df0841888698cb8da55354e22 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 29 May 2009 16:34:12 +0000 Subject: libqrencode has become thread-safe. --- ChangeLog | 2 ++ qrspec.c | 15 ++++++++++++++- rscode.c | 13 +++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 609f9e0999..3e0d057c58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * configure.ac, libqrencode.pc.in: - New option "--enable-thread-safety" has been added. This option is enabled by default. + * rscode.c, qrspec.c: + - libqrencode has become thread-safe! (probably) 2009.05.21 Kentaro FUKUCHI * qrencode.c, qrencode_inner.h: diff --git a/qrspec.c b/qrspec.c index 1a04a95423..40be9ee54a 100644 --- a/qrspec.c +++ b/qrspec.c @@ -25,12 +25,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include #include #include #include +#ifdef HAVE_LIBPTHREAD +#include +#endif -#include "config.h" #include "qrspec.h" /****************************************************************************** @@ -394,6 +398,9 @@ unsigned int QRspec_getFormatInfo(int mask, QRecLevel level) /* C99 says that static storage shall be initialized to a null pointer * by compiler. */ static unsigned char *frames[QRSPEC_VERSION_MAX + 1]; +#ifdef HAVE_LIBPTHREAD +static pthread_mutex_t frames_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif /** * Put a finder pattern. @@ -517,9 +524,15 @@ unsigned char *QRspec_newFrame(int version) if(version < 1 || version > QRSPEC_VERSION_MAX) return NULL; +#ifdef HAVE_LIBPTHREAD + pthread_mutex_lock(&frames_mutex); +#endif if(frames[version] == NULL) { frames[version] = QRspec_createFrame(version); } +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&frames_mutex); +#endif if(frames[version] == NULL) return NULL; width = qrspecCapacity[version].width; diff --git a/rscode.c b/rscode.c index c92f6f23fc..b4d0d30282 100644 --- a/rscode.c +++ b/rscode.c @@ -28,6 +28,10 @@ #include #include "rscode.h" +#ifdef HAVE_LIBPTHREAD +# include +#endif + /* Stuff specific to the 8-bit symbol version of the general purpose RS codecs * */ @@ -53,6 +57,9 @@ struct _RS { }; static RS *rslist = NULL; +#ifdef HAVE_LIBPTHREAD +static pthread_mutex_t rslist_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif static inline int modnn(RS *rs, int x){ while (x >= rs->nn) { @@ -203,6 +210,9 @@ RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) { RS *rs; +#ifdef HAVE_LIBPTHREAD + pthread_mutex_lock(&rslist_mutex); +#endif for(rs = rslist; rs != NULL; rs = rs->next) { if(rs->pad != pad) continue; if(rs->nroots != nroots) continue; @@ -220,6 +230,9 @@ RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) rslist = rs; DONE: +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&rslist_mutex); +#endif return rs; } -- cgit 0.0.5-2-1-g0f52 From 01ad22918b9839952d0f76ddab77fa9335db1396 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 30 May 2009 07:30:57 +0000 Subject: Functions for Micro QR Code encoding have been added. --- ChangeLog | 16 +++ mqrspec.c | 30 +++-- qrencode.c | 7 +- qrencode.h | 14 +++ qrinput.c | 288 ++++++++++++++++++++++++++++++++++---------- qrinput.h | 1 + tests/common.h | 63 ++++------ tests/test_mask.c | 108 +++++++++++++++++ tests/test_mqrspec.c | 13 ++ tests/test_qrencode.c | 157 ++---------------------- tests/test_qrinput.c | 323 +++++++++++++++++++++++++++++++++++--------------- tests/test_qrspec.c | 13 ++ 12 files changed, 678 insertions(+), 355 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e0d057c58..5033f056b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,22 @@ enabled by default. * rscode.c, qrspec.c: - libqrencode has become thread-safe! (probably) + * tests/common.h: + - sprintfBin() removed, printBstream() added. + * qrinput.[ch], qrencode.[ch], mqrspec.c: + - Functions for Micro QR Code encoding have been added. + * tests/common.h: + - Utility functions improved. + * tests/*.c: + - Code cleanups. + - Tests for Micro QR Code added. + +2009.05.30 Kentaro FUKUCHI + * qrinput.c: + - padlen check was wrong in QRinput_appendPaddingBit(). + * tests/test_qrinput.c: + - Stop printing bstream->data. + - test_padding2() has been added. 2009.05.21 Kentaro FUKUCHI * qrencode.c, qrencode_inner.h: diff --git a/mqrspec.c b/mqrspec.c index 30a27a1e87..e62880109a 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -25,10 +25,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include #include #include #include +#ifdef HAVE_LIBPTHREAD +#include +#endif #include "mqrspec.h" @@ -38,19 +43,19 @@ typedef struct { int width; //< Edge length of the symbol - int ec[3]; //< Number of ECC code (bytes) + int ec[4]; //< Number of ECC code (bytes) } MQRspec_Capacity; /** * Table of the capacity of symbols - * See Table 1 (pp.10) and Table 8 (pp.113) of Appendix 1, JIS X0510:2004. + * See Table 1 (pp.106) and Table 8 (pp.113) of Appendix 1, JIS X0510:2004. */ static const MQRspec_Capacity mqrspecCapacity[MQRSPEC_VERSION_MAX + 1] = { - { 0, {0, 0, 0}}, - { 11, {2, 0, 0}}, - { 13, {5, 6, 0}}, - { 15, {6, 8, 0}}, - { 17, {8, 10, 14}} + { 0, {0, 0, 0, 0}}, + { 11, {2, 0, 0, 0}}, + { 13, {5, 6, 0, 0}}, + { 15, {6, 8, 0, 0}}, + { 17, {8, 10, 14, 0}} }; int MQRspec_getDataLength(int version, QRecLevel level) @@ -61,7 +66,7 @@ int MQRspec_getDataLength(int version, QRecLevel level) w = mqrspecCapacity[version].width - 1; ecc = mqrspecCapacity[version].ec[level]; if(ecc == 0) return 0; - +/* Warning again: unlike in QRSpec_getDataLength, return in BITS! */ return w * w - 64 - ecc * 8; } @@ -152,6 +157,9 @@ unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level) /* C99 says that static storage shall be initialized to a null pointer * by compiler. */ static unsigned char *frames[MQRSPEC_VERSION_MAX + 1]; +#ifdef HAVE_LIBPTHREAD +static pthread_mutex_t frames_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif /** * Put a finder pattern. @@ -231,9 +239,15 @@ unsigned char *MQRspec_newFrame(int version) if(version < 1 || version > MQRSPEC_VERSION_MAX) return NULL; +#ifdef HAVE_LIBPTHREAD + pthread_mutex_lock(&frames_mutex); +#endif if(frames[version] == NULL) { frames[version] = MQRspec_createFrame(version); } +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&frames_mutex); +#endif if(frames[version] == NULL) return NULL; width = mqrspecCapacity[version].width; diff --git a/qrencode.c b/qrencode.c index 1457f81a00..092cc80d59 100644 --- a/qrencode.c +++ b/qrencode.c @@ -208,6 +208,7 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) { MQRRawCode *raw; RS *rs; + int dl; raw = (MQRRawCode *)malloc(sizeof(MQRRawCode)); if(raw == NULL) return NULL; @@ -227,13 +228,14 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) return NULL; } - rs = init_rs(8, 0x11d, 0, 1, raw->eccLength, 255 - raw->dataLength - raw->eccLength); + dl = (raw->dataLength + 4)/ 8; // M1 and M3 has 4 bit length data code. + rs = init_rs(8, 0x11d, 0, 1, raw->eccLength, 255 - dl - raw->eccLength); if(rs == NULL) { MQRraw_free(raw); return NULL; } - RSblock_initBlock(raw->rsblock, raw->dataLength, raw->datacode, raw->eccLength, raw->ecccode, rs); + RSblock_initBlock(raw->rsblock, dl, raw->datacode, raw->eccLength, raw->ecccode, rs); raw->count = 0; @@ -245,6 +247,7 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) * This function can be called iteratively. * @param raw raw code. * @return code + * FIXME: M1 and M3 has 4bit-length data code! */ __STATIC unsigned char MQRraw_getCode(MQRRawCode *raw) { diff --git a/qrencode.h b/qrencode.h index 342df3bd6e..f9c48edfe5 100644 --- a/qrencode.h +++ b/qrencode.h @@ -157,6 +157,18 @@ extern QRinput *QRinput_new(void); */ extern QRinput *QRinput_new2(int version, QRecLevel level); +/** + * Instantiate an input data object. Object's Micro QR Code flag is set. + * Unlike with full-sized QR Code, version number must be specified (>0). + * @param version version number (1--4). + * @param level Error correction level. + * @return an input object (initialized). On error, NULL is returned and errno + * is set to indicate the error. + * @throw ENOMEM unable to allocate memory for input objects. + * @throw EINVAL invalid arguments. + */ +extern QRinput *QRinput_newMQR(int version, QRecLevel level); + /** * Append data to an input object. * The data is copied and appended to the input object. @@ -182,6 +194,7 @@ extern int QRinput_getVersion(QRinput *input); /** * Set version of the QR-code that is to be encoded. + * This function cannot be applied to Micro QR Code. * @param input input object. * @param version version number (0 = auto) * @retval 0 success. @@ -198,6 +211,7 @@ extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input); /** * Set error correction level of the QR-code that is to be encoded. + * This function cannot be applied to Micro QR Code. * @param input input object. * @param level Error correction level. * @retval 0 success. diff --git a/qrinput.c b/qrinput.c index cc10e5ab72..5ab6583b61 100644 --- a/qrinput.c +++ b/qrinput.c @@ -27,6 +27,7 @@ #include "config.h" #include "qrencode.h" #include "qrspec.h" +#include "mqrspec.h" #include "bitstream.h" #include "qrinput.h" @@ -115,10 +116,30 @@ QRinput *QRinput_new2(int version, QRecLevel level) input->tail = NULL; input->version = version; input->level = level; + input->mqr = 0; return input; } +QRinput *QRinput_newMQR(int version, QRecLevel level) +{ + QRinput *input; + + if(version <= 0 || version > MQRSPEC_VERSION_MAX) goto INVALID; + if((MQRspec_getECCLength(version, level) == 0)) goto INVALID; + + input = QRinput_new2(version, level); + if(input == NULL) return NULL; + + input->mqr = 1; + + return input; + +INVALID: + errno = EINVAL; + return NULL; +} + int QRinput_getVersion(QRinput *input) { return input->version; @@ -126,7 +147,7 @@ int QRinput_getVersion(QRinput *input) int QRinput_setVersion(QRinput *input, int version) { - if(version < 0 || version > QRSPEC_VERSION_MAX) { + if(input->mqr || version < 0 || version > QRSPEC_VERSION_MAX) { errno = EINVAL; return -1; } @@ -143,7 +164,7 @@ QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input) int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level) { - if(level > QR_ECLEVEL_H) { + if(input->mqr || level > QR_ECLEVEL_H) { errno = EINVAL; return -1; } @@ -257,7 +278,11 @@ QRinput *QRinput_dup(QRinput *input) QRinput *n; QRinput_List *list, *e; - n = QRinput_new2(input->version, input->level); + if(input->mqr) { + n = QRinput_newMQR(input->version, input->level); + } else { + n = QRinput_new2(input->version, input->level); + } if(n == NULL) return NULL; list = input->head; @@ -325,28 +350,36 @@ int QRinput_estimateBitsModeNum(int size) /** * Convert the number data to a bit stream. * @param entry + * @param mqr * @retval 0 success * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ -static int QRinput_encodeModeNum(QRinput_List *entry, int version) +static int QRinput_encodeModeNum(QRinput_List *entry, int version, int mqr) { int words, i, ret; unsigned int val; - words = entry->size / 3; entry->bstream = BitStream_new(); if(entry->bstream == NULL) return -1; - val = 0x1; - ret = BitStream_appendNum(entry->bstream, 4, val); - if(ret < 0) goto ABORT; + if(mqr) { + if(version > 1) { + ret = BitStream_appendNum(entry->bstream, version - 1, 0); + if(ret < 0) goto ABORT; + } + ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); + if(ret < 0) goto ABORT; + } else { + ret = BitStream_appendNum(entry->bstream, 4, 1); + if(ret < 0) goto ABORT; - val = entry->size; - ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), val); - if(ret < 0) goto ABORT; + ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); + if(ret < 0) goto ABORT; + } + words = entry->size / 3; for(i=0; idata[i*3 ] - '0') * 100; val += (entry->data[i*3+1] - '0') * 10; @@ -429,28 +462,38 @@ int QRinput_estimateBitsModeAn(int size) /** * Convert the alphabet-numeric data to a bit stream. * @param entry + * @param mqr * @retval 0 success * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. + * @throw EINVAL invalid version. */ -static int QRinput_encodeModeAn(QRinput_List *entry, int version) +static int QRinput_encodeModeAn(QRinput_List *entry, int version, int mqr) { int words, i, ret; unsigned int val; - words = entry->size / 2; entry->bstream = BitStream_new(); if(entry->bstream == NULL) return -1; - val = 0x2; - ret = BitStream_appendNum(entry->bstream, 4, val); - if(ret < 0) goto ABORT; - - val = entry->size; - ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), val); - if(ret < 0) goto ABORT; + if(mqr) { + if(version < 2) { + errno = EINVAL; + goto ABORT; + } + ret = BitStream_appendNum(entry->bstream, version - 1, 1); + if(ret < 0) goto ABORT; + ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_AN, version), entry->size); + if(ret < 0) goto ABORT; + } else { + ret = BitStream_appendNum(entry->bstream, 4, 2); + if(ret < 0) goto ABORT; + ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), entry->size); + if(ret < 0) goto ABORT; + } + words = entry->size / 2; for(i=0; idata[i*2 ]) * 45; val += (unsigned int)QRinput_lookAnTable(entry->data[i*2+1]); @@ -490,26 +533,34 @@ int QRinput_estimateBitsMode8(int size) /** * Convert the 8bits data to a bit stream. * @param entry + * @param mqr * @retval 0 success * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ -static int QRinput_encodeMode8(QRinput_List *entry, int version) +static int QRinput_encodeMode8(QRinput_List *entry, int version, int mqr) { int ret, i; - unsigned int val; entry->bstream = BitStream_new(); if(entry->bstream == NULL) return -1; - val = 0x4; - ret = BitStream_appendNum(entry->bstream, 4, val); - if(ret < 0) goto ABORT; - - val = entry->size; - ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), val); - if(ret < 0) goto ABORT; + if(mqr) { + if(version < 3) { + errno = EINVAL; + goto ABORT; + } + ret = BitStream_appendNum(entry->bstream, version - 1, 2); + if(ret < 0) goto ABORT; + ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_8, version), entry->size); + if(ret < 0) goto ABORT; + } else { + ret = BitStream_appendNum(entry->bstream, 4, 4); + if(ret < 0) goto ABORT; + ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), entry->size); + if(ret < 0) goto ABORT; + } for(i=0; isize; i++) { ret = BitStream_appendNum(entry->bstream, 8, entry->data[i]); @@ -565,12 +616,14 @@ static int QRinput_checkModeKanji(int size, const unsigned char *data) /** * Convert the kanji data to a bit stream. * @param entry + * @param mqr * @retval 0 success * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. + * @throw EINVAL invalid version. */ -static int QRinput_encodeModeKanji(QRinput_List *entry, int version) +static int QRinput_encodeModeKanji(QRinput_List *entry, int version, int mqr) { int ret, i; unsigned int val, h; @@ -578,13 +631,21 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, int version) entry->bstream = BitStream_new(); if(entry->bstream == NULL) return -1; - val = 0x8; - ret = BitStream_appendNum(entry->bstream, 4, val); - if(ret < 0) goto ABORT; - - val = entry->size / 2; - ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), val); - if(ret < 0) goto ABORT; + if(mqr) { + if(version < 2) { + errno = EINVAL; + goto ABORT; + } + ret = BitStream_appendNum(entry->bstream, version - 1, 3); + if(ret < 0) goto ABORT; + ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); + if(ret < 0) goto ABORT; + } else { + ret = BitStream_appendNum(entry->bstream, 4, 8); + if(ret < 0) goto ABORT; + ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); + if(ret < 0) goto ABORT; + } for(i=0; isize; i+=2) { val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1]; @@ -614,15 +675,21 @@ ABORT: /** * Convert a structure symbol code to a bit stream. * @param entry + * @param mqr * @retval 0 success * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. + * @throw EINVAL invalid entry. */ -static int QRinput_encodeModeStructure(QRinput_List *entry) +static int QRinput_encodeModeStructure(QRinput_List *entry, int mqr) { int ret; + if(mqr) { + errno = EINVAL; + return -1; + } entry->bstream = BitStream_new(); if(entry->bstream == NULL) return -1; @@ -681,9 +748,10 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) * Estimates the length of the encoded bit stream on the current version. * @param entry * @param version version of the symbol + * @param mqr * @return number of bits */ -static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version) +static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version, int mqr) { int bits = 0; int l, m; @@ -710,11 +778,17 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version return 0; } - l = QRspec_lengthIndicator(entry->mode, version); - m = 1 << l; - num = (entry->size + m - 1) / m; + if(mqr) { + l = QRspec_lengthIndicator(entry->mode, version); + m = version - 1; + bits += l + m; + } else { + l = QRspec_lengthIndicator(entry->mode, version); + m = 1 << l; + num = (entry->size + m - 1) / m; - bits += num * (4 + l); // mode indicator (4bits) + length indicator + bits += num * (4 + l); // mode indicator (4bits) + length indicator + } return bits; } @@ -732,7 +806,7 @@ __STATIC int QRinput_estimateBitStreamSize(QRinput *input, int version) list = input->head; while(list != NULL) { - bits += QRinput_estimateBitStreamSizeOfEntry(list, version); + bits += QRinput_estimateBitStreamSizeOfEntry(list, version, input->mqr); list = list->next; } @@ -820,7 +894,7 @@ __STATIC int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) * @param entry * @return number of bits (>0) or -1 for failure. */ -static int QRinput_encodeBitStream(QRinput_List *entry, int version) +static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) { int words, ret; QRinput_List *st1 = NULL, *st2 = NULL; @@ -837,9 +911,9 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version) st2 = QRinput_List_newEntry(entry->mode, entry->size - words, &entry->data[words]); if(st2 == NULL) goto ABORT; - ret = QRinput_encodeBitStream(st1, version); + ret = QRinput_encodeBitStream(st1, version, mqr); if(ret < 0) goto ABORT; - ret = QRinput_encodeBitStream(st2, version); + ret = QRinput_encodeBitStream(st2, version, mqr); if(ret < 0) goto ABORT; entry->bstream = BitStream_new(); if(entry->bstream == NULL) goto ABORT; @@ -853,19 +927,19 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version) ret = 0; switch(entry->mode) { case QR_MODE_NUM: - ret = QRinput_encodeModeNum(entry, version); + ret = QRinput_encodeModeNum(entry, version, mqr); break; case QR_MODE_AN: - ret = QRinput_encodeModeAn(entry, version); + ret = QRinput_encodeModeAn(entry, version, mqr); break; case QR_MODE_8: - ret = QRinput_encodeMode8(entry, version); + ret = QRinput_encodeMode8(entry, version, mqr); break; case QR_MODE_KANJI: - ret = QRinput_encodeModeKanji(entry, version); + ret = QRinput_encodeModeKanji(entry, version, mqr); break; case QR_MODE_STRUCTURE: - ret = QRinput_encodeModeStructure(entry); + ret = QRinput_encodeModeStructure(entry, mqr); break; default: break; @@ -895,7 +969,7 @@ static int QRinput_createBitStream(QRinput *input) list = input->head; while(list != NULL) { - bits = QRinput_encodeBitStream(list, input->version); + bits = QRinput_encodeBitStream(list, input->version, input->mqr); if(bits < 0) return -1; total += bits; list = list->next; @@ -920,6 +994,16 @@ static int QRinput_convertData(QRinput *input) int bits; int ver; + if(input->mqr) { + bits = QRinput_createBitStream(input); + if(bits < 0) return -1; + if(bits > MQRspec_getDataLength(input->version, input->level)) { + errno = EINVAL; + return -1; + } + return 0; + } + ver = QRinput_estimateVersion(input); if(ver > QRinput_getVersion(input)) { QRinput_setVersion(input, ver); @@ -966,21 +1050,90 @@ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) return 0; } - if(maxbits - bits < 5) { + if(maxbits - bits <= 4) { ret = BitStream_appendNum(bstream, maxbits - bits, 0); goto DONE; } - bits += 4; - words = (bits + 7) / 8; + words = (bits + 4 + 7) / 8; + + padding = BitStream_new(); + if(padding == NULL) return -1; + ret = BitStream_appendNum(padding, words * 8 - bits, 0); + if(ret < 0) goto DONE; + + padlen = maxwords - words; + if(padlen > 0) { + padbuf = (unsigned char *)malloc(padlen); + if(padbuf == NULL) { + ret = -1; + goto DONE; + } + for(i=0; iversion, input->level); + maxwords = maxbits / 8; + + if(maxbits == bits) { + return 0; + } + + termbits = input->version * 2 + 1; + + if(maxbits - bits <= termbits) { + ret = BitStream_appendNum(bstream, maxbits - bits, 0); + goto DONE; + } + + bits += termbits; + + words = (bits + 7) / 8; + if(maxbits - words * 8 > 0) { + termbits += words * 8 - bits; + if(words == maxwords) termbits += maxbits - words * 8; + } else { + termbits += words * 8 - bits; + } padding = BitStream_new(); if(padding == NULL) return -1; - ret = BitStream_appendNum(padding, words * 8 - bits + 4, 0); + ret = BitStream_appendNum(padding, termbits, 0); if(ret < 0) goto DONE; padlen = maxwords - words; - if(padlen > 1) { + if(padlen > 0) { padbuf = (unsigned char *)malloc(padlen); if(padbuf == NULL) { ret = -1; @@ -994,6 +1147,11 @@ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) if(ret < 0) { goto DONE; } + termbits = maxbits - maxwords * 8; + if(termbits > 0) { + ret = BitStream_appendNum(padding, termbits, 0); + if(ret < 0) goto DONE; + } } ret = BitStream_append(bstream, padding); @@ -1050,7 +1208,11 @@ __STATIC BitStream *QRinput_getBitStream(QRinput *input) if(bstream == NULL) { return NULL; } - ret = QRinput_appendPaddingBit(bstream, input); + if(input->mqr) { + ret = QRinput_appendPaddingBitMQR(bstream, input); + } else { + ret = QRinput_appendPaddingBit(bstream, input); + } if(ret < 0) { BitStream_free(bstream); return NULL; @@ -1241,9 +1403,9 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) list = input->head; prev = NULL; while(list != NULL) { - nextbits = QRinput_estimateBitStreamSizeOfEntry(list, input->version); + nextbits = QRinput_estimateBitStreamSizeOfEntry(list, input->version, input->mqr); if(bits + nextbits <= maxbits) { - ret = QRinput_encodeBitStream(list, input->version); + ret = QRinput_encodeBitStream(list, input->version, input->mqr); if(ret < 0) goto ABORT; bits += ret; prev = list; @@ -1327,3 +1489,7 @@ int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s) return 0; } + +/****************************************************************************** + * Functions for Micro QR Code + *****************************************************************************/ diff --git a/qrinput.h b/qrinput.h index 21ced70430..de4ab77b4d 100644 --- a/qrinput.h +++ b/qrinput.h @@ -46,6 +46,7 @@ struct _QRinput { QRecLevel level; QRinput_List *head; QRinput_List *tail; + int mqr; }; /****************************************************************************** diff --git a/tests/common.h b/tests/common.h index 6156c7cb46..ede98d0831 100644 --- a/tests/common.h +++ b/tests/common.h @@ -123,15 +123,23 @@ void report() int ncmpBin(char *correct, BitStream *bstream, int len) { int i, bit; + char *p; if(len != BitStream_size(bstream)) { printf("Length is not match: %d, %d expected.\n", BitStream_size(bstream), len); return -1; } - for(i=0; idata[i] != bit) return -1; + i++; + p++; } return 0; @@ -139,50 +147,25 @@ int ncmpBin(char *correct, BitStream *bstream, int len) int cmpBin(char *correct, BitStream *bstream) { - int len; + int len = 0; + char *p; - len = strlen(correct); + + for(p = correct; *p != '\0'; p++) { + if(*p != ' ') len++; + } return ncmpBin(correct, bstream, len); } -char *sprintfBin(int size, unsigned char *data) +void printBstream(BitStream *bstream) { - int i, j; - unsigned char mask; - int b, r; - char *str, *p; - - str = (char *)malloc(size + 1); - p = str; - b = size / 8; - for(i=0; i> 1; - } - } - r = size - b * 8; - if(r) { - mask = 1 << (r - 1); - for(i=0; i> 1; - } - } - *p = '\0'; + int i, size; - return str; + size = BitStream_size(bstream); + for(i=0; idata[i]?"1":"0"); + } + printf("\n"); } static char qrModeChar[4] = {'n', 'a', '8', 'k'}; diff --git a/tests/test_mask.c b/tests/test_mask.c index 698bb116e9..81cd115061 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -131,10 +131,118 @@ void test_masks(void) testFinish(); } +#define N1 (3) +#define N2 (3) +#define N3 (40) +#define N4 (10) + +void test_eval(void) +{ + unsigned char *frame; + int w = 6; + int demerit; + + frame = (unsigned char *)malloc(w * w); + + testStart("Test mask evaluation (all white)"); + memset(frame, 0, w * w); + demerit = Mask_evaluateSymbol(w, frame); + testEndExp(demerit == ((N1 + 1)*w*2 + N2 * (w - 1) * (w - 1))); + + testStart("Test mask evaluation (all black)"); + memset(frame, 1, w * w); + demerit = Mask_evaluateSymbol(w, frame); + testEndExp(demerit == ((N1 + 1)*w*2 + N2 * (w - 1) * (w - 1))); + + free(frame); +} + +/* .#.#.#.#.# + * #.#.#.#.#. + * ..##..##.. + * ##..##..## + * ...###...# + * ###...###. + * ....####.. + * ####....## + * .....##### + * #####..... + */ +void test_eval2(void) +{ + unsigned char *frame; + int w = 10; + int demerit; + int x; + + frame = (unsigned char *)malloc(w * w); + + testStart("Test mask evaluation (run length penalty check)"); + for(x=0; xcount, "QRraw.count = %d != 0\n", raw->count); - assert_equal(raw->version, 10, "QRraw.version was not expected.\n"); - assert_equal(raw->dataLength, 19 * 6 + 20 * 2, "QRraw.dataLength was not expected.\n"); - assert_equal(raw->eccLength, 24 * 8, "QRraw.dataLength was not expected.\n"); - assert_equal(raw->b1, 6, "QRraw.b1 was not expected.\n"); - assert_equal(raw->blocks, 8, "QRraw.blocks was not expected.\n"); + assert_equal(raw->version, 10, "QRraw.version was not as expected. (%d)\n", raw->version); + assert_equal(raw->dataLength, 19 * 6 + 20 * 2, "QRraw.dataLength was not as expected.\n"); + assert_equal(raw->eccLength, 24 * 8, "QRraw.dataLength was not as expected.\n"); + assert_equal(raw->b1, 6, "QRraw.b1 was not as expected.\n"); + assert_equal(raw->blocks, 8, "QRraw.blocks was not as expected.\n"); for(i=0; ib1; i++) { - assert_equal(raw->rsblock[i].dataLength, 19, "QRraw.rsblock[].dataLength was not expected.\n"); + assert_equal(raw->rsblock[i].dataLength, 19, "QRraw.rsblock[].dataLength was not as expected.\n"); } for(i=raw->b1; iblocks; i++) { - assert_equal(raw->rsblock[i].dataLength, 20, "QRraw.rsblock[].dataLength was not expected.\n"); + assert_equal(raw->rsblock[i].dataLength, 20, "QRraw.rsblock[].dataLength was not as expected.\n"); } for(i=0; iblocks; i++) { - assert_equal(raw->rsblock[i].eccLength, 24, "QRraw.rsblock[].eccLength was not expected.\n"); + assert_equal(raw->rsblock[i].eccLength, 24, "QRraw.rsblock[].eccLength was not as expected.\n"); } QRinput_free(stream); @@ -179,38 +179,6 @@ void test_filler(void) } #endif -void print_mask(void) -{ - int mask; - int x, y; - int version = 4; - int width; - unsigned char *frame, *masked, *p; - - width = QRspec_getWidth(version); - frame = (unsigned char *)malloc(width * width); - memset(frame, 0x20, width * width); - for(mask=0; mask<8; mask++) { - masked = Mask_makeMask(width, frame, mask, QR_ECLEVEL_L); - p = masked; - printf("mask %d:\n", mask); - for(y=0; ydata); - testEnd(cmpBin(correct, bstream)); - QRinput_free(stream); + if(mqr) { + input = QRinput_newMQR(version, level); + } else { + input = QRinput_new2(version, level); + } + QRinput_append(input, mode, strlen(data), (unsigned char *)data); + bstream = QRinput_getBitStream(input); + ret = cmpBin(correct, bstream); + if(ret) { + printf("result : "); + printBstream(bstream); + printf("correct: %s\n", correct); + } + QRinput_free(input); BitStream_free(bstream); - free(buf); + + return ret; +} + +int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct) +{ + QRinput *input; + BitStream *bstream; + int ret; + + if(mqr) { + input = QRinput_newMQR(1, QR_ECLEVEL_L); + } else { + input = QRinput_new(); + } + QRinput_append(input, mode, strlen(data), (unsigned char *)data); + bstream = QRinput_mergeBitStream(input); + ret = cmpBin(correct, bstream); + QRinput_free(input); + BitStream_free(bstream); + + return ret; +} + +void test_encodeKanji(void) +{ + char str[5]= {0x93, 0x5f,0xe4, 0xaa, 0x00}; + char *correct = "10000000001001101100111111101010101010"; + + testStart("Encoding kanji stream."); + testEnd(mergeAndCheckBStream(0, QR_MODE_KANJI, str, correct)); } void test_encode8(void) { - QRinput *stream; char str[] = "AC-42"; char correct[] = "0100000001010100000101000011001011010011010000110010"; - BitStream *bstream; testStart("Encoding 8bit stream."); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_8, 5, (unsigned char *)str); - bstream = QRinput_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(cmpBin(correct, bstream)); - QRinput_free(stream); - BitStream_free(bstream); + testEnd(mergeAndCheckBStream(0, QR_MODE_8, str, correct)); } void test_encode8_versionup(void) @@ -69,20 +92,11 @@ void test_encode8_versionup(void) void test_encodeAn(void) { - QRinput *stream; - char str[] = "AC-42"; + char *str = "AC-42"; char correct[] = "00100000001010011100111011100111001000010"; - BitStream *bstream; testStart("Encoding alphabet-numeric stream."); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str); - bstream = QRinput_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(cmpBin(correct, bstream)); - QRinput_free(stream); - BitStream_free(bstream); + testEnd(mergeAndCheckBStream(0, QR_MODE_AN, str, correct)); } void test_encodeAn2(void) @@ -100,20 +114,11 @@ void test_encodeAn2(void) void test_encodeNumeric(void) { - QRinput *stream; - char num[9] = "01234567"; + char *str = "01234567"; char correct[] = "00010000001000000000110001010110011000011"; - BitStream *bstream; testStart("Encoding numeric stream. (8 digits)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - bstream = QRinput_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(cmpBin(correct, bstream)); - QRinput_free(stream); - BitStream_free(bstream); + testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct)); } void test_encodeNumeric_versionup(void) @@ -139,56 +144,42 @@ void test_encodeNumeric_versionup(void) void test_encodeNumericPadded(void) { - QRinput *stream; - char num[9] = "01234567"; + char *str = "01234567"; char *correct; char *correctHead = "000100000010000000001100010101100110000110000000"; - BitStream *bstream; - int flag, i; + int i, ret; testStart("Encoding numeric stream. (8 digits)(padded)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); - bstream = QRinput_getBitStream(stream); correct = (char *)malloc(19 * 8 + 1); correct[0] = '\0'; strcat(correct, correctHead); for(i=0; i<13; i++) { strcat(correct, (i&1)?"00010001":"11101100"); } - flag = cmpBin(correct, bstream); - testEnd(flag); + ret = encodeAndCheckBStream(0, 0, QR_ECLEVEL_L, QR_MODE_NUM, str, correct); + testEnd(ret); free(correct); - QRinput_free(stream); - BitStream_free(bstream); } void test_encodeNumericPadded2(void) { - QRinput *stream; - char num[8] = "0123456"; + char *str = "0123456"; char *correct; char *correctHead = "000100000001110000001100010101100101100000000000"; - BitStream *bstream; - int flag, i; + int i, ret; testStart("Encoding numeric stream. (7 digits)(padded)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_NUM, 7, (unsigned char *)num); - bstream = QRinput_getBitStream(stream); correct = (char *)malloc(19 * 8 + 1); correct[0] = '\0'; strcat(correct, correctHead); for(i=0; i<13; i++) { strcat(correct, (i&1)?"00010001":"11101100"); } - flag = cmpBin(correct, bstream); - testEnd(flag); + ret = encodeAndCheckBStream(0, 0, QR_ECLEVEL_L, QR_MODE_NUM, str, correct); + testEnd(ret); free(correct); - QRinput_free(stream); - BitStream_free(bstream); } void test_padding(void) @@ -200,7 +191,7 @@ void test_padding(void) unsigned char c; testStart("Padding bit check. (less than 5 bits)"); - input = QRinput_new2(0, QR_ECLEVEL_L); + input = QRinput_new2(1, QR_ECLEVEL_L); QRinput_append(input, QR_MODE_8, 17, (unsigned char *)data); bstream = QRinput_getBitStream(input); size = BitStream_size(bstream); @@ -216,40 +207,77 @@ void test_padding(void) BitStream_free(bstream); } -void test_encodeNumeric2(void) +void test_padding2(void) { - QRinput *stream; - char num[] = "0123456789012345"; - char correct[] = "00010000010000000000110001010110011010100110111000010100111010100101"; + QRinput *input; BitStream *bstream; + int i, size, ret; + char data[] = "0123456789ABCDeF"; + char correct[153]; + unsigned char c; - testStart("Encoding numeric stream. (16 digits)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num); - bstream = QRinput_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(cmpBin(correct, bstream)); - QRinput_free(stream); + testStart("Padding bit check. (1 or 2 padding bytes)"); + + /* 16 byte data (4 bit terminator and 1 byte padding) */ + memset(correct, 0, 153); + memcpy(correct, "010000010000", 12); + for(size=0; size<16; size++) { + c = 0x80; + for(i=0; i<8; i++) { + correct[size * 8 + i + 12] = (data[size]&c)?'1':'0'; + c = c >> 1; + } + } + memcpy(correct + 140, "000011101100", 12); + + input = QRinput_new2(1, QR_ECLEVEL_L); + QRinput_append(input, QR_MODE_8, 16, (unsigned char *)data); + bstream = QRinput_getBitStream(input); + size = BitStream_size(bstream); + assert_equal(size, 152, "16byte: # of bit is incorrect (%d != 152).\n", size); + ret = ncmpBin(correct, bstream, 152); + assert_zero(ret, "Padding bits incorrect.\n"); + printBstream(bstream); + + QRinput_free(input); + BitStream_free(bstream); + + /* 15 byte data (4 bit terminator and 2 byte paddings) */ + + memcpy(correct, "010000001111", 12); + memcpy(correct + 132, "00001110110000010001", 20); + + input = QRinput_new2(1, QR_ECLEVEL_L); + QRinput_append(input, QR_MODE_8, 15, (unsigned char *)data); + bstream = QRinput_getBitStream(input); + size = BitStream_size(bstream); + assert_equal(size, 152, "15byte: # of bit is incorrect (%d != 152).\n", size); + ret = ncmpBin(correct, bstream, 152); + assert_zero(ret, "Padding bits incorrect.\n"); + printBstream(bstream); + + testFinish(); + + QRinput_free(input); BitStream_free(bstream); } +void test_encodeNumeric2(void) +{ + char *str = "0123456789012345"; + char *correct = "00010000010000000000110001010110011010100110111000010100111010100101"; + + testStart("Encoding numeric stream. (16 digits)"); + testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct)); +} + void test_encodeNumeric3(void) { - QRinput *stream; - char num[9] = "0123456"; - char correct[] = "0001""0000000111""0000001100""0101011001""0110"; - BitStream *bstream; + char *str = "0123456"; + char *correct = "0001 0000000111 0000001100 0101011001 0110"; testStart("Encoding numeric stream. (7 digits)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_NUM, 7, (unsigned char *)num); - bstream = QRinput_mergeBitStream(stream); - printf("%s\n", correct); - printf("%s\n", bstream->data); - testEnd(cmpBin(correct, bstream)); - QRinput_free(stream); - BitStream_free(bstream); + testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct)); } void test_encodeTooLong(void) @@ -756,6 +784,104 @@ void test_null_free(void) testFinish(); } +void test_mqr_new(void) +{ + QRinput *input; + testStart("Testing QRinput_newMQR()."); + + input = QRinput_newMQR(0, QR_ECLEVEL_L); + assert_null(input, "Version 0 passed.\n"); + QRinput_free(input); + + input = QRinput_newMQR(5, QR_ECLEVEL_L); + assert_null(input, "Version 5 passed.\n"); + QRinput_free(input); + + input = QRinput_newMQR(1, QR_ECLEVEL_M); + assert_null(input, "Invalid ECLEVEL passed.\n"); + QRinput_free(input); + + input = QRinput_newMQR(1, QR_ECLEVEL_L); + assert_equal(input->version, 1, "QRinput.version was not as expected.\n"); + assert_equal(input->level, QR_ECLEVEL_L, "QRinput.version was not as expected.\n"); + QRinput_free(input); + + testFinish(); +} + +void test_mqr_setversion(void) +{ + QRinput *input; + int ret; + testStart("Testing QRinput_setVersion() for MQR."); + + input = QRinput_newMQR(1, QR_ECLEVEL_L); + ret = QRinput_setVersion(input, 2); + assert_exp((ret < 0), "QRinput_setVersion should be denied.\n"); + QRinput_free(input); + + testFinish(); +} + +void test_mqr_setlevel(void) +{ + QRinput *input; + int ret; + testStart("Testing QRinput_setErrorCorrectionLevel() for MQR."); + + input = QRinput_newMQR(1, QR_ECLEVEL_L); + ret = QRinput_setErrorCorrectionLevel(input, QR_ECLEVEL_M); + assert_exp((ret < 0), "QRinput_setErrorCorrectionLevel should be denied.\n"); + QRinput_free(input); + + testFinish(); +} + +void test_paddingMQR(void) +{ + char *dataM1[] = {"65", "513", "5139", "51365"}; + char *correctM1[] = {"01010000010000000000", + "01110000000010000000", + "10010000000011001000", + "10110000000011000001"}; + char *dataM2[] = {"513513", "51351365"}; + char *correctM2[] = {"0 0110 1000000001 1000000001 0000000", + "0 1000 1000000001 1000000001 1000001"}; + int i, ret; + + testStart("Padding bit check of MQR. (only 0 padding)"); + for(i=0; i<4; i++) { + ret = encodeAndCheckBStream(1, 1, QR_ECLEVEL_L, QR_MODE_NUM, dataM1[i], correctM1[i]); + assert_zero(ret, "Number %s incorrectly encoded.\n", dataM1[i]); + } + for(i=0; i<2; i++) { + ret = encodeAndCheckBStream(1, 2, QR_ECLEVEL_M, QR_MODE_NUM, dataM2[i], correctM2[i]); + assert_zero(ret, "Number %s incorrectly encoded.\n", dataM2[i]); + } + testFinish(); +} + +void test_padding2MQR(void) +{ + char *data[] = {"9", "513513", "513", "513"}; + int ver[] = {1, 2, 2, 3}; + char *correct[] = {"00110010 00000000 0000", + "0 0110 1000000001 1000000001 0000000 11101100", + "0 0011 1000000001 000000000 11101100 00010001", + "00 00011 1000000001 0000000 11101100 00010001 11101100 00010001 11101100 00010001 11101100 0000" + }; + int i, ret; + + testStart("Padding bit check. (1 or 2 padding bytes)"); + + for(i=0; i<4; i++) { + ret = encodeAndCheckBStream(1, ver[i], QR_ECLEVEL_L, QR_MODE_NUM, data[i], correct[i]); + assert_zero(ret, "Number %s incorrectly encoded.\n", data[i]); + } + testFinish(); +} + + int main(void) { test_encodeNumeric(); @@ -772,6 +898,7 @@ int main(void) test_encodeNumericPadded2(); test_encodeAnNum(); test_padding(); + test_padding2(); test_struct_listop(); test_insertStructuredAppendHeader(); test_insertStructuredAppendHeader_error(); @@ -787,6 +914,12 @@ int main(void) test_parity2(); test_null_free(); + test_mqr_new(); + test_mqr_setversion(); + test_mqr_setlevel(); + test_paddingMQR(); + test_padding2MQR(); + report(); return 0; diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 40c64d6569..67fce13598 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -145,6 +145,18 @@ void test_newframe(void) fclose(fp); } +void test_newframe_invalid(void) +{ + unsigned char *frame; + + testStart("Checking QRspec_newFrame with invalid version."); + frame = QRspec_newFrame(0); + assert_null(frame, "QRspec_newFrame(0) returns non-NULL."); + frame = QRspec_newFrame(QRSPEC_VERSION_MAX+1); + assert_null(frame, "QRspec_newFrame(0) returns non-NULL."); + testFinish(); +} + #if 0 /* This test is used to check positions of alignment pattern. See Appendix E * (pp.71) of JIS X0510:2004 and compare to the output. Before comment out @@ -294,6 +306,7 @@ int main(void) test_eccTable2(); //print_eccTable(); test_newframe(); + test_newframe_invalid(); //test_alignment(); test_verpat(); //print_newFrame(); -- cgit 0.0.5-2-1-g0f52 From f491b14f72459bfee7f06beb2a09e7d9f0330009 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 1 Jun 2009 01:57:54 +0000 Subject: Error check added. --- tests/prof_qrencode.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index 9230f07b05..c61b646dcc 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "../qrencode.h" #include "../qrspec.h" #include "../rscode.h" @@ -33,7 +34,11 @@ void prof_ver1to10(void) for(i=0; i<500; i++) { for(version = 0; version < 11; version++) { code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0); - QRcode_free(code); + if(code == NULL) { + perror("Failed to encode:"); + } else { + QRcode_free(code); + } } } timerStop(); @@ -50,7 +55,11 @@ void prof_ver31to40(void) for(i=0; i<50; i++) { for(version = 31; version < 41; version++) { code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0); - QRcode_free(code); + if(code == NULL) { + perror("Failed to encode:"); + } else { + QRcode_free(code); + } } } timerStop(); -- cgit 0.0.5-2-1-g0f52 From eb8353e47811f5acc361f615a3c05b2499a37774 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 1 Jun 2009 07:33:15 +0000 Subject: Bug fixed. --- tests/common.h | 1 + tests/test_bitstream.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/common.h b/tests/common.h index ede98d0831..1b72a8b1a7 100644 --- a/tests/common.h +++ b/tests/common.h @@ -140,6 +140,7 @@ int ncmpBin(char *correct, BitStream *bstream, int len) if(bstream->data[i] != bit) return -1; i++; p++; + if(i == len) break; } return 0; diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index cac4174c6e..120de58a4d 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -9,8 +9,8 @@ void test_null(void) testStart("Empty stream"); bstream = BitStream_new(); - assert_zero(BitStream_size(bstream), "Size of empty BitStream is not 0."); - assert_null(BitStream_toByte(bstream), "BitStream_toByte returned non-NULL."); + assert_zero(BitStream_size(bstream), "Size of empty BitStream is not 0.\n"); + assert_null(BitStream_toByte(bstream), "BitStream_toByte returned non-NULL.\n"); assert_nothing(BitStream_free(NULL), "Check BitStream_free(NULL).\n"); testFinish(); @@ -47,20 +47,20 @@ void test_bytes(void) void test_appendNum(void) { BitStream *bstream; - char correct[] = "10001010111111111111111100010010001101000101011001111000"; + char correct[] = "10001010 11111111 11111111 00010010001101000101011001111000"; testStart("Append Num"); bstream = BitStream_new(); BitStream_appendNum(bstream, 8, 0x0000008a); - assert_zero(ncmpBin(correct, bstream, 8), "Internal data is incorrect."); + assert_zero(ncmpBin(correct, bstream, 8), "Internal data is incorrect.\n"); BitStream_appendNum(bstream, 16, 0x0000ffff); - assert_zero(ncmpBin(correct, bstream, 24), "Internal data is incorrect."); + assert_zero(ncmpBin(correct, bstream, 24), "Internal data is incorrect.\n"); BitStream_appendNum(bstream, 32, 0x12345678); - assert_zero(cmpBin(correct, bstream), "Internal data is incorrect."); + assert_zero(cmpBin(correct, bstream), "Internal data is incorrect.\n"); testFinish(); BitStream_free(bstream); @@ -82,7 +82,7 @@ void test_appendBytes(void) data[0] = 0xff; data[1] = 0xff; BitStream_appendBytes(bstream, 2, data); - assert_zero(ncmpBin(correct, bstream, 24), "Internal data is incorrect."); + assert_zero(ncmpBin(correct, bstream, 24), "Internal data is incorrect.\n"); data[0] = 0x12; data[1] = 0x34; @@ -90,7 +90,7 @@ void test_appendBytes(void) data[3] = 0x78; BitStream_appendBytes(bstream, 4, data); - assert_zero(cmpBin(correct, bstream), "Internal data is incorrect."); + assert_zero(cmpBin(correct, bstream), "Internal data is incorrect.\n"); testFinish(); BitStream_free(bstream); -- cgit 0.0.5-2-1-g0f52 From a6d6f496d80170d335dc4c099be462598bd78767 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 1 Jun 2009 07:38:48 +0000 Subject: --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5033f056b9..d9a721acc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009.06.01 Kentaro FUKUCHI + * tests/prof_qrencode.c: + - Error check has been added. + * tests/common.h: + - Bug fixed. + 2009.05.30 Kentaro FUKUCHI * configure.ac, libqrencode.pc.in: - New option "--enable-thread-safety" has been added. This option is -- cgit 0.0.5-2-1-g0f52 From d4b1856383834b5cbc395cded10df9dcfa022879 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 1 Jun 2009 07:50:00 +0000 Subject: mqr check has been added. --- ChangeLog | 3 +++ qrencode.h | 7 +++++-- qrinput.c | 10 ++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9a721acc3..f90d35d943 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ - Error check has been added. * tests/common.h: - Bug fixed. + * qrinput.c, qrencode.h: + - QRinput_Struct_appendInput() and QRinput_splitQRinputToStruct() now + checks mqr flag. 2009.05.30 Kentaro FUKUCHI * configure.ac, libqrencode.pc.in: diff --git a/qrencode.h b/qrencode.h index f9c48edfe5..dc697def59 100644 --- a/qrencode.h +++ b/qrencode.h @@ -257,13 +257,15 @@ extern QRinput_Struct *QRinput_Struct_new(void); extern void QRinput_Struct_setParity(QRinput_Struct *s, unsigned char parity); /** - * Append a QRinput object to the set. + * Append a QRinput object to the set. QRinput created by QRinput_newMQR() + * will be rejected. * @warning never append the same QRinput object twice or more. * @param s structured input object. * @param input an input object. * @retval >0 number of input objects in the structure. * @retval -1 an error occurred. See Exceptions for the details. * @throw ENOMEM unable to allocate memory. + * @throw EINVAL invalid arguments. */ extern int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input); @@ -275,7 +277,8 @@ extern void QRinput_Struct_free(QRinput_Struct *s); /** * Split a QRinput to QRinput_Struct. It calculates a parity, set it, then - * insert structured-append headers. + * insert structured-append headers. QRinput created by QRinput_newMQR() will + * be rejected. * @param input input object. Version number and error correction level must be * set. * @return a set of input data. On error, NULL is returned, and errno is set diff --git a/qrinput.c b/qrinput.c index 5ab6583b61..ef1ded4177 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1291,6 +1291,11 @@ int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input) { QRinput_InputList *e; + if(input->mqr) { + errno = EINVAL; + return -1; + } + e = QRinput_InputList_newEntry(input); if(e == NULL) return -1; @@ -1381,6 +1386,11 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) int bits, maxbits, nextbits, bytes, ret; QRinput_List *list, *next, *prev; + if(input->mqr) { + errno = EINVAL; + return NULL; + } + s = QRinput_Struct_new(); if(s == NULL) return NULL; -- cgit 0.0.5-2-1-g0f52 From f51ca3bb73725cc2726ac796faddcf0af72fae0d Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 1 Jun 2009 08:07:04 +0000 Subject: New test of 4bit padding of _toByte(). --- ChangeLog | 2 ++ tests/test_bitstream.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ChangeLog b/ChangeLog index f90d35d943..63313d6320 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ * qrinput.c, qrencode.h: - QRinput_Struct_appendInput() and QRinput_splitQRinputToStruct() now checks mqr flag. + * tests/test_bitstream.c: + - New test of 4bit padding of _toByte(). 2009.05.30 Kentaro FUKUCHI * configure.ac, libqrencode.pc.in: diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 120de58a4d..b9449bbb57 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -118,6 +118,32 @@ void test_toByte(void) free(result); } +void test_toByte_4bitpadding(void) +{ + BitStream *bstream; + unsigned char *result; + + testStart("Convert to a byte array"); + + bstream = BitStream_new(); + BitStream_appendNum(bstream, 4, 0xb); + result = BitStream_toByte(bstream); + assert_equal(result[0], 0xb, "incorrect paddings\n"); + BitStream_free(bstream); + free(result); + + bstream = BitStream_new(); + BitStream_appendNum(bstream, 12, 0x335); + result = BitStream_toByte(bstream); + assert_equal(result[0], 0x33, "incorrect paddings\n"); + assert_equal(result[1], 0x05, "incorrect paddings\n"); + BitStream_free(bstream); + free(result); + + testFinish(); + +} + void test_size(void) { BitStream *bstream; @@ -142,6 +168,7 @@ int main(void) test_appendNum(); test_appendBytes(); test_toByte(); + test_toByte_4bitpadding(); test_size(); report(); -- cgit 0.0.5-2-1-g0f52 From f7be36d2aebb585a294de1525885f70366b64076 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 1 Jun 2009 16:33:32 +0000 Subject: Wrong maskNum. --- mmask.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmask.c b/mmask.c index c81db684aa..368a51fbce 100644 --- a/mmask.c +++ b/mmask.c @@ -81,7 +81,7 @@ static void Mask_mask3(int width, const unsigned char *s, unsigned char *d) MASKMAKER((((x+y)&1)+((x*y)%3))&1) } -#define maskNum (8) +#define maskNum (4) typedef void MaskMaker(int, const unsigned char *, unsigned char *); static MaskMaker *maskMakers[maskNum] = { Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3 -- cgit 0.0.5-2-1-g0f52 From 01e9b0d7ba43ea2feae5766b0cfe0984bcf2993b Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 3 Jun 2009 20:40:34 +0000 Subject: Error check has been added to Mask_makeMask(). --- mask.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mask.c b/mask.c index a5d9fb5d4c..aaf8b24a19 100644 --- a/mask.c +++ b/mask.c @@ -19,10 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" #include #include #include -#include "config.h" +#include #include "qrencode.h" #include "qrspec.h" #include "mask.h" @@ -159,6 +160,11 @@ unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLeve { unsigned char *masked; + if(mask < 0 || mask >= maskNum) { + errno = EINVAL; + return NULL; + } + masked = (unsigned char *)malloc(width * width); if(masked == NULL) return NULL; -- cgit 0.0.5-2-1-g0f52 From 9a30684d4a843ba625260e8dde27e37f1bf9414a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 3 Jun 2009 20:40:45 +0000 Subject: Dependency check was incorrect because of misconfiguration. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 7972a0aa26..7d9c238e6b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,6 +33,6 @@ if BUILD_TOOLS bin_PROGRAMS = qrencode qrencode_SOURCES = qrenc.c qrencode_CFLAGS = $(png_CFLAGS) -qrencode_LDADD = -lqrencode $(png_LIBS) +qrencode_LDADD = libqrencode.la $(png_LIBS) man1_MANS = qrencode.1 endif -- cgit 0.0.5-2-1-g0f52 From ad69ad25a48174ed1a723fcd3fd8ede64e23fbdd Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 3 Jun 2009 20:42:21 +0000 Subject: Bug fix and error check. --- mmask.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mmask.c b/mmask.c index 368a51fbce..5c6c5d5980 100644 --- a/mmask.c +++ b/mmask.c @@ -19,10 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" #include #include #include -#include "config.h" +#include #include "qrencode.h" #include "mqrspec.h" #include "mmask.h" @@ -37,13 +38,13 @@ __STATIC void MMask_writeFormatInformation(int version, int width, unsigned char for(i=0; i<8; i++) { v = 0x84 | (format & 1); - frame[width * (i + 1)+ 8] = v; - format= format >> 1; + frame[width * (i + 1) + 8] = v; + format = format >> 1; } for(i=0; i<7; i++) { v = 0x84 | (format & 1); - frame[width * 8 + 8 - i] = v; - format= format >> 1; + frame[width * 8 + 7 - i] = v; + format = format >> 1; } } @@ -104,6 +105,11 @@ unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecL unsigned char *masked; int width; + if(mask < 0 || mask >= maskNum) { + errno = EINVAL; + return NULL; + } + width = MQRspec_getWidth(version); masked = (unsigned char *)malloc(width * width); if(masked == NULL) return NULL; -- cgit 0.0.5-2-1-g0f52 From 6557a49362e065efe919aa78fd7550b0cdf225b9 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 3 Jun 2009 20:43:42 +0000 Subject: MQRspec_getDataLength() now returns in byte, and MQRspec_getDataLengthBit() returns in bit instead. --- mqrspec.c | 8 ++++++-- mqrspec.h | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mqrspec.c b/mqrspec.c index e62880109a..f904e98eb8 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -58,7 +58,7 @@ static const MQRspec_Capacity mqrspecCapacity[MQRSPEC_VERSION_MAX + 1] = { { 17, {8, 10, 14, 0}} }; -int MQRspec_getDataLength(int version, QRecLevel level) +int MQRspec_getDataLengthBit(int version, QRecLevel level) { int w; int ecc; @@ -66,10 +66,14 @@ int MQRspec_getDataLength(int version, QRecLevel level) w = mqrspecCapacity[version].width - 1; ecc = mqrspecCapacity[version].ec[level]; if(ecc == 0) return 0; -/* Warning again: unlike in QRSpec_getDataLength, return in BITS! */ return w * w - 64 - ecc * 8; } +int MQRspec_getDataLength(int version, QRecLevel level) +{ + return (MQRspec_getDataLengthBit(version, level) + 4) / 8; +} + int MQRspec_getECCLength(int version, QRecLevel level) { return mqrspecCapacity[version].ec[level]; diff --git a/mqrspec.h b/mqrspec.h index 56ac139239..3772bdf45c 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -40,11 +40,18 @@ /** * Return maximum data code length (bits) for the version. - * Warning: unlike in QRSpec_getDataLength, return in BITS! * @param version * @param level * @return maximum size (bits) */ +extern int MQRspec_getDataLengthBit(int version, QRecLevel level); + +/** + * Return maximum data code length (bytes) for the version. + * @param version + * @param level + * @return maximum size (bytes) + */ extern int MQRspec_getDataLength(int version, QRecLevel level); /** -- cgit 0.0.5-2-1-g0f52 From db35a2ee23e9b6c89b72d854099ae6f2daccc47e Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 3 Jun 2009 20:44:42 +0000 Subject: Follows changes of mqrspec.c. --- qrinput.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/qrinput.c b/qrinput.c index ef1ded4177..4c2b512bc8 100644 --- a/qrinput.c +++ b/qrinput.c @@ -997,7 +997,7 @@ static int QRinput_convertData(QRinput *input) if(input->mqr) { bits = QRinput_createBitStream(input); if(bits < 0) return -1; - if(bits > MQRspec_getDataLength(input->version, input->level)) { + if(bits > MQRspec_getDataLengthBit(input->version, input->level)) { errno = EINVAL; return -1; } @@ -1094,7 +1094,6 @@ DONE: * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. - * FIXME: Finished? Unit tests are needed. */ static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) { @@ -1104,7 +1103,7 @@ static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) int padlen; bits = BitStream_size(bstream); - maxbits = MQRspec_getDataLength(input->version, input->level); + maxbits = MQRspec_getDataLengthBit(input->version, input->level); maxwords = maxbits / 8; if(maxbits == bits) { -- cgit 0.0.5-2-1-g0f52 From f832f4446e3f8c75c46aebc48241e45c17e3070d Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 3 Jun 2009 20:47:07 +0000 Subject: QRencode_encodeStringMQR() and its 8bit version are added. QRcode_encodeMaskMQR() has been added. --- qrencode.c | 171 +++++++++++++++++++++++++++++++++++++++++++------------ qrencode.h | 12 ++++ qrencode_inner.h | 1 + 3 files changed, 148 insertions(+), 36 deletions(-) diff --git a/qrencode.c b/qrencode.c index 092cc80d59..6878f9f153 100644 --- a/qrencode.c +++ b/qrencode.c @@ -32,6 +32,7 @@ #include "rscode.h" #include "split.h" #include "mask.h" +#include "mmask.h" /****************************************************************************** * Raw code @@ -200,6 +201,7 @@ typedef struct { unsigned char *datacode; unsigned char *ecccode; RSblock *rsblock; + int oddbits; int count; } MQRRawCode; @@ -208,7 +210,6 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) { MQRRawCode *raw; RS *rs; - int dl; raw = (MQRRawCode *)malloc(sizeof(MQRRawCode)); if(raw == NULL) return NULL; @@ -216,6 +217,7 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) raw->version = input->version; raw->dataLength = MQRspec_getDataLength(input->version, input->level); raw->eccLength = MQRspec_getECCLength(input->version, input->level); + raw->oddbits = raw->dataLength * 8 - MQRspec_getDataLengthBit(input->version, input->level); raw->datacode = QRinput_getByteStream(input); if(raw->datacode == NULL) { free(raw); @@ -228,14 +230,19 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) return NULL; } - dl = (raw->dataLength + 4)/ 8; // M1 and M3 has 4 bit length data code. - rs = init_rs(8, 0x11d, 0, 1, raw->eccLength, 255 - dl - raw->eccLength); + raw->rsblock = (RSblock *)calloc(sizeof(RSblock), 1); + if(raw->rsblock == NULL) { + MQRraw_free(raw); + return NULL; + } + + rs = init_rs(8, 0x11d, 0, 1, raw->eccLength, 255 - raw->dataLength - raw->eccLength); if(rs == NULL) { MQRraw_free(raw); return NULL; } - RSblock_initBlock(raw->rsblock, dl, raw->datacode, raw->eccLength, raw->ecccode, rs); + RSblock_initBlock(raw->rsblock, raw->dataLength, raw->datacode, raw->eccLength, raw->ecccode, rs); raw->count = 0; @@ -247,7 +254,6 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) * This function can be called iteratively. * @param raw raw code. * @return code - * FIXME: M1 and M3 has 4bit-length data code! */ __STATIC unsigned char MQRraw_getCode(MQRRawCode *raw) { @@ -332,20 +338,21 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) y = 0; x -= 2; filler->dir = 1; - if(x == 6) { - x--; - y = 9; - } +// FIXME: _nextMQR is needed? +// if(x == 6) { +// x--; +// y = 9; +// } } } else { if(y == w) { y = w - 1; x -= 2; filler->dir = -1; - if(x == 6) { - x--; - y -= 8; - } +// if(x == 6) { +// x--; +// y -= 8; +// } } } if(x < 0 || y < 0) return NULL; @@ -357,6 +364,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) // This tail recursion could be optimized. return FrameFiller_next(filler); } + printf("%d,%d\n", x, y); return &p[y * w + x]; } @@ -438,6 +446,10 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) int i, j; QRcode *qrcode; + if(input->mqr) { + errno = EINVAL; + return NULL; + } if(input->version < 0 || input->version > QRSPEC_VERSION_MAX) { errno = EINVAL; return NULL; @@ -499,62 +511,149 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) return qrcode; } -QRcode *QRcode_encodeInput(QRinput *input) -{ - return QRcode_encodeMask(input, -1); -} - -QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level) +__STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) { - QRinput *input; - QRcode *code; - int ret; + int width, version; + MQRRawCode *raw; + unsigned char *frame, *masked, *p, code, bit; + FrameFiller *filler; + int i, j; + QRcode *qrcode; - if(string == NULL) { + if(!input->mqr) { + errno = EINVAL; + return NULL; + } + if(input->version < 0 || input->version > MQRSPEC_VERSION_MAX) { + errno = EINVAL; + return NULL; + } + if(input->level > QR_ECLEVEL_Q) { errno = EINVAL; return NULL; } - input = QRinput_new2(version, level); - if(input == NULL) return NULL; + raw = MQRraw_new(input); + if(raw == NULL) return NULL; - ret = QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string); - if(ret < 0) { - QRinput_free(input); + version = raw->version; + width = MQRspec_getWidth(version); + frame = MQRspec_newFrame(version); + if(frame == NULL) { + MQRraw_free(raw); + return NULL; + } + filler = FrameFiller_new(width, frame); + if(filler == NULL) { + MQRraw_free(raw); + free(frame); return NULL; } - code = QRcode_encodeInput(input); - QRinput_free(input); - return code; + /* inteleaved data and ecc codes */ + for(i=0; idataLength + raw->eccLength; i++) { + code = MQRraw_getCode(raw); + if(raw->oddbits && i == raw->dataLength - 1) { + bit = 1 << raw->oddbits; + for(j=0; joddbits; j++) { + p = FrameFiller_next(filler); + *p = 0x02 | ((bit & code) != 0); + bit = bit >> 1; + } + } else { + bit = 0x80; + for(j=0; j<8; j++) { + p = FrameFiller_next(filler); + *p = 0x02 | ((bit & code) != 0); + bit = bit >> 1; + } + } + } + MQRraw_free(raw); + free(filler); + /* masking */ + if(mask < 0) { + masked = MMask_mask(version, frame, input->level); + } else { + masked = MMask_makeMask(version, frame, mask, input->level); + } + if(masked == NULL) { + free(frame); + return NULL; + } + qrcode = QRcode_new(version, width, masked); + + free(frame); + + return qrcode; } -QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) +QRcode *QRcode_encodeInput(QRinput *input) +{ + if(input->mqr) { + return QRcode_encodeMaskMQR(input, -1); + } else { + return QRcode_encodeMask(input, -1); + } +} + +static QRcode *QRcode_encodeStringReal(const char *string, int version, QRecLevel level, int eightbit, int mqr, QRencodeMode hint, int casesensitive) { QRinput *input; QRcode *code; int ret; - if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) { + if(string == NULL) { + errno = EINVAL; + return NULL; + } + if(!eightbit && (hint != QR_MODE_8 && hint != QR_MODE_KANJI)) { errno = EINVAL; return NULL; } - input = QRinput_new2(version, level); + if(mqr) { + input = QRinput_newMQR(version, level); + } else { + input = QRinput_new2(version, level); + } if(input == NULL) return NULL; - ret = Split_splitStringToQRinput(string, input, hint, casesensitive); + if(eightbit) { + ret = QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string); + } else { + ret = Split_splitStringToQRinput(string, input, hint, casesensitive); + } if(ret < 0) { QRinput_free(input); return NULL; } - code = QRcode_encodeInput(input); QRinput_free(input); return code; } +QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level) +{ + return QRcode_encodeStringReal(string, version, level, 1, 0, QR_MODE_NUL, 0); +} + +QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) +{ + return QRcode_encodeStringReal(string, version, level, 0, 0, hint, casesensitive); +} + +QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level) +{ + return QRcode_encodeStringReal(string, version, level, 1, 1, QR_MODE_NUL, 0); +} + +QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) +{ + return QRcode_encodeStringReal(string, version, level, 0, 1, hint, casesensitive); +} + /****************************************************************************** * Structured QR-code encoding *****************************************************************************/ diff --git a/qrencode.h b/qrencode.h index dc697def59..cfdc2a6c68 100644 --- a/qrencode.h +++ b/qrencode.h @@ -383,6 +383,18 @@ extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel le */ extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level); +/** + * Micro QR Code version of QRcode_encodeString(). + * @warning This function is THREAD UNSAFE. + */ +extern QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); + +/** + * Micro QR Code version of QRcode_encodeString8bit(). + * @warning This function is THREAD UNSAFE. + */ +extern QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level); + /** * Free the instance of QRcode class. * @param qrcode an instance of QRcode class. diff --git a/qrencode_inner.h b/qrencode_inner.h index 8010f25acc..0217876270 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -87,6 +87,7 @@ extern unsigned char *FrameFiller_fillerTest(int version); * QR-code encoding *****************************************************************************/ extern QRcode *QRcode_encodeMask(QRinput *input, int mask); +extern QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask); /****************************************************************************** * Mask -- cgit 0.0.5-2-1-g0f52 From 0ac44406994c15fbef818548540cd5d84592ca71 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 3 Jun 2009 20:48:24 +0000 Subject: Bug fix. --- tests/test_mqrspec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index 87acefdef3..22657f93a4 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -95,7 +95,7 @@ void test_format(void) int err = 0; testStart("Format info test"); - for(version=1; version<4; version++) { + for(version=1; version<=4; version++) { for(l=0; l<3; l++) { for(mask=0; mask<4; mask++) { format = MQRspec_getFormatInfo(mask, version, (QRecLevel)l); @@ -152,7 +152,7 @@ void test_dataLength(void) testStart("Test dataLength"); for(v=0; v<4; v++) { for(l=0; l<3; l++) { - bits = MQRspec_getDataLength(v+1, (QRecLevel)l); + bits = MQRspec_getDataLengthBit(v+1, (QRecLevel)l); if(bits != datalen[v][l]) { printf("Error in version %d, level %d.\n", v, l); err++; -- cgit 0.0.5-2-1-g0f52 From 88a9c6a8bc44286310d6f7f9c115d10bc8a80480 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 4 Jun 2009 10:51:06 +0000 Subject: FrameFiller_nextFrameMQR() has been added. --- qrencode.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/qrencode.c b/qrencode.c index 6878f9f153..ed9cc41bd8 100644 --- a/qrencode.c +++ b/qrencode.c @@ -338,21 +338,20 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) y = 0; x -= 2; filler->dir = 1; -// FIXME: _nextMQR is needed? -// if(x == 6) { -// x--; -// y = 9; -// } + if(x == 6) { + x--; + y = 9; + } } } else { if(y == w) { y = w - 1; x -= 2; filler->dir = -1; -// if(x == 6) { -// x--; -// y -= 8; -// } + if(x == 6) { + x--; + y -= 8; + } } } if(x < 0 || y < 0) return NULL; @@ -364,6 +363,63 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) // This tail recursion could be optimized. return FrameFiller_next(filler); } + return &p[y * w + x]; +} + +static unsigned char *FrameFiller_nextMQR(FrameFiller *filler) +{ + unsigned char *p; + int x, y, w; + + if(filler->bit == -1) { + filler->bit = 0; + return filler->frame + filler->y * filler->width + filler->x; + } + + x = filler->x; + y = filler->y; + p = filler->frame; + w = filler->width; + + if(filler->bit == 0) { + x--; + filler->bit++; + } else { + x++; + y += filler->dir; + filler->bit--; + } + + if(filler->dir < 0) { + if(y < 0) { + y = 0; + x -= 2; + filler->dir = 1; + if(x == 6) { + x--; + y = 9; + } + } + } else { + if(y == w) { + y = w - 1; + x -= 2; + filler->dir = -1; + if(x == 6) { + x--; + y -= 8; + } + } + } + if(x < 0 || y < 0) return NULL; + + filler->x = x; + filler->y = y; + + if(p[y * w + x] & 0x80) { + // This tail recursion could be optimized. + return FrameFiller_nextMQR(filler); + } printf("%d,%d\n", x, y); return &p[y * w + x]; } @@ -556,14 +612,14 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) if(raw->oddbits && i == raw->dataLength - 1) { bit = 1 << raw->oddbits; for(j=0; joddbits; j++) { - p = FrameFiller_next(filler); + p = FrameFiller_nextMQR(filler); *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; } } else { bit = 0x80; for(j=0; j<8; j++) { - p = FrameFiller_next(filler); + p = FrameFiller_nextMQR(filler); *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; } -- cgit 0.0.5-2-1-g0f52 From fae2388abd09f1710a95c755398a6f8c620e5c77 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 01:34:54 +0000 Subject: FrameFiller improvements. --- ChangeLog | 7 +++ qrencode.c | 121 ++++++++++++++++++++++++++++++-------------------- qrencode_inner.h | 3 +- tests/test_qrencode.c | 89 ++++++++++++++++++++++++++++++------- 4 files changed, 153 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63313d6320..52a09d42cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009.06.05 Kentaro FUKUCHI + * qrencode.h, qrencode_inner.h, tests/test_qrencode.c: + - FrameFiller_next() has improved. + - FrameFiller_nextMQR() has been added. + - FrameFiller_test() FrameFiller_testMQR() have been added. + - Tests of FrameFiller added and improved. + 2009.06.01 Kentaro FUKUCHI * tests/prof_qrencode.c: - Error check has been added. diff --git a/qrencode.c b/qrencode.c index ed9cc41bd8..0d4e00987a 100644 --- a/qrencode.c +++ b/qrencode.c @@ -366,6 +366,39 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) return &p[y * w + x]; } +#ifdef __STATIC +extern unsigned char *FrameFiller_test(int version) +{ + int width; + unsigned char *frame, *p; + FrameFiller *filler; + int i, length; + + width = QRspec_getWidth(version); + frame = QRspec_newFrame(version); + if(frame == NULL) return NULL; + filler = FrameFiller_new(width, frame); + if(filler == NULL) { + free(frame); + return NULL; + } + length = QRspec_getDataLength(version, QR_ECLEVEL_L) * 8 + + QRspec_getECCLength(version, QR_ECLEVEL_L) * 8 + + QRspec_getRemainder(version); + for(i=0; idir = 1; - if(x == 6) { - x--; - y = 9; - } } } else { if(y == w) { y = w - 1; x -= 2; filler->dir = -1; - if(x == 6) { - x--; - y -= 8; - } } } if(x < 0 || y < 0) return NULL; @@ -420,48 +445,37 @@ static unsigned char *FrameFiller_nextMQR(FrameFiller *filler) // This tail recursion could be optimized. return FrameFiller_nextMQR(filler); } - printf("%d,%d\n", x, y); return &p[y * w + x]; } -#if 0 -unsigned char *FrameFiller_fillerTest(int version) +#ifdef __STATIC +extern unsigned char *FrameFiller_testMQR(int version) { - int width, length; + int width; unsigned char *frame, *p; FrameFiller *filler; - int i, j; - unsigned char cl = 1; - unsigned char ch = 0; + int i, length; - width = QRspec_getWidth(version); - frame = QRspec_newFrame(version); + width = MQRspec_getWidth(version); + frame = MQRspec_newFrame(version); + if(frame == NULL) return NULL; filler = FrameFiller_new(width, frame); - length = QRspec_getDataLength(version, QR_ECLEVEL_L) - + QRspec_getECCLength(version, QR_ECLEVEL_L); - - for(i=0; imqr) { errno = EINVAL; @@ -538,18 +552,21 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) bit = 0x80; for(j=0; j<8; j++) { p = FrameFiller_next(filler); + if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; } } QRraw_free(raw); + raw = NULL; /* remainder bits */ j = QRspec_getRemainder(version); for(i=0; ilevel); @@ -557,13 +574,14 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) masked = Mask_makeMask(width, frame, mask, input->level); } if(masked == NULL) { - free(frame); - return NULL; + goto EXIT; } qrcode = QRcode_new(version, width, masked); +EXIT: + QRraw_free(raw); + free(filler); free(frame); - return qrcode; } @@ -574,13 +592,13 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) unsigned char *frame, *masked, *p, code, bit; FrameFiller *filler; int i, j; - QRcode *qrcode; + QRcode *qrcode = NULL; if(!input->mqr) { errno = EINVAL; return NULL; } - if(input->version < 0 || input->version > MQRSPEC_VERSION_MAX) { + if(input->version <= 0 || input->version > MQRSPEC_VERSION_MAX) { errno = EINVAL; return NULL; } @@ -613,6 +631,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) bit = 1 << raw->oddbits; for(j=0; joddbits; j++) { p = FrameFiller_nextMQR(filler); + if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; } @@ -620,13 +639,15 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) bit = 0x80; for(j=0; j<8; j++) { p = FrameFiller_nextMQR(filler); + if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; } } } MQRraw_free(raw); - free(filler); + raw = NULL; + /* masking */ if(mask < 0) { masked = MMask_mask(version, frame, input->level); @@ -634,13 +655,15 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) masked = MMask_makeMask(version, frame, mask, input->level); } if(masked == NULL) { - free(frame); - return NULL; + goto EXIT; } + qrcode = QRcode_new(version, width, masked); +EXIT: + MQRraw_free(raw); + free(filler); free(frame); - return qrcode; } diff --git a/qrencode_inner.h b/qrencode_inner.h index 0217876270..d18882def5 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -81,7 +81,8 @@ extern void MQRraw_free(MQRRawCode *raw); /****************************************************************************** * Frame filling *****************************************************************************/ -extern unsigned char *FrameFiller_fillerTest(int version); +extern unsigned char *FrameFiller_test(int version); +extern unsigned char *FrameFiller_testMQR(int version); /****************************************************************************** * QR-code encoding diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 86f63b4da8..d77bfec557 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -3,6 +3,7 @@ #include "common.h" #include "../qrencode_inner.h" #include "../qrspec.h" +#include "../mqrspec.h" #include "../qrinput.h" #include "../mask.h" #include "../rscode.h" @@ -129,16 +130,16 @@ void test_iterate2() testEnd(err); } -#if 0 void print_filler(void) { int width; int x, y; - int version = 5; + int version = 7; unsigned char *frame; width = QRspec_getWidth(version); - frame = FrameFiller_fillerTest(version); + frame = FrameFiller_test(version); + if(frame == NULL) abort(); for(y=0; y 6)?3:0)); + assert_equal(frame[e], (unsigned char)((length - 1) & 127) | 0x80, + "Number of cell does not match.\n"); free(frame); - if(e) { - printf("Non-filled bit was found in version %d\n", i); - err++; + } + } + testFinish(); +} + +void print_fillerMQR(void) +{ + int width; + int x, y; + int version = 3; + unsigned char *frame; + + for(version = 1; version <= MQRSPEC_VERSION_MAX; version++) { + width = MQRspec_getWidth(version); + frame = FrameFiller_testMQR(version); + if(frame == NULL) abort(); + + for(y=0; y Date: Fri, 5 Jun 2009 15:38:06 +0000 Subject: --- ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 52a09d42cd..9ffb1d6f3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,18 @@ - FrameFiller_test() FrameFiller_testMQR() have been added. - Tests of FrameFiller added and improved. +2009.06.04 Kentaro FUKUCHI + * Makefile.am: + - Dependency check was incorrect because of misconfiguration. + * mask.c, mmask.c: + - Error check has been added to {Mask,MMask}_makeMask(). + * mqrspec.[ch], qrinput.c: + - MQRspec_getDataLength() now returns in byte. + - MQRspec_getDataLengthBit() returns in bit instead. + * qrencode.[ch], qrencode_inner.h: + - QRencode_encodeStringMQR() and its 8bit version are added. + - QRcode_encodeMaskMQR() has been added. + 2009.06.01 Kentaro FUKUCHI * tests/prof_qrencode.c: - Error check has been added. -- cgit 0.0.5-2-1-g0f52 From 4006013aac9267f274540037a24da5d9867f9476 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 16:17:59 +0000 Subject: QRinput_setVersionAndErrorCorrectionLevel() has been added. --- qrencode.h | 15 +++++++++++++-- qrinput.c | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/qrencode.h b/qrencode.h index cfdc2a6c68..0a00cb3fa4 100644 --- a/qrencode.h +++ b/qrencode.h @@ -193,7 +193,7 @@ extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const uns extern int QRinput_getVersion(QRinput *input); /** - * Set version of the QR-code that is to be encoded. + * Set version of the QR code that is to be encoded. * This function cannot be applied to Micro QR Code. * @param input input object. * @param version version number (0 = auto) @@ -210,7 +210,7 @@ extern int QRinput_setVersion(QRinput *input, int version); extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input); /** - * Set error correction level of the QR-code that is to be encoded. + * Set error correction level of the QR code that is to be encoded. * This function cannot be applied to Micro QR Code. * @param input input object. * @param level Error correction level. @@ -219,6 +219,17 @@ extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input); */ extern int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level); +/** + * Set version and error correction level of the QR code at once. + * This function is recommened for Micro QR Code. + * @param input input object. + * @param version version number (0 = auto) + * @param level Error correction level. + * @retval 0 success. + * @retval -1 invalid argument. + */ +extern int QRinput_setVersionAndErrorCorrectionLevel(QRinput *input, int version, QRecLevel level); + /** * Free the input object. * All of data chunks in the input object are freed too. diff --git a/qrinput.c b/qrinput.c index 4c2b512bc8..f44f0fcfe5 100644 --- a/qrinput.c +++ b/qrinput.c @@ -174,6 +174,26 @@ int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level) return 0; } +int QRinput_setVersionAndErrorCorrectionLevel(QRinput *input, int version, QRecLevel level) +{ + if(input->mqr) { + if(version <= 0 || version > MQRSPEC_VERSION_MAX) goto INVALID; + if((MQRspec_getECCLength(version, level) == 0)) goto INVALID; + } else { + if(version < 0 || version > QRSPEC_VERSION_MAX) goto INVALID; + if(level > QR_ECLEVEL_H) goto INVALID; + } + + input->version = version; + input->level = level; + + return 0; + +INVALID: + errno = EINVAL; + return -1; +} + static void QRinput_appendEntry(QRinput *input, QRinput_List *entry) { if(input->tail == NULL) { -- cgit 0.0.5-2-1-g0f52 From 74733af52e075af247ca3a489f62aa85d21e7110 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 16:43:44 +0000 Subject: Experimental support of Micro QR Code has been implemented. --- ChangeLog | 6 ++++++ qrenc.c | 44 +++++++++++++++++++++++++++++++++++++++----- tests/view_qrcode.c | 38 ++++++++++++++++++++++++++++---------- 3 files changed, 73 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ffb1d6f3f..e3ac282f90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009.06.06 Kentaro FUKUCHI + * qrenc.c, tests/view_qrcode.c: + - Experimental support of Micro QR Code has been implemented. + * qrencode.[ch]: + - QRinput_setVersionAndErrorCorrectionLevel() has been added. + 2009.06.05 Kentaro FUKUCHI * qrencode.h, qrencode_inner.h, tests/test_qrencode.c: - FrameFiller_next() has improved. diff --git a/qrenc.c b/qrenc.c index c68aec3178..05866d20a1 100644 --- a/qrenc.c +++ b/qrenc.c @@ -31,8 +31,9 @@ static int casesensitive = 1; static int eightbit = 0; static int version = 0; static int size = 3; -static int margin = 4; +static int margin = -1; static int structured = 0; +static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; @@ -48,11 +49,12 @@ static const struct option options[] = { {"casesensitive", no_argument , NULL, 'c'}, {"ignorecase" , no_argument , NULL, 'i'}, {"8bit" , no_argument , NULL, '8'}, + {"micro" , no_argument , NULL, 'M'}, {"version" , no_argument , NULL, 'V'}, {NULL, 0, NULL, 0} }; -static char *optstring = "ho:l:s:v:m:Skci8V"; +static char *optstring = "ho:l:s:v:m:Skci8MV"; static void usage(int help, int longopt) { @@ -88,6 +90,7 @@ static void usage(int help, int longopt) " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" " -8, -8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" +" -M, --micro encode in a Micro QR Code.\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" @@ -113,6 +116,7 @@ static void usage(int help, int longopt) " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" " -i ignore case distinctions and use only upper-case characters.\n" " -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n" +" -M encode in a Micro QR Code.\n" " -V display the version number and copyrights of the qrencode.\n" " [STRING] input data. If it is not specified, data will be taken from\n" " standard input.\n" @@ -250,10 +254,18 @@ static QRcode *encode(const char *intext) { QRcode *code; - if(eightbit) { - code = QRcode_encodeString8bit(intext, version, level); + if(micro) { + if(eightbit) { + code = QRcode_encodeString8bitMQR(intext, version, level); + } else { + code = QRcode_encodeStringMQR(intext, version, level, hint, casesensitive); + } } else { - code = QRcode_encodeString(intext, version, level, hint, casesensitive); + if(eightbit) { + code = QRcode_encodeString8bit(intext, version, level); + } else { + code = QRcode_encodeString(intext, version, level, hint, casesensitive); + } } return code; @@ -411,6 +423,9 @@ int main(int argc, char **argv) case '8': eightbit = 1; break; + case 'M': + micro = 1; + break; case 'V': usage(0, 0); exit(0); @@ -439,6 +454,25 @@ int main(int argc, char **argv) intext = readStdin(); } + if(margin < 0) { + if(micro) { + margin = 2; + } else { + margin = 4; + } + } + + if(micro) { + if(version == 0) { + fprintf(stderr, "Version must be specified to encode a Micro QR Code symbol.\n"); + exit(EXIT_FAILURE); + } + if(structured) { + fprintf(stderr, "Micro QR Code does not support structured symbols.\n"); + exit(EXIT_FAILURE); + } + } + if(structured) { if(version == 0) { fprintf(stderr, "Version must be specified to encode structured symbols.\n"); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index ed86183c68..0998269810 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -17,6 +17,7 @@ static int version = 1; static int size = 4; static int margin = 4; static int structured = 0; +static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; @@ -34,11 +35,12 @@ static const struct option options[] = { {"casesensitive", no_argument , NULL, 'c'}, {"ignorecase" , no_argument , NULL, 'i'}, {"8bit" , no_argument , NULL, '8'}, + {"micro" , no_argument , NULL, 'M'}, {"version" , no_argument , NULL, 'V'}, {NULL, 0, NULL, 0} }; -static char *optstring = "ho:l:s:v:m:Skci8V"; +static char *optstring = "h:l:s:v:m:Skci8MV"; static char levelChar[4] = {'L', 'M', 'Q', 'H'}; static void usage(int help, int longopt) @@ -70,6 +72,7 @@ static void usage(int help, int longopt) " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" " -8, -8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" +" -M, --micro encode in a Micro QR Code.\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" @@ -91,6 +94,7 @@ static void usage(int help, int longopt) " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" " -i ignore case distinctions and use only upper-case characters.\n" " -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n" +" -M encode in a Micro QR Code.\n" " -V display the version number and copyrights of the qrencode.\n" " [STRING] input data. If it is not specified, data will be taken from\n" " standard input.\n" @@ -148,17 +152,24 @@ void draw_singleQRcode(QRinput *stream, int mask) QRcode *qrcode; int width; - QRinput_setVersion(stream, version); - QRinput_setErrorCorrectionLevel(stream, level); - qrcode = QRcode_encodeMask(stream, mask); - if(qrcode == NULL) return; - - version = qrcode->version; - width = (qrcode->width + margin * 2) * size; + QRinput_setVersionAndErrorCorrectionLevel(stream, version, level); + if(micro) { + qrcode = QRcode_encodeMaskMQR(stream, mask); + } else { + qrcode = QRcode_encodeMask(stream, mask); + } + if(qrcode == NULL) { + width = (11 + margin * 2) * size; + } else { + version = qrcode->version; + width = (qrcode->width + margin * 2) * size; + } screen = SDL_SetVideoMode(width, width, 32, 0); SDL_FillRect(screen, NULL, 0xffffff); - draw_QRcode(qrcode, 0, 0); + if(qrcode) { + draw_QRcode(qrcode, 0, 0); + } SDL_Flip(screen); QRcode_free(qrcode); } @@ -353,7 +364,11 @@ void view_simple(const char *str) QRinput *input; int ret; - input = QRinput_new2(version, level); + if(micro) { + input = QRinput_newMQR(version, level); + } else { + input = QRinput_new2(version, level); + } if(input == NULL) { fprintf(stderr, "Memory allocation error.\n"); exit(1); @@ -455,6 +470,9 @@ int main(int argc, char **argv) case '8': eightbit = 1; break; + case 'M': + micro = 1; + break; case 'V': usage(0, 0); exit(0); -- cgit 0.0.5-2-1-g0f52 From 928d5fdf8c88bfd147bae1a833b368ca26471485 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 18:07:38 +0000 Subject: Synchronized to qrencode.c. --- qrencode_inner.h | 1 + 1 file changed, 1 insertion(+) diff --git a/qrencode_inner.h b/qrencode_inner.h index d18882def5..e36710eed4 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -71,6 +71,7 @@ typedef struct { unsigned char *datacode; unsigned char *ecccode; RSblock *rsblock; + int oddbits; int count; } MQRRawCode; -- cgit 0.0.5-2-1-g0f52 From e55a57bdb2c67fe9fba63c7a73e4e15ba57dda12 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 18:08:13 +0000 Subject: New frame printing function added. --- tests/common.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/common.h b/tests/common.h index 1b72a8b1a7..00d3baa7c2 100644 --- a/tests/common.h +++ b/tests/common.h @@ -71,6 +71,23 @@ void printQRinputInfo(QRinput *input) } } +void printFrame(int width, unsigned char *frame) +{ + int x, y; + + for(y=0; ywidth, code->data); +} + void testStartReal(const char *func, const char *name) { tests++; @@ -168,16 +185,4 @@ void printBstream(BitStream *bstream) } printf("\n"); } - -static char qrModeChar[4] = {'n', 'a', '8', 'k'}; -void printQrinput(QRinput *input) -{ - QRinput_List *list; - - list = input->head; - while(list != NULL) { - printf("%c(%d)\n", qrModeChar[list->mode], list->size); - list = list->next; - } -} #endif /* __COMMON_H__ */ -- cgit 0.0.5-2-1-g0f52 From 2c260346201bddcdcff0318fc67103e9386e9fc5 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 18:08:35 +0000 Subject: Code cleanups. --- tests/test_split.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_split.c b/tests/test_split.c index 8c9a5254af..10c9e3cd69 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -127,7 +127,7 @@ void test_split3(void) Split_splitStringToQRinput("ab:-E", input, QR_MODE_8, 0); list = input->head; if(inputTest(list, "a", 5)) { - printQrinput(input); + printQRinputInfo(input); err++; } testEnd(err); @@ -245,7 +245,7 @@ void test_split6(void) Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, QR_MODE_KANJI, 0); list = input->head; if(inputTest(list, "kakn", 2, 11, 2, 6)) { - printQrinput(input); + printQRinputInfo(input); err++; } testEnd(err); @@ -319,7 +319,7 @@ void test_split3c(void) Split_splitStringToQRinput("Ab345fg", input, QR_MODE_KANJI, 1); list = input->head; if(inputTest(list, "8", 7)) { - printQrinput(input); + printQRinputInfo(input); err++; } testEnd(err); @@ -351,7 +351,7 @@ void test_toupper(void) Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, QR_MODE_KANJI, 0); list = input->head; if(inputTest(list, "k", 10)) { - printQrinput(input); + printQRinputInfo(input); err++; } if(strncmp((char *)list->data, "\x83n\x83q\x83t\x83w\x83z", list->size)) { @@ -366,7 +366,7 @@ void test_toupper(void) Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, QR_MODE_8, 0); list = input->head; if(inputTest(list, "8", 10)) { - printQrinput(input); + printQRinputInfo(input); err++; } if(strncmp((char *)list->data, "\x83N\x83Q\x83T\x83W\x83Z", list->size)) { -- cgit 0.0.5-2-1-g0f52 From 9ee9e31cfd4837911e07dec02eef456d135bfc18 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 18:09:01 +0000 Subject: New tests have been added. --- tests/test_qrencode.c | 80 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index d77bfec557..b44f132316 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -38,7 +38,7 @@ void test_qrraw_new(void) assert_zero(raw->count, "QRraw.count = %d != 0\n", raw->count); assert_equal(raw->version, 10, "QRraw.version was not as expected. (%d)\n", raw->version); assert_equal(raw->dataLength, 19 * 6 + 20 * 2, "QRraw.dataLength was not as expected.\n"); - assert_equal(raw->eccLength, 24 * 8, "QRraw.dataLength was not as expected.\n"); + assert_equal(raw->eccLength, 24 * 8, "QRraw.eccLength was not as expected.\n"); assert_equal(raw->b1, 6, "QRraw.b1 was not as expected.\n"); assert_equal(raw->blocks, 8, "QRraw.blocks was not as expected.\n"); @@ -133,7 +133,6 @@ void test_iterate2() void print_filler(void) { int width; - int x, y; int version = 7; unsigned char *frame; @@ -141,12 +140,7 @@ void print_filler(void) frame = FrameFiller_test(version); if(frame == NULL) abort(); - for(y=0; ywidth; - frame = qrcode->data; - for(y=0; ycount, "MQRraw.count = %d != 0\n", raw->count); + assert_equal(raw->version, 1, "MQRraw.version was not as expected. (%d)\n", raw->version); + assert_equal(raw->dataLength, 3, "MQRraw.dataLength was not as expected.\n"); + assert_equal(raw->eccLength, 2, "MQRraw.eccLength was not as expected.\n"); + assert_zero(memcmp(raw->datacode, datacode, 3), "Datacode doesn't match.\n"); + + + QRinput_free(stream); + MQRraw_free(raw); + testFinish(); +} + int main(void) { test_iterate(); @@ -640,8 +667,11 @@ int main(void) test_qrraw_new(); //print_fillerMQR(); test_fillerMQR(); + test_encodeTooLongMQR(); + test_mqrraw_new(); QRspec_clearCache(); + MQRspec_clearCache(); free_rs_cache(); report(); -- cgit 0.0.5-2-1-g0f52 From 823f6e65b6e26d15f72054216890ca53c8ac5b3b Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 18:10:35 +0000 Subject: --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index e3ac282f90..63f75b3290 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ - Experimental support of Micro QR Code has been implemented. * qrencode.[ch]: - QRinput_setVersionAndErrorCorrectionLevel() has been added. + * tests/common.h, tests/test_split.c: + - Code cleanups. + - printFrame() and printQRcode() have been added. + * tests/test_qrencode.c: + - Some tests have been added. 2009.06.05 Kentaro FUKUCHI * qrencode.h, qrencode_inner.h, tests/test_qrencode.c: -- cgit 0.0.5-2-1-g0f52 From 2bfbc7ff355bb1653d2e8a101f9376ec617e7aea Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 18:12:24 +0000 Subject: Bumped version to 3.9.0. --- ChangeLog | 6 ++++++ configure.ac | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63f75b3290..0df3669bef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,12 @@ - printFrame() and printQRcode() have been added. * tests/test_qrencode.c: - Some tests have been added. + * Bumped vertion to 3.9.0. + - Next public release will be 4.0.0. + +2009.06.06 Kentaro FUKUCHI + [3.1.0] + * Version 3.1.0 has been released. 2009.06.05 Kentaro FUKUCHI * qrencode.h, qrencode_inner.h, tests/test_qrencode.c: diff --git a/configure.ac b/configure.ac index 5eb1d890d4..b391e93c03 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,9 @@ AC_INIT(QRencode) MAJOR_VERSION=3 -MINOR_VERSION=1 +MINOR_VERSION=9 MICRO_VERSION=0 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.${MICRO_VERSION}rc1 +VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) AC_SUBST(MICRO_VERSION) -- cgit 0.0.5-2-1-g0f52 From 50ac849f332dced19785706723347f309a7d1f0d Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 19:23:48 +0000 Subject: VERSION_MAX moved to qrencode.h. --- mqrspec.h | 5 ----- qrspec.h | 5 ----- 2 files changed, 10 deletions(-) diff --git a/mqrspec.h b/mqrspec.h index 3772bdf45c..d5385c0b69 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -28,11 +28,6 @@ * Version and capacity *****************************************************************************/ -/** - * Maximum version (size) of QR-code symbol. - */ -#define MQRSPEC_VERSION_MAX 4 - /** * Maximum width of a symbol */ diff --git a/qrspec.h b/qrspec.h index a544e9b107..73e10e0e51 100644 --- a/qrspec.h +++ b/qrspec.h @@ -28,11 +28,6 @@ * Version and capacity *****************************************************************************/ -/** - * Maximum version (size) of QR-code symbol. - */ -#define QRSPEC_VERSION_MAX 40 - /** * Maximum width of a symbol */ -- cgit 0.0.5-2-1-g0f52 From fa3bb0633bf78472da896091e00017f68b48a173 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 19:24:24 +0000 Subject: VERSION_MAX moved to qrencode.h. Some functions now throws ERANGE. --- qrencode.h | 12 ++++++++++++ qrinput.c | 33 +++++++++++++++++++-------------- tests/test_qrencode.c | 10 ++++++++-- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/qrencode.h b/qrencode.h index 0a00cb3fa4..a76aa8de9b 100644 --- a/qrencode.h +++ b/qrencode.h @@ -125,6 +125,17 @@ typedef enum { QR_ECLEVEL_H ///< highest } QRecLevel; +/** + * Maximum version (size) of QR-code symbol. + */ +#define QRSPEC_VERSION_MAX 40 + +/** + * Maximum version (size) of QR-code symbol. + */ +#define MQRSPEC_VERSION_MAX 4 + + /****************************************************************************** * Input data (qrinput.c) *****************************************************************************/ @@ -385,6 +396,7 @@ extern QRcode *QRcode_encodeInput(QRinput *input); * details. * @throw EINVAL invalid input object. * @throw ENOMEM unable to allocate memory for input objects. + * @throw ERANGE input data is too large. */ extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); diff --git a/qrinput.c b/qrinput.c index f44f0fcfe5..6079aeafa8 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1007,23 +1007,13 @@ static int QRinput_createBitStream(QRinput *input) * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. - * @throw EINVAL input is too large. + * @throw ERANGE input is too large. */ static int QRinput_convertData(QRinput *input) { int bits; int ver; - if(input->mqr) { - bits = QRinput_createBitStream(input); - if(bits < 0) return -1; - if(bits > MQRspec_getDataLengthBit(input->version, input->level)) { - errno = EINVAL; - return -1; - } - return 0; - } - ver = QRinput_estimateVersion(input); if(ver > QRinput_getVersion(input)) { QRinput_setVersion(input, ver); @@ -1034,7 +1024,7 @@ static int QRinput_convertData(QRinput *input) if(bits < 0) return -1; ver = QRspec_getMinimumVersion((bits + 7) / 8, input->level); if(ver < 0) { - errno = EINVAL; + errno = ERANGE; return -1; } else if(ver > QRinput_getVersion(input)) { QRinput_setVersion(input, ver); @@ -1053,6 +1043,7 @@ static int QRinput_convertData(QRinput *input) * @retval 0 success * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. + * @throw ERANGE input data is too large. * @throw ENOMEM unable to allocate memory. */ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) @@ -1066,6 +1057,10 @@ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) maxwords = QRspec_getDataLength(input->version, input->level); maxbits = maxwords * 8; + if(maxbits < bits) { + errno = ERANGE; + return -1; + } if(maxbits == bits) { return 0; } @@ -1113,6 +1108,7 @@ DONE: * @retval 0 success * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. + * @throw ERANGE input data is too large. * @throw ENOMEM unable to allocate memory. */ static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) @@ -1126,6 +1122,10 @@ static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) maxbits = MQRspec_getDataLengthBit(input->version, input->level); maxwords = maxbits / 8; + if(maxbits < bits) { + errno = ERANGE; + return -1; + } if(maxbits == bits) { return 0; } @@ -1192,8 +1192,13 @@ __STATIC BitStream *QRinput_mergeBitStream(QRinput *input) QRinput_List *list; int ret; - if(QRinput_convertData(input) < 0) { - return NULL; + if(input->mqr) { + ret = QRinput_createBitStream(input); + if(ret < 0) return NULL; + } else { + if(QRinput_convertData(input) < 0) { + return NULL; + } } bstream = BitStream_new(); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index b44f132316..9f3e7c327b 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -1,5 +1,6 @@ #include #include +#include #include "common.h" #include "../qrencode_inner.h" #include "../qrspec.h" @@ -429,10 +430,11 @@ void test_encodeTooLong(void) data[4299] = '\0'; code = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 0); - testEndExp(code == NULL); + assert_null(code, "Too large data is incorrectly accepted.\n"); + assert_equal(errno, ERANGE, "errno != ERANGE\n"); + testFinish(); if(code != NULL) { - printf("%d, %d\n", code->version, code->width); QRcode_free(code); } free(data); @@ -604,12 +606,16 @@ void test_encodeTooLongMQR(void) code = QRcode_encodeStringMQR(data[0], 1, QR_ECLEVEL_L, QR_MODE_8, 0); assert_null(code, "6 byte length numeric string was accepted to version 1.\n"); + assert_equal(errno, ERANGE, "errno != ERANGE\n"); code = QRcode_encodeStringMQR(data[1], 2, QR_ECLEVEL_L, QR_MODE_8, 0); assert_null(code, "7 byte length alphanumeric string was accepted to version 2.\n"); + assert_equal(errno, ERANGE, "errno != ERANGE\n"); code = QRcode_encodeString8bitMQR(data[2], 3, QR_ECLEVEL_L); assert_null(code, "9 byte length 8bit string was accepted to version 3.\n"); + assert_equal(errno, ERANGE, "errno != ERANGE\n"); code = QRcode_encodeString8bitMQR(data[3], 4, QR_ECLEVEL_L); assert_null(code, "16 byte length 8bit string was accepted to version 4.\n"); + assert_equal(errno, ERANGE, "errno != ERANGE\n"); testFinish(); if(code != NULL) { -- cgit 0.0.5-2-1-g0f52 From b3852b589d28a9ac54f8e1817c6fbb1289becb31 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 19:24:30 +0000 Subject: --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0df3669bef..7dad1e1bef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,14 @@ - printFrame() and printQRcode() have been added. * tests/test_qrencode.c: - Some tests have been added. + * qrspec.h, mqrspec.h, qrencode.h: + - Definitions of {MQR,QR}SPEC_VERSION_MAX are moved to qrencode.h. + * qrinput.c, qrencode.h, tests/test_qrencode.c: + - Size check has been removed from QRinput_convertData() for MQR. + - QRinput_convertData() throws ERANGE when the input is too large. + - QRinput_appendPadding*() throws ERANGE when the input is too large. + - As a result, QRencode_encodeString*() throws ERANGE in that cases. + - Some assertion checks of errno added to test_qrencode. * Bumped vertion to 3.9.0. - Next public release will be 4.0.0. -- cgit 0.0.5-2-1-g0f52 From bb5a1d3a140ab6abb0dc16292f08e57c784e4d11 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 5 Jun 2009 19:24:53 +0000 Subject: Error messages improved. --- qrenc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 05866d20a1..a06099ec21 100644 --- a/qrenc.c +++ b/qrenc.c @@ -277,7 +277,7 @@ static void qrencode(const char *intext, const char *outfile) qrcode = encode(intext); if(qrcode == NULL) { - perror("Failed to encode the input data:"); + perror("Failed to encode the input data"); exit(EXIT_FAILURE); } writePNG(qrcode, outfile); @@ -319,7 +319,7 @@ static void qrencodeStructured(const char *intext, const char *outfile) qrlist = encodeStructured(intext); if(qrlist == NULL) { - perror("Failed to encode the input data:"); + perror("Failed to encode the input data"); exit(EXIT_FAILURE); } @@ -454,6 +454,14 @@ int main(int argc, char **argv) intext = readStdin(); } + if(micro && version > MQRSPEC_VERSION_MAX) { + fprintf(stderr, "Version should be less or equal to %d.\n", MQRSPEC_VERSION_MAX); + exit(EXIT_FAILURE); + } else if(!micro && version > QRSPEC_VERSION_MAX) { + fprintf(stderr, "Version should be less or equal to %d.\n", QRSPEC_VERSION_MAX); + exit(EXIT_FAILURE); + } + if(margin < 0) { if(micro) { margin = 2; -- cgit 0.0.5-2-1-g0f52 From 3e7a9b401537166a27c9d9db24fc1320fd4bbcab Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 8 Jun 2009 08:05:41 +0000 Subject: Refactoring of FrameFiller. --- ChangeLog | 5 +++++ qrencode.c | 71 +++++++++++--------------------------------------------------- 2 files changed, 17 insertions(+), 59 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7dad1e1bef..8bf7fbecf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009.06.08 Kentaro FUKUCHI + * qrencode.c: + - FrameFiller_nextMQR() has integrated to FrameFiller_next(). + - FrameFiller_new() now requires mqr flag. + 2009.06.06 Kentaro FUKUCHI * qrenc.c, tests/view_qrcode.c: - Experimental support of Micro QR Code has been implemented. diff --git a/qrencode.c b/qrencode.c index 0d4e00987a..90b034777b 100644 --- a/qrencode.c +++ b/qrencode.c @@ -291,9 +291,10 @@ typedef struct { int x, y; int dir; int bit; + int mqr; } FrameFiller; -static FrameFiller *FrameFiller_new(int width, unsigned char *frame) +static FrameFiller *FrameFiller_new(int width, unsigned char *frame, int mqr) { FrameFiller *filler; @@ -305,6 +306,7 @@ static FrameFiller *FrameFiller_new(int width, unsigned char *frame) filler->y = width - 1; filler->dir = -1; filler->bit = -1; + filler->mqr = mqr; return filler; } @@ -338,7 +340,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) y = 0; x -= 2; filler->dir = 1; - if(x == 6) { + if(!filler->mqr && x == 6) { x--; y = 9; } @@ -348,7 +350,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) y = w - 1; x -= 2; filler->dir = -1; - if(x == 6) { + if(!filler->mqr && x == 6) { x--; y -= 8; } @@ -377,7 +379,7 @@ extern unsigned char *FrameFiller_test(int version) width = QRspec_getWidth(version); frame = QRspec_newFrame(version); if(frame == NULL) return NULL; - filler = FrameFiller_new(width, frame); + filler = FrameFiller_new(width, frame, 0); if(filler == NULL) { free(frame); return NULL; @@ -399,55 +401,6 @@ extern unsigned char *FrameFiller_test(int version) } #endif -static unsigned char *FrameFiller_nextMQR(FrameFiller *filler) -{ - unsigned char *p; - int x, y, w; - - if(filler->bit == -1) { - filler->bit = 0; - return filler->frame + filler->y * filler->width + filler->x; - } - - x = filler->x; - y = filler->y; - p = filler->frame; - w = filler->width; - - if(filler->bit == 0) { - x--; - filler->bit++; - } else { - x++; - y += filler->dir; - filler->bit--; - } - - if(filler->dir < 0) { - if(y < 0) { - y = 0; - x -= 2; - filler->dir = 1; - } - } else { - if(y == w) { - y = w - 1; - x -= 2; - filler->dir = -1; - } - } - if(x < 0 || y < 0) return NULL; - - filler->x = x; - filler->y = y; - - if(p[y * w + x] & 0x80) { - // This tail recursion could be optimized. - return FrameFiller_nextMQR(filler); - } - return &p[y * w + x]; -} - #ifdef __STATIC extern unsigned char *FrameFiller_testMQR(int version) { @@ -459,7 +412,7 @@ extern unsigned char *FrameFiller_testMQR(int version) width = MQRspec_getWidth(version); frame = MQRspec_newFrame(version); if(frame == NULL) return NULL; - filler = FrameFiller_new(width, frame); + filler = FrameFiller_new(width, frame, 1); if(filler == NULL) { free(frame); return NULL; @@ -467,7 +420,7 @@ extern unsigned char *FrameFiller_testMQR(int version) length = MQRspec_getDataLengthBit(version, QR_ECLEVEL_L) + MQRspec_getECCLength(version, QR_ECLEVEL_L) * 8; for(i=0; ioddbits && i == raw->dataLength - 1) { bit = 1 << raw->oddbits; for(j=0; joddbits; j++) { - p = FrameFiller_nextMQR(filler); + p = FrameFiller_next(filler); if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; @@ -638,7 +591,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) } else { bit = 0x80; for(j=0; j<8; j++) { - p = FrameFiller_nextMQR(filler); + p = FrameFiller_next(filler); if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; -- cgit 0.0.5-2-1-g0f52 From 9b284987455d83aeb070a47313ca31d940dc204c Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 8 Jun 2009 08:25:00 +0000 Subject: QRcode_clearCache() has been added. --- ChangeLog | 2 ++ qrencode.c | 11 +++++++++++ qrencode.h | 11 +++++++++++ tests/prof_qrencode.c | 5 +---- tests/test_monkey.c | 4 +--- tests/test_qrencode.c | 4 +--- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bf7fbecf6..2bc97cb6b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * qrencode.c: - FrameFiller_nextMQR() has integrated to FrameFiller_next(). - FrameFiller_new() now requires mqr flag. + * qrencode.[ch], tests/prof_qrencode.c, tests/test_{qrencode,monkey}.c: + - QRcode_clearCache() has been added. 2009.06.06 Kentaro FUKUCHI * qrenc.c, tests/view_qrcode.c: diff --git a/qrencode.c b/qrencode.c index 90b034777b..376a70a6b9 100644 --- a/qrencode.c +++ b/qrencode.c @@ -848,3 +848,14 @@ QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRec return codes; } + +/****************************************************************************** + * System utilities + *****************************************************************************/ + +void QRcode_clearCache(void) +{ + QRspec_clearCache(); + MQRspec_clearCache(); + free_rs_cache(); +} diff --git a/qrencode.h b/qrencode.h index a76aa8de9b..407f6cbae6 100644 --- a/qrencode.h +++ b/qrencode.h @@ -471,6 +471,17 @@ extern int QRcode_List_size(QRcode_List *qrlist); */ extern void QRcode_List_free(QRcode_List *qrlist); + +/****************************************************************************** + * System utilities + *****************************************************************************/ + +/** + * Clear all caches. This is only for debug purpose. If you are attacking a + * complicated memory leak bug, try this to reduce the reachable blocks record. + */ +extern void QRcode_clearCache(void); + #if defined(__cplusplus) } #endif diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index c61b646dcc..a02d9a7a8e 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -4,8 +4,6 @@ #include #include #include "../qrencode.h" -#include "../qrspec.h" -#include "../rscode.h" struct timeval tv; void timerStart(const char *str) @@ -70,8 +68,7 @@ int main(void) prof_ver1to10(); prof_ver31to40(); - QRspec_clearCache(); - free_rs_cache(); + QRcode_clearCache(); return 0; } diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 8986fe7212..35ec0ba55e 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -5,7 +5,6 @@ #include "../qrinput.h" #include "../split.h" #include "../qrspec.h" -#include "../rscode.h" #define MAX_LENGTH 7091 static char data[MAX_LENGTH]; @@ -317,8 +316,7 @@ int main(int argc, char **argv) monkey_split_kanji(loop); monkey_split_structure(loop); - QRspec_clearCache(); - free_rs_cache(); + QRcode_clearCache(); report(); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 9f3e7c327b..2df41ccc2d 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -676,9 +676,7 @@ int main(void) test_encodeTooLongMQR(); test_mqrraw_new(); - QRspec_clearCache(); - MQRspec_clearCache(); - free_rs_cache(); + QRcode_clearCache(); report(); -- cgit 0.0.5-2-1-g0f52 From 4eb0d94e3661fc2d32787c1756b3c1f1a8ccfc42 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 8 Jun 2009 08:54:23 +0000 Subject: WITH_TEST introduced. --- configure.ac | 5 ++++- mask.c | 4 +++- mask.h | 6 ++++++ mmask.c | 4 +++- mmask.h | 6 ++++++ qrencode.c | 4 ++-- qrencode_inner.h | 21 +-------------------- qrspec.c | 2 +- tests/common.h | 1 + 9 files changed, 27 insertions(+), 26 deletions(-) diff --git a/configure.ac b/configure.ac index b391e93c03..07a725d4ae 100644 --- a/configure.ac +++ b/configure.ac @@ -49,12 +49,15 @@ AC_ARG_WITH([tests], [AC_HELP_STRING([--with-tests], [build tests [default=no]]) AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes" ]) AH_VERBATIM([tests], [/* Define to 'static' if no test programs will be compiled. */ - #define __STATIC static +#define __STATIC static +#undef WITH_TESTS ]) if test x$build_tests = xyes ; then echo "#define __STATIC" >>confdefs.h +echo "#define WITH_TESTS 1" >>confdefs.h else echo "#define __STATIC static" >>confdefs.h +echo "/* #undef WITH_TESTS */" >>confdefs.h fi diff --git a/mask.c b/mask.c index aaf8b24a19..d57ec7b2f0 100644 --- a/mask.c +++ b/mask.c @@ -144,7 +144,8 @@ static MaskMaker *maskMakers[maskNum] = { Mask_mask4, Mask_mask5, Mask_mask6, Mask_mask7 }; -__STATIC unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask) +#ifdef WITH_TESTS +unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask) { unsigned char *masked; @@ -155,6 +156,7 @@ __STATIC unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, in return masked; } +#endif unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level) { diff --git a/mask.h b/mask.h index ca091908e3..4ce80c5dff 100644 --- a/mask.h +++ b/mask.h @@ -25,4 +25,10 @@ extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level); extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); +#ifdef WITH_TESTS +extern int Mask_evaluateSymbol(int width, unsigned char *frame); +extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); +#endif + #endif /* __MASK_H__ */ diff --git a/mmask.c b/mmask.c index 5c6c5d5980..7999c90612 100644 --- a/mmask.c +++ b/mmask.c @@ -88,7 +88,8 @@ static MaskMaker *maskMakers[maskNum] = { Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3 }; -__STATIC unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask) +#ifdef WITH_TESTS +unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask) { unsigned char *masked; @@ -99,6 +100,7 @@ __STATIC unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, i return masked; } +#endif unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level) { diff --git a/mmask.h b/mmask.h index 1353afec15..627dc32e1a 100644 --- a/mmask.h +++ b/mmask.h @@ -25,4 +25,10 @@ extern unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level); extern unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level); +#ifdef WITH_TESTS +extern int MMask_evaluateSymbol(int width, unsigned char *frame); +extern void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask); +#endif + #endif /* __MMASK_H__ */ diff --git a/qrencode.c b/qrencode.c index 376a70a6b9..f0dcef7e4e 100644 --- a/qrencode.c +++ b/qrencode.c @@ -368,7 +368,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) return &p[y * w + x]; } -#ifdef __STATIC +#ifdef WITH_TESTS extern unsigned char *FrameFiller_test(int version) { int width; @@ -401,7 +401,7 @@ extern unsigned char *FrameFiller_test(int version) } #endif -#ifdef __STATIC +#ifdef WITH_TESTS extern unsigned char *FrameFiller_testMQR(int version) { int width; diff --git a/qrencode_inner.h b/qrencode_inner.h index e36710eed4..d7b491b7d2 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -23,15 +23,8 @@ #define __QRENCODE_INNER_H__ /** - * This header file includes definitions for test use. + * Ths header file includes definitions for test use. */ -extern BitStream *QRinput_mergeBitStream(QRinput *input); -extern BitStream *QRinput_getBitStream(QRinput *input); -extern int QRinput_estimateBitStreamSize(QRinput *input, int version); -extern int QRinput_splitEntry(QRinput_List *entry, int bytes); -extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); -extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); - /****************************************************************************** * Raw code @@ -91,16 +84,4 @@ extern unsigned char *FrameFiller_testMQR(int version); extern QRcode *QRcode_encodeMask(QRinput *input, int mask); extern QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask); -/****************************************************************************** - * Mask - *****************************************************************************/ - -extern int Mask_evaluateSymbol(int width, unsigned char *frame); -extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); -extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); - -extern int MMask_evaluateSymbol(int width, unsigned char *frame); -extern int MMask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); -extern unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask); - #endif /* __QRENCODE_INNER_H__ */ diff --git a/qrspec.c b/qrspec.c index 40be9ee54a..f7bd531a64 100644 --- a/qrspec.c +++ b/qrspec.c @@ -308,7 +308,7 @@ static void QRspec_putAlignmentMarker(unsigned char *frame, int width, int ox, i } } -__STATIC void QRspec_putAlignmentPattern(int version, unsigned char *frame, int width) +static void QRspec_putAlignmentPattern(int version, unsigned char *frame, int width) { int d, w, x, y, cx, cy; diff --git a/tests/common.h b/tests/common.h index 00d3baa7c2..1654abb758 100644 --- a/tests/common.h +++ b/tests/common.h @@ -6,6 +6,7 @@ #define __COMMON_H__ #include +#include "../config.h" #include "../qrencode.h" #include "../qrinput.h" #include "../bitstream.h" -- cgit 0.0.5-2-1-g0f52 From 46a9bdfc0096f2f9a4bbe4d7bbd1347b427c372e Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 8 Jun 2009 08:54:35 +0000 Subject: WITH_TESTS introduced. --- ChangeLog | 7 +++++++ qrinput.h | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2bc97cb6b0..383c0c27a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,13 @@ - FrameFiller_new() now requires mqr flag. * qrencode.[ch], tests/prof_qrencode.c, tests/test_{qrencode,monkey}.c: - QRcode_clearCache() has been added. + * configure.ac, qrencode_inner.h, qrencode.c, mask.[ch], mmask.[ch], + qrinput.h, qrspec.c, tests/common.h: + - A macro WITH_TESTS has been introduced. + - "#ifdef __STATIC" has been replaced with "#ifdef __WITH_TESTS". + - Some definitions in qrencode_inner.h have been moved to appropriate + header files. + - Including config.h became mandatory for test programs. 2009.06.06 Kentaro FUKUCHI * qrenc.c, tests/view_qrcode.c: diff --git a/qrinput.h b/qrinput.h index de4ab77b4d..133dbd0663 100644 --- a/qrinput.h +++ b/qrinput.h @@ -101,4 +101,13 @@ extern const signed char QRinput_anTable[128]; */ #define MAX_STRUCTURED_SYMBOLS 16 +#ifdef WITH_TESTS +extern BitStream *QRinput_mergeBitStream(QRinput *input); +extern BitStream *QRinput_getBitStream(QRinput *input); +extern int QRinput_estimateBitStreamSize(QRinput *input, int version); +extern int QRinput_splitEntry(QRinput_List *entry, int bytes); +extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); +extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); +#endif + #endif /* __QRINPUT_H__ */ -- cgit 0.0.5-2-1-g0f52 From 91662c6b29bf36d81a3dc599c71a2bccbbd50248 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 8 Jun 2009 11:37:01 +0000 Subject: Multithread problem solved. --- ChangeLog | 6 +++ mask.c | 2 +- rscode.c | 1 + tests/Makefile.am | 6 +++ tests/pthread_qrencode.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 tests/pthread_qrencode.c diff --git a/ChangeLog b/ChangeLog index 383c0c27a4..53ab66fdc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,12 @@ - Some definitions in qrencode_inner.h have been moved to appropriate header files. - Including config.h became mandatory for test programs. + * tests/pthread_qrencode.c, tests/Makefile.am: + - New test program has been added. + * rscode.c: + - config.h was not included. + * mask.c: + - Race condition problem has been solved. 2009.06.06 Kentaro FUKUCHI * qrenc.c, tests/view_qrcode.c: diff --git a/mask.c b/mask.c index d57ec7b2f0..d6ee8d0227 100644 --- a/mask.c +++ b/mask.c @@ -176,7 +176,6 @@ unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLeve return masked; } -static int runLength[QRSPEC_WIDTH_MAX + 1]; //static int n1; //static int n2; @@ -223,6 +222,7 @@ __STATIC int Mask_evaluateSymbol(int width, unsigned char *frame) unsigned char b22, w22; int head; int demerit = 0; + int runLength[QRSPEC_WIDTH_MAX + 1]; p = frame; for(y=0; y #include +#include "config.h" #include "rscode.h" #ifdef HAVE_LIBPTHREAD diff --git a/tests/Makefile.am b/tests/Makefile.am index 209e709d99..404a9d2020 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,6 +7,9 @@ noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_mqrspec test_split test_monkey test_mask test_mmask \ create_frame_pattern create_mqr_frame_pattern \ $(sdlPROGRAMS) +if BUILD_TESTS +noinst_PROGRAMS += pthread_qrencode +endif EXTRA_DIST = frame @@ -46,6 +49,9 @@ test_mmask_LDADD = ../libqrencode.la prof_qrencode_SOURCES = prof_qrencode.c prof_qrencode_LDADD = ../libqrencode.la +pthread_qrencode_SOURCES = pthread_qrencode.c +pthread_qrencode_LDADD = ../libqrencode.la + create_frame_pattern_SOURCES = create_frame_pattern.c create_frame_pattern_CFLAGS = $(png_CFLAGS) create_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) diff --git a/tests/pthread_qrencode.c b/tests/pthread_qrencode.c new file mode 100644 index 0000000000..dbaa1ce5ea --- /dev/null +++ b/tests/pthread_qrencode.c @@ -0,0 +1,107 @@ +#include +#include +#include +#include +#include +#include +#include "../qrencode.h" + +#define THREADS (10) + +static pthread_t threads[THREADS]; + +struct timeval tv; +void timerStart(const char *str) +{ + printf("%s: START\n", str); + gettimeofday(&tv, NULL); +} + +void timerStop(void) +{ + struct timeval tc; + + gettimeofday(&tc, NULL); + printf("STOP: %ld msec\n", (tc.tv_sec - tv.tv_sec) * 1000 + + (tc.tv_usec - tv.tv_usec) / 1000); +} + +void *encode_ver1to10(void *arg) +{ + QRcode *code; + int i; + int version; + static const char *data = "This is test."; + + for(i=0; i<500; i++) { + for(version = 0; version < 11; version++) { + code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0); + if(code == NULL) { + perror("Failed to encode:"); + } else { + QRcode_free(code); + } + } + } + + return NULL; +} + +void prof_ver1to10(void) +{ + int i; + + timerStart("Version 1 - 10 (500 symbols for each)"); + for(i=0; i Date: Mon, 28 Sep 2009 02:56:04 +0000 Subject: Typo fixes. --- ChangeLog | 4 ++-- tests/view_qrcode.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53ab66fdc4..382ef5b854 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,7 +36,7 @@ - QRinput_appendPadding*() throws ERANGE when the input is too large. - As a result, QRencode_encodeString*() throws ERANGE in that cases. - Some assertion checks of errno added to test_qrencode. - * Bumped vertion to 3.9.0. + * Bumped version to 3.9.0. - Next public release will be 4.0.0. 2009.06.06 Kentaro FUKUCHI @@ -243,7 +243,7 @@ - Memory leaks have been eliminated. 2009.05.01 Kentaro FUKUCHI - * Bumped vertion to 3.1.0. + * Bumped version to 3.1.0. 2009.04.30 Kentaro FUKUCHI * bistream.[ch]: diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 0998269810..864d683176 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -58,7 +58,7 @@ static void usage(int help, int longopt) " -s NUMBER, --size=NUMBER\n" " specify the size of dot (pixel). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" -" specify error collectin level from L (lowest) to H (highest).\n" +" specify error correctin level from L (lowest) to H (highest).\n" " (default=L)\n\n" " -v NUMBER, --symversion=NUMBER\n" " specify the version of the symbol. (default=auto)\n\n" @@ -85,7 +85,7 @@ static void usage(int help, int longopt) " -h display this message.\n" " --help display the usage of long options.\n" " -s NUMBER specify the size of dot (pixel). (default=3)\n" -" -l {LMQH} specify error collectin level from L (lowest) to H (highest).\n" +" -l {LMQH} specify error correctin level from L (lowest) to H (highest).\n" " (default=L)\n" " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of margin. (default=4)\n" -- cgit 0.0.5-2-1-g0f52 From cd232926c017da3a2a561de711d6e36eea34d40d Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 28 Sep 2009 05:51:47 +0000 Subject: New options '-d' and '--dpi' have been added. Typo fixes. --- ChangeLog | 8 ++++++++ qrenc.c | 33 ++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 382ef5b854..636d376f62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009.09.28 Kentaro FUKUCHI + * qrenc.c: + - David's patch has been applied. + - New options '-d' and '--dpi' have been added. + - Typo fixes. + * tests/view_qrcode.c: + - Typo fixes. + 2009.06.08 Kentaro FUKUCHI * qrencode.c: - FrameFiller_nextMQR() has integrated to FrameFiller_next(). diff --git a/qrenc.c b/qrenc.c index a06099ec21..44860e7ed6 100644 --- a/qrenc.c +++ b/qrenc.c @@ -27,11 +27,14 @@ #include "config.h" #include "qrencode.h" +#define INCHES_PER_METER (100.0/2.54) + static int casesensitive = 1; static int eightbit = 0; static int version = 0; static int size = 3; static int margin = -1; +static int dpi = 72; static int structured = 0; static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; @@ -44,6 +47,7 @@ static const struct option options[] = { {"size" , required_argument, NULL, 's'}, {"symversion" , required_argument, NULL, 'v'}, {"margin" , required_argument, NULL, 'm'}, + {"dpi" , required_argument, NULL, 'd'}, {"structured" , no_argument , NULL, 'S'}, {"kanji" , no_argument , NULL, 'k'}, {"casesensitive", no_argument , NULL, 'c'}, @@ -54,7 +58,7 @@ static const struct option options[] = { {NULL, 0, NULL, 0} }; -static char *optstring = "ho:l:s:v:m:Skci8MV"; +static char *optstring = "ho:l:s:v:m:d:Skci8MV"; static void usage(int help, int longopt) { @@ -74,14 +78,16 @@ static void usage(int help, int longopt) " symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" " if specified, remove a trailing '.png' from FILENAME.\n\n" " -s NUMBER, --size=NUMBER\n" -" specify the size of dot (pixel). (default=3)\n\n" +" specify module size in dots (pixels). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" -" specify error collectin level from L (lowest) to H (highest).\n" +" specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n\n" " -v NUMBER, --symversion=NUMBER\n" " specify the version of the symbol. (default=auto)\n\n" " -m NUMBER, --margin=NUMBER\n" -" specify the width of margin. (default=4)\n\n" +" specify the width of the margins. (default=4)\n\n" +" -d NUMBER, --dpi=NUMBER\n" +" specify the DPI of the generated PNG. (default=72)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" @@ -106,11 +112,13 @@ static void usage(int help, int longopt) " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" " if specified, remove a trailing '.png' from FILENAME.\n" -" -s NUMBER specify the size of dot (pixel). (default=3)\n" -" -l {LMQH} specify error collectin level from L (lowest) to H (highest).\n" +" -s NUMBER specify module size in dots (pixel). (default=3)\n" +" -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" " -v NUMBER specify the version of the symbol. (default=auto)\n" -" -m NUMBER specify the width of margin. (default=4)\n" +" -m NUMBER specify the width of the margins. (default=4)\n" +" -d NUMBER specify the DPI of the generated PNG. (default=72)\n" + " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" @@ -204,6 +212,10 @@ static int writePNG(QRcode *qrcode, const char *outfile) PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + png_set_pHYs(png_ptr, info_ptr, + dpi * INCHES_PER_METER, + dpi * INCHES_PER_METER, + PNG_RESOLUTION_METER); png_write_info(png_ptr, info_ptr); /* top margin */ @@ -409,6 +421,13 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } break; + case 'd': + dpi = atoi(optarg); + if( dpi < 0 ) { + fprintf(stderr, "Invalid DPI: %d\n", dpi); + exit(EXIT_FAILURE); + } + break; case 'S': structured = 1; case 'k': -- cgit 0.0.5-2-1-g0f52 From f07255edc4dfa0c3be745a286a9acbf52a6599a5 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 6 Nov 2009 04:21:20 +0000 Subject: Sync-ed to 3.1.0. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index a77a56f8ea..ebe8253715 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.1.0 (2009.5.x) +Version 3.1.0 (2009.6.6) ------------------------ * Various code cleanups and performance improves. * Strict internal error checks have been added. -- cgit 0.0.5-2-1-g0f52 -- cgit 0.0.5-2-1-g0f52 From 09562b809b7e411ce7982969a5e40d5bcc08e838 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 6 Nov 2009 04:37:20 +0000 Subject: Documents updated. --- ChangeLog | 2 +- NEWS | 12 ++++++++++++ README | 5 +++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 636d376f62..5dfffd9692 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ 2009.09.28 Kentaro FUKUCHI * qrenc.c: - - David's patch has been applied. + - David's patch has been applied. (Thanks to David) - New options '-d' and '--dpi' have been added. - Typo fixes. * tests/view_qrcode.c: diff --git a/NEWS b/NEWS index ebe8253715..216c0c2f6e 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,18 @@ libqrencode NEWS - Overview of changes ====================================== +Version 4.0.0 (2009.x.x) +------------------------ +* Micro QR Code support has been added. +* "-M" option for Micro QR Code has been added to qrencode. +* "--dpi" (or "-d") has been added to qrencode. This option set DPI information + in an output PNG image. (Thanks to David Dahl) +* New option "--enable-thread-safety" has been added to the configure script. + It is enabled by default. + +Release Note: +This release supports Micro QR Code. + Version 3.1.0 (2009.6.6) ------------------------ * Various code cleanups and performance improves. diff --git a/README b/README index f99ad69bf0..ee8640467c 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.1.0 - QR Code encoding library +libqrencode 4.0.0 - QR Code encoding library GENERAL INFORMATION =================== @@ -23,10 +23,10 @@ are implemented such as: embedded - Optimized encoding of a string - Structured-append of symbols +- Micro QR Code Currently the following features are not supported: - ECI and FNC1 mode -- Micro QR Code - QR Code model 1 (deprecated) @@ -112,4 +112,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q NANKI Haruo - improved lower-case characteres encoding Philippe Delcroix - improved mask evaluation Yusuke Mihara - structured-append support +David Dahl - DPI patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 0fba4b8d11332af8f2e857f4ca7e5e9da7fcd097 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 6 Nov 2009 04:44:47 +0000 Subject: - *_clearCache() were thread unsafe. - * "Thread unsafe!" warnings were removed. --- mqrspec.c | 7 +++++++ mqrspec.h | 1 - qrspec.c | 7 +++++++ qrspec.h | 2 -- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mqrspec.c b/mqrspec.c index f904e98eb8..a38bd8fde3 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -266,7 +266,14 @@ void MQRspec_clearCache(void) { int i; +#ifdef HAVE_LIBPTHREAD + pthread_mutex_lock(&frames_mutex); +#endif for(i=1; i<=MQRSPEC_VERSION_MAX; i++) { free(frames[i]); + frames[i] = NULL; } +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&frames_mutex); +#endif } diff --git a/mqrspec.h b/mqrspec.h index d5385c0b69..ed65136dce 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -132,7 +132,6 @@ extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level * Return a copy of initialized frame. * When the same version is requested twice or more, a copy of cached frame * is returned. - * WARNING: Thread unsafe!!! * @param version * @return Array of unsigned char. You can free it by free(). */ diff --git a/qrspec.c b/qrspec.c index f7bd531a64..aa89a4560f 100644 --- a/qrspec.c +++ b/qrspec.c @@ -547,7 +547,14 @@ void QRspec_clearCache(void) { int i; +#ifdef HAVE_LIBPTHREAD + pthread_mutex_lock(&frames_mutex); +#endif for(i=1; i<=QRSPEC_VERSION_MAX; i++) { free(frames[i]); + frames[i] = NULL; } +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&frames_mutex); +#endif } diff --git a/qrspec.h b/qrspec.h index 73e10e0e51..6e3e8579f2 100644 --- a/qrspec.h +++ b/qrspec.h @@ -151,7 +151,6 @@ extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); * Return a copy of initialized frame. * When the same version is requested twice or more, a copy of cached frame * is returned. - * WARNING: Thread unsafe!!! * @param version * @return Array of unsigned char. You can free it by free(). */ @@ -159,7 +158,6 @@ extern unsigned char *QRspec_newFrame(int version); /** * Clear the frame cache. Typically for debug. - * WARNING: Thread unsafe!!! */ extern void QRspec_clearCache(void); -- cgit 0.0.5-2-1-g0f52 From 1beec7d308204feea9a61db37ab96eaa7ce21c36 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 6 Nov 2009 04:45:26 +0000 Subject: - "Thread unsafe!" warning has been removed. --- mqrspec.h | 1 - 1 file changed, 1 deletion(-) diff --git a/mqrspec.h b/mqrspec.h index ed65136dce..f27f8c2b56 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -139,7 +139,6 @@ extern unsigned char *MQRspec_newFrame(int version); /** * Clear the frame cache. Typically for debug. - * WARNING: Thread unsafe!!! */ extern void MQRspec_clearCache(void); -- cgit 0.0.5-2-1-g0f52 From e39cbc9787757b1e5748752b2ed996c167ffaf70 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 6 Nov 2009 04:48:44 +0000 Subject: free_rs_cache() now becomes thread safe. --- rscode.c | 7 +++++++ rscode.h | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rscode.c b/rscode.c index 43bfab60cd..379e95b106 100644 --- a/rscode.c +++ b/rscode.c @@ -250,12 +250,19 @@ void free_rs_cache(void) { RS *rs, *next; +#ifdef HAVE_LIBPTHREAD + pthread_mutex_lock(&rslist_mutex); +#endif rs = rslist; while(rs != NULL) { next = rs->next; free_rs_char(rs); rs = next; } + rslist = NULL; +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&rslist_mutex); +#endif } /* The guts of the Reed-Solomon encoder, meant to be #included diff --git a/rscode.h b/rscode.h index aea9400a60..0f212c8d40 100644 --- a/rscode.h +++ b/rscode.h @@ -33,7 +33,6 @@ typedef struct _RS RS; -/* WARNING: Thread unsafe!!! */ extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad); extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity); extern void free_rs_char(RS *rs); -- cgit 0.0.5-2-1-g0f52 From a31f4d08ecafa56b509743970e6c0c74c36f854d Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 6 Nov 2009 09:07:15 +0000 Subject: --- ChangeLog | 10 ++++++++++ NEWS | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5dfffd9692..b6b19c49a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009.11.06 Kentaro FUKUCHI + * NEWS, README: + - Documents updated. + * qrspec.[ch], mqrspec.[ch]: + - *_clearCache were not thread safe. + - "Thread unsafe" warnings were removed. + * rscode.[ch] + - free_rs_cache was not thread safe. + - "Thread unsafe" warnings were removed. + 2009.09.28 Kentaro FUKUCHI * qrenc.c: - David's patch has been applied. (Thanks to David) diff --git a/NEWS b/NEWS index 216c0c2f6e..3f1e225faf 100644 --- a/NEWS +++ b/NEWS @@ -7,11 +7,13 @@ Version 4.0.0 (2009.x.x) * "-M" option for Micro QR Code has been added to qrencode. * "--dpi" (or "-d") has been added to qrencode. This option set DPI information in an output PNG image. (Thanks to David Dahl) -* New option "--enable-thread-safety" has been added to the configure script. - It is enabled by default. +* New option "--enable-thread-safety" has been added to the configure script + that makes the library thread-safe. It is enabled by default. Release Note: This release supports Micro QR Code. +For a long time, libqrencode was thread unsafe. +Thread safe. Version 3.1.0 (2009.6.6) ------------------------ -- cgit 0.0.5-2-1-g0f52 From 8ff21ca4dde54a2bfa91cddda37cf4dc074f944e Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 9 Dec 2009 12:53:25 +0000 Subject: Typo fixes. --- ChangeLog | 4 ++++ qrencode.h | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6b19c49a5..e2664e2974 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009.11.27 Kentaro FUKUCHI + * qrencode.h: + - Typo fixes. + 2009.11.06 Kentaro FUKUCHI * NEWS, README: - Documents updated. diff --git a/qrencode.h b/qrencode.h index 407f6cbae6..3d63e6e4f6 100644 --- a/qrencode.h +++ b/qrencode.h @@ -380,7 +380,7 @@ extern QRcode *QRcode_encodeInput(QRinput *input); * Create a symbol from the string. The library automatically parses the input * string and encodes in a QR Code symbol. * @warning This function is THREAD UNSAFE. - * @param string input string. It must be NULL terminated. + * @param string input string. It must be NUL terminated. * @param version version of the symbol. If 0, the library chooses the minimum * version for the given input data. * @param level error correction level. @@ -436,7 +436,7 @@ extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s); * Create structured symbols from the string. The library automatically parses * the input string and encodes in a QR Code symbol. * @warning This function is THREAD UNSAFE. - * @param string input string. It should be NULL terminated. + * @param string input string. It must be NUL terminated. * @param version version of the symbol. * @param level error correction level. * @param hint tell the library how non-alphanumerical characters should be -- cgit 0.0.5-2-1-g0f52 From b44c5f95a8dac013dc67c68975ad059bd7d14ee1 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 16 Jan 2010 07:48:49 +0000 Subject: QRcode_encodeData{,MQR,Structured}() have been added. Code refactoring. --- qrencode.c | 117 +++++++++++++++++++++++++++++++++++++++++++------------------ qrencode.h | 35 ++++++++++++++++++ 2 files changed, 117 insertions(+), 35 deletions(-) diff --git a/qrencode.c b/qrencode.c index f0dcef7e4e..9ea37a0cd5 100644 --- a/qrencode.c +++ b/qrencode.c @@ -629,7 +629,7 @@ QRcode *QRcode_encodeInput(QRinput *input) } } -static QRcode *QRcode_encodeStringReal(const char *string, int version, QRecLevel level, int eightbit, int mqr, QRencodeMode hint, int casesensitive) +static QRcode *QRcode_encodeStringReal(const char *string, int version, QRecLevel level, int mqr, QRencodeMode hint, int casesensitive) { QRinput *input; QRcode *code; @@ -639,7 +639,7 @@ static QRcode *QRcode_encodeStringReal(const char *string, int version, QRecLeve errno = EINVAL; return NULL; } - if(!eightbit && (hint != QR_MODE_8 && hint != QR_MODE_KANJI)) { + if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) { errno = EINVAL; return NULL; } @@ -651,11 +651,46 @@ static QRcode *QRcode_encodeStringReal(const char *string, int version, QRecLeve } if(input == NULL) return NULL; - if(eightbit) { - ret = QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string); + ret = Split_splitStringToQRinput(string, input, hint, casesensitive); + if(ret < 0) { + QRinput_free(input); + return NULL; + } + code = QRcode_encodeInput(input); + QRinput_free(input); + + return code; +} + +QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) +{ + return QRcode_encodeStringReal(string, version, level, 0, hint, casesensitive); +} + +QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) +{ + return QRcode_encodeStringReal(string, version, level, 1, hint, casesensitive); +} + +static QRcode *QRcode_encodeDataReal(const unsigned char *data, int length, int version, QRecLevel level, int mqr) +{ + QRinput *input; + QRcode *code; + int ret; + + if(data == NULL || length == 0) { + errno = EINVAL; + return NULL; + } + + if(mqr) { + input = QRinput_newMQR(version, level); } else { - ret = Split_splitStringToQRinput(string, input, hint, casesensitive); + input = QRinput_new2(version, level); } + if(input == NULL) return NULL; + + ret = QRinput_append(input, QR_MODE_8, length, data); if(ret < 0) { QRinput_free(input); return NULL; @@ -666,26 +701,35 @@ static QRcode *QRcode_encodeStringReal(const char *string, int version, QRecLeve return code; } -QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level) +QRcode *QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level) { - return QRcode_encodeStringReal(string, version, level, 1, 0, QR_MODE_NUL, 0); + return QRcode_encodeDataReal(data, size, version, level, 0); } -QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) +QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level) { - return QRcode_encodeStringReal(string, version, level, 0, 0, hint, casesensitive); + if(string == NULL) { + errno = EINVAL; + return NULL; + } + return QRcode_encodeDataReal((unsigned char *)string, strlen(string), version, level, 0); } -QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level) +QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level) { - return QRcode_encodeStringReal(string, version, level, 1, 1, QR_MODE_NUL, 0); + return QRcode_encodeDataReal(data, size, version, level, 1); } -QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) +QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level) { - return QRcode_encodeStringReal(string, version, level, 0, 1, hint, casesensitive); + if(string == NULL) { + errno = EINVAL; + return NULL; + } + return QRcode_encodeDataReal((unsigned char *)string, strlen(string), version, level, 1); } + /****************************************************************************** * Structured QR-code encoding *****************************************************************************/ @@ -795,7 +839,10 @@ static QRcode_List *QRcode_encodeInputToStructured(QRinput *input) return codes; } -QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level) +static QRcode_List *QRcode_encodeDataStructuredReal( + int size, const unsigned char *data, + int version, QRecLevel level, + int eightbit, QRencodeMode hint, int casesensitive) { QRinput *input; QRcode_List *codes; @@ -805,11 +852,19 @@ QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, errno = EINVAL; return NULL; } + if(!eightbit && (hint != QR_MODE_8 && hint != QR_MODE_KANJI)) { + errno = EINVAL; + return NULL; + } input = QRinput_new2(version, level); if(input == NULL) return NULL; - ret = QRinput_append(input, QR_MODE_8, strlen(string), (unsigned char *)string); + if(eightbit) { + ret = QRinput_append(input, QR_MODE_8, size, data); + } else { + ret = Split_splitStringToQRinput((char *)data, input, hint, casesensitive); + } if(ret < 0) { QRinput_free(input); return NULL; @@ -820,33 +875,25 @@ QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, return codes; } -QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) -{ - QRinput *input; - QRcode_List *codes; - int ret; +QRcode_List *QRcode_encodeDataStructured(int size, const unsigned char *data, int version, QRecLevel level) { + return QRcode_encodeDataStructuredReal(size, data, version, level, 1, QR_MODE_NUL, 0); +} - if(version <= 0) { - errno = EINVAL; - return NULL; - } - if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) { +QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level) { + if(string == NULL) { errno = EINVAL; return NULL; } + return QRcode_encodeDataStructured(strlen(string), (unsigned char *)string, version, level); +} - input = QRinput_new2(version, level); - if(input == NULL) return NULL; - - ret = Split_splitStringToQRinput(string, input, hint, casesensitive); - if(ret < 0) { - QRinput_free(input); +QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) +{ + if(string == NULL) { + errno = EINVAL; return NULL; } - codes = QRcode_encodeInputToStructured(input); - QRinput_free(input); - - return codes; + return QRcode_encodeDataStructuredReal(strlen(string), (unsigned char *)string, version, level, 0, hint, casesensitive); } /****************************************************************************** diff --git a/qrencode.h b/qrencode.h index 3d63e6e4f6..0dbf948015 100644 --- a/qrencode.h +++ b/qrencode.h @@ -418,6 +418,26 @@ extern QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel */ extern QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level); +/** + * Encode byte stream (may include '\0') in 8-bit mode. + * @warning This function is THREAD UNSAFE. + * @param size size of the input data. + * @param data input data. + * @param version version of the symbol. If 0, the library chooses the minimum + * version for the given input data. + * @param level error correction level. + * @throw EINVAL invalid input object. + * @throw ENOMEM unable to allocate memory for input objects. + * @throw ERANGE input data is too large. + */ +extern QRcode *QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level); + +/** + * Micro QR Code version of QRcode_encodeData(). + * @warning This function is THREAD UNSAFE. + */ +extern QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level); + /** * Free the instance of QRcode class. * @param qrcode an instance of QRcode class. @@ -458,6 +478,21 @@ extern QRcode_List *QRcode_encodeStringStructured(const char *string, int versio */ extern QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level); +/** + * Create structured symbols from byte stream (may include '\0'). Wholde data + * are encoded in 8-bit mode. + * @warning This function is THREAD UNSAFE. + * @param size size of the input data. + * @param data input dat. + * @param version version of the symbol. + * @param level error correction level. + * @return a singly-linked list of QRcode. On error, NULL is returned, and + * errno is set to indicate the error. See Exceptions for the details. + * @throw EINVAL invalid input object. + * @throw ENOMEM unable to allocate memory for input objects. + */ +extern QRcode_List *QRcode_encodeDataStructured(int size, const unsigned char *data, int version, QRecLevel level); + /** * Return the number of symbols included in a QRcode_List. * @param qrlist a head entry of a QRcode_List. -- cgit 0.0.5-2-1-g0f52 From 73fb9e06f577c025d24a760eba744ddcf3554036 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Sat, 16 Jan 2010 07:50:32 +0000 Subject: New teset for QRencode_encodeData(). --- tests/test_qrencode.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 2df41ccc2d..a9552e995f 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -649,6 +649,24 @@ void test_mqrraw_new(void) testFinish(); } +void test_encodeData(void) +{ + QRcode *qrcode; + + testStart("Test QRencode_encodeData."); + qrcode = QRcode_encodeData(0, NULL, 0, QR_ECLEVEL_H); + assert_null(qrcode, "QRcode_encodeData(NULL, 0) returned something.\n"); + if(qrcode != NULL) QRcode_free(qrcode); + + qrcode = QRcode_encodeData(10, (unsigned char*)"test\0\0test", 0, QR_ECLEVEL_H); + assert_nonnull(qrcode, "QRcode_encodeData() failed.\n"); + if(qrcode != NULL) QRcode_free(qrcode); + + testFinish(); +} + + + int main(void) { test_iterate(); @@ -675,6 +693,7 @@ int main(void) test_fillerMQR(); test_encodeTooLongMQR(); test_mqrraw_new(); + test_encodeData(); QRcode_clearCache(); -- cgit 0.0.5-2-1-g0f52 From 751cfe96ea186c8a1ff0d13406e190f2b97d5a66 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 00:34:54 +0000 Subject: configuration cleanups. --- configure.ac | 54 ++++++++++++++++++++++++++++++------------------------ tests/Makefile.am | 2 +- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 07a725d4ae..c3b537ac5d 100644 --- a/configure.ac +++ b/configure.ac @@ -32,20 +32,28 @@ PKG_PROG_PKG_CONFIG AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1]) dnl --enable-thread-safety -AC_ARG_ENABLE([thread-safety], [AC_HELP_STRING([--enable-thread-safety], [make the library thread-safe. [default=yes]])], +AC_ARG_ENABLE([thread-safety], [AS_HELP_STRING([--enable-thread-safety], [make the library thread-safe. [default=yes]])], [], [enable_thread_safety=yes]) +if test x$enable_thread_safety = xyes; then + AC_CHECK_LIB([pthread], [pthread_mutex_init]) +fi +AM_CONDITIONAL([HAVE_LIBPTHREAD], [test "x$HAVE_LIBPTHREAD" = "xyes" ]) + + dnl --with-tools -AC_ARG_WITH([tools], [AC_HELP_STRING([--with-tools], [build utility tools [default=yes]])], +AC_ARG_WITH([tools], [AS_HELP_STRING([--with-tools], [build utility tools [default=yes]])], [build_tools=$withval], [build_tools=yes]) + AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ]) if test x$build_tools = xyes ; then PKG_CHECK_MODULES(png, "libpng12") fi dnl --with-tests -AC_ARG_WITH([tests], [AC_HELP_STRING([--with-tests], [build tests [default=no]])], +AC_ARG_WITH([tests], [AS_HELP_STRING([--with-tests], [build tests [default=no]])], [build_tests=$withval], [build_tests=no]) + AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes" ]) AH_VERBATIM([tests], [/* Define to 'static' if no test programs will be compiled. */ @@ -60,48 +68,46 @@ echo "#define __STATIC static" >>confdefs.h echo "/* #undef WITH_TESTS */" >>confdefs.h fi - if test x$build_tests = xyes ; then SDL_REQUIRED_VERSION=1.2.0 AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.])) + AC_MSG_NOTICE([SDL check done.]) fi AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ]) dnl --enable-gprof -AC_ARG_ENABLE([gprof], [AC_HELP_STRING([--enable-gprof], [generate extra code to write profile information suitable for gprof [default=no]])], +AC_ARG_ENABLE([gprof], [AS_HELP_STRING([--enable-gprof], [generate extra code to write profile information suitable for gprof [default=no]])], [], [enable_gprof=no]) -dnl --enable-gcov -AC_ARG_ENABLE([gcov], [AC_HELP_STRING([--enable-gcov], [generate extra code to write coverage information suitable for gcov [default=no]])], - [], [enable_gcov=no]) +if test x$enable_gprof = xyes; then + CFLAGS="$CFLAGS -g -pg" +fi -dnl --enable-mudflap -AC_ARG_ENABLE([mudflap], [AC_HELP_STRING([--enable-mudflap], [generate extra code to check memory leaks [default=no]])], - [], [enable_mudflap=no]) -dnl set CFLAGS -CFLAGS="-Wall $CFLAGS" +dnl --enable-gcov +AC_ARG_ENABLE([gcov], [AS_HELP_STRING([--enable-gcov], [generate extra code to write coverage information suitable for gcov [default=no]])], + [], [enable_gcov=no]) -if test $enable_thread_safety = yes; then - AC_CHECK_LIB([pthread], [pthread_mutex_init]) - LIBPTHREAD=-lpthread +if test x$enable_gcov = xyes; then + CFLAGS="$CFLAGS --coverage" fi -AC_SUBST(LIBPTHREAD) -if test $enable_gprof = yes; then - CFLAGS="$CFLAGS -g -pg" -fi -if test $enable_gcov = yes; then - CFLAGS="$CFLAGS --coverage" -fi +dnl --enable-mudflap +AC_ARG_ENABLE([mudflap], [AS_HELP_STRING([--enable-mudflap], [generate extra code to check memory leaks [default=no]])], + [], [enable_mudflap=no]) -if test $enable_mudflap = yes; then +if test x$enable_mudflap = xyes; then CFLAGS="$CFLAGS -fmudflap" LDFLAGS="$LDFLAGS -lmudflap" fi + +dnl set CFLAGS +CFLAGS="-Wall $CFLAGS" + + AC_OUTPUT echo "" diff --git a/tests/Makefile.am b/tests/Makefile.am index 404a9d2020..317bf0d0fe 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,7 +7,7 @@ noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_mqrspec test_split test_monkey test_mask test_mmask \ create_frame_pattern create_mqr_frame_pattern \ $(sdlPROGRAMS) -if BUILD_TESTS +if HAVE_LIBPTHREAD noinst_PROGRAMS += pthread_qrencode endif -- cgit 0.0.5-2-1-g0f52 From a0e1dfb470787e082417905ab89767e09c0c66c4 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 05:58:07 +0000 Subject: Support byte data including NUL ('\0'). --- qrenc.c | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/qrenc.c b/qrenc.c index 44860e7ed6..11fc294141 100644 --- a/qrenc.c +++ b/qrenc.c @@ -95,7 +95,7 @@ static void usage(int help, int longopt) " encode lower-case alphabet characters in 8-bit mode. (default)\n\n" " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" -" -8, -8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" +" -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" " -M, --micro encode in a Micro QR Code.\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" @@ -112,7 +112,7 @@ static void usage(int help, int longopt) " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" " if specified, remove a trailing '.png' from FILENAME.\n" -" -s NUMBER specify module size in dots (pixel). (default=3)\n" +" -s NUMBER specify module size in dots (pixels). (default=3)\n" " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" " -v NUMBER specify the version of the symbol. (default=auto)\n" @@ -134,12 +134,12 @@ static void usage(int help, int longopt) } #define MAX_DATA_SIZE (7090 * 16) /* from the specification */ -static char *readStdin(void) +static unsigned char *readStdin(int *length) { - char *buffer; + unsigned char *buffer; int ret; - buffer = (char *)malloc(MAX_DATA_SIZE); + buffer = (unsigned char *)malloc(MAX_DATA_SIZE + 1); if(buffer == NULL) { fprintf(stderr, "Memory allocation failed.\n"); exit(EXIT_FAILURE); @@ -155,6 +155,7 @@ static char *readStdin(void) } buffer[ret] = '\0'; + *length = ret; return buffer; } @@ -262,32 +263,32 @@ static int writePNG(QRcode *qrcode, const char *outfile) return 0; } -static QRcode *encode(const char *intext) +static QRcode *encode(const unsigned char *intext, int length) { QRcode *code; if(micro) { if(eightbit) { - code = QRcode_encodeString8bitMQR(intext, version, level); + code = QRcode_encodeDataMQR(length, intext, version, level); } else { - code = QRcode_encodeStringMQR(intext, version, level, hint, casesensitive); + code = QRcode_encodeStringMQR((char *)intext, version, level, hint, casesensitive); } } else { if(eightbit) { - code = QRcode_encodeString8bit(intext, version, level); + code = QRcode_encodeData(length, intext, version, level); } else { - code = QRcode_encodeString(intext, version, level, hint, casesensitive); + code = QRcode_encodeString((char *)intext, version, level, hint, casesensitive); } } return code; } -static void qrencode(const char *intext, const char *outfile) +static void qrencode(const unsigned char *intext, int length, const char *outfile) { QRcode *qrcode; - qrcode = encode(intext); + qrcode = encode(intext, length); if(qrcode == NULL) { perror("Failed to encode the input data"); exit(EXIT_FAILURE); @@ -296,20 +297,20 @@ static void qrencode(const char *intext, const char *outfile) QRcode_free(qrcode); } -static QRcode_List *encodeStructured(const char *intext) +static QRcode_List *encodeStructured(const unsigned char *intext, int length) { QRcode_List *list; if(eightbit) { - list = QRcode_encodeString8bitStructured(intext, version, level); + list = QRcode_encodeDataStructured(length, intext, version, level); } else { - list = QRcode_encodeStringStructured(intext, version, level, hint, casesensitive); + list = QRcode_encodeStringStructured((char *)intext, version, level, hint, casesensitive); } return list; } -static void qrencodeStructured(const char *intext, const char *outfile) +static void qrencodeStructured(const unsigned char *intext, int length, const char *outfile) { QRcode_List *qrlist, *p; char filename[FILENAME_MAX]; @@ -329,7 +330,7 @@ static void qrencodeStructured(const char *intext, const char *outfile) } } - qrlist = encodeStructured(intext); + qrlist = encodeStructured(intext, length); if(qrlist == NULL) { perror("Failed to encode the input data"); exit(EXIT_FAILURE); @@ -361,7 +362,8 @@ int main(int argc, char **argv) { int opt, lindex = -1; char *outfile = NULL; - char *intext = NULL; + unsigned char *intext = NULL; + int length = 0; while((opt = getopt_long(argc, argv, optstring, options, &lindex)) != -1) { switch(opt) { @@ -371,7 +373,7 @@ int main(int argc, char **argv) } else { usage(1, 0); } - exit(0); + exit(EXIT_SUCCESS); break; case 'o': outfile = optarg; @@ -447,7 +449,7 @@ int main(int argc, char **argv) break; case 'V': usage(0, 0); - exit(0); + exit(EXIT_SUCCESS); break; default: fprintf(stderr, "Try `qrencode --help' for more information.\n"); @@ -458,7 +460,7 @@ int main(int argc, char **argv) if(argc == 1) { usage(1, 0); - exit(0); + exit(EXIT_SUCCESS); } if(outfile == NULL) { @@ -467,10 +469,11 @@ int main(int argc, char **argv) } if(optind < argc) { - intext = argv[optind]; + intext = (unsigned char *)argv[optind]; + length = strlen((char *)intext); } if(intext == NULL) { - intext = readStdin(); + intext = readStdin(&length); } if(micro && version > MQRSPEC_VERSION_MAX) { @@ -505,9 +508,9 @@ int main(int argc, char **argv) fprintf(stderr, "Version must be specified to encode structured symbols.\n"); exit(EXIT_FAILURE); } - qrencodeStructured(intext, outfile); + qrencodeStructured(intext, length, outfile); } else { - qrencode(intext, outfile); + qrencode(intext, length, outfile); } return 0; -- cgit 0.0.5-2-1-g0f52 From 5d15aa88decb39cae0192fa15f3b5bd0db1965a0 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 11:50:54 +0000 Subject: Now '\0' in 8-bit mode data handled correctly. --- tests/view_qrcode.c | 78 +++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 864d683176..a9d39d905e 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -56,14 +56,14 @@ static void usage(int help, int longopt) " -h, --help display the help message. -h displays only the help of short\n" " options.\n\n" " -s NUMBER, --size=NUMBER\n" -" specify the size of dot (pixel). (default=3)\n\n" +" specify module size in dots (pixels). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" -" specify error correctin level from L (lowest) to H (highest).\n" +" specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n\n" " -v NUMBER, --symversion=NUMBER\n" " specify the version of the symbol. (default=auto)\n\n" " -m NUMBER, --margin=NUMBER\n" -" specify the width of margin. (default=4)\n\n" +" specify the width of the margins. (default=4)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" @@ -71,7 +71,7 @@ static void usage(int help, int longopt) " encode lower-case alphabet characters in 8-bit mode. (default)\n\n" " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" -" -8, -8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" +" -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" " -M, --micro encode in a Micro QR Code.\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" @@ -84,11 +84,11 @@ static void usage(int help, int longopt) "Encode input data in a QR Code and display.\n\n" " -h display this message.\n" " --help display the usage of long options.\n" -" -s NUMBER specify the size of dot (pixel). (default=3)\n" -" -l {LMQH} specify error correctin level from L (lowest) to H (highest).\n" +" -s NUMBER specify module size in dots (pixels). (default=3)\n" +" -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" " -v NUMBER specify the version of the symbol. (default=auto)\n" -" -m NUMBER specify the width of margin. (default=4)\n" +" -m NUMBER specify the width of the margins. (default=4)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" @@ -104,23 +104,29 @@ static void usage(int help, int longopt) } #define MAX_DATA_SIZE (7090 * 16) /* from the specification */ -static char *readStdin(void) +static unsigned char *readStdin(int *length) { - char *buffer; + unsigned char *buffer; int ret; - buffer = (char *)malloc(MAX_DATA_SIZE); + buffer = (unsigned char *)malloc(MAX_DATA_SIZE + 1); + if(buffer == NULL) { + fprintf(stderr, "Memory allocation failed.\n"); + exit(EXIT_FAILURE); + } + ret = fread(buffer, 1, MAX_DATA_SIZE, stdin); if(ret == 0) { fprintf(stderr, "No input data.\n"); - exit(1); + exit(EXIT_FAILURE); } - if(!feof(stdin)) { + if(feof(stdin) == 0) { fprintf(stderr, "Input data is too large.\n"); - exit(1); + exit(EXIT_FAILURE); } buffer[ret] = '\0'; + *length = ret; return buffer; } @@ -211,13 +217,13 @@ void draw_structuredQRcodeFromText(int argc, char **argv) s = QRinput_Struct_new(); if(s == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); - exit(1); + exit(EXIT_FAILURE); } for(i=0; i 1)) { view_multiText(argv + optind, argc - optind); } else { - view_simple(intext); + view_simple(intext, length); } SDL_Quit(); -- cgit 0.0.5-2-1-g0f52 From 9d6a0d2435648f184876f8bf93e03540d720a78c Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 11:51:48 +0000 Subject: Decoder has been added. --- tests/Makefile.am | 28 ++-- tests/decoder.c | 452 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/decoder.h | 30 ++++ 3 files changed, 496 insertions(+), 14 deletions(-) create mode 100644 tests/decoder.c create mode 100644 tests/decoder.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 317bf0d0fe..a05bfc7b6e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,37 +13,37 @@ endif EXTRA_DIST = frame -test_qrinput_SOURCES = test_qrinput.c common.h -test_qrinput_LDADD = ../libqrencode.la +test_qrinput_SOURCES = test_qrinput.c +test_qrinput_LDADD = ../libqrencode.la decoder.o -test_bitstream_SOURCES = test_bitstream.c common.h +test_bitstream_SOURCES = test_bitstream.c test_bitstream_LDADD = ../libqrencode.la -test_estimatebit_SOURCES = test_estimatebit.c common.h +test_estimatebit_SOURCES = test_estimatebit.c test_estimatebit_LDADD = ../libqrencode.la -test_qrspec_SOURCES = test_qrspec.c common.h +test_qrspec_SOURCES = test_qrspec.c test_qrspec_LDADD = ../libqrencode.la -test_mqrspec_SOURCES = test_mqrspec.c common.h +test_mqrspec_SOURCES = test_mqrspec.c test_mqrspec_LDADD = ../libqrencode.la -test_rs_SOURCES = test_rs.c common.h +test_rs_SOURCES = test_rs.c test_rs_LDADD = ../libqrencode.la -test_qrencode_SOURCES = test_qrencode.c common.h -test_qrencode_LDADD = ../libqrencode.la +test_qrencode_SOURCES = test_qrencode.c +test_qrencode_LDADD = ../libqrencode.la decoder.o -test_split_SOURCES = test_split.c common.h +test_split_SOURCES = test_split.c test_split_LDADD = ../libqrencode.la -test_monkey_SOURCES = test_monkey.c common.h +test_monkey_SOURCES = test_monkey.c test_monkey_LDADD = ../libqrencode.la -test_mask_SOURCES = test_mask.c common.h +test_mask_SOURCES = test_mask.c test_mask_LDADD = ../libqrencode.la -test_mmask_SOURCES = test_mmask.c common.h +test_mmask_SOURCES = test_mmask.c test_mmask_LDADD = ../libqrencode.la prof_qrencode_SOURCES = prof_qrencode.c @@ -61,7 +61,7 @@ create_mqr_frame_pattern_CFLAGS = $(png_CFLAGS) create_mqr_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) if HAVE_SDL -view_qrcode_SOURCES = view_qrcode.c common.h +view_qrcode_SOURCES = view_qrcode.c view_qrcode_CFLAGS= $(SDL_CFLAGS) view_qrcode_LDADD = ../libqrencode.la $(SDL_LIBS) endif diff --git a/tests/decoder.c b/tests/decoder.c new file mode 100644 index 0000000000..60f3c67b75 --- /dev/null +++ b/tests/decoder.c @@ -0,0 +1,452 @@ +#include +#include +#include +#include "../qrspec.h" +#include "decoder.h" +#include + +enum { + DECODE_OK = 0, + DECODE_INVALID = 1, +}; + +DataChunk *DataChunk_new(QRencodeMode mode) +{ + DataChunk *chunk; + + chunk = (DataChunk *)calloc(1, sizeof(DataChunk)); + if(chunk == NULL) return NULL; + + chunk->mode = mode; + + return chunk; +} + +void DataChunk_free(DataChunk *chunk) +{ + if(chunk) { + if(chunk->data) free(chunk->data); + free(chunk); + } +} + +DataChunk *decodeNum(int bits_length, unsigned char *bits, int version) +{ + int i, j; + int lbits, size, words, remain; + unsigned char *p; + char *buf, *q; + int val; + DataChunk *chunk; + + lbits = QRspec_lengthIndicator(QR_MODE_NUM, version); + if(bits_length < lbits) { + fprintf(stderr, "Bit length is too short: %d\n", bits_length); + return NULL; + } + p = bits; + val = 0; + for(i=0; isize = size; + chunk->data = (unsigned char *)buf; + + return chunk; +} + +static const char decodeAnTable[45] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', + '+', '-', '.', '/', ':' +}; + +DataChunk *decodeAn(int bits_length, unsigned char *bits, int version) +{ + int i, j; + int lbits, size, words, remain; + unsigned char *p; + char *buf, *q; + int val; + int ch, cl; + DataChunk *chunk; + + lbits = QRspec_lengthIndicator(QR_MODE_AN, version); + if(bits_length < lbits) { + fprintf(stderr, "Bit length is too short: %d\n", bits_length); + return NULL; + } + p = bits; + val = 0; + for(i=0; isize = size; + chunk->data = (unsigned char *)buf; + + return chunk; +} + +DataChunk *decode8(int bits_length, unsigned char *bits, int version) +{ + int i, j; + int lbits, size; + unsigned char *p; + unsigned char *buf, *q; + int val; + DataChunk *chunk; + + lbits = QRspec_lengthIndicator(QR_MODE_8, version); + if(bits_length < lbits) { + fprintf(stderr, "Bit length is too short: %d\n", bits_length); + return NULL; + } + p = bits; + val = 0; + for(i=0; isize = size; + chunk->data = buf; + + return chunk; +} + +DataChunk *decodeKanji(int bits_length, unsigned char *bits, int version) +{ + int i, j; + int lbits, size; + unsigned char *p; + char *buf, *q; + int val; + int ch, cl; + DataChunk *chunk; + + lbits = QRspec_lengthIndicator(QR_MODE_KANJI, version); + if(bits_length < lbits) { + fprintf(stderr, "Bit length is too short: %d\n", bits_length); + return NULL; + } + p = bits; + val = 0; + for(i=0; i= 0x1f00) { + val += 0xc140; + } else { + val += 0x8140; + } + sprintf(q, "%c%c", (val>>8) & 0xff, val & 0xff); + p += 13; + q += 2; + } + + chunk = DataChunk_new(QR_MODE_KANJI); + chunk->size = size * 2; + chunk->data = (unsigned char *)buf; + + return chunk; +} + +DataChunk *decodeChunk(int bits_length, unsigned char *bits, int version) +{ + int i, val; + + if(bits_length < 4) { + fprintf(stderr, "Bit length too short: %d\n", bits_length); + return NULL; + } + val = 0; + for(i=0; i<4; i++) { + val = val << 1; + val += bits[i]; + } + printf("Mode: %d\n", val); + bits_length -= 4; + bits += 4; + switch(val) { + case 1: + return decodeNum(bits_length, bits, version); + case 2: + return decodeAn(bits_length, bits, version); + case 4: + return decode8(bits_length, bits, version); + case 8: + return decodeKanji(bits_length, bits, version); + default: + break; + } + + fprintf(stderr, "Invalid mode in a chunk: %d\n", val); + + return NULL; +} + +void dumpNum(DataChunk *chunk) +{ + printf("%s\n", chunk->data); +} + +void dumpAn(DataChunk *chunk) +{ + printf("%s\n", chunk->data); +} + +void dump8(DataChunk *chunk) +{ + int i, j; + unsigned char c; + int count = 0; + unsigned char buf[16]; + + for(i=0; isize; i++) { + buf[count] = chunk->data[i]; + c = chunk->data[i]; + if(c >= ' ' && c <= '~') { + putchar(c); + } else { + putchar('.'); + } + count++; + + if(count >= 16) { + putchar(' '); + for(j=0; j<16; j++) { + printf(" %02x", buf[j]); + } + count = 0; + putchar('\n'); + } + } + if(count > 0) { + for(i=0; i<16 - count; i++) { + putchar(' '); + } + putchar(' '); + for(j=0; jsize; + inbuf = (char *)chunk->data; + outbytes = inbytes * 4 + 1; + outbuf = (char *)malloc(inbytes * 4 + 1); + outp = outbuf; + ret = iconv(conv, &inbuf, &inbytes, &outp, &outbytes); + if(ret < 0) { perror(NULL); } + *outp = '\0'; + + printf("%s\n", outbuf); + + iconv_close(conv); + free(outbuf); +} + +void dumpChunk(DataChunk *chunk) +{ + switch(chunk->mode) { + case QR_MODE_NUM: + printf("Numeric: %d bytes\n", chunk->size); + dumpNum(chunk); + break; + case QR_MODE_AN: + printf("AlphaNumeric: %d bytes\n", chunk->size); + dumpAn(chunk); + break; + case QR_MODE_8: + printf("8-bit data: %d bytes\n", chunk->size); + dump8(chunk); + break; + case QR_MODE_KANJI: + printf("Kanji: %d bytes\n", chunk->size); + dumpKanji(chunk); + break; + default: + printf("Invalid or reserved: %d bytes\n", chunk->size); + dump8(chunk); + break; + } +} + +void dumpChunks(QRdata *qrdata) +{ + DataChunk *chunk; + + chunk = qrdata->chunks; + while(chunk != NULL) { + dumpChunk(chunk); + chunk = chunk->next; + } +} + +void concatChunks(QRdata *qrdata) +{ + int idx; + unsigned char *data; + DataChunk *chunk; + int size = 0; + + chunk = qrdata->chunks; + while(chunk != NULL) { + size += chunk->size; + chunk = chunk->next; + } + if(size <= 0) { + qrdata->status = DECODE_INVALID; + return; + } + + data = malloc(size); + chunk = qrdata->chunks; + idx = 0; + while(chunk != NULL) { + memcpy(&data[idx], chunk->data, chunk->size); + idx += chunk->size; + chunk = chunk->next; + } + qrdata->size = size; + qrdata->data = data; +} + +QRdata *decodeQr(QRcode *code) +{ +} diff --git a/tests/decoder.h b/tests/decoder.h new file mode 100644 index 0000000000..f8cd81aaaa --- /dev/null +++ b/tests/decoder.h @@ -0,0 +1,30 @@ +#ifndef __DECODER_H__ +#define __DECODER_H__ + +#include "../qrencode.h" + +typedef struct _DataChunk { + QRencodeMode mode; + int size; + unsigned char *data; + struct _DataChunk *next; +} DataChunk; + +typedef struct { + int status; + int size; + unsigned char *data; + int version; + QRecLevel level; + DataChunk *chunks; +} QRdata; + +DataChunk *decodeNum(int bits_length, unsigned char *bits, int version); +DataChunk *decodeAn(int bits_length, unsigned char *bits, int version); +DataChunk *decode8(int bits_length, unsigned char *bits, int version); +DataChunk *decodeKanji(int bits_length, unsigned char *bits, int version); +DataChunk *decodeChunk(int bits_length, unsigned char *bits, int version); +void dumpChunk(DataChunk *chunk); +QRdata *decode(QRcode *code); + +#endif /* __DECODER_H__ */ -- cgit 0.0.5-2-1-g0f52 From 91de681567af11417aa29ca4569cbffd2e7b4d04 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 13:36:13 +0000 Subject: More implementation. --- tests/decoder.c | 233 ++++++++++++++++++++++++++++++++++++-------------------- tests/decoder.h | 13 ++-- 2 files changed, 156 insertions(+), 90 deletions(-) diff --git a/tests/decoder.c b/tests/decoder.c index 60f3c67b75..44f1269e87 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -1,9 +1,10 @@ #include #include #include +#include #include "../qrspec.h" +#include "../bitstream.h" #include "decoder.h" -#include enum { DECODE_OK = 0, @@ -30,44 +31,56 @@ void DataChunk_free(DataChunk *chunk) } } -DataChunk *decodeNum(int bits_length, unsigned char *bits, int version) +static int decodeLength(int *bits_length, unsigned char **bits, QRencodeMode mode, int version) +{ + int i; + int length = 0; + int lbits = QRspec_lengthIndicator(mode, version); + + if(*bits_length < lbits) { + fprintf(stderr, "Bit length is too short: %d\n", *bits_length); + return 0; + } + + length = 0; + for(i=0; isize = size; chunk->data = (unsigned char *)buf; + *bits_length -= sizeInBit; + *bits += sizeInBit; return chunk; } @@ -110,38 +125,29 @@ static const char decodeAnTable[45] = { '+', '-', '.', '/', ':' }; -DataChunk *decodeAn(int bits_length, unsigned char *bits, int version) +static DataChunk *decodeAn(int *bits_length, unsigned char **bits, int version) { int i, j; - int lbits, size, words, remain; + int size, sizeInBit, words, remain; unsigned char *p; char *buf, *q; int val; int ch, cl; DataChunk *chunk; - lbits = QRspec_lengthIndicator(QR_MODE_AN, version); - if(bits_length < lbits) { - fprintf(stderr, "Bit length is too short: %d\n", bits_length); - return NULL; - } - p = bits; - val = 0; - for(i=0; isize = size; chunk->data = (unsigned char *)buf; + *bits_length -= sizeInBit; + *bits += sizeInBit; return chunk; } -DataChunk *decode8(int bits_length, unsigned char *bits, int version) +static DataChunk *decode8(int *bits_length, unsigned char **bits, int version) { int i, j; - int lbits, size; + int size, sizeInBit; unsigned char *p; unsigned char *buf, *q; int val; DataChunk *chunk; - lbits = QRspec_lengthIndicator(QR_MODE_8, version); - if(bits_length < lbits) { - fprintf(stderr, "Bit length is too short: %d\n", bits_length); - return NULL; - } - p = bits; - val = 0; - for(i=0; isize = size; chunk->data = buf; + *bits_length -= sizeInBit; + *bits += sizeInBit; return chunk; } -DataChunk *decodeKanji(int bits_length, unsigned char *bits, int version) +static DataChunk *decodeKanji(int *bits_length, unsigned char **bits, int version) { int i, j; - int lbits, size; + int size, sizeInBit; unsigned char *p; char *buf, *q; int val; int ch, cl; DataChunk *chunk; - lbits = QRspec_lengthIndicator(QR_MODE_KANJI, version); - if(bits_length < lbits) { - fprintf(stderr, "Bit length is too short: %d\n", bits_length); - return NULL; - } - p = bits; - val = 0; - for(i=0; isize = size * 2; chunk->data = (unsigned char *)buf; + *bits_length -= sizeInBit; + *bits += sizeInBit; return chunk; } -DataChunk *decodeChunk(int bits_length, unsigned char *bits, int version) +static DataChunk *decodeChunk(int *bits_length, unsigned char **bits, int version) { int i, val; - if(bits_length < 4) { - fprintf(stderr, "Bit length too short: %d\n", bits_length); + if(*bits_length < 4) { + fprintf(stderr, "Bit length too short: %d, expected 4.\n", *bits_length); return NULL; } val = 0; for(i=0; i<4; i++) { val = val << 1; - val += bits[i]; + val += (*bits)[i]; } - printf("Mode: %d\n", val); - bits_length -= 4; - bits += 4; + *bits_length -= 4; + *bits += 4; switch(val) { + case 0: + return NULL; case 1: return decodeNum(bits_length, bits, version); case 2: @@ -381,7 +376,7 @@ void dumpKanji(DataChunk *chunk) free(outbuf); } -void dumpChunk(DataChunk *chunk) +static void dumpChunk(DataChunk *chunk) { switch(chunk->mode) { case QR_MODE_NUM: @@ -418,7 +413,7 @@ void dumpChunks(QRdata *qrdata) } } -void concatChunks(QRdata *qrdata) +void QRdata_concatChunks(QRdata *qrdata) { int idx; unsigned char *data; @@ -447,6 +442,78 @@ void concatChunks(QRdata *qrdata) qrdata->data = data; } +int appendChunk(QRdata *qrdata, int *bits_length, unsigned char **bits) +{ + DataChunk *chunk; + + chunk = decodeChunk(bits_length, bits, qrdata->version); + if(chunk == NULL) { + if(*bits_length == 0) { + return 1; + } else { + return -1; + } + } + + if(qrdata->last == NULL) { + qrdata->chunks = chunk; + } else { + qrdata->last->next = chunk; + } + qrdata->last = chunk; + + return 0; +} + +QRdata *QRdata_new(void) +{ + QRdata *qrdata; + + qrdata = (QRdata *)calloc(sizeof(QRdata), 1); + if(qrdata == NULL) return NULL; + + return qrdata; +} + +void QRdata_free(QRdata *qrdata) +{ + DataChunk *chunk, *next; + + chunk = qrdata->chunks; + while(chunk != NULL) { + next = chunk->next; + DataChunk_free(chunk); + chunk = next; + } + + if(qrdata->data != NULL) { + free(qrdata->data); + } + free(qrdata); +} + +static void QRdata_decodeBits(QRdata *qrdata, int length, unsigned char *bits) +{ + int ret = 0; + + while(ret == 0) { + ret = appendChunk(qrdata, &length, &bits); + } +} + +void QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream) +{ + QRdata_decodeBits(qrdata, bstream->length, bstream->data); +} + +void QRdata_dump(QRdata *data) +{ + dumpChunks(data); +} + QRdata *decodeQr(QRcode *code) { + QRdata *qrdata; + + qrdata = QRdata_new(); } diff --git a/tests/decoder.h b/tests/decoder.h index f8cd81aaaa..253535f0ad 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -6,6 +6,7 @@ typedef struct _DataChunk { QRencodeMode mode; int size; + int bits; unsigned char *data; struct _DataChunk *next; } DataChunk; @@ -16,15 +17,13 @@ typedef struct { unsigned char *data; int version; QRecLevel level; - DataChunk *chunks; + DataChunk *chunks, *last; } QRdata; -DataChunk *decodeNum(int bits_length, unsigned char *bits, int version); -DataChunk *decodeAn(int bits_length, unsigned char *bits, int version); -DataChunk *decode8(int bits_length, unsigned char *bits, int version); -DataChunk *decodeKanji(int bits_length, unsigned char *bits, int version); -DataChunk *decodeChunk(int bits_length, unsigned char *bits, int version); -void dumpChunk(DataChunk *chunk); +QRdata *QRdata_new(void); +void QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream); +void QRdata_dump(QRdata *data); +void QRdata_free(QRdata *data); QRdata *decode(QRcode *code); #endif /* __DECODER_H__ */ -- cgit 0.0.5-2-1-g0f52 From 576e1cb22f307f6269e95d2f256f51540c2a209e Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 14:48:57 +0000 Subject: Bug fixed. --- tests/test_qrinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index f37d9b2094..cc42d7f1a0 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -704,7 +704,7 @@ void test_splitentry3(void) e01 = e00->next; list = list->next; e10 = list->input->head; - e11 = e00->next; + e11 = e10->next; assert_equal(e00->mode, QR_MODE_STRUCTURE, "Structure header is missing?"); assert_equal(e01->mode, QR_MODE_8, "no data?!"); -- cgit 0.0.5-2-1-g0f52 From dccbb71bce10f1ea32a25033fb25b6a442ef264b Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 19:30:32 +0000 Subject: Code cleanup. --- tests/test_monkey.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 35ec0ba55e..c708eb8298 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -27,11 +27,9 @@ int fill8bitData(void) return len; } -void test_split_an(int num) +int fillANData(void) { - QRinput *input; - QRinput_List *list; - int len, i, ret; + int len, i; len = 1 + (int)drand((MAX_LENGTH - 2)); for(i=0; i Date: Mon, 18 Jan 2010 19:30:45 +0000 Subject: More tests with decoding function. --- tests/Makefile.am | 2 +- tests/decoder.c | 246 +++++++++++++++++++++++++++++++++++++++++++++++++- tests/decoder.h | 7 +- tests/test_qrencode.c | 39 ++++++++ tests/test_qrinput.c | 1 + tests/test_qrspec.c | 21 +++++ 6 files changed, 313 insertions(+), 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a05bfc7b6e..cb28fddc10 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,7 +23,7 @@ test_estimatebit_SOURCES = test_estimatebit.c test_estimatebit_LDADD = ../libqrencode.la test_qrspec_SOURCES = test_qrspec.c -test_qrspec_LDADD = ../libqrencode.la +test_qrspec_LDADD = ../libqrencode.la decoder.o test_mqrspec_SOURCES = test_mqrspec.c test_mqrspec_LDADD = ../libqrencode.la diff --git a/tests/decoder.c b/tests/decoder.c index 44f1269e87..54c13fa386 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -4,6 +4,7 @@ #include #include "../qrspec.h" #include "../bitstream.h" +#include "../mask.h" #include "decoder.h" enum { @@ -511,9 +512,252 @@ void QRdata_dump(QRdata *data) dumpChunks(data); } -QRdata *decodeQr(QRcode *code) +unsigned int QRcode_decodeVersion(QRcode *code) { + unsigned int v1, v2; + int x, y, width; + unsigned char *p; + + width = code->width; + if(width < 45) { + return (width - 21)/ 4 + 1; + } + + v1 = 0; + p = code->data + width * (width - 9) + 5; + for(x=0; x<6; x++) { + for(y=0; y<3; y++) { + v1 = v1 << 1; + v1 |= *(p - y * width - x) & 1; + } + } + + v2 = 0; + p = code->data + width * 5 + width - 9; + for(y=0; y<6; y++) { + for(x=0; x<3; x++) { + v2 = v2 << 1; + v2 |= *(p - y * width - x) & 1; + } + } + + if(v1 != v2) { + fprintf(stderr, "Two verion patterns are different.\n"); + return -1; + } + + return v1 >> 12; +} + +int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask) +{ + unsigned int v1, v2; + int i, width; + unsigned char *p; + + width = code->width; + + v1 = 0; + p = code->data + width * 8; + for(i=0; i<8; i++) { + v1 = v1 << 1; + if(i < 6) { + v1 |= *(p + i) & 1; + } else { + v1 |= *(p + i + 1) & 1; + } + } + p = code->data + width * 7 + 8; + for(i=0; i<7; i++) { + v1 = v1 << 1; + if(i < 1) { + v1 |= *(p - width * i) & 1; + } else { + v1 |= *(p - width * (i + 1)) & 1; + } + } + + v2 = 0; + p = code->data + width * (width - 1) + 8; + for(i=0; i<7; i++) { + v2 = v2 << 1; + v2 |= *(p - width * i) & 1; + } + p = code->data + width * 8 + width - 8; + for(i=0; i<8; i++) { + v2 = v2 << 1; + v2 |= *(p + i) & 1; + } + + if(v1 != v2) { + fprintf(stderr, "Two format infos are different.\n"); + return -1; + } + v1 = (v1 ^ 0x5412) >> 10; + *mask = v1 & 7; + switch((v1 >> 3) & 3) { + case 1: + *level = QR_ECLEVEL_L; + break; + case 0: + *level = QR_ECLEVEL_M; + break; + case 3: + *level = QR_ECLEVEL_Q; + break; + case 2: + *level = QR_ECLEVEL_H; + break; + default: + break; + } + + return 0; +} + +unsigned char *QRcode_unmask(QRcode *code) +{ + unsigned char *unmasked; + int mask; + QRecLevel level; + int ret; + + ret = QRcode_decodeFormat(code, &level, &mask); + if(ret < 0) return NULL; + unmasked = Mask_makeMask(code->width, code->data, mask, level); + + return unmasked; +} + +typedef struct { + int width; + unsigned char *frame; + int x, y; + int dir; + int bit; + int mqr; +} FrameFiller; + +static FrameFiller *FrameFiller_new(int width, unsigned char *frame, int mqr) +{ + FrameFiller *filler; + + filler = (FrameFiller *)malloc(sizeof(FrameFiller)); + if(filler == NULL) return NULL; + filler->width = width; + filler->frame = frame; + filler->x = width - 1; + filler->y = width - 1; + filler->dir = -1; + filler->bit = -1; + filler->mqr = mqr; + + return filler; +} + +static unsigned char *FrameFiller_next(FrameFiller *filler) +{ + unsigned char *p; + int x, y, w; + + if(filler->bit == -1) { + filler->bit = 0; + return filler->frame + filler->y * filler->width + filler->x; + } + + x = filler->x; + y = filler->y; + p = filler->frame; + w = filler->width; + + if(filler->bit == 0) { + x--; + filler->bit++; + } else { + x++; + y += filler->dir; + filler->bit--; + } + + if(filler->dir < 0) { + if(y < 0) { + y = 0; + x -= 2; + filler->dir = 1; + if(!filler->mqr && x == 6) { + x--; + y = 9; + } + } + } else { + if(y == w) { + y = w - 1; + x -= 2; + filler->dir = -1; + if(!filler->mqr && x == 6) { + x--; + y -= 8; + } + } + } + if(x < 0 || y < 0) return NULL; + + filler->x = x; + filler->y = y; + + if(p[y * w + x] & 0x80) { + // This tail recursion could be optimized. + return FrameFiller_next(filler); + } + return &p[y * w + x]; +} + +unsigned char *QRcode_decodeBits(QRcode *code, int *length) +{ + unsigned char *unmasked, *p, *bits; + FrameFiller *filler; + int spec[5]; + int ret, i, version, mask; + QRecLevel level; + + version = QRcode_decodeVersion(code); + if(version < 1) return NULL; + ret = QRcode_decodeFormat(code, &level, &mask); + if(ret < 0) return NULL; + + QRspec_getEccSpec(version, level, spec); + *length = QRspec_rsDataLength(spec) * 8; + bits = (unsigned char*)malloc(*length); + + unmasked = QRcode_unmask(code); + if(unmasked == NULL) return NULL; + + filler = FrameFiller_new(code->width, unmasked, 0); + for(i=0; i<*length; i++) { + p = FrameFiller_next(filler); + bits[i] = *p & 1; + } + + free(filler); + free(unmasked); + + return bits; +} + +QRdata *QRcode_decode(QRcode *code) +{ + unsigned char *bits; QRdata *qrdata; + int length; + bits = QRcode_decodeBits(code, &length); + if(bits == NULL) return NULL; qrdata = QRdata_new(); + QRdata_decodeBits(qrdata, length, bits); + QRdata_concatChunks(qrdata); + + free(bits); + + return qrdata; } + diff --git a/tests/decoder.h b/tests/decoder.h index 253535f0ad..63bb1204d0 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -24,6 +24,11 @@ QRdata *QRdata_new(void); void QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream); void QRdata_dump(QRdata *data); void QRdata_free(QRdata *data); -QRdata *decode(QRcode *code); +QRdata *QRcode_decode(QRcode *code); + +unsigned int QRcode_decodeVersion(QRcode *code); +int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask); +unsigned char *QRcode_unmask(QRcode *code); +unsigned char *QRcode_decodeCodeword(QRcode *code); #endif /* __DECODER_H__ */ diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index a9552e995f..5282e14b25 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -8,6 +8,7 @@ #include "../qrinput.h" #include "../mask.h" #include "../rscode.h" +#include "decoder.h" int inputSize(QRinput *input) { @@ -665,6 +666,42 @@ void test_encodeData(void) testFinish(); } +void test_formatInfo(void) +{ + QRcode *qrcode; + QRecLevel level; + int mask; + int ret; + + testStart("Test format info in QR code."); + qrcode = QRcode_encodeString("AC-42", 1, QR_ECLEVEL_H, QR_MODE_8, 1); + ret = QRcode_decodeFormat(qrcode, &level, &mask); + assert_equal(level, QR_ECLEVEL_H, "Decoded format is wrong.\n"); + + if(qrcode != NULL) QRcode_free(qrcode); + + testFinish(); +} + +void test_decodeSimple(void) +{ + char *str = "AC-42"; + QRcode *qrcode; + QRdata *qrdata; + + testStart("Test code words."); + qrcode = QRcode_encodeString(str, 1, QR_ECLEVEL_H, QR_MODE_8, 1); + qrdata = QRcode_decode(qrcode); + + assert_nonnull(qrdata, "Failed to decode.\n"); + if(qrdata != NULL) { + assert_zero(strncmp(str, (char *)(qrdata->data), strlen(str)), "Decoded data %s is different from the original %s\n", qrdata->data, str); + } + if(qrdata != NULL) QRdata_free(qrdata); + if(qrcode != NULL) QRcode_free(qrcode); + + testFinish(); +} int main(void) @@ -694,6 +731,8 @@ int main(void) test_encodeTooLongMQR(); test_mqrraw_new(); test_encodeData(); + test_formatInfo(); + test_decodeSimple(); QRcode_clearCache(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index cc42d7f1a0..8d01a712a9 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -5,6 +5,7 @@ #include "../qrinput.h" #include "../qrencode_inner.h" #include "../split.h" +#include "decoder.h" int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mode, char *data, char *correct) { diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 67fce13598..8133c4a681 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -2,6 +2,8 @@ #include #include "common.h" #include "../qrspec.h" +#include "../qrencode_inner.h" +#include "decoder.h" void print_eccTable(void) { @@ -300,6 +302,24 @@ void test_format(void) testEnd(err); } +void test_allframe(void) +{ + unsigned int version; + int i, width; + unsigned char *frame; + QRcode *qrcode; + + testStart("All empty frame check"); + for(i=1; i<= QRSPEC_VERSION_MAX; i++) { + width = QRspec_getWidth(i); + frame = QRspec_newFrame(i); + qrcode = QRcode_new(i, width, frame); + version = QRcode_decodeVersion(qrcode); + assert_equal(version, i, "Decoded version number is wrong: %d, expected %d.\n", version, i); + QRcode_free(qrcode); + } +} + int main(void) { test_eccTable(); @@ -311,6 +331,7 @@ int main(void) test_verpat(); //print_newFrame(); test_format(); + test_allframe(); QRspec_clearCache(); -- cgit 0.0.5-2-1-g0f52 From b3e7123eb926c0c50954e3dce24c2ca8582fe548 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 19:31:04 +0000 Subject: Code cleanups. --- qrspec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrspec.c b/qrspec.c index aa89a4560f..75afaacd2e 100644 --- a/qrspec.c +++ b/qrspec.c @@ -366,7 +366,7 @@ unsigned int QRspec_getVersionPattern(int version) { if(version < 7 || version > QRSPEC_VERSION_MAX) return 0; - return versionPattern[version -7]; + return versionPattern[version - 7]; } /****************************************************************************** -- cgit 0.0.5-2-1-g0f52 From 3a287d88a9ac1493b521003b854b2eeef1483614 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 19:32:12 +0000 Subject: QRcode_new() is now open for testers. --- qrencode.c | 4 +--- qrencode_inner.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/qrencode.c b/qrencode.c index 9ea37a0cd5..433e6eecc3 100644 --- a/qrencode.c +++ b/qrencode.c @@ -399,9 +399,7 @@ extern unsigned char *FrameFiller_test(int version) free(filler); return frame; } -#endif -#ifdef WITH_TESTS extern unsigned char *FrameFiller_testMQR(int version) { int width; @@ -438,7 +436,7 @@ extern unsigned char *FrameFiller_testMQR(int version) * QR-code encoding *****************************************************************************/ -static QRcode *QRcode_new(int version, int width, unsigned char *data) +__STATIC QRcode *QRcode_new(int version, int width, unsigned char *data) { QRcode *qrcode; diff --git a/qrencode_inner.h b/qrencode_inner.h index d7b491b7d2..724f8c4ae2 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -83,5 +83,6 @@ extern unsigned char *FrameFiller_testMQR(int version); *****************************************************************************/ extern QRcode *QRcode_encodeMask(QRinput *input, int mask); extern QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask); +extern QRcode *QRcode_new(int version, int width, unsigned char *data); #endif /* __QRENCODE_INNER_H__ */ -- cgit 0.0.5-2-1-g0f52 From 2b2a58a1fca9230a28177f4b7b7d0156de9e672e Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 18 Jan 2010 19:32:57 +0000 Subject: --- ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index e2664e2974..02f2088a8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2010.01.18 Kentaro FUKUCHI + * configure.ac: + - Configuration cleanups. + * tests/Makefile.am: + - Wrong conditional branch fixed. + * tests/decoder.[ch], tests/Makefile.am: + - Decoding function has been added. + * tests/test_{qrinput,qrspec,qrencode}.c: + - New tests added. + +2010.01.16 Kentaro FUKUCHI + * qrencode.[ch]: + - QRcode_encodeData{,MQR,Structured}() have been added. + * tests/test_qrencode.c: + - New test has been added. + 2009.11.27 Kentaro FUKUCHI * qrencode.h: - Typo fixes. -- cgit 0.0.5-2-1-g0f52 From 3f5992d54a6542c2bce2090ece94463083335307 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 07:17:32 +0000 Subject: Slightly optimized. --- tests/decoder.c | 9 ++------- tests/decoder.h | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/decoder.c b/tests/decoder.c index 54c13fa386..a94a5e164a 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -615,15 +615,10 @@ int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask) return 0; } -unsigned char *QRcode_unmask(QRcode *code) +unsigned char *QRcode_unmask(QRcode *code, QRecLevel level, int mask) { unsigned char *unmasked; - int mask; - QRecLevel level; - int ret; - ret = QRcode_decodeFormat(code, &level, &mask); - if(ret < 0) return NULL; unmasked = Mask_makeMask(code->width, code->data, mask, level); return unmasked; @@ -729,7 +724,7 @@ unsigned char *QRcode_decodeBits(QRcode *code, int *length) *length = QRspec_rsDataLength(spec) * 8; bits = (unsigned char*)malloc(*length); - unmasked = QRcode_unmask(code); + unmasked = QRcode_unmask(code, level, mask); if(unmasked == NULL) return NULL; filler = FrameFiller_new(code->width, unmasked, 0); diff --git a/tests/decoder.h b/tests/decoder.h index 63bb1204d0..64b3e4d43a 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -28,7 +28,7 @@ QRdata *QRcode_decode(QRcode *code); unsigned int QRcode_decodeVersion(QRcode *code); int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask); -unsigned char *QRcode_unmask(QRcode *code); +unsigned char *QRcode_unmask(QRcode *code, QRecLevel, int mask); unsigned char *QRcode_decodeCodeword(QRcode *code); #endif /* __DECODER_H__ */ -- cgit 0.0.5-2-1-g0f52 From 02693a7d820db89e64a239d36bb80f2b72c28bcd Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 07:17:44 +0000 Subject: Added new test. --- tests/test_qrencode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 5282e14b25..e5884ceccb 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -695,7 +695,8 @@ void test_decodeSimple(void) assert_nonnull(qrdata, "Failed to decode.\n"); if(qrdata != NULL) { - assert_zero(strncmp(str, (char *)(qrdata->data), strlen(str)), "Decoded data %s is different from the original %s\n", qrdata->data, str); + assert_equal(strlen(str), qrdata->size, "Lengths of input/output mismatched.\n"); + assert_zero(strncmp(str, (char *)(qrdata->data), qrdata->size), "Decoded data %s is different from the original %s\n", qrdata->data, str); } if(qrdata != NULL) QRdata_free(qrdata); if(qrcode != NULL) QRcode_free(qrcode); -- cgit 0.0.5-2-1-g0f52 From eb55ef204832611f453f69a9067e97ef6bc02c9a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 16:54:27 +0000 Subject: Bug fixes. --- tests/decoder.c | 71 +++++++++++++++++++++++++++++++++++++++------------------ tests/decoder.h | 2 +- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/tests/decoder.c b/tests/decoder.c index a94a5e164a..07af79b5f3 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -65,6 +65,7 @@ static DataChunk *decodeNum(int *bits_length, unsigned char **bits, int version) DataChunk *chunk; size = decodeLength(bits_length, bits, QR_MODE_NUM, version); + printf("Num ver=%d, size=%d\n", version, size); if(size < 0) return NULL; words = size / 3; @@ -108,6 +109,7 @@ static DataChunk *decodeNum(int *bits_length, unsigned char **bits, int version) } sprintf(q, "%1d", val); } + buf[size] = '\0'; chunk = DataChunk_new(QR_MODE_NUM); chunk->size = size; @@ -431,7 +433,7 @@ void QRdata_concatChunks(QRdata *qrdata) return; } - data = malloc(size); + data = malloc(size + 1); chunk = qrdata->chunks; idx = 0; while(chunk != NULL) { @@ -439,6 +441,7 @@ void QRdata_concatChunks(QRdata *qrdata) idx += chunk->size; chunk = chunk->next; } + data[size] = '\0'; qrdata->size = size; qrdata->data = data; } @@ -707,13 +710,44 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) return &p[y * w + x]; } -unsigned char *QRcode_decodeBits(QRcode *code, int *length) +unsigned char *QRcode_extractBits(int width, unsigned char *frame, int spec[5]) { - unsigned char *unmasked, *p, *bits; + unsigned char *bits, *p, *q; FrameFiller *filler; + int i, j; + int col, row, d1, b1, blocks, idx, words; + + blocks = QRspec_rsBlockNum(spec); + words = QRspec_rsDataLength(spec); + d1 = QRspec_rsDataCodes1(spec); + b1 = QRspec_rsBlockNum1(spec); + bits = (unsigned char *)calloc(words * 8, 1); + + row = col = 0; + filler = FrameFiller_new(width, frame, 0); + for(i=0; i=d1)?b1:0); + idx = d1 * row + col + ((row > b1)?(row-b1):0); + q = bits + idx * 8; + for(j=0; j<8; j++) { + p = FrameFiller_next(filler); + q[j] = *p & 1; + } + } + free(filler); + + return bits; +} + +QRdata *QRcode_decodeBits(QRcode *code) +{ + unsigned char *unmasked, *bits; int spec[5]; - int ret, i, version, mask; + int ret, version, mask; + int length; QRecLevel level; + QRdata *qrdata; version = QRcode_decodeVersion(code); if(version < 1) return NULL; @@ -721,38 +755,31 @@ unsigned char *QRcode_decodeBits(QRcode *code, int *length) if(ret < 0) return NULL; QRspec_getEccSpec(version, level, spec); - *length = QRspec_rsDataLength(spec) * 8; - bits = (unsigned char*)malloc(*length); + length = QRspec_rsDataLength(spec) * 8; unmasked = QRcode_unmask(code, level, mask); if(unmasked == NULL) return NULL; - filler = FrameFiller_new(code->width, unmasked, 0); - for(i=0; i<*length; i++) { - p = FrameFiller_next(filler); - bits[i] = *p & 1; - } - - free(filler); + bits = QRcode_extractBits(code->width, unmasked, spec); free(unmasked); - return bits; + qrdata = QRdata_new(); + qrdata->version = version; + qrdata->level = level; + QRdata_decodeBits(qrdata, length, bits); + + free(bits); + + return qrdata; } QRdata *QRcode_decode(QRcode *code) { - unsigned char *bits; QRdata *qrdata; - int length; - bits = QRcode_decodeBits(code, &length); - if(bits == NULL) return NULL; - qrdata = QRdata_new(); - QRdata_decodeBits(qrdata, length, bits); + qrdata = QRcode_decodeBits(code); QRdata_concatChunks(qrdata); - free(bits); - return qrdata; } diff --git a/tests/decoder.h b/tests/decoder.h index 64b3e4d43a..21570f15e9 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -28,7 +28,7 @@ QRdata *QRcode_decode(QRcode *code); unsigned int QRcode_decodeVersion(QRcode *code); int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask); -unsigned char *QRcode_unmask(QRcode *code, QRecLevel, int mask); +unsigned char *QRcode_unmask(QRcode *code, QRecLevel level, int mask); unsigned char *QRcode_decodeCodeword(QRcode *code); #endif /* __DECODER_H__ */ -- cgit 0.0.5-2-1-g0f52 From b03939759587c4f001d9b000a6ceeb71cd715a1b Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 16:54:41 +0000 Subject: Added new test. --- tests/test_mask.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_mask.c b/tests/test_mask.c index 81cd115061..d7e1c18908 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -3,6 +3,7 @@ #include "common.h" #include "../mask.h" #include "../qrspec.h" +#include "decoder.h" char dot[2] = {'_', '#'}; static char *maskPatterns[8] = { @@ -236,6 +237,34 @@ void test_eval3(void) free(frame); } +void test_format(void) +{ + unsigned char *frame, *masked; + int version, mask, width, dmask; + QRecLevel level, dlevel; + QRcode *code; + int ret; + + testStart("Checking format info."); + for(version=1; version<=QRSPEC_VERSION_MAX; version++) { + frame = QRspec_newFrame(version); + width = QRspec_getWidth(version); + for(level=0; level<4; level++) { + for(mask=0; mask<8; mask++) { + masked = Mask_makeMask(width, frame, mask, level); + code = QRcode_new(version, width, masked); + ret = QRcode_decodeFormat(code, &dlevel, &dmask); + assert_zero(ret, "Something wrong in format info.\n"); + assert_equal(dlevel, level, "Decoded level is wrong: %d, expected %d", dlevel, level); + assert_equal(dmask, mask, "Decoded mask is wrong: %d, expected %d", dlevel, level); + QRcode_free(code); + } + } + free(frame); + } + testFinish(); +} + int main(void) { //print_masks(); @@ -243,6 +272,7 @@ int main(void) test_eval(); test_eval2(); test_eval3(); + test_format(); report(); -- cgit 0.0.5-2-1-g0f52 From 83597a89f5c5014d793d69cf72529f2da7830a7a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 16:54:53 +0000 Subject: Added new tests. --- tests/Makefile.am | 2 +- tests/test_qrencode.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index cb28fddc10..70fdbe95c6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -41,7 +41,7 @@ test_monkey_SOURCES = test_monkey.c test_monkey_LDADD = ../libqrencode.la test_mask_SOURCES = test_mask.c -test_mask_LDADD = ../libqrencode.la +test_mask_LDADD = ../libqrencode.la decoder.o test_mmask_SOURCES = test_mmask.c test_mmask_LDADD = ../libqrencode.la diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index e5884ceccb..76e1d11d0d 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -8,6 +8,7 @@ #include "../qrinput.h" #include "../mask.h" #include "../rscode.h" +#include "../split.h" #include "decoder.h" int inputSize(QRinput *input) @@ -693,6 +694,38 @@ void test_decodeSimple(void) qrcode = QRcode_encodeString(str, 1, QR_ECLEVEL_H, QR_MODE_8, 1); qrdata = QRcode_decode(qrcode); + assert_nonnull(qrdata, "Failed to decode.\n"); + if(qrdata != NULL) { + assert_equal(strlen(str), qrdata->size, "Lengths of input/output mismatched: %d, expected %d.\n", qrdata->size, (int)strlen(str)); + assert_zero(strncmp(str, (char *)(qrdata->data), qrdata->size), "Decoded data %s is different from the original %s\n", qrdata->data, str); + } + if(qrdata != NULL) QRdata_free(qrdata); + if(qrcode != NULL) QRcode_free(qrcode); + + testFinish(); +} + + +void test_decodeLong(void) +{ + char *str = "12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ?????????????"; + QRcode *qrcode; + QRdata *qrdata; + QRecLevel level; + int mask, version; + QRinput *input; + BitStream *bstream; + + testStart("Test code words (long, splitted)."); + input = QRinput_new2(0, QR_ECLEVEL_H); + Split_splitStringToQRinput(str, input, QR_MODE_8, 1); + bstream = QRinput_mergeBitStream(input); + qrcode = QRcode_encodeString(str, 0, QR_ECLEVEL_H, QR_MODE_8, 1); + qrdata = QRcode_decode(qrcode); + + version = QRcode_decodeVersion(qrcode); + QRcode_decodeFormat(qrcode, &level, &mask); + assert_nonnull(qrdata, "Failed to decode.\n"); if(qrdata != NULL) { assert_equal(strlen(str), qrdata->size, "Lengths of input/output mismatched.\n"); @@ -734,6 +767,7 @@ int main(void) test_encodeData(); test_formatInfo(); test_decodeSimple(); + test_decodeLong(); QRcode_clearCache(); -- cgit 0.0.5-2-1-g0f52 From b783499302db25055eb3ca5e4da23b05928ec70a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 16:57:50 +0000 Subject: Frees unused objects correctly. --- tests/test_qrencode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 76e1d11d0d..4ad41766f3 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -714,12 +714,10 @@ void test_decodeLong(void) QRecLevel level; int mask, version; QRinput *input; - BitStream *bstream; testStart("Test code words (long, splitted)."); input = QRinput_new2(0, QR_ECLEVEL_H); Split_splitStringToQRinput(str, input, QR_MODE_8, 1); - bstream = QRinput_mergeBitStream(input); qrcode = QRcode_encodeString(str, 0, QR_ECLEVEL_H, QR_MODE_8, 1); qrdata = QRcode_decode(qrcode); @@ -733,6 +731,7 @@ void test_decodeLong(void) } if(qrdata != NULL) QRdata_free(qrdata); if(qrcode != NULL) QRcode_free(qrcode); + QRinput_free(input); testFinish(); } -- cgit 0.0.5-2-1-g0f52 From 38f4ab1c4fb7ebd069c94078c3fadd460c652dc7 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 19:58:11 +0000 Subject: Bug fix. --- qrencode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qrencode.c b/qrencode.c index 433e6eecc3..4c0816e10a 100644 --- a/qrencode.c +++ b/qrencode.c @@ -165,7 +165,7 @@ __STATIC unsigned char QRraw_getCode(QRRawCode *raw) if(raw->count < raw->dataLength) { row = raw->count % raw->blocks; col = raw->count / raw->blocks; - if(col >= raw->rsblock[row].dataLength) { + if(col >= raw->rsblock[0].dataLength) { row += raw->b1; } ret = raw->rsblock[row].data[col]; @@ -519,7 +519,10 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) } /* masking */ - if(mask < 0) { + if(mask == -2) { // just for debug purpose + masked = (unsigned char *)malloc(width * width); + memcpy(masked, frame, width * width); + } else if(mask < 0) { masked = Mask_mask(width, frame, input->level); } else { masked = Mask_makeMask(width, frame, mask, input->level); -- cgit 0.0.5-2-1-g0f52 From fcfaa2d51f50b191fc51f7bd1b81d83f48aeeb78 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 20:04:28 +0000 Subject: New tests. --- tests/Makefile.am | 2 +- tests/decoder.c | 63 ++++++++++++++++++----- tests/decoder.h | 8 +-- tests/test_monkey.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test_qrencode.c | 46 ++++++++++++++--- 5 files changed, 230 insertions(+), 26 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 70fdbe95c6..c5379036a7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -38,7 +38,7 @@ test_split_SOURCES = test_split.c test_split_LDADD = ../libqrencode.la test_monkey_SOURCES = test_monkey.c -test_monkey_LDADD = ../libqrencode.la +test_monkey_LDADD = ../libqrencode.la decoder.o test_mask_SOURCES = test_mask.c test_mask_LDADD = ../libqrencode.la decoder.o diff --git a/tests/decoder.c b/tests/decoder.c index 07af79b5f3..a2db488643 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -7,11 +7,6 @@ #include "../mask.h" #include "decoder.h" -enum { - DECODE_OK = 0, - DECODE_INVALID = 1, -}; - DataChunk *DataChunk_new(QRencodeMode mode) { DataChunk *chunk; @@ -65,7 +60,6 @@ static DataChunk *decodeNum(int *bits_length, unsigned char **bits, int version) DataChunk *chunk; size = decodeLength(bits_length, bits, QR_MODE_NUM, version); - printf("Num ver=%d, size=%d\n", version, size); if(size < 0) return NULL; words = size / 3; @@ -429,7 +423,6 @@ void QRdata_concatChunks(QRdata *qrdata) chunk = chunk->next; } if(size <= 0) { - qrdata->status = DECODE_INVALID; return; } @@ -618,7 +611,7 @@ int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask) return 0; } -unsigned char *QRcode_unmask(QRcode *code, QRecLevel level, int mask) +static unsigned char *unmask(QRcode *code, QRecLevel level, int mask) { unsigned char *unmasked; @@ -627,6 +620,19 @@ unsigned char *QRcode_unmask(QRcode *code, QRecLevel level, int mask) return unmasked; } +unsigned char *QRcode_unmask(QRcode *code) +{ + int ret, version, mask; + QRecLevel level; + + version = QRcode_decodeVersion(code); + if(version < 1) return NULL; + ret = QRcode_decodeFormat(code, &level, &mask); + if(ret < 0) return NULL; + + return unmask(code, level, mask); +} + typedef struct { int width; unsigned char *frame; @@ -710,7 +716,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) return &p[y * w + x]; } -unsigned char *QRcode_extractBits(int width, unsigned char *frame, int spec[5]) +static unsigned char *extractBits(int width, unsigned char *frame, int spec[5]) { unsigned char *bits, *p, *q; FrameFiller *filler; @@ -721,13 +727,20 @@ unsigned char *QRcode_extractBits(int width, unsigned char *frame, int spec[5]) words = QRspec_rsDataLength(spec); d1 = QRspec_rsDataCodes1(spec); b1 = QRspec_rsBlockNum1(spec); - bits = (unsigned char *)calloc(words * 8, 1); + bits = (unsigned char *)malloc(words * 8); + /* + * 00 01 02 03 04 05 06 07 08 09 + * 10 11 12 13 14 15 16 17 18 19 + * 20 21 22 23 24 25 26 27 28 29 30 + * 31 32 33 34 35 36 37 38 39 40 41 + * 42 43 44 45 46 47 48 49 50 51 52 + */ row = col = 0; filler = FrameFiller_new(width, frame, 0); for(i=0; i=d1)?b1:0); + row = i % blocks + ((col >= d1)?b1:0); idx = d1 * row + col + ((row > b1)?(row-b1):0); q = bits + idx * 8; for(j=0; j<8; j++) { @@ -740,6 +753,30 @@ unsigned char *QRcode_extractBits(int width, unsigned char *frame, int spec[5]) return bits; } +unsigned char *QRcode_extractBits(QRcode *code, int *length) +{ + unsigned char *unmasked, *bits; + int spec[5]; + int ret, version, mask; + QRecLevel level; + + version = QRcode_decodeVersion(code); + if(version < 1) return NULL; + ret = QRcode_decodeFormat(code, &level, &mask); + if(ret < 0) return NULL; + + QRspec_getEccSpec(version, level, spec); + *length = QRspec_rsDataLength(spec) * 8; + + unmasked = unmask(code, level, mask); + if(unmasked == NULL) return NULL; + + bits = extractBits(code->width, unmasked, spec); + free(unmasked); + + return bits; +} + QRdata *QRcode_decodeBits(QRcode *code) { unsigned char *unmasked, *bits; @@ -757,10 +794,10 @@ QRdata *QRcode_decodeBits(QRcode *code) QRspec_getEccSpec(version, level, spec); length = QRspec_rsDataLength(spec) * 8; - unmasked = QRcode_unmask(code, level, mask); + unmasked = unmask(code, level, mask); if(unmasked == NULL) return NULL; - bits = QRcode_extractBits(code->width, unmasked, spec); + bits = extractBits(code->width, unmasked, spec); free(unmasked); qrdata = QRdata_new(); diff --git a/tests/decoder.h b/tests/decoder.h index 21570f15e9..29e2aa3933 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -12,7 +12,6 @@ typedef struct _DataChunk { } DataChunk; typedef struct { - int status; int size; unsigned char *data; int version; @@ -24,11 +23,12 @@ QRdata *QRdata_new(void); void QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream); void QRdata_dump(QRdata *data); void QRdata_free(QRdata *data); -QRdata *QRcode_decode(QRcode *code); unsigned int QRcode_decodeVersion(QRcode *code); int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask); -unsigned char *QRcode_unmask(QRcode *code, QRecLevel level, int mask); -unsigned char *QRcode_decodeCodeword(QRcode *code); +unsigned char *QRcode_unmask(QRcode *code); +unsigned char *QRcode_extractBits(QRcode *code, int *length); +QRdata *QRcode_decodeBits(QRcode *code); +QRdata *QRcode_decode(QRcode *code); #endif /* __DECODER_H__ */ diff --git a/tests/test_monkey.c b/tests/test_monkey.c index c708eb8298..b48b37715c 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -5,6 +5,7 @@ #include "../qrinput.h" #include "../split.h" #include "../qrspec.h" +#include "decoder.h" #define MAX_LENGTH 7091 static char data[MAX_LENGTH]; @@ -40,6 +41,141 @@ int fillANData(void) return len; } +void test_encode_an(int num) +{ + int ret; + int len; + len = fillANData(); + QRcode *qrcode; + QRdata *qrdata; + FILE *fp; + char buf[256]; + + qrcode = QRcode_encodeString(data, 0, num % 4, QR_MODE_8, num % 2); + if(qrcode == NULL) { + if(errno == ERANGE) return; + perror("test_encode_an aborted at QRcode_encodeString():"); + printf("Length: %d\n", len); + printf("Level: %d\n", num % 4); + return; + } + qrdata = QRcode_decode(qrcode); + if(qrdata == NULL) { + printf("#%d: Failed to decode this code.\n", num); + QRcode_free(qrcode); + return; + } + if(qrdata->size != len) { + printf("#%d: length mismatched (orig: %d, decoded: %d)\n", num, len, qrdata->size); + } + ret = memcmp(qrdata->data, data, len); + if(ret != 0) { + unsigned char *frame, *p; + int x,y, c; + QRinput *input; + QRcode *origcode; + BitStream *bstream; + int spec[5]; + + printf("#%d: data mismatched.\n", num); + printf("Version: %d\n", qrcode->version); + QRspec_getEccSpec(qrcode->version, num%4, spec); + printf("DataLength: %d\n", QRspec_rsDataLength(spec)); + printf("BlockNum1: %d\n", QRspec_rsBlockNum1(spec)); + printf("BlockNum: %d\n", QRspec_rsBlockNum(spec)); + printf("DataCodes1: %d\n", QRspec_rsDataCodes1(spec)); + + snprintf(buf, 256, "monkey-orig-%d.dat", num); + fp = fopen(buf, "w"); + fputs(data, fp); + fclose(fp); + + snprintf(buf, 256, "monkey-result-%d.dat", num); + fp = fopen(buf, "w"); + fputs((char *)qrdata->data, fp); + fclose(fp); + + snprintf(buf, 256, "monkey-result-unmasked-%d.dat", num); + fp = fopen(buf, "w"); + frame = QRcode_unmask(qrcode); + p = frame; + for(y=0; ywidth; y++) { + for(x=0; xwidth; x++) { + fputc((*p&1)?'1':'0', fp); + p++; + } + fputc('\n', fp); + } + fclose(fp); + free(frame); + + snprintf(buf, 256, "monkey-orig-unmasked-%d.dat", num); + fp = fopen(buf, "w"); + input = QRinput_new2(0, num % 4); + Split_splitStringToQRinput(data, input, QR_MODE_8, num % 2); + origcode = QRcode_encodeMask(input, -2); + p = origcode->data; + for(y=0; ywidth; y++) { + for(x=0; xwidth; x++) { + fputc((*p&1)?'1':'0', fp); + p++; + } + fputc('\n', fp); + } + fclose(fp); + QRcode_free(origcode); + + snprintf(buf, 256, "monkey-orig-bits-%d.dat", num); + fp = fopen(buf, "w"); + bstream = QRinput_mergeBitStream(input); + c = 0; + for(x=0; xlength; x++) { + fputc((bstream->data[x]&1)?'1':'0', fp); + if((x & 7) == 7) { + fputc(' ', fp); + c++; + } + if((x & 63) == 63) { + fprintf(fp, "%d\n", c); + } + } + fclose(fp); + QRinput_free(input); + BitStream_free(bstream); + + snprintf(buf, 256, "monkey-result-bits-%d.dat", num); + fp = fopen(buf, "w"); + p = QRcode_extractBits(qrcode, &y); + c = 0; + for(x=0; xsize, "Lengths of input/output mismatched.\n"); + assert_zero(strncmp(str, (char *)(qrdata->data), qrdata->size), "Decoded data %s is different from the original %s\n", qrdata->data, str); + } + if(qrdata != NULL) QRdata_free(qrdata); + if(qrcode != NULL) QRcode_free(qrcode); + + testFinish(); +} + +void test_decodeVeryLong(void) +{ + char str[4000]; + int i; + QRcode *qrcode; + QRdata *qrdata; + + testStart("Test code words (very long string)."); + + for(i=0; i<3999; i++) { + str[i] = decodeAnTable[(int)drand(45)]; + } + str[3999] = '\0'; + + qrcode = QRcode_encodeString(str, 0, QR_ECLEVEL_L, QR_MODE_8, 0); + qrdata = QRcode_decode(qrcode); assert_nonnull(qrdata, "Failed to decode.\n"); if(qrdata != NULL) { @@ -731,7 +761,6 @@ void test_decodeLong(void) } if(qrdata != NULL) QRdata_free(qrdata); if(qrcode != NULL) QRcode_free(qrcode); - QRinput_free(input); testFinish(); } @@ -767,6 +796,7 @@ int main(void) test_formatInfo(); test_decodeSimple(); test_decodeLong(); + test_decodeVeryLong(); QRcode_clearCache(); -- cgit 0.0.5-2-1-g0f52 From 4c78d500792ba2f7f1046f3474b5f77c93040901 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Tue, 19 Jan 2010 20:16:58 +0000 Subject: --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 02f2088a8f..bfeeb5fca2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010.01.20 Kentaro FUKUCHI + * qrencode.c: + - Bug fix. + * tests/decoder.[ch]: + - Code refactoring. + * tests/test_{qrencode,mask,monkey}.c, Makefile.am: + - New tests added. + 2010.01.18 Kentaro FUKUCHI * configure.ac: - Configuration cleanups. -- cgit 0.0.5-2-1-g0f52 From 283764ca71d2f057115cf39d0455a06c37c92a99 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 Jan 2010 04:00:40 +0000 Subject: More bug checks. --- tests/decoder.c | 85 +++++++++++++++++++++++++++++++++++++++++++++------------ tests/decoder.h | 2 +- 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/tests/decoder.c b/tests/decoder.c index a2db488643..e7427ea24f 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -34,7 +34,7 @@ static int decodeLength(int *bits_length, unsigned char **bits, QRencodeMode mod int lbits = QRspec_lengthIndicator(mode, version); if(*bits_length < lbits) { - fprintf(stderr, "Bit length is too short: %d\n", *bits_length); + printf("Bit length is too short: %d\n", *bits_length); return 0; } @@ -71,7 +71,7 @@ static DataChunk *decodeNum(int *bits_length, unsigned char **bits, int version) sizeInBit += 4; } if(*bits_length < sizeInBit) { - fprintf(stderr, "Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit); + printf("Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit); return NULL; } @@ -139,7 +139,7 @@ static DataChunk *decodeAn(int *bits_length, unsigned char **bits, int version) remain = size - words * 2; sizeInBit = words * 11 + remain * 6; if(*bits_length < sizeInBit) { - fprintf(stderr, "Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit); + printf("Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit); return NULL; } @@ -190,7 +190,7 @@ static DataChunk *decode8(int *bits_length, unsigned char **bits, int version) sizeInBit = size * 8; if(*bits_length < sizeInBit) { - fprintf(stderr, "Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit); + printf("Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit); return NULL; } @@ -232,7 +232,7 @@ static DataChunk *decodeKanji(int *bits_length, unsigned char **bits, int versio sizeInBit = size * 13; if(*bits_length < sizeInBit) { - fprintf(stderr, "Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit); + printf("Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit); return NULL; } @@ -272,7 +272,6 @@ static DataChunk *decodeChunk(int *bits_length, unsigned char **bits, int versio int i, val; if(*bits_length < 4) { - fprintf(stderr, "Bit length too short: %d, expected 4.\n", *bits_length); return NULL; } val = 0; @@ -297,7 +296,7 @@ static DataChunk *decodeChunk(int *bits_length, unsigned char **bits, int versio break; } - fprintf(stderr, "Invalid mode in a chunk: %d\n", val); + printf("Invalid mode in a chunk: %d\n", val); return NULL; } @@ -445,11 +444,7 @@ int appendChunk(QRdata *qrdata, int *bits_length, unsigned char **bits) chunk = decodeChunk(bits_length, bits, qrdata->version); if(chunk == NULL) { - if(*bits_length == 0) { - return 1; - } else { - return -1; - } + return 1; } if(qrdata->last == NULL) { @@ -489,18 +484,20 @@ void QRdata_free(QRdata *qrdata) free(qrdata); } -static void QRdata_decodeBits(QRdata *qrdata, int length, unsigned char *bits) +static int QRdata_decodeBits(QRdata *qrdata, int length, unsigned char *bits) { int ret = 0; while(ret == 0) { ret = appendChunk(qrdata, &length, &bits); } + + return length; } -void QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream) +int QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream) { - QRdata_decodeBits(qrdata, bstream->length, bstream->data); + return QRdata_decodeBits(qrdata, bstream->length, bstream->data); } void QRdata_dump(QRdata *data) @@ -538,7 +535,7 @@ unsigned int QRcode_decodeVersion(QRcode *code) } if(v1 != v2) { - fprintf(stderr, "Two verion patterns are different.\n"); + printf("Two verion patterns are different.\n"); return -1; } @@ -586,7 +583,7 @@ int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask) } if(v1 != v2) { - fprintf(stderr, "Two format infos are different.\n"); + printf("Two format infos are different.\n"); return -1; } v1 = (v1 ^ 0x5412) >> 10; @@ -777,6 +774,55 @@ unsigned char *QRcode_extractBits(QRcode *code, int *length) return bits; } +static void printBits(int length, unsigned char *bits) +{ + int i; + + for(i=0; i= 8) { + printf("Something wrong? rbits = %d\n", rbits); + printBits(remainder, bits); + return -1; + } + for(i=0; iversion = version; qrdata->level = level; - QRdata_decodeBits(qrdata, length, bits); + ret = QRdata_decodeBits(qrdata, length, bits); + if(ret > 0) { + checkRemainderWords(length, bits, ret); + } free(bits); diff --git a/tests/decoder.h b/tests/decoder.h index 29e2aa3933..b3f78ee007 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -20,7 +20,7 @@ typedef struct { } QRdata; QRdata *QRdata_new(void); -void QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream); +int QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream); void QRdata_dump(QRdata *data); void QRdata_free(QRdata *data); -- cgit 0.0.5-2-1-g0f52 From d436b8203b4209311c24ff40aad32bde66a7a66e Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 Jan 2010 04:00:54 +0000 Subject: Typo fix. --- qrencode_inner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrencode_inner.h b/qrencode_inner.h index 724f8c4ae2..6f7b36b0de 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -23,7 +23,7 @@ #define __QRENCODE_INNER_H__ /** - * Ths header file includes definitions for test use. + * This header file includes definitions for test use. */ /****************************************************************************** -- cgit 0.0.5-2-1-g0f52 From 693cc690d12464d3065e379d8a4944477c1d4e45 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 Jan 2010 04:30:49 +0000 Subject: New tests. --- tests/test_monkey.c | 125 +++++++++++++++++++++++++++++++++++++++++++++------ tests/test_qrinput.c | 7 +++ 2 files changed, 119 insertions(+), 13 deletions(-) diff --git a/tests/test_monkey.c b/tests/test_monkey.c index b48b37715c..ab071d1ef7 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -8,14 +8,14 @@ #include "decoder.h" #define MAX_LENGTH 7091 -static char data[MAX_LENGTH]; -static char check[MAX_LENGTH]; +static unsigned char data[MAX_LENGTH]; +static unsigned char check[MAX_LENGTH]; static const char *AN = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; #define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0)) -int fill8bitData(void) +int fill8bitString(void) { int len, i; @@ -28,6 +28,19 @@ int fill8bitData(void) return len; } +int fill8bitData(void) +{ + int len, i; + + len = 1 + (int)drand((MAX_LENGTH - 2)); + for(i=0; idata; for(y=0; ywidth; y++) { @@ -189,7 +202,7 @@ void test_split_an(int num) perror("test_split_an aborted at QRinput_new2():"); return; } - ret = Split_splitStringToQRinput(data, input, QR_MODE_8, 1); + ret = Split_splitStringToQRinput((char *)data, input, QR_MODE_8, 1); if(ret < 0) { perror("test_split_an aborted at Split_splitStringToQRinput():"); QRinput_free(input); @@ -238,20 +251,62 @@ void monkey_split_an(int loop) } } +void test_encode_8(int num) +{ + QRcode *qrcode; + QRdata *qrdata; + int len, ret; + + len = fill8bitData(); + + qrcode = QRcode_encodeData(len, data, 0, num % 4); + if(qrcode == NULL) { + if(errno == ERANGE) return; + perror("test_encdoe_8 aborted at QRcode_encodeData():"); + return; + } + qrdata = QRcode_decode(qrcode); + if(qrdata == NULL) { + printf("#%d: Failed to decode this code.\n", num); + QRcode_free(qrcode); + return; + } + if(qrdata->size != len) { + printf("#%d: length mismatched (orig: %d, decoded: %d)\n", num, len, qrdata->size); + } + ret = memcmp(qrdata->data, data, len); + if(ret != 0) { + printf("#%d: data mismatched.\n", num); + } + QRdata_free(qrdata); + QRcode_free(qrcode); +} + +void monkey_encode_8(int loop) +{ + int i; + + puts("Monkey test: QRcode_encodeData() - 8bit char string."); + srand(0); + for(i=0; isize != len) { + printf("#%d: length mismatched (orig: %d, decoded: %d)\n", num, len, qrdata->size); + } + ret = memcmp(qrdata->data, data, len); + if(ret != 0) { + printf("#%d: data mismatched.\n", num); + } + QRdata_free(qrdata); + QRcode_free(qrcode); +} + +void monkey_encode_kanji(int loop) +{ + int i; + + puts("Monkey test: QRcode_encodeString() - kanji string."); + srand(0); + for(i=0; iversion = input->version; + QRdata_decodeBitStream(qrdata, bstream); + QRdata_dump(qrdata); + QRinput_free(input); BitStream_free(bstream); -- cgit 0.0.5-2-1-g0f52 From 20d32afea5e32827d43d19149e33846955de54b8 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 Jan 2010 04:38:08 +0000 Subject: --- ChangeLog | 2 ++ tests/test_qrinput.c | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index bfeeb5fca2..7367f61c3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ - Code refactoring. * tests/test_{qrencode,mask,monkey}.c, Makefile.am: - New tests added. + * qrencode_inner.h: + - Typo fix. 2010.01.18 Kentaro FUKUCHI * configure.ac: diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index e2c486dfd4..6be2de4cd4 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -37,7 +37,6 @@ int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct) QRinput *input; BitStream *bstream; int ret; - QRdata *qrdata; if(mqr) { input = QRinput_newMQR(1, QR_ECLEVEL_L); @@ -48,11 +47,6 @@ int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct) bstream = QRinput_mergeBitStream(input); ret = cmpBin(correct, bstream); - qrdata = QRdata_new(); - qrdata->version = input->version; - QRdata_decodeBitStream(qrdata, bstream); - QRdata_dump(qrdata); - QRinput_free(input); BitStream_free(bstream); -- cgit 0.0.5-2-1-g0f52 From ef05d6ab8ba68dd0838826d180fbc023ba367b7c Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 Jan 2010 05:38:07 +0000 Subject: --- NEWS | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 3f1e225faf..11f7b86cd5 100644 --- a/NEWS +++ b/NEWS @@ -1,19 +1,28 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.0.0 (2009.x.x) +Version 3.9.0 (2010.x.x) ------------------------ * Micro QR Code support has been added. -* "-M" option for Micro QR Code has been added to qrencode. +* "--micro" (or "-M") option for Micro QR Code has been added to qrencode. * "--dpi" (or "-d") has been added to qrencode. This option set DPI information in an output PNG image. (Thanks to David Dahl) * New option "--enable-thread-safety" has been added to the configure script that makes the library thread-safe. It is enabled by default. +* QRcode_encodeData(), QRcode_encodeDataMQR, QRcode_encodeDataStructured() have + been added for binary data encoding including '\0'. +* Typo and bug fixes. Release Note: -This release supports Micro QR Code. -For a long time, libqrencode was thread unsafe. -Thread safe. +** This is an open beta version of libqrencode 4.0.0. +Micro QR Code encoder has been added. Some functions (QRcode_*MQR()) have been +added to the library. The command line tool also accepts "--micro" and "-M" +options. "--dpi" and "-d" are also added to embed DPI information to PNG file. + +Binary data including '\0' can be encoded now with qrencode. To encode a binary +data, give "-8" option to qrencode, and let qrencode obtain data via standard +input like "qrencode -8 -o output.png < binary". + Version 3.1.0 (2009.6.6) ------------------------ -- cgit 0.0.5-2-1-g0f52 From 7d0ea71a278d76228c6fc622972ea867f73ddc52 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 Jan 2010 05:38:33 +0000 Subject: --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7367f61c3c..a9eb7a7035 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ - New tests added. * qrencode_inner.h: - Typo fix. + * NEWS: + - Updated. 2010.01.18 Kentaro FUKUCHI * configure.ac: -- cgit 0.0.5-2-1-g0f52 From 6b89e6b29b129e1625c904d69032167e021954c2 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 Jan 2010 06:55:26 +0000 Subject: Possible memory errors fixed. --- qrinput.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrinput.c b/qrinput.c index 6079aeafa8..38d1175b79 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1049,7 +1049,7 @@ static int QRinput_convertData(QRinput *input) static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) { int bits, maxbits, words, maxwords, i, ret; - BitStream *padding; + BitStream *padding = NULL; unsigned char *padbuf; int padlen; @@ -1114,7 +1114,7 @@ DONE: static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) { int bits, maxbits, words, maxwords, i, ret, termbits; - BitStream *padding; + BitStream *padding = NULL; unsigned char *padbuf; int padlen; -- cgit 0.0.5-2-1-g0f52 From ebc3768fb568af3682b3c9d88298576bba27012b Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 20 Jan 2010 06:56:12 +0000 Subject: Added iconv checks. --- ChangeLog | 4 ++++ configure.ac | 1 + tests/Makefile.am | 19 ++++++++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9eb7a7035..f0ae2b37f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,10 @@ - Typo fix. * NEWS: - Updated. + * qrinput.c: + - Possible memory errors fixed. + * configure.ac, tests/Makefile.am: + - Added iconv checks. 2010.01.18 Kentaro FUKUCHI * configure.ac: diff --git a/configure.ac b/configure.ac index c3b537ac5d..41ed4674df 100644 --- a/configure.ac +++ b/configure.ac @@ -72,6 +72,7 @@ if test x$build_tests = xyes ; then SDL_REQUIRED_VERSION=1.2.0 AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.])) AC_MSG_NOTICE([SDL check done.]) + AM_ICONV_LINK fi AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ]) diff --git a/tests/Makefile.am b/tests/Makefile.am index c5379036a7..d66237fe36 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,14 +7,19 @@ noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_mqrspec test_split test_monkey test_mask test_mmask \ create_frame_pattern create_mqr_frame_pattern \ $(sdlPROGRAMS) +noinst_LIBRARIES = libdecoder.a +DECODER_LIBS = libdecoder.a $(LIBICONV) +noinst_HEADERS = common.h if HAVE_LIBPTHREAD noinst_PROGRAMS += pthread_qrencode endif EXTRA_DIST = frame +libdecoder_a_SOURCES = decoder.c decoder.h + test_qrinput_SOURCES = test_qrinput.c -test_qrinput_LDADD = ../libqrencode.la decoder.o +test_qrinput_LDADD = ../libqrencode.la $(DECODER_LIBS) test_bitstream_SOURCES = test_bitstream.c test_bitstream_LDADD = ../libqrencode.la @@ -23,28 +28,28 @@ test_estimatebit_SOURCES = test_estimatebit.c test_estimatebit_LDADD = ../libqrencode.la test_qrspec_SOURCES = test_qrspec.c -test_qrspec_LDADD = ../libqrencode.la decoder.o +test_qrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) test_mqrspec_SOURCES = test_mqrspec.c -test_mqrspec_LDADD = ../libqrencode.la +test_mqrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) test_rs_SOURCES = test_rs.c test_rs_LDADD = ../libqrencode.la test_qrencode_SOURCES = test_qrencode.c -test_qrencode_LDADD = ../libqrencode.la decoder.o +test_qrencode_LDADD = ../libqrencode.la $(DECODER_LIBS) test_split_SOURCES = test_split.c test_split_LDADD = ../libqrencode.la test_monkey_SOURCES = test_monkey.c -test_monkey_LDADD = ../libqrencode.la decoder.o +test_monkey_LDADD = ../libqrencode.la $(DECODER_LIBS) test_mask_SOURCES = test_mask.c -test_mask_LDADD = ../libqrencode.la decoder.o +test_mask_LDADD = ../libqrencode.la $(DECODER_LIBS) test_mmask_SOURCES = test_mmask.c -test_mmask_LDADD = ../libqrencode.la +test_mmask_LDADD = ../libqrencode.la $(DECODER_LIBS) prof_qrencode_SOURCES = prof_qrencode.c prof_qrencode_LDADD = ../libqrencode.la -- cgit 0.0.5-2-1-g0f52 From aa10a7b6f42f1b9aec478f243aac7408dd88d9a1 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Thu, 21 Jan 2010 18:04:44 +0000 Subject: Code cleanup. --- tests/test_qrspec.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 8133c4a681..69838e139b 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -124,6 +124,8 @@ void test_newframe(void) size_t len; FILE *fp; unsigned char *frame; + QRcode *qrcode; + unsigned int version; testStart("Checking newly created frame."); fp = fopen("frame", "rb"); @@ -140,7 +142,10 @@ void test_newframe(void) abort(); } assert_zero(memcmp(frame, buf, len), "frame pattern mismatch (version %d)\n", i); - free(frame); + qrcode = QRcode_new(i, width, frame); + version = QRcode_decodeVersion(qrcode); + assert_equal(version, i, "Decoded version number is wrong: %d, expected %d.\n", version, i); + QRcode_free(qrcode); } testFinish(); @@ -302,24 +307,6 @@ void test_format(void) testEnd(err); } -void test_allframe(void) -{ - unsigned int version; - int i, width; - unsigned char *frame; - QRcode *qrcode; - - testStart("All empty frame check"); - for(i=1; i<= QRSPEC_VERSION_MAX; i++) { - width = QRspec_getWidth(i); - frame = QRspec_newFrame(i); - qrcode = QRcode_new(i, width, frame); - version = QRcode_decodeVersion(qrcode); - assert_equal(version, i, "Decoded version number is wrong: %d, expected %d.\n", version, i); - QRcode_free(qrcode); - } -} - int main(void) { test_eccTable(); @@ -331,7 +318,6 @@ int main(void) test_verpat(); //print_newFrame(); test_format(); - test_allframe(); QRspec_clearCache(); -- cgit 0.0.5-2-1-g0f52 From b4eee70841c1b6a4def5d1ff1d90ed1c50e44bb6 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 22 Jan 2010 04:48:20 +0000 Subject: Added tests for Micro QR Code. --- ChangeLog | 6 + tests/decoder.c | 384 ++++++++++++++++++++++++++++++++++++++++---------- tests/decoder.h | 15 ++ tests/test_qrencode.c | 47 ++++++ 4 files changed, 376 insertions(+), 76 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0ae2b37f7..bf06ed0a08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010.01.22 Kentaro FUKUCHI + * tests/test_qrspec.c: + - Code cleanup. + * tests/decoder.[ch], tests/test_qrencode.c: + - Added tests for Micro QR Code. + 2010.01.20 Kentaro FUKUCHI * qrencode.c: - Bug fix. diff --git a/tests/decoder.c b/tests/decoder.c index e7427ea24f..13b5cf9bae 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -5,8 +5,23 @@ #include "../qrspec.h" #include "../bitstream.h" #include "../mask.h" +#include "../mqrspec.h" +#include "../mmask.h" #include "decoder.h" +static unsigned int bitToInt(unsigned char *bits, int length) +{ + int i; + unsigned int val = 0; + + for(i=0; i= termbits) { + val = bitToInt(*bits, termbits); + if(val == 0) { + *bits += termbits; + *bits_length -= termbits; + return NULL; + } + } else { + if(*bits_length < modebits) { + val = bitToInt(*bits, *bits_length); + } else { + val = bitToInt(*bits, modebits); + } + if(val == 0) { + return NULL; + } else { + printf("Terminating bits include 1-bit.\n"); + return NULL; + } + } + val = bitToInt(*bits, modebits); + if(version == 4 && val > 3) { + printf("Invalid mode number %d.\n", val); + } + *bits_length -= modebits; + *bits += modebits; + switch(val) { + case 0: + return decodeNum(bits_length, bits, version, 1); + case 1: + return decodeAn(bits_length, bits, version, 1); + case 2: + return decode8(bits_length, bits, version, 1); + case 3: + return decodeKanji(bits_length, bits, version, 1); default: break; } @@ -442,7 +480,11 @@ int appendChunk(QRdata *qrdata, int *bits_length, unsigned char **bits) { DataChunk *chunk; - chunk = decodeChunk(bits_length, bits, qrdata->version); + if(qrdata->mqr) { + chunk = decodeChunkMQR(bits_length, bits, qrdata->version); + } else { + chunk = decodeChunk(bits_length, bits, qrdata->version); + } if(chunk == NULL) { return 1; } @@ -467,6 +509,17 @@ QRdata *QRdata_new(void) return qrdata; } +QRdata *QRdata_newMQR(void) +{ + QRdata *qrdata; + + qrdata = (QRdata *)calloc(sizeof(QRdata), 1); + if(qrdata == NULL) return NULL; + qrdata->mqr = 1; + + return qrdata; +} + void QRdata_free(QRdata *qrdata) { DataChunk *chunk, *next; @@ -788,16 +841,11 @@ static int checkRemainderWords(int length, unsigned char *bits, int remainder) { int rbits, words; unsigned char *p, v; - int i, j; + int i; words = remainder / 8; rbits = remainder - words * 8; bits += (length - remainder); - if(rbits >= 8) { - printf("Something wrong? rbits = %d\n", rbits); - printBits(remainder, bits); - return -1; - } for(i=0; iwidth; + + v = 0; + p = code->data + width * 8 + 1; + for(i=0; i<8; i++) { + v = v << 1; + v |= p[i] & 1; + } + p = code->data + width * 7 + 8; + for(i=0; i<7; i++) { + v = v << 1; + v |= *(p - width * i) & 1; + } + v ^= 0x4445; + *mask = (v >> 10) & 3; + t = (v >> 12) & 7; + *version = MQRformat[t].version; + *level = MQRformat[t].level; + if(*version * 2 + 9 != width) { + printf("Decoded version number does not match to the size.\n"); + return -1; + } + return 0; +} + +static unsigned char *unmaskMQR(QRcode *code, QRecLevel level, int mask) +{ + unsigned char *unmasked; + + unmasked = MMask_makeMask(code->version, code->data, mask, level); + + return unmasked; +} + +unsigned char *QRcode_unmaskMQR(QRcode *code) +{ + int ret, version, mask; + QRecLevel level; + + ret = QRcode_decodeFormatMQR(code, &version, &level, &mask); + if(ret < 0) return NULL; + + return unmaskMQR(code, level, mask); +} + +static unsigned char *extractBitsMQR(int width, unsigned char *frame, int version, QRecLevel level) +{ + unsigned char *bits; + FrameFiller *filler; + int i; + int size; + + size = MQRspec_getDataLengthBit(version, level); + bits = (unsigned char *)malloc(size); + filler = FrameFiller_new(width, frame, 1); + for(i=0; iwidth, unmasked, version, level); + free(unmasked); + + return bits; +} + +static int checkRemainderWordsMQR(int length, unsigned char *bits, int remainder, int version) +{ + int rbits, words, paddings; + unsigned char *p, v; + int i, decoded; + + decoded = length - remainder; + bits += decoded; + words = (decoded + 7) / 8; + rbits = words * 8 - decoded; + for(i=0; i 0) { + if((version == 1 || version == 3) && rbits == 4) { + v = (unsigned char)bitToInt(p, 4); + if(v != 0) { + printf("Last padding bits include 1-bit.\n"); + return -1; + } + } else { + printf("The length of the last padding bits is %d, not %d.\n", rbits, (version == 1 || version == 3)?4:0); + return -1; + } + } + + return 0; +} + +QRdata *QRcode_decodeBitsMQR(QRcode *code) +{ + unsigned char *unmasked, *bits; + int ret, version, mask; + int length; + QRecLevel level; + QRdata *qrdata; + + ret = QRcode_decodeFormatMQR(code, &version, &level, &mask); + if(ret < 0) return NULL; + + unmasked = unmaskMQR(code, level, mask); + if(unmasked == NULL) return NULL; + + length = MQRspec_getDataLengthBit(version, level); + bits = extractBitsMQR(code->width, unmasked, version, level); + free(unmasked); + + qrdata = QRdata_newMQR(); + qrdata->version = version; + qrdata->level = level; + ret = QRdata_decodeBits(qrdata, length, bits); + if(ret > 0) { + checkRemainderWordsMQR(length, bits, ret, version); + } + + free(bits); + + return qrdata; +} + +QRdata *QRcode_decodeMQR(QRcode *code) +{ + QRdata *qrdata; + qrdata = QRcode_decodeBitsMQR(code); + QRdata_concatChunks(qrdata); + + return qrdata; +} diff --git a/tests/decoder.h b/tests/decoder.h index b3f78ee007..81388e3f9b 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -14,12 +14,21 @@ typedef struct _DataChunk { typedef struct { int size; unsigned char *data; + int mqr; int version; QRecLevel level; DataChunk *chunks, *last; } QRdata; +struct FormatInfo { + int version; + QRecLevel level; +}; + +extern struct FormatInfo MQRformat[]; + QRdata *QRdata_new(void); +QRdata *QRdata_newMQR(void); int QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream); void QRdata_dump(QRdata *data); void QRdata_free(QRdata *data); @@ -31,4 +40,10 @@ unsigned char *QRcode_extractBits(QRcode *code, int *length); QRdata *QRcode_decodeBits(QRcode *code); QRdata *QRcode_decode(QRcode *code); +int QRcode_decodeFormatMQR(QRcode *code, int *vesion, QRecLevel *level, int *mask); +unsigned char *QRcode_unmaskMQR(QRcode *code); +unsigned char *QRcode_extractBitsMQR(QRcode *code, int *length); +QRdata *QRcode_decodeBitsMQR(QRcode *code); +QRdata *QRcode_decodeMQR(QRcode *code); + #endif /* __DECODER_H__ */ diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index b4917209f3..0df96e8cc5 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -694,6 +694,28 @@ void test_formatInfo(void) testFinish(); } +void test_formatInfoMQR(void) +{ + QRcode *qrcode; + QRecLevel level; + int version, mask; + int i, ret; + + testStart("Test format info in Micro QR code."); + for(i=0; i<8; i++) { + qrcode = QRcode_encodeStringMQR("1", + MQRformat[i].version, + MQRformat[i].level, + QR_MODE_8, 1); + ret = QRcode_decodeFormatMQR(qrcode, &version, &level, &mask); + assert_equal(MQRformat[i].version, version, "Decoded verion is wrong.\n"); + assert_equal(MQRformat[i].level, level, "Decoded level is wrong.\n"); + QRcode_free(qrcode); + } + + testFinish(); +} + void test_decodeSimple(void) { char *str = "AC-42"; @@ -765,6 +787,29 @@ void test_decodeVeryLong(void) testFinish(); } +void test_decodeShortMQR(void) +{ + char str[]="55"; + QRcode *qrcode; + QRdata *qrdata; + int i; + + testStart("Test code words (MQR)."); + for(i=0; i<8; i++) { + qrcode = QRcode_encodeStringMQR(str, + MQRformat[i].version, + MQRformat[i].level, + QR_MODE_8, 1); + qrdata = QRcode_decodeMQR(qrcode); + + assert_nonnull(qrdata, "Failed to decode.\n"); + assert_zero(strcmp((char *)qrdata->data, str), "Decoded data (%s) mismatched (%s)\n", (char *)qrdata->data, str); + if(qrdata != NULL) QRdata_free(qrdata); + if(qrcode != NULL) QRcode_free(qrcode); + } + + testFinish(); +} int main(void) { @@ -794,9 +839,11 @@ int main(void) test_mqrraw_new(); test_encodeData(); test_formatInfo(); + test_formatInfoMQR(); test_decodeSimple(); test_decodeLong(); test_decodeVeryLong(); + test_decodeShortMQR(); QRcode_clearCache(); -- cgit 0.0.5-2-1-g0f52 From 35fa732bd9806c968fd0343c19827b7ebe2fc21a Mon Sep 17 00:00:00 2001 From: fukuchi Date: Fri, 22 Jan 2010 04:58:46 +0000 Subject: --- tests/test_qrencode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 0df96e8cc5..ddc2e3e812 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -833,16 +833,16 @@ int main(void) test_struct_semilong(); test_null_free(); test_qrraw_new(); - //print_fillerMQR(); - test_fillerMQR(); - test_encodeTooLongMQR(); test_mqrraw_new(); test_encodeData(); test_formatInfo(); - test_formatInfoMQR(); test_decodeSimple(); test_decodeLong(); test_decodeVeryLong(); + //print_fillerMQR(); + test_fillerMQR(); + test_formatInfoMQR(); + test_encodeTooLongMQR(); test_decodeShortMQR(); QRcode_clearCache(); -- cgit 0.0.5-2-1-g0f52 From a9c3306229e5436d99b694b08642c67b2e421077 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 25 Jan 2010 01:16:28 +0000 Subject: * qrencode.h: - QR_MODE_{ECI,FNC1A,FNC1B} have been added to QRencodeMode. * qrspec.h, mqrspec.h, qrinput.c: - QRSPEC_MODEID_* and MQRSPEC_MODEID_* have been added, and hard coded numbers were replaced with them. --- ChangeLog | 7 +++++++ mqrspec.h | 12 ++++++++++++ qrencode.h | 3 +++ qrinput.c | 18 +++++++++--------- qrspec.h | 17 +++++++++++++++++ 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf06ed0a08..a127c7b562 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010.01.25 Kentaro FUKUCHI + * qrencode.h: + - QR_MODE_{ECI,FNC1A,FNC1B} have been added to QRencodeMode. + * qrspec.h, mqrspec.h, qrinput.c: + - QRSPEC_MODEID_* and MQRSPEC_MODEID_* have been added, and hard coded + numbers were replaced with them. + 2010.01.22 Kentaro FUKUCHI * tests/test_qrspec.c: - Code cleanup. diff --git a/mqrspec.h b/mqrspec.h index f27f8c2b56..fc98454ff2 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -142,4 +142,16 @@ extern unsigned char *MQRspec_newFrame(int version); */ extern void MQRspec_clearCache(void); +/****************************************************************************** + * Mode indicator + *****************************************************************************/ + +/** + * Mode indicator. See Table 2 in Appendix 1 of JIS X0510:2004, pp.107. + */ +#define MQRSPEC_MODEID_NUM 0 +#define MQRSPEC_MODEID_AN 1 +#define MQRSPEC_MODEID_8 2 +#define MQRSPEC_MODEID_KANJI 3 + #endif /* __MQRSPEC_H__ */ diff --git a/qrencode.h b/qrencode.h index 0dbf948015..11ff75f90c 100644 --- a/qrencode.h +++ b/qrencode.h @@ -113,6 +113,9 @@ typedef enum { QR_MODE_8, ///< 8-bit data mode QR_MODE_KANJI, ///< Kanji (shift-jis) mode QR_MODE_STRUCTURE, ///< Internal use only + QR_MODE_ECI, ///< ECI mode + QR_MODE_FNC1A, ///< FNC1, first position + QR_MODE_FNC1B, ///< FNC1, second position } QRencodeMode; /** diff --git a/qrinput.c b/qrinput.c index 38d1175b79..ca61958df5 100644 --- a/qrinput.c +++ b/qrinput.c @@ -386,13 +386,13 @@ static int QRinput_encodeModeNum(QRinput_List *entry, int version, int mqr) if(mqr) { if(version > 1) { - ret = BitStream_appendNum(entry->bstream, version - 1, 0); + ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_NUM); if(ret < 0) goto ABORT; } ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); if(ret < 0) goto ABORT; } else { - ret = BitStream_appendNum(entry->bstream, 4, 1); + ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_NUM); if(ret < 0) goto ABORT; ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); @@ -502,12 +502,12 @@ static int QRinput_encodeModeAn(QRinput_List *entry, int version, int mqr) errno = EINVAL; goto ABORT; } - ret = BitStream_appendNum(entry->bstream, version - 1, 1); + ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_AN); if(ret < 0) goto ABORT; ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_AN, version), entry->size); if(ret < 0) goto ABORT; } else { - ret = BitStream_appendNum(entry->bstream, 4, 2); + ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_AN); if(ret < 0) goto ABORT; ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), entry->size); if(ret < 0) goto ABORT; @@ -571,12 +571,12 @@ static int QRinput_encodeMode8(QRinput_List *entry, int version, int mqr) errno = EINVAL; goto ABORT; } - ret = BitStream_appendNum(entry->bstream, version - 1, 2); + ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_8); if(ret < 0) goto ABORT; ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_8, version), entry->size); if(ret < 0) goto ABORT; } else { - ret = BitStream_appendNum(entry->bstream, 4, 4); + ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_8); if(ret < 0) goto ABORT; ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), entry->size); if(ret < 0) goto ABORT; @@ -656,12 +656,12 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, int version, int mqr) errno = EINVAL; goto ABORT; } - ret = BitStream_appendNum(entry->bstream, version - 1, 3); + ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_KANJI); if(ret < 0) goto ABORT; ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); if(ret < 0) goto ABORT; } else { - ret = BitStream_appendNum(entry->bstream, 4, 8); + ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_KANJI); if(ret < 0) goto ABORT; ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); if(ret < 0) goto ABORT; @@ -713,7 +713,7 @@ static int QRinput_encodeModeStructure(QRinput_List *entry, int mqr) entry->bstream = BitStream_new(); if(entry->bstream == NULL) return -1; - ret = BitStream_appendNum(entry->bstream, 4, 0x03); + ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_STRUCTURE); if(ret < 0) goto ABORT; ret = BitStream_appendNum(entry->bstream, 4, entry->data[1] - 1); if(ret < 0) goto ABORT; diff --git a/qrspec.h b/qrspec.h index 6e3e8579f2..481e588afc 100644 --- a/qrspec.h +++ b/qrspec.h @@ -161,4 +161,21 @@ extern unsigned char *QRspec_newFrame(int version); */ extern void QRspec_clearCache(void); +/****************************************************************************** + * Mode indicator + *****************************************************************************/ + +/** + * Mode indicator. See Table 2 of JIS X0510:2004, pp.16. + */ +#define QRSPEC_MODEID_ECI 7 +#define QRSPEC_MODEID_NUM 1 +#define QRSPEC_MODEID_AN 2 +#define QRSPEC_MODEID_8 4 +#define QRSPEC_MODEID_KANJI 8 +#define QRSPEC_MODEID_FNC1A 5 +#define QRSPEC_MODEID_FNC1B 9 +#define QRSPEC_MODEID_STRUCTURE 3 +#define QRSPEC_MODEID_TERMINATOR 0 + #endif /* __QRSPEC_H__ */ -- cgit 0.0.5-2-1-g0f52 From 43c070a47519774fd1db5818845c204e03fd4977 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 25 Jan 2010 05:50:14 +0000 Subject: Modified usage message. --- qrenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 11fc294141..89e1c16c95 100644 --- a/qrenc.c +++ b/qrenc.c @@ -85,7 +85,7 @@ static void usage(int help, int longopt) " -v NUMBER, --symversion=NUMBER\n" " specify the version of the symbol. (default=auto)\n\n" " -m NUMBER, --margin=NUMBER\n" -" specify the width of the margins. (default=4)\n\n" +" specify the width of the margins. (default=4 (2 for Micro)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" " -S, --structured\n" @@ -116,7 +116,7 @@ static void usage(int help, int longopt) " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" " -v NUMBER specify the version of the symbol. (default=auto)\n" -" -m NUMBER specify the width of the margins. (default=4)\n" +" -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" " -S make structured symbols. Version must be specified.\n" -- cgit 0.0.5-2-1-g0f52 From 6befd5b74f123c5361a5935904f1ac85d2202791 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Mon, 25 Jan 2010 05:53:10 +0000 Subject: - Added new functions to set FNC1 flag. - FNC1 second position encoding now supported. --- ChangeLog | 7 ++++ qrencode.h | 30 ++++++++++++++-- qrinput.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- qrinput.h | 2 ++ qrspec.h | 4 +-- 5 files changed, 144 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index a127c7b562..33094ac1ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,13 @@ * qrspec.h, mqrspec.h, qrinput.c: - QRSPEC_MODEID_* and MQRSPEC_MODEID_* have been added, and hard coded numbers were replaced with them. + * qrenc.c: + - Modified usage. + * qrinput.h: + - Added a new field to QRinput for FNC1 support. + * qrinput.c, qrencode.h: + - Added new functions to set FNC1 flag. + - FNC1 second position encoding now supported. 2010.01.22 Kentaro FUKUCHI * tests/test_qrspec.c: diff --git a/qrencode.h b/qrencode.h index 11ff75f90c..e92f049c68 100644 --- a/qrencode.h +++ b/qrencode.h @@ -114,8 +114,8 @@ typedef enum { QR_MODE_KANJI, ///< Kanji (shift-jis) mode QR_MODE_STRUCTURE, ///< Internal use only QR_MODE_ECI, ///< ECI mode - QR_MODE_FNC1A, ///< FNC1, first position - QR_MODE_FNC1B, ///< FNC1, second position + QR_MODE_FNC1FIRST, ///< FNC1, first position + QR_MODE_FNC1SECOND, ///< FNC1, second position } QRencodeMode; /** @@ -199,6 +199,22 @@ extern QRinput *QRinput_newMQR(int version, QRecLevel level); */ extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data); +/** + * Append data to an input object with ECI header. + * The data is copied and appended to the input object. + * @param input input object. + * @param mode encoding mode. + * @param size size of data (byte). + * @param data a pointer to the memory area of the input data. + * @retval 0 success. + * @retval -1 an error occurred and errno is set to indeicate the error. + * See Execptions for the details. + * @throw ENOMEM unable to allocate memory. + * @throw EINVAL input data is invalid. + * + */ +extern int QRinput_appendECI(QRinput *input, QRencodeMode mode, int size, const unsigned char *data, unsigned int ecinum); + /** * Get current version. * @param input input object. @@ -326,6 +342,16 @@ extern QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input); */ extern int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s); +/** + * Set FNC1-1st position flag. + */ +extern int QRinput_setFNC1First(QRinput *input); + +/** + * Set FNC1-2nd position flag and application identifier. + */ +extern int QRinput_setFNC1Second(QRinput *input, unsigned char appid); + /****************************************************************************** * QRcode output (qrencode.c) *****************************************************************************/ diff --git a/qrinput.c b/qrinput.c index ca61958df5..d0254758f3 100644 --- a/qrinput.c +++ b/qrinput.c @@ -49,12 +49,14 @@ static QRinput_List *QRinput_List_newEntry(QRencodeMode mode, int size, const un entry->mode = mode; entry->size = size; - entry->data = (unsigned char *)malloc(size); - if(entry->data == NULL) { - free(entry); - return NULL; + if(size > 0) { + entry->data = (unsigned char *)malloc(size); + if(entry->data == NULL) { + free(entry); + return NULL; + } + memcpy(entry->data, data, size); } - memcpy(entry->data, data, size); entry->bstream = NULL; entry->next = NULL; @@ -117,6 +119,7 @@ QRinput *QRinput_new2(int version, QRecLevel level) input->version = version; input->level = level; input->mqr = 0; + input->fnc1 = 0; return input; } @@ -729,31 +732,63 @@ ABORT: return -1; } +/****************************************************************************** + * FNC1 + *****************************************************************************/ + +static int QRinput_checkModeFNC1Second(int size, const unsigned char *data) +{ + if(size != 1) return -1; + + return 0; +} + +static int QRinput_encodeModeFNC1Second(QRinput_List *entry, int version) +{ + int ret; + + entry->bstream = BitStream_new(); + if(entry->bstream == NULL) return -1; + + ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_FNC1SECOND); + if(ret < 0) goto ABORT; + + ret = BitStream_appendBytes(entry->bstream, 1, entry->data); + if(ret < 0) goto ABORT; + + return 0; +ABORT: + BitStream_free(entry->bstream); + entry->bstream = NULL; + return -1; +} + /****************************************************************************** * Validation *****************************************************************************/ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) { - if(size <= 0) return -1; + if((mode == QR_MODE_FNC1FIRST && size < 0) || size <= 0) return -1; switch(mode) { case QR_MODE_NUM: return QRinput_checkModeNum(size, (const char *)data); - break; case QR_MODE_AN: return QRinput_checkModeAn(size, (const char *)data); - break; case QR_MODE_KANJI: return QRinput_checkModeKanji(size, data); - break; case QR_MODE_8: return 0; - break; case QR_MODE_STRUCTURE: return 0; - break; - default: + case QR_MODE_ECI: + return -1; + case QR_MODE_FNC1FIRST: + return 0; + case QR_MODE_FNC1SECOND: + return QRinput_checkModeFNC1Second(size, data); + case QR_MODE_NUL: break; } @@ -961,6 +996,8 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) case QR_MODE_STRUCTURE: ret = QRinput_encodeModeStructure(entry, mqr); break; + case QR_MODE_FNC1SECOND: + ret = QRinput_encodeModeFNC1Second(entry, version); default: break; } @@ -1180,6 +1217,30 @@ DONE: return ret; } +static int QRinput_insertFNC1Header(QRinput *input) +{ + QRinput_List *entry; + + if(input->fnc1 == 1) { + entry = QRinput_List_newEntry(QR_MODE_FNC1FIRST, 0, NULL); + } else if(input->fnc1 == 2) { + entry = QRinput_List_newEntry(QR_MODE_FNC1SECOND, 1, &(input->appid)); + } + if(entry == NULL) { + return -1; + } + + if(input->head->mode != QR_MODE_STRUCTURE || input->head->mode != QR_MODE_ECI) { + entry->next = input->head; + input->head = entry; + } else { + entry->next = input->head->next; + input->head->next = entry; + } + + return 0; +} + /** * Merge all bit streams in the input data. * @param input input data. @@ -1193,9 +1254,15 @@ __STATIC BitStream *QRinput_mergeBitStream(QRinput *input) int ret; if(input->mqr) { - ret = QRinput_createBitStream(input); - if(ret < 0) return NULL; + if(QRinput_createBitStream(input) < 0) { + return NULL; + } } else { + if(input->fnc1) { + if(QRinput_insertFNC1Header(input) < 0) { + return NULL; + } + } if(QRinput_convertData(input) < 0) { return NULL; } @@ -1525,5 +1592,28 @@ int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s) } /****************************************************************************** - * Functions for Micro QR Code + * Extended encoding mode (FNC1 and ECI) *****************************************************************************/ + +int QRinput_setFNC1First(QRinput *input) +{ + if(input->mqr) { + errno = EINVAL; + return -1; + } + input->fnc1 = 1; + + return 0; +} + +int QRinput_setFNC1Second(QRinput *input, unsigned char appid) +{ + if(input->mqr) { + errno = EINVAL; + return -1; + } + input->fnc1 = 2; + input->appid = appid; + + return 0; +} diff --git a/qrinput.h b/qrinput.h index 133dbd0663..0cb1dad29a 100644 --- a/qrinput.h +++ b/qrinput.h @@ -47,6 +47,8 @@ struct _QRinput { QRinput_List *head; QRinput_List *tail; int mqr; + int fnc1; + unsigned char appid; }; /****************************************************************************** diff --git a/qrspec.h b/qrspec.h index 481e588afc..ff6cd9f97b 100644 --- a/qrspec.h +++ b/qrspec.h @@ -173,8 +173,8 @@ extern void QRspec_clearCache(void); #define QRSPEC_MODEID_AN 2 #define QRSPEC_MODEID_8 4 #define QRSPEC_MODEID_KANJI 8 -#define QRSPEC_MODEID_FNC1A 5 -#define QRSPEC_MODEID_FNC1B 9 +#define QRSPEC_MODEID_FNC1FIRST 5 +#define QRSPEC_MODEID_FNC1SECOND 9 #define QRSPEC_MODEID_STRUCTURE 3 #define QRSPEC_MODEID_TERMINATOR 0 -- cgit 0.0.5-2-1-g0f52 From ad4d46ae745d6134ea18417f82a85920aeca39a6 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 27 Jan 2010 06:24:59 +0000 Subject: --- ChangeLog | 15 +++++++ qrencode.h | 9 ++-- qrinput.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++----- qrinput.h | 10 ++++- qrspec.c | 5 ++- tests/test_qrinput.c | 43 ++++++++++++++++++ 6 files changed, 187 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33094ac1ee..dcc4cd8680 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010.01.27 Kentaro FUKUCHI + * qrinput.c, qrencode.h: + - 8bit encoding improved. + - QRinput_encodeModeECI(), QRinput_appendECIheader(), + QRinput_estimateBitsModeECI() have been added. + * tests/test_qrinput.c: + - Some tests for ECI header have been added. + * qrinput.[ch]: + - STRUCTURE_HEADER_BITS was renamed to STRUCTURE_HEADER_SIZE. + - MODE_INDICATOR_SIZE has been added. + - QRinput_isSplittableMode() has been added. + * qrspec.c: + - QRspec_maximumWords() now returns 0 if the entry cannot be splitted. + - Now includes "qrinput.h" for QRinput_isSplittableMode(). + 2010.01.25 Kentaro FUKUCHI * qrencode.h: - QR_MODE_{ECI,FNC1A,FNC1B} have been added to QRencodeMode. diff --git a/qrencode.h b/qrencode.h index e92f049c68..a1fae73514 100644 --- a/qrencode.h +++ b/qrencode.h @@ -200,12 +200,9 @@ extern QRinput *QRinput_newMQR(int version, QRecLevel level); extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data); /** - * Append data to an input object with ECI header. - * The data is copied and appended to the input object. + * Append ECI header. * @param input input object. - * @param mode encoding mode. - * @param size size of data (byte). - * @param data a pointer to the memory area of the input data. + * @param ecinum ECI indicator number (0 - 999999) * @retval 0 success. * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. @@ -213,7 +210,7 @@ extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const uns * @throw EINVAL input data is invalid. * */ -extern int QRinput_appendECI(QRinput *input, QRencodeMode mode, int size, const unsigned char *data, unsigned int ecinum); +extern int QRinput_appendECIheader(QRinput *input, unsigned int ecinum); /** * Get current version. diff --git a/qrinput.c b/qrinput.c index d0254758f3..259f0083fa 100644 --- a/qrinput.c +++ b/qrinput.c @@ -31,6 +31,14 @@ #include "bitstream.h" #include "qrinput.h" +/****************************************************************************** + * Utilities + *****************************************************************************/ +int QRinput_isSplittableMode(QRencodeMode mode) +{ + return (mode >= QR_MODE_NUM && mode <= QR_MODE_KANJI); +} + /****************************************************************************** * Entry of input data *****************************************************************************/ @@ -262,6 +270,24 @@ __STATIC int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int return 0; } +int QRinput_appendECIheader(QRinput *input, unsigned int ecinum) +{ + unsigned char data[4]; + + if(ecinum > 999999) { + errno = EINVAL; + return -1; + } + + /* We manually create byte array of ecinum because + (unsigned char *)&ecinum may cause bus error on some architectures, */ + data[0] = ecinum & 0xff; + data[1] = (ecinum >> 8) & 0xff; + data[2] = (ecinum >> 16) & 0xff; + data[3] = (ecinum >> 24) & 0xff; + return QRinput_append(input, QR_MODE_ECI, 4, data); +} + void QRinput_free(QRinput *input) { QRinput_List *list, *next; @@ -564,7 +590,7 @@ int QRinput_estimateBitsMode8(int size) */ static int QRinput_encodeMode8(QRinput_List *entry, int version, int mqr) { - int ret, i; + int ret; entry->bstream = BitStream_new(); if(entry->bstream == NULL) return -1; @@ -585,10 +611,8 @@ static int QRinput_encodeMode8(QRinput_List *entry, int version, int mqr) if(ret < 0) goto ABORT; } - for(i=0; isize; i++) { - ret = BitStream_appendNum(entry->bstream, 8, entry->data[i]); - if(ret < 0) goto ABORT; - } + ret = BitStream_appendBytes(entry->bstream, entry->size, entry->data); + if(ret < 0) goto ABORT; return 0; ABORT: @@ -763,6 +787,74 @@ ABORT: return -1; } +/****************************************************************************** + * ECI header + *****************************************************************************/ +static unsigned int QRinput_decodeECIfromByteArray(unsigned char *data) +{ + int i; + unsigned int ecinum; + + ecinum = 0; + for(i=0; i<4; i++) { + ecinum = ecinum << 8; + ecinum |= data[3-i]; + } + + return ecinum; +} + +int QRinput_estimateBitsModeECI(unsigned char *data) +{ + unsigned int ecinum; + + ecinum = QRinput_decodeECIfromByteArray(data);; + + /* See Table 4 of JISX 0510:2004 pp.17. */ + if(ecinum < 128) { + return MODE_INDICATOR_SIZE + 8; + } else if(ecinum < 16384) { + return MODE_INDICATOR_SIZE + 16; + } else { + return MODE_INDICATOR_SIZE + 24; + } +} + +static int QRinput_encodeModeECI(QRinput_List *entry, int version) +{ + int ret, words; + unsigned int ecinum, code; + + entry->bstream = BitStream_new(); + if(entry->bstream == NULL) return -1; + + ecinum = QRinput_decodeECIfromByteArray(entry->data);; + + /* See Table 4 of JISX 0510:2004 pp.17. */ + if(ecinum < 128) { + words = 1; + code = ecinum; + } else if(ecinum < 16384) { + words = 2; + code = 0x8000 + ecinum; + } else { + words = 3; + code = 0xc0000 + ecinum; + } + + ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_ECI); + if(ret < 0) goto ABORT; + + ret = BitStream_appendNum(entry->bstream, words * 8, code); + if(ret < 0) goto ABORT; + + return 0; +ABORT: + BitStream_free(entry->bstream); + entry->bstream = NULL; + return -1; +} + /****************************************************************************** * Validation *****************************************************************************/ @@ -783,7 +875,7 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) case QR_MODE_STRUCTURE: return 0; case QR_MODE_ECI: - return -1; + return 0; case QR_MODE_FNC1FIRST: return 0; case QR_MODE_FNC1SECOND: @@ -828,7 +920,15 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version bits = QRinput_estimateBitsModeKanji(entry->size); break; case QR_MODE_STRUCTURE: - return STRUCTURE_HEADER_BITS; + return STRUCTURE_HEADER_SIZE; + case QR_MODE_ECI: + bits = QRinput_estimateBitsModeECI(entry->data); + break; + case QR_MODE_FNC1FIRST: + return MODE_INDICATOR_SIZE; + break; + case QR_MODE_FNC1SECOND: + return MODE_INDICATOR_SIZE + 8; default: return 0; } @@ -842,7 +942,7 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version m = 1 << l; num = (entry->size + m - 1) / m; - bits += num * (4 + l); // mode indicator (4bits) + length indicator + bits += num * (MODE_INDICATOR_SIZE + l); } return bits; @@ -935,7 +1035,7 @@ __STATIC int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) } maxsize = QRspec_maximumWords(mode, version); if(size < 0) size = 0; - if(size > maxsize) size = maxsize; + if(maxsize > 0 && size > maxsize) size = maxsize; return size; } @@ -960,7 +1060,7 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) } words = QRspec_maximumWords(entry->mode, version); - if(entry->size > words) { + if(words != 0 && entry->size > words) { st1 = QRinput_List_newEntry(entry->mode, words, entry->data); if(st1 == NULL) goto ABORT; st2 = QRinput_List_newEntry(entry->mode, entry->size - words, &entry->data[words]); @@ -996,6 +1096,9 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) case QR_MODE_STRUCTURE: ret = QRinput_encodeModeStructure(entry, mqr); break; + case QR_MODE_ECI: + ret = QRinput_encodeModeECI(entry, version); + break; case QR_MODE_FNC1SECOND: ret = QRinput_encodeModeFNC1Second(entry, version); default: @@ -1492,7 +1595,7 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) } QRinput_Struct_setParity(s, QRinput_calcParity(input)); - maxbits = QRspec_getDataLength(input->version, input->level) * 8 - STRUCTURE_HEADER_BITS; + maxbits = QRspec_getDataLength(input->version, input->level) * 8 - STRUCTURE_HEADER_SIZE; if(maxbits <= 0) { QRinput_Struct_free(s); diff --git a/qrinput.h b/qrinput.h index 0cb1dad29a..73536fab61 100644 --- a/qrinput.h +++ b/qrinput.h @@ -25,6 +25,8 @@ #include "qrencode.h" #include "bitstream.h" +int QRinput_isSplittableMode(QRencodeMode mode); + /****************************************************************************** * Entry of input data *****************************************************************************/ @@ -93,10 +95,16 @@ extern const signed char QRinput_anTable[128]; #define QRinput_lookAnTable(__c__) \ ((__c__ & 0x80)?-1:QRinput_anTable[(int)__c__]) +/** + * Length of a standard mode indicator in bits. + */ + +#define MODE_INDICATOR_SIZE 4 + /** * Length of a segment of structured-append header. */ -#define STRUCTURE_HEADER_BITS 20 +#define STRUCTURE_HEADER_SIZE 20 /** * Maximum number of symbols in a set of structured-appended symbols. diff --git a/qrspec.c b/qrspec.c index 75afaacd2e..e01856cca1 100644 --- a/qrspec.c +++ b/qrspec.c @@ -36,6 +36,7 @@ #endif #include "qrspec.h" +#include "qrinput.h" /****************************************************************************** * Version and capacity @@ -144,7 +145,7 @@ int QRspec_lengthIndicator(QRencodeMode mode, int version) { int l; - if(mode == QR_MODE_STRUCTURE) return 0; + if(!QRinput_isSplittableMode(mode)) return 0; if(version <= 9) { l = 0; } else if(version <= 26) { @@ -162,7 +163,7 @@ int QRspec_maximumWords(QRencodeMode mode, int version) int bits; int words; - if(mode == QR_MODE_STRUCTURE) return 3; + if(!QRinput_isSplittableMode(mode)) return 0; if(version <= 9) { l = 0; } else if(version <= 26) { diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 6be2de4cd4..11606fe651 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -883,6 +883,46 @@ void test_padding2MQR(void) testFinish(); } +void test_ECIinvalid(void) +{ + QRinput *stream; + int ret; + + testStart("Appending invalid ECI header"); + stream = QRinput_new(); + ret = QRinput_appendECIheader(stream, 999999); + assert_zero(ret, "Valid ECI header rejected."); + ret = QRinput_appendECIheader(stream, 1000000); + assert_nonzero(ret, "Invalid ECI header accepted."); + QRinput_free(stream); + testFinish(); +} + +void test_encodeECI(void) +{ + QRinput *input; + BitStream *bstream; + unsigned char str[] = {0xa1, 0xa2, 0xa3, 0xa4, 0xa5}; + char *correct = "0111 00001001 0100 00000101 10100001 10100010 10100011 10100100 10100101"; + int ret; + + testStart("Encoding characters with ECI header."); + input = QRinput_new(); + ret = QRinput_appendECIheader(input, 9); + assert_zero(ret, "Valid ECI header rejected.\n"); + + ret = QRinput_append(input, QR_MODE_8, 5, str); + assert_zero(ret, "Failed to append characters.\n"); + bstream = QRinput_mergeBitStream(input); + assert_nonnull(bstream, "Failed to merge.\n"); + if(bstream != NULL) { + ret = ncmpBin(correct, bstream, 64); + assert_zero(ret, "Encodation of ECI header was invalid.\n"); + BitStream_free(bstream); + } + QRinput_free(input); + testFinish(); +} int main(void) { @@ -922,6 +962,9 @@ int main(void) test_paddingMQR(); test_padding2MQR(); + test_ECIinvalid(); + test_encodeECI(); + report(); return 0; -- cgit 0.0.5-2-1-g0f52 From 07fa75be848b766aaacfa6bc746a60bed37d6eb5 Mon Sep 17 00:00:00 2001 From: fukuchi Date: Wed, 3 Feb 2010 05:22:32 +0000 Subject: Merged with 3.1.1. --- ChangeLog | 7 +++++++ NEWS | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index dcc4cd8680..2ff0de21b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010.02.03 Kentaro FUKUCHI + [3.1.1] + * qrencode.c, README: + - Copyright year updates. + * Bumped vertion to 3.1.1. + * Version 3.1.1 has been released. + 2010.01.27 Kentaro FUKUCHI * qrinput.c, qrencode.h: - 8bit encoding improved. diff --git a/NEWS b/NEWS index 11f7b86cd5..a395eebcf6 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,16 @@ Binary data including '\0' can be encoded now with qrencode. To encode a binary data, give "-8" option to qrencode, and let qrencode obtain data via standard input like "qrencode -8 -o output.png < binary". +Version 3.1.1 (2010.2.3) +------------------------ +* A bug in the library has been fixed. + +Release Note: + +Libqrecode had generated incorrect QR Code in some cases. Symbols larger than +version 5 (error correction level Q and H) were affected. In many cases this +bug did not cause serious damage thanks to the error correction mechanism, but +we highly recommend you to encode symbols again using this release. Version 3.1.0 (2009.6.6) ------------------------ -- cgit 0.0.5-2-1-g0f52 From 24f71365289459cc8926535f60fa722041f86f30 Mon Sep 17 00:00:00 2001 From: "kentaro@fukuchi.org" Date: Sat, 9 Oct 2010 09:06:12 +0900 Subject: Added hgignore. --- .hgignore | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .hgignore diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000000..f76fec91a6 --- /dev/null +++ b/.hgignore @@ -0,0 +1,44 @@ +syntax:glob +.deps/ +.libs/ +autom4te.cache/ +m4/ +Makefile +Makefile.in +config.log +configure +config.status +config.h +config.h.in +aclocal.m4 +libtool +stamp-h1 +qrencode +qrencode.1 +qrencode.spec +libqrencode.pc +tests/create_frame_pattern +tests/create_mqr_frame_pattern +tests/frame +tests/mqrframe +tests/prof_qrencode +tests/test_bitstream +tests/test_estimatebit +tests/test_mask +tests/test_mmask +tests/test_monkey +tests/test_mqrspec +tests/test_qrencode +tests/test_qrinput +tests/test_qrspec +tests/test_rs +tests/test_split +tests/view_qrcode +use/compile +use/config.guess +use/config.rpath +use/config.sub +use/depcomp +use/install-sh +use/ltmain.sh +use/missing -- cgit 0.0.5-2-1-g0f52 From 68a8a6b63b8d8993c18429ea57202b65cd7db37b Mon Sep 17 00:00:00 2001 From: "kentaro@fukuchi.org" Date: Sat, 9 Oct 2010 10:49:22 +0900 Subject: Copyright year and mail addresses updated. --- ChangeLog | 7 ++++++- README | 6 +++--- bitstream.c | 2 +- bitstream.h | 2 +- mask.c | 2 +- mask.h | 2 +- mmask.c | 2 +- mmask.h | 2 +- mqrspec.c | 2 +- mqrspec.h | 2 +- qrenc.c | 4 ++-- qrencode.1.in | 2 +- qrencode.c | 2 +- qrencode.h | 2 +- qrencode.spec.in | 6 ++++-- qrencode_inner.h | 2 +- qrinput.c | 2 +- qrinput.h | 2 +- qrspec.c | 2 +- qrspec.h | 2 +- rscode.c | 2 +- rscode.h | 2 +- split.c | 2 +- split.h | 2 +- tests/view_qrcode.c | 2 +- 25 files changed, 36 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ff0de21b6..03cff15c6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,13 @@ +2010.10.09 Kentaro FUKUCHI + * Copyright year and mail address were updated. + * README, qrencode.spec.in + - The URL of qrencode's page has been updated. + 2010.02.03 Kentaro FUKUCHI [3.1.1] * qrencode.c, README: - Copyright year updates. - * Bumped vertion to 3.1.1. + * Bumped version to 3.1.1. * Version 3.1.1 has been released. 2010.01.27 Kentaro FUKUCHI diff --git a/README b/README index ee8640467c..d650f44a6e 100644 --- a/README +++ b/README @@ -73,7 +73,7 @@ You should limit the parameter by your application. LICENSING INFORMATION ===================== -Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi +Copyright (C) 2006-2010 Kentaro Fukuchi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free @@ -92,12 +92,12 @@ CONTACTS ======== Visit the homepage at: -http://megaui.net/fukuchi/works/qrencode/index.en.html +http://fukuchi.org/works/qrencode/index.en.html for new releases. Please mail any bug reports, suggestions, comments and questions to -Kentaro Fukuchi . Questions of license compliance +Kentaro Fukuchi . Questions of license compliance are also welcome. diff --git a/bitstream.c b/bitstream.c index 36a8ee6e2b..fb58a4d119 100644 --- a/bitstream.c +++ b/bitstream.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Binary sequence class. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/bitstream.h b/bitstream.h index 5a5ac90496..85049edf89 100644 --- a/bitstream.h +++ b/bitstream.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Binary sequence class. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mask.c b/mask.c index d6ee8d0227..70a668aed0 100644 --- a/mask.c +++ b/mask.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mask.h b/mask.h index 4ce80c5dff..2b8ff2f711 100644 --- a/mask.h +++ b/mask.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mmask.c b/mmask.c index 7999c90612..1bbf71e2ff 100644 --- a/mmask.c +++ b/mmask.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking for Micro QR Code. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mmask.h b/mmask.h index 627dc32e1a..a37de1059d 100644 --- a/mmask.h +++ b/mmask.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking for Micro QR Code. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mqrspec.c b/mqrspec.c index a38bd8fde3..ddb1fcfa03 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Micor QR Code specification in convenient format. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/mqrspec.h b/mqrspec.h index fc98454ff2..546cb875bc 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Micro QR Code specification in convenient format. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrenc.c b/qrenc.c index 89e1c16c95..f0ed56aca2 100644 --- a/qrenc.c +++ b/qrenc.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code encoding tool - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -64,7 +64,7 @@ static void usage(int help, int longopt) { fprintf(stderr, "qrencode version %s\n" -"Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi\n", VERSION); +"Copyright (C) 2006-2010 Kentaro Fukuchi\n", VERSION); if(help) { if(longopt) { fprintf(stderr, diff --git a/qrencode.1.in b/qrencode.1.in index 85b26047bc..958468b622 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -70,4 +70,4 @@ case-insensitive mode. Written by Kentaro Fukuchi. .SH COPYRIGHT -Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi. +Copyright (C) 2006, 2007, 2008, 2009, 2010 Kentaro Fukuchi. diff --git a/qrencode.c b/qrencode.c index 4c0816e10a..2a580f5876 100644 --- a/qrencode.c +++ b/qrencode.c @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrencode.h b/qrencode.h index a1fae73514..b9d287b535 100644 --- a/qrencode.h +++ b/qrencode.h @@ -1,7 +1,7 @@ /** * qrencode - QR Code encoder * - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrencode.spec.in b/qrencode.spec.in index f03947ade6..51543947ae 100644 --- a/qrencode.spec.in +++ b/qrencode.spec.in @@ -8,8 +8,8 @@ Summary: Libqrencode is a library for encoding data in a QR Code symbol, Group: System Environment/Libraries License: LGPLv2+ -URL: http://megaui.net/fukuchi/works/qrencode/ -Source0: http://megaui.net/fukuchi/works/qrencode/%{name}-%{version}.tar.gz +URL: http://fukuchi.org/works/qrencode/ +Source0: http://fukuchi.org/works/qrencode/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description @@ -62,6 +62,8 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/pkgconfig/libqrencode.pc %changelog +* Sat Oct 09 2010 Kentaro Fukuchi 3.9.0-1 +- URL and Source0 have been updated. * Fri May 01 2008 Kentaro Fukuchi 3.0.1-1 - The man page has been packaged correctly. * Tue May 15 2007 Kentaro Fukuchi 1.0.2-2 diff --git a/qrencode_inner.h b/qrencode_inner.h index 6f7b36b0de..40a0edc8b1 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Header for test use - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrinput.c b/qrinput.c index 259f0083fa..f421b62049 100644 --- a/qrinput.c +++ b/qrinput.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrinput.h b/qrinput.h index 73536fab61..c2332a80ce 100644 --- a/qrinput.h +++ b/qrinput.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrspec.c b/qrspec.c index e01856cca1..29ce2f7b4a 100644 --- a/qrspec.c +++ b/qrspec.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code specification in convenient format. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/qrspec.h b/qrspec.h index ff6cd9f97b..31a35fc86a 100644 --- a/qrspec.h +++ b/qrspec.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code specification in convenient format. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/rscode.c b/rscode.c index 379e95b106..1017601777 100644 --- a/rscode.c +++ b/rscode.c @@ -7,7 +7,7 @@ * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * (libfec is released under the GNU Lesser General Public License.) * - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/rscode.h b/rscode.h index 0f212c8d40..c6830b3076 100644 --- a/rscode.h +++ b/rscode.h @@ -7,7 +7,7 @@ * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * (libfec is released under the GNU Lesser General Public License.) * - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/split.c b/split.c index 4bb8e55b1c..0e5314b25c 100644 --- a/split.c +++ b/split.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/split.h b/split.h index 6a495e4910..37e6d86dcf 100644 --- a/split.h +++ b/split.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * Copyright (C) 2006-2010 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index a9d39d905e..dc3940d4b8 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -47,7 +47,7 @@ static void usage(int help, int longopt) { fprintf(stderr, "view_qrcode version %s\n" -"Copyright (C) 2008, 2009 Kentaro Fukuchi\n", VERSION); +"Copyright (C) 2008, 2009, 2010 Kentaro Fukuchi\n", VERSION); if(help) { if(longopt) { fprintf(stderr, -- cgit 0.0.5-2-1-g0f52 From 7c2e28050dc7a57b444e66bf1b75e50edf98179e Mon Sep 17 00:00:00 2001 From: "kentaro@fukuchi.org" Date: Sat, 9 Oct 2010 10:54:32 +0900 Subject: Added ACLOCAL_AMFLAGS suggested by libtoolize. --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 7d9c238e6b..55659c51b1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,5 @@ AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS=-I m4 SUBDIRS = . -- cgit 0.0.5-2-1-g0f52 From b1aee1f76dafc034848141542c23a1b11a9880e4 Mon Sep 17 00:00:00 2001 From: "kentaro@fukuchi.org" Date: Sat, 9 Oct 2010 10:56:20 +0900 Subject: Small package maintenance. --- .hgignore | 1 - ChangeLog | 5 + use/config.rpath | 666 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 671 insertions(+), 1 deletion(-) create mode 100755 use/config.rpath diff --git a/.hgignore b/.hgignore index f76fec91a6..5aea0f4eb0 100644 --- a/.hgignore +++ b/.hgignore @@ -36,7 +36,6 @@ tests/test_split tests/view_qrcode use/compile use/config.guess -use/config.rpath use/config.sub use/depcomp use/install-sh diff --git a/ChangeLog b/ChangeLog index 03cff15c6a..2cd53fcba3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ * Copyright year and mail address were updated. * README, qrencode.spec.in - The URL of qrencode's page has been updated. + * Makefile.am: + - Added ACLOCAL_AMFLAGS. + * use/config.rpath: + - Now explicitly included because required by AM_ICONV_LINK in + configure.ac. 2010.02.03 Kentaro FUKUCHI [3.1.1] diff --git a/use/config.rpath b/use/config.rpath new file mode 100755 index 0000000000..c547c68825 --- /dev/null +++ b/use/config.rpath @@ -0,0 +1,666 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2007 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + darwin*) + case $cc_basename in + xlc*) + wl='-Wl,' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + newsos6) + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc*) + wl='-Wl,' + ;; + pgcc | pgf77 | pgf90) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + wl='-Wl,' + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we cannot use + # them. + ld_shlibs=no + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if test "$GCC" = yes ; then + : + else + case $cc_basename in + xlc*) + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd1*) + ld_shlibs=no + ;; + freebsd2.2*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + freebsd2*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix4* | aix5*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + library_names_spec='$libname.a' + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd1*) + ;; + freebsd* | dragonfly*) + case "$host_os" in + freebsd[123]*) + library_names_spec='$libname$shrext$versuffix' ;; + *) + library_names_spec='$libname$shrext' ;; + esac + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + nto-qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' < Date: Sun, 2 Jan 2011 13:56:17 +0900 Subject: Info. message improved. --- tests/test_bitstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index b9449bbb57..11b63cbe17 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -11,7 +11,7 @@ void test_null(void) bstream = BitStream_new(); assert_zero(BitStream_size(bstream), "Size of empty BitStream is not 0.\n"); assert_null(BitStream_toByte(bstream), "BitStream_toByte returned non-NULL.\n"); - assert_nothing(BitStream_free(NULL), "Check BitStream_free(NULL).\n"); + assert_nothing(BitStream_free(NULL), "Checking BitStream_free(NULL).\n"); testFinish(); BitStream_free(bstream); -- cgit 0.0.5-2-1-g0f52 From d5fd940367464c877b0778ee8c4b495ac14b9aaf Mon Sep 17 00:00:00 2001 From: "kentaro@fukuchi.org" Date: Wed, 9 Feb 2011 23:15:14 +0900 Subject: Small bug fix. --- ChangeLog | 4 ++++ tests/view_qrcode.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2cd53fcba3..11fd4fa75d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011.02.09 Kentaro FUKUCHI + * tests/view_qrcode.c: + - "-h" had required an argument. + 2010.10.09 Kentaro FUKUCHI * Copyright year and mail address were updated. * README, qrencode.spec.in diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index dc3940d4b8..9602d75024 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -40,7 +40,7 @@ static const struct option options[] = { {NULL, 0, NULL, 0} }; -static char *optstring = "h:l:s:v:m:Skci8MV"; +static char *optstring = "hl:s:v:m:Skci8MV"; static char levelChar[4] = {'L', 'M', 'Q', 'H'}; static void usage(int help, int longopt) -- cgit 0.0.5-2-1-g0f52 From c9b8d24e4a90f21b39837322777ac884e2614175 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Feb 2011 16:01:44 +0900 Subject: Synchronized to the Mercurial source tree. --- .hgignore | 43 ------------------------------------------- NEWS | 2 +- TODO | 9 --------- 3 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 .hgignore diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 5aea0f4eb0..0000000000 --- a/.hgignore +++ /dev/null @@ -1,43 +0,0 @@ -syntax:glob -.deps/ -.libs/ -autom4te.cache/ -m4/ -Makefile -Makefile.in -config.log -configure -config.status -config.h -config.h.in -aclocal.m4 -libtool -stamp-h1 -qrencode -qrencode.1 -qrencode.spec -libqrencode.pc -tests/create_frame_pattern -tests/create_mqr_frame_pattern -tests/frame -tests/mqrframe -tests/prof_qrencode -tests/test_bitstream -tests/test_estimatebit -tests/test_mask -tests/test_mmask -tests/test_monkey -tests/test_mqrspec -tests/test_qrencode -tests/test_qrinput -tests/test_qrspec -tests/test_rs -tests/test_split -tests/view_qrcode -use/compile -use/config.guess -use/config.sub -use/depcomp -use/install-sh -use/ltmain.sh -use/missing diff --git a/NEWS b/NEWS index a395eebcf6..298aaba1fa 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.9.0 (2010.x.x) +Version 3.9.0 (2011.x.x) ------------------------ * Micro QR Code support has been added. * "--micro" (or "-M") option for Micro QR Code has been added to qrencode. diff --git a/TODO b/TODO index 8564ee9a4b..cc9ec194cb 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,3 @@ -Thread unsafe. -Only two functions, QRspec_newFrame() and init_rs(), are thread unsafe, but -most of qrencode functions are thread unsafe because of them. - -This package contains -*.c and *.h files (total): 8077 lines, 198863 bytes. -configure script : 22539 lines, 725612 bytes. -It's absolutely crazy. - Documents (not only the README, but also the manual of the library) needs revision of grammer, spell or to resolve ambiguity or incomplete descriptions. Feel really free to send us your revision. -- cgit 0.0.5-2-1-g0f52 From ea3b5904c39c3ad0954f867676ce85e16ebf389f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 5 May 2011 19:41:09 +0900 Subject: Unneeded report() has been removed. --- tests/test_monkey.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_monkey.c b/tests/test_monkey.c index ab071d1ef7..208cb4fa90 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -563,7 +563,5 @@ int main(int argc, char **argv) QRcode_clearCache(); - report(); - return 0; } -- cgit 0.0.5-2-1-g0f52 From fb22c96a17360e7e451d3e38a2ade73841a7f0f2 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 5 May 2011 19:45:05 +0900 Subject: All you need is .gitignore. --- .gitignore | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..5a1412ebe0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +*.gcno +*.gcov +*.gcda +.deps/ +.libs/ +autom4te.cache/ +m4/ +Makefile +Makefile.in +config.log +configure +config.status +config.h +config.h.in +aclocal.m4 +libtool +stamp-h1 +qrencode +qrencode.1 +qrencode.spec +libqrencode.pc +tests/create_frame_pattern +tests/create_mqr_frame_pattern +tests/frame +tests/mqrframe +tests/prof_qrencode +tests/test_bitstream +tests/test_estimatebit +tests/test_mask +tests/test_mmask +tests/test_monkey +tests/test_mqrspec +tests/test_qrencode +tests/test_qrinput +tests/test_qrspec +tests/test_rs +tests/test_split +tests/view_qrcode +use/compile +use/config.guess +use/config.sub +use/depcomp +use/install-sh +use/ltmain.sh +use/missing -- cgit 0.0.5-2-1-g0f52 From 639b4ca333ecc2412d1e479ebb4d44837acc7e0f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 5 May 2011 19:48:06 +0900 Subject: strdup() code has been added for non-POSIX environments. --- split.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/split.c b/split.c index 0e5314b25c..cfe2a11c67 100644 --- a/split.c +++ b/split.c @@ -7,7 +7,7 @@ * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) * or - * "Automatic identification and data capture techniques -- + * "Automatic identification and data capture techniques -- * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) * * This library is free software; you can redistribute it and/or @@ -25,6 +25,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include @@ -36,6 +39,17 @@ #define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10) #define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0) +#if !HAVE_STRDUP +#undef strdup +char *strdup(const char *s) +{ + size_t len = strlen(s) + 1; + void *new = malloc(len); + if(new == NULL) return NULL; + return (char *)memcpy(new, s, len); +} +#endif + static QRencodeMode Split_identifyMode(const char *string, QRencodeMode hint) { unsigned char c, d; -- cgit 0.0.5-2-1-g0f52 From 251f58ec6187862183a728d2e45c0a69af505a93 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 5 May 2011 19:48:31 +0900 Subject: Added AC_CHECK_FUNC([strdup]) for non-POSIX environments. / Now mudflapth is used instead of mudflap when pthread is enabled. --- configure.ac | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 41ed4674df..479fc3a019 100644 --- a/configure.ac +++ b/configure.ac @@ -31,6 +31,8 @@ PKG_PROG_PKG_CONFIG AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1]) +AC_CHECK_FUNCS([strdup]) + dnl --enable-thread-safety AC_ARG_ENABLE([thread-safety], [AS_HELP_STRING([--enable-thread-safety], [make the library thread-safe. [default=yes]])], [], [enable_thread_safety=yes]) @@ -100,8 +102,13 @@ AC_ARG_ENABLE([mudflap], [AS_HELP_STRING([--enable-mudflap], [generate extra cod [], [enable_mudflap=no]) if test x$enable_mudflap = xyes; then - CFLAGS="$CFLAGS -fmudflap" - LDFLAGS="$LDFLAGS -lmudflap" + if test x$enable_thread_safety = xyes; then + CFLAGS="$CFLAGS -fmudflapth" + LDFLAGS="$LDFLAGS -lmudflapth" + else + CFLAGS="$CFLAGS -fmudflap" + LDFLAGS="$LDFLAGS -lmudflap" + fi fi -- cgit 0.0.5-2-1-g0f52 From 4cbbca7462cca1cdee0b9c5389908269ad40f9d5 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 5 May 2011 19:49:17 +0900 Subject: config.h is now included at the top of the code. --- bitstream.c | 3 +++ mask.c | 5 ++++- mmask.c | 5 ++++- mqrspec.c | 5 +++-- qrenc.c | 4 +++- qrencode.c | 4 +++- qrinput.c | 6 ++++-- qrspec.c | 5 +++-- rscode.c | 8 +++++--- 9 files changed, 32 insertions(+), 13 deletions(-) diff --git a/bitstream.c b/bitstream.c index fb58a4d119..1504634220 100644 --- a/bitstream.c +++ b/bitstream.c @@ -19,6 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include diff --git a/mask.c b/mask.c index 70a668aed0..cb0952fd90 100644 --- a/mask.c +++ b/mask.c @@ -19,11 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "config.h" +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include #include + #include "qrencode.h" #include "qrspec.h" #include "mask.h" diff --git a/mmask.c b/mmask.c index 1bbf71e2ff..2b36d7c18d 100644 --- a/mmask.c +++ b/mmask.c @@ -19,11 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "config.h" +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include #include + #include "qrencode.h" #include "mqrspec.h" #include "mmask.h" diff --git a/mqrspec.c b/mqrspec.c index ddb1fcfa03..bfd618b565 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -25,8 +25,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "config.h" - +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include diff --git a/qrenc.c b/qrenc.c index f0ed56aca2..b185e1a53f 100644 --- a/qrenc.c +++ b/qrenc.c @@ -19,12 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include #include -#include "config.h" #include "qrencode.h" #define INCHES_PER_METER (100.0/2.54) diff --git a/qrencode.c b/qrencode.c index 2a580f5876..eaa0a72edf 100644 --- a/qrencode.c +++ b/qrencode.c @@ -18,12 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include #include -#include "config.h" #include "qrencode.h" #include "qrspec.h" #include "mqrspec.h" diff --git a/qrinput.c b/qrinput.c index f421b62049..565c0d5173 100644 --- a/qrinput.c +++ b/qrinput.c @@ -19,12 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include #include -#include "config.h" #include "qrencode.h" #include "qrspec.h" #include "mqrspec.h" @@ -1322,7 +1324,7 @@ DONE: static int QRinput_insertFNC1Header(QRinput *input) { - QRinput_List *entry; + QRinput_List *entry = NULL; if(input->fnc1 == 1) { entry = QRinput_List_newEntry(QR_MODE_FNC1FIRST, 0, NULL); diff --git a/qrspec.c b/qrspec.c index 29ce2f7b4a..4d40d10a26 100644 --- a/qrspec.c +++ b/qrspec.c @@ -25,8 +25,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "config.h" - +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include #include diff --git a/rscode.c b/rscode.c index 1017601777..2e32512a7f 100644 --- a/rscode.c +++ b/rscode.c @@ -24,15 +24,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +# include "config.h" +#endif #include #include -#include "config.h" -#include "rscode.h" - #ifdef HAVE_LIBPTHREAD # include #endif +#include "rscode.h" + /* Stuff specific to the 8-bit symbol version of the general purpose RS codecs * */ -- cgit 0.0.5-2-1-g0f52 From 0bd2b714231440f042fbfe4d662ed3bd0d82002f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 5 May 2011 19:50:02 +0900 Subject: . --- ChangeLog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index 11fd4fa75d..eb1f13795b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2011.05.05 Kentaro FUKUCHI + * split.c: + - strdup() code has been added for non-POSIX environments. (Thanks to + Seth Sims) + * configure.ac: + - Added AC_CHECK_FUNC([strdup]) for non-POSIX environments. + - Now mudflapth is used instead of mudflap when pthread is enabled. + * *.c: + - '#include "config.h"' has been moved to the top of the code and + wrapped with #if HAVE_CONFIG_H - #endif. + +2011.04.06 Kentaro FUKUCHI + * qrinput.c: + - Initializaion was missed in QRinput_insertFNC1Header(). + 2011.02.09 Kentaro FUKUCHI * tests/view_qrcode.c: - "-h" had required an argument. -- cgit 0.0.5-2-1-g0f52 From 22815cc51f4c50ff109d49a052e3106bc02cbf93 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 May 2011 13:17:03 +0900 Subject: Documents updated. --- qrencode.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/qrencode.h b/qrencode.h index b9d287b535..d6d33314ac 100644 --- a/qrencode.h +++ b/qrencode.h @@ -391,7 +391,7 @@ struct _QRcode_List { /** * Create a symbol from the input data. - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. * @param input input data. * @return an instance of QRcode class. The version of the result QRcode may * be larger than the designated version. On error, NULL is returned, @@ -405,7 +405,7 @@ extern QRcode *QRcode_encodeInput(QRinput *input); /** * Create a symbol from the string. The library automatically parses the input * string and encodes in a QR Code symbol. - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. * @param string input string. It must be NUL terminated. * @param version version of the symbol. If 0, the library chooses the minimum * version for the given input data. @@ -428,25 +428,25 @@ extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel le /** * Same to QRcode_encodeString(), but encode whole data in 8-bit mode. - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. */ extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level); /** * Micro QR Code version of QRcode_encodeString(). - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. */ extern QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); /** * Micro QR Code version of QRcode_encodeString8bit(). - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. */ extern QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level); /** * Encode byte stream (may include '\0') in 8-bit mode. - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. * @param size size of the input data. * @param data input data. * @param version version of the symbol. If 0, the library chooses the minimum @@ -460,7 +460,7 @@ extern QRcode *QRcode_encodeData(int size, const unsigned char *data, int versio /** * Micro QR Code version of QRcode_encodeData(). - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. */ extern QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level); @@ -472,7 +472,7 @@ extern void QRcode_free(QRcode *qrcode); /** * Create structured symbols from the input data. - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. * @param s * @return a singly-linked list of QRcode. */ @@ -481,7 +481,7 @@ extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s); /** * Create structured symbols from the string. The library automatically parses * the input string and encodes in a QR Code symbol. - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. * @param string input string. It must be NUL terminated. * @param version version of the symbol. * @param level error correction level. @@ -500,14 +500,14 @@ extern QRcode_List *QRcode_encodeStringStructured(const char *string, int versio /** * Same to QRcode_encodeStringStructured(), but encode whole data in 8-bit mode. - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. */ extern QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level); /** * Create structured symbols from byte stream (may include '\0'). Wholde data * are encoded in 8-bit mode. - * @warning This function is THREAD UNSAFE. + * @warning This function is THREAD UNSAFE when pthread is disabled. * @param size size of the input data. * @param data input dat. * @param version version of the symbol. -- cgit 0.0.5-2-1-g0f52 From 6ee1e1ff956dcdcd87644f70d4272b7cd38e1929 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 7 Aug 2011 06:05:23 +0900 Subject: Cflags has been set. (issue #2) --- ChangeLog | 4 ++++ libqrencode.pc.in | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index eb1f13795b..e0a0911819 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011.08.07 Kentaro FUKUCHI + * libqrencode.pc.in: + - Cflags has been set. (issue #2)(Thanks to ryo-on) + 2011.05.05 Kentaro FUKUCHI * split.c: - strdup() code has been added for non-POSIX environments. (Thanks to diff --git a/libqrencode.pc.in b/libqrencode.pc.in index c640f274fd..ac4673d3f7 100644 --- a/libqrencode.pc.in +++ b/libqrencode.pc.in @@ -7,3 +7,4 @@ Name: libqrencode Description: A QR Code encoding library Version: @VERSION@ Libs: -L${libdir} -lqrencode @LIBPTHREAD@ +Cflags: -I${includedir} -- cgit 0.0.5-2-1-g0f52 From e11ef8349d3a8b13e00f712f78a1cd4161751583 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 13 Aug 2011 13:01:52 +0900 Subject: Added "AC_PROG_RANLIB" (bug report from dev66) --- ChangeLog | 4 ++++ configure.ac | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index e0a0911819..f791a684ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011.08.13 Kentaro FUKUCHI + * configure.ac: + - Added "AC_PROG_RANLIB" (bug report from dev66) + 2011.08.07 Kentaro FUKUCHI * libqrencode.pc.in: - Cflags has been set. (issue #2)(Thanks to ryo-on) diff --git a/configure.ac b/configure.ac index 479fc3a019..d25c67d088 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,7 @@ AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL AC_PROG_LIBTOOL +AC_PROG_RANLIB PKG_PROG_PKG_CONFIG AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1]) -- cgit 0.0.5-2-1-g0f52 From a0a187ef7f78089f82d6c4a60c7e104076e8a150 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 13 Oct 2011 18:16:35 +0900 Subject: Mask_calcN2() has been refactored out from Mask_evaluateSymbol(). --- mask.c | 33 +++++++++++++++++++++++++-------- mask.h | 1 + 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/mask.c b/mask.c index cb0952fd90..f85bd7f97b 100644 --- a/mask.c +++ b/mask.c @@ -218,27 +218,44 @@ static int Mask_calcN1N3(int length, int *runLength) return demerit; } -__STATIC int Mask_evaluateSymbol(int width, unsigned char *frame) +__STATIC int Mask_calcN2(int width, unsigned char *frame) { int x, y; unsigned char *p; unsigned char b22, w22; + int demerit = 0; + + p = frame + width + 1; + for(y=1; y 0 && y > 0) { - b22 = p[0] & p[-1] & p[-width] & p [-width-1]; - w22 = p[0] | p[-1] | p[-width] | p [-width-1]; - if((b22 | (w22 ^ 1))&1) { - demerit += N2; - } - } if(x == 0 && (p[0] & 1)) { runLength[0] = -1; head = 1; diff --git a/mask.h b/mask.h index 2b8ff2f711..14e23236e6 100644 --- a/mask.h +++ b/mask.h @@ -26,6 +26,7 @@ extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, Q extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); #ifdef WITH_TESTS +extern int Mask_calcN2(int width, unsigned char *frame); extern int Mask_evaluateSymbol(int width, unsigned char *frame); extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); -- cgit 0.0.5-2-1-g0f52 From 4a9ee6538d3efb79dea1be834c697fb3cf552bc1 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 13 Oct 2011 18:17:20 +0900 Subject: New test code for Mask_calcN2 has been added. --- ChangeLog | 6 ++++++ tests/test_mask.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/ChangeLog b/ChangeLog index f791a684ba..7f1baad0e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011.10.13 Kentaro FUKUCHI + * mask.[ch]: + - Mask_calcN2() has been refactored out from Mask_evaluateSymbol(). + * test/test_mask.c: + - New test code for Mask_calcN2 has been added. + 2011.08.13 Kentaro FUKUCHI * configure.ac: - Added "AC_PROG_RANLIB" (bug report from dev66) diff --git a/tests/test_mask.c b/tests/test_mask.c index d7e1c18908..0f14e82ac0 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -197,6 +197,44 @@ void test_eval2(void) free(frame); } +void test_calcN2(void) +{ + unsigned char frame[64]; + int width; + int demerit; + int x, y; + + testStart("Test mask evaluation (2x2 block check)"); + width = 4; + for(y = 0; y < width; y++) { + for(x = 0; x < width; x++) { + frame[y * width + x] = ((x & 2) ^ (y & 2)) >> 1; + } + } + demerit = Mask_calcN2(width, frame); + assert_equal(demerit, N2 * 4, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 4); + + width = 4; + for(y = 0; y < width; y++) { + for(x = 0; x < width; x++) { + frame[y * width + x] = (((x + 1) & 2) ^ (y & 2)) >> 1; + } + } + demerit = Mask_calcN2(width, frame); + assert_equal(demerit, N2 * 2, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 2); + + width = 6; + for(y = 0; y < width; y++) { + for(x = 0; x < width; x++) { + frame[y * width + x] = (x / 3) ^ (y / 3); + } + } + demerit = Mask_calcN2(width, frame); + assert_equal(demerit, N2 * 16, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 16); + + testFinish(); +} + void test_eval3(void) { unsigned char *frame; @@ -273,6 +311,7 @@ int main(void) test_eval2(); test_eval3(); test_format(); + test_calcN2(); report(); -- cgit 0.0.5-2-1-g0f52 From acfd9a249a5011c1bc0d15c7435921e1de6184a0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 13 Oct 2011 18:33:36 +0900 Subject: Added a URL of the git repository has been added. --- ChangeLog | 2 ++ README | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f1baad0e3..32b6c8eda0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ - Mask_calcN2() has been refactored out from Mask_evaluateSymbol(). * test/test_mask.c: - New test code for Mask_calcN2 has been added. + * README: + - Added a URL to the git repository. 2011.08.13 Kentaro FUKUCHI * configure.ac: diff --git a/README b/README index d650f44a6e..eb469aaf69 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 4.0.0 - QR Code encoding library +libqrencode 3.9.0 - QR Code encoding library GENERAL INFORMATION =================== @@ -94,7 +94,9 @@ Visit the homepage at: http://fukuchi.org/works/qrencode/index.en.html -for new releases. +for new releases. The git repository is available at: + +https://github.com/fukuchi/libqrencode Please mail any bug reports, suggestions, comments and questions to Kentaro Fukuchi . Questions of license compliance -- cgit 0.0.5-2-1-g0f52 From 296e79216ba3ee33e131817daeae22fbe4f573be Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 16 Oct 2011 14:21:03 +0900 Subject: Mask_calcRunLength() has been refactored out from Mask_evaluateSymbol(). New test code for Mask_calcRunLength has been added. --- ChangeLog | 6 +++++ mask.c | 80 +++++++++++++++++++++++++++---------------------------- mask.h | 1 + tests/test_mask.c | 40 ++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32b6c8eda0..c09fb21ff1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011.10.16 Kentaro FUKUCHI + * mask.[ch]: + - Mask_calcRunLength() has been refactored out from Mask_evaluateSymbol(). + * test/test_mask.c: + - New test code for Mask_calcRunLength has been added. + 2011.10.13 Kentaro FUKUCHI * mask.[ch]: - Mask_calcN2() has been refactored out from Mask_evaluateSymbol(). diff --git a/mask.c b/mask.c index f85bd7f97b..d88e92e9e7 100644 --- a/mask.c +++ b/mask.c @@ -185,7 +185,7 @@ unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLeve //static int n3; //static int n4; -static int Mask_calcN1N3(int length, int *runLength) +__STATIC int Mask_calcN1N3(int length, int *runLength) { int i; int demerit = 0; @@ -241,58 +241,56 @@ __STATIC int Mask_calcN2(int width, unsigned char *frame) return demerit; } +__STATIC int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *runLength) +{ + int head; + int i; + unsigned char *p; + int pitch; + + pitch = (dir==0)?1:width; + for(i=0; i 0) { - if((p[0] ^ p[-1]) & 1) { - head++; - runLength[head] = 1; - } else { - runLength[head]++; - } - } - p++; - } - demerit += Mask_calcN1N3(head+1, runLength); + length = Mask_calcRunLength(width, frame + y * width, 0, runLength); + demerit += Mask_calcN1N3(length, runLength); } for(x=0; x 0) { - if((p[0] ^ p[-width]) & 1) { - head++; - runLength[head] = 1; - } else { - runLength[head]++; - } - } - p+=width; - } - demerit += Mask_calcN1N3(head+1, runLength); + length = Mask_calcRunLength(width, frame + x, 1, runLength); + demerit += Mask_calcN1N3(length, runLength); } return demerit; diff --git a/mask.h b/mask.h index 14e23236e6..f376608d27 100644 --- a/mask.h +++ b/mask.h @@ -27,6 +27,7 @@ extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level #ifdef WITH_TESTS extern int Mask_calcN2(int width, unsigned char *frame); +extern int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *runLength); extern int Mask_evaluateSymbol(int width, unsigned char *frame); extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); diff --git a/tests/test_mask.c b/tests/test_mask.c index 0f14e82ac0..c36384f235 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -303,6 +303,45 @@ void test_format(void) testFinish(); } +void test_calcRunLength(void) +{ + int width = 5; + unsigned char frame[width * width]; + int runLength[width + 1]; + int i, j; + int length; + static unsigned char pattern[6][5] = { + {0, 1, 0, 1, 0}, + {1, 0, 1, 0, 1}, + {0, 0, 0, 0, 0}, + {1, 1, 1, 1, 1}, + {0, 0, 1, 1, 1}, + {1, 1, 0, 0, 0} + }; + static int expected[6][7] = { + { 1, 1, 1, 1, 1, 0, 5}, + {-1, 1, 1, 1, 1, 1, 6}, + { 5, 0, 0, 0, 0, 0, 1}, + {-1, 5, 0, 0, 0, 0, 2}, + { 2, 3, 0, 0, 0, 0, 2}, + {-1, 2, 3, 0, 0, 0, 3} + }; + + testStart("Test runlength calc function"); + for(i=0; i<6; i++) { + length = Mask_calcRunLength(width, pattern[i], 0, runLength); + assert_equal(expected[i][6], length, "Length incorrect: %d, expected %d.\n", length, expected[i][6]); + assert_zero(memcmp(runLength, expected[i], sizeof(int) * (width + 1)), "Run length does not match: pattern %d, horizontal access.\n", i); + for(j=0; j Date: Mon, 17 Oct 2011 18:54:56 +0900 Subject: Various bug fixes. (Thanks to Adam Shepherd) --- mask.c | 19 +++++++++---------- mask.h | 3 ++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mask.c b/mask.c index d88e92e9e7..bc3d340dfd 100644 --- a/mask.c +++ b/mask.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -203,10 +203,10 @@ __STATIC int Mask_calcN1N3(int length, int *runLength) runLength[i-1] == fact && runLength[i+1] == fact && runLength[i+2] == fact) { - if(runLength[i-3] < 0 || runLength[i-3] >= 4 * fact) { + if(i == 3 || runLength[i-3] >= 4 * fact) { demerit += N3; //n3 += N3; - } else if(i+3 >= length || runLength[i+3] >= 4 * fact) { + } else if(i+4 >= length || runLength[i+3] >= 4 * fact) { demerit += N3; //n3 += N3; } @@ -249,9 +249,6 @@ __STATIC int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *r int pitch; pitch = (dir==0)?1:width; - for(i=0; i + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,6 +27,7 @@ extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level #ifdef WITH_TESTS extern int Mask_calcN2(int width, unsigned char *frame); +extern int Mask_calcN1N3(int length, int *runLength); extern int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *runLength); extern int Mask_evaluateSymbol(int width, unsigned char *frame); extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); -- cgit 0.0.5-2-1-g0f52 From 63ebb09d891111569b28dc7587237c5d8867a8c5 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 17 Oct 2011 18:56:11 +0900 Subject: Various test cases have been added. --- tests/test_mask.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/tests/test_mask.c b/tests/test_mask.c index c36384f235..9960ea6608 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -254,6 +254,7 @@ void test_eval3(void) frame = (unsigned char *)malloc(w * w); testStart("Test mask evaluation (1:1:3:1:1 check)"); + for(y=0; y<5; y++) { for(x=0; x Date: Mon, 17 Oct 2011 18:56:57 +0900 Subject: Now the latest PNG library is chosen when the configure script is executed. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d25c67d088..be41ad19a6 100644 --- a/configure.ac +++ b/configure.ac @@ -50,7 +50,7 @@ AC_ARG_WITH([tools], [AS_HELP_STRING([--with-tools], [build utility tools [defau AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ]) if test x$build_tools = xyes ; then - PKG_CHECK_MODULES(png, "libpng12") + PKG_CHECK_MODULES(png, "libpng") fi dnl --with-tests -- cgit 0.0.5-2-1-g0f52 From fe2e1e8e8a5f797976d1d3a3f9d295a1a3683ba9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 17 Oct 2011 18:57:43 +0900 Subject: Copyright year updated. --- ChangeLog | 24 +++++++++++++++++++++++- README | 7 ++++--- bitstream.c | 2 +- bitstream.h | 2 +- mmask.c | 2 +- mmask.h | 2 +- mqrspec.c | 2 +- mqrspec.h | 2 +- qrenc.c | 4 ++-- qrencode.c | 2 +- qrencode.h | 2 +- qrencode_inner.h | 2 +- qrinput.c | 2 +- qrinput.h | 2 +- qrspec.c | 2 +- qrspec.h | 2 +- rscode.c | 2 +- rscode.h | 2 +- split.c | 2 +- split.h | 2 +- 20 files changed, 46 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index c09fb21ff1..fbcb0620c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2011.10.17 Kentaro FUKUCHI + * configure.ac: + - Now the latest PNG library is chosen when the configure script is + executed. + * Copyright year has been updated. + +2011.10.17 Kentaro FUKUCHI + * mask.c: + - Unneeded zero-clear has been eliminated from Mask_calcRunLength(). + - A rounding-down error in N4 calculation has been fixed. + (Thanks to Adam Shepherd) + * tests/test_mask.c: + - Fixed some test cases. + +2011.10.17 Kentaro FUKUCHI + * mask.c: + - A bug in N3 penalty calculation functoin has been fixed. + (Thanks to Adam Shepherd) + * mask.h, tests/test_mask.c: + - Test cases for Mask_calcN1N3() have been added. + - Wrong test cases have been corrected. + 2011.10.16 Kentaro FUKUCHI * mask.[ch]: - Mask_calcRunLength() has been refactored out from Mask_evaluateSymbol(). @@ -41,7 +63,7 @@ 2010.10.09 Kentaro FUKUCHI * Copyright year and mail address were updated. - * README, qrencode.spec.in + * README, qrencode.spec.in: - The URL of qrencode's page has been updated. * Makefile.am: - Added ACLOCAL_AMFLAGS. diff --git a/README b/README index eb469aaf69..79f85016da 100644 --- a/README +++ b/README @@ -73,7 +73,7 @@ You should limit the parameter by your application. LICENSING INFORMATION ===================== -Copyright (C) 2006-2010 Kentaro Fukuchi +Copyright (C) 2006-2011 Kentaro Fukuchi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free @@ -88,8 +88,8 @@ with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -CONTACTS -======== +CONTACT +======= Visit the homepage at: http://fukuchi.org/works/qrencode/index.en.html @@ -115,4 +115,5 @@ NANKI Haruo - improved lower-case characteres encoding Philippe Delcroix - improved mask evaluation Yusuke Mihara - structured-append support David Dahl - DPI patch +Adam Shepherd - bug fix patch of the mask evaluation Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom - bug report / suggestion diff --git a/bitstream.c b/bitstream.c index 1504634220..a0b9283cb0 100644 --- a/bitstream.c +++ b/bitstream.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Binary sequence class. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/bitstream.h b/bitstream.h index 85049edf89..ffe743c5e0 100644 --- a/bitstream.h +++ b/bitstream.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Binary sequence class. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mmask.c b/mmask.c index 2b36d7c18d..d2d57ce122 100644 --- a/mmask.c +++ b/mmask.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking for Micro QR Code. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mmask.h b/mmask.h index a37de1059d..f6556e877d 100644 --- a/mmask.h +++ b/mmask.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking for Micro QR Code. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mqrspec.c b/mqrspec.c index bfd618b565..76d2d261a6 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Micor QR Code specification in convenient format. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/mqrspec.h b/mqrspec.h index 546cb875bc..2d4b90d281 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Micro QR Code specification in convenient format. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrenc.c b/qrenc.c index b185e1a53f..de1b56d964 100644 --- a/qrenc.c +++ b/qrenc.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code encoding tool - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -66,7 +66,7 @@ static void usage(int help, int longopt) { fprintf(stderr, "qrencode version %s\n" -"Copyright (C) 2006-2010 Kentaro Fukuchi\n", VERSION); +"Copyright (C) 2006-2011 Kentaro Fukuchi\n", VERSION); if(help) { if(longopt) { fprintf(stderr, diff --git a/qrencode.c b/qrencode.c index eaa0a72edf..dc146693b6 100644 --- a/qrencode.c +++ b/qrencode.c @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrencode.h b/qrencode.h index d6d33314ac..956af7edd3 100644 --- a/qrencode.h +++ b/qrencode.h @@ -1,7 +1,7 @@ /** * qrencode - QR Code encoder * - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrencode_inner.h b/qrencode_inner.h index 40a0edc8b1..3c40d0622a 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Header for test use - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrinput.c b/qrinput.c index 565c0d5173..5dcacf8aa2 100644 --- a/qrinput.c +++ b/qrinput.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrinput.h b/qrinput.h index c2332a80ce..9e6bad625d 100644 --- a/qrinput.h +++ b/qrinput.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrspec.c b/qrspec.c index 4d40d10a26..a42706f4b8 100644 --- a/qrspec.c +++ b/qrspec.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code specification in convenient format. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/qrspec.h b/qrspec.h index 31a35fc86a..54a3d9f09e 100644 --- a/qrspec.h +++ b/qrspec.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code specification in convenient format. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/rscode.c b/rscode.c index 2e32512a7f..edc32e2c92 100644 --- a/rscode.c +++ b/rscode.c @@ -7,7 +7,7 @@ * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * (libfec is released under the GNU Lesser General Public License.) * - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/rscode.h b/rscode.h index c6830b3076..5b976b2bfc 100644 --- a/rscode.h +++ b/rscode.h @@ -7,7 +7,7 @@ * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * (libfec is released under the GNU Lesser General Public License.) * - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/split.c b/split.c index cfe2a11c67..f53dce5dc4 100644 --- a/split.c +++ b/split.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/split.h b/split.h index 37e6d86dcf..b2cdbe5468 100644 --- a/split.h +++ b/split.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006-2010 Kentaro Fukuchi + * Copyright (C) 2006-2011 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) -- cgit 0.0.5-2-1-g0f52 From dc3de7576e4480a562c59a647ed002eb4931d342 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Oct 2011 04:25:05 +0900 Subject: Some code cleanups. --- ChangeLog | 10 ++++++++++ mask.c | 2 -- mmask.c | 2 -- tests/common.h | 2 -- tests/test_mask.c | 2 ++ tests/test_qrencode.c | 2 ++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index fbcb0620c0..f7eb328d05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011.10.23 Kentaro FUKUCHI + * mask.c, mmask.c, tests/common.h: + - Eliminated unused valiables. + * tests/test_qrencode.c: + - Some assertions added. + +2011.10.18 Kentaro FUKUCHI + * test/test_mask.c: + - To call QRspec_clearCache() at exit. + 2011.10.17 Kentaro FUKUCHI * configure.ac: - Now the latest PNG library is chosen when the configure script is diff --git a/mask.c b/mask.c index bc3d340dfd..47c658ca0e 100644 --- a/mask.c +++ b/mask.c @@ -298,7 +298,6 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) int i; unsigned char *mask, *bestMask; int minDemerit = INT_MAX; - int bestMaskNum = 0; int blacks; int bratio; int demerit; @@ -320,7 +319,6 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) // printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit); if(demerit < minDemerit) { minDemerit = demerit; - bestMaskNum = i; free(bestMask); bestMask = mask; mask = (unsigned char *)malloc(w2); diff --git a/mmask.c b/mmask.c index d2d57ce122..aadde2b79a 100644 --- a/mmask.c +++ b/mmask.c @@ -150,7 +150,6 @@ unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level) int i; unsigned char *mask, *bestMask; int maxScore = 0; - int bestMaskNum = 0; int score; int width; @@ -167,7 +166,6 @@ unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level) score = MMask_evaluateSymbol(width, mask); if(score > maxScore) { maxScore = score; - bestMaskNum = i; free(bestMask); bestMask = mask; mask = (unsigned char *)malloc(width * width); diff --git a/tests/common.h b/tests/common.h index 1654abb758..2015e806fc 100644 --- a/tests/common.h +++ b/tests/common.h @@ -27,12 +27,10 @@ const char *modeStr[5] = {"nm", "an", "8", "kj", "st"}; void printQRinput(QRinput *input) { QRinput_List *list; - unsigned char *p; int i; list = input->head; while(list != NULL) { - p = list->data; for(i=0; isize; i++) { printf("0x%02x,", list->data[i]); } diff --git a/tests/test_mask.c b/tests/test_mask.c index 9960ea6608..56bedcb308 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -402,5 +402,7 @@ int main(void) report(); + QRspec_clearCache(); + return 0; } diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index ddc2e3e812..668e375095 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -687,6 +687,7 @@ void test_formatInfo(void) testStart("Test format info in QR code."); qrcode = QRcode_encodeString("AC-42", 1, QR_ECLEVEL_H, QR_MODE_8, 1); ret = QRcode_decodeFormat(qrcode, &level, &mask); + assert_zero(ret, "Failed to decode.\n"); assert_equal(level, QR_ECLEVEL_H, "Decoded format is wrong.\n"); if(qrcode != NULL) QRcode_free(qrcode); @@ -708,6 +709,7 @@ void test_formatInfoMQR(void) MQRformat[i].level, QR_MODE_8, 1); ret = QRcode_decodeFormatMQR(qrcode, &version, &level, &mask); + assert_zero(ret, "Failed to decode.\n"); assert_equal(MQRformat[i].version, version, "Decoded verion is wrong.\n"); assert_equal(MQRformat[i].level, level, "Decoded level is wrong.\n"); QRcode_free(qrcode); -- cgit 0.0.5-2-1-g0f52 From 06de117be87ec4ef5dbbac21f3040f12daa29077 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Oct 2011 04:31:02 +0900 Subject: Added a link to the issue page at github. --- README | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README b/README index 79f85016da..ccab4e1e08 100644 --- a/README +++ b/README @@ -98,9 +98,15 @@ for new releases. The git repository is available at: https://github.com/fukuchi/libqrencode -Please mail any bug reports, suggestions, comments and questions to -Kentaro Fukuchi . Questions of license compliance -are also welcome. +Please mail any bug reports, suggestions, comments and questions to: + +Kentaro Fukuchi + +or submit issues to: + +https://github.com/fukuchi/libqrencode/issues + +Questions of license compliance are also welcome. ACKNOWLEDGMENTS -- cgit 0.0.5-2-1-g0f52 From 80c6837bc20f5164cd959b468f60715f70ab4a2b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Oct 2011 05:24:15 +0900 Subject: Version 3.2 branch has been started. --- ChangeLog | 7 +++++++ NEWS | 24 +++++++++++++++--------- README | 4 ++-- configure.ac | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index f7eb328d05..4eb23c78fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011.10.23 Kentaro FUKUCHI + [3.2.0] + * 3.2 branch has been started. + * README, NEWS, configure.ac: + - Version number changes. + - Micro QR Code support is now marked as "experimental" explicitly. + 2011.10.23 Kentaro FUKUCHI * mask.c, mmask.c, tests/common.h: - Eliminated unused valiables. diff --git a/NEWS b/NEWS index 298aaba1fa..7005ff5229 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,8 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.9.0 (2011.x.x) +Version 3.2.0 (2011.x.x) ------------------------ -* Micro QR Code support has been added. -* "--micro" (or "-M") option for Micro QR Code has been added to qrencode. * "--dpi" (or "-d") has been added to qrencode. This option set DPI information in an output PNG image. (Thanks to David Dahl) * New option "--enable-thread-safety" has been added to the configure script @@ -12,16 +10,24 @@ Version 3.9.0 (2011.x.x) * QRcode_encodeData(), QRcode_encodeDataMQR, QRcode_encodeDataStructured() have been added for binary data encoding including '\0'. * Typo and bug fixes. +* Micro QR Code support has been added. (experimental) +* "--micro" (or "-M") option for Micro QR Code has been added to qrencode. + (experimental) Release Note: -** This is an open beta version of libqrencode 4.0.0. -Micro QR Code encoder has been added. Some functions (QRcode_*MQR()) have been -added to the library. The command line tool also accepts "--micro" and "-M" -options. "--dpi" and "-d" are also added to embed DPI information to PNG file. - Binary data including '\0' can be encoded now with qrencode. To encode a binary data, give "-8" option to qrencode, and let qrencode obtain data via standard -input like "qrencode -8 -o output.png < binary". +input like "qrencode -8 -o output.png < binary". "--dpi" and "-d" are also +added to embed DPI information to PNG file. + +A bug in the mask pattern evaluation routine has been fixed. In some cases, +libqrencode may generate a different symbol from the one that was generated by +the prior libqrencode because of this bug fix, but the embedded data are not +affected. The symbols generated by the old libqrencode are valid. + +Experimental support of Micro QR Code encoder has been added. Some functions +(QRcode_*MQR()) have been added to the library. The command line tool also +accepts "--micro" and "-M" options. Version 3.1.1 (2010.2.3) ------------------------ diff --git a/README b/README index ccab4e1e08..8971a4ffbe 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.9.0 - QR Code encoding library +libqrencode 3.2.0 - QR Code encoding library GENERAL INFORMATION =================== @@ -23,7 +23,7 @@ are implemented such as: embedded - Optimized encoding of a string - Structured-append of symbols -- Micro QR Code +- Micro QR Code (experimental) Currently the following features are not supported: - ECI and FNC1 mode diff --git a/configure.ac b/configure.ac index be41ad19a6..6fb140970d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_INIT(QRencode) MAJOR_VERSION=3 -MINOR_VERSION=9 +MINOR_VERSION=2 MICRO_VERSION=0 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 27b292d1faeef131c1801d9a3d6b9ee1a909c0f7 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 24 Nov 2011 02:20:26 +0900 Subject: A bug in mask evaluation function has been eliminatd. --- mmask.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mmask.c b/mmask.c index aadde2b79a..99470f2008 100644 --- a/mmask.c +++ b/mmask.c @@ -132,12 +132,12 @@ __STATIC int MMask_evaluateSymbol(int width, unsigned char *frame) int sum1 = 0, sum2 = 0; p = frame + width * (width - 1); - for(x=0; x Date: Thu, 24 Nov 2011 02:21:14 +0900 Subject: Micro QR Code support is marked as 'experimental'. More tests and document updates. --- ChangeLog | 18 ++++++++++++++++++ NEWS | 16 ++++++++-------- README | 13 ++++++++----- TODO | 2 ++ qrenc.c | 2 +- qrencode.1.in | 10 ++++++++-- tests/test_mmask.c | 38 ++++++++++++++++++++++++++++++++++++++ tests/test_qrencode.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/test_qrinput.c | 15 +++++++++++++++ tests/view_qrcode.c | 3 ++- 10 files changed, 148 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4eb23c78fa..6d0c21ebe7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2011.11.23 Kentaro FUKUCHI + [3.2.0] + * qrencode.1.in: + - Added descriptions of "-d" and "-M". + +2011.11.3 Kentaro FUKUCHI + [3.2.0] + * tests/view_qrcode.c: + - Messages improved. + * mmask.c: + - A bug in mask evaluation function has been eliminatd. + * tests/test_mmask.c: + - New test case has been added. + * qrenc.c: + - Micro QR Code support is now marked as "experimental" explicitly. + * tests/test_qrinput.c, tests/test_qrencode.c: + - Added some test cases. + 2011.10.23 Kentaro FUKUCHI [3.2.0] * 3.2 branch has been started. diff --git a/NEWS b/NEWS index 7005ff5229..517645f912 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.2.0 (2011.x.x) +Version 3.2.0 (2011.11.23) ------------------------ * "--dpi" (or "-d") has been added to qrencode. This option set DPI information in an output PNG image. (Thanks to David Dahl) @@ -10,15 +10,15 @@ Version 3.2.0 (2011.x.x) * QRcode_encodeData(), QRcode_encodeDataMQR, QRcode_encodeDataStructured() have been added for binary data encoding including '\0'. * Typo and bug fixes. -* Micro QR Code support has been added. (experimental) +* Experimental Micro QR Code support has been added. * "--micro" (or "-M") option for Micro QR Code has been added to qrencode. (experimental) Release Note: -Binary data including '\0' can be encoded now with qrencode. To encode a binary -data, give "-8" option to qrencode, and let qrencode obtain data via standard -input like "qrencode -8 -o output.png < binary". "--dpi" and "-d" are also -added to embed DPI information to PNG file. +Binary data including '\0' is now supported. To encode a binary data, give "-8" +option to qrencode, and let qrencode obtain data via standard input like +"qrencode -8 -o output.png < binary". "--dpi" and "-d" are also added to embed +DPI information to PNG file. A bug in the mask pattern evaluation routine has been fixed. In some cases, libqrencode may generate a different symbol from the one that was generated by @@ -26,8 +26,8 @@ the prior libqrencode because of this bug fix, but the embedded data are not affected. The symbols generated by the old libqrencode are valid. Experimental support of Micro QR Code encoder has been added. Some functions -(QRcode_*MQR()) have been added to the library. The command line tool also -accepts "--micro" and "-M" options. +(QRcode_*MQR()) have been added to the library. The command line tool generates +Micro QR Code when "--micro" or "-M" is given. Version 3.1.1 (2010.2.3) ------------------------ diff --git a/README b/README index 8971a4ffbe..090ddd3e7b 100644 --- a/README +++ b/README @@ -64,11 +64,14 @@ You can generate a manual of the library by using Doxygen. WARNINGS ======== -Some functions are THREAD UNSAFE. See qrencode.h for the details. +The library is distributed WITHOUT ANY WRRANTY. -Carefully use the qrencode command if it is used by a web application (CGI). -For example, giving "-s" option with too large number to qrencode may cause DoS. -You should limit the parameter by your application. +Micro QR Code support is EXPERIMENTAL. + +Be careful to use the command line tool (qrencode) if it is used by a web +application (e.g. CGI script). For example, giving "-s" option with a large +number to qrencode may cause DoS. The parameters should be checked by the +application. LICENSING INFORMATION @@ -114,7 +117,7 @@ ACKNOWLEDGMENTS QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other countries. -Reed-Solomon code encoder is written by Phil Karn, KA9Q. +Reed-Solomon encoder is written by Phil Karn, KA9Q. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q NANKI Haruo - improved lower-case characteres encoding diff --git a/TODO b/TODO index cc9ec194cb..e9662afaff 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +Micro QR code encoding is not tested well. + Documents (not only the README, but also the manual of the library) needs revision of grammer, spell or to resolve ambiguity or incomplete descriptions. Feel really free to send us your revision. diff --git a/qrenc.c b/qrenc.c index de1b56d964..f621aa6d6b 100644 --- a/qrenc.c +++ b/qrenc.c @@ -98,7 +98,7 @@ static void usage(int help, int longopt) " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" " -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" -" -M, --micro encode in a Micro QR Code.\n\n" +" -M, --micro encode in a Micro QR Code. (experimental)\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" diff --git a/qrencode.1.in b/qrencode.1.in index 958468b622..a9eb18ed23 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -1,4 +1,4 @@ -.TH QRENCODE 1 "Jan. 23, 2008" "qrencode @VERSION@" +.TH QRENCODE 1 "Nov. 23, 2011" "qrencode @VERSION@" .SH NAME qrencode \- Encode input data in a QR Code and save as a PNG image. .SH SYNOPSIS @@ -36,6 +36,9 @@ specify the version of the symbol. (default=auto) .B \-m NUMBER, --margin=NUMBER specify the width of margin. (default=4) .TP +.B \-d NUMBER, --dpi=NUMBER +specify the DPI of the generated PNG. (default=72) +.TP .B \-S, --structured make structured symbols. Version must be specified. .TP @@ -51,6 +54,9 @@ ignore case distinctions and use only upper-case characters. .B \-8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored. .TP +.B \-M, --micro +encode in a Micro QR Code. (experimental) +.TP .B \-V, --version display the version number and copyrights of the qrencode. .TP @@ -70,4 +76,4 @@ case-insensitive mode. Written by Kentaro Fukuchi. .SH COPYRIGHT -Copyright (C) 2006, 2007, 2008, 2009, 2010 Kentaro Fukuchi. +Copyright (C) 2006-2011 Kentaro Fukuchi. diff --git a/tests/test_mmask.c b/tests/test_mmask.c index 26ac2aa201..a3346dd2da 100644 --- a/tests/test_mmask.c +++ b/tests/test_mmask.c @@ -103,12 +103,50 @@ void test_masks(void) testFinish(); } +void test_maskEvaluation(void) +{ + static const int w = 11; + unsigned char pattern[w*w]; + int i, score; + + memset(pattern, 0, w*w); + + testStart("Test mask evaluation"); + score = MMask_evaluateSymbol(w, pattern); + assert_equal(score, 0, "Mask score caluculation is incorrect. (score=%d (%d expected)\n", score, 0); + + for(i=0; iversion, 3, "Format info decoder returns wrong version number: %d (%d expected)\n", qrdata->version, 3); + assert_equal(qrdata->level, 1, "Format info decoder returns wrong level: %d (%d expected)\n", qrdata->level, 1); + assert_zero(strcmp((char *)qrdata->data, str), "Decoded data (%s) mismatched (%s)\n", (char *)qrdata->data, str); + + QRdata_free(qrdata); + free(frame); + + testFinish(); +} + int main(void) { test_iterate(); @@ -846,6 +893,7 @@ int main(void) test_formatInfoMQR(); test_encodeTooLongMQR(); test_decodeShortMQR(); + test_mqrencode(); QRcode_clearCache(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 11606fe651..bbcc279907 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -883,6 +883,20 @@ void test_padding2MQR(void) testFinish(); } +void test_textMQR(void) +{ + int version = 3; + QRecLevel level = QR_ECLEVEL_M; + char *str = "MICROQR"; + char *correct = {"01 0111 01111110000 01000110111 10001010010 011011 0000000 0000 11101100 0000"}; + int ret; + + testStart("Text encoding (Micro QR)"); + ret = encodeAndCheckBStream(1, version, level, QR_MODE_AN, str, correct); + assert_zero(ret, "AlphaNumeric string '%s' incorrectly encoded.\n", str); + testFinish(); +} + void test_ECIinvalid(void) { QRinput *stream; @@ -961,6 +975,7 @@ int main(void) test_mqr_setlevel(); test_paddingMQR(); test_padding2MQR(); + test_textMQR(); test_ECIinvalid(); test_encodeECI(); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 9602d75024..fd7e9a988c 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -72,7 +72,7 @@ static void usage(int help, int longopt) " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" " -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" -" -M, --micro encode in a Micro QR Code.\n\n" +" -M, --micro encode in a Micro QR Code. (experimental)\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" @@ -166,6 +166,7 @@ void draw_singleQRcode(QRinput *stream, int mask) } if(qrcode == NULL) { width = (11 + margin * 2) * size; + fprintf(stderr, "Input data does not fit to this setting.\n"); } else { version = qrcode->version; width = (qrcode->width + margin * 2) * size; -- cgit 0.0.5-2-1-g0f52 From 1c54200a7744b674cb65cdf2cf175e29c5f7e718 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 24 Nov 2011 21:47:21 +0100 Subject: Added EPS support. --- qrenc.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 121 insertions(+), 12 deletions(-) diff --git a/qrenc.c b/qrenc.c index de1b56d964..3dc98cbf45 100644 --- a/qrenc.c +++ b/qrenc.c @@ -42,6 +42,13 @@ static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; +static enum imageType { + PNG_TYPE, + EPS_TYPE +}; + +static enum imageType image_type = PNG_TYPE; + static const struct option options[] = { {"help" , no_argument , NULL, 'h'}, {"output" , required_argument, NULL, 'o'}, @@ -50,6 +57,7 @@ static const struct option options[] = { {"symversion" , required_argument, NULL, 'v'}, {"margin" , required_argument, NULL, 'm'}, {"dpi" , required_argument, NULL, 'd'}, + {"type" , required_argument, NULL, 't'}, {"structured" , no_argument , NULL, 'S'}, {"kanji" , no_argument , NULL, 'k'}, {"casesensitive", no_argument , NULL, 'c'}, @@ -60,7 +68,7 @@ static const struct option options[] = { {NULL, 0, NULL, 0} }; -static char *optstring = "ho:l:s:v:m:d:Skci8MV"; +static char *optstring = "ho:l:s:v:m:d:t:Skci8MV"; static void usage(int help, int longopt) { @@ -71,11 +79,11 @@ static void usage(int help, int longopt) if(longopt) { fprintf(stderr, "Usage: qrencode [OPTION]... [STRING]\n" -"Encode input data in a QR Code and save as a PNG image.\n\n" +"Encode input data in a QR Code and save as a PNG or EPS image.\n\n" " -h, --help display the help message. -h displays only the help of short\n" " options.\n\n" " -o FILENAME, --output=FILENAME\n" -" write PNG image to FILENAME. If '-' is specified, the result\n" +" write image to FILENAME. If '-' is specified, the result\n" " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" " if specified, remove a trailing '.png' from FILENAME.\n\n" @@ -90,6 +98,8 @@ static void usage(int help, int longopt) " specify the width of the margins. (default=4 (2 for Micro)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" +" -t {PNG,EPS}, --type={PNG,EPS}\n" +" specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" @@ -107,10 +117,10 @@ static void usage(int help, int longopt) } else { fprintf(stderr, "Usage: qrencode [OPTION]... [STRING]\n" -"Encode input data in a QR Code and save as a PNG image.\n\n" +"Encode input data in a QR Code and save as a PNG or EPS image.\n\n" " -h display this message.\n" " --help display the usage of long options.\n" -" -o FILENAME write PNG image to FILENAME. If '-' is specified, the result\n" +" -o FILENAME write image to FILENAME. If '-' is specified, the result\n" " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" " if specified, remove a trailing '.png' from FILENAME.\n" @@ -120,7 +130,7 @@ static void usage(int help, int longopt) " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" - +" -t {PNG,EPS} specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" @@ -265,6 +275,59 @@ static int writePNG(QRcode *qrcode, const char *outfile) return 0; } +static int writeEPS(QRcode *qrcode, const char *outfile) +{ + static FILE *fp; // avoid clobbering by setjmp. + unsigned char *row, *p; + int x, y, yy; + int realwidth; + + if(outfile[0] == '-' && outfile[1] == '\0') { + fp = stdout; + } else { + fp = fopen(outfile, "wb"); + if(fp == NULL) { + fprintf(stderr, "Failed to create file: %s\n", outfile); + perror(NULL); + exit(EXIT_FAILURE); + } + } + + realwidth = (qrcode->width + margin * 2) * size; + /* EPS file header */ + fprintf(fp, "%%!PS-Adobe-2.0 EPSF-1.2\n" + "%%%%BoundingBox: 0 0 %d %d\n" + "%%%%Pages: 1 1\n" + "%%%%EndComments\n", realwidth, realwidth); + /* draw point */ + fprintf(fp, "/p { " + "moveto " + "0 1 rlineto " + "1 0 rlineto " + "0 -1 rlineto " + "fill " + "} bind def " + "3 3 scale "); + + /* data */ + p = qrcode->data; + for(y=0; ywidth; y++) { + row = (p+(y*qrcode->width)); + yy = (margin + qrcode->width - y - 1); + + for(x=0; xwidth; x++) { + if(*(row+x)&0x1) { + fprintf(fp, "%d %d p ", margin + x, yy); + } + } + } + + fprintf(fp, "\n%%%%EOF\n"); + fclose(fp); + + return 0; +} + static QRcode *encode(const unsigned char *intext, int length) { QRcode *code; @@ -295,7 +358,17 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil perror("Failed to encode the input data"); exit(EXIT_FAILURE); } - writePNG(qrcode, outfile); + switch(image_type) { + case PNG_TYPE: + writePNG(qrcode, outfile); + break; + case EPS_TYPE: + writeEPS(qrcode, outfile); + break; + default: + fprintf(stderr, "Unknown image type.\n"); + exit(EXIT_FAILURE); + } QRcode_free(qrcode); } @@ -317,16 +390,32 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch QRcode_List *qrlist, *p; char filename[FILENAME_MAX]; char *base, *q, *suffix = NULL; + const char *type_suffix; int i = 1; - + int suffix_size; + + switch(image_type) { + case PNG_TYPE: + type_suffix = ".png"; + suffix_size = 4; + break; + case EPS_TYPE: + type_suffix = ".eps"; + suffix_size = 4; + break; + default: + fprintf(stderr, "Unknown image type.\n"); + exit(EXIT_FAILURE); + } + base = strdup(outfile); if(base == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); exit(EXIT_FAILURE); } - if(strlen(base) > 4) { - q = base + strlen(base) - 4; - if(strcasecmp(".png", q) == 0) { + if(strlen(base) > suffix_size) { + q = base + strlen(base) - suffix_size; + if(strcasecmp(type_suffix, q) == 0) { suffix = strdup(q); *q = '\0'; } @@ -348,7 +437,17 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch } else { snprintf(filename, FILENAME_MAX, "%s-%02d", base, i); } - writePNG(p->code, filename); + switch(image_type) { + case PNG_TYPE: + writePNG(p->code, filename); + break; + case EPS_TYPE: + writeEPS(p->code, filename); + break; + default: + fprintf(stderr, "Unknown image type.\n"); + exit(EXIT_FAILURE); + } i++; } @@ -432,6 +531,16 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } break; + case 't': + if(strcasecmp(optarg, "png") == 0) { + image_type = PNG_TYPE; + } else if(strcasecmp(optarg, "eps") == 0) { + image_type = EPS_TYPE; + } else { + fprintf(stderr, "Invalid image type: %s\n", optarg); + exit(EXIT_FAILURE); + } + break; case 'S': structured = 1; case 'k': -- cgit 0.0.5-2-1-g0f52 From 9820ebc969c101662d7b6c21917bca09ec22073c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Nov 2011 04:18:48 +0900 Subject: Version 3.2.0 released. --- ChangeLog | 4 ++++ NEWS | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d0c21ebe7..b9d5d27e25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011.11.26 Kentaro FUKUCHI + [3.2.0] + * Version 3.2.0 has been released. + 2011.11.23 Kentaro FUKUCHI [3.2.0] * qrencode.1.in: diff --git a/NEWS b/NEWS index 517645f912..809c73ebec 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,10 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.2.0 (2011.11.23) +Version 3.2.0 (2011.11.26) ------------------------ -* "--dpi" (or "-d") has been added to qrencode. This option set DPI information - in an output PNG image. (Thanks to David Dahl) +* "--dpi" (or "-d") option has been added to qrencode. This option set DPI + information in an output PNG image. (Thanks to David Dahl) * New option "--enable-thread-safety" has been added to the configure script that makes the library thread-safe. It is enabled by default. * QRcode_encodeData(), QRcode_encodeDataMQR, QRcode_encodeDataStructured() have -- cgit 0.0.5-2-1-g0f52 From 3ab848b38a21b4e2898ad3ccea3d0b1f059dc301 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Nov 2011 04:33:36 +0900 Subject: "RESOURCES" section has been added. --- qrencode.1.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qrencode.1.in b/qrencode.1.in index a9eb18ed23..50f6733025 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -75,5 +75,11 @@ case-insensitive mode. .SH AUTHOR Written by Kentaro Fukuchi. +.SH RESOURCES +.TP +Main Web Site: http://fukuchi.org/works/qrencode/ +.TP +Source code repository: https://github.com/fukuchi/libqrencode/ + .SH COPYRIGHT Copyright (C) 2006-2011 Kentaro Fukuchi. -- cgit 0.0.5-2-1-g0f52 From 4ed6a832222abe6cdde6dcf44dfef4d84d5c0185 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Nov 2011 04:33:50 +0900 Subject: URL updated. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 090ddd3e7b..871f9b9c63 100644 --- a/README +++ b/README @@ -95,7 +95,7 @@ CONTACT ======= Visit the homepage at: -http://fukuchi.org/works/qrencode/index.en.html +http://fukuchi.org/works/qrencode/ for new releases. The git repository is available at: -- cgit 0.0.5-2-1-g0f52 From e98f4c2ffbc06dcdc10644c7771f547fe6342256 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Nov 2011 04:34:01 +0900 Subject: 3.2.0 releasing mishmash. --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index b9d5d27e25..69f2b68079 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011.11.26 Kentaro FUKUCHI [3.2.0] + * qrencode.1.in: + - "RESOURCES" section has been added. + * README: + - URL to the main web site updated. * Version 3.2.0 has been released. 2011.11.23 Kentaro FUKUCHI -- cgit 0.0.5-2-1-g0f52 From b6816eae46bd194d661eb5cfb0bda7a02a2114d0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 11 Dec 2011 12:06:46 +0900 Subject: Whitespaces removal. --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index f621aa6d6b..3060c53ed8 100644 --- a/qrenc.c +++ b/qrenc.c @@ -49,7 +49,7 @@ static const struct option options[] = { {"size" , required_argument, NULL, 's'}, {"symversion" , required_argument, NULL, 'v'}, {"margin" , required_argument, NULL, 'm'}, - {"dpi" , required_argument, NULL, 'd'}, + {"dpi" , required_argument, NULL, 'd'}, {"structured" , no_argument , NULL, 'S'}, {"kanji" , no_argument , NULL, 'k'}, {"casesensitive", no_argument , NULL, 'c'}, -- cgit 0.0.5-2-1-g0f52 From 57059a9205e26e0490290e7b77c8ab15214d5eb8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 11 Dec 2011 12:19:13 +0900 Subject: Some code cleanups. --- qrenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qrenc.c b/qrenc.c index 06016ef869..9b48d39a97 100644 --- a/qrenc.c +++ b/qrenc.c @@ -277,7 +277,7 @@ static int writePNG(QRcode *qrcode, const char *outfile) static int writeEPS(QRcode *qrcode, const char *outfile) { - static FILE *fp; // avoid clobbering by setjmp. + FILE *fp; unsigned char *row, *p; int x, y, yy; int realwidth; @@ -397,16 +397,16 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch switch(image_type) { case PNG_TYPE: type_suffix = ".png"; - suffix_size = 4; break; case EPS_TYPE: type_suffix = ".eps"; - suffix_size = 4; break; default: fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); } + + suffix_size = strlen(type_suffix); base = strdup(outfile); if(base == NULL) { -- cgit 0.0.5-2-1-g0f52 From a6978b7d15c255333c0e83ab2de44b28dc96156f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 11 Dec 2011 12:22:29 +0900 Subject: More code cleanups. --- qrenc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 9b48d39a97..109fce028c 100644 --- a/qrenc.c +++ b/qrenc.c @@ -406,13 +406,12 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch exit(EXIT_FAILURE); } - suffix_size = strlen(type_suffix); - base = strdup(outfile); if(base == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); exit(EXIT_FAILURE); } + suffix_size = strlen(type_suffix); if(strlen(base) > suffix_size) { q = base + strlen(base) - suffix_size; if(strcasecmp(type_suffix, q) == 0) { -- cgit 0.0.5-2-1-g0f52 From 972a840915b610c54a212c89c454cf4b05b08623 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 11 Dec 2011 12:28:07 +0900 Subject: . --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 69f2b68079..a7b8f8ea44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011.12.11 Kentaro FUKUCHI + * qrenc.c: + - Pulled Zapster's EPS support patch. + - Some code cleanups. + 2011.11.26 Kentaro FUKUCHI [3.2.0] * qrencode.1.in: -- cgit 0.0.5-2-1-g0f52 From b4563217835c0f201a8b1c9ae3804695ad893c0e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 12 Dec 2011 13:32:42 +0900 Subject: Usage updates. --- qrenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 1d08fe599c..1ca2865a19 100644 --- a/qrenc.c +++ b/qrenc.c @@ -86,7 +86,7 @@ static void usage(int help, int longopt) " write image to FILENAME. If '-' is specified, the result\n" " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" -" if specified, remove a trailing '.png' from FILENAME.\n\n" +" if specified, remove its suffix from FILENAME.\n\n" " -s NUMBER, --size=NUMBER\n" " specify module size in dots (pixels). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" @@ -123,7 +123,7 @@ static void usage(int help, int longopt) " -o FILENAME write image to FILENAME. If '-' is specified, the result\n" " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" -" if specified, remove a trailing '.png' from FILENAME.\n" +" if specified, remove its suffix from FILENAME.\n" " -s NUMBER specify module size in dots (pixels). (default=3)\n" " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" -- cgit 0.0.5-2-1-g0f52 From e25666f3cee3cdb02872c4e1cb636ef13dd8dab9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 12 Dec 2011 13:46:43 +0900 Subject: Usage updates. --- qrenc.c | 8 ++++---- qrencode.1.in | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/qrenc.c b/qrenc.c index 1ca2865a19..577a9fc35c 100644 --- a/qrenc.c +++ b/qrenc.c @@ -85,8 +85,8 @@ static void usage(int help, int longopt) " -o FILENAME, --output=FILENAME\n" " write image to FILENAME. If '-' is specified, the result\n" " will be output to standard output. If -S is given, structured\n" -" symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" -" if specified, remove its suffix from FILENAME.\n\n" +" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n" +" (suffix is removed from FILENAME, if specified)\n" " -s NUMBER, --size=NUMBER\n" " specify module size in dots (pixels). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" @@ -122,8 +122,8 @@ static void usage(int help, int longopt) " --help display the usage of long options.\n" " -o FILENAME write image to FILENAME. If '-' is specified, the result\n" " will be output to standard output. If -S is given, structured\n" -" symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\n" -" if specified, remove its suffix from FILENAME.\n" +" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n" +" (suffix is removed from FILENAME, if specified)\n" " -s NUMBER specify module size in dots (pixels). (default=3)\n" " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" diff --git a/qrencode.1.in b/qrencode.1.in index 50f6733025..3760aee2ac 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -1,6 +1,6 @@ .TH QRENCODE 1 "Nov. 23, 2011" "qrencode @VERSION@" .SH NAME -qrencode \- Encode input data in a QR Code and save as a PNG image. +qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS .B "qrencode" [OPTION]... @@ -13,7 +13,7 @@ CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness. Qrencode is a utility software using libqrencode to encode string data in -a QR Code and save as a PNG image. +a QR Code and save as a PNG or EPS image. .SH OPTIONS .TP @@ -21,8 +21,7 @@ a QR Code and save as a PNG image. display help message. .TP .B \-o FILENAME, --output=FILENAME -write PNG image to FILENAME. If '-' is specified, the result will be output -to standard output. +write image to FILENAME. If '-' is specified, the result will be output to standard output. If -S is given, structured symbols are written to FILENAME-01.png, FILENAME-02.png, ... (suffix is removed from FILENAME, if specified) .TP .B \-s NUMBER, --size=NUMBER specify the size of dot (pixel). (default=3) @@ -39,6 +38,9 @@ specify the width of margin. (default=4) .B \-d NUMBER, --dpi=NUMBER specify the DPI of the generated PNG. (default=72) .TP +.B \-t {PNG,EPS}, --type={PNG,EPS} +specify the type of the generated image. (default=PNG) +.TP .B \-S, --structured make structured symbols. Version must be specified. .TP -- cgit 0.0.5-2-1-g0f52 From e642a3606efc1328dcd8e2cf1155dc69aa06c905 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 12 Dec 2011 13:47:01 +0900 Subject: Added a line to ACKNOWLEDGMENTS. --- ChangeLog | 4 ++++ README | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index a7b8f8ea44..8bda34da24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011.12.12 Kentaro FUKUCHI + * qrenc.c, qrencode.1.in: + - Usage updates. + 2011.12.11 Kentaro FUKUCHI * qrenc.c: - Pulled Zapster's EPS support patch. diff --git a/README b/README index 871f9b9c63..5c45c5efdf 100644 --- a/README +++ b/README @@ -125,4 +125,5 @@ Philippe Delcroix - improved mask evaluation Yusuke Mihara - structured-append support David Dahl - DPI patch Adam Shepherd - bug fix patch of the mask evaluation +zapster - EPS support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From feaf07220edf1980ded86282ca25285cf54a8851 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 12 Dec 2011 13:54:15 +0900 Subject: Bumped version to 3.2.1. --- ChangeLog | 5 +++++ README | 2 +- configure.ac | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bda34da24..de76f708c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011.12.12 Kentaro FUKUCHI + [3.2.1] + * configure.ac, README: + - Bumped version to 3.2.1. + 2011.12.12 Kentaro FUKUCHI * qrenc.c, qrencode.1.in: - Usage updates. diff --git a/README b/README index 5c45c5efdf..0e741a3f9c 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.2.0 - QR Code encoding library +libqrencode 3.2.1 - QR Code encoding library GENERAL INFORMATION =================== diff --git a/configure.ac b/configure.ac index 6fb140970d..3cec016eab 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_INIT(QRencode) MAJOR_VERSION=3 MINOR_VERSION=2 -MICRO_VERSION=0 +MICRO_VERSION=1 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 1f8b1d981229f54b97a2ef71b1cabfa2ce32bead Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 13 Jan 2012 00:23:17 -0600 Subject: Added ANSI_TYPE and ANSI256_TYPE imageTypes Also added case statements to reflect these additions. --- qrenc.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index 577a9fc35c..839a6be937 100644 --- a/qrenc.c +++ b/qrenc.c @@ -44,7 +44,9 @@ static QRencodeMode hint = QR_MODE_8; static enum imageType { PNG_TYPE, - EPS_TYPE + EPS_TYPE, + ANSI_TYPE, + ANSI256_TYPE }; static enum imageType image_type = PNG_TYPE; @@ -365,6 +367,12 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil case EPS_TYPE: writeEPS(qrcode, outfile); break; + case ANSI_TYPE: + writeANSI(qrcode, outfile); + break; + case ANSI256_TYPE: + writeANSI(qrcode, outfile); + break; default: fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); @@ -401,6 +409,12 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case EPS_TYPE: type_suffix = ".eps"; break; + case ANSI_TYPE: + type_suffix = ".txt"; + break; + case ANSI256_TYPE: + type_suffix = ".txt"; + break; default: fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); @@ -443,6 +457,12 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case EPS_TYPE: writeEPS(p->code, filename); break; + case ANSI_TYPE: + writeANSI(p->code, filename); + break; + case ANSI256_TYPE: + writeANSI(p->code, filename); + break; default: fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); @@ -535,6 +555,10 @@ int main(int argc, char **argv) image_type = PNG_TYPE; } else if(strcasecmp(optarg, "eps") == 0) { image_type = EPS_TYPE; + } else if(strcasecmp(optarg, "ansi") == 0) { + image_type = ANSI_TYPE; + } else if(strcasecmp(optarg, "ansi256") == 0) { + image_type = ANSI256_TYPE; } else { fprintf(stderr, "Invalid image type: %s\n", optarg); exit(EXIT_FAILURE); -- cgit 0.0.5-2-1-g0f52 From 2e61bfe3822d64dbda003307c8e9d52b6e1c0147 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 13 Jan 2012 00:24:28 -0600 Subject: Added writeANSI(2) to qrenc. Writes out ANSI color coded QR codes! --- qrenc.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/qrenc.c b/qrenc.c index 839a6be937..0c37419371 100644 --- a/qrenc.c +++ b/qrenc.c @@ -330,6 +330,108 @@ static int writeEPS(QRcode *qrcode, const char *outfile) return 0; } +static int writeANSI(QRcode *qrcode, const char *outfile) +{ + FILE *fp; + unsigned char *row, *p; + int x, y, yy; + int realwidth; + int last; + + char *white, *black, *buffer; + int white_s, black_s, buffer_s; + + if( image_type == ANSI256_TYPE ){ + /* codes for 256 color compatible terminals */ + white = "\033[48;5;231m"; + white_s = 11; + black = "\033[48;5;16m"; + black_s = 10; + } else { + white = "\033[47m"; + white_s = 5; + black = "\033[40m"; + black_s = 5; + } + + size = 1; + margin = 1; + + if(outfile[0] == '-' && outfile[1] == '\0') { + fp = stdout; + } else { + fp = fopen(outfile, "wb"); + if(fp == NULL) { + fprintf(stderr, "Failed to create file: %s\n", outfile); + perror(NULL); + exit(EXIT_FAILURE); + } + } + + realwidth = (qrcode->width + margin * 2) * size; + buffer_s = ( realwidth * white_s ) * 2; + buffer = (char *)malloc( buffer_s ); + if(buffer == NULL) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(EXIT_FAILURE); + } + bzero( buffer, buffer_s ); + + /* top margin */ + strncpy(buffer, white, white_s); + for(y=0; ydata; + for(y=0; ywidth; y++) { + row = (p+(y*qrcode->width)); + yy = (margin + qrcode->width - y - 1); + + bzero( buffer, buffer_s ); + strncpy( buffer, white, white_s ); + strncat( buffer, " ", 2 ); + last = 0; + + for(x=0; xwidth; x++) { + if(*(row+x)&0x1) { + if( last != 1 ){ + strncat( buffer, black, black_s ); + last = 1; + } + } else { + if( last != 0 ){ + strncat( buffer, white, white_s ); + last = 0; + } + } + strncat( buffer, " ", 2 ); + } + + if( last != 0 ){ + strncat( buffer, white, white_s ); + } + strncat( buffer, " \n", 3 ); + fputs( buffer, fp ); + } + + /* bottom margin */ + bzero( buffer, buffer_s); + strncpy(buffer, white, white_s); + for(y=0; y Date: Fri, 13 Jan 2012 00:26:16 -0600 Subject: Added documentation for the ANSI and ANSI256 types. --- qrenc.c | 5 +++-- qrencode.1.in | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qrenc.c b/qrenc.c index 0c37419371..ec44ab3fde 100644 --- a/qrenc.c +++ b/qrenc.c @@ -100,7 +100,7 @@ static void usage(int help, int longopt) " specify the width of the margins. (default=4 (2 for Micro)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,EPS}, --type={PNG,EPS}\n" +" -t {PNG,EPS,ANSI,ANSI256}, --type={PNG,EPS,ANSI,ANSI256}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" @@ -132,7 +132,8 @@ static void usage(int help, int longopt) " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,EPS} specify the type of the generated image. (default=PNG)\n" +" -t {PNG,EPS,ANSI,ANSI256}\n" +" specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" diff --git a/qrencode.1.in b/qrencode.1.in index 3760aee2ac..3887ba7e41 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -38,7 +38,7 @@ specify the width of margin. (default=4) .B \-d NUMBER, --dpi=NUMBER specify the DPI of the generated PNG. (default=72) .TP -.B \-t {PNG,EPS}, --type={PNG,EPS} +.B \-t {PNG,EPS,ANSI,ANSI256}, --type={PNG,EPS,ANSI,ANSI256} specify the type of the generated image. (default=PNG) .TP .B \-S, --structured -- cgit 0.0.5-2-1-g0f52 From 2f1f2b7fc8395709f202dbe79c6ea8a5c00f4136 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 13 Jan 2012 00:27:03 -0600 Subject: Cleaned up whitespace on line endings. --- qrenc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qrenc.c b/qrenc.c index ec44ab3fde..641e62cd63 100644 --- a/qrenc.c +++ b/qrenc.c @@ -464,10 +464,10 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil exit(EXIT_FAILURE); } switch(image_type) { - case PNG_TYPE: + case PNG_TYPE: writePNG(qrcode, outfile); break; - case EPS_TYPE: + case EPS_TYPE: writeEPS(qrcode, outfile); break; case ANSI_TYPE: @@ -506,10 +506,10 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch int suffix_size; switch(image_type) { - case PNG_TYPE: + case PNG_TYPE: type_suffix = ".png"; break; - case EPS_TYPE: + case EPS_TYPE: type_suffix = ".eps"; break; case ANSI_TYPE: -- cgit 0.0.5-2-1-g0f52 From 24e2540971d7b2714e495635abf40457e71882cd Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 14 Jan 2012 19:32:19 -0600 Subject: Modified writeANSI to reset colors on each row --- qrenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 641e62cd63..984210562e 100644 --- a/qrenc.c +++ b/qrenc.c @@ -383,7 +383,7 @@ static int writeANSI(QRcode *qrcode, const char *outfile) for(y=0; y Date: Mon, 16 Jan 2012 16:32:20 -0600 Subject: Broke out top+bottom ANSI margins in a function writeANSI_margin(6) handles writing the top and bottom margins for writeANSI --- qrenc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/qrenc.c b/qrenc.c index 984210562e..8781a3cc63 100644 --- a/qrenc.c +++ b/qrenc.c @@ -331,6 +331,23 @@ static int writeEPS(QRcode *qrcode, const char *outfile) return 0; } +static void writeANSI_margin(FILE* fp, int realwidth, + char* buffer, int buffer_s, + char* white, int white_s ) +{ + int x, y; + + for(x=0; x Date: Mon, 16 Jan 2012 16:34:23 -0600 Subject: Implement writeANSI_margin in writeANSI --- qrenc.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/qrenc.c b/qrenc.c index 8781a3cc63..6cd24ce882 100644 --- a/qrenc.c +++ b/qrenc.c @@ -393,15 +393,9 @@ static int writeANSI(QRcode *qrcode, const char *outfile) fprintf(stderr, "Failed to allocate memory.\n"); exit(EXIT_FAILURE); } - bzero( buffer, buffer_s ); /* top margin */ - strncpy(buffer, white, white_s); - for(y=0; ydata; @@ -437,13 +431,8 @@ static int writeANSI(QRcode *qrcode, const char *outfile) } /* bottom margin */ - bzero( buffer, buffer_s); - strncpy(buffer, white, white_s); - for(y=0; y Date: Mon, 16 Jan 2012 16:35:27 -0600 Subject: Add margin handling for data rows in writeANSI --- qrenc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 6cd24ce882..04529df95b 100644 --- a/qrenc.c +++ b/qrenc.c @@ -405,7 +405,9 @@ static int writeANSI(QRcode *qrcode, const char *outfile) bzero( buffer, buffer_s ); strncpy( buffer, white, white_s ); - strncat( buffer, " ", 2 ); + for(x=0; xwidth; x++) { @@ -426,7 +428,10 @@ static int writeANSI(QRcode *qrcode, const char *outfile) if( last != 0 ){ strncat( buffer, white, white_s ); } - strncat( buffer, " \033[0m\n", 7 ); + for(x=0; x Date: Mon, 16 Jan 2012 16:36:14 -0600 Subject: Modify margin override in writeANSI margin is instead set to 1 when option parsing occurs. to set a different margin, simply use -m after the image type option --- qrenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index 04529df95b..174612e147 100644 --- a/qrenc.c +++ b/qrenc.c @@ -373,7 +373,6 @@ static int writeANSI(QRcode *qrcode, const char *outfile) } size = 1; - margin = 1; if(outfile[0] == '-' && outfile[1] == '\0') { fp = stdout; @@ -670,8 +669,10 @@ int main(int argc, char **argv) } else if(strcasecmp(optarg, "eps") == 0) { image_type = EPS_TYPE; } else if(strcasecmp(optarg, "ansi") == 0) { + margin = 1; image_type = ANSI_TYPE; } else if(strcasecmp(optarg, "ansi256") == 0) { + margin = 1; image_type = ANSI256_TYPE; } else { fprintf(stderr, "Invalid image type: %s\n", optarg); -- cgit 0.0.5-2-1-g0f52 From a1603d5574469759a210db11feb74efb8076a4fc Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 19 Jan 2012 19:50:47 +0900 Subject: QRcode_APIVersion() and QRcode_APIVersionString() have been added. --- ChangeLog | 7 +++++++ configure.ac | 3 +++ qrenc.c | 2 +- qrencode.c | 18 ++++++++++++++++++ qrencode.h | 15 +++++++++++++++ tests/test_qrencode.c | 18 ++++++++++++++++++ 6 files changed, 62 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index de76f708c0..9c3fafe346 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012.01.19 Kentaro FUKUCHI + [3.2.1] + * cofigure.ac, qrencode.[hc], qrenc.c, tests/test_qrencode.c: + - QRcode_APIVersion() and QRcode_APIVersionString() have been added. + - New macro values {MAJOR,MINOR,MICRO}_VERSION have been introduced. + - New tests have been added. + 2011.12.12 Kentaro FUKUCHI [3.2.1] * configure.ac, README: diff --git a/configure.ac b/configure.ac index 3cec016eab..0d511f426b 100644 --- a/configure.ac +++ b/configure.ac @@ -8,6 +8,9 @@ AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) AC_SUBST(MICRO_VERSION) AC_SUBST(VERSION) +AC_DEFINE_UNQUOTED([MAJOR_VERSION], [$MAJOR_VERSION], [Major version number]) +AC_DEFINE_UNQUOTED([MINOR_VERSION], [$MINOR_VERSION], [Minor version number]) +AC_DEFINE_UNQUOTED([MICRO_VERSION], [$MICRO_VERSION], [Micro version number]) AC_CONFIG_SRCDIR([qrencode.c]) AC_CONFIG_HEADERS([config.h]) diff --git a/qrenc.c b/qrenc.c index 577a9fc35c..12391d8105 100644 --- a/qrenc.c +++ b/qrenc.c @@ -74,7 +74,7 @@ static void usage(int help, int longopt) { fprintf(stderr, "qrencode version %s\n" -"Copyright (C) 2006-2011 Kentaro Fukuchi\n", VERSION); +"Copyright (C) 2006-2011 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { if(longopt) { fprintf(stderr, diff --git a/qrencode.c b/qrencode.c index dc146693b6..169f6b31e8 100644 --- a/qrencode.c +++ b/qrencode.c @@ -903,6 +903,24 @@ QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRec * System utilities *****************************************************************************/ +void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version) +{ + if(major_version != NULL) { + *major_version = MAJOR_VERSION; + } + if(minor_version != NULL) { + *minor_version = MINOR_VERSION; + } + if(micro_version != NULL) { + *micro_version = MICRO_VERSION; + } +} + +char *QRcode_APIVersionString(void) +{ + return VERSION; +} + void QRcode_clearCache(void) { QRspec_clearCache(); diff --git a/qrencode.h b/qrencode.h index 956af7edd3..fa53e364d5 100644 --- a/qrencode.h +++ b/qrencode.h @@ -537,6 +537,21 @@ extern void QRcode_List_free(QRcode_List *qrlist); * System utilities *****************************************************************************/ +/** + * Return a string that identifies the library version. + * @param major_version + * @param minor_version + * @param micro_version + */ +extern void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version); + +/** + * Return a string that identifies the library version. + * @return a string identifies the library version. The string is held by the + * library. Do NOT free it. + */ +extern char *QRcode_APIVersionString(void); + /** * Clear all caches. This is only for debug purpose. If you are attacking a * complicated memory leak bug, try this to reduce the reachable blocks record. diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 8a21a90eca..cde7c32bac 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -860,6 +860,23 @@ void test_mqrencode(void) testFinish(); } +void test_apiversion(void) +{ + int major_version, minor_version, micro_version; + char *str, *str2; + + testStart("API Version check"); + QRcode_APIVersion(&major_version, &minor_version, µ_version); + assert_equal(major_version, MAJOR_VERSION, "Major version number mismatched: %d (%d expected)\n", major_version, MAJOR_VERSION); + assert_equal(minor_version, MINOR_VERSION, "Minor version number mismatched: %d (%d expected)\n", minor_version, MINOR_VERSION); + assert_equal(micro_version, MICRO_VERSION, "Micro version number mismatched: %d (%d expected)\n", micro_version, MICRO_VERSION); + str = QRcode_APIVersionString(); + str2 = QRcode_APIVersionString(); + assert_zero(strcmp(VERSION, str), "Version string mismatched: %s (%s expected)\n", str, VERSION); + assert_equal(str, str2, "Version strings are not identical."); + testFinish(); +} + int main(void) { test_iterate(); @@ -894,6 +911,7 @@ int main(void) test_encodeTooLongMQR(); test_decodeShortMQR(); test_mqrencode(); + test_apiversion(); QRcode_clearCache(); -- cgit 0.0.5-2-1-g0f52 From 8b7097194cb112618cb92319820b0fa19539c31c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 19 Jan 2012 19:52:40 +0900 Subject: Small warning fix. --- ChangeLog | 2 ++ qrenc.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9c3fafe346..e438254041 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ - QRcode_APIVersion() and QRcode_APIVersionString() have been added. - New macro values {MAJOR,MINOR,MICRO}_VERSION have been introduced. - New tests have been added. + * qrenc.c: + - Removed a useless storage class specifier from enum imageType. 2011.12.12 Kentaro FUKUCHI [3.2.1] diff --git a/qrenc.c b/qrenc.c index 12391d8105..421ee670c1 100644 --- a/qrenc.c +++ b/qrenc.c @@ -42,7 +42,7 @@ static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; -static enum imageType { +enum imageType { PNG_TYPE, EPS_TYPE }; -- cgit 0.0.5-2-1-g0f52 From 34ef5dab40a839d51f21798b07b69f6b9f22a928 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 19 Jan 2012 20:47:33 +0900 Subject: Added some notes. --- ChangeLog | 2 ++ NEWS | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e438254041..44eefb0289 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ - New tests have been added. * qrenc.c: - Removed a useless storage class specifier from enum imageType. + [master, 3.2.1] + * Pulled moshen:write_ansi. 2011.12.12 Kentaro FUKUCHI [3.2.1] diff --git a/NEWS b/NEWS index 809c73ebec..3f0ef024c7 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,18 @@ libqrencode NEWS - Overview of changes ====================================== +Version 3.2.1 (2012.x.x) +------------------------- +* EPS and ANSI text output supports have been added. + (Thanks to Zapster and Colin) +* QRcode_APIVersion() and QRcode_APIVersionString() have been added. + +Release Note: +Two new output format, EPS and ANSI text, have been added to the command line +tool. + Version 3.2.0 (2011.11.26) ------------------------- +-------------------------- * "--dpi" (or "-d") option has been added to qrencode. This option set DPI information in an output PNG image. (Thanks to David Dahl) * New option "--enable-thread-safety" has been added to the configure script -- cgit 0.0.5-2-1-g0f52 From 2eddaeedff771d0c22527bd8db564cda8416286b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 19 Jan 2012 21:56:36 +0900 Subject: Small bug fix. --- tests/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/decoder.c b/tests/decoder.c index 13b5cf9bae..cf3bc68a3e 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -401,7 +401,7 @@ void dumpKanji(DataChunk *chunk) outbuf = (char *)malloc(inbytes * 4 + 1); outp = outbuf; ret = iconv(conv, &inbuf, &inbytes, &outp, &outbytes); - if(ret < 0) { perror(NULL); } + if(ret == (size_t) -1) { perror(NULL); } *outp = '\0'; printf("%s\n", outbuf); -- cgit 0.0.5-2-1-g0f52 From 09b72eb3070a36461eb83c1ec5237e4855ee515b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 19 Jan 2012 21:56:43 +0900 Subject: Code refactoring. Now you can omit "-o -" for EPS and ANSI output. --- ChangeLog | 6 ++++++ qrenc.c | 47 +++++++++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44eefb0289..c28a861050 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,12 @@ - Removed a useless storage class specifier from enum imageType. [master, 3.2.1] * Pulled moshen:write_ansi. + [3.2.1] + * tests/decoder.c: + - Bug fix. + * qrenc.c: + - Code refactoring. + - Now you can omit "-o -" for EPS and ANSI output. 2011.12.12 Kentaro FUKUCHI [3.2.1] diff --git a/qrenc.c b/qrenc.c index d4c61e701b..b43c5708e7 100644 --- a/qrenc.c +++ b/qrenc.c @@ -175,6 +175,24 @@ static unsigned char *readStdin(int *length) return buffer; } +static FILE *openFile(const char *outfile) +{ + FILE *fp; + + if(outfile == NULL || (outfile[0] == '-' && outfile[1] == '\0')) { + fp = stdout; + } else { + fp = fopen(outfile, "wb"); + if(fp == NULL) { + fprintf(stderr, "Failed to create file: %s\n", outfile); + perror(NULL); + exit(EXIT_FAILURE); + } + } + + return fp; +} + static int writePNG(QRcode *qrcode, const char *outfile) { static FILE *fp; // avoid clobbering by setjmp. @@ -285,16 +303,7 @@ static int writeEPS(QRcode *qrcode, const char *outfile) int x, y, yy; int realwidth; - if(outfile[0] == '-' && outfile[1] == '\0') { - fp = stdout; - } else { - fp = fopen(outfile, "wb"); - if(fp == NULL) { - fprintf(stderr, "Failed to create file: %s\n", outfile); - perror(NULL); - exit(EXIT_FAILURE); - } - } + fp = openFile(outfile); realwidth = (qrcode->width + margin * 2) * size; /* EPS file header */ @@ -352,7 +361,7 @@ static int writeANSI(QRcode *qrcode, const char *outfile) { FILE *fp; unsigned char *row, *p; - int x, y, yy; + int x, y; int realwidth; int last; @@ -374,16 +383,7 @@ static int writeANSI(QRcode *qrcode, const char *outfile) size = 1; - if(outfile[0] == '-' && outfile[1] == '\0') { - fp = stdout; - } else { - fp = fopen(outfile, "wb"); - if(fp == NULL) { - fprintf(stderr, "Failed to create file: %s\n", outfile); - perror(NULL); - exit(EXIT_FAILURE); - } - } + fp = openFile(outfile); realwidth = (qrcode->width + margin * 2) * size; buffer_s = ( realwidth * white_s ) * 2; @@ -400,7 +400,6 @@ static int writeANSI(QRcode *qrcode, const char *outfile) p = qrcode->data; for(y=0; ywidth; y++) { row = (p+(y*qrcode->width)); - yy = (margin + qrcode->width - y - 1); bzero( buffer, buffer_s ); strncpy( buffer, white, white_s ); @@ -513,7 +512,7 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch char *base, *q, *suffix = NULL; const char *type_suffix; int i = 1; - int suffix_size; + size_t suffix_size; switch(image_type) { case PNG_TYPE: @@ -712,7 +711,7 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); } - if(outfile == NULL) { + if(outfile == NULL && image_type == PNG_TYPE) { fprintf(stderr, "No output filename is given.\n"); exit(EXIT_FAILURE); } -- cgit 0.0.5-2-1-g0f52 From 0eccba235aac0dc7d5bbc5250dce6c60339326cd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 19 Jan 2012 22:09:17 +0900 Subject: Added Colin (moshen@github) to ACKNOWLEDGMENTS. --- ChangeLog | 3 +++ README | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c28a861050..9b5cf47d8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,9 @@ * qrenc.c: - Code refactoring. - Now you can omit "-o -" for EPS and ANSI output. + * README: + - Added Colin (moshen@github) to ACKNOWLEDGMENTS. + - Added zapster's real name to ACKNOWLEDGMENTS. 2011.12.12 Kentaro FUKUCHI [3.2.1] diff --git a/README b/README index 0e741a3f9c..e4b478b0f6 100644 --- a/README +++ b/README @@ -120,10 +120,11 @@ countries. Reed-Solomon encoder is written by Phil Karn, KA9Q. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q -NANKI Haruo - improved lower-case characteres encoding -Philippe Delcroix - improved mask evaluation -Yusuke Mihara - structured-append support -David Dahl - DPI patch -Adam Shepherd - bug fix patch of the mask evaluation -zapster - EPS support patch +NANKI Haruo - improved lower-case characteres encoding +Philippe Delcroix - improved mask evaluation +Yusuke Mihara - structured-append support +David Dahl - DPI patch +Adam Shepherd - bug fix patch of the mask evaluation +Josef Eisl (zapster) - EPS support patch +Colin (moshen) - ANSI support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From a8979a6dc8cfaf1c1fbca8558bcd2011cc3fbd8e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 19 Jan 2012 22:11:24 +0900 Subject: Default margin size has been rollbacked to 4 for ANSI(256). --- ChangeLog | 1 + qrenc.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b5cf47d8b..6d1ad76b17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ * qrenc.c: - Code refactoring. - Now you can omit "-o -" for EPS and ANSI output. + - Default margin size has been rollbacked to 4 for ANSI(256). * README: - Added Colin (moshen@github) to ACKNOWLEDGMENTS. - Added zapster's real name to ACKNOWLEDGMENTS. diff --git a/qrenc.c b/qrenc.c index b43c5708e7..a855e2c948 100644 --- a/qrenc.c +++ b/qrenc.c @@ -668,10 +668,8 @@ int main(int argc, char **argv) } else if(strcasecmp(optarg, "eps") == 0) { image_type = EPS_TYPE; } else if(strcasecmp(optarg, "ansi") == 0) { - margin = 1; image_type = ANSI_TYPE; } else if(strcasecmp(optarg, "ansi256") == 0) { - margin = 1; image_type = ANSI256_TYPE; } else { fprintf(stderr, "Invalid image type: %s\n", optarg); -- cgit 0.0.5-2-1-g0f52 From 4b296731cb933d85ea2ffdedf04cda8c5e43aa08 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 31 Jan 2012 12:10:24 +0900 Subject: Recent 3.2 branch's development has been merged into the master. --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6d1ad76b17..e912fe4dd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.01.31 Kentaro FUKUCHI + [master] + * Recent 3.2 branch has been merged into the master. + 2012.01.19 Kentaro FUKUCHI [3.2.1] * cofigure.ac, qrencode.[hc], qrenc.c, tests/test_qrencode.c: -- cgit 0.0.5-2-1-g0f52 From ceab77a99661fb905f3082809adc0774de63fc58 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 31 Jan 2012 12:41:52 +0900 Subject: Quick bug fix intrdocud in 09b72eb3070a36461eb83c1ec5237e4855ee515b. --- ChangeLog | 2 ++ qrenc.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index e912fe4dd4..b518c4c5ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2012.01.31 Kentaro FUKUCHI [master] * Recent 3.2 branch has been merged into the master. + * qrenc.c: + - Quick bug fix introduced in 09b72eb3070a36461eb83c1ec5237e4855ee515b. 2012.01.19 Kentaro FUKUCHI [3.2.1] diff --git a/qrenc.c b/qrenc.c index a855e2c948..2231517801 100644 --- a/qrenc.c +++ b/qrenc.c @@ -532,6 +532,10 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch exit(EXIT_FAILURE); } + if(outfile == NULL) { + fprintf(stderr, "An output filename must be specified to store the structured images.\n"); + exit(EXIT_FAILURE); + } base = strdup(outfile); if(base == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); -- cgit 0.0.5-2-1-g0f52 From 3a45af1988169776d5a3b84e9bd670393caadead Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 28 Feb 2012 18:39:04 +0900 Subject: Added tests/pthread_qrencode. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5a1412ebe0..80e41c5cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ tests/create_frame_pattern tests/create_mqr_frame_pattern tests/frame tests/mqrframe +tests/pthread_qrencode tests/prof_qrencode tests/test_bitstream tests/test_estimatebit -- cgit 0.0.5-2-1-g0f52 From 46859665bc10161c856ff7e30691e55e0a5c9759 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 28 Feb 2012 18:54:14 +0900 Subject: Added "tests/pthread_qrencode". --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index b518c4c5ee..a34381f169 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012.02.28 Kentaro FUKUCHI + [master, 3.2.1] + * .gitignore + - Added "pthread_qrencode". + 2012.01.31 Kentaro FUKUCHI [master] * Recent 3.2 branch has been merged into the master. -- cgit 0.0.5-2-1-g0f52 From 4b8c7f4f69b82567461e158c401a51aeda6c1004 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 28 Feb 2012 18:55:12 +0900 Subject: Added "tests/pthread_qrencode". --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a34381f169..2d4dbae31a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ 2012.02.28 Kentaro FUKUCHI [master, 3.2.1] * .gitignore - - Added "pthread_qrencode". + - Added "tests/pthread_qrencode". 2012.01.31 Kentaro FUKUCHI [master] -- cgit 0.0.5-2-1-g0f52 From 65f304a1765996846666b963261c9068b8d1f455 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 28 Feb 2012 19:19:33 +0900 Subject: 3.3 branch has been created. --- ChangeLog | 5 +++++ NEWS | 2 +- README | 4 ++-- configure.ac | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d4dbae31a..e3ea166c63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ [master, 3.2.1] * .gitignore - Added "tests/pthread_qrencode". + [3.3] + * 3.3 branch has been started. + - 3.2.1 has been canceled. + * configure.ac, README, NEWS: + - Version number changes. 2012.01.31 Kentaro FUKUCHI [master] diff --git a/NEWS b/NEWS index 3f0ef024c7..c39bac7318 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.2.1 (2012.x.x) +Version 3.3.0 (2012.x.x) ------------------------- * EPS and ANSI text output supports have been added. (Thanks to Zapster and Colin) diff --git a/README b/README index e4b478b0f6..d2b221e623 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.2.1 - QR Code encoding library +libqrencode 3.3.0 - QR Code encoding library GENERAL INFORMATION =================== @@ -76,7 +76,7 @@ application. LICENSING INFORMATION ===================== -Copyright (C) 2006-2011 Kentaro Fukuchi +Copyright (C) 2006-2012 Kentaro Fukuchi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free diff --git a/configure.ac b/configure.ac index 0d511f426b..ddcc86170a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ AC_INIT(QRencode) MAJOR_VERSION=3 -MINOR_VERSION=2 -MICRO_VERSION=1 +MINOR_VERSION=3 +MICRO_VERSION=0 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 61974a4cf2cc1d96cd84156dc876999f34d1d749 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 28 Feb 2012 19:27:08 +0900 Subject: Release date updated. Copyright years updated. --- qrenc.c | 2 +- qrencode.1.in | 4 ++-- qrencode.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qrenc.c b/qrenc.c index 2231517801..d8bdcf8a4c 100644 --- a/qrenc.c +++ b/qrenc.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code encoding tool - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2012 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrencode.1.in b/qrencode.1.in index 3887ba7e41..cbedb21418 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -1,4 +1,4 @@ -.TH QRENCODE 1 "Nov. 23, 2011" "qrencode @VERSION@" +.TH QRENCODE 1 "Feb. 29, 2012" "qrencode @VERSION@" .SH NAME qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS @@ -84,4 +84,4 @@ Main Web Site: http://fukuchi.org/works/qrencode/ Source code repository: https://github.com/fukuchi/libqrencode/ .SH COPYRIGHT -Copyright (C) 2006-2011 Kentaro Fukuchi. +Copyright (C) 2006-2012 Kentaro Fukuchi. diff --git a/qrencode.c b/qrencode.c index 169f6b31e8..d166a24812 100644 --- a/qrencode.c +++ b/qrencode.c @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2012 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public -- cgit 0.0.5-2-1-g0f52 From 6242c370f4a6efe1767c0072dced57ba64ce1ccd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 30 Mar 2012 19:40:38 +0900 Subject: Replaced obsolete macro LIBPTHREAD with LIBS. (thx to gniibe) --- ChangeLog | 7 ++++++- libqrencode.pc.in | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3ea166c63..503a745f08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ +2012.03.30 Kentaro FUKUCHI + [3.2] + * libqrencode.pc.in : + - Replaced obsolete macro LIBPTHREAD with LIBS. (thx to gniibe) + 2012.02.28 Kentaro FUKUCHI [master, 3.2.1] - * .gitignore + * .gitignore: - Added "tests/pthread_qrencode". [3.3] * 3.3 branch has been started. diff --git a/libqrencode.pc.in b/libqrencode.pc.in index ac4673d3f7..94be41097a 100644 --- a/libqrencode.pc.in +++ b/libqrencode.pc.in @@ -6,5 +6,5 @@ includedir=@includedir@ Name: libqrencode Description: A QR Code encoding library Version: @VERSION@ -Libs: -L${libdir} -lqrencode @LIBPTHREAD@ +Libs: -L${libdir} -lqrencode @LIBS@ Cflags: -I${includedir} -- cgit 0.0.5-2-1-g0f52 From ce9baf24c0039a13d7242a8bd6fa19e0a80c9626 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 30 Mar 2012 19:49:30 +0900 Subject: Checks $ac_cv_lib_pthread_pthread_mutex_init instead of HAVE_LIBPTHREAD. (thx to gniibe) --- ChangeLog | 4 +++- configure.ac | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 503a745f08..ec2a6aa185 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,9 @@ 2012.03.30 Kentaro FUKUCHI - [3.2] * libqrencode.pc.in : - Replaced obsolete macro LIBPTHREAD with LIBS. (thx to gniibe) + * configure.ac: + - Checks $ac_cv_lib_pthread_pthread_mutex_init instead of + HAVE_LIBPTHREAD. (thx to gniibe) 2012.02.28 Kentaro FUKUCHI [master, 3.2.1] diff --git a/configure.ac b/configure.ac index ddcc86170a..c59523f0e7 100644 --- a/configure.ac +++ b/configure.ac @@ -44,7 +44,7 @@ AC_ARG_ENABLE([thread-safety], [AS_HELP_STRING([--enable-thread-safety], [make t if test x$enable_thread_safety = xyes; then AC_CHECK_LIB([pthread], [pthread_mutex_init]) fi -AM_CONDITIONAL([HAVE_LIBPTHREAD], [test "x$HAVE_LIBPTHREAD" = "xyes" ]) +AM_CONDITIONAL([HAVE_LIBPTHREAD], [test "x$ac_cv_lib_pthread_pthread_mutex_init" = "xyes" ]) dnl --with-tools -- cgit 0.0.5-2-1-g0f52 From 04795ee456612dfdd68aacddea1e2e4604436519 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 31 Mar 2012 12:04:59 +0900 Subject: 3.3 release mishmash. --- NEWS | 7 ++++++- README | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index c39bac7318..18f44b4c96 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.3.0 (2012.x.x) +Version 3.3.0 (2012.4.1) ------------------------- * EPS and ANSI text output supports have been added. (Thanks to Zapster and Colin) @@ -11,6 +11,11 @@ Release Note: Two new output format, EPS and ANSI text, have been added to the command line tool. +Version 3.2.1 (2012.4.1) +------------------------- +* Bugs in configure script and libtool file has been fixed. (Thanks to Yutaka + Niibe) + Version 3.2.0 (2011.11.26) -------------------------- * "--dpi" (or "-d") option has been added to qrencode. This option set DPI diff --git a/README b/README index d2b221e623..02e98bfa05 100644 --- a/README +++ b/README @@ -127,4 +127,5 @@ David Dahl - DPI patch Adam Shepherd - bug fix patch of the mask evaluation Josef Eisl (zapster) - EPS support patch Colin (moshen) - ANSI support patch -Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom - bug report / suggestion +Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Yutaka Niibe (gniibe) + - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From c4ae0215860f313e588b56527f4d618740335862 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 31 Mar 2012 14:27:27 +0900 Subject: Copyright year has been updated. --- ChangeLog | 9 +++++++++ qrenc.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ec2a6aa185..b8b6780831 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012.03.31 Kentaro FUKUCHI + [3.2] + * README, NEWS, configure.ac: + - Bumped version to 3.2.1. + * Version 3.2.1 has been released. + [3.3] + * qrenc.c: + - Copyright year has been updated. + 2012.03.30 Kentaro FUKUCHI * libqrencode.pc.in : - Replaced obsolete macro LIBPTHREAD with LIBS. (thx to gniibe) diff --git a/qrenc.c b/qrenc.c index d8bdcf8a4c..8f7a956c9b 100644 --- a/qrenc.c +++ b/qrenc.c @@ -76,7 +76,7 @@ static void usage(int help, int longopt) { fprintf(stderr, "qrencode version %s\n" -"Copyright (C) 2006-2011 Kentaro Fukuchi\n", QRcode_APIVersionString()); +"Copyright (C) 2006-2012 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { if(longopt) { fprintf(stderr, -- cgit 0.0.5-2-1-g0f52 From 89618d5af476c52510cd29cd93cb18115d70d00c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Apr 2012 00:04:56 +0900 Subject: ASCII mode has been added. (Thanks to Ralf Ertzinger) --- ChangeLog | 5 +++ README | 1 + qrenc.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 106 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8b6780831..770d79cac6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012.04.01 Kentaro FUKUCHI + [3.3] + * qrenc.c: + - ASCII mode has been added. (Thanks to Ralf Ertzinger) + 2012.03.31 Kentaro FUKUCHI [3.2] * README, NEWS, configure.ac: diff --git a/README b/README index 02e98bfa05..1c7e0a5e7c 100644 --- a/README +++ b/README @@ -127,5 +127,6 @@ David Dahl - DPI patch Adam Shepherd - bug fix patch of the mask evaluation Josef Eisl (zapster) - EPS support patch Colin (moshen) - ANSI support patch +Ralf Ertzinger - ASCII support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Yutaka Niibe (gniibe) - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index 8f7a956c9b..11173a9ffc 100644 --- a/qrenc.c +++ b/qrenc.c @@ -46,7 +46,9 @@ enum imageType { PNG_TYPE, EPS_TYPE, ANSI_TYPE, - ANSI256_TYPE + ANSI256_TYPE, + ASCII_TYPE, + ASCIIi_TYPE }; static enum imageType image_type = PNG_TYPE; @@ -100,7 +102,7 @@ static void usage(int help, int longopt) " specify the width of the margins. (default=4 (2 for Micro)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,EPS,ANSI,ANSI256}, --type={PNG,EPS,ANSI,ANSI256}\n" +" -t {PNG,EPS,ANSI,ANSI256,ASCII}, --type={PNG,EPS,ANSI,ANSI256,ASCII}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" @@ -132,7 +134,7 @@ static void usage(int help, int longopt) " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,EPS,ANSI,ANSI256}\n" +" -t {PNG,EPS,ANSI,ANSI256,ASCII}\n" " specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" @@ -442,6 +444,85 @@ static int writeANSI(QRcode *qrcode, const char *outfile) return 0; } +static void writeASCII_margin(FILE* fp, int realwidth, char* buffer, int buffer_s, int invert) +{ + int y, h; + + h = margin; + + memset(buffer, (invert?'#':' '), realwidth); + buffer[realwidth] = '\n'; + buffer[realwidth + 1] = '\0'; + for(y=0; ywidth + margin * 2) * 2; + buffer_s = realwidth + 1; + buffer = (char *)malloc( buffer_s ); + if(buffer == NULL) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(EXIT_FAILURE); + } + + /* top margin */ + writeASCII_margin(fp, realwidth, buffer, buffer_s, invert); + + /* data */ + for(y=0; ywidth; y++) { + row = qrcode->data+(y*qrcode->width); + p = buffer; + + memset(p, white, margin * 2); + p += margin * 2; + + for(x=0; xwidth; x++) { + if(row[x]&0x1) { + *p++ = black; + *p++ = black; + } else { + *p++ = white; + *p++ = white; + } + } + + memset(p, white, margin * 2); + p += margin * 2; + *p++ = '\n'; + *p++ = '\0'; + fputs( buffer, fp ); + } + + /* bottom margin */ + writeASCII_margin(fp, realwidth, buffer, buffer_s, invert); + + fclose(fp); + free(buffer); + + return 0; +} + static QRcode *encode(const unsigned char *intext, int length) { QRcode *code; @@ -485,6 +566,12 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil case ANSI256_TYPE: writeANSI(qrcode, outfile); break; + case ASCIIi_TYPE: + writeASCII(qrcode, outfile, 1); + break; + case ASCII_TYPE: + writeASCII(qrcode, outfile, 0); + break; default: fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); @@ -579,6 +666,12 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case ANSI256_TYPE: writeANSI(p->code, filename); break; + case ASCIIi_TYPE: + writeASCII(p->code, filename, 1); + break; + case ASCII_TYPE: + writeASCII(p->code, filename, 0); + break; default: fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); @@ -675,6 +768,10 @@ int main(int argc, char **argv) image_type = ANSI_TYPE; } else if(strcasecmp(optarg, "ansi256") == 0) { image_type = ANSI256_TYPE; + } else if(strcasecmp(optarg, "asciii") == 0) { + image_type = ASCIIi_TYPE; + } else if(strcasecmp(optarg, "ascii") == 0) { + image_type = ASCII_TYPE; } else { fprintf(stderr, "Invalid image type: %s\n", optarg); exit(EXIT_FAILURE); -- cgit 0.0.5-2-1-g0f52 From 2e6cea83308f106fa0acd915c05cbef7e25498a6 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Apr 2012 00:12:00 +0900 Subject: Small code cleanups. --- ChangeLog | 1 + qrenc.c | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 770d79cac6..5a70af9d35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ [3.3] * qrenc.c: - ASCII mode has been added. (Thanks to Ralf Ertzinger) + - Small code cleanups. 2012.03.31 Kentaro FUKUCHI [3.2] diff --git a/qrenc.c b/qrenc.c index 11173a9ffc..bf4cbb6930 100644 --- a/qrenc.c +++ b/qrenc.c @@ -346,15 +346,12 @@ static void writeANSI_margin(FILE* fp, int realwidth, char* buffer, int buffer_s, char* white, int white_s ) { - int x, y; + int y; - for(x=0; xcode, filename); break; case ANSI_TYPE: - writeANSI(p->code, filename); - break; case ANSI256_TYPE: writeANSI(p->code, filename); break; -- cgit 0.0.5-2-1-g0f52 From 7d0f258d9a1e4727d7df2d0d66be10084d320825 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Apr 2012 00:29:02 +0900 Subject: ASCII mode now handles ".txt" suffix correctly. --- ChangeLog | 1 + qrenc.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a70af9d35..6e4985283a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * qrenc.c: - ASCII mode has been added. (Thanks to Ralf Ertzinger) - Small code cleanups. + - ASCII mode now handles ".txt" suffix correctly. 2012.03.31 Kentaro FUKUCHI [3.2] diff --git a/qrenc.c b/qrenc.c index bf4cbb6930..bfc63a010b 100644 --- a/qrenc.c +++ b/qrenc.c @@ -604,9 +604,8 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch type_suffix = ".eps"; break; case ANSI_TYPE: - type_suffix = ".txt"; - break; case ANSI256_TYPE: + case ASCII_TYPE: type_suffix = ".txt"; break; default: -- cgit 0.0.5-2-1-g0f52 From d9bbf85f25fd3dff1b62abc60bee41d01e461a81 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Apr 2012 00:37:56 +0900 Subject: Documentation updates. --- NEWS | 12 ++++++++---- README | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 18f44b4c96..634c980cf7 100644 --- a/NEWS +++ b/NEWS @@ -3,13 +3,17 @@ libqrencode NEWS - Overview of changes Version 3.3.0 (2012.4.1) ------------------------- -* EPS and ANSI text output supports have been added. - (Thanks to Zapster and Colin) +* EPS, ANSI, and ASCII text output supports have been added. + (Thanks to Zapster, Colin, and Ralf) * QRcode_APIVersion() and QRcode_APIVersionString() have been added. Release Note: -Two new output format, EPS and ANSI text, have been added to the command line -tool. +Three new output format, EPS, ANSI, and ASCII text, have been added to the +command line tool. ANSI and ASCII mode ignore "-size" option. Give "-t ASCIIi" +to get an ASCII-mode symbol in inverted color. + +QRcode_APIVersion() is requested by Matthew Baker for better support of Python +ctypes binding. Check them out at https://code.google.com/p/libqrencode-ctypes/ Version 3.2.1 (2012.4.1) ------------------------- diff --git a/README b/README index 1c7e0a5e7c..e81a68be2a 100644 --- a/README +++ b/README @@ -128,5 +128,5 @@ Adam Shepherd - bug fix patch of the mask evaluation Josef Eisl (zapster) - EPS support patch Colin (moshen) - ANSI support patch Ralf Ertzinger - ASCII support patch -Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Yutaka Niibe (gniibe) - - bug report / suggestion +Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Yutaka Niibe (gniibe), +Matthew Baker - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From ccfb3de15ba9273b01f85f0cbdace122821d6f99 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Apr 2012 00:40:55 +0900 Subject: Version 3.3.0 has been released. --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6e4985283a..0b3898e204 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ - ASCII mode has been added. (Thanks to Ralf Ertzinger) - Small code cleanups. - ASCII mode now handles ".txt" suffix correctly. + * NEWS, README: + - Documentation updates. + * Version 3.3.0 has been released. 2012.03.31 Kentaro FUKUCHI [3.2] -- cgit 0.0.5-2-1-g0f52 From 116cf3005aff11d4fbaee19751d0ae3e1e4e7096 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Apr 2012 00:55:17 +0900 Subject: Merged to 3.3.0. --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0b3898e204..7d52319381 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ * NEWS, README: - Documentation updates. * Version 3.3.0 has been released. + [master] + * Merged to 3.3.0. 2012.03.31 Kentaro FUKUCHI [3.2] -- cgit 0.0.5-2-1-g0f52 From 4d69b10ef3f2993ede05f61145d2959f24445e90 Mon Sep 17 00:00:00 2001 From: Repox Date: Tue, 3 Apr 2012 16:43:04 +0200 Subject: Added SVG output addressing issue #8 --- qrenc.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index bfc63a010b..e13cfce0a3 100644 --- a/qrenc.c +++ b/qrenc.c @@ -45,6 +45,7 @@ static QRencodeMode hint = QR_MODE_8; enum imageType { PNG_TYPE, EPS_TYPE, + SVG_TYPE, ANSI_TYPE, ANSI256_TYPE, ASCII_TYPE, @@ -102,7 +103,7 @@ static void usage(int help, int longopt) " specify the width of the margins. (default=4 (2 for Micro)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,EPS,ANSI,ANSI256,ASCII}, --type={PNG,EPS,ANSI,ANSI256,ASCII}\n" +" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII}, --type={PNG,EPS,SVG,ANSI,ANSI256,ASCII}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" @@ -342,6 +343,47 @@ static int writeEPS(QRcode *qrcode, const char *outfile) return 0; } +static int writeSVG(QRcode *qrcode, const char *outfile) +{ + FILE *fp; + unsigned char *row, *p; + int x, y, yy, xx; + int realwidth; + int middle; + + fp = openFile(outfile); + + realwidth = (qrcode->width + margin * 2) * size; + middle = realwidth / 2; + + /* EPS file header */ + fprintf(fp, "\n" + "\n" + "\t\n" + , realwidth, realwidth, middle, middle); + + /* data */ + p = qrcode->data; + for(y=0; ywidth; y++) { + row = (p+(y*qrcode->width)); + yy = (margin + qrcode->width - y - 1); + yy = yy * size; + for(x=0; xwidth; x++) { + if(*(row+x)&0x1) { + xx = margin + x; + xx = xx * size; + // Swapping xx and yy as the QR code will be mirrored (unreadable) otherwise + fprintf(fp, "\t\t\n", yy, xx, size, size); + } + } + } + + fprintf(fp, "\t\n"); + fclose(fp); + + return 0; +} + static void writeANSI_margin(FILE* fp, int realwidth, char* buffer, int buffer_s, char* white, int white_s ) @@ -557,6 +599,9 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil case EPS_TYPE: writeEPS(qrcode, outfile); break; + case SVG_TYPE: + writeSVG(qrcode, outfile); + break; case ANSI_TYPE: case ANSI256_TYPE: writeANSI(qrcode, outfile); @@ -603,6 +648,9 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case EPS_TYPE: type_suffix = ".eps"; break; + case SVG_TYPE: + type_suffix = ".svg"; + break; case ANSI_TYPE: case ANSI256_TYPE: case ASCII_TYPE: @@ -654,6 +702,9 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case EPS_TYPE: writeEPS(p->code, filename); break; + case SVG_TYPE: + writeSVG(p->code, filename); + break; case ANSI_TYPE: case ANSI256_TYPE: writeANSI(p->code, filename); @@ -756,6 +807,8 @@ int main(int argc, char **argv) image_type = PNG_TYPE; } else if(strcasecmp(optarg, "eps") == 0) { image_type = EPS_TYPE; + } else if(strcasecmp(optarg, "svg") == 0) { + image_type = SVG_TYPE; } else if(strcasecmp(optarg, "ansi") == 0) { image_type = ANSI_TYPE; } else if(strcasecmp(optarg, "ansi256") == 0) { -- cgit 0.0.5-2-1-g0f52 From d5211ab46b6e2cc58930280c084ec877f9638c9e Mon Sep 17 00:00:00 2001 From: Repox Date: Tue, 3 Apr 2012 17:57:23 +0200 Subject: Added the SVG in the short help --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index e13cfce0a3..b1928ef0d4 100644 --- a/qrenc.c +++ b/qrenc.c @@ -135,7 +135,7 @@ static void usage(int help, int longopt) " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,EPS,ANSI,ANSI256,ASCII}\n" +" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII}\n" " specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" -- cgit 0.0.5-2-1-g0f52 From de4340693b55e45e5176996d0ea6e5f1f4c3e87a Mon Sep 17 00:00:00 2001 From: Repox Date: Wed, 4 Apr 2012 14:44:49 +0200 Subject: Removed white background and margin for SVG output --- qrenc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/qrenc.c b/qrenc.c index e13cfce0a3..fd4efaed7e 100644 --- a/qrenc.c +++ b/qrenc.c @@ -135,7 +135,7 @@ static void usage(int help, int longopt) " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,EPS,ANSI,ANSI256,ASCII}\n" +" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII}\n" " specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" @@ -354,24 +354,22 @@ static int writeSVG(QRcode *qrcode, const char *outfile) fp = openFile(outfile); realwidth = (qrcode->width + margin * 2) * size; - middle = realwidth / 2; + middle = (qrcode->width * size) / 2; - /* EPS file header */ + /* SVG file header */ fprintf(fp, "\n" - "\n" "\t\n" - , realwidth, realwidth, middle, middle); - + , middle, middle); + /* data */ p = qrcode->data; for(y=0; ywidth; y++) { row = (p+(y*qrcode->width)); - yy = (margin + qrcode->width - y - 1); + yy = (qrcode->width - y - 1); yy = yy * size; for(x=0; xwidth; x++) { if(*(row+x)&0x1) { - xx = margin + x; - xx = xx * size; + xx = x * size; // Swapping xx and yy as the QR code will be mirrored (unreadable) otherwise fprintf(fp, "\t\t\n", yy, xx, size, size); } -- cgit 0.0.5-2-1-g0f52 From eb7ef02522f86351da48ede10c5e99500839d50a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 10 Apr 2012 01:42:20 +0900 Subject: "Hyphen-used-as-minus-sign" error has been fixed. (Thanks to Yutaka Niibe) --- ChangeLog | 6 ++++++ qrencode.1.in | 38 +++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d52319381..3c6142fb1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012.04.10 Kentaro FUKUCHI + [master] + * Following fixes have been contributed by Yutaka Niibe. + * qrencode.1.in: + - "Hyphen-used-as-minus-sign" error has been fixed. + 2012.04.01 Kentaro FUKUCHI [3.3] * qrenc.c: diff --git a/qrencode.1.in b/qrencode.1.in index cbedb21418..072e6e4dd7 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -17,49 +17,49 @@ a QR Code and save as a PNG or EPS image. .SH OPTIONS .TP -.B \-h, --help +.B \-h, \-\-help display help message. .TP -.B \-o FILENAME, --output=FILENAME -write image to FILENAME. If '-' is specified, the result will be output to standard output. If -S is given, structured symbols are written to FILENAME-01.png, FILENAME-02.png, ... (suffix is removed from FILENAME, if specified) +.B \-o FILENAME, \-\-output=FILENAME +write image to FILENAME. If '\-' is specified, the result will be output to standard output. If \-S is given, structured symbols are written to FILENAME-01.png, FILENAME-02.png, ... (suffix is removed from FILENAME, if specified) .TP -.B \-s NUMBER, --size=NUMBER +.B \-s NUMBER, \-\-size=NUMBER specify the size of dot (pixel). (default=3) .TP -.B \-l {LMQH}, --level={LMQH} +.B \-l {LMQH}, \-\-level={LMQH} specify error collectin level from L (lowest) to H (highest). (default=L) .TP -.B \-v NUMBER, --symversion=NUMBER +.B \-v NUMBER, \-\-symversion=NUMBER specify the version of the symbol. (default=auto) .TP -.B \-m NUMBER, --margin=NUMBER +.B \-m NUMBER, \-\-margin=NUMBER specify the width of margin. (default=4) .TP -.B \-d NUMBER, --dpi=NUMBER +.B \-d NUMBER, \-\-dpi=NUMBER specify the DPI of the generated PNG. (default=72) .TP -.B \-t {PNG,EPS,ANSI,ANSI256}, --type={PNG,EPS,ANSI,ANSI256} +.B \-t {PNG,EPS,ANSI,ANSI256}, \-\-type={PNG,EPS,ANSI,ANSI256} specify the type of the generated image. (default=PNG) .TP -.B \-S, --structured +.B \-S, \-\-structured make structured symbols. Version must be specified. .TP -.B \-k, --kanji +.B \-k, \-\-kanji assume that the input text contains kanji (shift-jis). .TP -.B \-c, --casesensitive +.B \-c, \-\-casesensitive encode lower-case alphabet characters in 8-bit mode. (default) .TP -.B \-i, --ignorecase +.B \-i, \-\-ignorecase ignore case distinctions and use only upper-case characters. .TP -.B \-8, --8bit -encode entire data in 8-bit mode. -k, -c and -i will be ignored. +.B \-8, \-\-8bit +encode entire data in 8-bit mode. \-k, \-c and \-i will be ignored. .TP -.B \-M, --micro +.B \-M, \-\-micro encode in a Micro QR Code. (experimental) .TP -.B \-V, --version +.B \-V, \-\-version display the version number and copyrights of the qrencode. .TP .B [STRING] @@ -67,10 +67,10 @@ input data. If it is not specified, data will be taken from standard input. .SH EXAMPLES .TP -.B qrencode -l L -v 1 -o output.png 'Hello, world!' +.B qrencode \-l L \-v 1 \-o output.png 'Hello, world!' encode into a symbol version 1, level L. .TP -.B qrencode -iSv 1 --output=output.png +.B qrencode \-iSv 1 \-\-output=output.png read standard input and encode it into a structured-appended symbols in case-insensitive mode. -- cgit 0.0.5-2-1-g0f52 From d5112330e763a6691a6e98c6aed1c417b2b5a0ae Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 10 Apr 2012 02:06:37 +0900 Subject: Explicit link to libpthread has been eliminated. --- ChangeLog | 2 ++ README | 21 +++++++++++---------- configure.ac | 2 +- libqrencode.pc.in | 3 ++- tests/Makefile.am | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c6142fb1b..3547d1ab99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * Following fixes have been contributed by Yutaka Niibe. * qrencode.1.in: - "Hyphen-used-as-minus-sign" error has been fixed. + * configure.ac, libqrencode.pc.in, tests/Makefile.am: + - Explicit link to libpthread has been eliminated. 2012.04.01 Kentaro FUKUCHI [3.3] diff --git a/README b/README index e81a68be2a..f11ed91629 100644 --- a/README +++ b/README @@ -120,13 +120,14 @@ countries. Reed-Solomon encoder is written by Phil Karn, KA9Q. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q -NANKI Haruo - improved lower-case characteres encoding -Philippe Delcroix - improved mask evaluation -Yusuke Mihara - structured-append support -David Dahl - DPI patch -Adam Shepherd - bug fix patch of the mask evaluation -Josef Eisl (zapster) - EPS support patch -Colin (moshen) - ANSI support patch -Ralf Ertzinger - ASCII support patch -Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Yutaka Niibe (gniibe), -Matthew Baker - bug report / suggestion +NANKI Haruo - improved lower-case characteres encoding +Philippe Delcroix - improved mask evaluation +Yusuke Mihara - structured-append support +David Dahl - DPI patch +Adam Shepherd - bug fix patch of the mask evaluation +Josef Eisl (zapster) - EPS support patch +Colin (moshen) - ANSI support patch +Ralf Ertzinger - ASCII support patch +Yutaka Niibe (gniibe) - various bug fix patches +Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker + - bug report / suggestion diff --git a/configure.ac b/configure.ac index c59523f0e7..d51263169d 100644 --- a/configure.ac +++ b/configure.ac @@ -42,7 +42,7 @@ AC_ARG_ENABLE([thread-safety], [AS_HELP_STRING([--enable-thread-safety], [make t [], [enable_thread_safety=yes]) if test x$enable_thread_safety = xyes; then - AC_CHECK_LIB([pthread], [pthread_mutex_init]) + AC_CHECK_LIB([pthread], [pthread_mutex_init], [AC_SUBST([LIBPTHREAD], [-lpthread])]) fi AM_CONDITIONAL([HAVE_LIBPTHREAD], [test "x$ac_cv_lib_pthread_pthread_mutex_init" = "xyes" ]) diff --git a/libqrencode.pc.in b/libqrencode.pc.in index 94be41097a..ef6afbdf21 100644 --- a/libqrencode.pc.in +++ b/libqrencode.pc.in @@ -6,5 +6,6 @@ includedir=@includedir@ Name: libqrencode Description: A QR Code encoding library Version: @VERSION@ -Libs: -L${libdir} -lqrencode @LIBS@ +Libs: -L${libdir} -lqrencode +Libs.private: @LIBPTHREAD@ Cflags: -I${includedir} diff --git a/tests/Makefile.am b/tests/Makefile.am index d66237fe36..92eda902c4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -55,7 +55,7 @@ prof_qrencode_SOURCES = prof_qrencode.c prof_qrencode_LDADD = ../libqrencode.la pthread_qrencode_SOURCES = pthread_qrencode.c -pthread_qrencode_LDADD = ../libqrencode.la +pthread_qrencode_LDADD = ../libqrencode.la $(LIBPTHREAD) create_frame_pattern_SOURCES = create_frame_pattern.c create_frame_pattern_CFLAGS = $(png_CFLAGS) -- cgit 0.0.5-2-1-g0f52 From b7c770a480d602a8c3695539a21f342d5a52450d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 10 Apr 2012 02:11:50 +0900 Subject: Bumpled verstion to 3.3.1. --- ChangeLog | 3 +++ NEWS | 5 +++++ README | 2 +- configure.ac | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3547d1ab99..a7aa6f0004 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ - "Hyphen-used-as-minus-sign" error has been fixed. * configure.ac, libqrencode.pc.in, tests/Makefile.am: - Explicit link to libpthread has been eliminated. + [3.3] + * README, configure.ac: + - Bumped version to 3.3.1. 2012.04.01 Kentaro FUKUCHI [3.3] diff --git a/NEWS b/NEWS index 634c980cf7..32cd94c6a5 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ libqrencode NEWS - Overview of changes ====================================== +Version 3.3.1 (2012.4.11) +------------------------- +* Bugs in manual, configure script, and libtool files have been fixed. (Thanks + to Yutaka Niibe) + Version 3.3.0 (2012.4.1) ------------------------- * EPS, ANSI, and ASCII text output supports have been added. diff --git a/README b/README index f11ed91629..4ec7224536 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.3.0 - QR Code encoding library +libqrencode 3.3.1 - QR Code encoding library GENERAL INFORMATION =================== diff --git a/configure.ac b/configure.ac index d51263169d..0e53a0df5c 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_INIT(QRencode) MAJOR_VERSION=3 MINOR_VERSION=3 -MICRO_VERSION=0 +MICRO_VERSION=1 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From cd20baf36766991814712e2676d0c706e9cd0d82 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 10 Apr 2012 02:54:45 +0900 Subject: Pulled request #10 (SVG patch). --- ChangeLog | 3 +++ qrenc.c | 14 +++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3547d1ab99..b7d1eddc7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ - "Hyphen-used-as-minus-sign" error has been fixed. * configure.ac, libqrencode.pc.in, tests/Makefile.am: - Explicit link to libpthread has been eliminated. + * qrenc.c: + - Pulled Repox's SVG patch (Pull request #10). + - Slightly simplified. 2012.04.01 Kentaro FUKUCHI [3.3] diff --git a/qrenc.c b/qrenc.c index fd4efaed7e..8106e4b29b 100644 --- a/qrenc.c +++ b/qrenc.c @@ -348,30 +348,22 @@ static int writeSVG(QRcode *qrcode, const char *outfile) FILE *fp; unsigned char *row, *p; int x, y, yy, xx; - int realwidth; - int middle; fp = openFile(outfile); - realwidth = (qrcode->width + margin * 2) * size; - middle = (qrcode->width * size) / 2; - /* SVG file header */ fprintf(fp, "\n" - "\t\n" - , middle, middle); + "\t\n"); /* data */ p = qrcode->data; for(y=0; ywidth; y++) { row = (p+(y*qrcode->width)); - yy = (qrcode->width - y - 1); - yy = yy * size; + yy = y * size; for(x=0; xwidth; x++) { if(*(row+x)&0x1) { xx = x * size; - // Swapping xx and yy as the QR code will be mirrored (unreadable) otherwise - fprintf(fp, "\t\t\n", yy, xx, size, size); + fprintf(fp, "\t\t\n", xx, yy, size, size); } } } -- cgit 0.0.5-2-1-g0f52 From 0baad748ebc1d74f49071add91806cb4f571c340 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 11 Apr 2012 10:57:15 +0900 Subject: Paper size and margin are now set properly in SVG output. --- ChangeLog | 5 +++++ qrenc.c | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7d1eddc7c..ca6682ba30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012.04.11 Kentaro FUKUCHI + [master] + * qrenc.c: + - Paper size and margin are now set properly in SVG output. + 2012.04.10 Kentaro FUKUCHI [master] * Following fixes have been contributed by Yutaka Niibe. diff --git a/qrenc.c b/qrenc.c index 8106e4b29b..a35a37ca95 100644 --- a/qrenc.c +++ b/qrenc.c @@ -348,21 +348,24 @@ static int writeSVG(QRcode *qrcode, const char *outfile) FILE *fp; unsigned char *row, *p; int x, y, yy, xx; + int realwidth; fp = openFile(outfile); + + realwidth = (qrcode->width + margin * 2) * size; /* SVG file header */ - fprintf(fp, "\n" - "\t\n"); + fprintf(fp, "\n\t\n", + realwidth, realwidth); /* data */ p = qrcode->data; for(y=0; ywidth; y++) { row = (p+(y*qrcode->width)); - yy = y * size; + yy = (y + margin) * size; for(x=0; xwidth; x++) { if(*(row+x)&0x1) { - xx = x * size; + xx = (x + margin) * size; fprintf(fp, "\t\t\n", xx, yy, size, size); } } -- cgit 0.0.5-2-1-g0f52 From 924939c0c46c6562780a2e0f99b605641aa7a79d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 11 Apr 2012 15:16:49 +0900 Subject: Added Ropex's name to Acknowledgments. --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index f11ed91629..c4aa796512 100644 --- a/README +++ b/README @@ -129,5 +129,6 @@ Josef Eisl (zapster) - EPS support patch Colin (moshen) - ANSI support patch Ralf Ertzinger - ASCII support patch Yutaka Niibe (gniibe) - various bug fix patches +Dan Strom (Repox) - SVG support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 17782a2a6209f072f1c912ac09cae3dbc97476fc Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 18 Apr 2012 22:59:02 +0900 Subject: EPS dot size bug has been fixed (closes: #12). --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index bfc63a010b..00fca118ce 100644 --- a/qrenc.c +++ b/qrenc.c @@ -321,7 +321,7 @@ static int writeEPS(QRcode *qrcode, const char *outfile) "0 -1 rlineto " "fill " "} bind def " - "3 3 scale "); + "%d %d scale ", size, size); /* data */ p = qrcode->data; -- cgit 0.0.5-2-1-g0f52 From 86ccc35841967905fda767b448b5004ee28fd388 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 18 Apr 2012 23:09:49 +0900 Subject: Closes #12. --- ChangeLog | 5 +++++ NEWS | 6 +++--- README | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7aa6f0004..ce9a091925 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012.04.18 Kentaro FUKUCHI + [3.3] + * qrenc.c: + - EPS dot size bug has been fixed (closes: #12). + 2012.04.10 Kentaro FUKUCHI [master] * Following fixes have been contributed by Yutaka Niibe. diff --git a/NEWS b/NEWS index 32cd94c6a5..e093044d1c 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,10 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.3.1 (2012.4.11) +Version 3.3.1 (2012.4.18) ------------------------- -* Bugs in manual, configure script, and libtool files have been fixed. (Thanks - to Yutaka Niibe) +* Bugs in command line tool, manual, configure script, and libtool files have + been fixed. (Thanks to Yutaka Niibe and Rob Ryan) Version 3.3.0 (2012.4.1) ------------------------- diff --git a/README b/README index 4ec7224536..4115763f6a 100644 --- a/README +++ b/README @@ -129,5 +129,5 @@ Josef Eisl (zapster) - EPS support patch Colin (moshen) - ANSI support patch Ralf Ertzinger - ASCII support patch Yutaka Niibe (gniibe) - various bug fix patches -Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker +Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From baac80aefd97cadc8cfb8a11e0f3aff208de267f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 18 Apr 2012 23:18:11 +0900 Subject: Version 3.3.1 has been released. --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index ce9a091925..6e52f95588 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ [3.3] * qrenc.c: - EPS dot size bug has been fixed (closes: #12). + * Version 3.3.1 has been released. 2012.04.10 Kentaro FUKUCHI [master] -- cgit 0.0.5-2-1-g0f52 From 2c50ac3fe80b13e83553d86a6ad8717247ac21bd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 21 Apr 2012 17:47:28 +0900 Subject: Incorrect arguments order has been fixed. (Thanks to Fred Steinhaeuser) --- qrencode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrencode.c b/qrencode.c index d166a24812..b1d713d4ab 100644 --- a/qrencode.c +++ b/qrencode.c @@ -137,7 +137,7 @@ __STATIC QRRawCode *QRraw_new(QRinput *input) } raw->blocks = QRspec_rsBlockNum(spec); - raw->rsblock = (RSblock *)calloc(sizeof(RSblock), raw->blocks); + raw->rsblock = (RSblock *)calloc(raw->blocks, sizeof(RSblock)); if(raw->rsblock == NULL) { QRraw_free(raw); return NULL; @@ -232,7 +232,7 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) return NULL; } - raw->rsblock = (RSblock *)calloc(sizeof(RSblock), 1); + raw->rsblock = (RSblock *)calloc(1, sizeof(RSblock)); if(raw->rsblock == NULL) { MQRraw_free(raw); return NULL; -- cgit 0.0.5-2-1-g0f52 From 690cf32b8651d58400ee27ceac25ec15acc1ea74 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 21 Apr 2012 17:50:17 +0900 Subject: Incorrect arguments order has been fixed. (Thank to Fred Steinhaeuser) --- ChangeLog | 4 ++++ README | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6e52f95588..4185ef3042 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.04.21 Kentaro FUKUCHI + * qrenc.c: + - Incorrect arguments order has been fixed. (Thank to Fred Steinhaeuser) + 2012.04.18 Kentaro FUKUCHI [3.3] * qrenc.c: diff --git a/README b/README index 4115763f6a..98913e02a8 100644 --- a/README +++ b/README @@ -129,5 +129,6 @@ Josef Eisl (zapster) - EPS support patch Colin (moshen) - ANSI support patch Ralf Ertzinger - ASCII support patch Yutaka Niibe (gniibe) - various bug fix patches -Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan +Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, +Fred Steinhaeuser - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 52e329b4844c03758a6a53f278db38dd3a82f2eb Mon Sep 17 00:00:00 2001 From: Repox Date: Mon, 25 Jun 2012 10:55:35 +0200 Subject: Corrected spelling --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 0105e094d9..7b80038b42 100644 --- a/README +++ b/README @@ -129,7 +129,7 @@ Josef Eisl (zapster) - EPS support patch Colin (moshen) - ANSI support patch Ralf Ertzinger - ASCII support patch Yutaka Niibe (gniibe) - various bug fix patches -Dan Strom (Repox) - SVG support patch +Dan Storm (Repox) - SVG support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 92e289986723b3fd6ca0092720d00844322d47bf Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 20 Aug 2012 20:50:46 +0200 Subject: qrenc: add output mode for drawing smaller QR codes using UTF8 box drawing characters This patch adds "-t utf8" and "-t ansiutf8" to the qrencode tool, which outputs a QR code using UTF8 box drawing characters. This doubles the density of QR codes printed on terminals, and should be supported by virtuallly all modern terminals, including xterm, gnome-terminal and the Linux console. --- qrenc.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 3 deletions(-) diff --git a/qrenc.c b/qrenc.c index 7575b92f24..8aa387cab1 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1,3 +1,5 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/ + /** * qrencode - QR Code encoder * @@ -49,7 +51,9 @@ enum imageType { ANSI_TYPE, ANSI256_TYPE, ASCII_TYPE, - ASCIIi_TYPE + ASCIIi_TYPE, + UTF8_TYPE, + ANSIUTF8_TYPE }; static enum imageType image_type = PNG_TYPE; @@ -103,7 +107,8 @@ static void usage(int help, int longopt) " specify the width of the margins. (default=4 (2 for Micro)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII}, --type={PNG,EPS,SVG,ANSI,ANSI256,ASCII}\n" +" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={PNG,EPS,\n" +" SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" @@ -135,7 +140,7 @@ static void usage(int help, int longopt) " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII}\n" +" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" " specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" @@ -476,6 +481,82 @@ static int writeANSI(QRcode *qrcode, const char *outfile) return 0; } +static void writeUTF8_margin(FILE* fp, int realwidth, + const char* white, const char *reset, + int use_ansi) +{ + int x, y; + + for (y = 0; y < margin/2; y++) { + fputs(white, fp); + for (x = 0; x < realwidth; x++) + fputs("\342\226\210", fp); + fputs(reset, fp); + fputc('\n', fp); + } +} + +static int writeUTF8(QRcode *qrcode, const char *outfile, int use_ansi) +{ + FILE *fp; + int x, y; + int realwidth; + unsigned char *p; + const char *white, *reset; + + if (use_ansi){ + white = "\033[40;37;1m"; + reset = "\033[0m"; + } else { + white = ""; + reset = ""; + } + + fp = openFile(outfile); + + realwidth = (qrcode->width + margin * 2); + + /* top margin */ + writeUTF8_margin(fp, realwidth, white, reset, use_ansi); + + /* data */ + p = qrcode->data; + for(y = 0; y < qrcode->width; y += 2) { + unsigned char *row1, *row2; + row1 = p + y*qrcode->width; + row2 = p + y*qrcode->width + qrcode->width; + + fputs(white, fp); + + for (x = 0; x < margin; x++) + fputs("\342\226\210", fp); + + for (x = 0; x < qrcode->width; x++) { + if ((*(row1 + x) & 1) && (*(row2 + x) & 1)) + fputc(' ', fp); + else if (*(row1 + x) & 1) + fputs("\342\226\204", fp); + else if (*(row2 + x) & 1) + fputs("\342\226\200", fp); + else + fputs("\342\226\210", fp); + } + + for (x = 0; x < margin; x++) + fputs("\342\226\210", fp); + + fputs(reset, fp); + fputc('\n', fp); + } + + /* bottom margin */ + writeUTF8_margin(fp, realwidth, white, reset, use_ansi); + + fclose(fp); + + return 0; +} + static void writeASCII_margin(FILE* fp, int realwidth, char* buffer, int buffer_s, int invert) { int y, h; @@ -605,6 +686,12 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil case ASCII_TYPE: writeASCII(qrcode, outfile, 0); break; + case UTF8_TYPE: + writeUTF8(qrcode, outfile, 0); + break; + case ANSIUTF8_TYPE: + writeUTF8(qrcode, outfile, 1); + break; default: fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); @@ -647,6 +734,8 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case ANSI_TYPE: case ANSI256_TYPE: case ASCII_TYPE: + case UTF8_TYPE: + case ANSIUTF8_TYPE: type_suffix = ".txt"; break; default: @@ -708,6 +797,13 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case ASCII_TYPE: writeASCII(p->code, filename, 0); break; + case UTF8_TYPE: + writeUTF8(p->code, filename, 0); + break; + case ANSIUTF8_TYPE: + writeUTF8(p->code, filename, 0); + break; + default: fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); @@ -810,6 +906,10 @@ int main(int argc, char **argv) image_type = ASCIIi_TYPE; } else if(strcasecmp(optarg, "ascii") == 0) { image_type = ASCII_TYPE; + } else if(strcasecmp(optarg, "utf8") == 0) { + image_type = UTF8_TYPE; + } else if(strcasecmp(optarg, "ansiutf8") == 0) { + image_type = ANSIUTF8_TYPE; } else { fprintf(stderr, "Invalid image type: %s\n", optarg); exit(EXIT_FAILURE); -- cgit 0.0.5-2-1-g0f52 From b3d5f793a35ae187ab319fe7df31e0fea9bc7124 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 3 Sep 2012 17:44:28 +0900 Subject: Integrated David's SVG patch. --- ChangeLog | 4 +++ qrenc.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index caccc663f5..4fac409832 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.09.03 Kentaro FUKUCHI + * qrenc.c: + - Integrated David's SVG patch. + 2012.04.21 Kentaro FUKUCHI * qrenc.c: - Incorrect arguments order has been fixed. (Thank to Fred Steinhaeuser) diff --git a/qrenc.c b/qrenc.c index 7575b92f24..dcdb16b591 100644 --- a/qrenc.c +++ b/qrenc.c @@ -320,7 +320,7 @@ static int writeEPS(QRcode *qrcode, const char *outfile) "0 1 rlineto " "1 0 rlineto " "0 -1 rlineto " - "fill " + "} bind def " "%d %d scale ", size, size); @@ -343,36 +343,91 @@ static int writeEPS(QRcode *qrcode, const char *outfile) return 0; } -static int writeSVG(QRcode *qrcode, const char *outfile) +static int writeSVG( QRcode *qrcode, const char *outfile ) { FILE *fp; unsigned char *row, *p; - int x, y, yy, xx; + int x, y, x0, pen; int realwidth; + float scale; fp = openFile(outfile); + scale = dpi * INCHES_PER_METER / 100.0; + realwidth = (qrcode->width + margin * 2) * size; - - /* SVG file header */ - fprintf(fp, "\n\t\n", - realwidth, realwidth); - /* data */ + /* XML declaration */ + fputs( "\n", fp ); + + /* DTD + No document type specified because "while a DTD is provided in [the SVG] + specification, the use of DTDs for validating XML documents is known to be + problematic. In particular, DTDs do not handle namespaces gracefully. It + is *not* recommended that a DOCTYPE declaration be included in SVG + documents." + http://www.w3.org/TR/2003/REC-SVG11-20030114/intro.html#Namespace + */ + + /* Vanity remark */ + fprintf( fp, "\n", + QRcode_APIVersionString() ); + + /* SVG code start */ + fprintf( fp, "\n", + realwidth / scale, + realwidth / scale, + qrcode->width + margin * 2, + qrcode->width + margin * 2 + ); + + /* Make named group */ + fputs( "\t\n", fp ); + + /* Make solid background */ + fputs( "\t\t\n", fp ); + + /* Create new viewbox for QR data */ + fputs( "\t\t\n", fp); + + /* Write data */ p = qrcode->data; for(y=0; ywidth; y++) { row = (p+(y*qrcode->width)); - yy = (y + margin) * size; + + /* simple RLE */ + pen = 0; + x0 = 0; for(x=0; xwidth; x++) { - if(*(row+x)&0x1) { - xx = (x + margin) * size; - fprintf(fp, "\t\t\n", xx, yy, size, size); + if( !pen ) { + pen = *(row+x)&0x1; + x0 = x; + } else { + if(!(*(row+x)&0x1)) { + fprintf(fp, "\t\t\t\n", + x0 + margin, y + margin, x-x0 ); + pen = 0; + } } } + if( pen ) + fprintf(fp, "\t\t\t\n", + x0 + margin, y + margin, qrcode->width-x0 ); } - fprintf(fp, "\t\n"); - fclose(fp); + /* Close QR data viewbox */ + fputs( "\t\t\n", fp ); + + /* Close group */ + fputs( "\t\n", fp ); + + /* Close SVG code */ + fputs( "\n", fp ); + fclose( fp ); return 0; } -- cgit 0.0.5-2-1-g0f52 From ff195cf103c04e8799d64753e4cfd41f70374fdd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 4 Sep 2012 13:28:35 +0900 Subject: A bug introduced in 'b3d5f7' has been reverted. (Thanks to Terry) --- ChangeLog | 4 ++++ qrenc.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4fac409832..c7ef4244d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.09.03 Kentaro FUKUCHI + * qrenc.c: + - A bug introduced in 'b3d5f7' has been reverted. (Thanks to Terry) + 2012.09.03 Kentaro FUKUCHI * qrenc.c: - Integrated David's SVG patch. diff --git a/qrenc.c b/qrenc.c index dcdb16b591..ab2c3defbc 100644 --- a/qrenc.c +++ b/qrenc.c @@ -320,7 +320,7 @@ static int writeEPS(QRcode *qrcode, const char *outfile) "0 1 rlineto " "1 0 rlineto " "0 -1 rlineto " - + "fill " "} bind def " "%d %d scale ", size, size); -- cgit 0.0.5-2-1-g0f52 From f85831204c84a4b2f68dfaa68439dde80847f345 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 13 Sep 2012 17:39:06 +0900 Subject: Set XML(SVG) declaration's 'standalone' to 'yes'. --- ChangeLog | 4 ++++ qrenc.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c7ef4244d5..d58f68c36d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.09.13 Kentaro FUKUCHI + * qrenc.c: + - Set XML(SVG) declaration's 'standalone' to 'yes'. + 2012.09.03 Kentaro FUKUCHI * qrenc.c: - A bug introduced in 'b3d5f7' has been reverted. (Thanks to Terry) diff --git a/qrenc.c b/qrenc.c index ab2c3defbc..dde4b09949 100644 --- a/qrenc.c +++ b/qrenc.c @@ -358,7 +358,7 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) realwidth = (qrcode->width + margin * 2) * size; /* XML declaration */ - fputs( "\n", fp ); + fputs( "\n", fp ); /* DTD No document type specified because "while a DTD is provided in [the SVG] -- cgit 0.0.5-2-1-g0f52 From ad16ea8baa929b17a0d7afef9144b73a170f3a2b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 18 Sep 2012 19:21:56 +0900 Subject: Merge pull request #19 from mezcalero/master. --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index d58f68c36d..70f5baf2f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012.09.18 Kentaro FUKUCHI + * qrenc.c: + - Merge pull request #19 from mezcalero/master (UTF-8 box drawing + characters support). + 2012.09.13 Kentaro FUKUCHI * qrenc.c: - Set XML(SVG) declaration's 'standalone' to 'yes'. -- cgit 0.0.5-2-1-g0f52 From 025adb163049e10da3fff48713dffc9b464142c3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 19 Sep 2012 01:58:46 +0900 Subject: Followed Unicode block elements patch. --- qrencode.1.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qrencode.1.in b/qrencode.1.in index 072e6e4dd7..c49ceafe0c 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -38,7 +38,11 @@ specify the width of margin. (default=4) .B \-d NUMBER, \-\-dpi=NUMBER specify the DPI of the generated PNG. (default=72) .TP -.B \-t {PNG,EPS,ANSI,ANSI256}, \-\-type={PNG,EPS,ANSI,ANSI256} +.PD 0 +.B \-t {PNG,EPS,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.TP +.PD +.B \-\-type={PNG,EPS,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} specify the type of the generated image. (default=PNG) .TP .B \-S, \-\-structured -- cgit 0.0.5-2-1-g0f52 From 2132c2c6151d589cc6a857abc1a7b0ef92a94694 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 19 Sep 2012 01:59:02 +0900 Subject: Contributors list has been updated. --- ChangeLog | 10 ++++++++-- README | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70f5baf2f1..7609966cb2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,13 @@ +2012.09.19 Kentaro FUKUCHI + * README: + - Contributors list has been updated. + * qrencode.1.in: + - Followed Unicode block elements patch. + 2012.09.18 Kentaro FUKUCHI * qrenc.c: - - Merge pull request #19 from mezcalero/master (UTF-8 box drawing - characters support). + - Merge pull request #19 from mezcalero/master (Unicode block elements + support). 2012.09.13 Kentaro FUKUCHI * qrenc.c: diff --git a/README b/README index 7b80038b42..b08dd3b68b 100644 --- a/README +++ b/README @@ -123,13 +123,15 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q NANKI Haruo - improved lower-case characteres encoding Philippe Delcroix - improved mask evaluation Yusuke Mihara - structured-append support -David Dahl - DPI patch +David Dahl - DPI and SVG support patch Adam Shepherd - bug fix patch of the mask evaluation Josef Eisl (zapster) - EPS support patch Colin (moshen) - ANSI support patch Ralf Ertzinger - ASCII support patch Yutaka Niibe (gniibe) - various bug fix patches Dan Storm (Repox) - SVG support patch +Lennart Poettering (mezcalero) + - Improved text art patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From cae4640b36c7ddcdbe9e9b37bf2456ccead247db Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 22 Sep 2012 22:54:42 +0900 Subject: Color palette support has been added. --- ChangeLog | 7 +++++ qrenc.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ qrencode.1.in | 9 ++++++ 3 files changed, 96 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7609966cb2..9c1096939b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012.09.22 Kentaro FUKUCHI + * qrenc.c: + - Color palette support has been added. Currently PNG and SVG are + supported + * qrencode.1.in: + - "--foreground" and "--background" options have been added. + 2012.09.19 Kentaro FUKUCHI * README: - Contributors list has been updated. diff --git a/qrenc.c b/qrenc.c index dfae4a1890..7c8eaf7526 100644 --- a/qrenc.c +++ b/qrenc.c @@ -43,6 +43,8 @@ static int structured = 0; static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; +static unsigned int fg_color[4] = {0, 0, 0, 255}; +static unsigned int bg_color[4] = {255, 255, 255, 255}; enum imageType { PNG_TYPE, @@ -73,6 +75,8 @@ static const struct option options[] = { {"ignorecase" , no_argument , NULL, 'i'}, {"8bit" , no_argument , NULL, '8'}, {"micro" , no_argument , NULL, 'M'}, + {"foreground" , required_argument, NULL, 'f'}, + {"background" , required_argument, NULL, 'b'}, {"version" , no_argument , NULL, 'V'}, {NULL, 0, NULL, 0} }; @@ -119,6 +123,11 @@ static void usage(int help, int longopt) " ignore case distinctions and use only upper-case characters.\n\n" " -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" " -M, --micro encode in a Micro QR Code. (experimental)\n\n" +" --foreground=RRGGBB[AA]\n" +" --background=RRGGBB[AA]\n" +" specify foreground/background color in hexadecimal notation.\n" +" 6-digit (RGB) or 8-digit (RGBA) form are supported.\n" +" Color output support available only in PNG and SVG.\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" @@ -156,6 +165,20 @@ static void usage(int help, int longopt) } } +static int color_set(unsigned int color[4], const char *value) +{ + int len = strlen(value); + if(len == 6) { + sscanf(value, "%02x%02x%02x", &color[0], &color[1], &color[2]); + color[3] = 255; + } else if(len == 8) { + sscanf(value, "%02x%02x%02x%02x", &color[0], &color[1], &color[2], &color[3]); + } else { + return -1; + } + return 0; +} + #define MAX_DATA_SIZE (7090 * 16) /* from the specification */ static unsigned char *readStdin(int *length) { @@ -206,6 +229,8 @@ static int writePNG(QRcode *qrcode, const char *outfile) static FILE *fp; // avoid clobbering by setjmp. png_structp png_ptr; png_infop info_ptr; + png_colorp palette; + png_byte alpha_values[2]; unsigned char *row, *p, *q; int x, y, xx, yy, bit; int realwidth; @@ -246,11 +271,23 @@ static int writePNG(QRcode *qrcode, const char *outfile) exit(EXIT_FAILURE); } + palette = (png_colorp) malloc(sizeof(png_color) * 2); + palette[0].red = fg_color[0]; + palette[0].green = fg_color[1]; + palette[0].blue = fg_color[2]; + palette[1].red = bg_color[0]; + palette[1].green = bg_color[1]; + palette[1].blue = bg_color[2]; + alpha_values[0] = fg_color[3]; + alpha_values[1] = bg_color[3]; + png_set_PLTE(png_ptr, info_ptr, palette, 2); + png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL); + png_init_io(png_ptr, fp); png_set_IHDR(png_ptr, info_ptr, realwidth, realwidth, 1, - PNG_COLOR_TYPE_GRAY, + PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); @@ -348,6 +385,19 @@ static int writeEPS(QRcode *qrcode, const char *outfile) return 0; } +static void writeSVG_writeRect(FILE *fp, int x, int y, int width, char* col, float opacity) +{ + if(fg_color[3] != 255) { + fprintf(fp, "\t\t\t\n", + x, y, width, col, opacity ); + } else { + fprintf(fp, "\t\t\t\n", + x, y, width, col ); + } +} + static int writeSVG( QRcode *qrcode, const char *outfile ) { FILE *fp; @@ -355,6 +405,9 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) int x, y, x0, pen; int realwidth; float scale; + char fg[7], bg[7]; + float fg_opacity; + float bg_opacity; fp = openFile(outfile); @@ -362,6 +415,11 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) realwidth = (qrcode->width + margin * 2) * size; + snprintf(fg, 7, "%02x%02x%02x", fg_color[0], fg_color[1], fg_color[2]); + snprintf(bg, 7, "%02x%02x%02x", bg_color[0], bg_color[1], bg_color[2]); + fg_opacity = (float)fg_color[3] / 255; + bg_opacity = (float)bg_color[3] / 255; + /* XML declaration */ fputs( "\n", fp ); @@ -392,7 +450,11 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) fputs( "\t\n", fp ); /* Make solid background */ - fputs( "\t\t\n", fp ); + if(bg_color[3] != 255) { + fprintf(fp, "\t\t\n", bg, bg_opacity); + } else { + fprintf(fp, "\t\t\n", bg); + } /* Create new viewbox for QR data */ fputs( "\t\t\n", fp); @@ -411,17 +473,14 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) x0 = x; } else { if(!(*(row+x)&0x1)) { - fprintf(fp, "\t\t\t\n", - x0 + margin, y + margin, x-x0 ); + writeSVG_writeRect(fp, x0 + margin, y + margin, x-x0, fg, fg_opacity); pen = 0; } } } - if( pen ) - fprintf(fp, "\t\t\t\n", - x0 + margin, y + margin, qrcode->width-x0 ); + if( pen ) { + writeSVG_writeRect(fp, x0 + margin, y + margin, qrcode->width - x0, fg, fg_opacity); + } } /* Close QR data viewbox */ @@ -987,6 +1046,18 @@ int main(int argc, char **argv) case 'M': micro = 1; break; + case 'f': + if(color_set(fg_color, optarg)) { + fprintf(stderr, "Invalid foreground color value.\n"); + exit(EXIT_FAILURE); + } + break; + case 'b': + if(color_set(bg_color, optarg)) { + fprintf(stderr, "Invalid background color value.\n"); + exit(EXIT_FAILURE); + } + break; case 'V': usage(0, 0); exit(EXIT_SUCCESS); diff --git a/qrencode.1.in b/qrencode.1.in index c49ceafe0c..2720f0a4c9 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -63,6 +63,15 @@ encode entire data in 8-bit mode. \-k, \-c and \-i will be ignored. .B \-M, \-\-micro encode in a Micro QR Code. (experimental) .TP +.PD 0 +.B \-\-foreground=RRGGBB[AA] +.TP +.PD +.B \-\-background=RRGGBB[AA] +specify foreground/background color in hexadecimal notation. +6-digit (RGB) or 8-digit (RGBA) form are supported. +Color output support available only in PNG and SVG. +.TP .B \-V, \-\-version display the version number and copyrights of the qrencode. .TP -- cgit 0.0.5-2-1-g0f52 From dca8813e1f6dce7d7fa3a256b7f4ad3cbfb30538 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Sep 2012 13:40:15 +0900 Subject: Added a new test. --- ChangeLog | 4 ++++ tests/test_bitstream.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9c1096939b..c2fc86a575 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.09.24 Kentaro FUKUCHI + * tests/test_bitstream.c: + - Added new test. + 2012.09.22 Kentaro FUKUCHI * qrenc.c: - Color palette support has been added. Currently PNG and SVG are diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 11b63cbe17..a7192cb705 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -160,6 +160,40 @@ void test_size(void) BitStream_free(bstream); } +void test_append(void) +{ + BitStream *bs1, *bs2; + char c1[] = "0001111111111111111"; + char c2[] = "01111111111111111"; + char c3[] = "00011111111111111111111111111111"; + int ret; + + testStart("Append two BitStreams"); + + bs1 = BitStream_new(); + bs2 = BitStream_new(); + ret = BitStream_appendNum(bs1, 1, 0); + ret = BitStream_appendNum(bs2, 1, 0); + ret = BitStream_append(bs1, bs2); + assert_zero(ret, "Failed to append."); + assert_zero(ncmpBin(c1, bs1, 2), "Internal data is incorrect."); + + ret = BitStream_appendNum(bs2, 16, 65535); + assert_zero(ncmpBin(c2, bs2, 17), "Internal data is incorrect."); + ret = BitStream_append(bs1, bs2); + assert_zero(ret, "Failed to append."); + assert_zero(ncmpBin(c1, bs1, 19), "Internal data is incorrect."); + + ret = BitStream_appendNum(bs1, 13, (2^14)-1); + assert_zero(ret, "Failed to append."); + assert_zero(cmpBin(c3, bs1), "Internal data is incorrect."); + + testFinish(); + + BitStream_free(bs1); + BitStream_free(bs2); +} + int main(void) { test_null(); @@ -170,6 +204,7 @@ int main(void) test_toByte(); test_toByte_4bitpadding(); test_size(); + test_append(); report(); -- cgit 0.0.5-2-1-g0f52 From 7bf2aa773f0aed24df65927ed3298e8d3d77068e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Sep 2012 13:51:24 +0900 Subject: Stupid bug fixed. --- tests/test_bitstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index a7192cb705..bc8605f691 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -184,7 +184,7 @@ void test_append(void) assert_zero(ret, "Failed to append."); assert_zero(ncmpBin(c1, bs1, 19), "Internal data is incorrect."); - ret = BitStream_appendNum(bs1, 13, (2^14)-1); + ret = BitStream_appendNum(bs1, 13, 16383); assert_zero(ret, "Failed to append."); assert_zero(cmpBin(c3, bs1), "Internal data is incorrect."); -- cgit 0.0.5-2-1-g0f52 From 7954872c4e6c949d16387043d121eebd25a5888c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Sep 2012 13:51:24 +0900 Subject: Stupid bug fixed. --- tests/test_bitstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index a7192cb705..bc8605f691 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -184,7 +184,7 @@ void test_append(void) assert_zero(ret, "Failed to append."); assert_zero(ncmpBin(c1, bs1, 19), "Internal data is incorrect."); - ret = BitStream_appendNum(bs1, 13, (2^14)-1); + ret = BitStream_appendNum(bs1, 13, 16383); assert_zero(ret, "Failed to append."); assert_zero(cmpBin(c3, bs1), "Internal data is incorrect."); -- cgit 0.0.5-2-1-g0f52 From 8f1cd6546c99855737ec32b445c83ca1d2ddb3cd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Sep 2012 17:15:15 +0900 Subject: Test improved. --- tests/test_bitstream.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index bc8605f691..03fedda51d 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -163,9 +163,11 @@ void test_size(void) void test_append(void) { BitStream *bs1, *bs2; - char c1[] = "0001111111111111111"; - char c2[] = "01111111111111111"; - char c3[] = "00011111111111111111111111111111"; + char c1[] = "00"; + char c2[] = "0011"; + char c3[] = "01111111111111111"; + char c4[] = "001101111111111111111"; + char c5[] = "0011011111111111111111111111111111"; int ret; testStart("Append two BitStreams"); @@ -174,19 +176,26 @@ void test_append(void) bs2 = BitStream_new(); ret = BitStream_appendNum(bs1, 1, 0); ret = BitStream_appendNum(bs2, 1, 0); + ret = BitStream_append(bs1, bs2); assert_zero(ret, "Failed to append."); - assert_zero(ncmpBin(c1, bs1, 2), "Internal data is incorrect."); + assert_zero(cmpBin(c1, bs1), "Internal data is incorrect."); + + ret = BitStream_appendNum(bs1, 2, 3); + assert_zero(ret, "Failed to append."); + assert_zero(cmpBin(c2, bs1), "Internal data is incorrect."); ret = BitStream_appendNum(bs2, 16, 65535); - assert_zero(ncmpBin(c2, bs2, 17), "Internal data is incorrect."); + assert_zero(ret, "Failed to append."); + assert_zero(cmpBin(c3, bs2), "Internal data is incorrect."); + ret = BitStream_append(bs1, bs2); assert_zero(ret, "Failed to append."); - assert_zero(ncmpBin(c1, bs1, 19), "Internal data is incorrect."); + assert_zero(cmpBin(c4, bs1), "Internal data is incorrect."); ret = BitStream_appendNum(bs1, 13, 16383); assert_zero(ret, "Failed to append."); - assert_zero(cmpBin(c3, bs1), "Internal data is incorrect."); + assert_zero(cmpBin(c5, bs1), "Internal data is incorrect."); testFinish(); -- cgit 0.0.5-2-1-g0f52 From 0208aeda52d32edb5611c6126d86f50e724e4a15 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Sep 2012 17:15:15 +0900 Subject: Test improved. --- tests/test_bitstream.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index bc8605f691..03fedda51d 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -163,9 +163,11 @@ void test_size(void) void test_append(void) { BitStream *bs1, *bs2; - char c1[] = "0001111111111111111"; - char c2[] = "01111111111111111"; - char c3[] = "00011111111111111111111111111111"; + char c1[] = "00"; + char c2[] = "0011"; + char c3[] = "01111111111111111"; + char c4[] = "001101111111111111111"; + char c5[] = "0011011111111111111111111111111111"; int ret; testStart("Append two BitStreams"); @@ -174,19 +176,26 @@ void test_append(void) bs2 = BitStream_new(); ret = BitStream_appendNum(bs1, 1, 0); ret = BitStream_appendNum(bs2, 1, 0); + ret = BitStream_append(bs1, bs2); assert_zero(ret, "Failed to append."); - assert_zero(ncmpBin(c1, bs1, 2), "Internal data is incorrect."); + assert_zero(cmpBin(c1, bs1), "Internal data is incorrect."); + + ret = BitStream_appendNum(bs1, 2, 3); + assert_zero(ret, "Failed to append."); + assert_zero(cmpBin(c2, bs1), "Internal data is incorrect."); ret = BitStream_appendNum(bs2, 16, 65535); - assert_zero(ncmpBin(c2, bs2, 17), "Internal data is incorrect."); + assert_zero(ret, "Failed to append."); + assert_zero(cmpBin(c3, bs2), "Internal data is incorrect."); + ret = BitStream_append(bs1, bs2); assert_zero(ret, "Failed to append."); - assert_zero(ncmpBin(c1, bs1, 19), "Internal data is incorrect."); + assert_zero(cmpBin(c4, bs1), "Internal data is incorrect."); ret = BitStream_appendNum(bs1, 13, 16383); assert_zero(ret, "Failed to append."); - assert_zero(cmpBin(c3, bs1), "Internal data is incorrect."); + assert_zero(cmpBin(c5, bs1), "Internal data is incorrect."); testFinish(); -- cgit 0.0.5-2-1-g0f52 From 27b4e7f62bac2907bdd41f2d77a4c64e5d775270 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Sep 2012 17:22:56 +0900 Subject: Warnings suppressed. --- ChangeLog | 2 ++ tests/test_monkey.c | 4 ++-- tests/test_qrspec.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2fc86a575..ff406a4618 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2012.09.24 Kentaro FUKUCHI * tests/test_bitstream.c: - Added new test. + * tests/test_{monkey,qrspec}.c: + - Warnings suppressed. 2012.09.22 Kentaro FUKUCHI * qrenc.c: diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 208cb4fa90..e872634ab5 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -467,12 +467,12 @@ void test_split_structure(int num) QRinput_InputList *il; int version; QRecLevel level; - int len, c, i, ret; + int c, i, ret; version = (int)drand(40) + 1; level = (QRecLevel)drand(4); - len = fill8bitString(); + fill8bitString(); input = QRinput_new2(version, level); if(input == NULL) { diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 69838e139b..5993d5e003 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -20,6 +20,7 @@ void print_eccTable(void) + QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec); ecc = QRspec_rsBlockNum1(spec) * QRspec_rsEccCodes1(spec) + QRspec_rsBlockNum2(spec) * QRspec_rsEccCodes2(spec); + printf("%3d\t", data); printf("%3d\t", ecc); printf("%2d\t", QRspec_rsBlockNum1(spec)); printf("(%3d, %3d, %3d)\n", -- cgit 0.0.5-2-1-g0f52 From f9c50679a72b58962acc8bd1a53ad28b1744fa5c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Sep 2012 19:32:54 +0900 Subject: Reduced the user of malloc(). --- ChangeLog | 2 ++ bitstream.c | 99 ++++++++++++++++++++----------------------------------------- bitstream.h | 1 + 3 files changed, 35 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2fc86a575..adb23d64d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2012.09.24 Kentaro FUKUCHI * tests/test_bitstream.c: - Added new test. + * bitstream.[ch]: + - Reduced the use of dynamic memory allocation. 2012.09.22 Kentaro FUKUCHI * qrenc.c: diff --git a/bitstream.c b/bitstream.c index a0b9283cb0..c7dff72659 100644 --- a/bitstream.c +++ b/bitstream.c @@ -28,6 +28,8 @@ #include "bitstream.h" +#define DEFAULT_BUFSIZE (16) + BitStream *BitStream_new(void) { BitStream *bstream; @@ -36,49 +38,38 @@ BitStream *BitStream_new(void) if(bstream == NULL) return NULL; bstream->length = 0; - bstream->data = NULL; + bstream->data = (unsigned char *)malloc(DEFAULT_BUFSIZE); + if(bstream->data == NULL) { + free(bstream); + return NULL; + } + bstream->datasize = DEFAULT_BUFSIZE; return bstream; } -static int BitStream_allocate(BitStream *bstream, int length) +static int BitStream_expand(BitStream *bstream) { unsigned char *data; - if(bstream == NULL) { - return -1; - } - - data = (unsigned char *)malloc(length); + data = (unsigned char *)realloc(bstream->data, bstream->datasize * 2); if(data == NULL) { return -1; } - if(bstream->data) { - free(bstream->data); - } - bstream->length = length; bstream->data = data; + bstream->datasize *= 2; return 0; } -static BitStream *BitStream_newFromNum(int bits, unsigned int num) +static void BitStream_writeNum(unsigned char *dest, int bits, unsigned int num) { unsigned int mask; int i; unsigned char *p; - BitStream *bstream; - bstream = BitStream_new(); - if(bstream == NULL) return NULL; - - if(BitStream_allocate(bstream, bits)) { - BitStream_free(bstream); - return NULL; - } - - p = bstream->data; + p = dest; mask = 1 << (bits - 1); for(i=0; i> 1; } - - return bstream; } -static BitStream *BitStream_newFromBytes(int size, unsigned char *data) +static void BitStream_writeBytes(unsigned char *dest, int size, unsigned char *data) { unsigned char mask; int i, j; unsigned char *p; - BitStream *bstream; - - bstream = BitStream_new(); - if(bstream == NULL) return NULL; - if(BitStream_allocate(bstream, size * 8)) { - BitStream_free(bstream); - return NULL; - } - - p = bstream->data; + p = dest; for(i=0; i> 1; } } - - return bstream; } int BitStream_append(BitStream *bstream, BitStream *arg) { - unsigned char *data; - if(arg == NULL) { return -1; } if(arg->length == 0) { return 0; } - if(bstream->length == 0) { - if(BitStream_allocate(bstream, arg->length)) { - return -1; - } - memcpy(bstream->data, arg->data, arg->length); - return 0; - } - data = (unsigned char *)malloc(bstream->length + arg->length); - if(data == NULL) { - return -1; + while(bstream->length + arg->length > bstream->datasize) { + BitStream_expand(bstream); } - memcpy(data, bstream->data, bstream->length); - memcpy(data + bstream->length, arg->data, arg->length); - free(bstream->data); + memcpy(bstream->data + bstream->length, arg->data, arg->length); bstream->length += arg->length; - bstream->data = data; return 0; } int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num) { - BitStream *b; int ret; if(bits == 0) return 0; - b = BitStream_newFromNum(bits, num); - if(b == NULL) return -1; - - ret = BitStream_append(bstream, b); - BitStream_free(b); + while(bstream->datasize - bstream->length < bits) { + ret = BitStream_expand(bstream); + if(ret < 0) return ret; + } + BitStream_writeNum(bstream->data + bstream->length, bits, num); + bstream->length += bits; - return ret; + return 0; } int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) { - BitStream *b; int ret; if(size == 0) return 0; - b = BitStream_newFromBytes(size, data); - if(b == NULL) return -1; - - ret = BitStream_append(bstream, b); - BitStream_free(b); + while(bstream->datasize - bstream->length < size * 8) { + ret = BitStream_expand(bstream); + if(ret < 0) return ret; + } + BitStream_writeBytes(bstream->data + bstream->length, size, data); + bstream->length += size * 8; - return ret; + return 0; } unsigned char *BitStream_toByte(BitStream *bstream) diff --git a/bitstream.h b/bitstream.h index ffe743c5e0..24d9cb58fd 100644 --- a/bitstream.h +++ b/bitstream.h @@ -25,6 +25,7 @@ typedef struct { int length; unsigned char *data; + int datasize; } BitStream; extern BitStream *BitStream_new(void); -- cgit 0.0.5-2-1-g0f52 From baae95dcc4acbaaaeee9afe34f0f65a8206681f2 Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Mon, 24 Sep 2012 11:04:03 +0200 Subject: check color component strings decoding New options --foreground and --background try to decode strings in form RRGGBB[AA] where RGBA are hexadecimal digits. But color_set() function does not ensure that the string contains only hexadecimal digit. This patch add a basic check on the number of item decoded by sscanf() and add a check on the length of te parsed string. The string is known to have the number of color components required and being fully decoded. Signed-off-by: Yann Droneaud --- qrenc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 7c8eaf7526..ffc5e9b369 100644 --- a/qrenc.c +++ b/qrenc.c @@ -168,11 +168,18 @@ static void usage(int help, int longopt) static int color_set(unsigned int color[4], const char *value) { int len = strlen(value); + int count; if(len == 6) { - sscanf(value, "%02x%02x%02x", &color[0], &color[1], &color[2]); + count = sscanf(value, "%02x%02x%02x%n", &color[0], &color[1], &color[2], &len); + if(count < 3 || len != 6) { + return -1; + } color[3] = 255; } else if(len == 8) { - sscanf(value, "%02x%02x%02x%02x", &color[0], &color[1], &color[2], &color[3]); + count = sscanf(value, "%02x%02x%02x%02x%n", &color[0], &color[1], &color[2], &color[3], &len); + if(count < 4 || len != 8) { + return -1; + } } else { return -1; } -- cgit 0.0.5-2-1-g0f52 From 0391a58e343d98980a6a0602255bd318439c0174 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 25 Sep 2012 04:03:40 +0900 Subject: Acknowledgements updated. --- ChangeLog | 4 ++++ README | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index ff406a4618..b01fdf8bcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.09.25 Kentaro FUKUCHI + * qrenc.c: + - Input validation improved. (Thanks to Yann Droneaud) + 2012.09.24 Kentaro FUKUCHI * tests/test_bitstream.c: - Added new test. diff --git a/README b/README index b08dd3b68b..e67d3707b3 100644 --- a/README +++ b/README @@ -132,6 +132,7 @@ Yutaka Niibe (gniibe) - various bug fix patches Dan Storm (Repox) - SVG support patch Lennart Poettering (mezcalero) - Improved text art patch +Yann Droneaud - Improved input validation patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 2d5b9dc212e6902867ef5aa6dfc9a2502d9488cc Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 25 Sep 2012 04:16:30 +0900 Subject: README updated. --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index b01fdf8bcb..48d3573450 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2012.09.25 Kentaro FUKUCHI * qrenc.c: - Input validation improved. (Thanks to Yann Droneaud) + * README: + - Contributors list has been updated. 2012.09.24 Kentaro FUKUCHI * tests/test_bitstream.c: -- cgit 0.0.5-2-1-g0f52 From 1cb37499eece02b168c7d1c9844d312572846c13 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 25 Sep 2012 12:54:23 +0900 Subject: Reduced the use of dynamic memory allocation. --- ChangeLog | 4 ++++ qrinput.c | 66 ++++++++++++++++----------------------------------------------- 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index adb23d64d8..71daee2f4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.09.25 Kentaro FUKUCHI + * tests/qrinput.c: + - Reduced the use of dynamic memory allocation. + 2012.09.24 Kentaro FUKUCHI * tests/test_bitstream.c: - Added new test. diff --git a/qrinput.c b/qrinput.c index 5dcacf8aa2..78a7995356 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1191,8 +1191,6 @@ static int QRinput_convertData(QRinput *input) static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) { int bits, maxbits, words, maxwords, i, ret; - BitStream *padding = NULL; - unsigned char *padbuf; int padlen; bits = BitStream_size(bstream); @@ -1208,39 +1206,25 @@ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) } if(maxbits - bits <= 4) { - ret = BitStream_appendNum(bstream, maxbits - bits, 0); - goto DONE; + return BitStream_appendNum(bstream, maxbits - bits, 0); } words = (bits + 4 + 7) / 8; - padding = BitStream_new(); - if(padding == NULL) return -1; - ret = BitStream_appendNum(padding, words * 8 - bits, 0); - if(ret < 0) goto DONE; + ret = BitStream_appendNum(bstream, words * 8 - bits, 0); + if(ret < 0) return ret; padlen = maxwords - words; if(padlen > 0) { - padbuf = (unsigned char *)malloc(padlen); - if(padbuf == NULL) { - ret = -1; - goto DONE; - } for(i=0; iversion * 2 + 1; if(maxbits - bits <= termbits) { - ret = BitStream_appendNum(bstream, maxbits - bits, 0); - goto DONE; + return BitStream_appendNum(bstream, maxbits - bits, 0); } bits += termbits; @@ -1288,38 +1269,23 @@ static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) } else { termbits += words * 8 - bits; } - padding = BitStream_new(); - if(padding == NULL) return -1; - ret = BitStream_appendNum(padding, termbits, 0); - if(ret < 0) goto DONE; + ret = BitStream_appendNum(bstream, termbits, 0); + if(ret < 0) return ret; padlen = maxwords - words; if(padlen > 0) { - padbuf = (unsigned char *)malloc(padlen); - if(padbuf == NULL) { - ret = -1; - goto DONE; - } for(i=0; i 0) { - ret = BitStream_appendNum(padding, termbits, 0); - if(ret < 0) goto DONE; + ret = BitStream_appendNum(bstream, termbits, 0); + if(ret < 0) return ret; } } - ret = BitStream_append(bstream, padding); - -DONE: - BitStream_free(padding); - return ret; + return 0; } static int QRinput_insertFNC1Header(QRinput *input) -- cgit 0.0.5-2-1-g0f52 From 8a1cc3ba9bedb81d5ea0c37f2a15656524d96e2d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 24 Sep 2012 17:22:56 +0900 Subject: Warnings suppressed. --- ChangeLog | 2 ++ tests/test_monkey.c | 4 ++-- tests/test_qrspec.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71daee2f4b..bec628f563 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ 2012.09.24 Kentaro FUKUCHI * tests/test_bitstream.c: - Added new test. + * tests/test_{monkey,qrspec}.c: + - Warnings suppressed. * bitstream.[ch]: - Reduced the use of dynamic memory allocation. diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 208cb4fa90..e872634ab5 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -467,12 +467,12 @@ void test_split_structure(int num) QRinput_InputList *il; int version; QRecLevel level; - int len, c, i, ret; + int c, i, ret; version = (int)drand(40) + 1; level = (QRecLevel)drand(4); - len = fill8bitString(); + fill8bitString(); input = QRinput_new2(version, level); if(input == NULL) { diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 69838e139b..5993d5e003 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -20,6 +20,7 @@ void print_eccTable(void) + QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec); ecc = QRspec_rsBlockNum1(spec) * QRspec_rsEccCodes1(spec) + QRspec_rsBlockNum2(spec) * QRspec_rsEccCodes2(spec); + printf("%3d\t", data); printf("%3d\t", ecc); printf("%2d\t", QRspec_rsBlockNum1(spec)); printf("(%3d, %3d, %3d)\n", -- cgit 0.0.5-2-1-g0f52 From 58440b369f16e45fd444eedfd0b5fbeef38fe89f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 25 Sep 2012 18:52:53 +0900 Subject: Added a note about autogen.sh. --- ChangeLog | 1 + README | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48d3573450..5a41538770 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - Input validation improved. (Thanks to Yann Droneaud) * README: - Contributors list has been updated. + - Added a note about autogen.sh. 2012.09.24 Kentaro FUKUCHI * tests/test_bitstream.c: diff --git a/README b/README index e67d3707b3..5b3af6f4e9 100644 --- a/README +++ b/README @@ -2,16 +2,16 @@ libqrencode 3.3.1 - QR Code encoding library GENERAL INFORMATION =================== -Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D -symbology that can be scanned by handy terminals such as a mobile phone with -CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has -high robustness. +Libqrencode is a library for encoding data in a QR Code symbol, a 2D symbology +that can be scanned by handy terminals such as a mobile phone with CCD. The +capacity of QR Code is up to 7000 digits or 4000 characters and has high +robustness. Libqrencode accepts a string or a list of data chunks then encodes in a QR Code symbol as a bitmap array. While other QR Code applications generate an image file, using libqrencode allows applications to render QR Code symbols from raw bitmap data directly. This library also contains a command-line utility outputs -a QR Code symbol as a PNG image. It will help light-weight CGI programs. +a QR Code symbol as a PNG image. SPECIFICATION @@ -55,6 +55,9 @@ Run "./configure --help" to see the list of options. It also installs a binary "qrencode" to /usr/local/bin. If you want not to install it, give "--without-tools" option to the configure script. +When you downloaded a development tree from github, it is required to run +"autogen.sh" at first to generate configure script. + USAGE ===== @@ -101,7 +104,7 @@ for new releases. The git repository is available at: https://github.com/fukuchi/libqrencode -Please mail any bug reports, suggestions, comments and questions to: +Please mail any bug reports, suggestions, comments, and questions to: Kentaro Fukuchi -- cgit 0.0.5-2-1-g0f52 From ca6ef76676b4387d6f3593f731d653ca7c559b09 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 25 Sep 2012 19:41:28 +0900 Subject: Reducing BitStream_new(). --- qrinput.c | 132 ++++++++++++++++++++++++-------------------------------------- 1 file changed, 51 insertions(+), 81 deletions(-) diff --git a/qrinput.c b/qrinput.c index 78a7995356..7d721ce753 100644 --- a/qrinput.c +++ b/qrinput.c @@ -407,26 +407,23 @@ int QRinput_estimateBitsModeNum(int size) * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ -static int QRinput_encodeModeNum(QRinput_List *entry, int version, int mqr) +static int QRinput_encodeModeNum(QRinput_List *entry, BitStream *bstream, int version, int mqr) { int words, i, ret; unsigned int val; - entry->bstream = BitStream_new(); - if(entry->bstream == NULL) return -1; - if(mqr) { if(version > 1) { - ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_NUM); + ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_NUM); if(ret < 0) goto ABORT; } - ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); + ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); if(ret < 0) goto ABORT; } else { - ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_NUM); + ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_NUM); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); + ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); if(ret < 0) goto ABORT; } @@ -436,25 +433,23 @@ static int QRinput_encodeModeNum(QRinput_List *entry, int version, int mqr) val += (entry->data[i*3+1] - '0') * 10; val += (entry->data[i*3+2] - '0'); - ret = BitStream_appendNum(entry->bstream, 10, val); + ret = BitStream_appendNum(bstream, 10, val); if(ret < 0) goto ABORT; } if(entry->size - words * 3 == 1) { val = entry->data[words*3] - '0'; - ret = BitStream_appendNum(entry->bstream, 4, val); + ret = BitStream_appendNum(bstream, 4, val); if(ret < 0) goto ABORT; } else if(entry->size - words * 3 == 2) { val = (entry->data[words*3 ] - '0') * 10; val += (entry->data[words*3+1] - '0'); - BitStream_appendNum(entry->bstream, 7, val); + BitStream_appendNum(bstream, 7, val); if(ret < 0) goto ABORT; } return 0; ABORT: - BitStream_free(entry->bstream); - entry->bstream = NULL; return -1; } @@ -520,27 +515,24 @@ int QRinput_estimateBitsModeAn(int size) * @throw ENOMEM unable to allocate memory. * @throw EINVAL invalid version. */ -static int QRinput_encodeModeAn(QRinput_List *entry, int version, int mqr) +static int QRinput_encodeModeAn(QRinput_List *entry, BitStream *bstream, int version, int mqr) { int words, i, ret; unsigned int val; - entry->bstream = BitStream_new(); - if(entry->bstream == NULL) return -1; - if(mqr) { if(version < 2) { errno = EINVAL; goto ABORT; } - ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_AN); + ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_AN); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_AN, version), entry->size); + ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_AN, version), entry->size); if(ret < 0) goto ABORT; } else { - ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_AN); + ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_AN); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), entry->size); + ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_AN, version), entry->size); if(ret < 0) goto ABORT; } @@ -549,21 +541,19 @@ static int QRinput_encodeModeAn(QRinput_List *entry, int version, int mqr) val = (unsigned int)QRinput_lookAnTable(entry->data[i*2 ]) * 45; val += (unsigned int)QRinput_lookAnTable(entry->data[i*2+1]); - ret = BitStream_appendNum(entry->bstream, 11, val); + ret = BitStream_appendNum(bstream, 11, val); if(ret < 0) goto ABORT; } if(entry->size & 1) { val = (unsigned int)QRinput_lookAnTable(entry->data[words * 2]); - ret = BitStream_appendNum(entry->bstream, 6, val); + ret = BitStream_appendNum(bstream, 6, val); if(ret < 0) goto ABORT; } return 0; ABORT: - BitStream_free(entry->bstream); - entry->bstream = NULL; return -1; } @@ -590,36 +580,31 @@ int QRinput_estimateBitsMode8(int size) * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ -static int QRinput_encodeMode8(QRinput_List *entry, int version, int mqr) +static int QRinput_encodeMode8(QRinput_List *entry, BitStream *bstream, int version, int mqr) { int ret; - entry->bstream = BitStream_new(); - if(entry->bstream == NULL) return -1; - if(mqr) { if(version < 3) { errno = EINVAL; goto ABORT; } - ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_8); + ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_8); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_8, version), entry->size); + ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_8, version), entry->size); if(ret < 0) goto ABORT; } else { - ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_8); + ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_8); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), entry->size); + ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_8, version), entry->size); if(ret < 0) goto ABORT; } - ret = BitStream_appendBytes(entry->bstream, entry->size, entry->data); + ret = BitStream_appendBytes(bstream, entry->size, entry->data); if(ret < 0) goto ABORT; return 0; ABORT: - BitStream_free(entry->bstream); - entry->bstream = NULL; return -1; } @@ -672,27 +657,24 @@ static int QRinput_checkModeKanji(int size, const unsigned char *data) * @throw ENOMEM unable to allocate memory. * @throw EINVAL invalid version. */ -static int QRinput_encodeModeKanji(QRinput_List *entry, int version, int mqr) +static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int version, int mqr) { int ret, i; unsigned int val, h; - entry->bstream = BitStream_new(); - if(entry->bstream == NULL) return -1; - if(mqr) { if(version < 2) { errno = EINVAL; goto ABORT; } - ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_KANJI); + ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_KANJI); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); + ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); if(ret < 0) goto ABORT; } else { - ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_KANJI); + ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_KANJI); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); + ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); if(ret < 0) goto ABORT; } @@ -706,14 +688,12 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, int version, int mqr) h = (val >> 8) * 0xc0; val = (val & 0xff) + h; - ret = BitStream_appendNum(entry->bstream, 13, val); + ret = BitStream_appendNum(bstream, 13, val); if(ret < 0) goto ABORT; } return 0; ABORT: - BitStream_free(entry->bstream); - entry->bstream = NULL; return -1; } @@ -731,7 +711,7 @@ ABORT: * @throw ENOMEM unable to allocate memory. * @throw EINVAL invalid entry. */ -static int QRinput_encodeModeStructure(QRinput_List *entry, int mqr) +static int QRinput_encodeModeStructure(QRinput_List *entry, BitStream *bstream, int mqr) { int ret; @@ -739,22 +719,18 @@ static int QRinput_encodeModeStructure(QRinput_List *entry, int mqr) errno = EINVAL; return -1; } - entry->bstream = BitStream_new(); - if(entry->bstream == NULL) return -1; - ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_STRUCTURE); + ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_STRUCTURE); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, 4, entry->data[1] - 1); + ret = BitStream_appendNum(bstream, 4, entry->data[1] - 1); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, 4, entry->data[0] - 1); + ret = BitStream_appendNum(bstream, 4, entry->data[0] - 1); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, 8, entry->data[2]); + ret = BitStream_appendNum(bstream, 8, entry->data[2]); if(ret < 0) goto ABORT; return 0; ABORT: - BitStream_free(entry->bstream); - entry->bstream = NULL; return -1; } @@ -769,23 +745,18 @@ static int QRinput_checkModeFNC1Second(int size, const unsigned char *data) return 0; } -static int QRinput_encodeModeFNC1Second(QRinput_List *entry, int version) +static int QRinput_encodeModeFNC1Second(QRinput_List *entry, BitStream *bstream, int version) { int ret; - entry->bstream = BitStream_new(); - if(entry->bstream == NULL) return -1; - - ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_FNC1SECOND); + ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_FNC1SECOND); if(ret < 0) goto ABORT; - ret = BitStream_appendBytes(entry->bstream, 1, entry->data); + ret = BitStream_appendBytes(bstream, 1, entry->data); if(ret < 0) goto ABORT; return 0; ABORT: - BitStream_free(entry->bstream); - entry->bstream = NULL; return -1; } @@ -822,14 +793,11 @@ int QRinput_estimateBitsModeECI(unsigned char *data) } } -static int QRinput_encodeModeECI(QRinput_List *entry, int version) +static int QRinput_encodeModeECI(QRinput_List *entry, BitStream *bstream, int version) { int ret, words; unsigned int ecinum, code; - entry->bstream = BitStream_new(); - if(entry->bstream == NULL) return -1; - ecinum = QRinput_decodeECIfromByteArray(entry->data);; /* See Table 4 of JISX 0510:2004 pp.17. */ @@ -844,16 +812,14 @@ static int QRinput_encodeModeECI(QRinput_List *entry, int version) code = 0xc0000 + ecinum; } - ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_ECI); + ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_ECI); if(ret < 0) goto ABORT; - ret = BitStream_appendNum(entry->bstream, words * 8, code); + ret = BitStream_appendNum(bstream, words * 8, code); if(ret < 0) goto ABORT; return 0; ABORT: - BitStream_free(entry->bstream); - entry->bstream = NULL; return -1; } @@ -1055,12 +1021,16 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) { int words, ret; QRinput_List *st1 = NULL, *st2 = NULL; + BitStream *bstream; if(entry->bstream != NULL) { BitStream_free(entry->bstream); entry->bstream = NULL; } + bstream = BitStream_new(); + entry->bstream = bstream; + words = QRspec_maximumWords(entry->mode, version); if(words != 0 && entry->size > words) { st1 = QRinput_List_newEntry(entry->mode, words, entry->data); @@ -1072,8 +1042,7 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) if(ret < 0) goto ABORT; ret = QRinput_encodeBitStream(st2, version, mqr); if(ret < 0) goto ABORT; - entry->bstream = BitStream_new(); - if(entry->bstream == NULL) goto ABORT; + ret = BitStream_append(entry->bstream, st1->bstream); if(ret < 0) goto ABORT; ret = BitStream_append(entry->bstream, st2->bstream); @@ -1084,25 +1053,25 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) ret = 0; switch(entry->mode) { case QR_MODE_NUM: - ret = QRinput_encodeModeNum(entry, version, mqr); + ret = QRinput_encodeModeNum(entry, bstream, version, mqr); break; case QR_MODE_AN: - ret = QRinput_encodeModeAn(entry, version, mqr); + ret = QRinput_encodeModeAn(entry, bstream, version, mqr); break; case QR_MODE_8: - ret = QRinput_encodeMode8(entry, version, mqr); + ret = QRinput_encodeMode8(entry, bstream, version, mqr); break; case QR_MODE_KANJI: - ret = QRinput_encodeModeKanji(entry, version, mqr); + ret = QRinput_encodeModeKanji(entry, bstream, version, mqr); break; case QR_MODE_STRUCTURE: - ret = QRinput_encodeModeStructure(entry, mqr); + ret = QRinput_encodeModeStructure(entry, bstream, mqr); break; case QR_MODE_ECI: - ret = QRinput_encodeModeECI(entry, version); + ret = QRinput_encodeModeECI(entry, bstream, version); break; case QR_MODE_FNC1SECOND: - ret = QRinput_encodeModeFNC1Second(entry, version); + ret = QRinput_encodeModeFNC1Second(entry, bstream, version); default: break; } @@ -1113,6 +1082,7 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) ABORT: QRinput_List_freeEntry(st1); QRinput_List_freeEntry(st2); + BitStream_free(bstream); return -1; } -- cgit 0.0.5-2-1-g0f52 From b2f1d9229481bc0d865a7ca1ca5ce5f48e7290be Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Sep 2012 01:15:05 +0900 Subject: Reduced the use of dynamic memory allocation, and performance improved. --- ChangeLog | 9 ++++++- bitstream.h | 1 + qrinput.c | 85 ++++++++++++++++++++++++++----------------------------------- 3 files changed, 45 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index bec628f563..721b8beaa5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ +2012.09.29 Kentaro FUKUCHI + * bstream.h: + - Added a new function "BitStream_reset()". + * qrinput.c: + - Reduced the use of dynamic memory allocation. + - Performance improved. + 2012.09.25 Kentaro FUKUCHI - * tests/qrinput.c: + * qrinput.c, tests/qrinput.c: - Reduced the use of dynamic memory allocation. 2012.09.24 Kentaro FUKUCHI diff --git a/bitstream.h b/bitstream.h index 24d9cb58fd..3035a40fdf 100644 --- a/bitstream.h +++ b/bitstream.h @@ -33,6 +33,7 @@ extern int BitStream_append(BitStream *bstream, BitStream *arg); extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num); extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data); #define BitStream_size(__bstream__) (__bstream__->length) +#define BitStream_reset(__bstream__) (__bstream__->length = 0) extern unsigned char *BitStream_toByte(BitStream *bstream); extern void BitStream_free(BitStream *bstream); diff --git a/qrinput.c b/qrinput.c index 7d721ce753..2723bf035b 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1017,19 +1017,13 @@ __STATIC int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) * @param entry * @return number of bits (>0) or -1 for failure. */ -static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) +static int QRinput_encodeBitStream(QRinput_List *entry, BitStream *bstream, int version, int mqr) { int words, ret; QRinput_List *st1 = NULL, *st2 = NULL; - BitStream *bstream; - - if(entry->bstream != NULL) { - BitStream_free(entry->bstream); - entry->bstream = NULL; - } + int prevsize; - bstream = BitStream_new(); - entry->bstream = bstream; + prevsize = BitStream_size(bstream); words = QRspec_maximumWords(entry->mode, version); if(words != 0 && entry->size > words) { @@ -1038,15 +1032,11 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) st2 = QRinput_List_newEntry(entry->mode, entry->size - words, &entry->data[words]); if(st2 == NULL) goto ABORT; - ret = QRinput_encodeBitStream(st1, version, mqr); + ret = QRinput_encodeBitStream(st1, bstream, version, mqr); if(ret < 0) goto ABORT; - ret = QRinput_encodeBitStream(st2, version, mqr); + ret = QRinput_encodeBitStream(st2, bstream, version, mqr); if(ret < 0) goto ABORT; - ret = BitStream_append(entry->bstream, st1->bstream); - if(ret < 0) goto ABORT; - ret = BitStream_append(entry->bstream, st2->bstream); - if(ret < 0) goto ABORT; QRinput_List_freeEntry(st1); QRinput_List_freeEntry(st2); } else { @@ -1078,11 +1068,10 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) if(ret < 0) return -1; } - return BitStream_size(entry->bstream); + return BitStream_size(bstream) - prevsize; ABORT: QRinput_List_freeEntry(st1); QRinput_List_freeEntry(st2); - BitStream_free(bstream); return -1; } @@ -1094,14 +1083,14 @@ ABORT: * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ -static int QRinput_createBitStream(QRinput *input) +static int QRinput_createBitStream(QRinput *input, BitStream *bstream) { QRinput_List *list; int bits, total = 0; list = input->head; while(list != NULL) { - bits = QRinput_encodeBitStream(list, input->version, input->mqr); + bits = QRinput_encodeBitStream(list, bstream, input->version, input->mqr); if(bits < 0) return -1; total += bits; list = list->next; @@ -1121,7 +1110,7 @@ static int QRinput_createBitStream(QRinput *input) * @throw ENOMEM unable to allocate memory. * @throw ERANGE input is too large. */ -static int QRinput_convertData(QRinput *input) +static int QRinput_convertData(QRinput *input, BitStream *bstream) { int bits; int ver; @@ -1132,7 +1121,8 @@ static int QRinput_convertData(QRinput *input) } for(;;) { - bits = QRinput_createBitStream(input); + BitStream_reset(bstream); + bits = QRinput_createBitStream(input, bstream); if(bits < 0) return -1; ver = QRspec_getMinimumVersion((bits + 7) / 8, input->level); if(ver < 0) { @@ -1291,12 +1281,13 @@ static int QRinput_insertFNC1Header(QRinput *input) __STATIC BitStream *QRinput_mergeBitStream(QRinput *input) { BitStream *bstream; - QRinput_List *list; - int ret; + + bstream = BitStream_new(); + if(bstream == NULL) return NULL; if(input->mqr) { - if(QRinput_createBitStream(input) < 0) { - return NULL; + if(QRinput_createBitStream(input, bstream) < 0) { + goto ABORT; } } else { if(input->fnc1) { @@ -1304,25 +1295,16 @@ __STATIC BitStream *QRinput_mergeBitStream(QRinput *input) return NULL; } } - if(QRinput_convertData(input) < 0) { - return NULL; - } - } - - bstream = BitStream_new(); - if(bstream == NULL) return NULL; - - list = input->head; - while(list != NULL) { - ret = BitStream_append(bstream, list->bstream); - if(ret < 0) { - BitStream_free(bstream); - return NULL; + if(QRinput_convertData(input, bstream) < 0) { + goto ABORT; } - list = list->next; } return bstream; + +ABORT: + BitStream_free(bstream); + return NULL; } /** @@ -1513,10 +1495,11 @@ __STATIC int QRinput_splitEntry(QRinput_List *entry, int bytes) QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) { - QRinput *p; - QRinput_Struct *s; + QRinput *p = NULL; + QRinput_Struct *s = NULL; int bits, maxbits, nextbits, bytes, ret; QRinput_List *list, *next, *prev; + BitStream *bstream = NULL; if(input->mqr) { errno = EINVAL; @@ -1535,11 +1518,10 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) QRinput_Struct_setParity(s, QRinput_calcParity(input)); maxbits = QRspec_getDataLength(input->version, input->level) * 8 - STRUCTURE_HEADER_SIZE; - if(maxbits <= 0) { - QRinput_Struct_free(s); - QRinput_free(input); - return NULL; - } + if(maxbits <= 0) goto ABORT; + + bstream = BitStream_new(); + if(bstream == NULL) goto ABORT; bits = 0; list = input->head; @@ -1547,7 +1529,8 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) while(list != NULL) { nextbits = QRinput_estimateBitStreamSizeOfEntry(list, input->version, input->mqr); if(bits + nextbits <= maxbits) { - ret = QRinput_encodeBitStream(list, input->version, input->mqr); + BitStream_reset(bstream); + ret = QRinput_encodeBitStream(list, bstream, input->version, input->mqr); if(ret < 0) goto ABORT; bits += ret; prev = list; @@ -1588,19 +1571,23 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) } QRinput_Struct_appendInput(s, input); if(s->size > MAX_STRUCTURED_SYMBOLS) { - QRinput_Struct_free(s); errno = ERANGE; + QRinput_Struct_free(s); + BitStream_free(bstream); return NULL; } ret = QRinput_Struct_insertStructuredAppendHeaders(s); if(ret < 0) { QRinput_Struct_free(s); + BitStream_free(bstream); return NULL; } + BitStream_free(bstream); return s; ABORT: + BitStream_free(bstream); QRinput_free(input); QRinput_Struct_free(s); return NULL; -- cgit 0.0.5-2-1-g0f52 From 3a84f58f9b68ed9ff8dd8af88868098734cac7c9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Sep 2012 09:55:38 +0900 Subject: QRinput_mergeBitStream() now requires a BitStream. --- qrinput.c | 38 ++++++++++++++++---------------------- qrinput.h | 2 +- tests/common.h | 7 ++++--- tests/test_monkey.c | 3 ++- tests/test_qrencode.c | 3 ++- tests/test_qrinput.c | 33 ++++++++++++++++++++++----------- tests/test_split.c | 12 +++++++----- 7 files changed, 54 insertions(+), 44 deletions(-) diff --git a/qrinput.c b/qrinput.c index 2723bf035b..85d60557c0 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1278,33 +1278,24 @@ static int QRinput_insertFNC1Header(QRinput *input) * @return merged bit stream */ -__STATIC BitStream *QRinput_mergeBitStream(QRinput *input) +__STATIC int QRinput_mergeBitStream(QRinput *input, BitStream *bstream) { - BitStream *bstream; - - bstream = BitStream_new(); - if(bstream == NULL) return NULL; - if(input->mqr) { if(QRinput_createBitStream(input, bstream) < 0) { - goto ABORT; + return -1; } } else { if(input->fnc1) { if(QRinput_insertFNC1Header(input) < 0) { - return NULL; + return -1; } } if(QRinput_convertData(input, bstream) < 0) { - goto ABORT; + return -1; } } - return bstream; - -ABORT: - BitStream_free(bstream); - return NULL; + return 0; } /** @@ -1318,21 +1309,24 @@ __STATIC BitStream *QRinput_getBitStream(QRinput *input) BitStream *bstream; int ret; - bstream = QRinput_mergeBitStream(input); - if(bstream == NULL) { - return NULL; - } + bstream = BitStream_new(); + if(bstream == NULL) return NULL; + + ret = QRinput_mergeBitStream(input, bstream); + if(ret < 0) goto ABORT; + if(input->mqr) { ret = QRinput_appendPaddingBitMQR(bstream, input); } else { ret = QRinput_appendPaddingBit(bstream, input); } - if(ret < 0) { - BitStream_free(bstream); - return NULL; - } + if(ret < 0) goto ABORT; return bstream; + +ABORT: + BitStream_free(bstream); + return NULL; } /** diff --git a/qrinput.h b/qrinput.h index 9e6bad625d..1f13e0ff2e 100644 --- a/qrinput.h +++ b/qrinput.h @@ -112,7 +112,7 @@ extern const signed char QRinput_anTable[128]; #define MAX_STRUCTURED_SYMBOLS 16 #ifdef WITH_TESTS -extern BitStream *QRinput_mergeBitStream(QRinput *input); +extern int QRinput_mergeBitStream(QRinput *input, BitStream *bstream); extern BitStream *QRinput_getBitStream(QRinput *input); extern int QRinput_estimateBitStreamSize(QRinput *input, int version); extern int QRinput_splitEntry(QRinput_List *entry, int bytes); diff --git a/tests/common.h b/tests/common.h index 2015e806fc..2d3b6c4ed8 100644 --- a/tests/common.h +++ b/tests/common.h @@ -43,7 +43,7 @@ void printQRinputInfo(QRinput *input) { QRinput_List *list; BitStream *b; - int i; + int i, ret; printf("QRinput info:\n"); printf(" version: %d\n", input->version); @@ -55,8 +55,9 @@ void printQRinputInfo(QRinput *input) list = list->next; } printf(" chunks: %d\n", i); - b = QRinput_mergeBitStream(input); - if(b != NULL) { + b = BitStream_new(); + ret = QRinput_mergeBitStream(input, b); + if(ret == 0) { printf(" bitstream-size: %d\n", BitStream_size(b)); BitStream_free(b); } diff --git a/tests/test_monkey.c b/tests/test_monkey.c index e872634ab5..756ca8f6d2 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -140,7 +140,8 @@ void test_encode_an(int num) snprintf(buf, 256, "monkey-orig-bits-%d.dat", num); fp = fopen(buf, "w"); - bstream = QRinput_mergeBitStream(input); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); c = 0; for(x=0; xlength; x++) { fputc((bstream->data[x]&1)?'1':'0', fp); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index cde7c32bac..7376ea4103 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -26,7 +26,8 @@ int inputSize(QRinput *input) BitStream *bstream; int size; - bstream = QRinput_mergeBitStream(input); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); size = BitStream_size(bstream); BitStream_free(bstream); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index bbcc279907..e7632665ca 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -44,7 +44,8 @@ int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct) input = QRinput_new(); } QRinput_append(input, mode, strlen(data), (unsigned char *)data); - bstream = QRinput_mergeBitStream(input); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); ret = cmpBin(correct, bstream); QRinput_free(input); @@ -82,8 +83,9 @@ void test_encode8_versionup(void) str = (char *)malloc(2900); memset(str, 0xff, 2900); stream = QRinput_new(); + bstream = BitStream_new(); QRinput_append(stream, QR_MODE_8, 2900, (unsigned char *)str); - bstream = QRinput_mergeBitStream(stream); + QRinput_mergeBitStream(stream, bstream); version = QRinput_getVersion(stream); assert_equal(version, 40, "Version is %d (40 expected).\n", version); testFinish(); @@ -134,8 +136,9 @@ void test_encodeNumeric_versionup(void) str = (char *)malloc(1050); memset(str, '1', 1050); stream = QRinput_new2(0, QR_ECLEVEL_L); + bstream = BitStream_new(); QRinput_append(stream, QR_MODE_NUM, 1050, (unsigned char *)str); - bstream = QRinput_mergeBitStream(stream); + QRinput_mergeBitStream(stream, bstream); version = QRinput_getVersion(stream); assert_equal(version, 14, "Version is %d (14 expected).", version); testFinish(); @@ -287,6 +290,7 @@ void test_encodeTooLong(void) QRinput *stream; unsigned char *data; BitStream *bstream; + int ret; data = (unsigned char *)malloc(4297); memset(data, 'A', 4297); @@ -294,8 +298,9 @@ void test_encodeTooLong(void) testStart("Encoding long string. (4297 bytes of alphanumeric)"); stream = QRinput_new(); QRinput_append(stream, QR_MODE_AN, 4297, data); - bstream = QRinput_mergeBitStream(stream); - testEndExp(bstream == NULL); + bstream = BitStream_new(); + ret = QRinput_mergeBitStream(stream, bstream); + testEndExp(ret != 0); QRinput_free(stream); if(bstream != NULL) { BitStream_free(bstream); @@ -312,7 +317,8 @@ void test_encodeAnNum(void) input = QRinput_new(); QRinput_append(input, QR_MODE_AN, 11, (unsigned char *)"ABCDEFGHIJK"); QRinput_append(input, QR_MODE_NUM, 12, (unsigned char *)"123456789012"); - bstream = QRinput_mergeBitStream(input); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); testEndExp(BitStream_size(bstream) == 128); QRinput_free(input); BitStream_free(bstream); @@ -320,7 +326,8 @@ void test_encodeAnNum(void) testStart("Bit length check of alphabet stream. (23)"); input = QRinput_new(); QRinput_append(input, QR_MODE_AN, 23, (unsigned char *)"ABCDEFGHIJK123456789012"); - bstream = QRinput_mergeBitStream(input); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); testEndExp(BitStream_size(bstream) == 140); QRinput_free(input); BitStream_free(bstream); @@ -368,10 +375,11 @@ void test_insertStructuredAppendHeader(void) testStart("Insert a structured-append header"); stream = QRinput_new(); + bstream = BitStream_new(); QRinput_append(stream, QR_MODE_8, 1, (unsigned char *)"A"); ret = QRinput_insertStructuredAppendHeader(stream, 16, 1, 0xa5); assert_zero(ret, "QRinput_insertStructuredAppendHeader() returns nonzero.\n"); - bstream = QRinput_mergeBitStream(stream); + QRinput_mergeBitStream(stream, bstream); assert_nonnull(bstream->data, "Bstream->data is null."); assert_zero(cmpBin(correct, bstream), "bitstream is wrong."); testFinish(); @@ -441,7 +449,8 @@ static int check_lengthOfCode(QRencodeMode mode, char *data, int size, int versi input = QRinput_new(); QRinput_setVersion(input, version); QRinput_append(input, mode, size, (unsigned char *)data); - b = QRinput_mergeBitStream(input); + b = BitStream_new(); + QRinput_mergeBitStream(input, b); bits = BitStream_size(b); bytes = QRinput_lengthOfCode(mode, version, bits); QRinput_free(input); @@ -507,7 +516,8 @@ void test_struct_split_example(void) e = s->head; i = 0; while(e != NULL) { - bstream = QRinput_mergeBitStream(e->input); + bstream = BitStream_new(); + QRinput_mergeBitStream(e->input, bstream); BitStream_free(bstream); l = e->input->head->next; assert_equal(l->mode, QR_MODE_8, "#%d: wrong mode (%d).\n", i, l->mode); @@ -927,7 +937,8 @@ void test_encodeECI(void) ret = QRinput_append(input, QR_MODE_8, 5, str); assert_zero(ret, "Failed to append characters.\n"); - bstream = QRinput_mergeBitStream(input); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); assert_nonnull(bstream, "Failed to merge.\n"); if(bstream != NULL) { ret = ncmpBin(correct, bstream, 64); diff --git a/tests/test_split.c b/tests/test_split.c index 10c9e3cd69..d177ae54f0 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -67,7 +67,8 @@ int inputSize(QRinput *input) BitStream *bstream; int size; - bstream = QRinput_mergeBitStream(input); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); size = BitStream_size(bstream); BitStream_free(bstream); @@ -77,15 +78,16 @@ int inputSize(QRinput *input) void test_split1(void) { QRinput *input; - BitStream *stream; + BitStream *bstream; testStart("Split test: null string"); input = QRinput_new2(0, QR_ECLEVEL_L); Split_splitStringToQRinput("", input, QR_MODE_8, 0); - stream = QRinput_mergeBitStream(input); - testEndExp(BitStream_size(stream) == 0); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); + testEndExp(BitStream_size(bstream) == 0); QRinput_free(input); - BitStream_free(stream); + BitStream_free(bstream); } void test_split2(void) -- cgit 0.0.5-2-1-g0f52 From 8cb6e6e37b7bddc12acc792cc77776f47bfac06d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Sep 2012 10:36:59 +0900 Subject: Interface of QRinput_getBitStream() have been changed. --- ChangeLog | 2 ++ qrinput.c | 25 ++++++++++++------------- qrinput.h | 2 +- tests/test_qrinput.c | 12 ++++++++---- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 721b8beaa5..76f423a28f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ * qrinput.c: - Reduced the use of dynamic memory allocation. - Performance improved. + - Interfaces of QRinput_getBitStream() and QRinput_mergeBitStream() have + been changed. 2012.09.25 Kentaro FUKUCHI * qrinput.c, tests/qrinput.c: diff --git a/qrinput.c b/qrinput.c index 85d60557c0..5dfdd54791 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1304,29 +1304,21 @@ __STATIC int QRinput_mergeBitStream(QRinput *input, BitStream *bstream) * @return padded merged bit stream */ -__STATIC BitStream *QRinput_getBitStream(QRinput *input) +__STATIC int QRinput_getBitStream(QRinput *input, BitStream *bstream) { - BitStream *bstream; int ret; - bstream = BitStream_new(); - if(bstream == NULL) return NULL; - ret = QRinput_mergeBitStream(input, bstream); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; if(input->mqr) { ret = QRinput_appendPaddingBitMQR(bstream, input); } else { ret = QRinput_appendPaddingBit(bstream, input); } - if(ret < 0) goto ABORT; + if(ret < 0) return -1; - return bstream; - -ABORT: - BitStream_free(bstream); - return NULL; + return 0; } /** @@ -1339,11 +1331,18 @@ unsigned char *QRinput_getByteStream(QRinput *input) { BitStream *bstream; unsigned char *array; + int ret; - bstream = QRinput_getBitStream(input); + bstream = BitStream_new(); if(bstream == NULL) { return NULL; } + + ret = QRinput_getBitStream(input, bstream); + if(ret < 0) { + BitStream_free(bstream); + return NULL; + } array = BitStream_toByte(bstream); BitStream_free(bstream); diff --git a/qrinput.h b/qrinput.h index 1f13e0ff2e..9bf2a4533d 100644 --- a/qrinput.h +++ b/qrinput.h @@ -113,7 +113,7 @@ extern const signed char QRinput_anTable[128]; #ifdef WITH_TESTS extern int QRinput_mergeBitStream(QRinput *input, BitStream *bstream); -extern BitStream *QRinput_getBitStream(QRinput *input); +extern int QRinput_getBitStream(QRinput *input, BitStream *bstream); extern int QRinput_estimateBitStreamSize(QRinput *input, int version); extern int QRinput_splitEntry(QRinput_List *entry, int bytes); extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index e7632665ca..1b50d2b406 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -19,7 +19,8 @@ int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mo input = QRinput_new2(version, level); } QRinput_append(input, mode, strlen(data), (unsigned char *)data); - bstream = QRinput_getBitStream(input); + bstream = BitStream_new(); + QRinput_getBitStream(input, bstream); ret = cmpBin(correct, bstream); if(ret) { printf("result : "); @@ -198,7 +199,8 @@ void test_padding(void) testStart("Padding bit check. (less than 5 bits)"); input = QRinput_new2(1, QR_ECLEVEL_L); QRinput_append(input, QR_MODE_8, 17, (unsigned char *)data); - bstream = QRinput_getBitStream(input); + bstream = BitStream_new(); + QRinput_getBitStream(input, bstream); size = BitStream_size(bstream); assert_equal(size, 152, "# of bit is incorrect (%d != 152).\n", size); c = 0; @@ -237,7 +239,8 @@ void test_padding2(void) input = QRinput_new2(1, QR_ECLEVEL_L); QRinput_append(input, QR_MODE_8, 16, (unsigned char *)data); - bstream = QRinput_getBitStream(input); + bstream = BitStream_new(); + QRinput_getBitStream(input, bstream); size = BitStream_size(bstream); assert_equal(size, 152, "16byte: # of bit is incorrect (%d != 152).\n", size); ret = ncmpBin(correct, bstream, 152); @@ -254,7 +257,8 @@ void test_padding2(void) input = QRinput_new2(1, QR_ECLEVEL_L); QRinput_append(input, QR_MODE_8, 15, (unsigned char *)data); - bstream = QRinput_getBitStream(input); + bstream = BitStream_new(); + QRinput_getBitStream(input, bstream); size = BitStream_size(bstream); assert_equal(size, 152, "15byte: # of bit is incorrect (%d != 152).\n", size); ret = ncmpBin(correct, bstream, 152); -- cgit 0.0.5-2-1-g0f52 From aa06a5bac59879ec1cca14f720ac68cd701d7884 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Oct 2012 04:00:49 +0900 Subject: Bumpved --- NEWS | 3 +++ README | 2 +- configure.ac | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index e093044d1c..cfd868d301 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ libqrencode NEWS - Overview of changes ====================================== +Version 3.4.0 (2012.10.x) +------------------------- + Version 3.3.1 (2012.4.18) ------------------------- * Bugs in command line tool, manual, configure script, and libtool files have diff --git a/README b/README index 5b3af6f4e9..71474650dc 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.3.1 - QR Code encoding library +libqrencode 3.4.0 - QR Code encoding library GENERAL INFORMATION =================== diff --git a/configure.ac b/configure.ac index 0e53a0df5c..83ba0e60ad 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ AC_INIT(QRencode) MAJOR_VERSION=3 -MINOR_VERSION=3 -MICRO_VERSION=1 +MINOR_VERSION=4 +MICRO_VERSION=0 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 4bd893507e172c1fc039fa19a7bfe788a52cad61 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Oct 2012 04:01:56 +0900 Subject: Bumped version to 3.4.0. --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5a41538770..a2c3b9b8b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.10.09 Kentaro FUKUCHI + * configure.ac, README, NEWS: + - Bumped version to 3.4.0. + 2012.09.25 Kentaro FUKUCHI * qrenc.c: - Input validation improved. (Thanks to Yann Droneaud) -- cgit 0.0.5-2-1-g0f52 From bf7c669f113dd67b97bcb74d77476f75faad2067 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Oct 2012 04:27:23 +0900 Subject: Improved Usage. --- qrenc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qrenc.c b/qrenc.c index ffc5e9b369..8ea431d16e 100644 --- a/qrenc.c +++ b/qrenc.c @@ -157,6 +157,11 @@ static void usage(int help, int longopt) " -i ignore case distinctions and use only upper-case characters.\n" " -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n" " -M encode in a Micro QR Code.\n" +" --foreground=RRGGBB[AA]\n" +" --background=RRGGBB[AA]\n" +" specify foreground/background color in hexadecimal notation.\n" +" 6-digit (RGB) or 8-digit (RGBA) form are supported.\n" +" Color output support available only in PNG and SVG.\n" " -V display the version number and copyrights of the qrencode.\n" " [STRING] input data. If it is not specified, data will be taken from\n" " standard input.\n" -- cgit 0.0.5-2-1-g0f52 From 64555315d574956426c91182fbe2eea5b1415976 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Oct 2012 04:27:41 +0900 Subject: Added SVG option to --type. --- qrencode.1.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qrencode.1.in b/qrencode.1.in index 2720f0a4c9..3576c6d1e4 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -1,4 +1,4 @@ -.TH QRENCODE 1 "Feb. 29, 2012" "qrencode @VERSION@" +.TH QRENCODE 1 "Oct. 9, 2012" "qrencode @VERSION@" .SH NAME qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS @@ -39,10 +39,10 @@ specify the width of margin. (default=4) specify the DPI of the generated PNG. (default=72) .TP .PD 0 -.B \-t {PNG,EPS,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.B \-t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} .TP .PD -.B \-\-type={PNG,EPS,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.B \-\-type={PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} specify the type of the generated image. (default=PNG) .TP .B \-S, \-\-structured -- cgit 0.0.5-2-1-g0f52 From 8a6673265e84a6d73d086ade3b9f120a5d1171ee Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Oct 2012 04:28:14 +0900 Subject: NEWS updates. --- ChangeLog | 5 +++++ NEWS | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index a2c3b9b8b9..42b0b4e5e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ 2012.10.09 Kentaro FUKUCHI + [3.4] * configure.ac, README, NEWS: - Bumped version to 3.4.0. + * qrencode.1.in: + - Added SVG option to --type. + * qrenc.c: + - Usage improved. 2012.09.25 Kentaro FUKUCHI * qrenc.c: diff --git a/NEWS b/NEWS index cfd868d301..70b7ed97be 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,17 @@ libqrencode NEWS - Overview of changes Version 3.4.0 (2012.10.x) ------------------------- +* SVG, UTF8, and ANSIUTF8 output supports have been added to the command line + tool. (Thanks to Dan Storm, David Dahl, and Lennart Poettering) +* Colored QR Code support. +* Bug fixes. (Thanks to Terry Burton, Fred Steinhaeuser, and Yann Droneaud) + +Release Note: +Three new output format, SVG, UTF8, and ANSIUTF8 have been added to the command +line tool. UTF8 and ANSIUTF8 are another text art mode, using Unicode block +elements for high-resolution text output. Long-awaited colored QR code has been +introduced. Try "--foreground" and "--background" options to set the colors. +Currently PNG and SVG supports colored output. Version 3.3.1 (2012.4.18) ------------------------- -- cgit 0.0.5-2-1-g0f52 From babfdb20075a2323de473e711378539d130c7d37 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Oct 2012 04:30:13 +0900 Subject: Contributors updated. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 71474650dc..1f395691fe 100644 --- a/README +++ b/README @@ -137,5 +137,5 @@ Lennart Poettering (mezcalero) - Improved text art patch Yann Droneaud - Improved input validation patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, -Fred Steinhaeuser +Fred Steinhaeuser, Terry Burton - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 2e08c29841b663184be50ee59dc2ea92ef09242c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Oct 2012 23:47:22 +0900 Subject: Inkscape-friendly SVG output. --- ChangeLog | 1 + qrenc.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42b0b4e5e8..7e45d4a4a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ - Added SVG option to --type. * qrenc.c: - Usage improved. + - Inkscape-friendly SVG output. 2012.09.25 Kentaro FUKUCHI * qrenc.c: diff --git a/qrenc.c b/qrenc.c index 8ea431d16e..3fa13b6d2a 100644 --- a/qrenc.c +++ b/qrenc.c @@ -415,7 +415,7 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) FILE *fp; unsigned char *row, *p; int x, y, x0, pen; - int realwidth; + int symwidth, realwidth; float scale; char fg[7], bg[7]; float fg_opacity; @@ -425,7 +425,8 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) scale = dpi * INCHES_PER_METER / 100.0; - realwidth = (qrcode->width + margin * 2) * size; + symwidth = qrcode->width + margin * 2; + realwidth = symwidth * size; snprintf(fg, 7, "%02x%02x%02x", fg_color[0], fg_color[1], fg_color[2]); snprintf(bg, 7, "%02x%02x%02x", bg_color[0], bg_color[1], bg_color[2]); @@ -452,10 +453,7 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) fprintf( fp, "\n", - realwidth / scale, - realwidth / scale, - qrcode->width + margin * 2, - qrcode->width + margin * 2 + realwidth / scale, realwidth / scale, symwidth, symwidth ); /* Make named group */ @@ -463,9 +461,9 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) /* Make solid background */ if(bg_color[3] != 255) { - fprintf(fp, "\t\t\n", bg, bg_opacity); + fprintf(fp, "\t\t\n", symwidth, symwidth, bg, bg_opacity); } else { - fprintf(fp, "\t\t\n", bg); + fprintf(fp, "\t\t\n", symwidth, symwidth, bg); } /* Create new viewbox for QR data */ -- cgit 0.0.5-2-1-g0f52 From a761ba4172d6861900825d3633217d7401420841 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 13 Oct 2012 06:44:21 +0900 Subject: Documentation improved. Copyright year has been updated. --- qrencode.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/qrencode.h b/qrencode.h index fa53e364d5..63540e8a1e 100644 --- a/qrencode.h +++ b/qrencode.h @@ -1,7 +1,7 @@ /** * qrencode - QR Code encoder * - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2012 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -382,12 +382,10 @@ typedef struct { * Singly-linked list of QRcode. Used to represent a structured symbols. * A list is terminated with NULL. */ -typedef struct _QRcode_List QRcode_List; - -struct _QRcode_List { +typedef struct _QRcode_List { QRcode *code; - QRcode_List *next; -}; + struct _QRcode_List *next; +} QRcode_List; /** * Create a symbol from the input data. @@ -555,6 +553,7 @@ extern char *QRcode_APIVersionString(void); /** * Clear all caches. This is only for debug purpose. If you are attacking a * complicated memory leak bug, try this to reduce the reachable blocks record. + * @warning This function is THREAD UNSAFE when pthread is disabled. */ extern void QRcode_clearCache(void); -- cgit 0.0.5-2-1-g0f52 From 9bc3eeeb9b8f1776b789d4c683d551b7730bc0c9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 13 Oct 2012 06:44:47 +0900 Subject: Rebased on a template from Doxygen 1.7.6.1. --- ChangeLog | 8 + Doxyfile | 1673 ++++++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 1109 insertions(+), 572 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e45d4a4a5..a587ebc3b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012.10.13 Kentaro FUKUCHI + [3.4] + * qrencode.h: + - Documentation improved. + - Copyright year has been updated. + * Doxyfile: + - Rebased on a template from Doxygen 1.7.6.1. + 2012.10.09 Kentaro FUKUCHI [3.4] * configure.ac, README, NEWS: diff --git a/Doxyfile b/Doxyfile index f4aa9431be..a2a015120c 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,603 +1,823 @@ -# Doxyfile 1.4.7 +# Doxyfile 1.7.6.1 # This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project +# doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored +# All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") +# Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. PROJECT_NAME = QRencode -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "QR Code encoder" + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = +OUTPUT_DIRECTORY = -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, -# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, -# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, -# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, -# Swedish, and Ukrainian. +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" -ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = +STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) -MULTILINE_CPP_IS_BRIEF = NO +QT_AUTOBRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. -DETAILS_AT_TOP = NO +MULTILINE_CPP_IS_BRIEF = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = YES + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = YES -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = YES -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = YES -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = NO -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = qrencode.h -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. -EXCLUDE = +EXCLUDE = -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented # functions referencing it will be listed. -REFERENCED_BY_RELATION = YES +REFERENCED_BY_RELATION = NO -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities # called/used by that function will be listed. -REFERENCES_RELATION = YES +REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. +# link to the source code. +# Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES @@ -606,279 +826,548 @@ VERBATIM_HEADERS = YES # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. -HTML_HEADER = +HTML_FOOTER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! -HTML_FOOTER = +HTML_STYLESHEET = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. -HTML_STYLESHEET = +HTML_EXTRA_FILES = -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. -GENERATE_TREEVIEW = NO +USE_INLINE_TREES = NO -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. -PAPER_TYPE = a4wide +PAPER_TYPE = a4 -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. -PDF_HYPERLINKS = NO +PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. -USE_PDFLATEX = NO +USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO @@ -887,33 +1376,33 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES @@ -922,10 +1411,10 @@ XML_PROGRAMLISTING = YES # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO @@ -934,319 +1423,359 @@ GENERATE_AUTOGEN_DEF = NO # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the preprocessor +# Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen +# If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO -# If set to YES, the inheritance and collaboration graphs will show the +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. CALL_GRAPH = NO -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). -MAX_DOT_GRAPH_WIDTH = 1024 +MSCFILE_DIRS = -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. -MAX_DOT_GRAPH_HEIGHT = 1024 +DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that a graph may be further truncated if the graph's -# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH -# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), -# the graph is not depth-constrained. +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. -DOT_MULTI_TARGETS = NO +DOT_MULTI_TARGETS = YES -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO -- cgit 0.0.5-2-1-g0f52 From 29961bf3b14d0a8fe4039b84e43cc3d96d7349f5 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 13 Oct 2012 06:47:31 +0900 Subject: Indent fixed. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 1f395691fe..02133dd698 100644 --- a/README +++ b/README @@ -134,7 +134,7 @@ Ralf Ertzinger - ASCII support patch Yutaka Niibe (gniibe) - various bug fix patches Dan Storm (Repox) - SVG support patch Lennart Poettering (mezcalero) - - Improved text art patch + - Improved text art patch Yann Droneaud - Improved input validation patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton -- cgit 0.0.5-2-1-g0f52 From e02549d155c5aff4dc405719366e53cb9e438164 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 15 Oct 2012 05:47:08 +0900 Subject: Version 3.4.0 has been released. --- ChangeLog | 4 ++++ NEWS | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a587ebc3b0..c108b55dac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.10.15 Kentaro FUKUCHI + [3.4] + * Version 3.4.0 has been released. + 2012.10.13 Kentaro FUKUCHI [3.4] * qrencode.h: diff --git a/NEWS b/NEWS index 70b7ed97be..f1d2b66512 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,8 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.4.0 (2012.10.x) -------------------------- +Version 3.4.0 (2012.10.15) +-------------------------- * SVG, UTF8, and ANSIUTF8 output supports have been added to the command line tool. (Thanks to Dan Storm, David Dahl, and Lennart Poettering) * Colored QR Code support. -- cgit 0.0.5-2-1-g0f52 From 55ed2a6260eee67196b1d7fb3b508dfc5774d5cc Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 15 Oct 2012 06:05:29 +0900 Subject: Merged version 3.4.0. --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index c108b55dac..df6c2034fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2012.10.15 Kentaro FUKUCHI [3.4] * Version 3.4.0 has been released. + [master] + * Merged 3.4.0. 2012.10.13 Kentaro FUKUCHI [3.4] -- cgit 0.0.5-2-1-g0f52 From f92f76a238693ad813e4755d32de22a3fc23f1cd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 15 Oct 2012 07:38:34 +0900 Subject: HAVE_LIBPTHREAD was not correctly defined in config.h.in. --- ChangeLog | 5 +++++ configure.ac | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index c108b55dac..ef59cd9934 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012.10.15 Kentaro FUKUCHI + [3.4] + * configure.ac: + - HAVE_LIBPTHREAD was not correctly defined in config.h.in. + 2012.10.15 Kentaro FUKUCHI [3.4] * Version 3.4.0 has been released. diff --git a/configure.ac b/configure.ac index 83ba0e60ad..8419f74607 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,10 @@ if test x$enable_thread_safety = xyes; then AC_CHECK_LIB([pthread], [pthread_mutex_init], [AC_SUBST([LIBPTHREAD], [-lpthread])]) fi AM_CONDITIONAL([HAVE_LIBPTHREAD], [test "x$ac_cv_lib_pthread_pthread_mutex_init" = "xyes" ]) +# FIXME: isn't it able to integrate the followings to AC_CHECK_LIB? +if test x$ac_cv_lib_pthread_pthread_mutex_init = xyes ; then + AC_DEFINE([HAVE_LIBPTHREAD], [1], [Define to 1 if using pthread is enabled.]) +fi dnl --with-tools -- cgit 0.0.5-2-1-g0f52 From 665285cfad9604fd657a4b3b39453ee1830e3b93 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 15 Oct 2012 14:59:23 +0900 Subject: New test script checking autoconf-related scripts has been added. --- tests/test_configure.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 tests/test_configure.sh diff --git a/tests/test_configure.sh b/tests/test_configure.sh new file mode 100755 index 0000000000..a2f9b3f309 --- /dev/null +++ b/tests/test_configure.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +BASEDIR=.. + +CONFIG_H_IN="$BASEDIR/config.h.in" +CONFIG_H="$BASEDIR/config.h" +LIBQRENCODE_PC_IN="$BASEDIR/libqrencode.pc.in" +LIBQRENCODE_PC="$BASEDIR/libqrencode.pc" + +(cd $BASEDIR; ./autogen.sh) + +# test config.h.in +grep "#undef HAVE_LIBPTHREAD" $CONFIG_H_IN > /dev/null +if test ! $? -eq 0; then + echo "HAVE_LIBPTHREAD undefined in config.h.in." + exit 1 +fi + +# test libqrencode.pc.in +grep "Libs.private: @LIBPTHREAD@" $LIBQRENCODE_PC_IN > /dev/null +if test ! $? -eq 0; then + echo "Pthread is not handled in libqrencode.pc.in." + exit 1 +fi + +# test pthread checks in configure +(cd $BASEDIR; ./configure --with-tests --enable-thread-safety > /dev/null) +grep "#define HAVE_LIBPTHREAD 1" $CONFIG_H > /dev/null +if test ! $? -eq 0; then + echo "HAVE_LIBPTHREAD undefined in config.h." + exit 1 +fi + +grep "Libs.private: -lpthread" $LIBQRENCODE_PC > /dev/null +if test ! $? -eq 0; then + echo "Pthread is not handled in libqrencode.pc." + exit 1 +fi + +(cd $BASEDIR; ./configure --with-tests --disable-thread-safety > /dev/null) +grep "#define HAVE_LIBPTHREAD 1" $CONFIG_H > /dev/null +if test ! $? -eq 1; then + echo "HAVE_LIBPTHREAD incorrectly defined in config.h." + exit 1 +fi + +grep "Libs.private: -lpthread" $LIBQRENCODE_PC > /dev/null +if test ! $? -eq 1; then + echo "Pthread is incorrectly handled in libqrencode.pc." + exit 1 +fi + +(cd $BASEDIR; ./configure --with-tests > /dev/null) + +exit 0 -- cgit 0.0.5-2-1-g0f52 From d7a6a70b776ed1cfeeaa625fa4e87a18cf39fced Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 15 Oct 2012 14:59:44 +0900 Subject: Bumped version to 3.4.0. --- ChangeLog | 4 ++++ NEWS | 4 ++++ README | 2 +- configure.ac | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef59cd9934..197cabc91d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ [3.4] * configure.ac: - HAVE_LIBPTHREAD was not correctly defined in config.h.in. + * tests/test_configure.sh: + - New test script checking autoconf-related scripts has been added. + * configure.ac, README, NEWS: + - Bumped version to 3.4.0. 2012.10.15 Kentaro FUKUCHI [3.4] diff --git a/NEWS b/NEWS index f1d2b66512..30f6b15cd1 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ libqrencode NEWS - Overview of changes ====================================== +Version 3.4.1 (2012.10.15) +-------------------------- +* Bug fix release. + Version 3.4.0 (2012.10.15) -------------------------- * SVG, UTF8, and ANSIUTF8 output supports have been added to the command line diff --git a/README b/README index 02133dd698..700466861b 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.4.0 - QR Code encoding library +libqrencode 3.4.1 - QR Code encoding library GENERAL INFORMATION =================== diff --git a/configure.ac b/configure.ac index 8419f74607..b9d725777e 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_INIT(QRencode) MAJOR_VERSION=3 MINOR_VERSION=4 -MICRO_VERSION=0 +MICRO_VERSION=1 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 538055153f6b0b99ea83bcd967cfab4ccb16ff06 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 15 Oct 2012 16:12:41 +0900 Subject: Bumped version to 3.4.1. (typo fix) --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 197cabc91d..730296fd7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ * tests/test_configure.sh: - New test script checking autoconf-related scripts has been added. * configure.ac, README, NEWS: - - Bumped version to 3.4.0. + - Bumped version to 3.4.1. 2012.10.15 Kentaro FUKUCHI [3.4] -- cgit 0.0.5-2-1-g0f52 From d207c9abba4b89929b5d2698eebcdea63b1a76f9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 18 Oct 2012 01:25:11 +0900 Subject: Version 3.4.1. --- ChangeLog | 6 ++++++ NEWS | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 730296fd7f..2fe5349a23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012.10.17 Kentaro FUKUCHI + [3.4] + * NEWS: + - Release note has been written. + * Version 3.4.1 has been released. + 2012.10.15 Kentaro FUKUCHI [3.4] * configure.ac: diff --git a/NEWS b/NEWS index 30f6b15cd1..ad17098293 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,15 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.4.1 (2012.10.15) +Version 3.4.1 (2012.10.17) -------------------------- * Bug fix release. +Release Note: +Mutual exclusion did not work correctly since 3.3.1. If your application uses +libqrencode in multithreaded environment, it is strongly recommended to update +it. + Version 3.4.0 (2012.10.15) -------------------------- * SVG, UTF8, and ANSIUTF8 output supports have been added to the command line -- cgit 0.0.5-2-1-g0f52 From 1b881dea4c2e2f9bdcb4e0a8fe552e6d7f61501c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 21 Oct 2012 05:20:30 +0900 Subject: Unnecessary "goto ABORT" eliminated. --- ChangeLog | 4 ++++ qrinput.c | 82 ++++++++++++++++++++++++++------------------------------------- 2 files changed, 38 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index b052724fcc..969cc2c057 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.10.21 Kentaro FUKUCHI + * qrinput.c: + - Unnecessary "goto ABORT" eliminated. + 2012.10.17 Kentaro FUKUCHI [3.4] * NEWS: diff --git a/qrinput.c b/qrinput.c index 5dfdd54791..c6ecec2023 100644 --- a/qrinput.c +++ b/qrinput.c @@ -415,16 +415,16 @@ static int QRinput_encodeModeNum(QRinput_List *entry, BitStream *bstream, int ve if(mqr) { if(version > 1) { ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_NUM); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_NUM); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } words = entry->size / 3; @@ -434,23 +434,21 @@ static int QRinput_encodeModeNum(QRinput_List *entry, BitStream *bstream, int ve val += (entry->data[i*3+2] - '0'); ret = BitStream_appendNum(bstream, 10, val); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } if(entry->size - words * 3 == 1) { val = entry->data[words*3] - '0'; ret = BitStream_appendNum(bstream, 4, val); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } else if(entry->size - words * 3 == 2) { val = (entry->data[words*3 ] - '0') * 10; val += (entry->data[words*3+1] - '0'); BitStream_appendNum(bstream, 7, val); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } return 0; -ABORT: - return -1; } /****************************************************************************** @@ -523,17 +521,17 @@ static int QRinput_encodeModeAn(QRinput_List *entry, BitStream *bstream, int ver if(mqr) { if(version < 2) { errno = EINVAL; - goto ABORT; + return -1; } ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_AN); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_AN, version), entry->size); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_AN); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_AN, version), entry->size); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } words = entry->size / 2; @@ -542,19 +540,17 @@ static int QRinput_encodeModeAn(QRinput_List *entry, BitStream *bstream, int ver val += (unsigned int)QRinput_lookAnTable(entry->data[i*2+1]); ret = BitStream_appendNum(bstream, 11, val); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } if(entry->size & 1) { val = (unsigned int)QRinput_lookAnTable(entry->data[words * 2]); ret = BitStream_appendNum(bstream, 6, val); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } return 0; -ABORT: - return -1; } /****************************************************************************** @@ -587,25 +583,23 @@ static int QRinput_encodeMode8(QRinput_List *entry, BitStream *bstream, int vers if(mqr) { if(version < 3) { errno = EINVAL; - goto ABORT; + return -1; } ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_8); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_8, version), entry->size); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_8); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_8, version), entry->size); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } ret = BitStream_appendBytes(bstream, entry->size, entry->data); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; return 0; -ABORT: - return -1; } @@ -665,17 +659,17 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int if(mqr) { if(version < 2) { errno = EINVAL; - goto ABORT; + return -1; } ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_KANJI); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_KANJI); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } for(i=0; isize; i+=2) { @@ -689,12 +683,10 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int val = (val & 0xff) + h; ret = BitStream_appendNum(bstream, 13, val); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; } return 0; -ABORT: - return -1; } /****************************************************************************** @@ -721,17 +713,15 @@ static int QRinput_encodeModeStructure(QRinput_List *entry, BitStream *bstream, } ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_STRUCTURE); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, 4, entry->data[1] - 1); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, 4, entry->data[0] - 1); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, 8, entry->data[2]); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; return 0; -ABORT: - return -1; } /****************************************************************************** @@ -750,14 +740,12 @@ static int QRinput_encodeModeFNC1Second(QRinput_List *entry, BitStream *bstream, int ret; ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_FNC1SECOND); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendBytes(bstream, 1, entry->data); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; return 0; -ABORT: - return -1; } /****************************************************************************** @@ -813,14 +801,12 @@ static int QRinput_encodeModeECI(QRinput_List *entry, BitStream *bstream, int ve } ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_ECI); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; ret = BitStream_appendNum(bstream, words * 8, code); - if(ret < 0) goto ABORT; + if(ret < 0) return -1; return 0; -ABORT: - return -1; } /****************************************************************************** -- cgit 0.0.5-2-1-g0f52 From ebe3bbd599b4f8fbf11ca26ee6bfe0213de1d6a4 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 21 Oct 2012 19:40:11 +0900 Subject: Typo fixes in comments. --- qrinput.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/qrinput.c b/qrinput.c index c6ecec2023..5d51049dc6 100644 --- a/qrinput.c +++ b/qrinput.c @@ -373,7 +373,7 @@ static int QRinput_checkModeNum(int size, const char *data) } /** - * Estimates the length of the encoded bit stream of numeric data. + * Estimate the length of the encoded bit stream of numeric data. * @param size * @return number of bits */ @@ -399,7 +399,7 @@ int QRinput_estimateBitsModeNum(int size) } /** - * Convert the number data to a bit stream. + * Convert the number data and append to a bit stream. * @param entry * @param mqr * @retval 0 success @@ -485,7 +485,7 @@ static int QRinput_checkModeAn(int size, const char *data) } /** - * Estimates the length of the encoded bit stream of alphabet-numeric data. + * Estimate the length of the encoded bit stream of alphabet-numeric data. * @param size * @return number of bits */ @@ -504,7 +504,7 @@ int QRinput_estimateBitsModeAn(int size) } /** - * Convert the alphabet-numeric data to a bit stream. + * Convert the alphabet-numeric data and append to a bit stream. * @param entry * @param mqr * @retval 0 success @@ -558,7 +558,7 @@ static int QRinput_encodeModeAn(QRinput_List *entry, BitStream *bstream, int ver *****************************************************************************/ /** - * Estimates the length of the encoded bit stream of 8 bit data. + * Estimate the length of the encoded bit stream of 8 bit data. * @param size * @return number of bits */ @@ -568,7 +568,7 @@ int QRinput_estimateBitsMode8(int size) } /** - * Convert the 8bits data to a bit stream. + * Convert the 8bits data and append to a bit stream. * @param entry * @param mqr * @retval 0 success @@ -608,7 +608,7 @@ static int QRinput_encodeMode8(QRinput_List *entry, BitStream *bstream, int vers *****************************************************************************/ /** - * Estimates the length of the encoded bit stream of kanji data. + * Estimate the length of the encoded bit stream of kanji data. * @param size * @return number of bits */ @@ -642,7 +642,7 @@ static int QRinput_checkModeKanji(int size, const unsigned char *data) } /** - * Convert the kanji data to a bit stream. + * Convert the kanji data and append to a bit stream. * @param entry * @param mqr * @retval 0 success @@ -694,7 +694,7 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int *****************************************************************************/ /** - * Convert a structure symbol code to a bit stream. + * Convert a structure symbol code and append to a bit stream. * @param entry * @param mqr * @retval 0 success @@ -846,7 +846,7 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) *****************************************************************************/ /** - * Estimates the length of the encoded bit stream on the current version. + * Estimate the length of the encoded bit stream on the current version. * @param entry * @param version version of the symbol * @param mqr @@ -903,7 +903,7 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version } /** - * Estimates the length of the encoded bit stream of the data. + * Estimate the length of the encoded bit stream of the data. * @param input input data * @param version version of the symbol * @return number of bits @@ -923,7 +923,7 @@ __STATIC int QRinput_estimateBitStreamSize(QRinput *input, int version) } /** - * Estimates the required version number of the symbol. + * Estimate the required version number of the symbol. * @param input input data * @return required version number */ @@ -946,7 +946,7 @@ static int QRinput_estimateVersion(QRinput *input) } /** - * Returns required length in bytes for specified mode, version and bits. + * Return required length in bytes for specified mode, version and bits. * @param mode * @param version * @param bits @@ -999,8 +999,9 @@ __STATIC int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) *****************************************************************************/ /** - * Convert the input data in the data chunk to a bit stream. + * Convert the input data in the data chunk and append to a bit stream. * @param entry + * @param bstream * @return number of bits (>0) or -1 for failure. */ static int QRinput_encodeBitStream(QRinput_List *entry, BitStream *bstream, int version, int mqr) @@ -1090,6 +1091,7 @@ static int QRinput_createBitStream(QRinput *input, BitStream *bstream) * When the version number is given and that is not sufficient, it is increased * automatically. * @param input input data. + * @param bstream where the converted data is stored. * @retval 0 success * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. -- cgit 0.0.5-2-1-g0f52 From 80b60e26676120a3b65f050a18ba587c87444796 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 8 Nov 2012 16:57:11 +0900 Subject: Memory leak bug has been fixed. (issue #24) (Thanks to chisj) --- ChangeLog | 6 ++++++ qrinput.c | 8 ++++++-- tests/test_qrencode.c | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 413b4fb448..098c578c7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012.11.8 Kentaro FUKUCHI + * qrinput.c: + - Memory leak bug has been fixed. (issue #25) (Thanks to chisj) + * tests/test_qrinput.c: + - Added NUL checks for malloc-related bugs using failmalloc. + 2012.10.17 Kentaro FUKUCHI [3.4] * NEWS: diff --git a/qrinput.c b/qrinput.c index 5dcacf8aa2..f484945e78 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1645,12 +1645,16 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) input->tail = prev; } ret = QRinput_Struct_appendInput(s, input); - if(ret < 0) goto ABORT; + if(ret < 0) { + QRinput_free(p); + goto ABORT; + } input = p; bits = 0; } } - QRinput_Struct_appendInput(s, input); + ret = QRinput_Struct_appendInput(s, input); + if(ret < 0) goto ABORT; if(s->size > MAX_STRUCTURED_SYMBOLS) { QRinput_Struct_free(s); errno = ERANGE; diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index cde7c32bac..9f02a16f16 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -245,6 +245,7 @@ void test_format(void) testStart("Test format information(level L,mask 0)"); width = QRspec_getWidth(1); frame = QRspec_newFrame(1); + if(frame == NULL) goto ABORT; format = QRspec_getFormatInfo(1, QR_ECLEVEL_L); blacks = Mask_writeFormatInformation(width, frame, 1, QR_ECLEVEL_L); decode = 0; @@ -294,6 +295,7 @@ void test_format(void) free(frame); +ABORT: testEnd(0); } @@ -336,11 +338,13 @@ void test_encode(void) testStart("Test encode (1-M)"); stream = QRinput_new(); + if(stream == NULL) goto ABORT; QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); for(mask=0; mask<8; mask++) { QRinput_setVersion(stream, 1); QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_M); qrcode = QRcode_encodeMask(stream, mask); + if(qrcode == NULL) goto ABORT; w = qrcode->width; frame = qrcode->data; for(y=0; y Date: Thu, 8 Nov 2012 17:51:40 +0900 Subject: Incorrect bit extraction bug in QRcode_encodeMaskMQR() has been fixed. (issue #25) (Thanks to vlad417) --- ChangeLog | 8 ++++++-- README | 2 +- qrencode.c | 2 +- tests/test_qrencode.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 098c578c7b..5d42534867 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,12 @@ 2012.11.8 Kentaro FUKUCHI * qrinput.c: - - Memory leak bug has been fixed. (issue #25) (Thanks to chisj) - * tests/test_qrinput.c: + - Memory leak bug has been fixed. (issue #24) (Thanks to chisj) + * qrencode.c: + - Incorrect bit extraction bug in QRcode_encodeMaskMQR() has been fixed. + (issue #25) (Thanks to vlad417) + * tests/test_qrencode.c: - Added NUL checks for malloc-related bugs using failmalloc. + - Added a new test for issue #25. (Thanks to vlad417) 2012.10.17 Kentaro FUKUCHI [3.4] diff --git a/README b/README index 700466861b..8153c4640d 100644 --- a/README +++ b/README @@ -137,5 +137,5 @@ Lennart Poettering (mezcalero) - Improved text art patch Yann Droneaud - Improved input validation patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, -Fred Steinhaeuser, Terry Burton +Fred Steinhaeuser, Terry Burton, chisj, vlad417 - bug report / suggestion diff --git a/qrencode.c b/qrencode.c index b1d713d4ab..ab8b5d85c5 100644 --- a/qrencode.c +++ b/qrencode.c @@ -584,7 +584,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) for(i=0; idataLength + raw->eccLength; i++) { code = MQRraw_getCode(raw); if(raw->oddbits && i == raw->dataLength - 1) { - bit = 1 << raw->oddbits; + bit = 1 << (raw->oddbits - 1); for(j=0; joddbits; j++) { p = FrameFiller_next(filler); if(p == NULL) goto EXIT; diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 9f02a16f16..d1e0918d34 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -19,6 +19,15 @@ static const char decodeAnTable[45] = { '+', '-', '.', '/', ':' }; +typedef struct { + char *str; + int version; + QRecLevel level; + QRencodeMode hint; + int casesensitive; +} TestString; +#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0])) + #define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0)) int inputSize(QRinput *input) @@ -818,6 +827,38 @@ void test_decodeShortMQR(void) testFinish(); } +void test_oddBitCalcMQR(void) +{ + /* test issue #25 (odd bits calculation bug) */ + /* test pattern contributed by vlad417 */ + TestString tests[] = { + {"46194", 1, QR_ECLEVEL_L, QR_MODE_8, 1}, + {"WBA5Y47YPQQ", 3, QR_ECLEVEL_L, QR_MODE_8, 1} + }; + QRcode *qrcode; + QRdata *qrdata; + int i; + + testStart("Odd bits calculation bug checking (MQR)."); + + for(i=0; i<_countof(tests); i++) { + qrcode = QRcode_encodeStringMQR(tests[i].str, + tests[i].version, + tests[i].level, + tests[i].hint, + tests[i].casesensitive); + assert_nonnull(qrcode, "Failed to encode: %s\n", tests[i].str); + if(qrcode == NULL) continue; + qrdata = QRcode_decodeMQR(qrcode); + assert_nonnull(qrdata, "Failed to decode.\n"); + assert_zero(strcmp((char *)qrdata->data, tests[i].str), "Decoded data (%s) mismatched (%s)\n", (char *)qrdata->data, tests[i].str); + if(qrdata != NULL) QRdata_free(qrdata); + QRcode_free(qrcode); + } + + testFinish(); +} + void test_mqrencode(void) { char *str = "MICROQR"; @@ -915,6 +956,7 @@ int main(void) test_formatInfoMQR(); test_encodeTooLongMQR(); test_decodeShortMQR(); + test_oddBitCalcMQR(); test_mqrencode(); test_apiversion(); -- cgit 0.0.5-2-1-g0f52 From 959f6f9ae12a3a329f68c2ee074accf43f08cc86 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 9 Nov 2012 01:48:28 +0900 Subject: Code cleanup. --- ChangeLog | 4 ++++ qrinput.c | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d42534867..53bf64c5de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012.11.9 Kentaro FUKUCHI + * qrinput.c: + - Code cleanup. + 2012.11.8 Kentaro FUKUCHI * qrinput.c: - Memory leak bug has been fixed. (issue #24) (Thanks to chisj) diff --git a/qrinput.c b/qrinput.c index f484945e78..2533d08448 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1618,16 +1618,19 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) list = list->next; } else { bytes = QRinput_lengthOfCode(list->mode, input->version, maxbits - bits); + p = QRinput_new2(input->version, input->level); + if(p == NULL) goto ABORT; if(bytes > 0) { /* Splits this entry into 2 entries. */ ret = QRinput_splitEntry(list, bytes); - if(ret < 0) goto ABORT; + if(ret < 0) { + QRinput_free(p); + goto ABORT; + } /* First half is the tail of the current input. */ next = list->next; list->next = NULL; /* Second half is the head of the next input, p.*/ - p = QRinput_new2(input->version, input->level); - if(p == NULL) goto ABORT; p->head = next; /* Renew QRinput.tail. */ p->tail = input->tail; @@ -1638,8 +1641,6 @@ QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input) } else { /* Current entry will go to the next input. */ prev->next = NULL; - p = QRinput_new2(input->version, input->level); - if(p == NULL) goto ABORT; p->head = list; p->tail = input->tail; input->tail = prev; -- cgit 0.0.5-2-1-g0f52 From 08da4df8977f2bc74f364c7184c4edcf39d40150 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 30 Nov 2012 03:09:42 +0900 Subject: Doxygen documents improved. --- ChangeLog | 8 ++++++-- qrencode.h | 32 +++++++++++++++++--------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53bf64c5de..03ec5626f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,12 @@ -2012.11.9 Kentaro FUKUCHI +2012.11.30 Kentaro FUKUCHI + * qrencode.h + - Doxygen documents improved. + +2012.11.09 Kentaro FUKUCHI * qrinput.c: - Code cleanup. -2012.11.8 Kentaro FUKUCHI +2012.11.08 Kentaro FUKUCHI * qrinput.c: - Memory leak bug has been fixed. (issue #24) (Thanks to chisj) * qrencode.c: diff --git a/qrencode.h b/qrencode.h index 63540e8a1e..e554bb9241 100644 --- a/qrencode.h +++ b/qrencode.h @@ -24,10 +24,10 @@ * * \section encoding Encoding * - * There are two ways to encode data: encoding a string or + * There are two methods to encode data: encoding a string/data or * encoding a structured data. * - * \subsection encoding-string Encoding a string + * \subsection encoding-string Encoding a string/data * You can encode a string by calling QRcode_encodeString(). * The given string is parsed automatically and encoded. If you want to encode * data that can be represented as a C string style (NUL terminated), you can @@ -36,11 +36,11 @@ * If the input data contains Kanji (Shift-JIS) characters and you want to * encode them as Kanji in QR Code, you should give QR_MODE_KANJI as a hint. * Otherwise, all of non-alphanumeric characters are encoded as 8 bit data. - * If you want to encode a whole string in 8 bit mode, use + * If you want to encode a whole string in 8 bit mode, you can use * QRcode_encodeString8bit() instead. * - * Please note that a C string can not contain NUL character. If your data - * contains NUL, you should chose the second way. + * Please note that a C string can not contain NUL characters. If your data + * contains NUL, you must use QRcode_encodeData(). * * \subsection encoding-input Encoding a structured data * You can construct a structured input data manually. If the structure of the @@ -408,11 +408,12 @@ extern QRcode *QRcode_encodeInput(QRinput *input); * @param version version of the symbol. If 0, the library chooses the minimum * version for the given input data. * @param level error correction level. - * @param hint tell the library how non-alphanumerical characters should be - * encoded. If QR_MODE_KANJI is given, kanji characters will be - * encoded as Shif-JIS characters. If QR_MODE_8 is given, all of - * non-alphanumerical characters will be encoded as is. If you want - * to embed UTF-8 string, choose this. + * @param hint tell the library how Japanese Kanji characters should be + * encoded. If QR_MODE_KANJI is given, the library assumes that the + * given string contains Shift-JIS characters and encodes them in + * Kanji-mode. If QR_MODE_8 is given, all of non-alphanumerical + * characters will be encoded as is. If you want to embed UTF-8 + * string, choose this. Other mode will cause EINVAL error. * @param casesensitive case-sensitive(1) or not(0). * @return an instance of QRcode class. The version of the result QRcode may * be larger than the designated version. On error, NULL is returned, @@ -483,11 +484,12 @@ extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s); * @param string input string. It must be NUL terminated. * @param version version of the symbol. * @param level error correction level. - * @param hint tell the library how non-alphanumerical characters should be - * encoded. If QR_MODE_KANJI is given, kanji characters will be - * encoded as Shif-JIS characters. If QR_MODE_8 is given, all of - * non-alphanumerical characters will be encoded as is. If you want - * to embed UTF-8 string, choose this. + * @param hint tell the library how Japanese Kanji characters should be + * encoded. If QR_MODE_KANJI is given, the library assumes that the + * given string contains Shift-JIS characters and encodes them in + * Kanji-mode. If QR_MODE_8 is given, all of non-alphanumerical + * characters will be encoded as is. If you want to embed UTF-8 + * string, choose this. Other mode will cause EINVAL error. * @param casesensitive case-sensitive(1) or not(0). * @return a singly-linked list of QRcode. On error, NULL is returned, and * errno is set to indicate the error. See Exceptions for the details. -- cgit 0.0.5-2-1-g0f52 From 0d8b58a11ada78856cf751052d20bd343a6446f8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 17 Feb 2013 14:58:23 +0900 Subject: Now includes "string.h" by itself for libpng16. (Thanks to Petr) --- ChangeLog | 4 ++++ qrenc.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 03ec5626f2..9246b79c61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013.02.16 Kentaro FUKUCHI + * qrenc.c: + - Now it includes "string.h" by itself for libpng16. (Thanks to Petr) + 2012.11.30 Kentaro FUKUCHI * qrencode.h - Doxygen documents improved. diff --git a/qrenc.c b/qrenc.c index 3fa13b6d2a..0c3239e5d4 100644 --- a/qrenc.c +++ b/qrenc.c @@ -26,6 +26,7 @@ #endif #include #include +#include #include #include -- cgit 0.0.5-2-1-g0f52 From ac7773c94874c2334b159228a18db8a2fcc23a17 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 17 Feb 2013 15:15:50 +0900 Subject: Preparing for 3.4.2 release. --- ChangeLog | 5 +++++ NEWS | 8 ++++++++ README | 2 +- configure.ac | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9246b79c61..4caa390485 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013.02.16 Kentaro FUKUCHI + [3.4, master] + * configure.ac, README, NEWS: + - Bumped version to 3.4.2. + 2013.02.16 Kentaro FUKUCHI * qrenc.c: - Now it includes "string.h" by itself for libpng16. (Thanks to Petr) diff --git a/NEWS b/NEWS index ad17098293..ec4855cbb7 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,14 @@ libqrencode NEWS - Overview of changes ====================================== +Version 3.4.2 (2013.2.17) +------------------------- +* Bug fix release. (issue #24 and #25) (Thanks to chisj, vlad417 and Petr) + +Release Note: +Micro QR Code encoder had a bug that caused incorrect output. Now the bug has +been fixed. + Version 3.4.1 (2012.10.17) -------------------------- * Bug fix release. diff --git a/README b/README index 8153c4640d..8ea1926175 100644 --- a/README +++ b/README @@ -137,5 +137,5 @@ Lennart Poettering (mezcalero) - Improved text art patch Yann Droneaud - Improved input validation patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, -Fred Steinhaeuser, Terry Burton, chisj, vlad417 +Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr - bug report / suggestion diff --git a/configure.ac b/configure.ac index b9d725777e..6db600b423 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_INIT(QRencode) MAJOR_VERSION=3 MINOR_VERSION=4 -MICRO_VERSION=1 +MICRO_VERSION=2 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 0869dbea908f3bc2fdd9cdb78edd485616611f6d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 17 Feb 2013 15:17:41 +0900 Subject: Bumped version to 3.4.2. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 8ea1926175..6ee33363ab 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.4.1 - QR Code encoding library +libqrencode 3.4.2 - QR Code encoding library GENERAL INFORMATION =================== -- cgit 0.0.5-2-1-g0f52 From 82d797c0191d80fa303c264f38edf2efa7b630ea Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 26 Feb 2013 09:58:17 +0900 Subject: Applied Viona's bug fix patch. (Thanks to Viona) --- ChangeLog | 7 +++++++ split.c | 1 + tests/test_split.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4caa390485..07b2c92209 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013.02.26 Kentaro FUKUCHI + * split.c, tests/test_split.c: + - Applied Viona's bug fix patch. (Thanks to Viona) + - Additional switching cost between AN and Num mode has been included + correctly. + - New test case has been added. + 2013.02.16 Kentaro FUKUCHI [3.4, master] * configure.ac, README, NEWS: diff --git a/split.c b/split.c index f53dce5dc4..42ba333702 100644 --- a/split.c +++ b/split.c @@ -140,6 +140,7 @@ static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint) } dif = QRinput_estimateBitsModeAn(p - string) /* + 4 + la */ + QRinput_estimateBitsModeNum(q - p) + 4 + ln + + (isalnum(*q)?(4 + ln):0) - QRinput_estimateBitsModeAn(q - string) /* - 4 - la */; if(dif < 0) { break; diff --git a/tests/test_split.c b/tests/test_split.c index 10c9e3cd69..5364c11aa9 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -394,6 +394,39 @@ void test_splitNum8(void) QRinput_free(input); } +void test_splitAnNAn(void) +{ + QRinput *input1, *input2, *input3; + int s1, s2, s3; + char *strall = "326A80A9C5004C0875571F8B71C311F2F86"; + char *str1 = "326A80A9C5004C"; + char *str2 = "0875571"; + char *str3 = "F8B71C311F2F86"; + + testStart("Split test: switching from An to Num cost test"); + input1 = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(strall, input1, QR_MODE_8, 0); + + input2 = QRinput_new(); + QRinput_append(input2, QR_MODE_AN, 35, (unsigned char *)strall); + + input3 = QRinput_new(); + QRinput_append(input3, QR_MODE_AN, 14, (unsigned char *)str1); + QRinput_append(input3, QR_MODE_NUM, 7, (unsigned char *)str2); + QRinput_append(input3, QR_MODE_AN, 14, (unsigned char *)str3); + + s1 = inputSize(input1); + s2 = inputSize(input2); + s3 = inputSize(input3); + + assert_equal(s1, s2, "Incorrect split"); + assert_exp(s2 < s3, "Incorrect split"); + testFinish(); + QRinput_free(input1); + QRinput_free(input2); + QRinput_free(input3); +} + int main(void) { test_split1(); @@ -407,6 +440,7 @@ int main(void) test_split3c(); test_toupper(); test_splitNum8(); + test_splitAnNAn(); report(); -- cgit 0.0.5-2-1-g0f52 From dde971708820ed8b4e6d3cc492b26e3363e252cf Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 26 Feb 2013 11:53:54 +0900 Subject: More bug fixes related to switching cost estimation. --- ChangeLog | 2 ++ split.c | 16 ++++++++- tests/test_split.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 120 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07b2c92209..beed6f7eed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ - Applied Viona's bug fix patch. (Thanks to Viona) - Additional switching cost between AN and Num mode has been included correctly. + - Additional switching cost between 8 and AN/Num mode has been included + correctly. - New test case has been added. 2013.02.16 Kentaro FUKUCHI diff --git a/split.c b/split.c index 42ba333702..a2cb0e0e3f 100644 --- a/split.c +++ b/split.c @@ -193,10 +193,12 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) int ret; int run; int dif; - int la, ln; + int la, ln, l8; + int swcost; la = QRspec_lengthIndicator(QR_MODE_AN, input->version); ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version); + l8 = QRspec_lengthIndicator(QR_MODE_8, input->version); p = string + 1; while(*p != '\0') { @@ -209,8 +211,14 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) while(isdigit(*q)) { q++; } + if(Split_identifyMode(q, hint) == QR_MODE_8) { + swcost = 4 + l8; + } else { + swcost = 0; + } dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */ + QRinput_estimateBitsModeNum(q - p) + 4 + ln + + swcost - QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */; if(dif < 0) { break; @@ -222,8 +230,14 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) while(isalnum(*q)) { q++; } + if(Split_identifyMode(q, hint) == QR_MODE_8) { + swcost = 4 + l8; + } else { + swcost = 0; + } dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */ + QRinput_estimateBitsModeAn(q - p) + 4 + la + + swcost - QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */; if(dif < 0) { break; diff --git a/tests/test_split.c b/tests/test_split.c index 5364c11aa9..0570451a71 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -420,7 +420,106 @@ void test_splitAnNAn(void) s3 = inputSize(input3); assert_equal(s1, s2, "Incorrect split"); - assert_exp(s2 < s3, "Incorrect split"); + assert_exp(s2 < s3, "Incorrect estimation"); + testFinish(); + QRinput_free(input1); + QRinput_free(input2); + QRinput_free(input3); +} + +void test_splitAn8An(void) +{ + QRinput *input1, *input2, *input3; + int s1, s2, s3; + char *strall = "ABCDabcdefABCD"; + char *str1 = "ABCD"; + char *str2 = "abcdef"; + char *str3 = "ABCD"; + + testStart("Split test: switching from 8 to An cost test"); + input1 = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1); + + input2 = QRinput_new(); + QRinput_append(input2, QR_MODE_8, 14, (unsigned char *)strall); + + input3 = QRinput_new(); + QRinput_append(input3, QR_MODE_AN, 4, (unsigned char *)str1); + QRinput_append(input3, QR_MODE_8, 6, (unsigned char *)str2); + QRinput_append(input3, QR_MODE_AN, 4, (unsigned char *)str3); + + s1 = inputSize(input1); + s2 = inputSize(input2); + s3 = inputSize(input3); + + assert_equal(s1, s2, "Incorrect split"); + assert_exp(s2 < s3, "Incorrect estimation"); + testFinish(); + QRinput_free(input1); + QRinput_free(input2); + QRinput_free(input3); +} + +void test_split8An8(void) +{ + QRinput *input1, *input2, *input3; + int s1, s2, s3; + char *strall = "abcABCDEFGHabc"; + char *str1 = "abc"; + char *str2 = "ABCDEFGH"; + char *str3 = "abc"; + + testStart("Split test: switching from 8-An-8 cost test"); + input1 = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1); + + input2 = QRinput_new(); + QRinput_append(input2, QR_MODE_8, 14, (unsigned char *)strall); + + input3 = QRinput_new(); + QRinput_append(input3, QR_MODE_8, 3, (unsigned char *)str1); + QRinput_append(input3, QR_MODE_AN, 8, (unsigned char *)str2); + QRinput_append(input3, QR_MODE_8, 3, (unsigned char *)str3); + + s1 = inputSize(input1); + s2 = inputSize(input2); + s3 = inputSize(input3); + + assert_equal(s1, s2, "Incorrect split"); + assert_exp(s2 < s3, "Incorrect estimation"); + testFinish(); + QRinput_free(input1); + QRinput_free(input2); + QRinput_free(input3); +} + +void test_split8N8(void) +{ + QRinput *input1, *input2, *input3; + int s1, s2, s3; + char *strall = "abc1234abc"; + char *str1 = "abc"; + char *str2 = "1234"; + char *str3 = "abc"; + + testStart("Split test: switching from 8-N-8 cost test"); + input1 = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1); + + input2 = QRinput_new(); + QRinput_append(input2, QR_MODE_8, 10, (unsigned char *)strall); + + input3 = QRinput_new(); + QRinput_append(input3, QR_MODE_8, 3, (unsigned char *)str1); + QRinput_append(input3, QR_MODE_NUM, 4, (unsigned char *)str2); + QRinput_append(input3, QR_MODE_8, 3, (unsigned char *)str3); + + s1 = inputSize(input1); + s2 = inputSize(input2); + s3 = inputSize(input3); + + assert_equal(s1, s2, "Incorrect split"); + assert_exp(s2 < s3, "Incorrect estimation"); testFinish(); QRinput_free(input1); QRinput_free(input2); @@ -441,6 +540,9 @@ int main(void) test_toupper(); test_splitNum8(); test_splitAnNAn(); + test_splitAn8An(); + test_split8An8(); + test_split8N8(); report(); -- cgit 0.0.5-2-1-g0f52 From 085db190f16b46d1d08bf0aa015b1961bc3d8bed Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 27 Feb 2013 18:50:20 +0900 Subject: Messages corrected. --- tests/test_split.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_split.c b/tests/test_split.c index 0570451a71..1a43760a45 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -403,7 +403,7 @@ void test_splitAnNAn(void) char *str2 = "0875571"; char *str3 = "F8B71C311F2F86"; - testStart("Split test: switching from An to Num cost test"); + testStart("Split test: An-N-An switching cost test"); input1 = QRinput_new2(0, QR_ECLEVEL_L); Split_splitStringToQRinput(strall, input1, QR_MODE_8, 0); @@ -436,7 +436,7 @@ void test_splitAn8An(void) char *str2 = "abcdef"; char *str3 = "ABCD"; - testStart("Split test: switching from 8 to An cost test"); + testStart("Split test: An-8-An switching cost test"); input1 = QRinput_new2(0, QR_ECLEVEL_L); Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1); @@ -469,7 +469,7 @@ void test_split8An8(void) char *str2 = "ABCDEFGH"; char *str3 = "abc"; - testStart("Split test: switching from 8-An-8 cost test"); + testStart("Split test: 8-An-8 switching cost test"); input1 = QRinput_new2(0, QR_ECLEVEL_L); Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1); @@ -502,7 +502,7 @@ void test_split8N8(void) char *str2 = "1234"; char *str3 = "abc"; - testStart("Split test: switching from 8-N-8 cost test"); + testStart("Split test: 8-N-8 switching cost test"); input1 = QRinput_new2(0, QR_ECLEVEL_L); Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1); -- cgit 0.0.5-2-1-g0f52 From 44bbd4c1b47b88d503216c1f4ad44ccf12abbcf3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 27 Feb 2013 18:50:31 +0900 Subject: Documents updated. --- NEWS | 8 +++++--- README | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index ec4855cbb7..ae1b0f18c0 100644 --- a/NEWS +++ b/NEWS @@ -3,11 +3,13 @@ libqrencode NEWS - Overview of changes Version 3.4.2 (2013.2.17) ------------------------- -* Bug fix release. (issue #24 and #25) (Thanks to chisj, vlad417 and Petr) +* Bug fix release. (Thanks to chisj, vlad417, Petr and Viona) + Release Note: -Micro QR Code encoder had a bug that caused incorrect output. Now the bug has -been fixed. +Micro QR Code encoder had a bug that caused incorrect output (issue #25). Now +the bug has been fixed. Memory leak bug (#24) and insufficient string splitting +bug have been fixed. Version 3.4.1 (2012.10.17) -------------------------- diff --git a/README b/README index 6ee33363ab..7c435f89fc 100644 --- a/README +++ b/README @@ -134,8 +134,9 @@ Ralf Ertzinger - ASCII support patch Yutaka Niibe (gniibe) - various bug fix patches Dan Storm (Repox) - SVG support patch Lennart Poettering (mezcalero) - - Improved text art patch -Yann Droneaud - Improved input validation patch + - improved text art patch +Yann Droneaud - improved input validation patch +Viona - bug fix patch for string splitting Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From c6f119976a3938b36fc14fec18b42586519085b2 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 1 Mar 2013 11:36:12 +0900 Subject: Preparing for 3.4.2. --- ChangeLog | 4 ++++ NEWS | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index beed6f7eed..6cc0d02275 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013.03.01 Kentaro FUKUCHI + * README, NEWS: + - Documentation update. + 2013.02.26 Kentaro FUKUCHI * split.c, tests/test_split.c: - Applied Viona's bug fix patch. (Thanks to Viona) diff --git a/NEWS b/NEWS index ae1b0f18c0..787bbef125 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,8 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.4.2 (2013.2.17) -------------------------- +Version 3.4.2 (2013.3.1) +------------------------ * Bug fix release. (Thanks to chisj, vlad417, Petr and Viona) -- cgit 0.0.5-2-1-g0f52 From cc46df5b853a9959022f469c4b3b11fdb376ca9d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 1 Mar 2013 18:13:20 +0900 Subject: Version 3.4.2 has been released. --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 6cc0d02275..5a2118ebbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2013.03.01 Kentaro FUKUCHI * README, NEWS: - Documentation update. + * Version 3.4.2 has been released. 2013.02.26 Kentaro FUKUCHI * split.c, tests/test_split.c: -- cgit 0.0.5-2-1-g0f52 From d5dbf14a5aa986a799f3bdbc7f2fbec6efb5e57e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 26 Mar 2013 09:16:59 +0900 Subject: Memory leak bug has been fixed. (Thanks to Hassan Hajji) --- ChangeLog | 4 ++++ README | 2 +- qrenc.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5a2118ebbc..3874c9ede0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013.03.26 Kentaro FUKUCHI + * qrenc.c: + - Memory leak bug has been fixed. (Thanks to Hassan Hajji) + 2013.03.01 Kentaro FUKUCHI * README, NEWS: - Documentation update. diff --git a/README b/README index 7c435f89fc..72ae81f794 100644 --- a/README +++ b/README @@ -138,5 +138,5 @@ Lennart Poettering (mezcalero) Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, -Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr +Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index 0c3239e5d4..41aaccade8 100644 --- a/qrenc.c +++ b/qrenc.c @@ -350,6 +350,7 @@ static int writePNG(QRcode *qrcode, const char *outfile) fclose(fp); free(row); + free(palette); return 0; } -- cgit 0.0.5-2-1-g0f52 From dbc719303749e302d755dc88fd64f977fb386282 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 26 Mar 2013 10:36:58 +0900 Subject: Buffer overrun bug has been fixed / Code cleanups. --- ChangeLog | 2 ++ qrenc.c | 33 ++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3874c9ede0..3e9a83b272 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2013.03.26 Kentaro FUKUCHI * qrenc.c: - Memory leak bug has been fixed. (Thanks to Hassan Hajji) + - Buffer overrun bug has been fixed. + - Code cleanups. 2013.03.01 Kentaro FUKUCHI * README, NEWS: diff --git a/qrenc.c b/qrenc.c index 41aaccade8..05a927cc07 100644 --- a/qrenc.c +++ b/qrenc.c @@ -285,6 +285,10 @@ static int writePNG(QRcode *qrcode, const char *outfile) } palette = (png_colorp) malloc(sizeof(png_color) * 2); + if(palette == NULL) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(EXIT_FAILURE); + } palette[0].red = fg_color[0]; palette[0].green = fg_color[1]; palette[0].blue = fg_color[2]; @@ -627,7 +631,6 @@ static int writeUTF8(QRcode *qrcode, const char *outfile, int use_ansi) FILE *fp; int x, y; int realwidth; - unsigned char *p; const char *white, *reset; if (use_ansi){ @@ -646,11 +649,10 @@ static int writeUTF8(QRcode *qrcode, const char *outfile, int use_ansi) writeUTF8_margin(fp, realwidth, white, reset, use_ansi); /* data */ - p = qrcode->data; for(y = 0; y < qrcode->width; y += 2) { unsigned char *row1, *row2; - row1 = p + y*qrcode->width; - row2 = p + y*qrcode->width + qrcode->width; + row1 = qrcode->data + y*qrcode->width; + row2 = row1 + qrcode->width; fputs(white, fp); @@ -658,14 +660,19 @@ static int writeUTF8(QRcode *qrcode, const char *outfile, int use_ansi) fputs("\342\226\210", fp); for (x = 0; x < qrcode->width; x++) { - if ((*(row1 + x) & 1) && (*(row2 + x) & 1)) - fputc(' ', fp); - else if (*(row1 + x) & 1) - fputs("\342\226\204", fp); - else if (*(row2 + x) & 1) - fputs("\342\226\200", fp); - else - fputs("\342\226\210", fp); + if(row1[x] & 1) { + if(y < qrcode->width - 1 && row2[x] & 1) { + fputc(' ', fp); + } else { + fputs("\342\226\204", fp); + } + } else { + if(y < qrcode->width - 1 && row2[x] & 1) { + fputs("\342\226\200", fp); + } else { + fputs("\342\226\210", fp); + } + } } for (x = 0; x < margin; x++) @@ -718,7 +725,7 @@ static int writeASCII(QRcode *qrcode, const char *outfile, int invert) fp = openFile(outfile); realwidth = (qrcode->width + margin * 2) * 2; - buffer_s = realwidth + 1; + buffer_s = realwidth + 2; buffer = (char *)malloc( buffer_s ); if(buffer == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); -- cgit 0.0.5-2-1-g0f52 From f3d5ecc40e9aa4b30f89796fa65b8134bb7d2999 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 30 Mar 2013 12:30:10 +0900 Subject: Renamed a variable ("index") to avoid compile-time warning. (Thanks to Emmanuel Blot). Range check improved. --- ChangeLog | 6 ++++++ qrinput.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e9a83b272..332e1a0985 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013.03.30 Kentaro FUKUCHI + * qrinput.c: + - Renamed a variable ("index") to avoid compile-time warning. (Thanks to + Emmanuel Blot) + - Range check improved. + 2013.03.26 Kentaro FUKUCHI * qrenc.c: - Memory leak bug has been fixed. (Thanks to Hassan Hajji) diff --git a/qrinput.c b/qrinput.c index 2533d08448..29ea23dbbb 100644 --- a/qrinput.c +++ b/qrinput.c @@ -237,14 +237,14 @@ int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned c * Insert a structured-append header to the head of the input data. * @param input input data. * @param size number of structured symbols. - * @param index index number of the symbol. (1 <= index <= size) + * @param number index number of the symbol. (1 <= number <= size) * @param parity parity among input data. (NOTE: each symbol of a set of structured symbols has the same parity data) * @retval 0 success. * @retval -1 error occurred and errno is set to indeicate the error. See Execptions for the details. * @throw EINVAL invalid parameter. * @throw ENOMEM unable to allocate memory. */ -__STATIC int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity) +__STATIC int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int number, unsigned char parity) { QRinput_List *entry; unsigned char buf[3]; @@ -253,13 +253,13 @@ __STATIC int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int errno = EINVAL; return -1; } - if(index <= 0 || index > MAX_STRUCTURED_SYMBOLS) { + if(number <= 0 || number > size) { errno = EINVAL; return -1; } buf[0] = (unsigned char)size; - buf[1] = (unsigned char)index; + buf[1] = (unsigned char)number; buf[2] = parity; entry = QRinput_List_newEntry(QR_MODE_STRUCTURE, 3, buf); if(entry == NULL) { -- cgit 0.0.5-2-1-g0f52 From 2cafb7eb0a232d3186ecfb9d40c6e839088b1c35 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 30 Mar 2013 12:44:42 +0900 Subject: bug fix. --- ChangeLog | 2 ++ autogen.sh | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 332e1a0985..306b568c8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ - Renamed a variable ("index") to avoid compile-time warning. (Thanks to Emmanuel Blot) - Range check improved. + * autogen.sh: + - bug fix.(Thanks to Emmanuel Blot) 2013.03.26 Kentaro FUKUCHI * qrenc.c: diff --git a/autogen.sh b/autogen.sh index d1b1955707..b90f44f370 100755 --- a/autogen.sh +++ b/autogen.sh @@ -8,12 +8,13 @@ else LIBTOOLIZE=libtoolize fi +ACLOCAL_OPT="" if [ -d /usr/local/share/aclocal ]; then - ACLOCAL_DIR=/usr/local/share/aclocal + ACLOCAL_OPT="-I /usr/local/share/aclocal" elif [ -d /opt/local/share/aclocal ]; then - ACLOCAL_DIR=/opt/local/share/aclocal + ACLOCAL_OPT="-I /opt/local/share/aclocal" elif [ -d /usr/share/aclocal ]; then - ACLOCAL_DIR=/usr/share/aclocal + ACLOCAL_OPT="-I /usr/share/aclocal" fi if [ ! -d use ]; then @@ -22,7 +23,7 @@ fi autoheader -aclocal -I $ACLOCAL_DIR +aclocal $ACLOCAL_OPT $LIBTOOLIZE --automake --copy automake --add-missing --copy -- cgit 0.0.5-2-1-g0f52 From 1473fee13c2ad5502ef2789f13d2d4f6e8923249 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Mon, 17 Jun 2013 11:16:29 +0200 Subject: Added command line option -r -rle. This is used to enable run-length encoding for svg output. Removed run-length encoding by default in function writeSVG. --- qrenc.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/qrenc.c b/qrenc.c index 0c3239e5d4..f201ebd6b3 100644 --- a/qrenc.c +++ b/qrenc.c @@ -41,6 +41,7 @@ static int size = 3; static int margin = -1; static int dpi = 72; static int structured = 0; +static int rle = 0; static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; @@ -75,6 +76,7 @@ static const struct option options[] = { {"casesensitive", no_argument , NULL, 'c'}, {"ignorecase" , no_argument , NULL, 'i'}, {"8bit" , no_argument , NULL, '8'}, + {"rle" , no_argument , NULL, 'r'}, {"micro" , no_argument , NULL, 'M'}, {"foreground" , required_argument, NULL, 'f'}, {"background" , required_argument, NULL, 'b'}, @@ -82,7 +84,7 @@ static const struct option options[] = { {NULL, 0, NULL, 0} }; -static char *optstring = "ho:l:s:v:m:d:t:Skci8MV"; +static char *optstring = "ho:l:s:v:m:d:t:Skci8rMV"; static void usage(int help, int longopt) { @@ -123,6 +125,7 @@ static void usage(int help, int longopt) " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" " -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" +" -r, --rle enable run-length encoding for svg.\n\n" " -M, --micro encode in a Micro QR Code. (experimental)\n\n" " --foreground=RRGGBB[AA]\n" " --background=RRGGBB[AA]\n" @@ -157,6 +160,7 @@ static void usage(int help, int longopt) " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" " -i ignore case distinctions and use only upper-case characters.\n" " -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n" +" -r, --rle enable run-length encoding for svg.\n\n" " -M encode in a Micro QR Code.\n" " --foreground=RRGGBB[AA]\n" " --background=RRGGBB[AA]\n" @@ -475,25 +479,35 @@ static int writeSVG( QRcode *qrcode, const char *outfile ) for(y=0; ywidth; y++) { row = (p+(y*qrcode->width)); - /* simple RLE */ - pen = 0; - x0 = 0; - for(x=0; xwidth; x++) { - if( !pen ) { - pen = *(row+x)&0x1; - x0 = x; - } else { - if(!(*(row+x)&0x1)) { - writeSVG_writeRect(fp, x0 + margin, y + margin, x-x0, fg, fg_opacity); - pen = 0; + if( !rle ) { + /* no RLE */ + for(x=0; xwidth; x++) { + if(*(row+x)&0x1) { + writeSVG_writeRect(fp, margin + x, + margin + y, 1, + fg, fg_opacity); } } - } - if( pen ) { - writeSVG_writeRect(fp, x0 + margin, y + margin, qrcode->width - x0, fg, fg_opacity); + } else { + /* simple RLE */ + pen = 0; + x0 = 0; + for(x=0; xwidth; x++) { + if( !pen ) { + pen = *(row+x)&0x1; + x0 = x; + } else { + if(!(*(row+x)&0x1)) { + writeSVG_writeRect(fp, x0 + margin, y + margin, x-x0, fg, fg_opacity); + pen = 0; + } + } + } + if( pen ) { + writeSVG_writeRect(fp, x0 + margin, y + margin, qrcode->width - x0, fg, fg_opacity); + } } } - /* Close QR data viewbox */ fputs( "\t\t\n", fp ); @@ -1054,6 +1068,9 @@ int main(int argc, char **argv) case '8': eightbit = 1; break; + case 'r': + rle = 1; + break; case 'M': micro = 1; break; -- cgit 0.0.5-2-1-g0f52 From 11ac32eb6f3089baa2059cc528ac5278f21b791d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 19 Jun 2013 00:23:23 +0900 Subject: Removed magic comment. --- qrenc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 05a927cc07..86b618c2e1 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/ - /** * qrencode - QR Code encoder * -- cgit 0.0.5-2-1-g0f52 From 22342794d463a1e6f8584756f25691e814656075 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 19 Jun 2013 00:25:06 +0900 Subject: Added an acknowledgement to Emmanuel Blot. --- README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README b/README index 72ae81f794..ed24bef869 100644 --- a/README +++ b/README @@ -138,5 +138,6 @@ Lennart Poettering (mezcalero) Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, -Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji +Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, +Emmanuel Blot - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 656987b26ec02335fd508931821ff5c6aba14ce5 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 19 Jun 2013 01:09:48 +0900 Subject: Removed '-r' option (short for '--rle'). --- qrenc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qrenc.c b/qrenc.c index 9165f0d355..b90bd22ec3 100644 --- a/qrenc.c +++ b/qrenc.c @@ -74,7 +74,7 @@ static const struct option options[] = { {"casesensitive", no_argument , NULL, 'c'}, {"ignorecase" , no_argument , NULL, 'i'}, {"8bit" , no_argument , NULL, '8'}, - {"rle" , no_argument , NULL, 'r'}, + {"rle" , no_argument , &rle, 1}, {"micro" , no_argument , NULL, 'M'}, {"foreground" , required_argument, NULL, 'f'}, {"background" , required_argument, NULL, 'b'}, @@ -123,10 +123,10 @@ static void usage(int help, int longopt) " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" " -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" -" -r, --rle enable run-length encoding for svg.\n\n" +" --rle enable run-length encoding for SVG.\n\n" " -M, --micro encode in a Micro QR Code. (experimental)\n\n" -" --foreground=RRGGBB[AA]\n" -" --background=RRGGBB[AA]\n" +" --foreground=RRGGBB[AA]\n" +" --background=RRGGBB[AA]\n" " specify foreground/background color in hexadecimal notation.\n" " 6-digit (RGB) or 8-digit (RGBA) form are supported.\n" " Color output support available only in PNG and SVG.\n" @@ -158,7 +158,6 @@ static void usage(int help, int longopt) " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" " -i ignore case distinctions and use only upper-case characters.\n" " -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n" -" -r, --rle enable run-length encoding for svg.\n\n" " -M encode in a Micro QR Code.\n" " --foreground=RRGGBB[AA]\n" " --background=RRGGBB[AA]\n" @@ -1096,6 +1095,8 @@ int main(int argc, char **argv) usage(0, 0); exit(EXIT_SUCCESS); break; + case 0: + break; default: fprintf(stderr, "Try `qrencode --help' for more information.\n"); exit(EXIT_FAILURE); -- cgit 0.0.5-2-1-g0f52 From c872d88811f2d185628336c2602c0d9ca81b84a9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 19 Jun 2013 01:10:25 +0900 Subject: Added an acknowledgement to Daniel. (#29) --- ChangeLog | 7 +++++++ README | 1 + 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 306b568c8e..8e9590f1db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013.06.17 Kentaro FUKUCHI + * qrenc.c: + - Merged pull request #29. (Thanks to Daniel Dörrhöfer) + - Run length encoding has been made non-default. + - New option "--rle" has been instroduced to enable run length encoding + for SVG format. + 2013.03.30 Kentaro FUKUCHI * qrinput.c: - Renamed a variable ("index") to avoid compile-time warning. (Thanks to diff --git a/README b/README index ed24bef869..4cb3d24e03 100644 --- a/README +++ b/README @@ -137,6 +137,7 @@ Lennart Poettering (mezcalero) - improved text art patch Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting +Daniel Dörrhöfer - RLE option Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot -- cgit 0.0.5-2-1-g0f52 From cb7f5de21ddbd76ab23296df9609e9379137554c Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Tue, 18 Jun 2013 22:18:39 +0200 Subject: Removed the "r" in *optstring. short version -r as an option removed. --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index b90bd22ec3..50806b1b6e 100644 --- a/qrenc.c +++ b/qrenc.c @@ -82,7 +82,7 @@ static const struct option options[] = { {NULL, 0, NULL, 0} }; -static char *optstring = "ho:l:s:v:m:d:t:Skci8rMV"; +static char *optstring = "ho:l:s:v:m:d:t:Skci8MV"; static void usage(int help, int longopt) { -- cgit 0.0.5-2-1-g0f52 From fd06c8abcf418e3e6476df38e058358218135363 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 16 Jul 2013 11:09:16 +0900 Subject: Missing breaks in switch. (Thanks to ßlúèÇhîp) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 6 ++++++ README | 2 +- qrenc.c | 1 + qrinput.c | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e9590f1db..e888e9d8cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013.07.16 Kentaro FUKUCHI + * qrenc.c: + - missing break in switch. (Thanks to ßlúèÇhîp) + * qrinput.c: + - missing/redundant breaks in switch. + 2013.06.17 Kentaro FUKUCHI * qrenc.c: - Merged pull request #29. (Thanks to Daniel Dörrhöfer) diff --git a/README b/README index 4cb3d24e03..a878297589 100644 --- a/README +++ b/README @@ -140,5 +140,5 @@ Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, -Emmanuel Blot +Emmanuel Blot, ßlúèÇhîp - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index b90bd22ec3..61822920f7 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1061,6 +1061,7 @@ int main(int argc, char **argv) break; case 'S': structured = 1; + break; case 'k': hint = QR_MODE_KANJI; break; diff --git a/qrinput.c b/qrinput.c index 29ea23dbbb..b59dd1b3ab 100644 --- a/qrinput.c +++ b/qrinput.c @@ -928,7 +928,6 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version break; case QR_MODE_FNC1FIRST: return MODE_INDICATOR_SIZE; - break; case QR_MODE_FNC1SECOND: return MODE_INDICATOR_SIZE + 8; default: @@ -1103,6 +1102,7 @@ static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr) break; case QR_MODE_FNC1SECOND: ret = QRinput_encodeModeFNC1Second(entry, version); + break; default: break; } -- cgit 0.0.5-2-1-g0f52 From 2abc75117f0830b11b57be26fcf1a375a189f7fd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 29 Jul 2013 18:24:29 +0900 Subject: Bumpbed verstion tio 3.4.3. --- ChangeLog | 5 +++++ NEWS | 4 ++++ README | 2 +- configure.ac | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 306b568c8e..f18feccd1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013.07.29 Kentaro FUKUCHI + [3.4] + * configure.ac, README, NEWS: + - Bumped version to 3.4.3. + 2013.03.30 Kentaro FUKUCHI * qrinput.c: - Renamed a variable ("index") to avoid compile-time warning. (Thanks to diff --git a/NEWS b/NEWS index 787bbef125..eb942a0d47 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ libqrencode NEWS - Overview of changes ====================================== +Version 3.4.3 (2013.7.30) +------------------------ +* Bug fix release. (Thanks to Emmanuel Blot) + Version 3.4.2 (2013.3.1) ------------------------ * Bug fix release. (Thanks to chisj, vlad417, Petr and Viona) diff --git a/README b/README index ed24bef869..0ca636d05e 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.4.2 - QR Code encoding library +libqrencode 3.4.3 - QR Code encoding library GENERAL INFORMATION =================== diff --git a/configure.ac b/configure.ac index 6db600b423..5b46a20b71 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_INIT(QRencode) MAJOR_VERSION=3 MINOR_VERSION=4 -MICRO_VERSION=2 +MICRO_VERSION=3 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) -- cgit 0.0.5-2-1-g0f52 From 3e6c77c1ea3e6fa123e4964a26b8322e7fb2d9fd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 30 Jul 2013 04:54:04 +0900 Subject: Release note has been updated. --- NEWS | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index eb942a0d47..320f1130c9 100644 --- a/NEWS +++ b/NEWS @@ -3,13 +3,23 @@ libqrencode NEWS - Overview of changes Version 3.4.3 (2013.7.30) ------------------------ -* Bug fix release. (Thanks to Emmanuel Blot) +* New option "--rle" has been added to the command line tool (Thanks to Daniel + Dörrhöfer) +* Bug fix release. (Thanks to Emmanuel Blot, ßlúèÇhîp) + +Release Note: +This release contains a couple of bug fixes and a new minor feature of the +command line tool. There is no change in the library. + +Run Length Encoding (RLE) for SVG output decreases the size of the output file, +but it makes complicated to edit the image by SVG editors. A newly introduced +command line option "--rle" enables RLE. RLE will not be applied if it is not +given. Version 3.4.2 (2013.3.1) ------------------------ * Bug fix release. (Thanks to chisj, vlad417, Petr and Viona) - Release Note: Micro QR Code encoder had a bug that caused incorrect output (issue #25). Now the bug has been fixed. Memory leak bug (#24) and insufficient string splitting -- cgit 0.0.5-2-1-g0f52 From 34824e1e2911a5177a440f62bf2ae85be4da2990 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 11 Aug 2013 15:26:32 +0900 Subject: Typo fix. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 320f1130c9..5d8e09bcc9 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,7 @@ Version 3.4.3 (2013.7.30) ------------------------ * New option "--rle" has been added to the command line tool (Thanks to Daniel Dörrhöfer) -* Bug fix release. (Thanks to Emmanuel Blot, ßlúèÇhîp) +* Bug fix release. (Thanks to Emmanuel Blot and ßlúèÇhîp) Release Note: This release contains a couple of bug fixes and a new minor feature of the -- cgit 0.0.5-2-1-g0f52 From 7b15cd44a9668d6aca789b039b6d8374f5418a03 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 11 Aug 2013 15:32:19 +0900 Subject: Added an acknowledgement record. --- NEWS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 5d8e09bcc9..58e945fcdd 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,11 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.4.3 (2013.7.30) +Version 3.4.3 (2013.8.11) ------------------------ * New option "--rle" has been added to the command line tool (Thanks to Daniel Dörrhöfer) -* Bug fix release. (Thanks to Emmanuel Blot and ßlúèÇhîp) +* Bug fix release. (Thanks to Hassan Hajji, Emmanuel Blot, and ßlúèÇhîp) Release Note: This release contains a couple of bug fixes and a new minor feature of the -- cgit 0.0.5-2-1-g0f52 From cfa43209281c13c859790590b217ec90fd801cd3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 11 Aug 2013 15:35:07 +0900 Subject: Copyright year updatd. --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index b789fc31a6..2a8eba3630 100644 --- a/qrenc.c +++ b/qrenc.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code encoding tool - * Copyright (C) 2006-2012 Kentaro Fukuchi + * Copyright (C) 2006-2013 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public -- cgit 0.0.5-2-1-g0f52 From 055f441af7eaa38cc794fe5a2e5bb236bbd54661 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 12 Aug 2013 11:05:51 +0900 Subject: Documents updated. --- ChangeLog | 2 +- NEWS | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0998fbfaaf..bf15228106 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ * qrenc.c: - missing break in switch. (Thanks to ßlúèÇhîp) * qrinput.c: - - missing/redundant breaks in switch. + - missing/redundant breaks in some switch statements. 2013.06.17 Kentaro FUKUCHI * qrenc.c: diff --git a/NEWS b/NEWS index 58e945fcdd..de26e0178b 100644 --- a/NEWS +++ b/NEWS @@ -1,15 +1,15 @@ libqrencode NEWS - Overview of changes ====================================== -Version 3.4.3 (2013.8.11) +Version 3.4.3 (2013.8.12) ------------------------ * New option "--rle" has been added to the command line tool (Thanks to Daniel Dörrhöfer) -* Bug fix release. (Thanks to Hassan Hajji, Emmanuel Blot, and ßlúèÇhîp) +* Bug fixes. (Thanks to Hassan Hajji, Emmanuel Blot, and ßlúèÇhîp) Release Note: This release contains a couple of bug fixes and a new minor feature of the -command line tool. There is no change in the library. +command line tool. Some minor bugs in the library have been fixed. Run Length Encoding (RLE) for SVG output decreases the size of the output file, but it makes complicated to edit the image by SVG editors. A newly introduced -- cgit 0.0.5-2-1-g0f52 From f9f6034915b550fc65ae085622839b1e7dbef4ea Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 15 Aug 2013 10:28:54 +0900 Subject: Reed-Solomon code routine has been completely rewritten. --- ChangeLog | 8 ++ Makefile.am | 2 +- qrencode.c | 25 +--- rscode.c | 327 -------------------------------------------------- rscode.h | 41 ------- rsecc.c | 131 ++++++++++++++++++++ rsecc.h | 28 +++++ tests/Makefile.am | 4 +- tests/rscode.c | 274 ++++++++++++++++++++++++++++++++++++++++++ tests/rscode.h | 40 ++++++ tests/test_qrencode.c | 2 +- tests/test_rs.c | 88 +++++++++++++- 12 files changed, 575 insertions(+), 395 deletions(-) delete mode 100644 rscode.c delete mode 100644 rscode.h create mode 100644 rsecc.c create mode 100644 rsecc.h create mode 100644 tests/rscode.c create mode 100644 tests/rscode.h diff --git a/ChangeLog b/ChangeLog index bf15228106..dc0aa55792 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013.08.15 Kentaro FUKUCHI + * rsecc.[ch], rscode.[ch], Makefile.am, qrencode.c: + - Reed-Solomon error correction code has been completely rewritten. + - Phil Karn's code has been removed (moved to tests). + * tests/test_rs.c, tests/test_qrencode.c, tests/rscode.[ch], tests/Makefile.am: + - Test codes related to ECC have been updated. + - Phil Karn's code has been moved to tests, just for test purpose. + 2013.07.29 Kentaro FUKUCHI [3.4] * configure.ac, README, NEWS: diff --git a/Makefile.am b/Makefile.am index 55659c51b1..9c02b81220 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,7 @@ libqrencode_la_SOURCES = qrencode.c qrencode_inner.h \ qrinput.c qrinput.h \ bitstream.c bitstream.h \ qrspec.c qrspec.h \ - rscode.c rscode.h \ + rsecc.c rsecc.h \ split.c split.h \ mask.c mask.h \ mqrspec.c mqrspec.h \ diff --git a/qrencode.c b/qrencode.c index ab8b5d85c5..aeecf2d18b 100644 --- a/qrencode.c +++ b/qrencode.c @@ -31,7 +31,7 @@ #include "mqrspec.h" #include "bitstream.h" #include "qrinput.h" -#include "rscode.h" +#include "rsecc.h" #include "split.h" #include "mask.h" #include "mmask.h" @@ -59,14 +59,14 @@ typedef struct { int count; } QRRawCode; -static void RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int el, unsigned char *ecc, RS *rs) +static void RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int el, unsigned char *ecc) { block->dataLength = dl; block->data = data; block->eccLength = el; block->ecc = ecc; - encode_rs_char(rs, data, ecc); + RSECC_encode(el, 255 - dl - el, data, ecc); } static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsigned char *ecc) @@ -74,19 +74,16 @@ static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsig int i; RSblock *block; unsigned char *dp, *ep; - RS *rs; int el, dl; dl = QRspec_rsDataCodes1(spec); el = QRspec_rsEccCodes1(spec); - rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); - if(rs == NULL) return -1; block = blocks; dp = data; ep = ecc; for(i=0; ieccLength, 255 - raw->dataLength - raw->eccLength); - if(rs == NULL) { - MQRraw_free(raw); - return NULL; - } - - RSblock_initBlock(raw->rsblock, raw->dataLength, raw->datacode, raw->eccLength, raw->ecccode, rs); + RSblock_initBlock(raw->rsblock, raw->dataLength, raw->datacode, raw->eccLength, raw->ecccode); raw->count = 0; @@ -925,5 +913,4 @@ void QRcode_clearCache(void) { QRspec_clearCache(); MQRspec_clearCache(); - free_rs_cache(); } diff --git a/rscode.c b/rscode.c deleted file mode 100644 index edc32e2c92..0000000000 --- a/rscode.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * qrencode - QR Code encoder - * - * Reed solomon encoder. This code is taken from Phil Karn's libfec then - * editted and packed into a pair of .c and .h files. - * - * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - * (libfec is released under the GNU Lesser General Public License.) - * - * Copyright (C) 2006-2011 Kentaro Fukuchi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if HAVE_CONFIG_H -# include "config.h" -#endif -#include -#include -#ifdef HAVE_LIBPTHREAD -# include -#endif - -#include "rscode.h" - -/* Stuff specific to the 8-bit symbol version of the general purpose RS codecs - * - */ -typedef unsigned char data_t; - - -/** - * Reed-Solomon codec control block - */ -struct _RS { - int mm; /* Bits per symbol */ - int nn; /* Symbols per block (= (1<= rs->nn) { - x -= rs->nn; - x = (x >> rs->mm) + (x & rs->nn); - } - return x; -} - - -#define MODNN(x) modnn(rs,x) - -#define MM (rs->mm) -#define NN (rs->nn) -#define ALPHA_TO (rs->alpha_to) -#define INDEX_OF (rs->index_of) -#define GENPOLY (rs->genpoly) -#define NROOTS (rs->nroots) -#define FCR (rs->fcr) -#define PRIM (rs->prim) -#define IPRIM (rs->iprim) -#define PAD (rs->pad) -#define A0 (NN) - - -/* Initialize a Reed-Solomon codec - * symsize = symbol size, bits - * gfpoly = Field generator polynomial coefficients - * fcr = first root of RS code generator polynomial, index form - * prim = primitive element to generate polynomial roots - * nroots = RS code generator polynomial degree (number of roots) - * pad = padding bytes at front of shortened block - */ -static RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) -{ - RS *rs; - - -/* Common code for intializing a Reed-Solomon control block (char or int symbols) - * Copyright 2004 Phil Karn, KA9Q - * May be used under the terms of the GNU Lesser General Public License (LGPL) - */ -//#undef NULL -//#define NULL ((void *)0) - - int i, j, sr,root,iprim; - - rs = NULL; - /* Check parameter ranges */ - if(symsize < 0 || symsize > (int)(8*sizeof(data_t))){ - goto done; - } - - if(fcr < 0 || fcr >= (1<= (1<= (1<= ((1<mm = symsize; - rs->nn = (1<pad = pad; - - rs->alpha_to = (data_t *)malloc(sizeof(data_t)*(rs->nn+1)); - if(rs->alpha_to == NULL){ - free(rs); - rs = NULL; - goto done; - } - rs->index_of = (data_t *)malloc(sizeof(data_t)*(rs->nn+1)); - if(rs->index_of == NULL){ - free(rs->alpha_to); - free(rs); - rs = NULL; - goto done; - } - - /* Generate Galois field lookup tables */ - rs->index_of[0] = A0; /* log(zero) = -inf */ - rs->alpha_to[A0] = 0; /* alpha**-inf = 0 */ - sr = 1; - for(i=0;inn;i++){ - rs->index_of[sr] = i; - rs->alpha_to[i] = sr; - sr <<= 1; - if(sr & (1<nn; - } - if(sr != 1){ - /* field generator polynomial is not primitive! */ - free(rs->alpha_to); - free(rs->index_of); - free(rs); - rs = NULL; - goto done; - } - - /* Form RS code generator polynomial from its roots */ - rs->genpoly = (data_t *)malloc(sizeof(data_t)*(nroots+1)); - if(rs->genpoly == NULL){ - free(rs->alpha_to); - free(rs->index_of); - free(rs); - rs = NULL; - goto done; - } - rs->fcr = fcr; - rs->prim = prim; - rs->nroots = nroots; - rs->gfpoly = gfpoly; - - /* Find prim-th root of 1, used in decoding */ - for(iprim=1;(iprim % prim) != 0;iprim += rs->nn) - ; - rs->iprim = iprim / prim; - - rs->genpoly[0] = 1; - for (i = 0,root=fcr*prim; i < nroots; i++,root += prim) { - rs->genpoly[i+1] = 1; - - /* Multiply rs->genpoly[] by @**(root + x) */ - for (j = i; j > 0; j--){ - if (rs->genpoly[j] != 0) - rs->genpoly[j] = rs->genpoly[j-1] ^ rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[j]] + root)]; - else - rs->genpoly[j] = rs->genpoly[j-1]; - } - /* rs->genpoly[0] can never be zero */ - rs->genpoly[0] = rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[0]] + root)]; - } - /* convert rs->genpoly[] to index form for quicker encoding */ - for (i = 0; i <= nroots; i++) - rs->genpoly[i] = rs->index_of[rs->genpoly[i]]; - done:; - - return rs; -} - -RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) -{ - RS *rs; - -#ifdef HAVE_LIBPTHREAD - pthread_mutex_lock(&rslist_mutex); -#endif - for(rs = rslist; rs != NULL; rs = rs->next) { - if(rs->pad != pad) continue; - if(rs->nroots != nroots) continue; - if(rs->mm != symsize) continue; - if(rs->gfpoly != gfpoly) continue; - if(rs->fcr != fcr) continue; - if(rs->prim != prim) continue; - - goto DONE; - } - - rs = init_rs_char(symsize, gfpoly, fcr, prim, nroots, pad); - if(rs == NULL) goto DONE; - rs->next = rslist; - rslist = rs; - -DONE: -#ifdef HAVE_LIBPTHREAD - pthread_mutex_unlock(&rslist_mutex); -#endif - return rs; -} - - -void free_rs_char(RS *rs) -{ - free(rs->alpha_to); - free(rs->index_of); - free(rs->genpoly); - free(rs); -} - -void free_rs_cache(void) -{ - RS *rs, *next; - -#ifdef HAVE_LIBPTHREAD - pthread_mutex_lock(&rslist_mutex); -#endif - rs = rslist; - while(rs != NULL) { - next = rs->next; - free_rs_char(rs); - rs = next; - } - rslist = NULL; -#ifdef HAVE_LIBPTHREAD - pthread_mutex_unlock(&rslist_mutex); -#endif -} - -/* The guts of the Reed-Solomon encoder, meant to be #included - * into a function body with the following typedefs, macros and variables supplied - * according to the code parameters: - - * data_t - a typedef for the data symbol - * data_t data[] - array of NN-NROOTS-PAD and type data_t to be encoded - * data_t parity[] - an array of NROOTS and type data_t to be written with parity symbols - * NROOTS - the number of roots in the RS code generator polynomial, - * which is the same as the number of parity symbols in a block. - Integer variable or literal. - * - * NN - the total number of symbols in a RS block. Integer variable or literal. - * PAD - the number of pad symbols in a block. Integer variable or literal. - * ALPHA_TO - The address of an array of NN elements to convert Galois field - * elements in index (log) form to polynomial form. Read only. - * INDEX_OF - The address of an array of NN elements to convert Galois field - * elements in polynomial form to index (log) form. Read only. - * MODNN - a function to reduce its argument modulo NN. May be inline or a macro. - * GENPOLY - an array of NROOTS+1 elements containing the generator polynomial in index form - - * The memset() and memmove() functions are used. The appropriate header - * file declaring these functions (usually ) must be included by the calling - * program. - - * Copyright 2004, Phil Karn, KA9Q - * May be used under the terms of the GNU Lesser General Public License (LGPL) - */ - -#undef A0 -#define A0 (NN) /* Special reserved value encoding zero in index form */ - -void encode_rs_char(RS *rs, const data_t *data, data_t *parity) -{ - int i, j; - data_t feedback; - - memset(parity,0,NROOTS*sizeof(data_t)); - - for(i=0;i - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __RSCODE_H__ -#define __RSCODE_H__ - -/* - * General purpose RS codec, 8-bit symbols. - */ - -typedef struct _RS RS; - -extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad); -extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity); -extern void free_rs_char(RS *rs); -extern void free_rs_cache(void); - -#endif /* __RSCODE_H__ */ diff --git a/rsecc.c b/rsecc.c new file mode 100644 index 0000000000..1f3b816d65 --- /dev/null +++ b/rsecc.c @@ -0,0 +1,131 @@ +/* + * qrencode - QR Code encoder + * + * Reed solomon error correction code encoder specialized for QR code. + * + * Copyright (C) 2013 Kentaro Fukuchi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if HAVE_CONFIG_H +# include "config.h" +#endif +#include +#include + +#include "rsecc.h" + +static int initialized = 0; + +#define SYMBOL_SIZE (8) +static const int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see pp.37 of JIS X0510:2004) */ +#define symbols ((1 << SYMBOL_SIZE) - 1) +#define max_generatorSize (30) + +#define min_length (2) +#define max_length (max_generatorSize) + +static unsigned char alpha[symbols + 1]; +static unsigned char aindex[symbols + 1]; +static unsigned char generator[max_length - min_length + 1][max_generatorSize + 1]; +static unsigned char generatorInitialized[max_length - min_length + 1]; + +static void RSECC_initLookupTable(void) +{ + int i, b; + + alpha[symbols] = 0; + aindex[0] = symbols; + + b = 1; + for(i = 0; i < symbols; i++) { + alpha[i] = b; + aindex[b] = i; + b <<= 1; + if(b & (symbols + 1)) { + b ^= proot; + } + b &= symbols; + } +} + +void RSECC_init(void) +{ + RSECC_initLookupTable(); + memset(generatorInitialized, 0, (max_length - min_length)); + initialized = 1; +} + +static void generator_init(int length) +{ + int i, j, a; + int g[max_generatorSize + 1]; + + g[0] = 1; + a = 0; + for(i = 1; i <= length; i++) { + g[i] = 1; + for(j = i - 1; j > 0; j--) { + if(g[0] != 0) { + g[j] = g[j - 1] ^ alpha[(aindex[g[j]] + a) % symbols]; + } else { + g[j] = g[j - 1]; + } + } + g[0] = alpha[(aindex[g[0]] + a) % symbols]; + a++; + } + + for(i = 0; i <= length; i++) { + generator[length - min_length][i] = aindex[g[i]]; + } + + generatorInitialized[length - min_length] = 1; +} + +int RSECC_encode(int length, int pad, const unsigned char *data, unsigned char *ecc) +{ + int i, j; + unsigned char feedback; + unsigned char *gen; + + if(!initialized) { + RSECC_init(); + } + + if(length > max_length) return -1; + + memset(ecc, 0, length); + if(!generatorInitialized[length - min_length]) generator_init(length); + gen = generator[length - min_length]; + + for(i = 0; i < symbols - length - pad; i++) { + feedback = aindex[data[i] ^ ecc[0]]; + if(feedback != symbols) { + for(j = 1; j < length; j++) { + ecc[j] ^= alpha[(feedback + gen[length - j]) % symbols]; + } + } + memmove(&ecc[0], &ecc[1], length - 1); + if(feedback != symbols) { + ecc[length - 1] = alpha[(feedback + gen[0]) % symbols]; + } else { + ecc[length - 1] = 0; + } + } + + return 0; +} diff --git a/rsecc.h b/rsecc.h new file mode 100644 index 0000000000..99490a2c1e --- /dev/null +++ b/rsecc.h @@ -0,0 +1,28 @@ +/* + * qrencode - QR Code encoder + * + * Reed solomon error correction code encoder specialized for QR code. + * + * Copyright (C) 2006-2011 Kentaro Fukuchi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __RSECC_H__ +#define __RSECC_H__ + +extern int RSECC_encode(int length, int pad, const unsigned char *data, unsigned char *ecc); + +#endif /* __RSECC_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 92eda902c4..274a2da2d0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,7 +9,7 @@ noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ $(sdlPROGRAMS) noinst_LIBRARIES = libdecoder.a DECODER_LIBS = libdecoder.a $(LIBICONV) -noinst_HEADERS = common.h +noinst_HEADERS = common.h rscode.h if HAVE_LIBPTHREAD noinst_PROGRAMS += pthread_qrencode endif @@ -33,7 +33,7 @@ test_qrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) test_mqrspec_SOURCES = test_mqrspec.c test_mqrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_rs_SOURCES = test_rs.c +test_rs_SOURCES = test_rs.c rscode.c test_rs_LDADD = ../libqrencode.la test_qrencode_SOURCES = test_qrencode.c diff --git a/tests/rscode.c b/tests/rscode.c new file mode 100644 index 0000000000..7d14651448 --- /dev/null +++ b/tests/rscode.c @@ -0,0 +1,274 @@ +/* + * qrencode - QR Code encoder + * + * Reed solomon encoder. This code is taken from Phil Karn's libfec then + * editted and packed into a pair of .c and .h files. + * + * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q + * (libfec is released under the GNU Lesser General Public License.) + * + * Copyright (C) 2006-2011 Kentaro Fukuchi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if HAVE_CONFIG_H +# include "config.h" +#endif +#include +#include + +#include "rscode.h" + +/* Stuff specific to the 8-bit symbol version of the general purpose RS codecs + * + */ +typedef unsigned char data_t; + + +/** + * Reed-Solomon codec control block + */ +struct _RS { + int mm; /* Bits per symbol */ + int nn; /* Symbols per block (= (1<= rs->nn) { + x -= rs->nn; + x = (x >> rs->mm) + (x & rs->nn); + } + return x; +} + + +#define MODNN(x) modnn(rs,x) + +#define MM (rs->mm) +#define NN (rs->nn) +#define ALPHA_TO (rs->alpha_to) +#define INDEX_OF (rs->index_of) +#define GENPOLY (rs->genpoly) +#define NROOTS (rs->nroots) +#define FCR (rs->fcr) +#define PRIM (rs->prim) +#define IPRIM (rs->iprim) +#define PAD (rs->pad) +#define A0 (NN) + + +/* Initialize a Reed-Solomon codec + * symsize = symbol size, bits + * gfpoly = Field generator polynomial coefficients + * fcr = first root of RS code generator polynomial, index form + * prim = primitive element to generate polynomial roots + * nroots = RS code generator polynomial degree (number of roots) + * pad = padding bytes at front of shortened block + */ +static RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) +{ + RS *rs; + + +/* Common code for intializing a Reed-Solomon control block (char or int symbols) + * Copyright 2004 Phil Karn, KA9Q + * May be used under the terms of the GNU Lesser General Public License (LGPL) + */ +//#undef NULL +//#define NULL ((void *)0) + + int i, j, sr,root,iprim; + + rs = NULL; + /* Check parameter ranges */ + if(symsize < 0 || symsize > (int)(8*sizeof(data_t))){ + goto done; + } + + if(fcr < 0 || fcr >= (1<= (1<= (1<= ((1<mm = symsize; + rs->nn = (1<pad = pad; + + rs->alpha_to = (data_t *)malloc(sizeof(data_t)*(rs->nn+1)); + if(rs->alpha_to == NULL){ + free(rs); + rs = NULL; + goto done; + } + rs->index_of = (data_t *)malloc(sizeof(data_t)*(rs->nn+1)); + if(rs->index_of == NULL){ + free(rs->alpha_to); + free(rs); + rs = NULL; + goto done; + } + + /* Generate Galois field lookup tables */ + rs->index_of[0] = A0; /* log(zero) = -inf */ + rs->alpha_to[A0] = 0; /* alpha**-inf = 0 */ + sr = 1; + for(i=0;inn;i++){ + rs->index_of[sr] = i; + rs->alpha_to[i] = sr; + sr <<= 1; + if(sr & (1<nn; + } + if(sr != 1){ + /* field generator polynomial is not primitive! */ + free(rs->alpha_to); + free(rs->index_of); + free(rs); + rs = NULL; + goto done; + } + + /* Form RS code generator polynomial from its roots */ + rs->genpoly = (data_t *)malloc(sizeof(data_t)*(nroots+1)); + if(rs->genpoly == NULL){ + free(rs->alpha_to); + free(rs->index_of); + free(rs); + rs = NULL; + goto done; + } + rs->fcr = fcr; + rs->prim = prim; + rs->nroots = nroots; + rs->gfpoly = gfpoly; + + /* Find prim-th root of 1, used in decoding */ + for(iprim=1;(iprim % prim) != 0;iprim += rs->nn) + ; + rs->iprim = iprim / prim; + + rs->genpoly[0] = 1; + for (i = 0,root=fcr*prim; i < nroots; i++,root += prim) { + rs->genpoly[i+1] = 1; + + /* Multiply rs->genpoly[] by @**(root + x) */ + for (j = i; j > 0; j--){ + if (rs->genpoly[j] != 0) + rs->genpoly[j] = rs->genpoly[j-1] ^ rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[j]] + root)]; + else + rs->genpoly[j] = rs->genpoly[j-1]; + } + /* rs->genpoly[0] can never be zero */ + rs->genpoly[0] = rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[0]] + root)]; + } + /* convert rs->genpoly[] to index form for quicker encoding */ + for (i = 0; i <= nroots; i++) + rs->genpoly[i] = rs->index_of[rs->genpoly[i]]; + done:; + + return rs; +} + +RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) +{ + return init_rs_char(symsize, gfpoly, fcr, prim, nroots, pad); +} + + +void free_rs_char(RS *rs) +{ + free(rs->alpha_to); + free(rs->index_of); + free(rs->genpoly); + free(rs); +} + +/* The guts of the Reed-Solomon encoder, meant to be #included + * into a function body with the following typedefs, macros and variables supplied + * according to the code parameters: + + * data_t - a typedef for the data symbol + * data_t data[] - array of NN-NROOTS-PAD and type data_t to be encoded + * data_t parity[] - an array of NROOTS and type data_t to be written with parity symbols + * NROOTS - the number of roots in the RS code generator polynomial, + * which is the same as the number of parity symbols in a block. + Integer variable or literal. + * + * NN - the total number of symbols in a RS block. Integer variable or literal. + * PAD - the number of pad symbols in a block. Integer variable or literal. + * ALPHA_TO - The address of an array of NN elements to convert Galois field + * elements in index (log) form to polynomial form. Read only. + * INDEX_OF - The address of an array of NN elements to convert Galois field + * elements in polynomial form to index (log) form. Read only. + * MODNN - a function to reduce its argument modulo NN. May be inline or a macro. + * GENPOLY - an array of NROOTS+1 elements containing the generator polynomial in index form + + * The memset() and memmove() functions are used. The appropriate header + * file declaring these functions (usually ) must be included by the calling + * program. + + * Copyright 2004, Phil Karn, KA9Q + * May be used under the terms of the GNU Lesser General Public License (LGPL) + */ + +#undef A0 +#define A0 (NN) /* Special reserved value encoding zero in index form */ + +void encode_rs_char(RS *rs, const data_t *data, data_t *parity) +{ + int i, j; + data_t feedback; + + memset(parity,0,NROOTS*sizeof(data_t)); + + for(i=0;i + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __RSCODE_H__ +#define __RSCODE_H__ + +/* + * General purpose RS codec, 8-bit symbols. + */ + +typedef struct _RS RS; + +extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad); +extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity); +extern void free_rs_char(RS *rs); + +#endif /* __RSCODE_H__ */ diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index d1e0918d34..badbdd8347 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -7,7 +7,7 @@ #include "../mqrspec.h" #include "../qrinput.h" #include "../mask.h" -#include "../rscode.h" +#include "../rsecc.h" #include "../split.h" #include "decoder.h" diff --git a/tests/test_rs.c b/tests/test_rs.c index 7ea2695ad8..55d750f06b 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -2,11 +2,14 @@ #include #include "common.h" #include "../qrencode_inner.h" +#include "../qrspec.h" +#include "../mqrspec.h" #include "../qrinput.h" -#include "../rscode.h" +#include "../rsecc.h" +#include "rscode.h" /* See pp. 73 of JIS X0510:2004 */ -void test_rscode1(void) +void test_rscodeexample(void) { QRinput *stream; QRRawCode *code; @@ -27,11 +30,88 @@ void test_rscode1(void) QRraw_free(code); } +static void compareRS(unsigned char data[]) +{ + int i, j; + RS *rs; + int spec[5]; + int dl, el; + unsigned char ecc_expected[256], ecc_rscodec[256]; + + for(i = 1; i <= QRSPEC_VERSION_MAX; i++) { + for(j = QR_ECLEVEL_L; j <= QR_ECLEVEL_H; j++) { + QRspec_getEccSpec(i, (QRecLevel)j, spec); + dl = QRspec_rsDataCodes1(spec); + el = QRspec_rsEccCodes1(spec); + rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); + RSECC_encode(el, 255 - dl - el, data, ecc_rscodec); + encode_rs_char(rs, data, ecc_expected); + assert_zero(memcmp(ecc_expected, ecc_rscodec, el), "Invalid ECC found: length %d.\n", el); + free_rs_char(rs); + + dl = QRspec_rsDataCodes2(spec); + el = QRspec_rsEccCodes2(spec); + if(dl != 0) { + rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); + RSECC_encode(el, 255 - dl - el, data, ecc_rscodec); + encode_rs_char(rs, data, ecc_expected); + assert_zero(memcmp(ecc_expected, ecc_rscodec, el), "Invalid ECC found: length %d.\n", el); + free_rs_char(rs); + } + } + } +} + +static void compareRSMQR(unsigned char data[]) +{ + int i, j; + RS *rs; + int dl, el; + unsigned char ecc_expected[256], ecc_rscodec[256]; + + for(i = 1; i <= MQRSPEC_VERSION_MAX; i++) { + for(j = QR_ECLEVEL_L; j <= QR_ECLEVEL_Q; j++) { + dl = MQRspec_getDataLength(i, (QRecLevel)j); + el = MQRspec_getECCLength(i, (QRecLevel)j); + if(dl != 0) { + rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); + RSECC_encode(el, 255 - dl - el, data, ecc_rscodec); + encode_rs_char(rs, data, ecc_expected); + assert_zero(memcmp(ecc_expected, ecc_rscodec, el), "Invalid ECC found: length %d.\n", el); + free_rs_char(rs); + } + } + } +} + +void test_allQRSizeAndECCLevel(void) +{ + int i; + unsigned char data[256]; + + testStart("Comparing with KA9Q's code: all QR Code sizes and ECC levels"); + memset(data, 0, 256); + compareRS(data); + compareRSMQR(data); + memset(data, 0xaa, 256); + compareRS(data); + compareRSMQR(data); + memset(data, 0xff, 256); + compareRS(data); + compareRSMQR(data); + for(i=0; i<256; i++) { + data[i] = i; + } + compareRS(data); + compareRSMQR(data); + testFinish(); +} + int main(void) { - test_rscode1(); + test_rscodeexample(); + test_allQRSizeAndECCLevel(); - free_rs_cache(); report(); return 0; -- cgit 0.0.5-2-1-g0f52 From e6d9bf216b676fd892fd8fcab9c716b52aabf30a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 15 Aug 2013 10:30:23 +0900 Subject: Code cleanup. --- ChangeLog | 10 ++++++---- tests/test_mqrspec.c | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc0aa55792..61ca01eac3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,12 @@ 2013.08.15 Kentaro FUKUCHI * rsecc.[ch], rscode.[ch], Makefile.am, qrencode.c: - - Reed-Solomon error correction code has been completely rewritten. - - Phil Karn's code has been removed (moved to tests). + - Reed-Solomon error correction code has been completely rewritten. + - Phil Karn's code has been removed (moved to tests). * tests/test_rs.c, tests/test_qrencode.c, tests/rscode.[ch], tests/Makefile.am: - - Test codes related to ECC have been updated. - - Phil Karn's code has been moved to tests, just for test purpose. + - Test codes related to ECC have been updated. + - Phil Karn's code has been moved to tests, just for test purpose. + * tests/test_mqrspec.c: + - Code cleanup. 2013.07.29 Kentaro FUKUCHI [3.4] diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index 22657f93a4..70705c1178 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -95,8 +95,8 @@ void test_format(void) int err = 0; testStart("Format info test"); - for(version=1; version<=4; version++) { - for(l=0; l<3; l++) { + for(version=1; version<=MQRSPEC_VERSION_MAX; version++) { + for(l=QR_ECLEVEL_L; l<=QR_ECLEVEL_Q; l++) { for(mask=0; mask<4; mask++) { format = MQRspec_getFormatInfo(mask, version, (QRecLevel)l); type = typeTable[version - 1][l]; -- cgit 0.0.5-2-1-g0f52 From 76b4461d24300efa2b28801058239279708782b0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 15 Aug 2013 16:48:48 +0900 Subject: Code cleanups and refactoring. --- ChangeLog | 4 ++++ qrencode.c | 2 +- rsecc.c | 29 +++++++++++++++-------------- rsecc.h | 2 +- tests/test_rs.c | 6 +++--- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61ca01eac3..c31494f3ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013.08.15 Kentaro FUKUCHI + * rsecc.[ch], qrencode.c, tests/test_rc.c: + - Code cleanups and refactoring. + 2013.08.15 Kentaro FUKUCHI * rsecc.[ch], rscode.[ch], Makefile.am, qrencode.c: - Reed-Solomon error correction code has been completely rewritten. diff --git a/qrencode.c b/qrencode.c index aeecf2d18b..823ce4cd72 100644 --- a/qrencode.c +++ b/qrencode.c @@ -66,7 +66,7 @@ static void RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int e block->eccLength = el; block->ecc = ecc; - RSECC_encode(el, 255 - dl - el, data, ecc); + RSECC_encode(dl, el, data, ecc); } static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsigned char *ecc) diff --git a/rsecc.c b/rsecc.c index 1f3b816d65..359e61cc02 100644 --- a/rsecc.c +++ b/rsecc.c @@ -31,12 +31,13 @@ static int initialized = 0; #define SYMBOL_SIZE (8) -static const int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see pp.37 of JIS X0510:2004) */ #define symbols ((1 << SYMBOL_SIZE) - 1) -#define max_generatorSize (30) +static const int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see pp.37 of JIS X0510:2004) */ +/* min/max codeword length of ECC, calculated from the specification. */ #define min_length (2) -#define max_length (max_generatorSize) +#define max_length (30) +#define max_generatorSize (max_length) static unsigned char alpha[symbols + 1]; static unsigned char aindex[symbols + 1]; @@ -96,7 +97,7 @@ static void generator_init(int length) generatorInitialized[length - min_length] = 1; } -int RSECC_encode(int length, int pad, const unsigned char *data, unsigned char *ecc) +int RSECC_encode(int datalength, int ecclength, const unsigned char *data, unsigned char *ecc) { int i, j; unsigned char feedback; @@ -106,24 +107,24 @@ int RSECC_encode(int length, int pad, const unsigned char *data, unsigned char * RSECC_init(); } - if(length > max_length) return -1; + if(ecclength > max_length) return -1; - memset(ecc, 0, length); - if(!generatorInitialized[length - min_length]) generator_init(length); - gen = generator[length - min_length]; + memset(ecc, 0, ecclength); + if(!generatorInitialized[ecclength - min_length]) generator_init(ecclength); + gen = generator[ecclength - min_length]; - for(i = 0; i < symbols - length - pad; i++) { + for(i = 0; i < datalength; i++) { feedback = aindex[data[i] ^ ecc[0]]; if(feedback != symbols) { - for(j = 1; j < length; j++) { - ecc[j] ^= alpha[(feedback + gen[length - j]) % symbols]; + for(j = 1; j < ecclength; j++) { + ecc[j] ^= alpha[(feedback + gen[ecclength - j]) % symbols]; } } - memmove(&ecc[0], &ecc[1], length - 1); + memmove(&ecc[0], &ecc[1], ecclength - 1); if(feedback != symbols) { - ecc[length - 1] = alpha[(feedback + gen[0]) % symbols]; + ecc[ecclength - 1] = alpha[(feedback + gen[0]) % symbols]; } else { - ecc[length - 1] = 0; + ecc[ecclength - 1] = 0; } } diff --git a/rsecc.h b/rsecc.h index 99490a2c1e..a6cf86e9d5 100644 --- a/rsecc.h +++ b/rsecc.h @@ -23,6 +23,6 @@ #ifndef __RSECC_H__ #define __RSECC_H__ -extern int RSECC_encode(int length, int pad, const unsigned char *data, unsigned char *ecc); +extern int RSECC_encode(int datalength, int ecclength, const unsigned char *data, unsigned char *ecc); #endif /* __RSECC_H__ */ diff --git a/tests/test_rs.c b/tests/test_rs.c index 55d750f06b..59a525fa5d 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -44,7 +44,7 @@ static void compareRS(unsigned char data[]) dl = QRspec_rsDataCodes1(spec); el = QRspec_rsEccCodes1(spec); rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); - RSECC_encode(el, 255 - dl - el, data, ecc_rscodec); + RSECC_encode(dl, el, data, ecc_rscodec); encode_rs_char(rs, data, ecc_expected); assert_zero(memcmp(ecc_expected, ecc_rscodec, el), "Invalid ECC found: length %d.\n", el); free_rs_char(rs); @@ -53,7 +53,7 @@ static void compareRS(unsigned char data[]) el = QRspec_rsEccCodes2(spec); if(dl != 0) { rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); - RSECC_encode(el, 255 - dl - el, data, ecc_rscodec); + RSECC_encode(dl, el, data, ecc_rscodec); encode_rs_char(rs, data, ecc_expected); assert_zero(memcmp(ecc_expected, ecc_rscodec, el), "Invalid ECC found: length %d.\n", el); free_rs_char(rs); @@ -75,7 +75,7 @@ static void compareRSMQR(unsigned char data[]) el = MQRspec_getECCLength(i, (QRecLevel)j); if(dl != 0) { rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el); - RSECC_encode(el, 255 - dl - el, data, ecc_rscodec); + RSECC_encode(dl, el, data, ecc_rscodec); encode_rs_char(rs, data, ecc_expected); assert_zero(memcmp(ecc_expected, ecc_rscodec, el), "Invalid ECC found: length %d.\n", el); free_rs_char(rs); -- cgit 0.0.5-2-1-g0f52 From 0976065792b4738cca2e93a1d586d8fe5cfd3adb Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 15 Aug 2013 16:50:57 +0900 Subject: Bumped version to 3.9.0. --- ChangeLog | 4 ++++ configure.ac | 4 ++-- qrenc.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c31494f3ad..5b14ea74da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ 2013.08.15 Kentaro FUKUCHI * rsecc.[ch], qrencode.c, tests/test_rc.c: - Code cleanups and refactoring. + * configure.ac: + - Bumped version to 3.9.0, preparing for major update. + * qrenc.c: + - Copyright year in usage has been updated. 2013.08.15 Kentaro FUKUCHI * rsecc.[ch], rscode.[ch], Makefile.am, qrencode.c: diff --git a/configure.ac b/configure.ac index 5b46a20b71..fab4e4ac73 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ AC_INIT(QRencode) MAJOR_VERSION=3 -MINOR_VERSION=4 -MICRO_VERSION=3 +MINOR_VERSION=9 +MICRO_VERSION=0 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) diff --git a/qrenc.c b/qrenc.c index 2a8eba3630..68e111ae4b 100644 --- a/qrenc.c +++ b/qrenc.c @@ -88,7 +88,7 @@ static void usage(int help, int longopt) { fprintf(stderr, "qrencode version %s\n" -"Copyright (C) 2006-2012 Kentaro Fukuchi\n", QRcode_APIVersionString()); +"Copyright (C) 2006-2013 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { if(longopt) { fprintf(stderr, -- cgit 0.0.5-2-1-g0f52 From 220b6687d69ec558ce77a4b69092deced320b720 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 15 Aug 2013 16:59:55 +0900 Subject: Help messages improved. --- ChangeLog | 1 + qrenc.c | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b14ea74da..db71583685 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ - Bumped version to 3.9.0, preparing for major update. * qrenc.c: - Copyright year in usage has been updated. + - Help message improved. 2013.08.15 Kentaro FUKUCHI * rsecc.[ch], rscode.[ch], Makefile.am, qrencode.c: diff --git a/qrenc.c b/qrenc.c index 68e111ae4b..904fe8f999 100644 --- a/qrenc.c +++ b/qrenc.c @@ -100,7 +100,7 @@ static void usage(int help, int longopt) " write image to FILENAME. If '-' is specified, the result\n" " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n" -" (suffix is removed from FILENAME, if specified)\n" +" (suffix is removed from FILENAME, if specified)\n\n" " -s NUMBER, --size=NUMBER\n" " specify module size in dots (pixels). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" @@ -112,8 +112,7 @@ static void usage(int help, int longopt) " specify the width of the margins. (default=4 (2 for Micro)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={PNG,EPS,\n" -" SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" +" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={...}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" @@ -129,7 +128,7 @@ static void usage(int help, int longopt) " --background=RRGGBB[AA]\n" " specify foreground/background color in hexadecimal notation.\n" " 6-digit (RGB) or 8-digit (RGBA) form are supported.\n" -" Color output support available only in PNG and SVG.\n" +" Color output support available only in PNG and SVG.\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" @@ -159,14 +158,10 @@ static void usage(int help, int longopt) " -i ignore case distinctions and use only upper-case characters.\n" " -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n" " -M encode in a Micro QR Code.\n" -" --foreground=RRGGBB[AA]\n" -" --background=RRGGBB[AA]\n" -" specify foreground/background color in hexadecimal notation.\n" -" 6-digit (RGB) or 8-digit (RGBA) form are supported.\n" -" Color output support available only in PNG and SVG.\n" " -V display the version number and copyrights of the qrencode.\n" " [STRING] input data. If it is not specified, data will be taken from\n" -" standard input.\n" +" standard input.\n\n" +" Try \"qrencode --help\" for more options.\n" ); } } -- cgit 0.0.5-2-1-g0f52 From 742c4790a2a57e897443ebc8492c69e92d6b0a99 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 15 Aug 2013 17:02:18 +0900 Subject: Minor bug fix. --- ChangeLog | 1 + rsecc.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index db71583685..afcde01857 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2013.08.15 Kentaro FUKUCHI * rsecc.[ch], qrencode.c, tests/test_rc.c: - Code cleanups and refactoring. + - Bug fix. * configure.ac: - Bumped version to 3.9.0, preparing for major update. * qrenc.c: diff --git a/rsecc.c b/rsecc.c index 359e61cc02..cf67d3f08d 100644 --- a/rsecc.c +++ b/rsecc.c @@ -66,7 +66,7 @@ static void RSECC_initLookupTable(void) void RSECC_init(void) { RSECC_initLookupTable(); - memset(generatorInitialized, 0, (max_length - min_length)); + memset(generatorInitialized, 0, (max_length - min_length + 1)); initialized = 1; } -- cgit 0.0.5-2-1-g0f52 From 8db6ed827746f016ea358da01146fdf9aee28041 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 22 Aug 2013 13:24:10 +0900 Subject: Some short/overrunning underlines fixed. --- NEWS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index de26e0178b..50e5238191 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ libqrencode NEWS - Overview of changes ====================================== Version 3.4.3 (2013.8.12) ------------------------- +------------------------- * New option "--rle" has been added to the command line tool (Thanks to Daniel Dörrhöfer) * Bug fixes. (Thanks to Hassan Hajji, Emmanuel Blot, and ßlúèÇhîp) @@ -68,7 +68,7 @@ QRcode_APIVersion() is requested by Matthew Baker for better support of Python ctypes binding. Check them out at https://code.google.com/p/libqrencode-ctypes/ Version 3.2.1 (2012.4.1) -------------------------- +------------------------ * Bugs in configure script and libtool file has been fixed. (Thanks to Yutaka Niibe) @@ -212,7 +212,7 @@ API changes: - QRinput_setVersion Version 2.0.0 (2008.1.24) --------------------------- +------------------------- Summary: * "-i" option to ignore case distinctions has been added to qrencode and view_qrcode. -- cgit 0.0.5-2-1-g0f52 From 76844283c7dd5fe8947f37bf3b5b4976fd86a270 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 22 Aug 2013 13:24:43 +0900 Subject: Avoid to use sdl-config. (Thanks to Heiko Becker) --- ChangeLog | 4 ++++ README | 2 +- configure.ac | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index afcde01857..bdf931bb24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013.08.22 Kentaro FUKUCHI + * configure.ac: + - Avoid to use sdl-config. (Thanks to Heiko Becker) + 2013.08.15 Kentaro FUKUCHI * rsecc.[ch], qrencode.c, tests/test_rc.c: - Code cleanups and refactoring. diff --git a/README b/README index 2f79701ed6..ed2009099f 100644 --- a/README +++ b/README @@ -140,5 +140,5 @@ Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, -Emmanuel Blot, ßlúèÇhîp +Emmanuel Blot, ßlúèÇhîp, Heiko Becker - bug report / suggestion diff --git a/configure.ac b/configure.ac index fab4e4ac73..badcafdb4e 100644 --- a/configure.ac +++ b/configure.ac @@ -80,8 +80,7 @@ fi if test x$build_tests = xyes ; then SDL_REQUIRED_VERSION=1.2.0 - AM_PATH_SDL($SDL_REQUIRED_VERSION,,AC_MSG_WARN([*** SDL $SDL_REQUIRED_VERSION or better is required.])) - AC_MSG_NOTICE([SDL check done.]) + PKG_CHECK_MODULES(SDL, [sdl >= $SDL_REQUIRED_VERSION]) AM_ICONV_LINK fi AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ]) -- cgit 0.0.5-2-1-g0f52 From 68f1d979ce10e87e0becc2357978742f09411866 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Wed, 4 Sep 2013 10:41:43 +0200 Subject: Bugfix: Numerical result out of range. To meet the specification at version 40 maximum charakter. --- qrspec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qrspec.c b/qrspec.c index a42706f4b8..3cf5c4a14b 100644 --- a/qrspec.c +++ b/qrspec.c @@ -113,8 +113,9 @@ int QRspec_getMinimumVersion(int size, QRecLevel level) int i; int words; - for(i=1; i<= QRSPEC_VERSION_MAX; i++) { + for(i=1; i<= QRSPEC_VERSION_MAX+1; i++) { words = qrspecCapacity[i].words - qrspecCapacity[i].ec[level]; + if(i > QRSPEC_VERSION_MAX) return QRSPEC_VERSION_MAX; if(words >= size) return i; } -- cgit 0.0.5-2-1-g0f52 From 8a4fbce74177ab2ef3ce55fbcabe2e4b683c2ebc Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Wed, 4 Sep 2013 20:10:45 +0200 Subject: Bugfix: Numerical result out of range function getMinimumVersion does not return -1 if QRSPEC_VERSION_MAX is reached any more. Testing for maximum character is done by function QRinput_appendPaddingBit[MQR]? This test was redundant some how. --- qrinput.c | 8 +------- qrspec.c | 5 ++--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/qrinput.c b/qrinput.c index b59dd1b3ab..95a82d893a 100644 --- a/qrinput.c +++ b/qrinput.c @@ -984,9 +984,6 @@ static int QRinput_estimateVersion(QRinput *input) prev = version; bits = QRinput_estimateBitStreamSize(input, prev); version = QRspec_getMinimumVersion((bits + 7) / 8, input->level); - if (version < 0) { - return -1; - } } while (version > prev); return version; @@ -1165,10 +1162,7 @@ static int QRinput_convertData(QRinput *input) bits = QRinput_createBitStream(input); if(bits < 0) return -1; ver = QRspec_getMinimumVersion((bits + 7) / 8, input->level); - if(ver < 0) { - errno = ERANGE; - return -1; - } else if(ver > QRinput_getVersion(input)) { + if(ver > QRinput_getVersion(input)) { QRinput_setVersion(input, ver); } else { break; diff --git a/qrspec.c b/qrspec.c index 3cf5c4a14b..fdd18eab4f 100644 --- a/qrspec.c +++ b/qrspec.c @@ -113,13 +113,12 @@ int QRspec_getMinimumVersion(int size, QRecLevel level) int i; int words; - for(i=1; i<= QRSPEC_VERSION_MAX+1; i++) { + for(i=1; i<= QRSPEC_VERSION_MAX; i++) { words = qrspecCapacity[i].words - qrspecCapacity[i].ec[level]; - if(i > QRSPEC_VERSION_MAX) return QRSPEC_VERSION_MAX; if(words >= size) return i; } - return -1; + return QRSPEC_VERSION_MAX; } int QRspec_getWidth(int version) -- cgit 0.0.5-2-1-g0f52 From 3bb18adf079b2122b2b2f2d7f1839289f3513d0f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 Sep 2013 19:08:36 +0900 Subject: bzero() has been replaced with memset(). (Thanks to Gavin Andresen) --- ChangeLog | 4 ++++ README | 2 +- qrenc.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bdf931bb24..857d3e4a5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013.09.06 Kentaro FUKUCHI + * qrenc.c: + - bzero() has been replaced with memset(). (Thanks to Gavin Andresen) + 2013.08.22 Kentaro FUKUCHI * configure.ac: - Avoid to use sdl-config. (Thanks to Heiko Becker) diff --git a/README b/README index ed2009099f..602f301597 100644 --- a/README +++ b/README @@ -140,5 +140,5 @@ Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, -Emmanuel Blot, ßlúèÇhîp, Heiko Becker +Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index 904fe8f999..040959d41d 100644 --- a/qrenc.c +++ b/qrenc.c @@ -576,7 +576,7 @@ static int writeANSI(QRcode *qrcode, const char *outfile) for(y=0; ywidth; y++) { row = (p+(y*qrcode->width)); - bzero( buffer, buffer_s ); + memset(buffer, 0, buffer_s); strncpy( buffer, white, white_s ); for(x=0; x Date: Fri, 6 Sep 2013 21:10:49 +0900 Subject: Minimum length of bit buffer has been extended to 128. In many cases the library needs 128 bits at least to generate a symbol. --- ChangeLog | 5 +++++ bitstream.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d96aae6eaa..1bc3ff73a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013.09.06 Kentaro FUKUCHI + * bitstream.c: + - Minimum length of bit buffer has been extended to 128. In many cases + the library needs 128 bits at least to generate a symbol. + 2013.08.22 Kentaro FUKUCHI * configure.ac: - Avoid to use sdl-config. (Thanks to Heiko Becker) diff --git a/bitstream.c b/bitstream.c index c7dff72659..db93d610ed 100644 --- a/bitstream.c +++ b/bitstream.c @@ -28,7 +28,7 @@ #include "bitstream.h" -#define DEFAULT_BUFSIZE (16) +#define DEFAULT_BUFSIZE (128) BitStream *BitStream_new(void) { -- cgit 0.0.5-2-1-g0f52 From cb466d5c6ae3d0602f295f451ac521ebc97152b2 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 7 Sep 2013 03:39:06 +0900 Subject: New tests for excessive or maximum input have been added. --- ChangeLog | 8 +++++++ tests/test_qrencode.c | 65 ++++++++++++++++++++++++++++++++++++++------------- tests/test_qrinput.c | 22 ----------------- 3 files changed, 57 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 857d3e4a5d..fcae669155 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,14 @@ 2013.09.06 Kentaro FUKUCHI * qrenc.c: - bzero() has been replaced with memset(). (Thanks to Gavin Andresen) + * qrspec.c, qrinput.c: + - QRspec_getMinimumVersion() now returns maximum version number for + excessive input, instead of -1. Closes #31. (Thanks to Danil + Dörrhöfer) + * tests/test_qrencode.c: + - New tests for excessive or maximum input have been added. + * tests/test_qrinput.c: + - A deprecatd test has been removed. 2013.08.22 Kentaro FUKUCHI * configure.ac: diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index badbdd8347..a4c195d420 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -444,26 +444,59 @@ void test_encodeEmpty8(void) if(qrcode != NULL) QRcode_free(qrcode); } -void test_encodeTooLong(void) +void test_encodeLongData(void) { - QRcode *code; - char *data; + QRinput *stream; + unsigned char data[7090]; + int maxlength[4][4] = {{7089,5596,3993,3057}, + {4296,3391,2420,1852}, + {2953,2331,1663,1273}, + {1817*2,1435*2,1024*2, 784*2}}; + int i, l, len, ret; + QRcode *qrcode; - testStart("Encode too large data"); - data = (char *)malloc(4300); - memset(data, 'a', 4295); - memset(data + 4295, '0', 4); - data[4299] = '\0'; + testStart("Encoding long data."); - code = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 0); - assert_null(code, "Too large data is incorrectly accepted.\n"); - assert_equal(errno, ERANGE, "errno != ERANGE\n"); - testFinish(); + for(i=QR_MODE_NUM; i<=QR_MODE_KANJI; i++) { + if(i != QR_MODE_KANJI) { + memset(data, '0', maxlength[i][0]); + } else { + for(l=0; l<=maxlength[i][0]/2; l++) { + data[l*2] = 0x93; data[l*2+1] = 0x5f; + } + } + for(l=QR_ECLEVEL_L; l<=QR_ECLEVEL_H; l++) { + stream = QRinput_new2(0, l); + ret = QRinput_append(stream, i, maxlength[i][l], data); + assert_zero(ret, "Failed to add %d-byte %s to a QRinput\n", maxlength[i][l], modeStr[i]); + qrcode = QRcode_encodeInput(stream); + assert_nonnull(qrcode, "(QRcode_encodeInput) failed to encode %d-byte %s in level %d.\n", maxlength[i][l], modeStr[i], l); + if(qrcode != NULL) { + QRcode_free(qrcode); + } + QRinput_free(stream); - if(code != NULL) { - QRcode_free(code); + stream = QRinput_new2(0, l); + len = maxlength[i][l]; + if(i == QR_MODE_KANJI) { + len += 2; + } else { + len += 1; + } + ret = QRinput_append(stream, i, len, data); + if(ret == 0) { + qrcode = QRcode_encodeInput(stream); + assert_null(qrcode, "(QRcode_encodeInput) incorrectly succeeded to encode %d-byte %s in level %d.\n", len, modeStr[i], l); + if(qrcode != NULL) { + printf("version: %d\n", qrcode->version); + QRcode_free(qrcode); + } + } + QRinput_free(stream); + } } - free(data); + + testFinish(); } void test_01234567(void) @@ -937,7 +970,7 @@ int main(void) test_encodeEmpty(); test_encodeNull8(); test_encodeEmpty8(); - test_encodeTooLong(); + test_encodeLongData(); test_01234567(); test_invalid_input(); // print_01234567(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index bbcc279907..dbd6d17e13 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -282,27 +282,6 @@ void test_encodeNumeric3(void) testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct)); } -void test_encodeTooLong(void) -{ - QRinput *stream; - unsigned char *data; - BitStream *bstream; - - data = (unsigned char *)malloc(4297); - memset(data, 'A', 4297); - - testStart("Encoding long string. (4297 bytes of alphanumeric)"); - stream = QRinput_new(); - QRinput_append(stream, QR_MODE_AN, 4297, data); - bstream = QRinput_mergeBitStream(stream); - testEndExp(bstream == NULL); - QRinput_free(stream); - if(bstream != NULL) { - BitStream_free(bstream); - } - free(data); -} - void test_encodeAnNum(void) { QRinput *input; @@ -946,7 +925,6 @@ int main(void) test_encodeNumeric_versionup(); test_encode8(); test_encode8_versionup(); - test_encodeTooLong(); test_encodeAn(); test_encodeAn2(); test_encodeKanji(); -- cgit 0.0.5-2-1-g0f52 From 5f3bba099266b432cd9df58f09be2b220f0ceeaf Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 7 Sep 2013 03:41:11 +0900 Subject: Acknowledgements updated. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 602f301597..9623ce033d 100644 --- a/README +++ b/README @@ -137,7 +137,7 @@ Lennart Poettering (mezcalero) - improved text art patch Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting -Daniel Dörrhöfer - RLE option +Daniel Dörrhöfer - RLE option, some bug fixes. Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen -- cgit 0.0.5-2-1-g0f52 From 543935ccb111e823b466e7730cdb051acf637528 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 8 Sep 2013 13:27:58 +0900 Subject: Small bug fix. --- ChangeLog | 4 ++++ tests/test_qrencode.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00205d094b..65d3a70c4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013.09.08 Kentaro FUKUCHI + * tests/test_qrencode.c: + - Small bug fix. + 2013.09.06 Kentaro FUKUCHI * qrenc.c: - bzero() has been replaced with memset(). (Thanks to Gavin Andresen) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 74e7f9f2f4..6ab7f0c31b 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -460,9 +460,9 @@ void test_encodeLongData(void) for(i=QR_MODE_NUM; i<=QR_MODE_KANJI; i++) { if(i != QR_MODE_KANJI) { - memset(data, '0', maxlength[i][0]); + memset(data, '0', maxlength[i][0] + 1); } else { - for(l=0; l<=maxlength[i][0]/2; l++) { + for(l=0; l<=maxlength[i][0]/2+1; l++) { data[l*2] = 0x93; data[l*2+1] = 0x5f; } } -- cgit 0.0.5-2-1-g0f52 From d76c9a647dc1f2a499cdd78c12db8dea80b2da4a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 27 Oct 2013 10:50:55 +0900 Subject: Bug in QRinput_insertFNC1Header() has been fixed. (Thanks to David Binderman) --- ChangeLog | 5 +++++ README | 2 +- qrinput.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65d3a70c4c..ec4d7b009c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013.10.27 Kentaro FUKUCHI + * qrinput.c: + - Bug in QRinput_insertFNC1Header() has been fixed. (Thanks to David + Binderman) + 2013.09.08 Kentaro FUKUCHI * tests/test_qrencode.c: - Small bug fix. diff --git a/README b/README index 9623ce033d..a8caf65883 100644 --- a/README +++ b/README @@ -140,5 +140,5 @@ Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option, some bug fixes. Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, -Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen +Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman - bug report / suggestion diff --git a/qrinput.c b/qrinput.c index 1b9182d095..3f31336f8a 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1243,7 +1243,7 @@ static int QRinput_insertFNC1Header(QRinput *input) return -1; } - if(input->head->mode != QR_MODE_STRUCTURE || input->head->mode != QR_MODE_ECI) { + if(input->head->mode != QR_MODE_STRUCTURE && input->head->mode != QR_MODE_ECI) { entry->next = input->head; input->head = entry; } else { -- cgit 0.0.5-2-1-g0f52 From c3af4c44be2b6ce8757eb0e1097f97c1e269da95 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 27 Oct 2013 11:44:26 +0900 Subject: Code cleanup. --- qrinput.c | 10 ++++++---- tests/decoder.c | 2 +- tests/decoder.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qrinput.c b/qrinput.c index 3f31336f8a..f2daa1d8f9 100644 --- a/qrinput.c +++ b/qrinput.c @@ -732,10 +732,12 @@ static int QRinput_checkModeFNC1Second(int size, const unsigned char *data) { if(size != 1) return -1; + /* No data check required. */ + return 0; } -static int QRinput_encodeModeFNC1Second(QRinput_List *entry, BitStream *bstream, int version) +static int QRinput_encodeModeFNC1Second(QRinput_List *entry, BitStream *bstream) { int ret; @@ -781,7 +783,7 @@ int QRinput_estimateBitsModeECI(unsigned char *data) } } -static int QRinput_encodeModeECI(QRinput_List *entry, BitStream *bstream, int version) +static int QRinput_encodeModeECI(QRinput_List *entry, BitStream *bstream) { int ret, words; unsigned int ecinum, code; @@ -1041,10 +1043,10 @@ static int QRinput_encodeBitStream(QRinput_List *entry, BitStream *bstream, int ret = QRinput_encodeModeStructure(entry, bstream, mqr); break; case QR_MODE_ECI: - ret = QRinput_encodeModeECI(entry, bstream, version); + ret = QRinput_encodeModeECI(entry, bstream); break; case QR_MODE_FNC1SECOND: - ret = QRinput_encodeModeFNC1Second(entry, bstream, version); + ret = QRinput_encodeModeFNC1Second(entry, bstream); break; default: break; diff --git a/tests/decoder.c b/tests/decoder.c index cf3bc68a3e..4d7c109bb6 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -558,7 +558,7 @@ void QRdata_dump(QRdata *data) dumpChunks(data); } -unsigned int QRcode_decodeVersion(QRcode *code) +int QRcode_decodeVersion(QRcode *code) { unsigned int v1, v2; int x, y, width; diff --git a/tests/decoder.h b/tests/decoder.h index 81388e3f9b..afff7764b6 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -33,7 +33,7 @@ int QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream); void QRdata_dump(QRdata *data); void QRdata_free(QRdata *data); -unsigned int QRcode_decodeVersion(QRcode *code); +int QRcode_decodeVersion(QRcode *code); int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask); unsigned char *QRcode_unmask(QRcode *code); unsigned char *QRcode_extractBits(QRcode *code, int *length); -- cgit 0.0.5-2-1-g0f52 From bae0edb8bb9af101b0f2c9e1c6045866fe13d881 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 27 Oct 2013 12:16:35 +0900 Subject: Previous commit log appended. --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index ec4d7b009c..0252d37cec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * qrinput.c: - Bug in QRinput_insertFNC1Header() has been fixed. (Thanks to David Binderman) + * qrinput.c, test/decoder.[ch]: + - Code cleanup. 2013.09.08 Kentaro FUKUCHI * tests/test_qrencode.c: -- cgit 0.0.5-2-1-g0f52 From 30753cd7def484097a4901630b9a6b552e100645 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 4 Jan 2014 18:41:00 +0900 Subject: Code cleanups. --- ChangeLog | 4 ++++ rsecc.c | 22 +++++++++++----------- rsecc.h | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0252d37cec..fd717c1d6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.01.04 Kentaro FUKUCHI + * rsecc.[ch]: + - Code cleanups. + 2013.10.27 Kentaro FUKUCHI * qrinput.c: - Bug in QRinput_insertFNC1Header() has been fixed. (Thanks to David diff --git a/rsecc.c b/rsecc.c index cf67d3f08d..e1db33a53e 100644 --- a/rsecc.c +++ b/rsecc.c @@ -97,7 +97,7 @@ static void generator_init(int length) generatorInitialized[length - min_length] = 1; } -int RSECC_encode(int datalength, int ecclength, const unsigned char *data, unsigned char *ecc) +int RSECC_encode(int data_length, int ecc_length, const unsigned char *data, unsigned char *ecc) { int i, j; unsigned char feedback; @@ -107,24 +107,24 @@ int RSECC_encode(int datalength, int ecclength, const unsigned char *data, unsig RSECC_init(); } - if(ecclength > max_length) return -1; + if(ecc_length > max_length) return -1; - memset(ecc, 0, ecclength); - if(!generatorInitialized[ecclength - min_length]) generator_init(ecclength); - gen = generator[ecclength - min_length]; + memset(ecc, 0, ecc_length); + if(!generatorInitialized[ecc_length - min_length]) generator_init(ecc_length); + gen = generator[ecc_length - min_length]; - for(i = 0; i < datalength; i++) { + for(i = 0; i < data_length; i++) { feedback = aindex[data[i] ^ ecc[0]]; if(feedback != symbols) { - for(j = 1; j < ecclength; j++) { - ecc[j] ^= alpha[(feedback + gen[ecclength - j]) % symbols]; + for(j = 1; j < ecc_length; j++) { + ecc[j] ^= alpha[(feedback + gen[ecc_length - j]) % symbols]; } } - memmove(&ecc[0], &ecc[1], ecclength - 1); + memmove(&ecc[0], &ecc[1], ecc_length - 1); if(feedback != symbols) { - ecc[ecclength - 1] = alpha[(feedback + gen[0]) % symbols]; + ecc[ecc_length - 1] = alpha[(feedback + gen[0]) % symbols]; } else { - ecc[ecclength - 1] = 0; + ecc[ecc_length - 1] = 0; } } diff --git a/rsecc.h b/rsecc.h index a6cf86e9d5..e5efd8446d 100644 --- a/rsecc.h +++ b/rsecc.h @@ -3,7 +3,7 @@ * * Reed solomon error correction code encoder specialized for QR code. * - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2013 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -23,6 +23,6 @@ #ifndef __RSECC_H__ #define __RSECC_H__ -extern int RSECC_encode(int datalength, int ecclength, const unsigned char *data, unsigned char *ecc); +extern int RSECC_encode(int data_length, int ecc_length, const unsigned char *data, unsigned char *ecc); #endif /* __RSECC_H__ */ -- cgit 0.0.5-2-1-g0f52 From c9fb08cf11bac034993dc18f086ea3b6abb96693 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Fri, 10 Jan 2014 12:25:33 +0100 Subject: commandline argument --help and -V is printed to stdout, instead of stderr. --- qrenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qrenc.c b/qrenc.c index 040959d41d..253d0cbac2 100644 --- a/qrenc.c +++ b/qrenc.c @@ -86,12 +86,12 @@ static char *optstring = "ho:l:s:v:m:d:t:Skci8MV"; static void usage(int help, int longopt) { - fprintf(stderr, + fprintf(stdout, "qrencode version %s\n" "Copyright (C) 2006-2013 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { if(longopt) { - fprintf(stderr, + fprintf(stdout, "Usage: qrencode [OPTION]... [STRING]\n" "Encode input data in a QR Code and save as a PNG or EPS image.\n\n" " -h, --help display the help message. -h displays only the help of short\n" @@ -135,7 +135,7 @@ static void usage(int help, int longopt) " standard input.\n" ); } else { - fprintf(stderr, + fprintf(stdout, "Usage: qrencode [OPTION]... [STRING]\n" "Encode input data in a QR Code and save as a PNG or EPS image.\n\n" " -h display this message.\n" -- cgit 0.0.5-2-1-g0f52 From dd39c4b9009050a32283a6dc745461370367bf1e Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Fri, 10 Jan 2014 14:37:29 +0100 Subject: EXIT_FAILURE is returned at argc == 1. Just in case that qrencode is used in a shell script. error message instead of usage(1,0). --- qrenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 253d0cbac2..d09bd51a63 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1101,8 +1101,8 @@ int main(int argc, char **argv) } if(argc == 1) { - usage(1, 0); - exit(EXIT_SUCCESS); + fprintf(stderr, "Try `qrencode --help' for more information.\n"); + exit(EXIT_FAILURE); } if(outfile == NULL && image_type == PNG_TYPE) { -- cgit 0.0.5-2-1-g0f52 From 3be2a613799e13a4755d483061d23fb6abcbd467 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Fri, 10 Jan 2014 21:21:34 +0100 Subject: "usage" function distinguishes between explicit call and a wrong usage. explicit = stdout. else = stderr --- qrenc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qrenc.c b/qrenc.c index d09bd51a63..f6900a4ff8 100644 --- a/qrenc.c +++ b/qrenc.c @@ -84,14 +84,15 @@ static const struct option options[] = { static char *optstring = "ho:l:s:v:m:d:t:Skci8MV"; -static void usage(int help, int longopt) +static void usage(int help, int longopt, int status) { - fprintf(stdout, + FILE *out = status ? stderr : stdout; + fprintf(out, "qrencode version %s\n" "Copyright (C) 2006-2013 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { if(longopt) { - fprintf(stdout, + fprintf(out, "Usage: qrencode [OPTION]... [STRING]\n" "Encode input data in a QR Code and save as a PNG or EPS image.\n\n" " -h, --help display the help message. -h displays only the help of short\n" @@ -135,7 +136,7 @@ static void usage(int help, int longopt) " standard input.\n" ); } else { - fprintf(stdout, + fprintf(out, "Usage: qrencode [OPTION]... [STRING]\n" "Encode input data in a QR Code and save as a PNG or EPS image.\n\n" " -h display this message.\n" @@ -969,9 +970,9 @@ int main(int argc, char **argv) switch(opt) { case 'h': if(lindex == 0) { - usage(1, 1); + usage(1, 1, EXIT_SUCCESS); } else { - usage(1, 0); + usage(1, 0, EXIT_SUCCESS); } exit(EXIT_SUCCESS); break; @@ -1088,7 +1089,7 @@ int main(int argc, char **argv) } break; case 'V': - usage(0, 0); + usage(0, 0, EXIT_SUCCESS); exit(EXIT_SUCCESS); break; case 0: @@ -1101,7 +1102,7 @@ int main(int argc, char **argv) } if(argc == 1) { - fprintf(stderr, "Try `qrencode --help' for more information.\n"); + usage(1, 0, EXIT_FAILURE); exit(EXIT_FAILURE); } -- cgit 0.0.5-2-1-g0f52 From 839f1a9d141df7553cd8a0e33fbe490844a91362 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Fri, 10 Jan 2014 22:45:42 +0100 Subject: New travis.yml file to get CI started. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..789cad43fd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: c +compiler: + - gcc +script: ./configure --with-tests && make -- cgit 0.0.5-2-1-g0f52 From fb72fdf2f27aad6740abdb8ddd9e61015704aa54 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Fri, 10 Jan 2014 23:06:40 +0100 Subject: Added autogen.sh to script --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 789cad43fd..2ecd962e35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: c compiler: - gcc -script: ./configure --with-tests && make +script: +- ./autogen.sh +- ./configure --with-tests && make -- cgit 0.0.5-2-1-g0f52 From ae7ada22195b614892c13b06bccc819c80d335ac Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Fri, 10 Jan 2014 23:46:50 +0100 Subject: Added installl instructions apt-get install libsdl and libpng Added sudo make install --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2ecd962e35..4af95662b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: c compiler: - gcc +install +- apt-get install libsdl1.2-dev libpng12-dev script: - ./autogen.sh - ./configure --with-tests && make +- sudo make install + -- cgit 0.0.5-2-1-g0f52 From 84f9fba2a54e6fcf3be5d1039dd79682cfd2638f Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Fri, 10 Jan 2014 23:52:59 +0100 Subject: fix : --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4af95662b2..f5d2e03f9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: c compiler: - gcc -install +install: - apt-get install libsdl1.2-dev libpng12-dev script: - ./autogen.sh -- cgit 0.0.5-2-1-g0f52 From b4f3fba848c08a400864a89144f5f9123b6e6797 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 00:00:12 +0100 Subject: installing libsdl2-dev --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f5d2e03f9e..17502a057c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,8 @@ language: c compiler: - gcc install: -- apt-get install libsdl1.2-dev libpng12-dev +- apt-get install libsdl2-dev +- apt-get install libpng12-dev script: - ./autogen.sh - ./configure --with-tests && make -- cgit 0.0.5-2-1-g0f52 From 53c29cf26398a47e19c7ff15e0928388e8635fe1 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 00:07:10 +0100 Subject: sudo needed for apt-get install --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17502a057c..d5978b5068 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ language: c compiler: - gcc install: -- apt-get install libsdl2-dev -- apt-get install libpng12-dev +- sudo apt-get install libsdl2-dev +- sudo apt-get install libpng12-dev script: - ./autogen.sh - ./configure --with-tests && make -- cgit 0.0.5-2-1-g0f52 From bf53f8a9b5f10ffd387c60615777acca96de4cc9 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 00:12:54 +0100 Subject: run apt-get update first --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5978b5068..c66fd069de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,10 @@ language: c compiler: - gcc install: -- sudo apt-get install libsdl2-dev +- sudo apt-get update +- sudo apt-get install libsdl-image1.2-dev - sudo apt-get install libpng12-dev -script: +script: - ./autogen.sh - ./configure --with-tests && make - sudo make install - -- cgit 0.0.5-2-1-g0f52 From f7a6a76ee6dda797d6335f4ff3bda8c75b6017ca Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 00:24:17 +0100 Subject: Added before_script and script: to test build. --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c66fd069de..7b04a07978 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,14 @@ install: - sudo apt-get update - sudo apt-get install libsdl-image1.2-dev - sudo apt-get install libpng12-dev -script: - ./autogen.sh - ./configure --with-tests && make - sudo make install +before_script: +- cd ./tests +- ./create_frame_pattern frame +script: +- cd ./tests +- ./test_configure.sh +- ./test_configure.sh + -- cgit 0.0.5-2-1-g0f52 From ededb10552a152702573cade6eeebde416234029 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 00:33:59 +0100 Subject: cd to full path now --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b04a07978..f3e9644669 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ install: - ./configure --with-tests && make - sudo make install before_script: -- cd ./tests +- cd /home/travis/libqrencode/tests - ./create_frame_pattern frame script: -- cd ./tests -- ./test_configure.sh +- cd /home/travis/libqrencode/tests - ./test_configure.sh +- ./test_all.sh -- cgit 0.0.5-2-1-g0f52 From 88ed77a67312472526b21abaf798f69ed38de91d Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 01:01:26 +0100 Subject: Cahnged full path --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3e9644669..81114f971a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ install: - ./configure --with-tests && make - sudo make install before_script: -- cd /home/travis/libqrencode/tests +- cd /home/travis/build/d4ndo/libqrencode/tests - ./create_frame_pattern frame script: -- cd /home/travis/libqrencode/tests +- cd /home/travis/build/d4ndo/libqrencode/tests - ./test_configure.sh - ./test_all.sh -- cgit 0.0.5-2-1-g0f52 From 0c0fa5f10f136cc0a3c94f5563e67d8e0aeab4d9 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 01:07:28 +0100 Subject: Removed apt-get update. Just to get sure it is needed to install libsdl. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 81114f971a..ca58673543 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: c compiler: - gcc install: -- sudo apt-get update - sudo apt-get install libsdl-image1.2-dev - sudo apt-get install libpng12-dev - ./autogen.sh -- cgit 0.0.5-2-1-g0f52 From c0d5a8c10396685f5f539c40c94bf72cdeccddf0 Mon Sep 17 00:00:00 2001 From: Daniel Dörrhöfer Date: Sat, 11 Jan 2014 01:20:34 +0100 Subject: Update README --- README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README b/README index a8caf65883..00267a3d5f 100644 --- a/README +++ b/README @@ -1,5 +1,7 @@ libqrencode 3.4.3 - QR Code encoding library +!https://travis-ci.org/d4ndo/libqrencode.png?branch=travis!:https://travis-ci.org/d4ndo/libqrencode + GENERAL INFORMATION =================== Libqrencode is a library for encoding data in a QR Code symbol, a 2D symbology -- cgit 0.0.5-2-1-g0f52 From 50a9db39e346e12492b250841088ca9c34bb4329 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 01:35:24 +0100 Subject: Added apt-get update again. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ca58673543..81114f971a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: c compiler: - gcc install: +- sudo apt-get update - sudo apt-get install libsdl-image1.2-dev - sudo apt-get install libpng12-dev - ./autogen.sh -- cgit 0.0.5-2-1-g0f52 From 48f813b7e504b1e4868dacdde901217768f471b3 Mon Sep 17 00:00:00 2001 From: Daniel Dörrhöfer Date: Sat, 11 Jan 2014 01:38:04 +0100 Subject: Update README --- README | 2 -- 1 file changed, 2 deletions(-) diff --git a/README b/README index 00267a3d5f..a8caf65883 100644 --- a/README +++ b/README @@ -1,7 +1,5 @@ libqrencode 3.4.3 - QR Code encoding library -!https://travis-ci.org/d4ndo/libqrencode.png?branch=travis!:https://travis-ci.org/d4ndo/libqrencode - GENERAL INFORMATION =================== Libqrencode is a library for encoding data in a QR Code symbol, a 2D symbology -- cgit 0.0.5-2-1-g0f52 From ca6111c36d368d913ea1e3344b9921d402c9efbc Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 12:53:20 +0100 Subject: changed /home/travis by ~. added pwd to get some debug output. --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 81114f971a..0b35afad79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,12 @@ install: - ./configure --with-tests && make - sudo make install before_script: -- cd /home/travis/build/d4ndo/libqrencode/tests +- pwd +- cd ~/build/d4ndo/libqrencode/tests - ./create_frame_pattern frame script: -- cd /home/travis/build/d4ndo/libqrencode/tests +- pwd +- cd ~/build/d4ndo/libqrencode/tests - ./test_configure.sh - ./test_all.sh -- cgit 0.0.5-2-1-g0f52 From ce95263f989957f0160152c52500b9df94e8ca1b Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 12:58:09 +0100 Subject: Using cd tests now. --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0b35afad79..c4f08767aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,11 @@ install: - ./configure --with-tests && make - sudo make install before_script: -- pwd -- cd ~/build/d4ndo/libqrencode/tests +- cd tests - ./create_frame_pattern frame script: - pwd -- cd ~/build/d4ndo/libqrencode/tests +- cd tests - ./test_configure.sh - ./test_all.sh -- cgit 0.0.5-2-1-g0f52 From 2271d73884f65d0c014f7098ba43f99e76538aa4 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 13:22:41 +0100 Subject: using cd tests in before_test: only. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4f08767aa..e1c7533c17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,6 @@ before_script: - cd tests - ./create_frame_pattern frame script: -- pwd -- cd tests - ./test_configure.sh - ./test_all.sh -- cgit 0.0.5-2-1-g0f52 From b0ca024d0f9b8ff9612f2624108b952f421b6f9b Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 13:45:37 +0100 Subject: Removed trailing whitespace --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e1c7533c17..fa506a1925 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,3 @@ before_script: script: - ./test_configure.sh - ./test_all.sh - -- cgit 0.0.5-2-1-g0f52 From fd06dd54ce1d02038a2ce29a8d9f319193967bda Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Sat, 11 Jan 2014 16:12:42 +0100 Subject: Try clang compiler. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fa506a1925..4b23a5d04f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: c compiler: - gcc + - clang install: - sudo apt-get update - sudo apt-get install libsdl-image1.2-dev -- cgit 0.0.5-2-1-g0f52 From d7066c29abe99d9a3726da4bb3bbda0003b07e13 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 15 Jan 2014 01:32:31 +0900 Subject: Usage modified. --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index f6900a4ff8..31dfbfd3de 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1095,7 +1095,7 @@ int main(int argc, char **argv) case 0: break; default: - fprintf(stderr, "Try `qrencode --help' for more information.\n"); + fprintf(stderr, "Try \"qrencode --help\" for more information.\n"); exit(EXIT_FAILURE); break; } -- cgit 0.0.5-2-1-g0f52 From 2e366cdf31604098ad9a73b16cba6de1b1ed3b36 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 15 Jan 2014 01:34:11 +0900 Subject: Contributors list updated. --- README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README b/README index a8caf65883..94c88fc4a1 100644 --- a/README +++ b/README @@ -140,5 +140,6 @@ Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option, some bug fixes. Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, -Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman +Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, +ralgozino - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 3d13c6cc4d81c5037811c6d78fc6d6ec3226569d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 15 Jan 2014 01:36:04 +0900 Subject: merged 78d44fd. --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index fd717c1d6b..0e7112da9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014.01.15 Kentaro FUKUCHI + * qrenc.c: + - Merged pull request 78d44fd - commandline argument --help and -V is + printed to stdout, instead of stderr. + 2014.01.04 Kentaro FUKUCHI * rsecc.[ch]: - Code cleanups. -- cgit 0.0.5-2-1-g0f52 From d6d47655f302325d547886fd4d8fee59497d1a38 Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Tue, 28 Jan 2014 12:15:12 +0100 Subject: clang compiler removed from test for the time beeing. --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b23a5d04f..ea90e8a128 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: c + compiler: - - gcc - - clang +- gcc + install: - sudo apt-get update - sudo apt-get install libsdl-image1.2-dev @@ -9,9 +10,11 @@ install: - ./autogen.sh - ./configure --with-tests && make - sudo make install + before_script: - cd tests - ./create_frame_pattern frame + script: - ./test_configure.sh - ./test_all.sh -- cgit 0.0.5-2-1-g0f52 From 9f737d734f0bb8dc6719447a9e3dc9aab771dc9f Mon Sep 17 00:00:00 2001 From: doerrhoefer Date: Tue, 28 Jan 2014 12:24:06 +0100 Subject: yet another test. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ea90e8a128..57935372df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: c - + compiler: - gcc -- cgit 0.0.5-2-1-g0f52 From 385015e518e873b0e80b0a83b8715c93e6f277d0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 9 Feb 2014 21:32:53 +0900 Subject: Merged pull-request #40. --- ChangeLog | 4 ++++ README | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0e7112da9d..7a1d790916 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.02.09 Kentaro FUKUCHI + * .travis.yaml: + - Configuration file for Travis CI. (Thanks to Danil Dörrhöfer) + 2014.01.15 Kentaro FUKUCHI * qrenc.c: - Merged pull request 78d44fd - commandline argument --help and -V is diff --git a/README b/README index 94c88fc4a1..d7acbc13ad 100644 --- a/README +++ b/README @@ -137,7 +137,7 @@ Lennart Poettering (mezcalero) - improved text art patch Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting -Daniel Dörrhöfer - RLE option, some bug fixes. +Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -- cgit 0.0.5-2-1-g0f52 From 07747c579664e5b24da8d7e1ea27f9850e8ae58b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 9 Feb 2014 21:34:33 +0900 Subject: Fixed some warnings. --- ChangeLog | 2 ++ configure.ac | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a1d790916..34f75d310e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2014.02.09 Kentaro FUKUCHI * .travis.yaml: - Configuration file for Travis CI. (Thanks to Danil Dörrhöfer) + * configure.ac: + - Fixed some warnings. 2014.01.15 Kentaro FUKUCHI * qrenc.c: diff --git a/configure.ac b/configure.ac index badcafdb4e..6eaaf726bc 100644 --- a/configure.ac +++ b/configure.ac @@ -1,13 +1,15 @@ -AC_INIT(QRencode) - -MAJOR_VERSION=3 -MINOR_VERSION=9 -MICRO_VERSION=0 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION +m4_define([__MAJOR_VERSION], [3])dnl +m4_define([__MINOR_VERSION], [9])dnl +m4_define([__MICRO_VERSION], [0])dnl +m4_define([__VERSION], [__MAJOR_VERSION.__MINOR_VERSION.__MICRO_VERSION])dnl +AC_INIT(QRencode, __VERSION) + +MAJOR_VERSION=__MAJOR_VERSION +MINOR_VERSION=__MINOR_VERSION +MICRO_VERSION=__MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) AC_SUBST(MICRO_VERSION) -AC_SUBST(VERSION) AC_DEFINE_UNQUOTED([MAJOR_VERSION], [$MAJOR_VERSION], [Major version number]) AC_DEFINE_UNQUOTED([MINOR_VERSION], [$MINOR_VERSION], [Minor version number]) AC_DEFINE_UNQUOTED([MICRO_VERSION], [$MICRO_VERSION], [Micro version number]) @@ -19,7 +21,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CANONICAL_HOST AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE(qrencode, $VERSION) +AM_INIT_AUTOMAKE AC_DISABLE_STATIC AC_C_CONST -- cgit 0.0.5-2-1-g0f52 From cebe8f3dd9d9f17f2df709d7e9160b7efc045a22 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 9 Feb 2014 21:34:52 +0900 Subject: New README for Github. --- README.md | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..85f5e14de4 --- /dev/null +++ b/README.md @@ -0,0 +1,145 @@ +# libqrencode 3.4.3 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) + +GENERAL INFORMATION +=================== +Libqrencode is a library for encoding data in a QR Code symbol, a 2D symbology +that can be scanned by handy terminals such as a mobile phone with CCD. The +capacity of QR Code is up to 7000 digits or 4000 characters and has high +robustness. + +Libqrencode accepts a string or a list of data chunks then encodes in a QR Code +symbol as a bitmap array. While other QR Code applications generate an image +file, using libqrencode allows applications to render QR Code symbols from raw +bitmap data directly. This library also contains a command-line utility outputs +a QR Code symbol as a PNG image. + + +SPECIFICATION +============= +Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial +Standards) X0510:2004 or ISO/IEC 18004. Most of features in the specification +are implemented such as: +- Numeric, alphabet, Japanese kanji (Shift-JIS) or any 8 bit code can be + embedded +- Optimized encoding of a string +- Structured-append of symbols +- Micro QR Code (experimental) + +Currently the following features are not supported: +- ECI and FNC1 mode +- QR Code model 1 (deprecated) + + +INSTALL +======= + +Requirements +------------ +Some test programs or utility tools uses SDL or PNG, but the library itself +has no dependencies. You can skip compiling those tools if you want not to +install programs using SDL or PNG. + +Compile & install +----------------- +Just try + +./configure +make +make install + +This compiles and installs the library and header file to the appropriate +directories. By default, /usr/local/lib and /usr/local/include. You can change +the destination directory by passing some options to the configure script. +Run "./configure --help" to see the list of options. + +It also installs a binary "qrencode" to /usr/local/bin. If you want not to +install it, give "--without-tools" option to the configure script. + +When you downloaded a development tree from github, it is required to run +"autogen.sh" at first to generate configure script. + + +USAGE +===== +Basic usages of this library are written in the header file (qrencode.h). +You can generate a manual of the library by using Doxygen. + + +WARNINGS +======== +The library is distributed WITHOUT ANY WRRANTY. + +Micro QR Code support is EXPERIMENTAL. + +Be careful to use the command line tool (qrencode) if it is used by a web +application (e.g. CGI script). For example, giving "-s" option with a large +number to qrencode may cause DoS. The parameters should be checked by the +application. + + +LICENSING INFORMATION +===================== +Copyright (C) 2006-2012 Kentaro Fukuchi + +This library is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free +Software Foundation; either version 2.1 of the License, or any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this library; if not, write to the Free Software Foundation, Inc., 51 +Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +CONTACT +======= +Visit the homepage at: + +http://fukuchi.org/works/qrencode/ + +for new releases. The git repository is available at: + +https://github.com/fukuchi/libqrencode + +Please mail any bug reports, suggestions, comments, and questions to: + +Kentaro Fukuchi + +or submit issues to: + +https://github.com/fukuchi/libqrencode/issues + +Questions of license compliance are also welcome. + + +ACKNOWLEDGMENTS +=============== +QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other +countries. + +Reed-Solomon encoder is written by Phil Karn, KA9Q. +Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q + +NANKI Haruo - improved lower-case characteres encoding +Philippe Delcroix - improved mask evaluation +Yusuke Mihara - structured-append support +David Dahl - DPI and SVG support patch +Adam Shepherd - bug fix patch of the mask evaluation +Josef Eisl (zapster) - EPS support patch +Colin (moshen) - ANSI support patch +Ralf Ertzinger - ASCII support patch +Yutaka Niibe (gniibe) - various bug fix patches +Dan Storm (Repox) - SVG support patch +Lennart Poettering (mezcalero) + - improved text art patch +Yann Droneaud - improved input validation patch +Viona - bug fix patch for string splitting +Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration +Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, +Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, +Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, +ralgozino + - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 85929492e1b790e01a76bd2ae004310b9e1d2b6a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 9 Feb 2014 21:40:47 +0900 Subject: More markdowns. --- README.md | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 85f5e14de4..183caa87e4 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,11 @@ Compile & install ----------------- Just try +``` ./configure make make install +``` This compiles and installs the library and header file to the appropriate directories. By default, /usr/local/lib and /usr/local/include. You can change @@ -123,23 +125,18 @@ countries. Reed-Solomon encoder is written by Phil Karn, KA9Q. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q -NANKI Haruo - improved lower-case characteres encoding -Philippe Delcroix - improved mask evaluation -Yusuke Mihara - structured-append support -David Dahl - DPI and SVG support patch -Adam Shepherd - bug fix patch of the mask evaluation -Josef Eisl (zapster) - EPS support patch -Colin (moshen) - ANSI support patch -Ralf Ertzinger - ASCII support patch -Yutaka Niibe (gniibe) - various bug fix patches -Dan Storm (Repox) - SVG support patch -Lennart Poettering (mezcalero) - - improved text art patch -Yann Droneaud - improved input validation patch -Viona - bug fix patch for string splitting -Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration -Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, -Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, -Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino - - bug report / suggestion +- NANKI Haruo - improved lower-case characteres encoding +- Philippe Delcroix - improved mask evaluation +- Yusuke Mihara - structured-append support +- David Dahl - DPI and SVG support patch +- Adam Shepherd - bug fix patch of the mask evaluation +- Josef Eisl (zapster) - EPS support patch +- Colin (moshen) - ANSI support patch +- Ralf Ertzinger - ASCII support patch +- Yutaka Niibe (gniibe) - various bug fix patches +- Dan Storm (Repox) - SVG support patch +- Lennart Poettering (mezcalero) - improved text art patch +- Yann Droneaud - improved input validation patch +- Viona - bug fix patch for string splitting +- Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration +- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 5914c0cd9f78321e378284cc09f451f8900bbf73 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 14 Feb 2014 09:01:15 +0900 Subject: Messages improved. --- ChangeLog | 6 ++++++ README | 2 +- qrenc.c | 15 ++++++++++++--- qrinput.c | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34f75d310e..bf8b138bc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014.02.14 Kentaro FUKUCHI + * qrinput.c: + - Minor documentation fix. + * qrenc.c: + - Error message improved. + 2014.02.09 Kentaro FUKUCHI * .travis.yaml: - Configuration file for Travis CI. (Thanks to Danil Dörrhöfer) diff --git a/README b/README index d7acbc13ad..78d4ce141a 100644 --- a/README +++ b/README @@ -141,5 +141,5 @@ Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino +ralgozino, Sean McMurray - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index 31dfbfd3de..753c05b132 100644 --- a/qrenc.c +++ b/qrenc.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "qrencode.h" @@ -89,7 +90,7 @@ static void usage(int help, int longopt, int status) FILE *out = status ? stderr : stdout; fprintf(out, "qrencode version %s\n" -"Copyright (C) 2006-2013 Kentaro Fukuchi\n", QRcode_APIVersionString()); +"Copyright (C) 2006-2014 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { if(longopt) { fprintf(out, @@ -803,7 +804,11 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil qrcode = encode(intext, length); if(qrcode == NULL) { - perror("Failed to encode the input data"); + if(errno == ERANGE) { + fprintf(stderr, "Failed to encode the input data: Input data too large\n"); + } else { + perror("Failed to encode the input data"); + } exit(EXIT_FAILURE); } switch(image_type) { @@ -903,7 +908,11 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch qrlist = encodeStructured(intext, length); if(qrlist == NULL) { - perror("Failed to encode the input data"); + if(errno == ERANGE) { + fprintf(stderr, "Failed to encode the input data: Input data too large\n"); + } else { + perror("Failed to encode the input data"); + } exit(EXIT_FAILURE); } diff --git a/qrinput.c b/qrinput.c index f2daa1d8f9..de8c942120 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1095,7 +1095,7 @@ static int QRinput_createBitStream(QRinput *input, BitStream *bstream) * @retval -1 an error occurred and errno is set to indeicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. - * @throw ERANGE input is too large. + * @throw ERANGE input data is too large. */ static int QRinput_convertData(QRinput *input, BitStream *bstream) { -- cgit 0.0.5-2-1-g0f52 From e3f473fbfbbc9d7e88becca364e59980738583c5 Mon Sep 17 00:00:00 2001 From: "antenore@simbiosi.org" Date: Fri, 28 Feb 2014 09:26:27 +0100 Subject: Updated qrencode documentation, adding SYMBOL VERSIONS section --- qrenc.c | 8 +++++++- qrencode.1.in | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index 753c05b132..19ca43877f 100644 --- a/qrenc.c +++ b/qrenc.c @@ -109,7 +109,7 @@ static void usage(int help, int longopt, int status) " specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n\n" " -v NUMBER, --symversion=NUMBER\n" -" specify the version of the symbol. (default=auto)\n\n" +" specify the version of the symbol. (default=auto) See SYMBOL VERSIONS for more information\n\n" " -m NUMBER, --margin=NUMBER\n" " specify the width of the margins. (default=4 (2 for Micro)))\n\n" " -d NUMBER, --dpi=NUMBER\n" @@ -135,6 +135,12 @@ static void usage(int help, int longopt, int status) " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" " standard input.\n" +" [SYMBOL VERSIONS] The symbol versions of QR Code range from Version 1 to Version 40.\n" +" Each version has a different module configuration or number of modules,\n" +" ranging from Version 1 (21 × 21 modules) up to Version 40 (177 × 177 modules).\n" +" Each higher version number comprises 4 additional modules per side.\n" +" See http://www.qrcode.com/en/about/version.html for a detailed version list.\n" + ); } else { fprintf(out, diff --git a/qrencode.1.in b/qrencode.1.in index 3576c6d1e4..49044738d8 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -30,7 +30,7 @@ specify the size of dot (pixel). (default=3) specify error collectin level from L (lowest) to H (highest). (default=L) .TP .B \-v NUMBER, \-\-symversion=NUMBER -specify the version of the symbol. (default=auto) +specify the version of the symbol. (default=auto).See SYMBOL VERSIONS for more information .TP .B \-m NUMBER, \-\-margin=NUMBER specify the width of margin. (default=4) @@ -77,6 +77,13 @@ display the version number and copyrights of the qrencode. .TP .B [STRING] input data. If it is not specified, data will be taken from standard input. +.TP +.B [SYMBOL VERSIONS] +The symbol versions of QR Code range from Version 1 to Version 40. +Each version has a different module configuration or number of modules, +ranging from Version 1 (21 × 21 modules) up to Version 40 (177 × 177 modules). +Each higher version number comprises 4 additional modules per side. +See http://www.qrcode.com/en/about/version.html for a detailed version list. .SH EXAMPLES .TP @@ -86,6 +93,9 @@ encode into a symbol version 1, level L. .B qrencode \-iSv 1 \-\-output=output.png read standard input and encode it into a structured-appended symbols in case-insensitive mode. +.TP +.B cat bigfile.txt | qrencode \-S -v 40 \-l L \-o output.png +encode into a symbol version 40, level L. .SH AUTHOR Written by Kentaro Fukuchi. -- cgit 0.0.5-2-1-g0f52 From 42d671278982402d70995fab6b12bc383faeca21 Mon Sep 17 00:00:00 2001 From: "antenore@simbiosi.org" Date: Fri, 28 Feb 2014 09:27:05 +0100 Subject: Quick installation howto for linux --- README.Linux | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 README.Linux diff --git a/README.Linux b/README.Linux new file mode 100644 index 0000000000..2bf62ca169 --- /dev/null +++ b/README.Linux @@ -0,0 +1,8 @@ +INSTALLATION +============ +``` +autoreconf -vfi +./autogen.sh +./configure +make && sudo make install +``` -- cgit 0.0.5-2-1-g0f52 From 33ac4616eca0c5cfb63da4206930a40e3f687107 Mon Sep 17 00:00:00 2001 From: "antenore@simbiosi.org" Date: Fri, 28 Feb 2014 09:32:30 +0100 Subject: Updated qrencode documentation, adding SYMBOL VERSIONS section --- qrencode.1.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrencode.1.in b/qrencode.1.in index 49044738d8..5e666570b8 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -94,7 +94,7 @@ encode into a symbol version 1, level L. read standard input and encode it into a structured-appended symbols in case-insensitive mode. .TP -.B cat bigfile.txt | qrencode \-S -v 40 \-l L \-o output.png +.B cat bigfile.txt | qrencode \-S \-v 40 \-l L \-o output.png encode into a symbol version 40, level L. .SH AUTHOR -- cgit 0.0.5-2-1-g0f52 From 67a410437ab3b1d37b3d67e41eaeaf02abfbc673 Mon Sep 17 00:00:00 2001 From: "antenore@simbiosi.org" Date: Fri, 28 Feb 2014 14:52:54 +0100 Subject: Updated qrencode documentation --- README.Linux | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 README.Linux diff --git a/README.Linux b/README.Linux deleted file mode 100644 index 2bf62ca169..0000000000 --- a/README.Linux +++ /dev/null @@ -1,8 +0,0 @@ -INSTALLATION -============ -``` -autoreconf -vfi -./autogen.sh -./configure -make && sudo make install -``` -- cgit 0.0.5-2-1-g0f52 From 4b03628bf20f6aeba6df5648052dcde5b6846c0e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 16 Apr 2014 16:31:19 +0200 Subject: Check return value of BitStream_expand --- bitstream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bitstream.c b/bitstream.c index db93d610ed..33d17a3b20 100644 --- a/bitstream.c +++ b/bitstream.c @@ -105,6 +105,8 @@ static void BitStream_writeBytes(unsigned char *dest, int size, unsigned char *d int BitStream_append(BitStream *bstream, BitStream *arg) { + int ret; + if(arg == NULL) { return -1; } @@ -113,7 +115,8 @@ int BitStream_append(BitStream *bstream, BitStream *arg) } while(bstream->length + arg->length > bstream->datasize) { - BitStream_expand(bstream); + ret = BitStream_expand(bstream); + if(ret < 0) return ret; } memcpy(bstream->data + bstream->length, arg->data, arg->length); -- cgit 0.0.5-2-1-g0f52 From 43131e12fca98ab6cb01e94af5d04340204a6ca8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 9 Feb 2014 21:34:33 +0900 Subject: Fixed some warnings. --- ChangeLog | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 18 +++++++++------- 2 files changed, 78 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf15228106..b6bc5e1bba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,71 @@ +2014.02.09 Kentaro FUKUCHI + * .travis.yaml: + - Configuration file for Travis CI. (Thanks to Danil Dörrhöfer) + * configure.ac: + - Fixed some warnings. + +2014.01.15 Kentaro FUKUCHI + * qrenc.c: + - Merged pull request 78d44fd - commandline argument --help and -V is + printed to stdout, instead of stderr. + +2014.01.04 Kentaro FUKUCHI + * rsecc.[ch]: + - Code cleanups. + +2013.10.27 Kentaro FUKUCHI + * qrinput.c: + - Bug in QRinput_insertFNC1Header() has been fixed. (Thanks to David + Binderman) + * qrinput.c, test/decoder.[ch]: + - Code cleanup. + +2013.09.08 Kentaro FUKUCHI + * tests/test_qrencode.c: + - Small bug fix. + +2013.09.06 Kentaro FUKUCHI + * qrenc.c: + - bzero() has been replaced with memset(). (Thanks to Gavin Andresen) + * qrspec.c, qrinput.c: + - QRspec_getMinimumVersion() now returns maximum version number for + excessive input, instead of -1. Closes #31. (Thanks to Danil + Dörrhöfer) + * tests/test_qrencode.c: + - New tests for excessive or maximum input have been added. + * tests/test_qrinput.c: + - A deprecatd test has been removed. + [reduce_malloc] + * bitstream.c: + - Minimum length of bit buffer has been extended to 128. In many cases + the library needs 128 bits at least to generate a symbol. + [master] + * merged reduce_malloc branch. + +2013.08.22 Kentaro FUKUCHI + * configure.ac: + - Avoid to use sdl-config. (Thanks to Heiko Becker) + +2013.08.15 Kentaro FUKUCHI + * rsecc.[ch], qrencode.c, tests/test_rc.c: + - Code cleanups and refactoring. + - Bug fix. + * configure.ac: + - Bumped version to 3.9.0, preparing for major update. + * qrenc.c: + - Copyright year in usage has been updated. + - Help message improved. + +2013.08.15 Kentaro FUKUCHI + * rsecc.[ch], rscode.[ch], Makefile.am, qrencode.c: + - Reed-Solomon error correction code has been completely rewritten. + - Phil Karn's code has been removed (moved to tests). + * tests/test_rs.c, tests/test_qrencode.c, tests/rscode.[ch], tests/Makefile.am: + - Test codes related to ECC have been updated. + - Phil Karn's code has been moved to tests, just for test purpose. + * tests/test_mqrspec.c: + - Code cleanup. + 2013.07.29 Kentaro FUKUCHI [3.4] * configure.ac, README, NEWS: diff --git a/configure.ac b/configure.ac index 5b46a20b71..cc983ba31a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,13 +1,15 @@ -AC_INIT(QRencode) - -MAJOR_VERSION=3 -MINOR_VERSION=4 -MICRO_VERSION=3 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION +m4_define([__MAJOR_VERSION], [3])dnl +m4_define([__MINOR_VERSION], [4])dnl +m4_define([__MICRO_VERSION], [3])dnl +m4_define([__VERSION], [__MAJOR_VERSION.__MINOR_VERSION.__MICRO_VERSION])dnl +AC_INIT(QRencode, __VERSION) + +MAJOR_VERSION=__MAJOR_VERSION +MINOR_VERSION=__MINOR_VERSION +MICRO_VERSION=__MICRO_VERSION AC_SUBST(MAJOR_VERSION) AC_SUBST(MINOR_VERSION) AC_SUBST(MICRO_VERSION) -AC_SUBST(VERSION) AC_DEFINE_UNQUOTED([MAJOR_VERSION], [$MAJOR_VERSION], [Major version number]) AC_DEFINE_UNQUOTED([MINOR_VERSION], [$MINOR_VERSION], [Minor version number]) AC_DEFINE_UNQUOTED([MICRO_VERSION], [$MICRO_VERSION], [Micro version number]) @@ -19,7 +21,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CANONICAL_HOST AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE(qrencode, $VERSION) +AM_INIT_AUTOMAKE AC_DISABLE_STATIC AC_C_CONST -- cgit 0.0.5-2-1-g0f52 From 91f87d4ceb991edd234fe73ee8f6185a2b484741 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 22 Jun 2014 02:03:19 +0900 Subject: A memory leak bug fixed. (Thanks to @win32asm) --- ChangeLog | 4 ++++ README | 2 +- qrencode.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b6bc5e1bba..e2a8921c80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.06.22 Kentaro FUKUCHI + * qrencode.c: + - A memory leak bug has been fixed. (Thanks to @win32asm) + 2014.02.09 Kentaro FUKUCHI * .travis.yaml: - Configuration file for Travis CI. (Thanks to Danil Dörrhöfer) diff --git a/README b/README index 2f79701ed6..bc2b07fd94 100644 --- a/README +++ b/README @@ -140,5 +140,5 @@ Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, -Emmanuel Blot, ßlúèÇhîp +Emmanuel Blot, ßlúèÇhîp, win32asm - bug report / suggestion diff --git a/qrencode.c b/qrencode.c index ab8b5d85c5..8daedf0126 100644 --- a/qrencode.c +++ b/qrencode.c @@ -533,6 +533,9 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) goto EXIT; } qrcode = QRcode_new(version, width, masked); + if(qrcode == NULL) { + free(masked); + } EXIT: QRraw_free(raw); -- cgit 0.0.5-2-1-g0f52 From 8562710d1b8364e6ec60de5c85742314444c6f2e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 22 Jun 2014 02:51:19 +0900 Subject: Merged pull-request #46. --- ChangeLog | 2 ++ README | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4754d9c647..9cbdda9b9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2014.06.22 Kentaro FUKUCHI * qrencode.c: - A memory leak bug has been fixed. (Thanks to @win32asm) + * bitstream.c: + - Check return value of BitStream_expand. (PR #46, Thanks to @tklauser) 2014.02.14 Kentaro FUKUCHI * qrinput.c: diff --git a/README b/README index fd66964092..c66497ba02 100644 --- a/README +++ b/README @@ -141,5 +141,5 @@ Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino, Sean McMurray, win32asm +ralgozino, Sean McMurray, win32asm, Tobias Klauser - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 3999eeb1fa68bae3d40664235b22d4a47b10107b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 27 Jun 2014 05:04:38 +0900 Subject: Fixed some format issues. --- ChangeLog | 5 +++++ README | 2 +- qrenc.c | 20 ++++++++++++-------- qrencode.1.in | 10 +++++----- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cbdda9b9d..26f0b71824 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014.06.27 Kentaro FUKUCHI + * qrenc.c, qrencode.1.in: + - Merged pull-request #44. (Thanks to Antenore) + - Fixed some format issues. + 2014.06.22 Kentaro FUKUCHI * qrencode.c: - A memory leak bug has been fixed. (Thanks to @win32asm) diff --git a/README b/README index c66497ba02..bddbb6cc3f 100644 --- a/README +++ b/README @@ -141,5 +141,5 @@ Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino, Sean McMurray, win32asm, Tobias Klauser +ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index 19ca43877f..9515690041 100644 --- a/qrenc.c +++ b/qrenc.c @@ -109,9 +109,10 @@ static void usage(int help, int longopt, int status) " specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n\n" " -v NUMBER, --symversion=NUMBER\n" -" specify the version of the symbol. (default=auto) See SYMBOL VERSIONS for more information\n\n" +" specify the version of the symbol. See SYMBOL VERSIONS for more\n" +" information. (default=auto)\n\n" " -m NUMBER, --margin=NUMBER\n" -" specify the width of the margins. (default=4 (2 for Micro)))\n\n" +" specify the width of the margins. (default=4 (2 for Micro QR)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" " -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={...}\n" @@ -134,12 +135,15 @@ static void usage(int help, int longopt, int status) " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" -" standard input.\n" -" [SYMBOL VERSIONS] The symbol versions of QR Code range from Version 1 to Version 40.\n" -" Each version has a different module configuration or number of modules,\n" -" ranging from Version 1 (21 × 21 modules) up to Version 40 (177 × 177 modules).\n" -" Each higher version number comprises 4 additional modules per side.\n" -" See http://www.qrcode.com/en/about/version.html for a detailed version list.\n" +" standard input.\n\n" +"*SYMBOL VERSIONS\n" +" The symbol versions of QR Code range from Version 1 to Version\n" +" 40. Each version has a different module configuration or number\n" +" of modules, ranging from Version 1 (21 x 21 modules) up to\n" +" Version 40 (177 x 177 modules). Each higher version number\n" +" comprises 4 additional modules per side by default. See\n" +" http://www.qrcode.com/en/about/version.html for a detailed\n" +" version list.\n" ); } else { diff --git a/qrencode.1.in b/qrencode.1.in index 5e666570b8..bc3ca7e7d2 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -30,7 +30,7 @@ specify the size of dot (pixel). (default=3) specify error collectin level from L (lowest) to H (highest). (default=L) .TP .B \-v NUMBER, \-\-symversion=NUMBER -specify the version of the symbol. (default=auto).See SYMBOL VERSIONS for more information +specify the version of the symbol. See SYMBOL VERSIONS for more information. (default=auto) .TP .B \-m NUMBER, \-\-margin=NUMBER specify the width of margin. (default=4) @@ -77,12 +77,12 @@ display the version number and copyrights of the qrencode. .TP .B [STRING] input data. If it is not specified, data will be taken from standard input. -.TP -.B [SYMBOL VERSIONS] + +.SH SYMBOL VERSIONS The symbol versions of QR Code range from Version 1 to Version 40. Each version has a different module configuration or number of modules, -ranging from Version 1 (21 × 21 modules) up to Version 40 (177 × 177 modules). -Each higher version number comprises 4 additional modules per side. +ranging from Version 1 (21 x 21 modules) up to Version 40 (177 x 177 modules). +Each higher version number comprises 4 additional modules per side by default. See http://www.qrcode.com/en/about/version.html for a detailed version list. .SH EXAMPLES -- cgit 0.0.5-2-1-g0f52 From 6e7ce2ef60179497950452e650f46bd2e8a8513b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 27 Jun 2014 05:06:25 +0900 Subject: Acknowledgements updated. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 183caa87e4..bdffa61ac0 100644 --- a/README.md +++ b/README.md @@ -139,4 +139,4 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - Yann Droneaud - improved input validation patch - Viona - bug fix patch for string splitting - Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration -- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino - bug report / suggestion +- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 878a101eb80088c0e6f93caf5f773684adc13e68 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 4 Jul 2014 07:16:23 +0900 Subject: Updated to the newer version. --- ChangeLog | 4 ++ use/config.rpath | 138 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 85 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26f0b71824..5f9711577f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.07.04 Kentaro FUKUCHI + * use/config.rpath: + - Updated to the newer version bundled with gettext-0.18.3.2. + 2014.06.27 Kentaro FUKUCHI * qrenc.c, qrencode.1.in: - Merged pull-request #44. (Thanks to Antenore) diff --git a/use/config.rpath b/use/config.rpath index c547c68825..c38b914d6b 100755 --- a/use/config.rpath +++ b/use/config.rpath @@ -2,7 +2,7 @@ # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # -# Copyright 1996-2007 Free Software Foundation, Inc. +# Copyright 1996-2013 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit , 1996 # @@ -25,7 +25,7 @@ # known workaround is to choose shorter directory names for the build # directory and/or the installation directory. -# All known linkers require a `.a' archive for static linking (except MSVC, +# All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a shrext=.so @@ -47,7 +47,7 @@ for cc_temp in $CC""; do done cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` -# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. +# Code taken from libtool.m4's _LT_COMPILER_PIC. wl= if test "$GCC" = yes; then @@ -57,14 +57,7 @@ else aix*) wl='-Wl,' ;; - darwin*) - case $cc_basename in - xlc*) - wl='-Wl,' - ;; - esac - ;; - mingw* | cygwin* | pw32* | os2*) + mingw* | cygwin* | pw32* | os2* | cegcc*) ;; hpux9* | hpux10* | hpux11*) wl='-Wl,' @@ -72,24 +65,37 @@ else irix5* | irix6* | nonstopux*) wl='-Wl,' ;; - newsos6) - ;; - linux* | k*bsd*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in - icc* | ecc*) + ecc*) wl='-Wl,' ;; - pgcc | pgf77 | pgf90) + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) + wl='-Wl,' + ;; + nagfor*) + wl='-Wl,-Wl,,' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) wl='-Wl,' ;; ccc*) wl='-Wl,' ;; + xl* | bgxl* | bgf* | mpixl*) + wl='-Wl,' + ;; como) wl='-lopt=' ;; *) case `$CC -V 2>&1 | sed 5q` in + *Sun\ F* | *Sun*Fortran*) + wl= + ;; *Sun\ C*) wl='-Wl,' ;; @@ -97,13 +103,24 @@ else ;; esac ;; + newsos6) + ;; + *nto* | *qnx*) + ;; osf3* | osf4* | osf5*) wl='-Wl,' ;; rdos*) ;; solaris*) - wl='-Wl,' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + wl='-Qoption ld ' + ;; + *) + wl='-Wl,' + ;; + esac ;; sunos4*) wl='-Qoption ld ' @@ -124,7 +141,7 @@ else esac fi -# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. hardcode_libdir_flag_spec= hardcode_libdir_separator= @@ -132,7 +149,7 @@ hardcode_direct=no hardcode_minus_L=no case "$host_os" in - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. @@ -158,22 +175,21 @@ if test "$with_gnu_ld" = yes; then # option of GNU ld is called -rpath, not --rpath. hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' case "$host_os" in - aix3* | aix4* | aix5*) + aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no fi ;; amigaos*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we cannot use - # them. - ld_shlibs=no + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then @@ -182,7 +198,7 @@ if test "$with_gnu_ld" = yes; then ld_shlibs=no fi ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' @@ -192,11 +208,13 @@ if test "$with_gnu_ld" = yes; then ld_shlibs=no fi ;; + haiku*) + ;; interix[3-9]*) hardcode_direct=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; - gnu* | linux* | k*bsd*-gnu) + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else @@ -254,7 +272,7 @@ else hardcode_direct=unsupported fi ;; - aix4* | aix5*) + aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. @@ -264,7 +282,7 @@ else # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes @@ -319,14 +337,18 @@ else fi ;; amigaos*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # see comment about different semantics on the GNU ld section - ld_shlibs=no + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac ;; bsdi[45]*) ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is @@ -336,24 +358,15 @@ else ;; darwin* | rhapsody*) hardcode_direct=no - if test "$GCC" = yes ; then + if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then : else - case $cc_basename in - xlc*) - ;; - *) - ld_shlibs=no - ;; - esac + ld_shlibs=no fi ;; dgux*) hardcode_libdir_flag_spec='-L$libdir' ;; - freebsd1*) - ld_shlibs=no - ;; freebsd2.2*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes @@ -414,6 +427,8 @@ else hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; + *nto* | *qnx*) + ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes @@ -494,7 +509,7 @@ else fi # Check dynamic linker characteristics -# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. # Unlike libtool.m4, here we don't care about _all_ names of the library, but # only about the one the linker finds when passed -lNAME. This is the last # element of library_names_spec in libtool.m4, or possibly two of them if the @@ -505,11 +520,16 @@ case "$host_os" in aix3*) library_names_spec='$libname.a' ;; - aix4* | aix5*) + aix[4-9]*) library_names_spec='$libname$shrext' ;; amigaos*) - library_names_spec='$libname.a' + case "$host_cpu" in + powerpc*) + library_names_spec='$libname$shrext' ;; + m68k) + library_names_spec='$libname.a' ;; + esac ;; beos*) library_names_spec='$libname$shrext' @@ -517,7 +537,7 @@ case "$host_os" in bsdi[45]*) library_names_spec='$libname$shrext' ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) shrext=.dll library_names_spec='$libname.dll.a $libname.lib' ;; @@ -528,8 +548,6 @@ case "$host_os" in dgux*) library_names_spec='$libname$shrext' ;; - freebsd1*) - ;; freebsd* | dragonfly*) case "$host_os" in freebsd[123]*) @@ -541,6 +559,9 @@ case "$host_os" in gnu*) library_names_spec='$libname$shrext' ;; + haiku*) + library_names_spec='$libname$shrext' + ;; hpux9* | hpux10* | hpux11*) case $host_cpu in ia64*) @@ -576,7 +597,7 @@ case "$host_os" in ;; linux*oldld* | linux*aout* | linux*coff*) ;; - linux* | k*bsd*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu) library_names_spec='$libname$shrext' ;; knetbsd*-gnu) @@ -588,7 +609,7 @@ case "$host_os" in newsos6) library_names_spec='$libname$shrext' ;; - nto-qnx*) + *nto* | *qnx*) library_names_spec='$libname$shrext' ;; openbsd*) @@ -619,6 +640,9 @@ case "$host_os" in sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) library_names_spec='$libname$shrext' ;; + tpf*) + library_names_spec='$libname$shrext' + ;; uts4*) library_names_spec='$libname$shrext' ;; -- cgit 0.0.5-2-1-g0f52 From ecf124c69c8bf42275908494db94b5244bc43b23 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 4 Jul 2014 07:49:06 +0900 Subject: Some fixes for Mac OS + homebrew. --- ChangeLog | 4 + acinclude.m4 | 1388 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ autogen.sh | 4 + 3 files changed, 1396 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5f9711577f..3e7c2d1480 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ 2014.07.04 Kentaro FUKUCHI * use/config.rpath: - Updated to the newer version bundled with gettext-0.18.3.2. + * acinclude.m4: + - Added iconv.m4, lib-{link,ld,prefix}.m4 for Mac OS. + * autogen.sh: + - mkdir m4 if not exist. 2014.06.27 Kentaro FUKUCHI * qrenc.c, qrencode.1.in: diff --git a/acinclude.m4 b/acinclude.m4 index e69de29bb2..6f48ebd1b1 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -0,0 +1,1388 @@ +# iconv.m4 serial 18 (gettext-0.18.2) +dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], + [am_cv_func_iconv=yes]) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], + [am_cv_lib_iconv=yes] + [am_cv_func_iconv=yes]) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ + dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, + dnl Solaris 10. + am_save_LIBS="$LIBS" + if test $am_cv_lib_iconv = yes; then + LIBS="$LIBS $LIBICONV" + fi + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +int main () +{ + int result = 0; + /* Test against AIX 5.1 bug: Failures are not distinguishable from successful + returns. */ + { + iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); + if (cd_utf8_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + result |= 1; + iconv_close (cd_utf8_to_88591); + } + } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\263"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + result |= 2; + iconv_close (cd_ascii_to_88591); + } + } + /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304"; + static char buf[2] = { (char)0xDE, (char)0xAD }; + const char *inptr = input; + size_t inbytesleft = 1; + char *outptr = buf; + size_t outbytesleft = 1; + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) + result |= 4; + iconv_close (cd_88591_to_utf8); + } + } +#if 0 /* This bug could be worked around by the caller. */ + /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if ((int)res > 0) + result |= 8; + iconv_close (cd_88591_to_utf8); + } + } +#endif + /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is + provided. */ + if (/* Try standardized names. */ + iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) + /* Try IRIX, OSF/1 names. */ + && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) + /* Try AIX names. */ + && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) + /* Try HP-UX names. */ + && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) + result |= 16; + return result; +}]])], + [am_cv_func_iconv_works=yes], + [am_cv_func_iconv_works=no], + [ +changequote(,)dnl + case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac +changequote([,])dnl + ]) + LIBS="$am_save_LIBS" + ]) + case "$am_cv_func_iconv_works" in + *no) am_func_iconv=no am_cv_lib_iconv=no ;; + *) am_func_iconv=yes ;; + esac + else + am_func_iconv=no am_cv_lib_iconv=no + fi + if test "$am_func_iconv" = yes; then + AC_DEFINE([HAVE_ICONV], [1], + [Define if you have the iconv() function and it works.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST([LIBICONV]) + AC_SUBST([LTLIBICONV]) +]) + +dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to +dnl avoid warnings like +dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". +dnl This is tricky because of the way 'aclocal' is implemented: +dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. +dnl Otherwise aclocal's initial scan pass would miss the macro definition. +dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. +dnl Otherwise aclocal would emit many "Use of uninitialized value $1" +dnl warnings. +m4_define([gl_iconv_AC_DEFUN], + m4_version_prereq([2.64], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [m4_ifdef([gl_00GNULIB], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [[AC_DEFUN( + [$1], [$2])]])])) +gl_iconv_AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL([am_cv_proto_iconv], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif + ]], + [[]])], + [am_cv_proto_iconv_arg1=""], + [am_cv_proto_iconv_arg1="const"]) + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([ + $am_cv_proto_iconv]) + AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], + [Define as const if the declaration of iconv() needs const.]) + dnl Also substitute ICONV_CONST in the gnulib generated . + m4_ifdef([gl_ICONV_H_DEFAULTS], + [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) + if test -n "$am_cv_proto_iconv_arg1"; then + ICONV_CONST="const" + fi + ]) + fi +]) +# lib-ld.m4 serial 6 +dnl Copyright (C) 1996-2003, 2009-2013 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Subroutines of libtool.m4, +dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid +dnl collision with libtool.m4. + +dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], +[# I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 /dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` + while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL([acl_cv_path_LD], +[if test -z "$LD"; then + acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$acl_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 = 1.10 to complain if config.rpath is missing. + m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE([rpath], + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_FROMPACKAGE(name, package) +dnl declares that libname comes from the given package. The configure file +dnl will then not have a --with-libname-prefix option but a +dnl --with-package-prefix option. Several libraries can come from the same +dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar +dnl macro call that searches for libname. +AC_DEFUN([AC_LIB_FROMPACKAGE], +[ + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_frompackage_]NAME, [$2]) + popdef([NAME]) + pushdef([PACK],[$2]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_libsinpackage_]PACKUP, + m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) + popdef([PACKUP]) + popdef([PACK]) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found +dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) + dnl Autoconf >= 2.61 supports dots in --with options. + pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_ARG_WITH(P_A_C_K[-prefix], +[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib + --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + LIB[]NAME[]_PREFIX= + dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been + dnl computed. So it has to be reset here. + HAVE_LIB[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + dnl The same code as in the loop below: + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$acl_hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi + popdef([P_A_C_K]) + popdef([PACKLIBS]) + popdef([PACKUP]) + popdef([PACK]) + popdef([NAME]) +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) + +dnl For those cases where a variable contains several -L and -l options +dnl referring to unknown libraries and directories, this macro determines the +dnl necessary additional linker options for the runtime path. +dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) +dnl sets LDADDVAR to linker options needed together with LIBSVALUE. +dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, +dnl otherwise linking without libtool is assumed. +AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], +[ + AC_REQUIRE([AC_LIB_RPATH]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + $1= + if test "$enable_rpath" != no; then + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode directories into the resulting + dnl binary. + rpathdirs= + next= + for opt in $2; do + if test -n "$next"; then + dir="$next" + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= + else + case $opt in + -L) next=yes ;; + -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= ;; + *) next= ;; + esac + fi + done + if test "X$rpathdirs" != "X"; then + if test -n ""$3""; then + dnl libtool is used for linking. Use -R options. + for dir in $rpathdirs; do + $1="${$1}${$1:+ }-R$dir" + done + else + dnl The linker is used for linking directly. + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user + dnl must pass all path elements in one option. + alldirs= + for dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="$flag" + else + dnl The -rpath options are cumulative. + for dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="${$1}${$1:+ }$flag" + done + fi + fi + fi + fi + fi + AC_SUBST([$1]) +]) +# lib-prefix.m4 serial 7 (gettext-0.18) +dnl Copyright (C) 2001-2005, 2008-2013 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_PREPARE_MULTILIB creates +dnl - a variable acl_libdirstem, containing the basename of the libdir, either +dnl "lib" or "lib64" or "lib/64", +dnl - a variable acl_libdirstem2, as a secondary possible value for +dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or +dnl "lib/amd64". +AC_DEFUN([AC_LIB_PREPARE_MULTILIB], +[ + dnl There is no formal standard regarding lib and lib64. + dnl On glibc systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine + dnl the compiler's default mode by looking at the compiler's library search + dnl path. If at least one of its elements ends in /lib64 or points to a + dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. + dnl Otherwise we use the default, namely "lib". + dnl On Solaris systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or + dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. + AC_REQUIRE([AC_CANONICAL_HOST]) + acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment + dnl . + dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." + dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the + dnl symlink is missing, so we set acl_libdirstem2 too. + AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], + [AC_EGREP_CPP([sixtyfour bits], [ +#ifdef _LP64 +sixtyfour bits +#endif + ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) + ]) + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" +]) diff --git a/autogen.sh b/autogen.sh index b90f44f370..ab14d6c040 100755 --- a/autogen.sh +++ b/autogen.sh @@ -21,6 +21,10 @@ if [ ! -d use ]; then mkdir use fi +if [ ! -d m4 ]; then + mkdir m4 +fi + autoheader aclocal $ACLOCAL_OPT -- cgit 0.0.5-2-1-g0f52 From 5c8a99b9d9875e84734a987652bd7da121facc4c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 4 Jul 2014 08:05:15 +0900 Subject: Fixed some doxygen commands. --- ChangeLog | 2 ++ qrencode.h | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e7c2d1480..6570f89033 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ - Added iconv.m4, lib-{link,ld,prefix}.m4 for Mac OS. * autogen.sh: - mkdir m4 if not exist. + * qrencode.h: + - Fixed some doxygen commands. 2014.06.27 Kentaro FUKUCHI * qrenc.c, qrencode.1.in: diff --git a/qrencode.h b/qrencode.h index e554bb9241..02aa023aad 100644 --- a/qrencode.h +++ b/qrencode.h @@ -360,17 +360,17 @@ extern int QRinput_setFNC1Second(QRinput *input, unsigned char appid); * the uchar is 1, the corresponding module is black. The other bits are * meaningless for usual applications, but here its specification is described. * - *
- * MSB 76543210 LSB
- *     |||||||`- 1=black/0=white
- *     ||||||`-- data and ecc code area
- *     |||||`--- format information
- *     ||||`---- version information
- *     |||`----- timing pattern
- *     ||`------ alignment pattern
- *     |`------- finder pattern and separator
- *     `-------- non-data modules (format, timing, etc.)
- * 
+ * @verbatim + MSB 76543210 LSB + |||||||`- 1=black/0=white + ||||||`-- data and ecc code area + |||||`--- format information + ||||`---- version information + |||`----- timing pattern + ||`------ alignment pattern + |`------- finder pattern and separator + `-------- non-data modules (format, timing, etc.) + @endverbatim */ typedef struct { int version; ///< version of the symbol -- cgit 0.0.5-2-1-g0f52 From 379a1d1fff9b03c21c76f2401e4d9506155741a8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 4 Jul 2014 09:37:41 +0900 Subject: Copyright year updated. --- README | 2 +- README.md | 2 +- bitstream.c | 2 +- bitstream.h | 2 +- qrenc.c | 2 +- qrencode.1.in | 2 +- qrencode.c | 2 +- qrinput.c | 2 +- qrinput.h | 2 +- qrspec.c | 2 +- qrspec.h | 2 +- rsecc.c | 2 +- rsecc.h | 2 +- split.c | 2 +- split.h | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README b/README index bddbb6cc3f..fbc83860f0 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.4.3 - QR Code encoding library +libqrencode 3.9.0 - QR Code encoding library GENERAL INFORMATION =================== diff --git a/README.md b/README.md index bdffa61ac0..7dbd619fb5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# libqrencode 3.4.3 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) +# libqrencode 3.9.0 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) GENERAL INFORMATION =================== diff --git a/bitstream.c b/bitstream.c index 33d17a3b20..866e775442 100644 --- a/bitstream.c +++ b/bitstream.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Binary sequence class. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/bitstream.h b/bitstream.h index 3035a40fdf..601f10f2e6 100644 --- a/bitstream.h +++ b/bitstream.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Binary sequence class. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrenc.c b/qrenc.c index 9515690041..0af5449ab3 100644 --- a/qrenc.c +++ b/qrenc.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code encoding tool - * Copyright (C) 2006-2013 Kentaro Fukuchi + * Copyright (C) 2006-2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrencode.1.in b/qrencode.1.in index bc3ca7e7d2..b59f052c68 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -1,4 +1,4 @@ -.TH QRENCODE 1 "Oct. 9, 2012" "qrencode @VERSION@" +.TH QRENCODE 1 "Jun. 27, 2014" "qrencode @VERSION@" .SH NAME qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS diff --git a/qrencode.c b/qrencode.c index 3d3a982f44..f7b0d3f137 100644 --- a/qrencode.c +++ b/qrencode.c @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Copyright (C) 2006-2012 Kentaro Fukuchi + * Copyright (C) 2006-2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrinput.c b/qrinput.c index de8c942120..4bc23e6747 100644 --- a/qrinput.c +++ b/qrinput.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrinput.h b/qrinput.h index 9bf2a4533d..dd6dcf35d4 100644 --- a/qrinput.h +++ b/qrinput.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrspec.c b/qrspec.c index fdd18eab4f..039a5be47c 100644 --- a/qrspec.c +++ b/qrspec.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code specification in convenient format. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2013 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/qrspec.h b/qrspec.h index 54a3d9f09e..e15624c0bd 100644 --- a/qrspec.h +++ b/qrspec.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code specification in convenient format. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2013 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/rsecc.c b/rsecc.c index e1db33a53e..3358317c26 100644 --- a/rsecc.c +++ b/rsecc.c @@ -3,7 +3,7 @@ * * Reed solomon error correction code encoder specialized for QR code. * - * Copyright (C) 2013 Kentaro Fukuchi + * Copyright (C) 2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/rsecc.h b/rsecc.h index e5efd8446d..ff34449a6f 100644 --- a/rsecc.h +++ b/rsecc.h @@ -3,7 +3,7 @@ * * Reed solomon error correction code encoder specialized for QR code. * - * Copyright (C) 2013 Kentaro Fukuchi + * Copyright (C) 2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/split.c b/split.c index a2cb0e0e3f..e3bb6fc3f9 100644 --- a/split.c +++ b/split.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2013 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/split.h b/split.h index b2cdbe5468..2817ccfcad 100644 --- a/split.h +++ b/split.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2013 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) -- cgit 0.0.5-2-1-g0f52 From a2f6d4cca327038bcd5ecdf0f8a1237f33837aa9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 6 Jul 2014 07:54:39 +0900 Subject: New image type PNG32 has been added. --- ChangeLog | 4 ++ README | 1 + README.md | 1 + qrenc.c | 195 ++++++++++++++++++++++++++++++++++++++++------------------ qrencode.1.in | 6 +- 5 files changed, 143 insertions(+), 64 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6570f89033..d5f60831da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.07.06 Kentaro FUKUCHI + * qrenc.c, qrencode.1.in: + - Added a new image type PNG32 (direct color mode). (Thanks to Greg Hart) + 2014.07.04 Kentaro FUKUCHI * use/config.rpath: - Updated to the newer version bundled with gettext-0.18.3.2. diff --git a/README b/README index fbc83860f0..a1868680be 100644 --- a/README +++ b/README @@ -138,6 +138,7 @@ Lennart Poettering (mezcalero) Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration +Greg Hart - PNG32 support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, diff --git a/README.md b/README.md index 7dbd619fb5..df012ece9d 100644 --- a/README.md +++ b/README.md @@ -139,4 +139,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - Yann Droneaud - improved input validation patch - Viona - bug fix patch for string splitting - Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration +- Greg Hart - PNG32 support patch - Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index 0af5449ab3..039b3ad6e8 100644 --- a/qrenc.c +++ b/qrenc.c @@ -44,11 +44,12 @@ static int rle = 0; static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; -static unsigned int fg_color[4] = {0, 0, 0, 255}; -static unsigned int bg_color[4] = {255, 255, 255, 255}; +static unsigned char fg_color[4] = {0, 0, 0, 255}; +static unsigned char bg_color[4] = {255, 255, 255, 255}; enum imageType { PNG_TYPE, + PNG32_TYPE, EPS_TYPE, SVG_TYPE, ANSI_TYPE, @@ -115,7 +116,7 @@ static void usage(int help, int longopt, int status) " specify the width of the margins. (default=4 (2 for Micro QR)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={...}\n" +" -t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={...}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" @@ -162,7 +163,7 @@ static void usage(int help, int longopt, int status) " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" +" -t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" " specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" @@ -179,21 +180,28 @@ static void usage(int help, int longopt, int status) } } -static int color_set(unsigned int color[4], const char *value) +static int color_set(unsigned char color[4], const char *value) { int len = strlen(value); - int count; + int i, count; + unsigned int col[3]; if(len == 6) { - count = sscanf(value, "%02x%02x%02x%n", &color[0], &color[1], &color[2], &len); + count = sscanf(value, "%02x%02x%02x%n", &col[0], &col[1], &col[2], &len); if(count < 3 || len != 6) { return -1; } + for(i=0; i<3; i++) { + color[i] = col[i]; + } color[3] = 255; } else if(len == 8) { - count = sscanf(value, "%02x%02x%02x%02x%n", &color[0], &color[1], &color[2], &color[3], &len); + count = sscanf(value, "%02x%02x%02x%02x%n", &col[0], &col[1], &col[2], &col[3], &len); if(count < 4 || len != 8) { return -1; } + for(i=0; i<4; i++) { + color[i] = col[i]; + } } else { return -1; } @@ -245,19 +253,36 @@ static FILE *openFile(const char *outfile) return fp; } -static int writePNG(QRcode *qrcode, const char *outfile) +static void fillRow(unsigned char *row, int size, unsigned char color[]) +{ + int i; + + for(i = 0; i< size; i++) { + memcpy(row, color, 4); + row += 4; + } +} + +static int writePNG(QRcode *qrcode, const char *outfile, enum imageType type) { static FILE *fp; // avoid clobbering by setjmp. png_structp png_ptr; png_infop info_ptr; - png_colorp palette; + png_colorp palette = NULL; png_byte alpha_values[2]; unsigned char *row, *p, *q; int x, y, xx, yy, bit; int realwidth; realwidth = (qrcode->width + margin * 2) * size; - row = (unsigned char *)malloc((realwidth + 7) / 8); + if(type == PNG_TYPE) { + row = (unsigned char *)malloc((realwidth + 7) / 8); + } else if(type == PNG32_TYPE) { + row = (unsigned char *)malloc(realwidth * 4); + } else { + fprintf(stderr, "Internal error.\n"); + exit(EXIT_FAILURE); + } if(row == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); exit(EXIT_FAILURE); @@ -292,77 +317,121 @@ static int writePNG(QRcode *qrcode, const char *outfile) exit(EXIT_FAILURE); } - palette = (png_colorp) malloc(sizeof(png_color) * 2); - if(palette == NULL) { - fprintf(stderr, "Failed to allocate memory.\n"); - exit(EXIT_FAILURE); + if(type == PNG_TYPE) { + palette = (png_colorp) malloc(sizeof(png_color) * 2); + if(palette == NULL) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(EXIT_FAILURE); + } + palette[0].red = fg_color[0]; + palette[0].green = fg_color[1]; + palette[0].blue = fg_color[2]; + palette[1].red = bg_color[0]; + palette[1].green = bg_color[1]; + palette[1].blue = bg_color[2]; + alpha_values[0] = fg_color[3]; + alpha_values[1] = bg_color[3]; + png_set_PLTE(png_ptr, info_ptr, palette, 2); + png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL); } - palette[0].red = fg_color[0]; - palette[0].green = fg_color[1]; - palette[0].blue = fg_color[2]; - palette[1].red = bg_color[0]; - palette[1].green = bg_color[1]; - palette[1].blue = bg_color[2]; - alpha_values[0] = fg_color[3]; - alpha_values[1] = bg_color[3]; - png_set_PLTE(png_ptr, info_ptr, palette, 2); - png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL); png_init_io(png_ptr, fp); - png_set_IHDR(png_ptr, info_ptr, - realwidth, realwidth, - 1, - PNG_COLOR_TYPE_PALETTE, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); + if(type == PNG_TYPE) { + png_set_IHDR(png_ptr, info_ptr, + realwidth, realwidth, + 1, + PNG_COLOR_TYPE_PALETTE, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + } else { + png_set_IHDR(png_ptr, info_ptr, + realwidth, realwidth, + 8, + PNG_COLOR_TYPE_RGB_ALPHA, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + } png_set_pHYs(png_ptr, info_ptr, dpi * INCHES_PER_METER, dpi * INCHES_PER_METER, PNG_RESOLUTION_METER); png_write_info(png_ptr, info_ptr); + if(type == PNG_TYPE) { /* top margin */ - memset(row, 0xff, (realwidth + 7) / 8); - for(y=0; ydata; - for(y=0; ywidth; y++) { - bit = 7; + /* data */ + p = qrcode->data; + for(y=0; ywidth; y++) { + bit = 7; + memset(row, 0xff, (realwidth + 7) / 8); + q = row; + q += margin * size / 8; + bit = 7 - (margin * size % 8); + for(x=0; xwidth; x++) { + for(xx=0; xxwidth; x++) { - for(xx=0; xxdata; + for(y=0; ywidth; y++) { + fillRow(row, realwidth, bg_color); + for(x=0; xwidth; x++) { + for(xx=0; xxcode, filename); + case PNG32_TYPE: + writePNG(p->code, filename, image_type); break; case EPS_TYPE: writeEPS(p->code, filename); @@ -1051,7 +1122,9 @@ int main(int argc, char **argv) } break; case 't': - if(strcasecmp(optarg, "png") == 0) { + if(strcasecmp(optarg, "png24") == 0) { + image_type = PNG32_TYPE; + } else if(strcasecmp(optarg, "png") == 0) { image_type = PNG_TYPE; } else if(strcasecmp(optarg, "eps") == 0) { image_type = EPS_TYPE; diff --git a/qrencode.1.in b/qrencode.1.in index b59f052c68..bade365c98 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -1,4 +1,4 @@ -.TH QRENCODE 1 "Jun. 27, 2014" "qrencode @VERSION@" +.TH QRENCODE 1 "Jul. 6, 2014" "qrencode @VERSION@" .SH NAME qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS @@ -39,10 +39,10 @@ specify the width of margin. (default=4) specify the DPI of the generated PNG. (default=72) .TP .PD 0 -.B \-t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.B \-t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} .TP .PD -.B \-\-type={PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.B \-\-type={PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} specify the type of the generated image. (default=PNG) .TP .B \-S, \-\-structured -- cgit 0.0.5-2-1-g0f52 From 2a40ac8593060e12f2d0348ef77a2bcaa2dca813 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 7 Jul 2014 03:03:57 +0900 Subject: Code cleanup. --- qrenc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qrenc.c b/qrenc.c index 039b3ad6e8..c1b25f7db7 100644 --- a/qrenc.c +++ b/qrenc.c @@ -429,9 +429,7 @@ static int writePNG(QRcode *qrcode, const char *outfile, enum imageType type) fclose(fp); free(row); - if(palette) { - free(palette); - } + free(palette); return 0; } -- cgit 0.0.5-2-1-g0f52 From 59504b79a398f05f16680637d1fd873038028c14 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 7 Jul 2014 03:21:32 +0900 Subject: Serious typo fix. --- ChangeLog | 4 ++++ qrenc.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d5f60831da..0f1e3d3237 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.07.07 Kentaro FUKUCHI + * qrenc.c: + - Serious typo fix. + 2014.07.06 Kentaro FUKUCHI * qrenc.c, qrencode.1.in: - Added a new image type PNG32 (direct color mode). (Thanks to Greg Hart) diff --git a/qrenc.c b/qrenc.c index c1b25f7db7..db85696071 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1120,7 +1120,7 @@ int main(int argc, char **argv) } break; case 't': - if(strcasecmp(optarg, "png24") == 0) { + if(strcasecmp(optarg, "png32") == 0) { image_type = PNG32_TYPE; } else if(strcasecmp(optarg, "png") == 0) { image_type = PNG_TYPE; -- cgit 0.0.5-2-1-g0f52 From 988c6c9fb800c8baf730e3b186345b1dd4c29cf3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 8 Jul 2014 01:18:51 +0900 Subject: Code cleanups. --- ChangeLog | 4 ++++ qrenc.c | 65 +++++++++++++++++++++++++++++++-------------------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f1e3d3237..a1daa358a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.07.08 Kentaro FUKUCHI + * qrenc.c: + - Code cleanups. + 2014.07.07 Kentaro FUKUCHI * qrenc.c: - Serious typo fix. diff --git a/qrenc.c b/qrenc.c index db85696071..c8ee952762 100644 --- a/qrenc.c +++ b/qrenc.c @@ -253,7 +253,7 @@ static FILE *openFile(const char *outfile) return fp; } -static void fillRow(unsigned char *row, int size, unsigned char color[]) +static void fillRow(unsigned char *row, int size, const unsigned char color[]) { int i; @@ -263,7 +263,7 @@ static void fillRow(unsigned char *row, int size, unsigned char color[]) } } -static int writePNG(QRcode *qrcode, const char *outfile, enum imageType type) +static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType type) { static FILE *fp; // avoid clobbering by setjmp. png_structp png_ptr; @@ -434,7 +434,7 @@ static int writePNG(QRcode *qrcode, const char *outfile, enum imageType type) return 0; } -static int writeEPS(QRcode *qrcode, const char *outfile) +static int writeEPS(const QRcode *qrcode, const char *outfile) { FILE *fp; unsigned char *row, *p; @@ -478,7 +478,7 @@ static int writeEPS(QRcode *qrcode, const char *outfile) return 0; } -static void writeSVG_writeRect(FILE *fp, int x, int y, int width, char* col, float opacity) +static void writeSVG_writeRect(FILE *fp, int x, int y, int width, const char* col, float opacity) { if(fg_color[3] != 255) { fprintf(fp, "\t\t\twidth + margin * 2) * size; - buffer_s = ( realwidth * white_s ) * 2; - buffer = (char *)malloc( buffer_s ); + buffer_s = (realwidth * white_s) * 2; + buffer = (char *)malloc(buffer_s); if(buffer == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); exit(EXIT_FAILURE); } /* top margin */ - writeANSI_margin(fp, realwidth, buffer, buffer_s, white, white_s); + writeANSI_margin(fp, realwidth, buffer, white, white_s); /* data */ p = qrcode->data; @@ -656,39 +656,39 @@ static int writeANSI(QRcode *qrcode, const char *outfile) row = (p+(y*qrcode->width)); memset(buffer, 0, buffer_s); - strncpy( buffer, white, white_s ); + strncpy(buffer, white, white_s); for(x=0; xwidth; x++) { if(*(row+x)&0x1) { if( last != 1 ){ - strncat( buffer, black, black_s ); + strncat(buffer, black, black_s); last = 1; } } else { if( last != 0 ){ - strncat( buffer, white, white_s ); + strncat(buffer, white, white_s); last = 0; } } - strncat( buffer, " ", 2 ); + strncat(buffer, " ", 2); } if( last != 0 ){ - strncat( buffer, white, white_s ); + strncat(buffer, white, white_s); } for(x=0; xwidth + margin * 2); /* top margin */ - writeUTF8_margin(fp, realwidth, white, reset, use_ansi); + writeUTF8_margin(fp, realwidth, white, reset); /* data */ for(y = 0; y < qrcode->width; y += 2) { @@ -768,14 +767,14 @@ static int writeUTF8(QRcode *qrcode, const char *outfile, int use_ansi) } /* bottom margin */ - writeUTF8_margin(fp, realwidth, white, reset, use_ansi); + writeUTF8_margin(fp, realwidth, white, reset); fclose(fp); return 0; } -static void writeASCII_margin(FILE* fp, int realwidth, char* buffer, int buffer_s, int invert) +static void writeASCII_margin(FILE* fp, int realwidth, char* buffer, int invert) { int y, h; @@ -789,7 +788,7 @@ static void writeASCII_margin(FILE* fp, int realwidth, char* buffer, int buffer_ } } -static int writeASCII(QRcode *qrcode, const char *outfile, int invert) +static int writeASCII(const QRcode *qrcode, const char *outfile, int invert) { FILE *fp; unsigned char *row; @@ -818,7 +817,7 @@ static int writeASCII(QRcode *qrcode, const char *outfile, int invert) } /* top margin */ - writeASCII_margin(fp, realwidth, buffer, buffer_s, invert); + writeASCII_margin(fp, realwidth, buffer, invert); /* data */ for(y=0; ywidth; y++) { @@ -846,7 +845,7 @@ static int writeASCII(QRcode *qrcode, const char *outfile, int invert) } /* bottom margin */ - writeASCII_margin(fp, realwidth, buffer, buffer_s, invert); + writeASCII_margin(fp, realwidth, buffer, invert); fclose(fp); free(buffer); -- cgit 0.0.5-2-1-g0f52 From 8ceba94355394bab2efb23a20f7702f9d6f94e1d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 8 Jul 2014 06:24:38 +0900 Subject: Some possible minor bug fixes and code cleanups. --- ChangeLog | 3 ++- qrenc.c | 1 - qrinput.c | 1 + tests/test_qrinput.c | 4 ---- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1daa358a4..4a959f906a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2014.07.08 Kentaro FUKUCHI - * qrenc.c: + * qrenc.c, qrinput.c, tests/test_qrinput.c: - Code cleanups. + - Some possible minor bugs has been fixed. 2014.07.07 Kentaro FUKUCHI * qrenc.c: diff --git a/qrenc.c b/qrenc.c index c8ee952762..93f8299bd4 100644 --- a/qrenc.c +++ b/qrenc.c @@ -369,7 +369,6 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty /* data */ p = qrcode->data; for(y=0; ywidth; y++) { - bit = 7; memset(row, 0xff, (realwidth + 7) / 8); q = row; q += margin * size / 8; diff --git a/qrinput.c b/qrinput.c index 4bc23e6747..b3f3d4c971 100644 --- a/qrinput.c +++ b/qrinput.c @@ -59,6 +59,7 @@ static QRinput_List *QRinput_List_newEntry(QRencodeMode mode, int size, const un entry->mode = mode; entry->size = size; + entry->data = NULL; if(size > 0) { entry->data = (unsigned char *)malloc(size); if(entry->data == NULL) { diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 133417f49f..9a9e544bfc 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -568,8 +568,6 @@ void test_splitentry(void) QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str); i2 = QRinput_dup(i1); - e = i2->head; - e = i2->head; QRinput_splitEntry(e, 4); @@ -628,8 +626,6 @@ void test_splitentry2(void) QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str); i2 = QRinput_dup(i1); - e = i2->head; - e = i2->head; QRinput_splitEntry(e, 4); -- cgit 0.0.5-2-1-g0f52 From 6a73cc29b2fb84a04f01a85c93dcc538331157b6 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 24 Jul 2014 18:13:37 +0900 Subject: Code refactoring (QRinput_Struct_count has been added). --- ChangeLog | 4 ++++ qrinput.c | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a959f906a..c9639af17c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.07.24 Kentaro FUKUCHI + * qrinput.c: + - Code refactoring (QRinput_Struct_count has been added). + 2014.07.08 Kentaro FUKUCHI * qrenc.c, qrinput.c, tests/test_qrinput.c: - Code cleanups. diff --git a/qrinput.c b/qrinput.c index b3f3d4c971..a93de80b96 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1434,6 +1434,18 @@ static unsigned char QRinput_Struct_calcParity(QRinput_Struct *s) return parity; } +static int QRinput_Struct_count(QRinput_Struct *s) +{ + int num = 0; + QRinput_InputList *list; + + for(list = s->head; list != NULL; list = list->next) { + num++; + } + + return num; +} + static int QRinput_List_shrinkEntry(QRinput_List *entry, int bytes) { unsigned char *data; @@ -1584,12 +1596,7 @@ int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s) if(s->parity < 0) { QRinput_Struct_calcParity(s); } - num = 0; - list = s->head; - while(list != NULL) { - num++; - list = list->next; - } + num = QRinput_Struct_count(s); i = 1; list = s->head; while(list != NULL) { -- cgit 0.0.5-2-1-g0f52 From 68a3112eac7bc22d5fddfd474e5b1c6bed790b2c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 24 Jul 2014 18:30:46 +0900 Subject: More code cleanups. --- ChangeLog | 1 + qrinput.c | 21 ++++++--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9639af17c..ed07935388 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2014.07.24 Kentaro FUKUCHI * qrinput.c: - Code refactoring (QRinput_Struct_count has been added). + - and more code cleanups. 2014.07.08 Kentaro FUKUCHI * qrenc.c, qrinput.c, tests/test_qrinput.c: diff --git a/qrinput.c b/qrinput.c index a93de80b96..783bd37895 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1434,18 +1434,6 @@ static unsigned char QRinput_Struct_calcParity(QRinput_Struct *s) return parity; } -static int QRinput_Struct_count(QRinput_Struct *s) -{ - int num = 0; - QRinput_InputList *list; - - for(list = s->head; list != NULL; list = list->next) { - num++; - } - - return num; -} - static int QRinput_List_shrinkEntry(QRinput_List *entry, int bytes) { unsigned char *data; @@ -1590,17 +1578,20 @@ ABORT: int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s) { - int num, i; + int i; QRinput_InputList *list; + if(s->size == 1) { + return 0; + } + if(s->parity < 0) { QRinput_Struct_calcParity(s); } - num = QRinput_Struct_count(s); i = 1; list = s->head; while(list != NULL) { - if(QRinput_insertStructuredAppendHeader(list->input, num, i, s->parity)) + if(QRinput_insertStructuredAppendHeader(list->input, s->size, i, s->parity)) return -1; i++; list = list->next; -- cgit 0.0.5-2-1-g0f52 From f2ec7368aba84c9e661d9a0e9068fde854e4878c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 24 Jul 2014 18:56:11 +0900 Subject: Added new option, "verbose". --- ChangeLog | 4 +++- qrenc.c | 23 ++++++++++++++++++----- qrencode.1.in | 3 +++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed07935388..581fb0cfb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,9 @@ 2014.07.24 Kentaro FUKUCHI * qrinput.c: - Code refactoring (QRinput_Struct_count has been added). - - and more code cleanups. + - And more code cleanups. + * qrinput.c, qrencode.1.in: + - Added new option, "verbose". 2014.07.08 Kentaro FUKUCHI * qrenc.c, qrinput.c, tests/test_qrinput.c: diff --git a/qrenc.c b/qrenc.c index 93f8299bd4..643d4d57e4 100644 --- a/qrenc.c +++ b/qrenc.c @@ -47,6 +47,8 @@ static QRencodeMode hint = QR_MODE_8; static unsigned char fg_color[4] = {0, 0, 0, 255}; static unsigned char bg_color[4] = {255, 255, 255, 255}; +static int verbose = 0; + enum imageType { PNG_TYPE, PNG32_TYPE, @@ -78,9 +80,10 @@ static const struct option options[] = { {"8bit" , no_argument , NULL, '8'}, {"rle" , no_argument , &rle, 1}, {"micro" , no_argument , NULL, 'M'}, - {"foreground" , required_argument, NULL, 'f'}, - {"background" , required_argument, NULL, 'b'}, + {"foreground" , required_argument, NULL, 'f'}, + {"background" , required_argument, NULL, 'b'}, {"version" , no_argument , NULL, 'V'}, + {"verbose" , no_argument , &verbose, 1}, {NULL, 0, NULL, 0} }; @@ -135,6 +138,8 @@ static void usage(int help, int longopt, int status) " Color output support available only in PNG and SVG.\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" +" --verbose\n" +" display verbose information to stderr.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" " standard input.\n\n" "*SYMBOL VERSIONS\n" @@ -886,6 +891,11 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil } exit(EXIT_FAILURE); } + + if(verbose) { + fprintf(stderr, "File: %s, Version: %d\n", (outfile!=NULL)?outfile:"(stdout)", qrcode->version); + } + switch(image_type) { case PNG_TYPE: case PNG32_TYPE: @@ -917,6 +927,7 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil fprintf(stderr, "Unknown image type.\n"); exit(EXIT_FAILURE); } + QRcode_free(qrcode); } @@ -1002,6 +1013,11 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch } else { snprintf(filename, FILENAME_MAX, "%s-%02d", base, i); } + + if(verbose) { + fprintf(stderr, "File: %s, Version: %d\n", filename, p->code->version); + } + switch(image_type) { case PNG_TYPE: case PNG32_TYPE: @@ -1158,9 +1174,6 @@ int main(int argc, char **argv) case '8': eightbit = 1; break; - case 'r': - rle = 1; - break; case 'M': micro = 1; break; diff --git a/qrencode.1.in b/qrencode.1.in index bade365c98..5fa73e6f79 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -75,6 +75,9 @@ Color output support available only in PNG and SVG. .B \-V, \-\-version display the version number and copyrights of the qrencode. .TP +.B \-\-verbose +display verbose information to stderr. +.TP .B [STRING] input data. If it is not specified, data will be taken from standard input. -- cgit 0.0.5-2-1-g0f52 From 5c2635eeddf95722618dfd660ca5a3ed5dd032f6 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 24 Jul 2014 19:17:03 +0900 Subject: A new test has been added. --- ChangeLog | 4 ++++ tests/test_qrinput.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 581fb0cfb0..25147a99f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ * qrinput.c: - Code refactoring (QRinput_Struct_count has been added). - And more code cleanups. + - Avoid to add a Structued-append chunk when only one symbol is + generated. + * tests/test_qrinput.c: + - New test has been added. * qrinput.c, qrencode.1.in: - Added new option, "verbose". diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 9a9e544bfc..5c2798e522 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -555,6 +555,24 @@ void test_struct_split_invalidVersion(void) free(str); } +void test_struct_singlestructure(void) +{ + QRinput *input; + QRinput_Struct *s; + char *str = "TEST"; + + testStart("Testing structured-append symbols. (single structure)"); + input = QRinput_new2(10, QR_ECLEVEL_H); + QRinput_append(input, QR_MODE_8, strlen(str), (unsigned char *)str); + s = QRinput_splitQRinputToStruct(input); + assert_nonnull(s, "must return a code."); + assert_equal(s->size, 1, "size must be 1, but %d returned.", s->size); + printQRinputInfo(s->head->input); + testFinish(); + if(s != NULL) QRinput_Struct_free(s); + QRinput_free(input); +} + void test_splitentry(void) { QRinput *i1, *i2; @@ -953,6 +971,7 @@ int main(void) test_struct_split_example(); test_struct_split_tooLarge(); test_struct_split_invalidVersion(); + test_struct_singlestructure(); test_parity(); test_parity2(); test_null_free(); -- cgit 0.0.5-2-1-g0f52 From ea57eb9a4d2735de51c42e2aac3987a477dddf2e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 24 Jul 2014 19:24:34 +0900 Subject: New debug function has been added. --- ChangeLog | 2 ++ tests/common.h | 14 ++++++++++++++ tests/test_qrinput.c | 6 ++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25147a99f2..ccae3f1f3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ - New test has been added. * qrinput.c, qrencode.1.in: - Added new option, "verbose". + * tests/common.h: + - printQRinputStruct() has been added. 2014.07.08 Kentaro FUKUCHI * qrenc.c, qrinput.c, tests/test_qrinput.c: diff --git a/tests/common.h b/tests/common.h index 2d3b6c4ed8..4d284cafb3 100644 --- a/tests/common.h +++ b/tests/common.h @@ -71,6 +71,20 @@ void printQRinputInfo(QRinput *input) } } +void printQRinputStruct(QRinput_Struct *s) +{ + QRinput_InputList *list; + int i = 1; + + printf("Struct size: %d\n", s->size); + printf("Struct parity: %08x\n", s->parity); + for(list = s->head; list != NULL; list = list->next) { + printf("Symbol %d - ", i); + printQRinputInfo(list->input); + i++; + } +} + void printFrame(int width, unsigned char *frame) { int x, y; diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 5c2798e522..73a5787b7c 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -563,11 +563,13 @@ void test_struct_singlestructure(void) testStart("Testing structured-append symbols. (single structure)"); input = QRinput_new2(10, QR_ECLEVEL_H); - QRinput_append(input, QR_MODE_8, strlen(str), (unsigned char *)str); + QRinput_append(input, QR_MODE_AN, strlen(str), (unsigned char *)str); s = QRinput_splitQRinputToStruct(input); assert_nonnull(s, "must return a code."); assert_equal(s->size, 1, "size must be 1, but %d returned.", s->size); - printQRinputInfo(s->head->input); + if(s->size != 1) { + printQRinputStruct(s); + } testFinish(); if(s != NULL) QRinput_Struct_free(s); QRinput_free(input); -- cgit 0.0.5-2-1-g0f52 From dee86b20d83c8a92fb7f682f2e76b3ac72583835 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 24 Jul 2014 19:43:44 +0900 Subject: Credit has been corrected. --- ChangeLog | 2 ++ rsecc.c | 2 ++ rsecc.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index ccae3f1f3c..025979e7ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ - Added new option, "verbose". * tests/common.h: - printQRinputStruct() has been added. + * rsecc.{c,h}: + - Copyright notice and credit has been corrected. 2014.07.08 Kentaro FUKUCHI * qrenc.c, qrinput.c, tests/test_qrinput.c: diff --git a/rsecc.c b/rsecc.c index 3358317c26..bcf99e2f28 100644 --- a/rsecc.c +++ b/rsecc.c @@ -2,7 +2,9 @@ * qrencode - QR Code encoder * * Reed solomon error correction code encoder specialized for QR code. + * This code is based on Phil Karn's libfec and rewriten by Kentaro Fukuchi. * + * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Copyright (C) 2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or diff --git a/rsecc.h b/rsecc.h index ff34449a6f..5d2e400af6 100644 --- a/rsecc.h +++ b/rsecc.h @@ -2,7 +2,9 @@ * qrencode - QR Code encoder * * Reed solomon error correction code encoder specialized for QR code. + * This code is based on Phil Karn's libfec and rewriten by Kentaro Fukuchi. * + * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Copyright (C) 2014 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or -- cgit 0.0.5-2-1-g0f52 From 4c511e19c3b76c2ee636a45015f1af5f96c510b9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 24 Jul 2014 21:17:35 +0900 Subject: Various updates. --- ChangeLog | 7 ++++++- README | 2 +- README.md | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 025979e7ea..33fcbde287 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,7 @@ - Code refactoring (QRinput_Struct_count has been added). - And more code cleanups. - Avoid to add a Structued-append chunk when only one symbol is - generated. + generated. (Thanks to Yoshimichi Inoue) * tests/test_qrinput.c: - New test has been added. * qrinput.c, qrencode.1.in: @@ -12,6 +12,11 @@ - printQRinputStruct() has been added. * rsecc.{c,h}: - Copyright notice and credit has been corrected. + * README, README.md: + - ACKNOWLEDGMENTS updates. + [3.4] + - Bumped version to 3.4.4. + * Version 3.4.4 has ben released. 2014.07.08 Kentaro FUKUCHI * qrenc.c, qrinput.c, tests/test_qrinput.c: diff --git a/README b/README index a1868680be..f13537c2e5 100644 --- a/README +++ b/README @@ -142,5 +142,5 @@ Greg Hart - PNG32 support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore +ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue - bug report / suggestion diff --git a/README.md b/README.md index df012ece9d..c566a808c1 100644 --- a/README.md +++ b/README.md @@ -140,4 +140,4 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - Viona - bug fix patch for string splitting - Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration - Greg Hart - PNG32 support patch -- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore - bug report / suggestion +- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From f7a397e41146f034bbde318e53de010aeeeca67e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 25 Jul 2014 02:20:38 +0900 Subject: New test suite test_split_urls has been added. (undertrial) --- .gitignore | 1 + tests/Makefile.am | 4 + tests/URI_testset.inc | 1273 +++++++++++++++++++++++++++++++++++++++++++++++ tests/test_split_urls.c | 89 ++++ 4 files changed, 1367 insertions(+) create mode 100644 tests/URI_testset.inc create mode 100644 tests/test_split_urls.c diff --git a/.gitignore b/.gitignore index 80e41c5cf9..0f5c375581 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ tests/test_qrinput tests/test_qrspec tests/test_rs tests/test_split +tests/test_split_urls tests/view_qrcode use/compile use/config.guess diff --git a/tests/Makefile.am b/tests/Makefile.am index 274a2da2d0..0581c35d74 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,6 +6,7 @@ noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_qrspec test_rs test_qrencode prof_qrencode \ test_mqrspec test_split test_monkey test_mask test_mmask \ create_frame_pattern create_mqr_frame_pattern \ + test_split_urls \ $(sdlPROGRAMS) noinst_LIBRARIES = libdecoder.a DECODER_LIBS = libdecoder.a $(LIBICONV) @@ -42,6 +43,9 @@ test_qrencode_LDADD = ../libqrencode.la $(DECODER_LIBS) test_split_SOURCES = test_split.c test_split_LDADD = ../libqrencode.la +test_split_urls_SOURCES = test_split_urls.c +test_split_urls_LDADD = ../libqrencode.la $(DECODER_LIBS) + test_monkey_SOURCES = test_monkey.c test_monkey_LDADD = ../libqrencode.la $(DECODER_LIBS) diff --git a/tests/URI_testset.inc b/tests/URI_testset.inc new file mode 100644 index 0000000000..3aaaff0234 --- /dev/null +++ b/tests/URI_testset.inc @@ -0,0 +1,1273 @@ +struct TestSet { + int expected_length; + char *url; +}; + +struct TestSet testset[] = { +{3132,"http://ads.bluelithium.com/clk?3,eJytjcFqwzAQRL8mNyO0luUoiB7WcQUGS8RFbXBuqVEcxxbKwSDy93HS0P5AH3uYYXd2AKT4hpOjJ-d4njGWdxIySB2nnB0hoVJKRvkmhTXb8GRyIWBVdw0W01bRAh-Y3Vfb4ItS4Ee.fcqdQBJLQsTg2.5nmzOT479QirH4fOkKcfnfL9WDMk09vhd.ZxpM2cSD17G2yh8uetZWTfoGQ7tXY22N1xa53lfc2DYz.W.yLUnO83xdMVylapkYI7kdzyGQLvjF3wHZQ1eK,http%3A%2F%2Fomicronpath.com%2F%3Fa%3D448%26c%3D3201%26s1%3DYahooStream_917_Nevada4"}, +{3745,"http://ads.bluelithium.com/clk?3,eJytjd2OgjAQhZ.GO9K0lEpJ48WwUNekdIWoBO8UCfKX7gUJ4tNv3bj6AvtlLs7knDlDiDgzSi8sqDzOAtfnviAecSuGGT25DhZCUGwN4tOAOX1lDGxUmULYZT0O4cGnyYoankQcsvrjV245oClCiDfDn8.UYQn.QsS7cP.UGwDbX9vXjdSp6uLwHUuIjtL5ay1btZPDsU3GZCf7ZCZNkcte5YdG3.c33cZY5wU7pq.LleNcx.F7QWHhSjvTNKH5dDUGlWaw-w-Jy1ek,http%3A%2F%2Ftanphysics.com%2Farticles%2Freview1.php%3Futm_source%3DUSA%26utm_medium%3DYHO%26utm_content%3D917-STRM4%26utm_campaign%3DYHO%26keyword%3DYHO-917-STRM4"}, +{896,"http://amigo.geneontology.org/cgi-bin/amigo/go.cgi?view=details&search_constraint=terms&depth=0&query=GO:0042438"}, +{611,"http://amigo.geneontology.org/cgi-bin/amigo/gp-assoc.cgi?gp=UniProtKB:P30046"}, +{212,"http://answers.yahoo.com/"}, +{196,"http://autos.yahoo.com/"}, +{348,"http://baseball.fantasysports.yahoo.com/b1"}, +{234,"http://biogps.org/gene/1652/"}, +{644,"http://blog.washingtonpost.com/dcsportsbog/2007/05/a_caron_butler_surprise.html"}, +{340,"http://ca.wikipedia.org/wiki/Caron_Butler"}, +{212,"http://careers.yahoo.com/"}, +{404,"http://commons.wikimedia.org/wiki/Atlas_of_Turkey"}, +{380,"http://creativecommons.org/licenses/by-sa/3.0/"}, +{380,"http://da.wikipedia.org/wiki/Johann_David_Wyss"}, +{244,"http://de.wikipedia.org/wiki/"}, +{340,"http://de.wikipedia.org/wiki/Caron_Butler"}, +{380,"http://de.wikipedia.org/wiki/Johann_David_Wyss"}, +{340,"http://de.wikipedia.org/wiki/Massey_Lopes"}, +{512,"http://de.wikipedia.org/wiki/T%C3%BCrkische_Verfassung_von_1921"}, +{336,"http://dx.doi.org/10.1002%2Felps.11501301201"}, +{334,"http://dx.doi.org/10.1006%2Fbbrc.1993.2524"}, +{296,"http://dx.doi.org/10.1007%2Fs003359900858"}, +{304,"http://dx.doi.org/10.1021%2Fbi982184o"}, +{402,"http://dx.doi.org/10.1034%2Fj.1600-0625.2003.120307.x"}, +{255,"http://dx.doi.org/10.1038%2F990031"}, +{296,"http://dx.doi.org/10.1038%2Fmsb4100134"}, +{282,"http://dx.doi.org/10.1038%2Fnbt810"}, +{329,"http://dx.doi.org/10.1073%2Fpnas.242603899"}, +{326,"http://dx.doi.org/10.1074%2Fjbc.M203220200"}, +{307,"http://dx.doi.org/10.1101%2Fgr.2596504"}, +{360,"http://dx.doi.org/10.1186%2Fgb-2004-5-10-r84"}, +{228,"http://education.yahoo.com/"}, +{364,"http://en.m.wikipedia.org/wiki/Ambrose_Dyson"}, +{356,"http://en.m.wikipedia.org/wiki/Caron_Butler"}, +{340,"http://en.m.wikipedia.org/wiki/DDT_(gene)"}, +{396,"http://en.m.wikipedia.org/wiki/Johann_David_Wyss"}, +{332,"http://en.m.wikipedia.org/wiki/Lady_Anne"}, +{492,"http://en.m.wikipedia.org/wiki/Sir_Massey_Lopes,_3rd_Baronet"}, +{308,"http://en.m.wikipedia.org/wiki/Tumula"}, +{480,"http://en.m.wikipedia.org/wiki/Turkish_Constitution_of_1921"}, +{556,"http://en.m.wikipedia.org/wiki/Vietnam_University_Admission_Rankings"}, +{444,"http://en.m.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{196,"http://en.wikipedia.org"}, +{816,"http://en.wikipedia.org/w/index.php?title=2013%E2%80%9314_Milwaukee_Bucks_season&action=edit&redlink=1"}, +{548,"http://en.wikipedia.org/w/index.php?title=Ambrose_Dyson&action=edit"}, +{628,"http://en.wikipedia.org/w/index.php?title=Ambrose_Dyson&action=edit§ion=1"}, +{572,"http://en.wikipedia.org/w/index.php?title=Ambrose_Dyson&action=history"}, +{548,"http://en.wikipedia.org/w/index.php?title=Ambrose_Dyson&action=info"}, +{552,"http://en.wikipedia.org/w/index.php?title=Ambrose_Dyson&oldid=562636681"}, +{564,"http://en.wikipedia.org/w/index.php?title=Ambrose_Dyson&printable=yes"}, +{564,"http://en.wikipedia.org/w/index.php?title=Ambrose_Dyson&veaction=edit"}, +{644,"http://en.wikipedia.org/w/index.php?title=Ambrose_Dyson&veaction=edit§ion=1"}, +{540,"http://en.wikipedia.org/w/index.php?title=Caron_Butler&action=edit"}, +{620,"http://en.wikipedia.org/w/index.php?title=Caron_Butler&action=edit§ion=1"}, +{564,"http://en.wikipedia.org/w/index.php?title=Caron_Butler&action=history"}, +{540,"http://en.wikipedia.org/w/index.php?title=Caron_Butler&action=info"}, +{544,"http://en.wikipedia.org/w/index.php?title=Caron_Butler&oldid=571697645"}, +{556,"http://en.wikipedia.org/w/index.php?title=Caron_Butler&printable=yes"}, +{556,"http://en.wikipedia.org/w/index.php?title=Caron_Butler&veaction=edit"}, +{636,"http://en.wikipedia.org/w/index.php?title=Caron_Butler&veaction=edit§ion=1"}, +{780,"http://en.wikipedia.org/w/index.php?title=Court_of_Jurisdictional_Conflict&action=edit&redlink=1"}, +{524,"http://en.wikipedia.org/w/index.php?title=DDT_(gene)&action=edit"}, +{604,"http://en.wikipedia.org/w/index.php?title=DDT_(gene)&action=edit§ion=1"}, +{548,"http://en.wikipedia.org/w/index.php?title=DDT_(gene)&action=history"}, +{524,"http://en.wikipedia.org/w/index.php?title=DDT_(gene)&action=info"}, +{528,"http://en.wikipedia.org/w/index.php?title=DDT_(gene)&oldid=453962249"}, +{540,"http://en.wikipedia.org/w/index.php?title=DDT_(gene)&printable=yes"}, +{540,"http://en.wikipedia.org/w/index.php?title=DDT_(gene)&veaction=edit"}, +{620,"http://en.wikipedia.org/w/index.php?title=DDT_(gene)&veaction=edit§ion=1"}, +{724,"http://en.wikipedia.org/w/index.php?title=Devonshire_County_Council&action=edit&redlink=1"}, +{812,"http://en.wikipedia.org/w/index.php?title=H%C3%A0_T%C4%A9nh_Gifted_High_School&action=edit&redlink=1"}, +{820,"http://en.wikipedia.org/w/index.php?title=H%C6%B0ng_Y%C3%AAn_Gifted_High_School&action=edit&redlink=1"}, +{580,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&action=edit"}, +{660,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&action=edit§ion=1"}, +{660,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&action=edit§ion=2"}, +{604,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&action=history"}, +{580,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&action=info"}, +{584,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&oldid=568638498"}, +{596,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&printable=yes"}, +{596,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&veaction=edit"}, +{676,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&veaction=edit§ion=1"}, +{676,"http://en.wikipedia.org/w/index.php?title=Johann_David_Wyss&veaction=edit§ion=2"}, +{684,"http://en.wikipedia.org/w/index.php?title=Johann_Emmanuel_Wyss&action=edit&redlink=1"}, +{652,"http://en.wikipedia.org/w/index.php?title=Josh_Oppenheimer&action=edit&redlink=1"}, +{588,"http://en.wikipedia.org/w/index.php?title=Lady_Ann&action=edit&redlink=1"}, +{516,"http://en.wikipedia.org/w/index.php?title=Lady_Anne&action=edit"}, +{596,"http://en.wikipedia.org/w/index.php?title=Lady_Anne&action=edit§ion=1"}, +{540,"http://en.wikipedia.org/w/index.php?title=Lady_Anne&action=history"}, +{516,"http://en.wikipedia.org/w/index.php?title=Lady_Anne&action=info"}, +{520,"http://en.wikipedia.org/w/index.php?title=Lady_Anne&oldid=372343156"}, +{532,"http://en.wikipedia.org/w/index.php?title=Lady_Anne&printable=yes"}, +{532,"http://en.wikipedia.org/w/index.php?title=Lady_Anne&veaction=edit"}, +{612,"http://en.wikipedia.org/w/index.php?title=Lady_Anne&veaction=edit§ion=1"}, +{740,"http://en.wikipedia.org/w/index.php?title=Military_Court_of_Cassation&action=edit&redlink=1"}, +{820,"http://en.wikipedia.org/w/index.php?title=Military_High_Court_of_Administration&action=edit&redlink=1"}, +{620,"http://en.wikipedia.org/w/index.php?title=Monte_Mathis&action=edit&redlink=1"}, +{764,"http://en.wikipedia.org/w/index.php?title=Quang_Trung_Gifted_High_School&action=edit&redlink=1"}, +{740,"http://en.wikipedia.org/w/index.php?title=Robert_Hackett_(basketball)&action=edit&redlink=1"}, +{676,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&action=edit"}, +{756,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&action=edit§ion=1"}, +{700,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&action=history"}, +{676,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&action=info"}, +{680,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&oldid=545042390"}, +{692,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&printable=yes"}, +{692,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&veaction=edit"}, +{772,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&veaction=edit§ion=1"}, +{772,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&veaction=edit§ion=2"}, +{772,"http://en.wikipedia.org/w/index.php?title=Sir_Massey_Lopes,_3rd_Baronet&veaction=edit§ion=3"}, +{788,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Ambrose+Dyson"}, +{780,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Caron+Butler"}, +{796,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=DDT+%28gene%29"}, +{820,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Johann+David+Wyss"}, +{756,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Lady+Anne"}, +{932,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Sir+Massey+Lopes%2C+3rd+Baronet"}, +{732,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Tumula"}, +{908,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Turkish+Constitution+of+1921"}, +{980,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Vietnam+University+Admission+Rankings"}, +{868,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Vy%C5%A1n%C3%BD+Slavkov"}, +{1004,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Ambrose+Dyson&oldid=562636681&writer=rl"}, +{996,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Caron+Butler&oldid=571697645&writer=rl"}, +{1012,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=DDT+%28gene%29&oldid=453962249&writer=rl"}, +{1036,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Johann+David+Wyss&oldid=568638498&writer=rl"}, +{972,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Lady+Anne&oldid=372343156&writer=rl"}, +{1148,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Sir+Massey+Lopes%2C+3rd+Baronet&oldid=545042390&writer=rl"}, +{948,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Tumula&oldid=401070860&writer=rl"}, +{1124,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Turkish+Constitution+of+1921&oldid=566504847&writer=rl"}, +{1196,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Vietnam+University+Admission+Rankings&oldid=568532236&writer=rl"}, +{1084,"http://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=render_article&arttitle=Vy%C5%A1n%C3%BD+Slavkov&oldid=541325469&writer=rl"}, +{672,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Ambrose_Dyson&id=562636681"}, +{664,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Caron_Butler&id=571697645"}, +{680,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=DDT_%28gene%29&id=453962249"}, +{704,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Johann_David_Wyss&id=568638498"}, +{640,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Lady_Anne&id=372343156"}, +{816,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Sir_Massey_Lopes%2C_3rd_Baronet&id=545042390"}, +{616,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Tumula&id=401070860"}, +{792,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Turkish_Constitution_of_1921&id=566504847"}, +{864,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Vietnam_University_Admission_Rankings&id=568532236"}, +{752,"http://en.wikipedia.org/w/index.php?title=Special:Cite&page=Vy%C5%A1n%C3%BD_Slavkov&id=541325469"}, +{668,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Ambrose+Dyson"}, +{764,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Ambrose+Dyson&type=signup"}, +{660,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Caron+Butler"}, +{756,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Caron+Butler&type=signup"}, +{676,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=DDT+%28gene%29"}, +{772,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=DDT+%28gene%29&type=signup"}, +{700,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Johann+David+Wyss"}, +{796,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Johann+David+Wyss&type=signup"}, +{636,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Lady+Anne"}, +{732,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Lady+Anne&type=signup"}, +{812,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Sir+Massey+Lopes%2C+3rd+Baronet"}, +{908,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Sir+Massey+Lopes%2C+3rd+Baronet&type=signup"}, +{612,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Tumula"}, +{708,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Tumula&type=signup"}, +{788,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Turkish+Constitution+of+1921"}, +{884,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Turkish+Constitution+of+1921&type=signup"}, +{860,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Vietnam+University+Admission+Rankings"}, +{956,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Vietnam+University+Admission+Rankings&type=signup"}, +{748,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Vy%C5%A1n%C3%BD+Slavkov"}, +{844,"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Vy%C5%A1n%C3%BD+Slavkov&type=signup"}, +{692,"http://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Lady_Anne&namespace=0"}, +{636,"http://en.wikipedia.org/w/index.php?title=Talk:Lady_Anne&action=edit&redlink=1"}, +{628,"http://en.wikipedia.org/w/index.php?title=Template:2002_NBA_Draft&action=edit"}, +{1028,"http://en.wikipedia.org/w/index.php?title=Template:Big_East_Conference_Men%27s_Basketball_Player_of_the_Year_navbox&action=edit"}, +{636,"http://en.wikipedia.org/w/index.php?title=Template:Cartoonist-stub&action=edit"}, +{692,"http://en.wikipedia.org/w/index.php?title=Template:Constitution_of_Turkey&action=edit"}, +{872,"http://en.wikipedia.org/w/index.php?title=Template:Dallas_Mavericks_2010%E2%80%9311_NBA_champions&action=edit"}, +{612,"http://en.wikipedia.org/w/index.php?title=Template:Gene-22-stub&action=edit"}, +{676,"http://en.wikipedia.org/w/index.php?title=Template:Levo%C4%8Da_District&action=edit"}, +{756,"http://en.wikipedia.org/w/index.php?title=Template:Milwaukee_Bucks_current_roster&action=edit"}, +{636,"http://en.wikipedia.org/w/index.php?title=Template:Noctuoidea-stub&action=edit"}, +{580,"http://en.wikipedia.org/w/index.php?title=Template:PBB/1652&action=edit"}, +{604,"http://en.wikipedia.org/w/index.php?title=Template:PDB_Gallery&action=edit"}, +{660,"http://en.wikipedia.org/w/index.php?title=Template:Politics_of_Turkey&action=edit"}, +{676,"http://en.wikipedia.org/w/index.php?title=Template:Pre%C5%A1ov-geo-stub&action=edit"}, +{700,"http://en.wikipedia.org/w/index.php?title=Template:Switzerland-writer-stub&action=edit"}, +{716,"http://en.wikipedia.org/w/index.php?title=Template:The_Swiss_Family_Robinson&action=edit"}, +{700,"http://en.wikipedia.org/w/index.php?title=Template_talk:PBB/1652&action=edit&redlink=1"}, +{836,"http://en.wikipedia.org/w/index.php?title=Template_talk:The_Swiss_Family_Robinson&action=edit&redlink=1"}, +{492,"http://en.wikipedia.org/w/index.php?title=Tumula&action=edit"}, +{572,"http://en.wikipedia.org/w/index.php?title=Tumula&action=edit§ion=1"}, +{516,"http://en.wikipedia.org/w/index.php?title=Tumula&action=history"}, +{492,"http://en.wikipedia.org/w/index.php?title=Tumula&action=info"}, +{496,"http://en.wikipedia.org/w/index.php?title=Tumula&oldid=401070860"}, +{508,"http://en.wikipedia.org/w/index.php?title=Tumula&printable=yes"}, +{508,"http://en.wikipedia.org/w/index.php?title=Tumula&veaction=edit"}, +{588,"http://en.wikipedia.org/w/index.php?title=Tumula&veaction=edit§ion=1"}, +{668,"http://en.wikipedia.org/w/index.php?title=Turkish_Constitution_of_1921&action=edit"}, +{748,"http://en.wikipedia.org/w/index.php?title=Turkish_Constitution_of_1921&action=edit§ion=1"}, +{692,"http://en.wikipedia.org/w/index.php?title=Turkish_Constitution_of_1921&action=history"}, +{668,"http://en.wikipedia.org/w/index.php?title=Turkish_Constitution_of_1921&action=info"}, +{672,"http://en.wikipedia.org/w/index.php?title=Turkish_Constitution_of_1921&oldid=566504847"}, +{684,"http://en.wikipedia.org/w/index.php?title=Turkish_Constitution_of_1921&printable=yes"}, +{684,"http://en.wikipedia.org/w/index.php?title=Turkish_Constitution_of_1921&veaction=edit"}, +{764,"http://en.wikipedia.org/w/index.php?title=Turkish_Constitution_of_1921&veaction=edit§ion=1"}, +{724,"http://en.wikipedia.org/w/index.php?title=Turkish_Court_of_Accounts&action=edit&redlink=1"}, +{740,"http://en.wikipedia.org/w/index.php?title=Vietnam_University_Admission_Rankings&action=edit"}, +{820,"http://en.wikipedia.org/w/index.php?title=Vietnam_University_Admission_Rankings&action=edit§ion=1"}, +{764,"http://en.wikipedia.org/w/index.php?title=Vietnam_University_Admission_Rankings&action=history"}, +{740,"http://en.wikipedia.org/w/index.php?title=Vietnam_University_Admission_Rankings&action=info"}, +{744,"http://en.wikipedia.org/w/index.php?title=Vietnam_University_Admission_Rankings&oldid=568532236"}, +{756,"http://en.wikipedia.org/w/index.php?title=Vietnam_University_Admission_Rankings&printable=yes"}, +{756,"http://en.wikipedia.org/w/index.php?title=Vietnam_University_Admission_Rankings&veaction=edit"}, +{836,"http://en.wikipedia.org/w/index.php?title=Vietnam_University_Admission_Rankings&veaction=edit§ion=1"}, +{628,"http://en.wikipedia.org/w/index.php?title=Vy%C5%A1n%C3%BD_Slavkov&action=edit"}, +{708,"http://en.wikipedia.org/w/index.php?title=Vy%C5%A1n%C3%BD_Slavkov&action=edit§ion=1"}, +{652,"http://en.wikipedia.org/w/index.php?title=Vy%C5%A1n%C3%BD_Slavkov&action=history"}, +{628,"http://en.wikipedia.org/w/index.php?title=Vy%C5%A1n%C3%BD_Slavkov&action=info"}, +{632,"http://en.wikipedia.org/w/index.php?title=Vy%C5%A1n%C3%BD_Slavkov&oldid=541325469"}, +{644,"http://en.wikipedia.org/w/index.php?title=Vy%C5%A1n%C3%BD_Slavkov&printable=yes"}, +{644,"http://en.wikipedia.org/w/index.php?title=Vy%C5%A1n%C3%BD_Slavkov&veaction=edit"}, +{724,"http://en.wikipedia.org/w/index.php?title=Vy%C5%A1n%C3%BD_Slavkov&veaction=edit§ion=1"}, +{568,"http://en.wikipedia.org/w/index.php?title=Vyšný_Slavkov&oldid=541325469"}, +{525,"http://en.wikipedia.org/wiki/%C4%90%E1%BA%AFk_L%E1%BA%AFk_Province"}, +{469,"http://en.wikipedia.org/wiki/%C4%90%E1%BB%93ng_Nai_Province"}, +{685,"http://en.wikipedia.org/wiki/2001%E2%80%9302_NCAA_Division_I_men%27s_basketball_season"}, +{493,"http://en.wikipedia.org/wiki/2002%E2%80%9303_Miami_Heat_season"}, +{437,"http://en.wikipedia.org/wiki/2002%E2%80%9303_NBA_season"}, +{356,"http://en.wikipedia.org/wiki/2002_NBA_Draft"}, +{356,"http://en.wikipedia.org/wiki/2002_NBA_draft"}, +{493,"http://en.wikipedia.org/wiki/2003%E2%80%9304_Miami_Heat_season"}, +{437,"http://en.wikipedia.org/wiki/2003%E2%80%9304_NBA_season"}, +{557,"http://en.wikipedia.org/wiki/2004%E2%80%9305_Los_Angeles_Lakers_season"}, +{437,"http://en.wikipedia.org/wiki/2004%E2%80%9305_NBA_season"}, +{380,"http://en.wikipedia.org/wiki/2004_NBA_Playoffs"}, +{437,"http://en.wikipedia.org/wiki/2005%E2%80%9306_NBA_season"}, +{557,"http://en.wikipedia.org/wiki/2005%E2%80%9306_Washington_Wizards_season"}, +{437,"http://en.wikipedia.org/wiki/2006%E2%80%9307_NBA_season"}, +{557,"http://en.wikipedia.org/wiki/2006%E2%80%9307_Washington_Wizards_season"}, +{364,"http://en.wikipedia.org/wiki/2006_NBA_Finals"}, +{380,"http://en.wikipedia.org/wiki/2006_NBA_Playoffs"}, +{437,"http://en.wikipedia.org/wiki/2007%E2%80%9308_NBA_season"}, +{557,"http://en.wikipedia.org/wiki/2007%E2%80%9308_Washington_Wizards_season"}, +{420,"http://en.wikipedia.org/wiki/2007_NBA_All-Star_Game"}, +{437,"http://en.wikipedia.org/wiki/2008%E2%80%9309_NBA_season"}, +{557,"http://en.wikipedia.org/wiki/2008%E2%80%9309_Washington_Wizards_season"}, +{420,"http://en.wikipedia.org/wiki/2008_NBA_All-Star_Game"}, +{380,"http://en.wikipedia.org/wiki/2008_NBA_Playoffs"}, +{541,"http://en.wikipedia.org/wiki/2009%E2%80%9310_Dallas_Mavericks_season"}, +{437,"http://en.wikipedia.org/wiki/2009%E2%80%9310_NBA_season"}, +{557,"http://en.wikipedia.org/wiki/2009%E2%80%9310_Washington_Wizards_season"}, +{541,"http://en.wikipedia.org/wiki/2010%E2%80%9311_Dallas_Mavericks_season"}, +{437,"http://en.wikipedia.org/wiki/2010%E2%80%9311_NBA_season"}, +{380,"http://en.wikipedia.org/wiki/2010_NBA_Playoffs"}, +{573,"http://en.wikipedia.org/wiki/2011%E2%80%9312_Los_Angeles_Clippers_season"}, +{437,"http://en.wikipedia.org/wiki/2011%E2%80%9312_NBA_season"}, +{364,"http://en.wikipedia.org/wiki/2011_NBA_Finals"}, +{380,"http://en.wikipedia.org/wiki/2011_NBA_Playoffs"}, +{573,"http://en.wikipedia.org/wiki/2012%E2%80%9313_Los_Angeles_Clippers_season"}, +{437,"http://en.wikipedia.org/wiki/2012%E2%80%9313_NBA_season"}, +{380,"http://en.wikipedia.org/wiki/2012_NBA_Playoffs"}, +{437,"http://en.wikipedia.org/wiki/2013%E2%80%9314_NBA_season"}, +{380,"http://en.wikipedia.org/wiki/2013_NBA_Playoffs"}, +{380,"http://en.wikipedia.org/wiki/Abdullah_G%C3%BCl"}, +{572,"http://en.wikipedia.org/wiki/Accession_of_Turkey_to_the_European_Union"}, +{308,"http://en.wikipedia.org/wiki/Adelaide"}, +{332,"http://en.wikipedia.org/wiki/Albert_Pell"}, +{308,"http://en.wikipedia.org/wiki/Alderman"}, +{396,"http://en.wikipedia.org/wiki/Alfredton,_Victoria"}, +{340,"http://en.wikipedia.org/wiki/All_American"}, +{412,"http://en.wikipedia.org/wiki/Allies_of_World_War_I"}, +{364,"http://en.wikipedia.org/wiki/Alonzo_Mourning"}, +{396,"http://en.wikipedia.org/wiki/Amar%27e_Stoudemire"}, +{420,"http://en.wikipedia.org/wiki/Amateur_Athletic_Union"}, +{348,"http://en.wikipedia.org/wiki/Ambrose_Dyson"}, +{356,"http://en.wikipedia.org/wiki/Ambrose_Dyson#"}, +{444,"http://en.wikipedia.org/wiki/Ambrose_Dyson#cite_note-2"}, +{516,"http://en.wikipedia.org/wiki/Ambrose_Dyson#cite_note-lindesay-1"}, +{436,"http://en.wikipedia.org/wiki/Ambrose_Dyson#cite_ref-2"}, +{524,"http://en.wikipedia.org/wiki/Ambrose_Dyson#cite_ref-lindesay_1-0"}, +{524,"http://en.wikipedia.org/wiki/Ambrose_Dyson#cite_ref-lindesay_1-1"}, +{460,"http://en.wikipedia.org/wiki/Ambrose_Dyson#mw-navigation"}, +{420,"http://en.wikipedia.org/wiki/Ambrose_Dyson#p-search"}, +{292,"http://en.wikipedia.org/wiki/Animal"}, +{580,"http://en.wikipedia.org/wiki/Anne,_Duchess_of_Cumberland_and_Strathearn"}, +{324,"http://en.wikipedia.org/wiki/Anne_Bacon"}, +{332,"http://en.wikipedia.org/wiki/Anne_Brewis"}, +{492,"http://en.wikipedia.org/wiki/Anne_Conway,_Viscountess_Conway"}, +{340,"http://en.wikipedia.org/wiki/Anne_Halkett"}, +{316,"http://en.wikipedia.org/wiki/Anne_Hyde"}, +{340,"http://en.wikipedia.org/wiki/Anne_Lambton"}, +{500,"http://en.wikipedia.org/wiki/Anne_Lennard,_Countess_of_Sussex"}, +{500,"http://en.wikipedia.org/wiki/Anne_Stanley,_Countess_of_Ancram"}, +{540,"http://en.wikipedia.org/wiki/Anne_Stanley,_Countess_of_Castlehaven"}, +{332,"http://en.wikipedia.org/wiki/Anne_Wilson"}, +{356,"http://en.wikipedia.org/wiki/Antawn_Jamison"}, +{276,"http://en.wikipedia.org/wiki/Area"}, +{316,"http://en.wikipedia.org/wiki/Arthropod"}, +{396,"http://en.wikipedia.org/wiki/Assist_(basketball)"}, +{436,"http://en.wikipedia.org/wiki/Atat%C3%BCrk%27s_Reforms"}, +{380,"http://en.wikipedia.org/wiki/Authority_control"}, +{669,"http://en.wikipedia.org/wiki/B%C3%A0_R%E1%BB%8Ba%E2%80%93V%C5%A9ng_T%C3%A0u_Province"}, +{520,"http://en.wikipedia.org/wiki/B%C3%ACnh_%C4%90%E1%BB%8Bnh_Province"}, +{528,"http://en.wikipedia.org/wiki/B%C3%ACnh_Ph%C6%B0%E1%BB%9Bc_Province"}, +{450,"http://en.wikipedia.org/wiki/B%E1%BA%AFc_Giang_Province"}, +{442,"http://en.wikipedia.org/wiki/B%E1%BA%AFc_Ninh_Province"}, +{308,"http://en.wikipedia.org/wiki/Baldovce"}, +{308,"http://en.wikipedia.org/wiki/Ballarat"}, +{388,"http://en.wikipedia.org/wiki/Ballarat,_Victoria"}, +{364,"http://en.wikipedia.org/wiki/Baron_Roborough"}, +{324,"http://en.wikipedia.org/wiki/Basketball"}, +{316,"http://en.wikipedia.org/wiki/Beharovce"}, +{356,"http://en.wikipedia.org/wiki/Ben_Hansbrough"}, +{380,"http://en.wikipedia.org/wiki/Benjamin_Disraeli"}, +{476,"http://en.wikipedia.org/wiki/Beverly_Hills_Family_Robinson"}, +{539,"http://en.wikipedia.org/wiki/Big_East_Conference_(1979%E2%80%932013)"}, +{700,"http://en.wikipedia.org/wiki/Big_East_Conference_Men%27s_Basketball_Player_of_the_Year"}, +{316,"http://en.wikipedia.org/wiki/Bijacovce"}, +{644,"http://en.wikipedia.org/wiki/Bill_Russell_NBA_Finals_Most_Valuable_Player_Award"}, +{332,"http://en.wikipedia.org/wiki/Billy_Owens"}, +{444,"http://en.wikipedia.org/wiki/Biological_classification"}, +{388,"http://en.wikipedia.org/wiki/Block_(basketball)"}, +{284,"http://en.wikipedia.org/wiki/Blogs"}, +{404,"http://en.wikipedia.org/wiki/Bo%C5%A1tjan_Nachbar"}, +{324,"http://en.wikipedia.org/wiki/Bob_Bender"}, +{356,"http://en.wikipedia.org/wiki/Brandin_Knight"}, +{460,"http://en.wikipedia.org/wiki/Brandon_Knight_(basketball)"}, +{364,"http://en.wikipedia.org/wiki/Brendan_Haywood"}, +{356,"http://en.wikipedia.org/wiki/Brian_Cardinal"}, +{332,"http://en.wikipedia.org/wiki/Brian_Grant"}, +{308,"http://en.wikipedia.org/wiki/Brutovce"}, +{308,"http://en.wikipedia.org/wiki/Buglovce"}, +{332,"http://en.wikipedia.org/wiki/Burger_King"}, +{340,"http://en.wikipedia.org/wiki/C._J._Dennis"}, +{380,"http://en.wikipedia.org/wiki/Cabinet_of_Turkey"}, +{292,"http://en.wikipedia.org/wiki/Caliph"}, +{316,"http://en.wikipedia.org/wiki/Caliphate"}, +{372,"http://en.wikipedia.org/wiki/Carlo_Pellegrini"}, +{348,"http://en.wikipedia.org/wiki/Carlos_Boozer"}, +{356,"http://en.wikipedia.org/wiki/Carlos_Delfino"}, +{340,"http://en.wikipedia.org/wiki/Caron_Butler"}, +{348,"http://en.wikipedia.org/wiki/Caron_Butler#"}, +{460,"http://en.wikipedia.org/wiki/Caron_Butler#College_career"}, +{428,"http://en.wikipedia.org/wiki/Caron_Butler#Early_life"}, +{460,"http://en.wikipedia.org/wiki/Caron_Butler#External_links"}, +{428,"http://en.wikipedia.org/wiki/Caron_Butler#NBA_career"}, +{516,"http://en.wikipedia.org/wiki/Caron_Butler#NBA_career_statistics"}, +{452,"http://en.wikipedia.org/wiki/Caron_Butler#Personal_life"}, +{412,"http://en.wikipedia.org/wiki/Caron_Butler#Playoffs"}, +{428,"http://en.wikipedia.org/wiki/Caron_Butler#References"}, +{460,"http://en.wikipedia.org/wiki/Caron_Butler#Regular_season"}, +{444,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-10"}, +{436,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-5"}, +{524,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-AllStories-7"}, +{466,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-BK-20"}, +{492,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-oprah1-1"}, +{492,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-oprah2-2"}, +{492,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-straws-3"}, +{524,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-toughjuice-8"}, +{516,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-washtimes-9"}, +{556,"http://en.wikipedia.org/wiki/Caron_Butler#cite_note-wp-greatescape-4"}, +{436,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-10"}, +{428,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-5"}, +{532,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-AllStories_7-0"}, +{532,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-AllStories_7-1"}, +{476,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-BK_20-0"}, +{476,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-BK_20-1"}, +{500,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-oprah1_1-0"}, +{500,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-oprah2_2-0"}, +{500,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-straws_3-0"}, +{500,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-straws_3-1"}, +{500,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-straws_3-2"}, +{532,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-toughjuice_8-0"}, +{524,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-washtimes_9-0"}, +{564,"http://en.wikipedia.org/wiki/Caron_Butler#cite_ref-wp-greatescape_4-0"}, +{452,"http://en.wikipedia.org/wiki/Caron_Butler#mw-navigation"}, +{412,"http://en.wikipedia.org/wiki/Caron_Butler#p-search"}, +{324,"http://en.wikipedia.org/wiki/Cartoonist"}, +{356,"http://en.wikipedia.org/wiki/Casey_Jacobsen"}, +{404,"http://en.wikipedia.org/wiki/Category:1743_births"}, +{404,"http://en.wikipedia.org/wiki/Category:1818_births"}, +{404,"http://en.wikipedia.org/wiki/Category:1818_deaths"}, +{404,"http://en.wikipedia.org/wiki/Category:1876_births"}, +{404,"http://en.wikipedia.org/wiki/Category:1908_deaths"}, +{404,"http://en.wikipedia.org/wiki/Category:1913_deaths"}, +{524,"http://en.wikipedia.org/wiki/Category:1921_in_the_Ottoman_Empire"}, +{404,"http://en.wikipedia.org/wiki/Category:1980_births"}, +{492,"http://en.wikipedia.org/wiki/Category:19th-century_novelists"}, +{576,"http://en.wikipedia.org/wiki/Category:Accuracy_disputes_from_March_2012"}, +{596,"http://en.wikipedia.org/wiki/Category:African-American_basketball_players"}, +{572,"http://en.wikipedia.org/wiki/Category:All_article_disambiguation_pages"}, +{636,"http://en.wikipedia.org/wiki/Category:All_articles_lacking_reliable_references"}, +{652,"http://en.wikipedia.org/wiki/Category:All_articles_needing_additional_references"}, +{572,"http://en.wikipedia.org/wiki/Category:All_articles_needing_coordinates"}, +{532,"http://en.wikipedia.org/wiki/Category:All_articles_to_be_expanded"}, +{620,"http://en.wikipedia.org/wiki/Category:All_articles_with_unsourced_statements"}, +{508,"http://en.wikipedia.org/wiki/Category:All_disambiguation_pages"}, +{620,"http://en.wikipedia.org/wiki/Category:All_pages_needing_factual_verification"}, +{644,"http://en.wikipedia.org/wiki/Category:Articles_containing_Turkish-language_text"}, +{752,"http://en.wikipedia.org/wiki/Category:Articles_lacking_reliable_references_from_February_2013"}, +{760,"http://en.wikipedia.org/wiki/Category:Articles_needing_additional_references_from_January_2011"}, +{716,"http://en.wikipedia.org/wiki/Category:Articles_needing_translation_from_German_Wikipedia"}, +{632,"http://en.wikipedia.org/wiki/Category:Articles_to_be_expanded_from_August_2013"}, +{636,"http://en.wikipedia.org/wiki/Category:Articles_with_%27species%27_microformats"}, +{744,"http://en.wikipedia.org/wiki/Category:Articles_with_unsourced_statements_from_September_2010"}, +{492,"http://en.wikipedia.org/wiki/Category:Australian_cartoonists"}, +{500,"http://en.wikipedia.org/wiki/Category:Australian_illustrators"}, +{476,"http://en.wikipedia.org/wiki/Category:Australian_satirists"}, +{700,"http://en.wikipedia.org/wiki/Category:Baronets_in_the_Baronetage_of_the_United_Kingdom"}, +{580,"http://en.wikipedia.org/wiki/Category:Basketball_players_from_Wisconsin"}, +{444,"http://en.wikipedia.org/wiki/Category:Cartoonist_stubs"}, +{524,"http://en.wikipedia.org/wiki/Category:Cartoonists_from_Melbourne"}, +{508,"http://en.wikipedia.org/wiki/Category:Chromosome_22_gene_stubs"}, +{684,"http://en.wikipedia.org/wiki/Category:Connecticut_Huskies_men%27s_basketball_players"}, +{532,"http://en.wikipedia.org/wiki/Category:Conservative_Party_(UK)_MPs"}, +{500,"http://en.wikipedia.org/wiki/Category:Constitutions_of_Turkey"}, +{508,"http://en.wikipedia.org/wiki/Category:Dallas_Mavericks_players"}, +{484,"http://en.wikipedia.org/wiki/Category:Defunct_constitutions"}, +{476,"http://en.wikipedia.org/wiki/Category:Disambiguation_pages"}, +{492,"http://en.wikipedia.org/wiki/Category:High_Sheriffs_of_Devon"}, +{620,"http://en.wikipedia.org/wiki/Category:High_schools_for_the_gifted_in_Vietnam"}, +{500,"http://en.wikipedia.org/wiki/Category:High_schools_in_Vietnam"}, +{428,"http://en.wikipedia.org/wiki/Category:Human_proteins"}, +{420,"http://en.wikipedia.org/wiki/Category:Living_people"}, +{540,"http://en.wikipedia.org/wiki/Category:Los_Angeles_Clippers_players"}, +{524,"http://en.wikipedia.org/wiki/Category:Los_Angeles_Lakers_players"}, +{852,"http://en.wikipedia.org/wiki/Category:Members_of_the_United_Kingdom_Parliament_for_English_constituencies"}, +{492,"http://en.wikipedia.org/wiki/Category:Miami_Heat_draft_picks"}, +{460,"http://en.wikipedia.org/wiki/Category:Miami_Heat_players"}, +{428,"http://en.wikipedia.org/wiki/Category:Micronoctuidae"}, +{644,"http://en.wikipedia.org/wiki/Category:National_Basketball_Association_All-Stars"}, +{444,"http://en.wikipedia.org/wiki/Category:Noctuoidea_stubs"}, +{556,"http://en.wikipedia.org/wiki/Category:Pages_with_no_translate_target"}, +{444,"http://en.wikipedia.org/wiki/Category:People_from_Bern"}, +{548,"http://en.wikipedia.org/wiki/Category:People_from_Racine,_Wisconsin"}, +{588,"http://en.wikipedia.org/wiki/Category:Pre%C5%A1ov_Region_geography_stubs"}, +{460,"http://en.wikipedia.org/wiki/Category:Schools_in_Vietnam"}, +{436,"http://en.wikipedia.org/wiki/Category:Shooting_guards"}, +{428,"http://en.wikipedia.org/wiki/Category:Small_forwards"}, +{386,"http://en.wikipedia.org/wiki/Category:Spi%C5%A1"}, +{524,"http://en.wikipedia.org/wiki/Category:Swiss_children%27s_writers"}, +{436,"http://en.wikipedia.org/wiki/Category:Swiss_novelists"}, +{460,"http://en.wikipedia.org/wiki/Category:Swiss_writer_stubs"}, +{479,"http://en.wikipedia.org/wiki/Category:UK_MPs_1857%E2%80%931859"}, +{479,"http://en.wikipedia.org/wiki/Category:UK_MPs_1859%E2%80%931865"}, +{479,"http://en.wikipedia.org/wiki/Category:UK_MPs_1868%E2%80%931874"}, +{479,"http://en.wikipedia.org/wiki/Category:UK_MPs_1874%E2%80%931880"}, +{479,"http://en.wikipedia.org/wiki/Category:UK_MPs_1880%E2%80%931885"}, +{548,"http://en.wikipedia.org/wiki/Category:United_States_Navy_ship_names"}, +{592,"http://en.wikipedia.org/wiki/Category:Use_British_English_from_March_2012"}, +{560,"http://en.wikipedia.org/wiki/Category:Use_dmy_dates_from_January_2012"}, +{536,"http://en.wikipedia.org/wiki/Category:Use_dmy_dates_from_July_2013"}, +{660,"http://en.wikipedia.org/wiki/Category:Vietnam_articles_missing_geocoordinate_data"}, +{724,"http://en.wikipedia.org/wiki/Category:Villages_and_municipalities_in_Levo%C4%8Da_District"}, +{524,"http://en.wikipedia.org/wiki/Category:Washington_Wizards_players"}, +{964,"http://en.wikipedia.org/wiki/Category:Wikipedia_articles_incorporating_an_LRPP-Bt_template_without_an_unnamed_parameter"}, +{816,"http://en.wikipedia.org/wiki/Category:Wikipedia_articles_needing_factual_verification_from_March_2012"}, +{848,"http://en.wikipedia.org/wiki/Category:Wikipedia_articles_needing_page_number_citations_from_February_2013"}, +{636,"http://en.wikipedia.org/wiki/Category:Wikipedia_articles_with_VIAF_identifiers"}, +{412,"http://en.wikipedia.org/wiki/Cemil_%C3%87i%C3%A7ek"}, +{540,"http://en.wikipedia.org/wiki/Charles_Smith_(basketball,_born_1965)"}, +{540,"http://en.wikipedia.org/wiki/Charles_Smith_(basketball,_born_1967)"}, +{364,"http://en.wikipedia.org/wiki/Chris_Jefferies"}, +{444,"http://en.wikipedia.org/wiki/Chris_Mullin_(basketball)"}, +{436,"http://en.wikipedia.org/wiki/Chris_Owens_(basketball)"}, +{340,"http://en.wikipedia.org/wiki/Chris_Wilcox"}, +{348,"http://en.wikipedia.org/wiki/Chromosome_22"}, +{348,"http://en.wikipedia.org/wiki/Chucky_Atkins"}, +{380,"http://en.wikipedia.org/wiki/Clare_Sewell_Read"}, +{396,"http://en.wikipedia.org/wiki/Cleveland_Cavaliers"}, +{548,"http://en.wikipedia.org/wiki/Connecticut_Huskies_men%27s_basketball"}, +{499,"http://en.wikipedia.org/wiki/Conservative_Government_1874-1880"}, +{428,"http://en.wikipedia.org/wiki/Conservative_Party_(UK)"}, +{340,"http://en.wikipedia.org/wiki/Constitution"}, +{420,"http://en.wikipedia.org/wiki/Constitution_of_Turkey"}, +{484,"http://en.wikipedia.org/wiki/Constitutional_Court_of_Turkey"}, +{500,"http://en.wikipedia.org/wiki/Constitutional_history_of_Turkey"}, +{428,"http://en.wikipedia.org/wiki/Constitutional_monarchy"}, +{340,"http://en.wikipedia.org/wiki/Corey_Brewer"}, +{364,"http://en.wikipedia.org/wiki/Corsley_Edwards"}, +{460,"http://en.wikipedia.org/wiki/Court_of_Cassation_(Turkey)"}, +{372,"http://en.wikipedia.org/wiki/Curtis_Borchardt"}, +{516,"http://en.wikipedia.org/wiki/D%C3%BAbrava,_Levo%C4%8Da_District"}, +{324,"http://en.wikipedia.org/wiki/DDT_(gene)"}, +{332,"http://en.wikipedia.org/wiki/DDT_(gene)#"}, +{476,"http://en.wikipedia.org/wiki/DDT_(gene)#cite_note-entrez-3"}, +{506,"http://en.wikipedia.org/wiki/DDT_(gene)#cite_note-pmid9480844-1"}, +{484,"http://en.wikipedia.org/wiki/DDT_(gene)#cite_ref-entrez_3-0"}, +{484,"http://en.wikipedia.org/wiki/DDT_(gene)#cite_ref-entrez_3-1"}, +{518,"http://en.wikipedia.org/wiki/DDT_(gene)#cite_ref-pmid9480844_1-0"}, +{436,"http://en.wikipedia.org/wiki/DDT_(gene)#mw-navigation"}, +{396,"http://en.wikipedia.org/wiki/DDT_(gene)#p-search"}, +{300,"http://en.wikipedia.org/wiki/Da_Nang"}, +{348,"http://en.wikipedia.org/wiki/Dajuan_Wagner"}, +{372,"http://en.wikipedia.org/wiki/Dallas_Mavericks"}, +{372,"http://en.wikipedia.org/wiki/Dan_Callandrillo"}, +{324,"http://en.wikipedia.org/wiki/Dan_Dickau"}, +{340,"http://en.wikipedia.org/wiki/Dan_Gadzuric"}, +{340,"http://en.wikipedia.org/wiki/Daniel_Defoe"}, +{364,"http://en.wikipedia.org/wiki/Darius_Songaila"}, +{380,"http://en.wikipedia.org/wiki/Darrell_Armstrong"}, +{300,"http://en.wikipedia.org/wiki/Das_Bus"}, +{356,"http://en.wikipedia.org/wiki/David_Andersen"}, +{340,"http://en.wikipedia.org/wiki/DeJuan_Blair"}, +{380,"http://en.wikipedia.org/wiki/DeShawn_Stevenson"}, +{364,"http://en.wikipedia.org/wiki/Derrick_Coleman"}, +{380,"http://en.wikipedia.org/wiki/Deshawn_Stevenson"}, +{444,"http://en.wikipedia.org/wiki/Digital_object_identifier"}, +{348,"http://en.wikipedia.org/wiki/Dirk_Nowitzki"}, +{447,"http://en.wikipedia.org/wiki/Dlh%C3%A9_Str%C3%A1%C5%BEe"}, +{508,"http://en.wikipedia.org/wiki/Do%C4%BEany,_Levo%C4%8Da_District"}, +{356,"http://en.wikipedia.org/wiki/Doma%C5%88ovce"}, +{364,"http://en.wikipedia.org/wiki/Dominique_Jones"}, +{372,"http://en.wikipedia.org/wiki/Donyell_Marshall"}, +{292,"http://en.wikipedia.org/wiki/Dravce"}, +{332,"http://en.wikipedia.org/wiki/Drew_Gooden"}, +{364,"http://en.wikipedia.org/wiki/Duke_University"}, +{332,"http://en.wikipedia.org/wiki/Dwane_Casey"}, +{436,"http://en.wikipedia.org/wiki/Eastern_Conference_(NBA)"}, +{380,"http://en.wikipedia.org/wiki/Economy_of_Turkey"}, +{444,"http://en.wikipedia.org/wiki/Eddie_Jordan_(basketball)"}, +{404,"http://en.wikipedia.org/wiki/Edward_Ambrose_Dyson"}, +{340,"http://en.wikipedia.org/wiki/Edward_Dyson"}, +{316,"http://en.wikipedia.org/wiki/Ekpe_Udoh"}, +{396,"http://en.wikipedia.org/wiki/Elections_in_Turkey"}, +{540,"http://en.wikipedia.org/wiki/Elections_in_Turkey#General_elections"}, +{524,"http://en.wikipedia.org/wiki/Elections_in_Turkey#Local_elections"}, +{316,"http://en.wikipedia.org/wiki/Elevation"}, +{300,"http://en.wikipedia.org/wiki/Elite_8"}, +{340,"http://en.wikipedia.org/wiki/Emeka_Okafor"}, +{300,"http://en.wikipedia.org/wiki/Ensembl"}, +{356,"http://en.wikipedia.org/wiki/Entente_powers"}, +{292,"http://en.wikipedia.org/wiki/Entrez"}, +{292,"http://en.wikipedia.org/wiki/Enzyme"}, +{436,"http://en.wikipedia.org/wiki/Enzyme_Commission_number"}, +{436,"http://en.wikipedia.org/wiki/Erdo%C4%9Fan_III_Cabinet"}, +{340,"http://en.wikipedia.org/wiki/Eric_Bledsoe"}, +{396,"http://en.wikipedia.org/wiki/Ersan_%C4%B0lyasova"}, +{580,"http://en.wikipedia.org/wiki/Establishment_of_Turkish_national_movement"}, +{604,"http://en.wikipedia.org/wiki/European_Union_%E2%80%93_Turkey_Customs_Union"}, +{420,"http://en.wikipedia.org/wiki/Executive_(government)"}, +{500,"http://en.wikipedia.org/wiki/FIBA_Under-21_World_Championship"}, +{372,"http://en.wikipedia.org/wiki/Family_(biology)"}, +{396,"http://en.wikipedia.org/wiki/Federico_Kammerichs"}, +{428,"http://en.wikipedia.org/wiki/Field_goal_(basketball)"}, +{484,"http://en.wikipedia.org/wiki/File:A_coloured_voting_box.svg"}, +{508,"http://en.wikipedia.org/wiki/File:Bryant_Fades_Over_Butler.jpg"}, +{412,"http://en.wikipedia.org/wiki/File:Caron_Butler.JPG"}, +{428,"http://en.wikipedia.org/wiki/File:Creatorballoon.png"}, +{380,"http://en.wikipedia.org/wiki/File:DNA_stub.png"}, +{420,"http://en.wikipedia.org/wiki/File:Disambig_gray.svg"}, +{428,"http://en.wikipedia.org/wiki/File:Flag_of_Turkey.svg"}, +{610,"http://en.wikipedia.org/wiki/File:Massey_Lopes,_Vanity_Fair,_1875-05-15.jpg"}, +{468,"http://en.wikipedia.org/wiki/File:Noctua.pronuba.7199.jpg"}, +{412,"http://en.wikipedia.org/wiki/File:Okres_levoca.png"}, +{514,"http://en.wikipedia.org/wiki/File:PBB_GE_DDT_202929_s_at_tn.png"}, +{412,"http://en.wikipedia.org/wiki/File:PDB_1dpt_EBI.jpg"}, +{356,"http://en.wikipedia.org/wiki/File:P_vip.svg"}, +{476,"http://en.wikipedia.org/wiki/File:Protein_DDT_PDB_1dpt.png"}, +{420,"http://en.wikipedia.org/wiki/File:Quill_and_ink.svg"}, +{460,"http://en.wikipedia.org/wiki/File:Slovakiatynk%C3%A4.svg"}, +{412,"http://en.wikipedia.org/wiki/File:Speaker_Icon.svg"}, +{540,"http://en.wikipedia.org/wiki/File:Translation_to_english_arrow.svg"}, +{436,"http://en.wikipedia.org/wiki/File:Wikisource-logo.svg"}, +{524,"http://en.wikipedia.org/wiki/Financial_Secretary_to_the_Treasury"}, +{524,"http://en.wikipedia.org/wiki/Foreign_Language_Specialized_School"}, +{460,"http://en.wikipedia.org/wiki/Foreign_relations_of_Turkey"}, +{564,"http://en.wikipedia.org/wiki/Francis_Cottington,_1st_Baron_Cottington"}, +{460,"http://en.wikipedia.org/wiki/Frank_Williams_(basketball)"}, +{428,"http://en.wikipedia.org/wiki/Fred_Jones_(basketball)"}, +{324,"http://en.wikipedia.org/wiki/Free_throw"}, +{456,"http://en.wikipedia.org/wiki/French_Constitution_of_1791"}, +{316,"http://en.wikipedia.org/wiki/Gary_Neal"}, +{276,"http://en.wikipedia.org/wiki/Gene"}, +{316,"http://en.wikipedia.org/wiki/GeneCards"}, +{348,"http://en.wikipedia.org/wiki/Gene_Ontology"}, +{284,"http://en.wikipedia.org/wiki/Genus"}, +{468,"http://en.wikipedia.org/wiki/Geographic_coordinate_system"}, +{412,"http://en.wikipedia.org/wiki/Geography_of_Slovakia"}, +{412,"http://en.wikipedia.org/wiki/Giannis_Antetokounmpo"}, +{356,"http://en.wikipedia.org/wiki/Gilbert_Arenas"}, +{396,"http://en.wikipedia.org/wiki/Gran%C4%8D-Petrovce"}, +{508,"http://en.wikipedia.org/wiki/Grand_National_Assembly_of_Turkey"}, +{412,"http://en.wikipedia.org/wiki/Great_Western_Railway"}, +{404,"http://en.wikipedia.org/wiki/H%C3%A0_Nam_Province"}, +{452,"http://en.wikipedia.org/wiki/H%C3%A0_T%C4%A9nh_Province"}, +{460,"http://en.wikipedia.org/wiki/H%C6%B0ng_Y%C3%AAn_Province"}, +{523,"http://en.wikipedia.org/wiki/H%E1%BA%A3i_D%C6%B0%C6%A1ng_Province"}, +{316,"http://en.wikipedia.org/wiki/Hai_Phong"}, +{348,"http://en.wikipedia.org/wiki/Hakim_Warrick"}, +{284,"http://en.wikipedia.org/wiki/Hanoi"}, +{540,"http://en.wikipedia.org/wiki/Hanoi_%E2%80%93_Amsterdam_High_School"}, +{316,"http://en.wikipedia.org/wiki/Harakovce"}, +{364,"http://en.wikipedia.org/wiki/Hasheem_Thabeet"}, +{348,"http://en.wikipedia.org/wiki/Help:Category"}, +{348,"http://en.wikipedia.org/wiki/Help:Contents"}, +{396,"http://en.wikipedia.org/wiki/Help:Disambiguation"}, +{396,"http://en.wikipedia.org/wiki/Help:IPA_for_German"}, +{516,"http://en.wikipedia.org/wiki/Help:Introduction_to_referencing/1"}, +{524,"http://en.wikipedia.org/wiki/Henry_Chaplin,_1st_Viscount_Chaplin"}, +{476,"http://en.wikipedia.org/wiki/Henry_Lopes,_1st_Baron_Ludlow"}, +{500,"http://en.wikipedia.org/wiki/Henry_Lopes,_1st_Baron_Roborough"}, +{604,"http://en.wikipedia.org/wiki/Her_Majesty%27s_Most_Honourable_Privy_Council"}, +{812,"http://en.wikipedia.org/wiki/High_School_for_Gifted_Students,_Hanoi_National_University_of_Education"}, +{724,"http://en.wikipedia.org/wiki/High_School_for_Gifted_Students,_Hanoi_University_of_Science"}, +{452,"http://en.wikipedia.org/wiki/High_School_for_the_Gifted"}, +{412,"http://en.wikipedia.org/wiki/High_Sheriff_of_Devon"}, +{300,"http://en.wikipedia.org/wiki/History"}, +{380,"http://en.wikipedia.org/wiki/History_of_Turkey"}, +{572,"http://en.wikipedia.org/wiki/History_of_Turkish_presidential_elections"}, +{372,"http://en.wikipedia.org/wiki/Ho_Chi_Minh_City"}, +{324,"http://en.wikipedia.org/wiki/HomoloGene"}, +{444,"http://en.wikipedia.org/wiki/Human_Genome_Organisation"}, +{332,"http://en.wikipedia.org/wiki/Ian_Mahinmi"}, +{292,"http://en.wikipedia.org/wiki/Insect"}, +{372,"http://en.wikipedia.org/wiki/Internet_Archive"}, +{316,"http://en.wikipedia.org/wiki/Ish_Smith"}, +{332,"http://en.wikipedia.org/wiki/Islamic_Law"}, +{340,"http://en.wikipedia.org/wiki/J._J._Redick"}, +{308,"http://en.wikipedia.org/wiki/Jablonov"}, +{332,"http://en.wikipedia.org/wiki/Jae_Crowder"}, +{348,"http://en.wikipedia.org/wiki/Jamal_Sampson"}, +{468,"http://en.wikipedia.org/wiki/James_Singleton_(basketball)"}, +{468,"http://en.wikipedia.org/wiki/James_Wilson_(UK_politician)"}, +{340,"http://en.wikipedia.org/wiki/Jared_Dudley"}, +{356,"http://en.wikipedia.org/wiki/Jared_Jeffries"}, +{460,"http://en.wikipedia.org/wiki/Jason_Jennings_(basketball)"}, +{324,"http://en.wikipedia.org/wiki/Jason_Kidd"}, +{332,"http://en.wikipedia.org/wiki/Jason_Terry"}, +{444,"http://en.wikipedia.org/wiki/Jay_Williams_(basketball)"}, +{428,"http://en.wikipedia.org/wiki/Jeff_Green_(basketball)"}, +{407,"http://en.wikipedia.org/wiki/Ji%C5%99%C3%AD_Welsch"}, +{332,"http://en.wikipedia.org/wiki/Jim_Calhoun"}, +{340,"http://en.wikipedia.org/wiki/Jim_Cleamons"}, +{380,"http://en.wikipedia.org/wiki/Johann_David_Wyss"}, +{388,"http://en.wikipedia.org/wiki/Johann_David_Wyss#"}, +{476,"http://en.wikipedia.org/wiki/Johann_David_Wyss#cite_note-1"}, +{468,"http://en.wikipedia.org/wiki/Johann_David_Wyss#cite_ref-1"}, +{492,"http://en.wikipedia.org/wiki/Johann_David_Wyss#mw-navigation"}, +{452,"http://en.wikipedia.org/wiki/Johann_David_Wyss#p-search"}, +{388,"http://en.wikipedia.org/wiki/Johann_Rudolf_Wyss"}, +{436,"http://en.wikipedia.org/wiki/John_Bagley_(basketball)"}, +{420,"http://en.wikipedia.org/wiki/John_Carpenter_Garnier"}, +{324,"http://en.wikipedia.org/wiki/John_Duren"}, +{436,"http://en.wikipedia.org/wiki/John_Henson_(basketball)"}, +{380,"http://en.wikipedia.org/wiki/John_Lewis_Phipps"}, +{492,"http://en.wikipedia.org/wiki/John_Russell,_Viscount_Amberley"}, +{340,"http://en.wikipedia.org/wiki/John_Salmons"}, +{460,"http://en.wikipedia.org/wiki/John_Tremayne_(1825_-_1901)"}, +{540,"http://en.wikipedia.org/wiki/John_Yarde-Buller,_1st_Baron_Churston"}, +{404,"http://en.wikipedia.org/wiki/Jos%C3%A9_Juan_Barea"}, +{332,"http://en.wikipedia.org/wiki/Josh_Howard"}, +{500,"http://en.wikipedia.org/wiki/Juan_Carlos_Navarro_(basketball)"}, +{324,"http://en.wikipedia.org/wiki/Juan_Dixon"}, +{332,"http://en.wikipedia.org/wiki/Kareem_Rush"}, +{543,"http://en.wikipedia.org/wiki/Kemal_K%C4%B1l%C4%B1%C3%A7daro%C4%9Flu"}, +{348,"http://en.wikipedia.org/wiki/Kerry_Kittles"}, +{324,"http://en.wikipedia.org/wiki/Kew_Asylum"}, +{468,"http://en.wikipedia.org/wiki/Kh%C3%A1nh_H%C3%B2a_Province"}, +{364,"http://en.wikipedia.org/wiki/Khris_Middleton"}, +{324,"http://en.wikipedia.org/wiki/Kl%C4%8Dov"}, +{332,"http://en.wikipedia.org/wiki/Kobe_Bryant"}, +{338,"http://en.wikipedia.org/wiki/Korytn%C3%A9"}, +{308,"http://en.wikipedia.org/wiki/Kurimany"}, +{332,"http://en.wikipedia.org/wiki/Kwame_Brown"}, +{530,"http://en.wikipedia.org/wiki/L%C3%BA%C4%8Dka,_Levo%C4%8Da_District"}, +{316,"http://en.wikipedia.org/wiki/Lady_Anne"}, +{324,"http://en.wikipedia.org/wiki/Lady_Anne#"}, +{484,"http://en.wikipedia.org/wiki/Lady_Anne#Fictional_characters"}, +{372,"http://en.wikipedia.org/wiki/Lady_Anne#People"}, +{388,"http://en.wikipedia.org/wiki/Lady_Anne#See_also"}, +{364,"http://en.wikipedia.org/wiki/Lady_Anne#Ships"}, +{428,"http://en.wikipedia.org/wiki/Lady_Anne#mw-navigation"}, +{388,"http://en.wikipedia.org/wiki/Lady_Anne#p-search"}, +{412,"http://en.wikipedia.org/wiki/Lady_Anne-Marie_Byrne"}, +{380,"http://en.wikipedia.org/wiki/Lady_Anne_Barnard"}, +{364,"http://en.wikipedia.org/wiki/Lady_Anne_Berry"}, +{364,"http://en.wikipedia.org/wiki/Lady_Anne_Blunt"}, +{468,"http://en.wikipedia.org/wiki/Lady_Anne_Cavendish-Bentinck"}, +{396,"http://en.wikipedia.org/wiki/Lady_Anne_Churchill"}, +{388,"http://en.wikipedia.org/wiki/Lady_Anne_Clifford"}, +{500,"http://en.wikipedia.org/wiki/Lady_Anne_Farquharson-MacKintosh"}, +{356,"http://en.wikipedia.org/wiki/Lady_Anne_Rhys"}, +{396,"http://en.wikipedia.org/wiki/Lam_Son_High_School"}, +{324,"http://en.wikipedia.org/wiki/Lamar_Odom"}, +{340,"http://en.wikipedia.org/wiki/Laron_Profit"}, +{324,"http://en.wikipedia.org/wiki/Larry_Drew"}, +{452,"http://en.wikipedia.org/wiki/Larry_Sanders_(basketball)"}, +{492,"http://en.wikipedia.org/wiki/Lawrence_Palk,_1st_Baron_Haldon"}, +{340,"http://en.wikipedia.org/wiki/LeBron_James"}, +{444,"http://en.wikipedia.org/wiki/Le_Hong_Phong_High_School"}, +{556,"http://en.wikipedia.org/wiki/Leader_of_the_Main_Opposition_of_Turkey"}, +{548,"http://en.wikipedia.org/wiki/Legal_System_in_the_Republic_of_Turkey"}, +{756,"http://en.wikipedia.org/wiki/Legal_System_in_the_Republic_of_Turkey#Turkish_Court_of_Accounts"}, +{548,"http://en.wikipedia.org/wiki/Legal_system_of_the_Republic_of_Turkey"}, +{332,"http://en.wikipedia.org/wiki/Legislative"}, +{332,"http://en.wikipedia.org/wiki/Lepidoptera"}, +{332,"http://en.wikipedia.org/wiki/Levo%C4%8Da"}, +{404,"http://en.wikipedia.org/wiki/Levo%C4%8Da_District"}, +{308,"http://en.wikipedia.org/wiki/LibriVox"}, +{412,"http://en.wikipedia.org/wiki/List_of_NBA_champions"}, +{468,"http://en.wikipedia.org/wiki/List_of_Presidents_of_Turkey"}, +{692,"http://en.wikipedia.org/wiki/List_of_Presidents_of_the_Constitutional_Court_of_Turkey"}, +{508,"http://en.wikipedia.org/wiki/List_of_Prime_Ministers_of_Turkey"}, +{596,"http://en.wikipedia.org/wiki/List_of_Speakers_of_the_Parliament_of_Turkey"}, +{444,"http://en.wikipedia.org/wiki/List_of_Turkish_diplomats"}, +{540,"http://en.wikipedia.org/wiki/List_of_diplomatic_missions_of_Turkey"}, +{452,"http://en.wikipedia.org/wiki/List_of_extant_baronetcies"}, +{524,"http://en.wikipedia.org/wiki/List_of_political_parties_in_Turkey"}, +{372,"http://en.wikipedia.org/wiki/Long_An_Province"}, +{340,"http://en.wikipedia.org/wiki/Lonny_Baxter"}, +{516,"http://en.wikipedia.org/wiki/Lord_Commissioner_of_the_Admiralty"}, +{404,"http://en.wikipedia.org/wiki/Los_Angeles_Clippers"}, +{388,"http://en.wikipedia.org/wiki/Los_Angeles_Lakers"}, +{348,"http://en.wikipedia.org/wiki/Lost_in_Space"}, +{324,"http://en.wikipedia.org/wiki/Luis_Scola"}, +{356,"http://en.wikipedia.org/wiki/Luke_Harangody"}, +{340,"http://en.wikipedia.org/wiki/Luke_Ridnour"}, +{548,"http://en.wikipedia.org/wiki/Macrophage_migration_inhibitory_factor"}, +{604,"http://en.wikipedia.org/wiki/Macrophage_migration_inhibitory_factor_domain"}, +{316,"http://en.wikipedia.org/wiki/Main_Page"}, +{428,"http://en.wikipedia.org/wiki/Maine_Central_Institute"}, +{356,"http://en.wikipedia.org/wiki/Marcus_Haislip"}, +{348,"http://en.wikipedia.org/wiki/Marcus_Taylor"}, +{332,"http://en.wikipedia.org/wiki/Mario_Kasun"}, +{388,"http://en.wikipedia.org/wiki/Maryland_Terrapins"}, +{332,"http://en.wikipedia.org/wiki/Matt_Barnes"}, +{372,"http://en.wikipedia.org/wiki/Melbourne_Herald"}, +{364,"http://en.wikipedia.org/wiki/Melbourne_Punch"}, +{324,"http://en.wikipedia.org/wiki/Melvin_Ely"}, +{468,"http://en.wikipedia.org/wiki/Mendelian_Inheritance_in_Man"}, +{324,"http://en.wikipedia.org/wiki/Miami_Heat"}, +{356,"http://en.wikipedia.org/wiki/Micronoctuidae"}, +{388,"http://en.wikipedia.org/wiki/Mike_Dunleavy,_Jr."}, +{426,"http://en.wikipedia.org/wiki/Milo%C5%A1_Vujani%C4%87"}, +{364,"http://en.wikipedia.org/wiki/Milwaukee_Bucks"}, +{404,"http://en.wikipedia.org/wiki/Ministries_of_Turkey"}, +{596,"http://en.wikipedia.org/wiki/Ministry_of_Education_and_Training_(Vietnam)"}, +{532,"http://en.wikipedia.org/wiki/Ministry_of_Foreign_Affairs_(Turkey)"}, +{388,"http://en.wikipedia.org/wiki/Miroslav_Raduljica"}, +{412,"http://en.wikipedia.org/wiki/Mladen_%C5%A0ekularac"}, +{300,"http://en.wikipedia.org/wiki/Monarch"}, +{276,"http://en.wikipedia.org/wiki/Moth"}, +{340,"http://en.wikipedia.org/wiki/Mountain_Dew"}, +{436,"http://en.wikipedia.org/wiki/Mouse_Genome_Informatics"}, +{340,"http://en.wikipedia.org/wiki/Municipality"}, +{452,"http://en.wikipedia.org/wiki/Mustafa_Kemal_Atat%C3%BCrk"}, +{268,"http://en.wikipedia.org/wiki/NBA"}, +{396,"http://en.wikipedia.org/wiki/NBA_All-Rookie_Team"}, +{380,"http://en.wikipedia.org/wiki/NBA_All-Star_Game"}, +{292,"http://en.wikipedia.org/wiki/Nahiye"}, +{472,"http://en.wikipedia.org/wiki/Nam_%C4%90%E1%BB%8Bnh_Province"}, +{340,"http://en.wikipedia.org/wiki/Nate_Wolters"}, +{540,"http://en.wikipedia.org/wiki/National_Basketball_Association_draft"}, +{516,"http://en.wikipedia.org/wiki/National_Security_Council_(Turkey)"}, +{404,"http://en.wikipedia.org/wiki/National_sovereignty"}, +{348,"http://en.wikipedia.org/wiki/Neme%C5%A1any"}, +{314,"http://en.wikipedia.org/wiki/Nen%C3%AA"}, +{378,"http://en.wikipedia.org/wiki/Nenad_Krsti%C4%87"}, +{420,"http://en.wikipedia.org/wiki/New_Orleans,_Louisiana"}, +{364,"http://en.wikipedia.org/wiki/New_York_Knicks"}, +{436,"http://en.wikipedia.org/wiki/Ngh%E1%BB%87_An_Province"}, +{484,"http://en.wikipedia.org/wiki/Nguyen_Thuong_Hien_High_School"}, +{460,"http://en.wikipedia.org/wiki/Ni%C5%BEn%C3%A9_Repa%C5%A1e"}, +{348,"http://en.wikipedia.org/wiki/Nick_Van_Exel"}, +{404,"http://en.wikipedia.org/wiki/Nikoloz_Tskitishvili"}, +{324,"http://en.wikipedia.org/wiki/Noctuoidea"}, +{378,"http://en.wikipedia.org/wiki/O%C4%BE%C5%A1avica"}, +{324,"http://en.wikipedia.org/wiki/O._J._Mayo"}, +{340,"http://en.wikipedia.org/wiki/Open_Library"}, +{316,"http://en.wikipedia.org/wiki/Ordzovany"}, +{412,"http://en.wikipedia.org/wiki/Oriel_College,_Oxford"}, +{332,"http://en.wikipedia.org/wiki/Otto_Porter"}, +{356,"http://en.wikipedia.org/wiki/Ottoman_Empire"}, +{364,"http://en.wikipedia.org/wiki/Ottoman_dynasty"}, +{372,"http://en.wikipedia.org/wiki/Ottoman_language"}, +{620,"http://en.wikipedia.org/wiki/Outline_of_political_science#Politics_by_region"}, +{500,"http://en.wikipedia.org/wiki/Parliament_of_the_United_Kingdom"}, +{332,"http://en.wikipedia.org/wiki/Pat_Garrity"}, +{348,"http://en.wikipedia.org/wiki/Patrick_Ewing"}, +{340,"http://en.wikipedia.org/wiki/Pav%C4%BEany"}, +{402,"http://en.wikipedia.org/wiki/Peja_Stojakovi%C4%87"}, +{388,"http://en.wikipedia.org/wiki/Perils_of_the_Wild"}, +{332,"http://en.wikipedia.org/wiki/Peter_Fehse"}, +{476,"http://en.wikipedia.org/wiki/Ph%C3%BA_Th%E1%BB%8D_Province"}, +{452,"http://en.wikipedia.org/wiki/Ph%C3%BA_Y%C3%AAn_Province"}, +{340,"http://en.wikipedia.org/wiki/Phoenix_Suns"}, +{380,"http://en.wikipedia.org/wiki/Pittsfield,_Maine"}, +{356,"http://en.wikipedia.org/wiki/Po%C4%BEanovce"}, +{388,"http://en.wikipedia.org/wiki/Politics_of_Turkey"}, +{524,"http://en.wikipedia.org/wiki/Politics_of_Turkey#Executive_branch"}, +{540,"http://en.wikipedia.org/wiki/Politics_of_Turkey#Legislative_branch"}, +{372,"http://en.wikipedia.org/wiki/Pongr%C3%A1covce"}, +{324,"http://en.wikipedia.org/wiki/Population"}, +{372,"http://en.wikipedia.org/wiki/Portal:Biography"}, +{364,"http://en.wikipedia.org/wiki/Portal:Contents"}, +{412,"http://en.wikipedia.org/wiki/Portal:Current_events"}, +{428,"http://en.wikipedia.org/wiki/Portal:Featured_content"}, +{364,"http://en.wikipedia.org/wiki/Portal:Politics"}, +{348,"http://en.wikipedia.org/wiki/Portal:Turkey"}, +{388,"http://en.wikipedia.org/wiki/Pre%C5%A1ov_Region"}, +{396,"http://en.wikipedia.org/wiki/President_of_Turkey"}, +{436,"http://en.wikipedia.org/wiki/Prime_Minister_of_Turkey"}, +{380,"http://en.wikipedia.org/wiki/Project_Gutenberg"}, +{380,"http://en.wikipedia.org/wiki/Protein_Data_Bank"}, +{292,"http://en.wikipedia.org/wiki/PubMed"}, +{356,"http://en.wikipedia.org/wiki/PubMed_Central"}, +{380,"http://en.wikipedia.org/wiki/PubMed_Identifier"}, +{372,"http://en.wikipedia.org/wiki/Public_relations"}, +{284,"http://en.wikipedia.org/wiki/Qadaa"}, +{460,"http://en.wikipedia.org/wiki/Qu%E1%BA%A3ng_Ninh_Province"}, +{340,"http://en.wikipedia.org/wiki/Quinton_Ross"}, +{636,"http://en.wikipedia.org/wiki/Quoc_Hoc_%E2%80%93_Hue_High_School_for_the_Gifted"}, +{340,"http://en.wikipedia.org/wiki/Qyntel_Woods"}, +{380,"http://en.wikipedia.org/wiki/Racine,_Wisconsin"}, +{428,"http://en.wikipedia.org/wiki/Racine_Park_High_School"}, +{324,"http://en.wikipedia.org/wiki/Randy_Foye"}, +{348,"http://en.wikipedia.org/wiki/Randy_Holcomb"}, +{348,"http://en.wikipedia.org/wiki/Rasual_Butler"}, +{316,"http://en.wikipedia.org/wiki/Ray_Allen"}, +{404,"http://en.wikipedia.org/wiki/Rebound_(basketball)"}, +{444,"http://en.wikipedia.org/wiki/Recep_Tayyip_Erdo%C4%9Fan"}, +{556,"http://en.wikipedia.org/wiki/Reggie_Williams_(basketball,_born_1964)"}, +{308,"http://en.wikipedia.org/wiki/Republic"}, +{388,"http://en.wikipedia.org/wiki/Republic_of_Turkey"}, +{476,"http://en.wikipedia.org/wiki/Richard_Hamilton_(basketball)"}, +{348,"http://en.wikipedia.org/wiki/Rick_Carlisle"}, +{372,"http://en.wikipedia.org/wiki/Robert_Archibald"}, +{604,"http://en.wikipedia.org/wiki/Robert_Haldane-Duncan,_3rd_Earl_of_Camperdown"}, +{364,"http://en.wikipedia.org/wiki/Robinson_Crusoe"}, +{340,"http://en.wikipedia.org/wiki/Rod_Grizzard"}, +{380,"http://en.wikipedia.org/wiki/Rodrigue_Beaubois"}, +{372,"http://en.wikipedia.org/wiki/Roger_Mason,_Jr."}, +{348,"http://en.wikipedia.org/wiki/Ronald_Murray"}, +{348,"http://en.wikipedia.org/wiki/Ryan_Humphrey"}, +{364,"http://en.wikipedia.org/wiki/Sam_Clancy,_Jr."}, +{436,"http://en.wikipedia.org/wiki/Samuel_Trehawke_Kekewich"}, +{380,"http://en.wikipedia.org/wiki/San_Antonio_Spurs"}, +{460,"http://en.wikipedia.org/wiki/Scott_Williams_(basketball)"}, +{404,"http://en.wikipedia.org/wiki/Secularism_in_Turkey"}, +{348,"http://en.wikipedia.org/wiki/Sephardi_Jews"}, +{388,"http://en.wikipedia.org/wiki/Shaquille_O%27Neal"}, +{340,"http://en.wikipedia.org/wiki/Shawn_Marion"}, +{548,"http://en.wikipedia.org/wiki/Sir_Manasseh_Masseh_Lopes,_1st_Baronet"}, +{476,"http://en.wikipedia.org/wiki/Sir_Massey_Lopes,_3rd_Baronet"}, +{484,"http://en.wikipedia.org/wiki/Sir_Massey_Lopes,_3rd_Baronet#"}, +{572,"http://en.wikipedia.org/wiki/Sir_Massey_Lopes,_3rd_Baronet#cite_note-1"}, +{564,"http://en.wikipedia.org/wiki/Sir_Massey_Lopes,_3rd_Baronet#cite_ref-1"}, +{588,"http://en.wikipedia.org/wiki/Sir_Massey_Lopes,_3rd_Baronet#mw-navigation"}, +{548,"http://en.wikipedia.org/wiki/Sir_Massey_Lopes,_3rd_Baronet#p-search"}, +{468,"http://en.wikipedia.org/wiki/Sir_Ralph_Lopes,_2nd_Baronet"}, +{308,"http://en.wikipedia.org/wiki/Slovakia"}, +{348,"http://en.wikipedia.org/wiki/Small_forward"}, +{564,"http://en.wikipedia.org/wiki/South_Devon_(UK_Parliament_constituency)"}, +{444,"http://en.wikipedia.org/wiki/South_Melbourne,_Victoria"}, +{332,"http://en.wikipedia.org/wiki/Sovereignty"}, +{412,"http://en.wikipedia.org/wiki/Space_Family_Robinson"}, +{463,"http://en.wikipedia.org/wiki/Special:BookSources/0091354609"}, +{356,"http://en.wikipedia.org/wiki/Special:Random"}, +{412,"http://en.wikipedia.org/wiki/Special:RecentChanges"}, +{572,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Ambrose_Dyson"}, +{564,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Caron_Butler"}, +{548,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/DDT_(gene)"}, +{604,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Johann_David_Wyss"}, +{540,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Lady_Anne"}, +{700,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Sir_Massey_Lopes,_3rd_Baronet"}, +{516,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Tumula"}, +{688,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Turkish_Constitution_of_1921"}, +{764,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Vietnam_University_Admission_Rankings"}, +{652,"http://en.wikipedia.org/wiki/Special:RecentChangesLinked/Vy%C5%A1n%C3%BD_Slavkov"}, +{404,"http://en.wikipedia.org/wiki/Special:SpecialPages"}, +{524,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Ambrose_Dyson"}, +{516,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Caron_Butler"}, +{500,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/DDT_(gene)"}, +{556,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Johann_David_Wyss"}, +{492,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Lady_Anne"}, +{652,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Sir_Massey_Lopes,_3rd_Baronet"}, +{468,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Tumula"}, +{640,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Turkish_Constitution_of_1921"}, +{716,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Vietnam_University_Admission_Rankings"}, +{604,"http://en.wikipedia.org/wiki/Special:WhatLinksHere/Vy%C5%A1n%C3%BD_Slavkov"}, +{460,"http://en.wikipedia.org/wiki/Spi%C5%A1sk%C3%A9_Podhradie"}, +{484,"http://en.wikipedia.org/wiki/Spi%C5%A1sk%C3%BD_%C5%A0tvrtok"}, +{428,"http://en.wikipedia.org/wiki/Spi%C5%A1sk%C3%BD_Hrhov"}, +{388,"http://en.wikipedia.org/wiki/Steal_(basketball)"}, +{332,"http://en.wikipedia.org/wiki/Steve_Logan"}, +{404,"http://en.wikipedia.org/wiki/Stranded_(2002_film)"}, +{492,"http://en.wikipedia.org/wiki/Studenec_(Levo%C4%8Da_District)"}, +{292,"http://en.wikipedia.org/wiki/Sultan"}, +{524,"http://en.wikipedia.org/wiki/Supreme_Electoral_Council_of_Turkey"}, +{444,"http://en.wikipedia.org/wiki/Swiss_Family_Guy_Robinson"}, +{508,"http://en.wikipedia.org/wiki/Swiss_Family_Robinson_(1940_film)"}, +{508,"http://en.wikipedia.org/wiki/Swiss_Family_Robinson_(1960_film)"}, +{548,"http://en.wikipedia.org/wiki/Swiss_Family_Robinson_(1974_TV_series)"}, +{332,"http://en.wikipedia.org/wiki/Switzerland"}, +{292,"http://en.wikipedia.org/wiki/Sydney"}, +{324,"http://en.wikipedia.org/wiki/Tactusinae"}, +{388,"http://en.wikipedia.org/wiki/Talk:Ambrose_Dyson"}, +{380,"http://en.wikipedia.org/wiki/Talk:Caron_Butler"}, +{364,"http://en.wikipedia.org/wiki/Talk:DDT_(gene)"}, +{420,"http://en.wikipedia.org/wiki/Talk:Johann_David_Wyss"}, +{516,"http://en.wikipedia.org/wiki/Talk:Sir_Massey_Lopes,_3rd_Baronet"}, +{332,"http://en.wikipedia.org/wiki/Talk:Tumula"}, +{504,"http://en.wikipedia.org/wiki/Talk:Turkish_Constitution_of_1921"}, +{580,"http://en.wikipedia.org/wiki/Talk:Vietnam_University_Admission_Rankings"}, +{468,"http://en.wikipedia.org/wiki/Talk:Vy%C5%A1n%C3%BD_Slavkov"}, +{324,"http://en.wikipedia.org/wiki/Tamar_Slay"}, +{364,"http://en.wikipedia.org/wiki/Tayshaun_Prince"}, +{428,"http://en.wikipedia.org/wiki/Template:2002_NBA_Draft"}, +{828,"http://en.wikipedia.org/wiki/Template:Big_East_Conference_Men%27s_Basketball_Player_of_the_Year_navbox"}, +{436,"http://en.wikipedia.org/wiki/Template:Cartoonist-stub"}, +{436,"http://en.wikipedia.org/wiki/Template:Citation_needed"}, +{492,"http://en.wikipedia.org/wiki/Template:Constitution_of_Turkey"}, +{672,"http://en.wikipedia.org/wiki/Template:Dallas_Mavericks_2010%E2%80%9311_NBA_champions"}, +{412,"http://en.wikipedia.org/wiki/Template:Gene-22-stub"}, +{476,"http://en.wikipedia.org/wiki/Template:Levo%C4%8Da_District"}, +{556,"http://en.wikipedia.org/wiki/Template:Milwaukee_Bucks_current_roster"}, +{436,"http://en.wikipedia.org/wiki/Template:Noctuoidea-stub"}, +{371,"http://en.wikipedia.org/wiki/Template:PBB/1652"}, +{404,"http://en.wikipedia.org/wiki/Template:PDB_Gallery"}, +{460,"http://en.wikipedia.org/wiki/Template:Politics_of_Turkey"}, +{476,"http://en.wikipedia.org/wiki/Template:Pre%C5%A1ov-geo-stub"}, +{500,"http://en.wikipedia.org/wiki/Template:Switzerland-writer-stub"}, +{516,"http://en.wikipedia.org/wiki/Template:The_Swiss_Family_Robinson"}, +{396,"http://en.wikipedia.org/wiki/Template:Translated"}, +{468,"http://en.wikipedia.org/wiki/Template_talk:2002_NBA_Draft"}, +{868,"http://en.wikipedia.org/wiki/Template_talk:Big_East_Conference_Men%27s_Basketball_Player_of_the_Year_navbox"}, +{476,"http://en.wikipedia.org/wiki/Template_talk:Cartoonist-stub"}, +{532,"http://en.wikipedia.org/wiki/Template_talk:Constitution_of_Turkey"}, +{712,"http://en.wikipedia.org/wiki/Template_talk:Dallas_Mavericks_2010%E2%80%9311_NBA_champions"}, +{452,"http://en.wikipedia.org/wiki/Template_talk:Gene-22-stub"}, +{516,"http://en.wikipedia.org/wiki/Template_talk:Levo%C4%8Da_District"}, +{596,"http://en.wikipedia.org/wiki/Template_talk:Milwaukee_Bucks_current_roster"}, +{476,"http://en.wikipedia.org/wiki/Template_talk:Noctuoidea-stub"}, +{444,"http://en.wikipedia.org/wiki/Template_talk:PDB_Gallery"}, +{500,"http://en.wikipedia.org/wiki/Template_talk:Politics_of_Turkey"}, +{516,"http://en.wikipedia.org/wiki/Template_talk:Pre%C5%A1ov-geo-stub"}, +{540,"http://en.wikipedia.org/wiki/Template_talk:Switzerland-writer-stub"}, +{340,"http://en.wikipedia.org/wiki/Terry_Dehere"}, +{340,"http://en.wikipedia.org/wiki/Terry_Stotts"}, +{468,"http://en.wikipedia.org/wiki/Th%C3%A1i_B%C3%ACnh_Province"}, +{660,"http://en.wikipedia.org/wiki/Th%E1%BB%ABa_Thi%C3%AAn%E2%80%93Hu%E1%BA%BF_Province"}, +{356,"http://en.wikipedia.org/wiki/Thanh_H%C3%B3a"}, +{428,"http://en.wikipedia.org/wiki/Thanh_H%C3%B3a_Province"}, +{340,"http://en.wikipedia.org/wiki/The_Bulletin"}, +{444,"http://en.wikipedia.org/wiki/The_Castaways_of_the_Flag"}, +{388,"http://en.wikipedia.org/wiki/The_London_Gazette"}, +{444,"http://en.wikipedia.org/wiki/The_Swiss_Family_Robinson"}, +{700,"http://en.wikipedia.org/wiki/The_Swiss_Family_Robinson:_Flone_of_the_Mysterious_Island"}, +{580,"http://en.wikipedia.org/wiki/The_Swiss_Family_Robinson_(1975_TV_series)"}, +{500,"http://en.wikipedia.org/wiki/Thomas_Brassey,_1st_Earl_Brassey"}, +{420,"http://en.wikipedia.org/wiki/Three-point_field_goal"}, +{340,"http://en.wikipedia.org/wiki/Tim_Grgurich"}, +{420,"http://en.wikipedia.org/wiki/Tim_James_(basketball)"}, +{332,"http://en.wikipedia.org/wiki/Tito_Maddox"}, +{324,"http://en.wikipedia.org/wiki/Tom_Durkin"}, +{300,"http://en.wikipedia.org/wiki/Torysky"}, +{452,"http://en.wikipedia.org/wiki/Tran_Dai_Nghia_High_School"}, +{388,"http://en.wikipedia.org/wiki/Treaty_of_Lausanne"}, +{412,"http://en.wikipedia.org/wiki/Treaty_of_S%C3%A8vres"}, +{316,"http://en.wikipedia.org/wiki/Troy_Bell"}, +{332,"http://en.wikipedia.org/wiki/Troy_Murphy"}, +{292,"http://en.wikipedia.org/wiki/Tumula"}, +{300,"http://en.wikipedia.org/wiki/Tumula#"}, +{404,"http://en.wikipedia.org/wiki/Tumula#mw-navigation"}, +{364,"http://en.wikipedia.org/wiki/Tumula#p-search"}, +{388,"http://en.wikipedia.org/wiki/Tumula_flavicollis"}, +{292,"http://en.wikipedia.org/wiki/Turkey"}, +{660,"http://en.wikipedia.org/wiki/Turkey%27s_membership_of_international_organizations"}, +{404,"http://en.wikipedia.org/wiki/Turkish_Armed_Forces"}, +{464,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921"}, +{476,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#"}, +{556,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#Background"}, +{588,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#External_links"}, +{540,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#Overview"}, +{556,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#References"}, +{644,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#Text_.28as_enacted.29"}, +{540,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#Timeline"}, +{564,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#cite_note-1"}, +{556,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#cite_ref-1"}, +{580,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#mw-navigation"}, +{540,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1921#p-search"}, +{464,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1924"}, +{464,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1961"}, +{464,"http://en.wikipedia.org/wiki/Turkish_Constitution_of_1982"}, +{436,"http://en.wikipedia.org/wiki/Turkish_Council_of_State"}, +{436,"http://en.wikipedia.org/wiki/Turkish_Independence_War"}, +{460,"http://en.wikipedia.org/wiki/Turkish_War_of_Independence"}, +{480,"http://en.wikipedia.org/wiki/Turkish_general_election,_2011"}, +{372,"http://en.wikipedia.org/wiki/Turkish_language"}, +{472,"http://en.wikipedia.org/wiki/Turkish_local_elections,_2009"}, +{520,"http://en.wikipedia.org/wiki/Turkish_presidential_election,_2007"}, +{356,"http://en.wikipedia.org/wiki/Tyson_Chandler"}, +{420,"http://en.wikipedia.org/wiki/USS_Lady_Anne_(SP-154)"}, +{324,"http://en.wikipedia.org/wiki/Ulo%C5%BEa"}, +{300,"http://en.wikipedia.org/wiki/UniProt"}, +{348,"http://en.wikipedia.org/wiki/United_States"}, +{548,"http://en.wikipedia.org/wiki/United_States_national_basketball_team"}, +{444,"http://en.wikipedia.org/wiki/University_of_Connecticut"}, +{468,"http://en.wikipedia.org/wiki/V%C4%A9nh_Ph%C3%BAc_Province"}, +{567,"http://en.wikipedia.org/wiki/Vanity_Fair_(British_magazine_1868-1914)"}, +{396,"http://en.wikipedia.org/wiki/Viacheslav_Kravtsov"}, +{540,"http://en.wikipedia.org/wiki/Vietnam_University_Admission_Rankings"}, +{548,"http://en.wikipedia.org/wiki/Vietnam_University_Admission_Rankings#"}, +{636,"http://en.wikipedia.org/wiki/Vietnam_University_Admission_Rankings#cite_note-1"}, +{628,"http://en.wikipedia.org/wiki/Vietnam_University_Admission_Rankings#cite_ref-1"}, +{652,"http://en.wikipedia.org/wiki/Vietnam_University_Admission_Rankings#mw-navigation"}, +{612,"http://en.wikipedia.org/wiki/Vietnam_University_Admission_Rankings#p-search"}, +{340,"http://en.wikipedia.org/wiki/Vil%C3%A2yet"}, +{300,"http://en.wikipedia.org/wiki/Village"}, +{380,"http://en.wikipedia.org/wiki/Vincent_Yarbrough"}, +{532,"http://en.wikipedia.org/wiki/Virtual_International_Authority_File"}, +{460,"http://en.wikipedia.org/wiki/Vy%C5%A1n%C3%A9_Repa%C5%A1e"}, +{428,"http://en.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{436,"http://en.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov#"}, +{540,"http://en.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov#mw-navigation"}, +{500,"http://en.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov#p-search"}, +{444,"http://en.wikipedia.org/wiki/Walter_Berry_(basketball)"}, +{372,"http://en.wikipedia.org/wiki/Washington,_D.C."}, +{460,"http://en.wikipedia.org/wiki/Washington_Park_High_School"}, +{388,"http://en.wikipedia.org/wiki/Washington_Wizards"}, +{460,"http://en.wikipedia.org/wiki/Wesley_Johnson_(basketball)"}, +{540,"http://en.wikipedia.org/wiki/Westbury_(UK_Parliament_constituency)"}, +{364,"http://en.wikipedia.org/wiki/Wikipedia:About"}, +{444,"http://en.wikipedia.org/wiki/Wikipedia:Citation_needed"}, +{436,"http://en.wikipedia.org/wiki/Wikipedia:Citing_sources"}, +{452,"http://en.wikipedia.org/wiki/Wikipedia:Community_portal"}, +{404,"http://en.wikipedia.org/wiki/Wikipedia:Contact_us"}, +{516,"http://en.wikipedia.org/wiki/Wikipedia:Copying_within_Wikipedia"}, +{468,"http://en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard"}, +{468,"http://en.wikipedia.org/wiki/Wikipedia:General_disclaimer"}, +{548,"http://en.wikipedia.org/wiki/Wikipedia:Identifying_reliable_sources"}, +{362,"http://en.wikipedia.org/wiki/Wikipedia:NOTRS"}, +{404,"http://en.wikipedia.org/wiki/Wikipedia:Persondata"}, +{356,"http://en.wikipedia.org/wiki/Wikipedia:Stub"}, +{868,"http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"}, +{412,"http://en.wikipedia.org/wiki/Wikipedia:Translation"}, +{372,"http://en.wikipedia.org/wiki/Wikipedia:V#SELF"}, +{580,"http://en.wikipedia.org/wiki/Wikipedia:Verifiability#Burden_of_evidence"}, +{324,"http://en.wikipedia.org/wiki/Will_Dyson"}, +{388,"http://en.wikipedia.org/wiki/Winchester_College"}, +{316,"http://en.wikipedia.org/wiki/Wisconsin"}, +{332,"http://en.wikipedia.org/wiki/World_War_I"}, +{292,"http://en.wikipedia.org/wiki/Yahoo!"}, +{308,"http://en.wikipedia.org/wiki/Yao_Ming"}, +{348,"http://en.wikipedia.org/wiki/Zaza_Pachulia"}, +{556,"http://en.wikisource.org/wiki/Constitution_of_the_Republic_of_Turkey"}, +{428,"http://eo.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{340,"http://es.wikipedia.org/wiki/Caron_Butler"}, +{380,"http://es.wikipedia.org/wiki/Johann_David_Wyss"}, +{228,"http://everything.yahoo.com"}, +{236,"http://everything.yahoo.com/"}, +{420,"http://feedback.yahoo.com/forums/206380-us-homepage"}, +{204,"http://finance.yahoo.com"}, +{212,"http://finance.yahoo.com/"}, +{602,"http://finance.yahoo.com/news/brazil-looks-break-us-centric-040621384.html"}, +{554,"http://finance.yahoo.com/news/did-ted-cruz-just-force-211204954.html"}, +{642,"http://finance.yahoo.com/news/theyve-turned-over-costa-concordia-102731647.html"}, +{284,"http://finance.yahoo.com/q?s=^IXIC"}, +{578,"http://finance.yahoo.com/video/winning-lottery-beat-odds-193258229.html"}, +{148,"http://flickr.com"}, +{404,"http://flss.edu.vn/Home.asp?param=news&NewsID=147"}, +{980,"http://football.fantasysports.yahoo.com/?ovchn=YAH&ovcpn=Front+Page&ovcrn=Front+page+P+Link+Nav+button&ovrfd=YAH&ovtac=AD"}, +{340,"http://fr.wikipedia.org/wiki/Caron_Butler"}, +{380,"http://fr.wikipedia.org/wiki/Johann_David_Wyss"}, +{428,"http://fr.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{196,"http://games.yahoo.com/"}, +{697,"http://genome.ucsc.edu/cgi-bin/hgTracks?org=Human&db=hg19&position=chr22:24313554-24322660"}, +{689,"http://genome.ucsc.edu/cgi-bin/hgTracks?org=Mouse&db=mm9&position=chr10:75771230-75773414"}, +{340,"http://gl.wikipedia.org/wiki/Caron_Butler"}, +{196,"http://green.yahoo.com/"}, +{204,"http://groups.yahoo.com/"}, +{687,"http://hangtime.blogs.nba.com/2011/01/04/caron-butler-out-for-season/?ls=iref:nbahpt2"}, +{476,"http://hansard.millbanksystems.com/people/sir-massey-lopes"}, +{618,"http://he.wikipedia.org/wiki/%D7%A7%D7%90%D7%A8%D7%95%D7%9F_%D7%91%D7%90%D7%98%D7%9C%D7%A8"}, +{196,"http://health.yahoo.net"}, +{636,"http://health.yahoo.net/articles/weight-loss/why-obese-people-cant-lose-weight"}, +{653,"http://help.yahoo.com/kb/index?page=content&y=PROD_FRONT&locale=en_US&id=SLN14553"}, +{372,"http://help.yahoo.com/l/us/yahoo/helpcentral/"}, +{268,"http://homes.yahoo.com/own-rent/"}, +{340,"http://hr.wikipedia.org/wiki/Caron_Butler"}, +{412,"http://hu.wikipedia.org/wiki/Fels%C5%91szal%C3%B3k"}, +{180,"http://info.yahoo.com"}, +{188,"http://info.yahoo.com/"}, +{396,"http://info.yahoo.com/legal/us/yahoo/utos/terms/"}, +{396,"http://info.yahoo.com/privacy/us/yahoo/homepage/"}, +{452,"http://info.yahoo.com/privacy/us/yahoo/relevantads.html"}, +{340,"http://it.wikipedia.org/wiki/Caron_Butler"}, +{428,"http://it.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{651,"http://ja.wikipedia.org/wiki/%E3%82%AB%E3%83%AD%E3%83%B3%E3%83%BB%E3%83%90%E3%83%88%E3%83%A9%E3%83%BC"}, +{898,"http://ja.wikipedia.org/wiki/%E3%83%A8%E3%83%8F%E3%83%B3%E3%83%BB%E3%83%80%E3%83%93%E3%83%83%E3%83%88%E3%83%BB%E3%82%A6%E3%82%A3%E3%83%BC%E3%82%B9"}, +{564,"http://jobsearch.monster.com/search/?cy=us&WT.mc_n=yta_trough_jsrtest"}, +{596,"http://librivox.org/newcatalog/search.php?title=&author=Johann+David+Wyss"}, +{356,"http://lv.wikipedia.org/wiki/Kerons_Batlers"}, +{252,"http://mail.yahoo.com?.intl=us"}, +{188,"http://maps.yahoo.com/"}, +{220,"http://messenger.yahoo.com"}, +{196,"http://movies.yahoo.com"}, +{522,"http://movies.yahoo.com/video/short-game-crushing-224038083.html"}, +{428,"http://ms.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{188,"http://music.yahoo.com"}, +{276,"http://my.yahoo.com/?fr=yfp-t-403"}, +{634,"http://myespn.go.com/blogs/truehoop/0-24-118/Caron-Butler-in-the-Basement.html"}, +{188,"http://news.yahoo.com/"}, +{618,"http://news.yahoo.com/amazing-roll-cloud-tumbles-over-dc-area-161409111.html"}, +{994,"http://news.yahoo.com/blogs/trending-now/family-sells-home--goes-on-epic-yearlong-trip-to-all-50-states-185712913.html?vp=1"}, +{388,"http://news.yahoo.com/comics/dilbert-slideshow/"}, +{746,"http://news.yahoo.com/cost-cutting-may-have-played-role-in-navy-yard-shooting-134106229.html"}, +{682,"http://news.yahoo.com/giant-underground-blob-magma-puzzles-scientists-210726200.html"}, +{746,"http://news.yahoo.com/lightbox/dilbert-slideshow/20130523-dt130523-gif-photo-050423497.html"}, +{516,"http://news.yahoo.com/photos/costa-concordia-salvage-slideshow/"}, +{599,"http://news.yahoo.com/photos/turtle-rescue-in-israel-1379421810-slideshow/"}, +{666,"http://news.yahoo.com/put-business-trauma-doctor-pleads-u-navy-yard-181522657.html"}, +{698,"http://news.yahoo.com/touting-obamacare-us-says-millions-could-pay-less-212243340.html"}, +{578,"http://news.yahoo.com/video/old-soda-bottles-giving-life-001700872.html"}, +{380,"http://nl.wikipedia.org/wiki/Johann_David_Wyss"}, +{428,"http://nl.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{380,"http://no.wikipedia.org/wiki/Johann_David_Wyss"}, +{180,"http://omg.yahoo.com/"}, +{650,"http://omg.yahoo.com/blogs/celeb-news/brad-pitt-finally-makes-cut-223549188.html"}, +{794,"http://omg.yahoo.com/blogs/celeb-news/fashion-faceoff-miley-cyrus-vs-rachel-mcadams-190957403.html"}, +{882,"http://omg.yahoo.com/blogs/celeb-news/justin-theroux-reveals-one-thing-jennifer-aniston-wouldn-113635271.html"}, +{882,"http://omg.yahoo.com/news/courteney-cox-david-arquette-selling-beverly-hills-mansion-184500328-us-weekly.html"}, +{232,"http://omim.org/entry/602750"}, +{3387,"http://open.login.yahoo.net/openid/yrp/hr_signin?.intl=us&idp=facebook&ts=1379461518&rpcrumb=&.src=home&appid=90376669494&spid=b9ed13cc-ddec-11de-9c83-001b784d35e1&perms=email,user_birthday,user_education_history,user_likes,user_location,user_relationships,user_subscriptions,user_work_history,friends_birthday,friends_education_history,friends_likes,friends_location,friends_work_history&.done=http%3A%2F%2Fwww.yahoo.com%2F"}, +{320,"http://openlibrary.org/authors/OL342629A"}, +{340,"http://pl.wikipedia.org/wiki/Caron_Butler"}, +{380,"http://pl.wikipedia.org/wiki/Johann_David_Wyss"}, +{428,"http://pl.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{855,"http://probasketballtalk.nbcsports.com/2010/07/21/caron-butler-used-to-work-at-a-burger-king-now-owns-six/"}, +{340,"http://pt.wikipedia.org/wiki/Caron_Butler"}, +{659,"http://ru.wikipedia.org/wiki/%D0%91%D0%B0%D1%82%D0%BB%D0%B5%D1%80,_%D0%9A%D1%8D%D1%80%D0%BE%D0%BD"}, +{917,"http://ru.wikipedia.org/wiki/%D0%9A%D0%BE%D0%BD%D1%81%D1%82%D0%B8%D1%82%D1%83%D1%86%D0%B8%D1%8F_%D0%A2%D1%83%D1%80%D1%86%D0%B8%D0%B8_(1921)"}, +{204,"http://screen.yahoo.com/"}, +{453,"http://screen.yahoo.com/11-old-boy-made-9-134626064.html"}, +{738,"http://screen.yahoo.com/snl-women-skits/girl-wish-hadnt-started-conversation-000000658.html"}, +{204,"http://search.yahoo.com/"}, +{244,"http://search.yahoo.com/local"}, +{741,"http://search.yahoo.com/search?cs=bz&p=Biblical-era%20town&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{765,"http://search.yahoo.com/search?cs=bz&p=Green%20River%20Killer&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{733,"http://search.yahoo.com/search?cs=bz&p=Hostile%20takeover&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{741,"http://search.yahoo.com/search?cs=bz&p=Jennifer%20Lopez%20&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{701,"http://search.yahoo.com/search?cs=bz&p=Jessa%20Duggar&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{717,"http://search.yahoo.com/search?cs=bz&p=Kim%20Zolciak%20&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{717,"http://search.yahoo.com/search?cs=bz&p=LSU%20fraternity&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{741,"http://search.yahoo.com/search?cs=bz&p=Linda%20Ronstadt%20&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{749,"http://search.yahoo.com/search?cs=bz&p=Star%20Trek%20NSA%20&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{781,"http://search.yahoo.com/search?cs=bz&p=Walking%20Dead%20spinoff&fr=fp-tts-900&fr2=ps&woeid=23424856"}, +{188,"http://shine.yahoo.com"}, +{196,"http://shine.yahoo.com/"}, +{276,"http://shine.yahoo.com/horoscope/"}, +{548,"http://shine.yahoo.com/horoscope/virgo/extended-daily-20130917.html"}, +{548,"http://shine.yahoo.com/horoscope/virgo/overview-daily-20130917.html"}, +{754,"http://shine.yahoo.com/shine-food/5-things-didnt-know-could-pillsbury-biscuits-205500571.html"}, +{730,"http://shine.yahoo.com/shine-food/fabios-ultimate-pulled-pork-sandwich-011700797.html?vp=1"}, +{220,"http://shopping.yahoo.com/"}, +{412,"http://simple.wikipedia.org/wiki/Johann_David_Wyss"}, +{428,"http://sk.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{436,"http://smallbusiness.yahoo.com/?s_fptrough=ysb_acq_fp"}, +{402,"http://sports.espn.go.com/nba/news/story?id=3290089"}, +{400,"http://sports.espn.go.com/nba/recap?gameId=270117027"}, +{400,"http://sports.espn.go.com/nba/recap?gameId=280313027"}, +{196,"http://sports.yahoo.com"}, +{204,"http://sports.yahoo.com/"}, +{911,"http://sports.yahoo.com/blogs/mlb-big-league-stew/fan-dashes-onto-field-during-rays-game-only-192151790--mlb.html"}, +{991,"http://sports.yahoo.com/blogs/nfl-shutdown-corner/does-andy-reid-still-wish-philadelphia-jamaal-charles-180705907--nfl.html"}, +{260,"http://sports.yahoo.com/fantasy"}, +{228,"http://sports.yahoo.com/mlb"}, +{376,"http://sports.yahoo.com/mlb/preview?gid=330917104"}, +{360,"http://sports.yahoo.com/mlb/recap?gid=330917220"}, +{308,"http://sports.yahoo.com/mlb/teams/atl"}, +{939,"http://sports.yahoo.com/nba/blog/ball_dont_lie/post/More-on-Caron-Butler-s-extreme-Mountain-Dew-addi?urn=nba%2C198240"}, +{332,"http://sports.yahoo.com/nba/players/3608"}, +{647,"http://sports.yahoo.com/news/team-report-san-francisco-49ers-211200051--nfl.html"}, +{228,"http://sports.yahoo.com/nfl"}, +{383,"http://sports.yahoo.com/nfl/preview?gid=20130919021"}, +{367,"http://sports.yahoo.com/nfl/recap?gid=20130916004"}, +{308,"http://sports.yahoo.com/nfl/teams/cin"}, +{228,"http://sports.yahoo.com/nhl"}, +{308,"http://sports.yahoo.com/nhl/teams/was"}, +{684,"http://sr.wikipedia.org/wiki/%D0%92%D0%B8%D1%88%D0%BD%D0%B8_%D0%A1%D0%BB%D0%B0%D0%B2%D0%BA%D0%BE%D0%B2"}, +{832,"http://ta.wikipedia.org/wiki/%E0%AE%95%E0%AE%B0%E0%AE%BE%E0%AE%A9%E0%AF%8D_%E0%AE%AA%E0%AE%9F%E0%AF%8D%E0%AE%B2%E0%AE%B0%E0%AF%8D"}, +{931,"http://th.wikipedia.org/wiki/%E0%B9%81%E0%B8%84%E0%B8%A3%E0%B8%AD%E0%B8%99_%E0%B8%9A%E0%B8%B1%E0%B8%95%E0%B9%80%E0%B8%A5%E0%B8%AD%E0%B8%A3%E0%B9%8C"}, +{818,"http://thptbinhxuyen.edu.vn/vp/Top-200-truong-THPT-co-diem-thi-dai-hoc-cao-nhat-2011-t11736-7938.html"}, +{972,"http://tools.wmflabs.org/geohack/geohack.php?pagename=Vy%C5%A1n%C3%BD_Slavkov¶ms=49_04_N_20_52_E_region:SK_type:city"}, +{340,"http://tr.wikipedia.org/wiki/Caron_Butler"}, +{604,"http://tr.wikipedia.org/wiki/Te%C5%9Fkil%C3%A2t-%C4%B1_Esas%C3%AEye_Kanunu"}, +{204,"http://travel.yahoo.com/"}, +{172,"http://tv.yahoo.com/"}, +{770,"http://tv.yahoo.com/news/ncis-exclusive-sopranos-alum-eyed-zivas-successor-debut-205821229.html"}, +{684,"http://tv.yahoo.com/photos/emmys-unrecognizable-emmy-star-transformations-slideshow/"}, +{717,"http://uk.wikipedia.org/wiki/%D0%92%D0%B8%D1%88%D0%BD%D1%96%D0%B9_%D0%A1%D0%BB%D0%B0%D0%B2%D0%BA%D0%BE%D0%B2"}, +{801,"http://vi.wikipedia.org/wiki/Tr%C6%B0%E1%BB%9Dng_THPT_chuy%C3%AAn_L%C6%B0%C6%A1ng_V%C4%83n_Ch%C3%A1nh"}, +{1046,"http://vi.wikipedia.org/wiki/X%E1%BA%BFp_h%E1%BA%A1ng_tr%C6%B0%E1%BB%9Dng_trung_h%E1%BB%8Dc_ph%E1%BB%95_th%C3%B4ng_Vi%E1%BB%87t_Nam"}, +{232,"http://viaf.org/viaf/94287141"}, +{684,"http://voices.washingtonpost.com/dcsportsbog/2007/04/on_caron_butler_and_straws.html"}, +{436,"http://war.wikipedia.org/wiki/Vy%C5%A1n%C3%BD_Slavkov"}, +{505,"http://washingtontimes.com/sports/20060417-122458-4991r_page2.htm"}, +{204,"http://weather.yahoo.com"}, +{404,"http://weather.yahoo.com/forecast/JAXX0077_f.html"}, +{740,"http://web.archive.org/web/20040603025509/http://www.usabasketball.com/history/ymwc_2001.html"}, +{260,"http://wikimediafoundation.org/"}, +{412,"http://wikimediafoundation.org/wiki/Privacy_policy"}, +{396,"http://wikimediafoundation.org/wiki/Terms_of_Use"}, +{308,"http://www.anayasa.gen.tr/1921tek.htm"}, +{492,"http://www.basketball-reference.com/players/b/butleca01.html"}, +{587,"http://www.basketballreference.com/players/playerpage.htm?ilkid=BUTLECA01"}, +{380,"http://www.bilkent.edu.tr/~genckaya/1921C.html"}, +{308,"http://www.caronbutlersummercamp.com/"}, +{308,"http://www.daao.org.au/main/read/2355"}, +{386,"http://www.ebi.ac.uk/QuickGO/GProtein?ac=P30046"}, +{1416,"http://www.ebi.ac.uk/pdbe/searchResults.html?display=both&term=P30046%20or%20Q53Y51%20or%20E2RQU0%20or%20A5PK65%20or%20O35215%20or%20Q3UNI8%20or%20P80254%20or%20Q5ZMG0%20or%20Q6IQL4"}, +{574,"http://www.ensembl.org/Homo_sapiens/geneview?gene=ENSG00000099977;db=core"}, +{591,"http://www.ensembl.org/Mus_musculus/geneview?gene=ENSMUSG00000001666;db=core"}, +{188,"http://www.flickr.com/"}, +{550,"http://www.flickr.com/photos/yahooeditorspicks/galleries/72157635598104765"}, +{901,"http://www.flickr.com/photos/yahooeditorspicks/galleries/72157635598104765/with/7037921709/lightbox/?yc=www.yahoo.com"}, +{952,"http://www.fool.com/investing/general/2013/09/16/3-car-brands-that-may-disappear-before-2020.aspx?source=eogyholnk0000001"}, +{576,"http://www.genecards.org/cgi-bin/carddisp.pl?id_type=entrezgene&id=1652"}, +{456,"http://www.genenames.org/data/hgnc_data.php?hgnc_id=2732"}, +{443,"http://www.genome.jp/dbget-bin/www_bget?enzyme+4.1.1.84"}, +{404,"http://www.gutenberg.org/author/Johann_David_Wyss"}, +{597,"http://www.informatics.jax.org/searches/accession_report.cgi?id=MGI:1298381"}, +{212,"http://www.intonow.com/ci"}, +{348,"http://www.leighrayment.com/baronetage.htm"}, +{444,"http://www.london-gazette.co.uk/issues/21964/pages/379"}, +{436,"http://www.mapress.com/zootaxa/2010/f/z02583p119f.pdf"}, +{340,"http://www.mapress.com/zootaxa/index.html"}, +{212,"http://www.mediawiki.org/"}, +{544,"http://www.nba.com/allstar2007/news/allstar_reserves_070201.html"}, +{332,"http://www.nba.com/news/pow_070122.html"}, +{348,"http://www.nba.com/playerfile/caron_butler"}, +{356,"http://www.nba.com/playerfile/caron_butler/"}, +{492,"http://www.nba.com/suns/news/suns-trade-kravtsov-smith-bucks"}, +{588,"http://www.nba.com/suns/suns-complete-deal-eric-bledsoe-and-caron-butler"}, +{832,"http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=homologene&dopt=HomoloGene&list_uids=1038"}, +{812,"http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=retrieve&dopt=default&list_uids=13202&rn=1"}, +{804,"http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=retrieve&dopt=default&list_uids=1652&rn=1"}, +{488,"http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?val=NM_001084392"}, +{478,"http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?val=NM_010027"}, +{405,"http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1219731"}, +{400,"http://www.ncbi.nlm.nih.gov/pmc/articles/PMC139241"}, +{405,"http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1847948"}, +{344,"http://www.ncbi.nlm.nih.gov/pubmed/10079069"}, +{341,"http://www.ncbi.nlm.nih.gov/pubmed/1286669"}, +{341,"http://www.ncbi.nlm.nih.gov/pubmed/8267597"}, +{688,"http://www.ncbi.nlm.nih.gov/sites/entrez?Db=gene&Cmd=ShowDetailView&TermToSearch=1652"}, +{747,"http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid=13202"}, +{744,"http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid=1652"}, +{428,"http://www.oprah.com/oprahshow/Overcoming-the-Odds/8"}, +{428,"http://www.oprah.com/oprahshow/Overcoming-the-Odds/9"}, +{412,"http://www.rcsb.org/pdb/cgi/explore.cgi?pdbId=1DPT"}, +{1322,"http://www.rcsb.org/pdb/search/smartSubquery.do?smartSearchSubtype=UpAccessionIdQuery&accessionIdList=P30046,Q53Y51,E2RQU0,A5PK65,O35215,Q3UNI8,P80254,Q5ZMG0,Q6IQL4"}, +{806,"http://www.sbnation.com/golf/2013/9/17/4737628/bmw-championship-2013-tiger-woods-penalty-johnny-miller"}, +{364,"http://www.statistics.sk/mosmis/eng/run.html"}, +{188,"http://www.tbmm.gov.tr"}, +{372,"http://www.tbmm.gov.tr/english/about_tgna.htm"}, +{212,"http://www.thepeerage.com"}, +{284,"http://www.thepeerage.com/info.htm"}, +{585,"http://www.uconnhuskies.com/AllStories/MBasketball/2002/06/26/20020626.html"}, +{304,"http://www.uniprot.org/uniprot/O35215"}, +{304,"http://www.uniprot.org/uniprot/P30046"}, +{644,"http://www.washingtonpost.com/wp-dyn/content/article/2008/02/16/AR2008021600752_2.html"}, +{293,"http://www.wikidata.org/wiki/Q115822"}, +{460,"http://www.wikidata.org/wiki/Q115822#sitelinks-wikipedia"}, +{292,"http://www.wikimediafoundation.org/"}, +{172,"http://www.yahoo.com"}, +{180,"http://www.yahoo.com/"}, +{188,"http://www.yahoo.com/#"}, +{276,"http://www.yahoo.com/#suggestions"}, +{244,"http://www.yahoo.com/?hps=210"}, +{444,"http://yahoo.match.com?trackingid=526100&bannerid=673168"}, +{535,"http://zh.wikipedia.org/wiki/%E5%8D%A1%E9%9A%86%C2%B7%E5%B7%B4%E7%89%B9%E5%8B%92"}, +{1164,"https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en"}, +{740,"https://edit.yahoo.com/registration?.src=fpctx&.intl=us&.done=http%3A%2F%2Fwww.yahoo.com%2F"}, +{748,"https://login.yahoo.com/config/login?.src=fpctx&.intl=us&.done=http%3A%2F%2Fwww.yahoo.com%2F"}, +{548,"https://www.mediawiki.org/wiki/Special:MyLanguage/How_to_contribute"}, +{0,NULL} +}; diff --git a/tests/test_split_urls.c b/tests/test_split_urls.c new file mode 100644 index 0000000000..db6b455024 --- /dev/null +++ b/tests/test_split_urls.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include "common.h" +#include "../qrinput.h" +#include "../qrencode_inner.h" +#include "../split.h" +#include "decoder.h" + +#include "URI_testset.inc" + +void encodeURLandPrint(char *url) { + QRinput *input; + BitStream *bstream; + + input = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(url, input, QR_MODE_8, 1); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); + + printf("{%d,\"%s\"},\n", BitStream_size(bstream), url); + + QRinput_free(input); + BitStream_free(bstream); +} + +void print_currentBitLength() { + struct TestSet *ts = testset; + + puts("struct TestSet {\n\tint expected_length;\n\tchar *url;\n};"); + puts("\nstruct TestSet testset[] = {"); + + while(ts->url != NULL) { + encodeURLandPrint(ts->url); + ts++; + } + + puts("{0,NULL}\n};"); +} + +int encodeURLandCompare(char *url, int expected_length) { + QRinput *input; + BitStream *bstream; + int ret = 0; + + input = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(url, input, QR_MODE_8, 1); + bstream = BitStream_new(); + QRinput_mergeBitStream(input, bstream); + + int length = BitStream_size(bstream); + if(length > expected_length) { + printf("The length of the encode stream is longer than expected: %d over %d\n", length, expected_length); + printQRinput(input); + + ret = 1; + } else if(length < expected_length) { + printf("The length of the encode stream is shorter than expected: %d under %d\n", length, expected_length); + printQRinput(input); + + ret = 1; + } + + QRinput_free(input); + BitStream_free(bstream); + + return ret; +} + +void test_bitstream_length() { + struct TestSet *ts = testset; + int err = 0; + + testStart("Split_URL test: compare bitstream length"); + while(ts->url != NULL) { + err += encodeURLandCompare(ts->url, ts->expected_length); + ts++; + } + testEnd(err); +} + +int main(void) +{ + test_bitstream_length(); + + report(); + + return 0; +} -- cgit 0.0.5-2-1-g0f52 From 14f0c1a7f572a0d353b6156db1cc0d453bc99a24 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 25 Jul 2014 02:23:20 +0900 Subject: New test suite. --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 33fcbde287..424b80cca3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014.07.25 Kentaro FUKUCHI + * tests/URI_testset.inc, tests/test_split_urls.c, tests/Makefile.am, + .gitignore: + - A new test suite evaluating splitting efficiency has been added. + - Still undertrial. + 2014.07.24 Kentaro FUKUCHI * qrinput.c: - Code refactoring (QRinput_Struct_count has been added). -- cgit 0.0.5-2-1-g0f52 From 598cab5d88f5da2afe565c89dee94e44e5cdb8f8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 Aug 2014 13:25:45 +0900 Subject: Use SDL_WaitEvent() instead of SDL_PollEvent(). --- ChangeLog | 4 ++ tests/view_qrcode.c | 126 ++++++++++++++++++++++++++-------------------------- 2 files changed, 66 insertions(+), 64 deletions(-) diff --git a/ChangeLog b/ChangeLog index 424b80cca3..243cd6da39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.08.05 Kentaro FUKUCHI + * tests/view_qrcode.c: + - Use SDL_WaitEvent() instead of SDL_PollEvent(). + 2014.07.25 Kentaro FUKUCHI * tests/URI_testset.inc, tests/test_split_urls.c, tests/Makefile.am, .gitignore: diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index fd7e9a988c..7009c448c6 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -289,73 +289,71 @@ void view(int mode, QRinput *input) } loop = 1; while(loop) { - usleep(10000); - while(SDL_PollEvent(&event)) { - if(event.type == SDL_KEYDOWN) { - switch(event.key.keysym.sym) { - case SDLK_RIGHT: - version++; - if(version > QRSPEC_VERSION_MAX) - version = QRSPEC_VERSION_MAX; - loop = 0; - break; - case SDLK_LEFT: - version--; - if(version < 1) - version = 1; - loop = 0; - break; - case SDLK_UP: - size++; - loop = 0; - break; - case SDLK_DOWN: - size--; - if(size < 1) size = 1; - loop = 0; - break; - case SDLK_0: - case SDLK_1: - case SDLK_2: - case SDLK_3: - case SDLK_4: - case SDLK_5: - case SDLK_6: - case SDLK_7: - if(!mode && !structured) { - mask = (event.key.keysym.sym - SDLK_0); - loop = 0; - } - break; - case SDLK_8: - if(!mode && !structured) { - mask = -1; - loop = 0; - } - break; - case SDLK_l: - level = QR_ECLEVEL_L; - loop = 0; - break; - case SDLK_m: - level = QR_ECLEVEL_M; - loop = 0; - break; - case SDLK_h: - level = QR_ECLEVEL_H; - loop = 0; - break; - case SDLK_q: - level = QR_ECLEVEL_Q; + SDL_WaitEvent(&event); + if(event.type == SDL_KEYDOWN) { + switch(event.key.keysym.sym) { + case SDLK_RIGHT: + version++; + if(version > QRSPEC_VERSION_MAX) + version = QRSPEC_VERSION_MAX; + loop = 0; + break; + case SDLK_LEFT: + version--; + if(version < 1) + version = 1; + loop = 0; + break; + case SDLK_UP: + size++; + loop = 0; + break; + case SDLK_DOWN: + size--; + if(size < 1) size = 1; + loop = 0; + break; + case SDLK_0: + case SDLK_1: + case SDLK_2: + case SDLK_3: + case SDLK_4: + case SDLK_5: + case SDLK_6: + case SDLK_7: + if(!mode && !structured) { + mask = (event.key.keysym.sym - SDLK_0); loop = 0; - break; - case SDLK_ESCAPE: + } + break; + case SDLK_8: + if(!mode && !structured) { + mask = -1; loop = 0; - flag = 0; - break; - default: - break; } + break; + case SDLK_l: + level = QR_ECLEVEL_L; + loop = 0; + break; + case SDLK_m: + level = QR_ECLEVEL_M; + loop = 0; + break; + case SDLK_h: + level = QR_ECLEVEL_H; + loop = 0; + break; + case SDLK_q: + level = QR_ECLEVEL_Q; + loop = 0; + break; + case SDLK_ESCAPE: + loop = 0; + flag = 0; + break; + default: + break; } if(event.type == SDL_QUIT) { loop = 0; -- cgit 0.0.5-2-1-g0f52 From c9ad802120a3aeebb45804314eead2d35511dad0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 Aug 2014 14:43:57 +0900 Subject: Added some conditional flags for configuration/building process. --- ChangeLog | 4 ++++ Makefile.am | 2 ++ configure.ac | 12 ++++++++++-- tests/Makefile.am | 25 +++++++++++++++++-------- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 243cd6da39..f9cf5264e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ 2014.08.05 Kentaro FUKUCHI + * configure.ac, Makefile.am, tests/Makefile.am: + - Added some conditional flags for configuration/building process. + - HAVE_PNG and HAVE_SDL can be refered from both Makefile and program + code. * tests/view_qrcode.c: - Use SDL_WaitEvent() instead of SDL_PollEvent(). diff --git a/Makefile.am b/Makefile.am index 9c02b81220..ae56671942 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,9 +31,11 @@ EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \ qrencode.1.in Doxyfile tests/test_all.sh if BUILD_TOOLS +if HAVE_PNG bin_PROGRAMS = qrencode qrencode_SOURCES = qrenc.c qrencode_CFLAGS = $(png_CFLAGS) qrencode_LDADD = libqrencode.la $(png_LIBS) man1_MANS = qrencode.1 endif +endif diff --git a/configure.ac b/configure.ac index 6eaaf726bc..a755e4f091 100644 --- a/configure.ac +++ b/configure.ac @@ -59,8 +59,16 @@ AC_ARG_WITH([tools], [AS_HELP_STRING([--with-tools], [build utility tools [defau AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ]) if test x$build_tools = xyes ; then - PKG_CHECK_MODULES(png, "libpng") + PKG_CHECK_MODULES(png, "libpng", [AC_DEFINE([HAVE_PNG], [1], [Define to 1 if using libpng is enabled.])], [AC_DEFINE([HAVE_PNG], [0])]) + if test x$png_CFLAGS = x ; then + echo " +!!!!!!!!!! +LIBPNG is required to build the utility tools. Temporarily disabled. +!!!!!!!!!! +" + fi fi +AM_CONDITIONAL(HAVE_PNG, [test "x$png_CFLAGS" != "x" ]) dnl --with-tests AC_ARG_WITH([tests], [AS_HELP_STRING([--with-tests], [build tests [default=no]])], @@ -82,7 +90,7 @@ fi if test x$build_tests = xyes ; then SDL_REQUIRED_VERSION=1.2.0 - PKG_CHECK_MODULES(SDL, [sdl >= $SDL_REQUIRED_VERSION]) + PKG_CHECK_MODULES(SDL, [sdl >= $SDL_REQUIRED_VERSION], [AC_DEFINE([HAVE_SDL], [1], [Define to 1 if using SDL is enabled.])], [AC_DEFINE([HAVE_SDL], [0])]) AM_ICONV_LINK fi AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 0581c35d74..bf609b7209 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,13 +1,21 @@ +AM_CFLAGS = +AM_LDFLAGS = + if HAVE_SDL sdlPROGRAMS = view_qrcode +AM_CFLAGS += $(SDL_CFLAGS) +AM_LDFLAGS += $(SDL_LIBS) +endif + +if HAVE_PNG +pngPROGRAMS = create_frame_pattern create_mqr_frame_pattern endif noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ test_qrspec test_rs test_qrencode prof_qrencode \ test_mqrspec test_split test_monkey test_mask test_mmask \ - create_frame_pattern create_mqr_frame_pattern \ test_split_urls \ - $(sdlPROGRAMS) + $(pngPROGRAMS) $(sdlPROGRAMS) noinst_LIBRARIES = libdecoder.a DECODER_LIBS = libdecoder.a $(LIBICONV) noinst_HEADERS = common.h rscode.h @@ -61,16 +69,17 @@ prof_qrencode_LDADD = ../libqrencode.la pthread_qrencode_SOURCES = pthread_qrencode.c pthread_qrencode_LDADD = ../libqrencode.la $(LIBPTHREAD) +if HAVE_PNG create_frame_pattern_SOURCES = create_frame_pattern.c -create_frame_pattern_CFLAGS = $(png_CFLAGS) -create_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) +create_frame_pattern_CFLAGS = $(png_CFLAGS) $(AM_CFLAGS) +create_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) $(AM_LDFLAGS) create_mqr_frame_pattern_SOURCES = create_mqr_frame_pattern.c -create_mqr_frame_pattern_CFLAGS = $(png_CFLAGS) -create_mqr_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) +create_mqr_frame_pattern_CFLAGS = $(png_CFLAGS) $(AM_CFLAGS) +create_mqr_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) $(AM_LDFLAGS) +endif if HAVE_SDL view_qrcode_SOURCES = view_qrcode.c -view_qrcode_CFLAGS= $(SDL_CFLAGS) -view_qrcode_LDADD = ../libqrencode.la $(SDL_LIBS) +view_qrcode_LDADD = ../libqrencode.la endif -- cgit 0.0.5-2-1-g0f52 From d0a7499ec0f20435b2131930285734aa0a6ff391 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 Aug 2014 14:50:07 +0900 Subject: Verbose debug message eliminated. --- tests/test_qrinput.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 73a5787b7c..5ee944520d 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -245,7 +245,6 @@ void test_padding2(void) assert_equal(size, 152, "16byte: # of bit is incorrect (%d != 152).\n", size); ret = ncmpBin(correct, bstream, 152); assert_zero(ret, "Padding bits incorrect.\n"); - printBstream(bstream); QRinput_free(input); BitStream_free(bstream); @@ -263,7 +262,6 @@ void test_padding2(void) assert_equal(size, 152, "15byte: # of bit is incorrect (%d != 152).\n", size); ret = ncmpBin(correct, bstream, 152); assert_zero(ret, "Padding bits incorrect.\n"); - printBstream(bstream); testFinish(); -- cgit 0.0.5-2-1-g0f52 From c83400cfee1e68fd92d5711cee62b1d98d61b954 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 Aug 2014 15:04:27 +0900 Subject: Added show_QRcode() for testing purposes. (Thanks to Sunil Maganally) --- ChangeLog | 2 ++ README | 3 ++- README.md | 2 +- tests/common.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9cf5264e4..5be0dd993f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ code. * tests/view_qrcode.c: - Use SDL_WaitEvent() instead of SDL_PollEvent(). + * tests/common.h: + - Added show_QRcode() for testing purposes. (Thanks to Sunil Maganally) 2014.07.25 Kentaro FUKUCHI * tests/URI_testset.inc, tests/test_split_urls.c, tests/Makefile.am, diff --git a/README b/README index f13537c2e5..9486f8f168 100644 --- a/README +++ b/README @@ -142,5 +142,6 @@ Greg Hart - PNG32 support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue +ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, +Sunil Maganally - bug report / suggestion diff --git a/README.md b/README.md index c566a808c1..7a113d705b 100644 --- a/README.md +++ b/README.md @@ -140,4 +140,4 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - Viona - bug fix patch for string splitting - Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration - Greg Hart - PNG32 support patch -- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue - bug report / suggestion +- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, Sunil Maganally - bug report / suggestion diff --git a/tests/common.h b/tests/common.h index 4d284cafb3..322a45b319 100644 --- a/tests/common.h +++ b/tests/common.h @@ -199,4 +199,64 @@ void printBstream(BitStream *bstream) } printf("\n"); } + +#if HAVE_SDL +/* Experimental debug function */ +/* You can call show_QRcode(QRcode *code) to display the QR Code from anywhere + * in test code using SDL. */ +#include +static SDL_Surface *screen = NULL; + +static void draw_QRcode(QRcode *qrcode, int ox, int oy, int margin, int size) +{ + int x, y, width; + unsigned char *p; + SDL_Rect rect; + + ox += margin * size; + oy += margin * size; + width = qrcode->width; + p = qrcode->data; + for(y=0; ywidth + 4 * 2) * 4; //maring = 4, size = 4 + screen = SDL_SetVideoMode(width, width, 32, 0); + SDL_FillRect(screen, NULL, 0xffffff); + + draw_QRcode(qrcode, 0, 0, 4, 4); + + SDL_Flip(screen); + fprintf(stderr, "Press any key on the QR Code window to proceed.\n"); + + int loop = 1; + while(loop) { + SDL_WaitEvent(&event); + if(event.type == SDL_KEYDOWN) { + loop = 0; + } + } +} +#else +void show_QRcode() { +} +#endif + #endif /* __COMMON_H__ */ -- cgit 0.0.5-2-1-g0f52 From 518d0025f03797a1c6de85bf27fd216594b09d89 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 Aug 2014 15:12:30 +0900 Subject: Cleanups. --- .gitignore | 1 + tests/Makefile.am | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0f5c375581..da409d12fa 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ use/depcomp use/install-sh use/ltmain.sh use/missing +html/ diff --git a/tests/Makefile.am b/tests/Makefile.am index bf609b7209..252f2d8871 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -72,11 +72,11 @@ pthread_qrencode_LDADD = ../libqrencode.la $(LIBPTHREAD) if HAVE_PNG create_frame_pattern_SOURCES = create_frame_pattern.c create_frame_pattern_CFLAGS = $(png_CFLAGS) $(AM_CFLAGS) -create_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) $(AM_LDFLAGS) +create_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) create_mqr_frame_pattern_SOURCES = create_mqr_frame_pattern.c create_mqr_frame_pattern_CFLAGS = $(png_CFLAGS) $(AM_CFLAGS) -create_mqr_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) $(AM_LDFLAGS) +create_mqr_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) endif if HAVE_SDL -- cgit 0.0.5-2-1-g0f52 From e72cf9ef4fbf65fb13676d0246b48dd705efdc39 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 Aug 2014 15:43:17 +0900 Subject: main()'s arguments now correctly declared. --- ChangeLog | 2 ++ tests/prof_qrencode.c | 2 +- tests/pthread_qrencode.c | 2 +- tests/test_bitstream.c | 2 +- tests/test_estimatebit.c | 2 +- tests/test_mask.c | 2 +- tests/test_mmask.c | 2 +- tests/test_mqrspec.c | 2 +- tests/test_qrencode.c | 2 +- tests/test_qrinput.c | 2 +- tests/test_qrspec.c | 2 +- tests/test_rs.c | 2 +- tests/test_split.c | 2 +- tests/test_split_urls.c | 2 +- 14 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5be0dd993f..e7d723d5bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ - Use SDL_WaitEvent() instead of SDL_PollEvent(). * tests/common.h: - Added show_QRcode() for testing purposes. (Thanks to Sunil Maganally) + * tests/*.c: + - main()'s arguments now correctly declared. 2014.07.25 Kentaro FUKUCHI * tests/URI_testset.inc, tests/test_split_urls.c, tests/Makefile.am, diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index a02d9a7a8e..6c285e80b5 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -63,7 +63,7 @@ void prof_ver31to40(void) timerStop(); } -int main(void) +int main(int argc, char **argv) { prof_ver1to10(); prof_ver31to40(); diff --git a/tests/pthread_qrencode.c b/tests/pthread_qrencode.c index dbaa1ce5ea..77655583ea 100644 --- a/tests/pthread_qrencode.c +++ b/tests/pthread_qrencode.c @@ -96,7 +96,7 @@ void prof_ver31to40(void) timerStop(); } -int main(void) +int main(int argc, char **argv) { prof_ver1to10(); prof_ver31to40(); diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 03fedda51d..85e634ecd0 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -203,7 +203,7 @@ void test_append(void) BitStream_free(bs2); } -int main(void) +int main(int argc, char **argv) { test_null(); test_num(); diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index bcae3f6273..4e65eb630c 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -139,7 +139,7 @@ void test_mix(void) QRinput_free(gstream); } -int main(void) +int main(int argc, char **argv) { gstream = QRinput_new(); diff --git a/tests/test_mask.c b/tests/test_mask.c index 56bedcb308..b9e2744e32 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -388,7 +388,7 @@ void test_calcN1N3(void) testFinish(); } -int main(void) +int main(int argc, char **argv) { //print_masks(); test_masks(); diff --git a/tests/test_mmask.c b/tests/test_mmask.c index a3346dd2da..c81dd866e8 100644 --- a/tests/test_mmask.c +++ b/tests/test_mmask.c @@ -138,7 +138,7 @@ void test_maskEvaluation(void) testFinish(); } -int main(void) +int main(int argc, char **argv) { //print_masks(); test_masks(); diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index 70705c1178..56c5a89864 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -162,7 +162,7 @@ void test_dataLength(void) testEnd(err); } -int main(void) +int main(int argc, char **argv) { test_newFrame(); test_newframe_invalid(); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 6ab7f0c31b..cc92463183 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -957,7 +957,7 @@ void test_apiversion(void) testFinish(); } -int main(void) +int main(int argc, char **argv) { test_iterate(); test_iterate2(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 5ee944520d..e8e404a750 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -944,7 +944,7 @@ void test_encodeECI(void) testFinish(); } -int main(void) +int main(int argc, char **argv) { test_encodeNumeric(); test_encodeNumeric2(); diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 5993d5e003..53a60eaa84 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -308,7 +308,7 @@ void test_format(void) testEnd(err); } -int main(void) +int main(int argc, char **argv) { test_eccTable(); test_eccTable2(); diff --git a/tests/test_rs.c b/tests/test_rs.c index 59a525fa5d..cbcdb5a573 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -107,7 +107,7 @@ void test_allQRSizeAndECCLevel(void) testFinish(); } -int main(void) +int main(int argc, char **argv) { test_rscodeexample(); test_allQRSizeAndECCLevel(); diff --git a/tests/test_split.c b/tests/test_split.c index 63a0a4c93d..d17501484a 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -528,7 +528,7 @@ void test_split8N8(void) QRinput_free(input3); } -int main(void) +int main(int argc, char **argv) { test_split1(); test_split2(); diff --git a/tests/test_split_urls.c b/tests/test_split_urls.c index db6b455024..3de2fc83d3 100644 --- a/tests/test_split_urls.c +++ b/tests/test_split_urls.c @@ -79,7 +79,7 @@ void test_bitstream_length() { testEnd(err); } -int main(void) +int main(int argc, char **argv) { test_bitstream_length(); -- cgit 0.0.5-2-1-g0f52 From 0ed5072e2faa42e09ddae3057532e0ef08de8f3f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 15 Aug 2014 19:54:26 +0900 Subject: Version number check improved for Micro QR Code. --- ChangeLog | 4 ++++ tests/view_qrcode.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e7d723d5bd..cfb9d23a88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.08.15 Kentaro FUKUCHI + * tests/view_qrcode.c: + - Version number check improved for Micro QR Code. + 2014.08.05 Kentaro FUKUCHI * configure.ac, Makefile.am, tests/Makefile.am: - Added some conditional flags for configuration/building process. diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 7009c448c6..53db7dca92 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -15,7 +15,7 @@ static int casesensitive = 1; static int eightbit = 0; static int version = 1; static int size = 4; -static int margin = 4; +static int margin = -1; static int structured = 0; static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; @@ -502,6 +502,33 @@ int main(int argc, char **argv) intext = readStdin(&length); } + if(micro && version > MQRSPEC_VERSION_MAX) { + fprintf(stderr, "Version should be less or equal to %d.\n", MQRSPEC_VERSION_MAX); + exit(EXIT_FAILURE); + } else if(!micro && version > QRSPEC_VERSION_MAX) { + fprintf(stderr, "Version should be less or equal to %d.\n", QRSPEC_VERSION_MAX); + exit(EXIT_FAILURE); + } + + if(margin < 0) { + if(micro) { + margin = 2; + } else { + margin = 4; + } + } + + if(micro) { + if(version == 0) { + fprintf(stderr, "Version must be specified to encode a Micro QR Code symbol.\n"); + exit(EXIT_FAILURE); + } + if(structured) { + fprintf(stderr, "Micro QR Code does not support structured symbols.\n"); + exit(EXIT_FAILURE); + } + } + if(SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Failed initializing SDL: %s\n", SDL_GetError()); return -1; -- cgit 0.0.5-2-1-g0f52 From 6a4b2e3710b3c762f43d5ecb18db69cab1e1c10c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 15 Aug 2014 20:36:23 +0900 Subject: Code/Usage cleanups and updates. --- tests/view_qrcode.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 53db7dca92..43481d0928 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -13,7 +13,7 @@ static SDL_Surface *screen = NULL; static int casesensitive = 1; static int eightbit = 0; -static int version = 1; +static int version = 0; static int size = 4; static int margin = -1; static int structured = 0; @@ -61,9 +61,10 @@ static void usage(int help, int longopt) " specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n\n" " -v NUMBER, --symversion=NUMBER\n" -" specify the version of the symbol. (default=auto)\n\n" +" specify the version of the symbol. See SYMBOL VERSIONS for more\n" +" information. (default=auto)\n\n" " -m NUMBER, --margin=NUMBER\n" -" specify the width of the margins. (default=4)\n\n" +" specify the width of the margins. (default=4 (2 for Micro QR)))\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" @@ -76,7 +77,15 @@ static void usage(int help, int longopt) " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" -" standard input.\n" +" standard input.\n\n" +"*SYMBOL VERSIONS\n" +" The symbol versions of QR Code range from Version 1 to Version\n" +" 40. Each version has a different module configuration or number\n" +" of modules, ranging from Version 1 (21 x 21 modules) up to\n" +" Version 40 (177 x 177 modules). Each higher version number\n" +" comprises 4 additional modules per side by default. See\n" +" http://www.qrcode.com/en/about/version.html for a detailed\n" +" version list.\n" ); } else { fprintf(stderr, @@ -88,7 +97,7 @@ static void usage(int help, int longopt) " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" " -v NUMBER specify the version of the symbol. (default=auto)\n" -" -m NUMBER specify the width of the margins. (default=4)\n" +" -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" @@ -489,6 +498,7 @@ int main(int argc, char **argv) break; } } + if(argc == 1) { usage(1, 0); exit(EXIT_SUCCESS); @@ -529,19 +539,22 @@ int main(int argc, char **argv) } } + if(structured) { + if(version == 0) { + fprintf(stderr, "Version must be specified to encode structured symbols.\n"); + exit(EXIT_FAILURE); + } + if(argc - optind > 1) { + view_multiText(argv + optind, argc - optind); + } else { + view_simple(intext, length); + } + } + if(SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Failed initializing SDL: %s\n", SDL_GetError()); return -1; } - if(structured && version < 1) { - fprintf(stderr, "Version number must be greater than 0 to encode structured symbols.\n"); - exit(EXIT_FAILURE); - } - if(structured && (argc - optind > 1)) { - view_multiText(argv + optind, argc - optind); - } else { - view_simple(intext, length); - } SDL_Quit(); -- cgit 0.0.5-2-1-g0f52 From 22abc45fcd0e7ca96ad815c7cbcf8b88b2984832 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 18 Aug 2014 15:00:29 +0900 Subject: Added new option "--enable-asan" that enables AddressSanitizer. --- ChangeLog | 4 ++++ configure.ac | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index cfb9d23a88..702e950111 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.08.18 Kentaro FUKUCHI + * configure.ac: + - Added new option "--enable-asan" that enables AddressSanitizer. + 2014.08.15 Kentaro FUKUCHI * tests/view_qrcode.c: - Version number check improved for Micro QR Code. diff --git a/configure.ac b/configure.ac index a755e4f091..1a0e67d3d2 100644 --- a/configure.ac +++ b/configure.ac @@ -128,6 +128,15 @@ if test x$enable_mudflap = xyes; then fi fi +dnl --enable-asan +AC_ARG_ENABLE([asan], [AS_HELP_STRING([--enable-asan], [use AddressSanitizer [default=no]])], + [], [enable_asan=no]) + +if test x$enable_asan = xyes; then + CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer" + LDFLAGS="$LDFLAGS -fsanitize=address" +fi + dnl set CFLAGS CFLAGS="-Wall $CFLAGS" -- cgit 0.0.5-2-1-g0f52 From b8935bf044b11869d170d3366583c67b39b6a021 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 8 Sep 2014 04:38:22 +0900 Subject: Added color support for EPS output. (closes #55) --- ChangeLog | 4 ++++ README | 2 +- README.md | 2 +- qrenc.c | 18 +++++++++++++++--- qrencode.1.in | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 702e950111..304b6985df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.09.08 Kentaro FUKUCHI + * qrenc.c: + - Added color support for EPS output. + 2014.08.18 Kentaro FUKUCHI * configure.ac: - Added new option "--enable-asan" that enables AddressSanitizer. diff --git a/README b/README index 9486f8f168..a1b48677cb 100644 --- a/README +++ b/README @@ -143,5 +143,5 @@ Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, -Sunil Maganally +Sunil Maganally, Norman Gray - bug report / suggestion diff --git a/README.md b/README.md index 7a113d705b..b262b3a292 100644 --- a/README.md +++ b/README.md @@ -140,4 +140,4 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - Viona - bug fix patch for string splitting - Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration - Greg Hart - PNG32 support patch -- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, Sunil Maganally - bug report / suggestion +- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, Sunil Maganally, Norman Gray - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index 643d4d57e4..78f1c1200d 100644 --- a/qrenc.c +++ b/qrenc.c @@ -135,7 +135,7 @@ static void usage(int help, int longopt, int status) " --background=RRGGBB[AA]\n" " specify foreground/background color in hexadecimal notation.\n" " 6-digit (RGB) or 8-digit (RGBA) form are supported.\n" -" Color output support available only in PNG and SVG.\n\n" +" Color output support available only in PNG, EPS and SVG.\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " --verbose\n" @@ -460,8 +460,20 @@ static int writeEPS(const QRcode *qrcode, const char *outfile) "1 0 rlineto " "0 -1 rlineto " "fill " - "} bind def " - "%d %d scale ", size, size); + "} bind def\n"); + /* set color */ + fprintf(fp, "gsave\n"); + fprintf(fp, "%f %f %f setrgbcolor\n", + (float)bg_color[0] / 255, + (float)bg_color[1] / 255, + (float)bg_color[2] / 255); + fprintf(fp, "%d %d scale\n", realwidth, realwidth); + fprintf(fp, "0 0 p\ngrestore\n"); + fprintf(fp, "%f %f %f setrgbcolor\n", + (float)fg_color[0] / 255, + (float)fg_color[1] / 255, + (float)fg_color[2] / 255); + fprintf(fp, "%d %d scale\n", size, size); /* data */ p = qrcode->data; diff --git a/qrencode.1.in b/qrencode.1.in index 5fa73e6f79..12d14368e8 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -70,7 +70,7 @@ encode in a Micro QR Code. (experimental) .B \-\-background=RRGGBB[AA] specify foreground/background color in hexadecimal notation. 6-digit (RGB) or 8-digit (RGBA) form are supported. -Color output support available only in PNG and SVG. +Color output support available only in PNG, EPS and SVG. .TP .B \-V, \-\-version display the version number and copyrights of the qrencode. -- cgit 0.0.5-2-1-g0f52 From 9cf54485cfddc64cff1862f36f82ba9eca5f0ef2 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Sep 2014 18:36:27 +0900 Subject: Merged 3.4.4. --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS b/NEWS index 50e5238191..d5f570bc7f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,18 @@ libqrencode NEWS - Overview of changes ====================================== +Version 3.4.4 (2014.7.24) +------------------------- +* Bug fix release. (Thanks to Yoshimichi Inoue) +* New option "--verbose" has been added to the command line tool. + +Release Note: +When only one symbol is generated in structured-append mode, the library had +inserted unnecessary chunk to the symbol and some QR Code readers fail to read +it. Now the library omits the chunk and generate a symbol identical to non- +structured symbol. + + Version 3.4.3 (2013.8.12) ------------------------- * New option "--rle" has been added to the command line tool (Thanks to Daniel -- cgit 0.0.5-2-1-g0f52 From 3d2001f1efcd2741ab3cdc3adaf7bd9f9b2b6784 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Sep 2014 20:37:05 +0900 Subject: Added an entry about 4.0.0. (not released yet) --- NEWS | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index d5f570bc7f..6bf424a8eb 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,22 @@ libqrencode NEWS - Overview of changes ====================================== +Version 4.0.0 (2014.x.x) +------------------------ +* Memory efficiency has been improved. +* Error correction code generating functions have been improved. +* Command line tool "qrencode" has been improved: + * PNG32 (direct color mode). (Thanks to Greg Hart) + * EPS output now supports foreground and background color. +* Various bug fixes. +* Various fixes for developers. + +Release Note: +While no API changes are introduced with this major update, we incremented the +major version number of libqrencode to 4, because its internal are widely +improved. + + Version 3.4.4 (2014.7.24) ------------------------- * Bug fix release. (Thanks to Yoshimichi Inoue) @@ -12,7 +28,6 @@ inserted unnecessary chunk to the symbol and some QR Code readers fail to read it. Now the library omits the chunk and generate a symbol identical to non- structured symbol. - Version 3.4.3 (2013.8.12) ------------------------- * New option "--rle" has been added to the command line tool (Thanks to Daniel @@ -117,7 +132,6 @@ Version 3.1.1 (2010.2.3) * A bug in the library has been fixed. Release Note: - Libqrecode had generated incorrect QR Code in some cases. Symbols larger than version 5 (error correction level Q and H) were affected. In many cases this bug did not cause serious damage thanks to the error correction mechanism, but @@ -132,7 +146,6 @@ Version 3.1.0 (2009.6.6) * Some memory leak bugs have been fixed. Release Note: - This release focuses on the code cleanup and performance improve. Encoding time has been improved, drastically in large symbols. Basically this update only changes its internal code. The API is not changed, no need to recompile user @@ -147,7 +160,6 @@ Version 3.0.3 (2008.6.1) for the detailed instruction. Release Note: - This release improves the portability of our command line tool "qrencode". The library is not changed so that any applications using libqrencode are not affected. @@ -186,7 +198,6 @@ Version 3.0.0 (2008.4.30) * Some bug fixes. Release Note: - Now libqrencode supports "structured-append" of symbols. A large data set can be split into multiple QR code symbols. The basic usage of structured-append is not so different from the single symbol encoding: just call @@ -242,7 +253,6 @@ Summary: - QRcode_encodeString8bit() has been added. Release Note: - Previously libqrencode encodes lower-case alphabet characters in Alphabet- Numeric mode (upper-case alphabet and numeric) by default. According to the specification of QR code, however, it is clearly claimed that Alphabet-Numeric -- cgit 0.0.5-2-1-g0f52 From 52b9191e879dcd21a59f5270b6dac22896514fb3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 9 Sep 2014 22:35:13 +0900 Subject: Run length calc improved. --- ChangeLog | 6 ++++++ mask.c | 44 +++++++++++++++++++++++++++++++++++--------- mask.h | 3 ++- tests/test_mask.c | 8 ++++---- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 304b6985df..ff263bbfe8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014.09.09 Kentaro FUKUCHI + * NEWS: + - Added an entry about 4.0.0. (not released yet) + * mask.[ch], tests/test_mask.c: + - Run length calculation has been slightly improved. + 2014.09.08 Kentaro FUKUCHI * qrenc.c: - Added color support for EPS output. diff --git a/mask.c b/mask.c index 47c658ca0e..1485d01962 100644 --- a/mask.c +++ b/mask.c @@ -241,14 +241,40 @@ __STATIC int Mask_calcN2(int width, unsigned char *frame) return demerit; } -__STATIC int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *runLength) +__STATIC int Mask_calcRunLengthH(int width, unsigned char *frame, int *runLength) { int head; int i; - unsigned char *p; - int pitch; + unsigned char prev; + + if(frame[0] & 1) { + runLength[0] = -1; + head = 1; + } else { + head = 0; + } + runLength[head] = 1; + prev = frame[0]; + + for(i=1; i Date: Tue, 9 Sep 2014 23:35:29 +0900 Subject: Reduced malloc calls. --- ChangeLog | 1 + mask.c | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff263bbfe8..e1f451bf03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - Added an entry about 4.0.0. (not released yet) * mask.[ch], tests/test_mask.c: - Run length calculation has been slightly improved. + - Reduce malloc calls. 2014.09.08 Kentaro FUKUCHI * qrenc.c: diff --git a/mask.c b/mask.c index 1485d01962..71b7cd78c4 100644 --- a/mask.c +++ b/mask.c @@ -321,17 +321,17 @@ __STATIC int Mask_evaluateSymbol(int width, unsigned char *frame) unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) { + static unsigned char mask[QRSPEC_WIDTH_MAX * QRSPEC_WIDTH_MAX]; int i; - unsigned char *mask, *bestMask; + unsigned char *bestMask; int minDemerit = INT_MAX; int blacks; int bratio; int demerit; int w2 = width * width; - mask = (unsigned char *)malloc(w2); - if(mask == NULL) return NULL; - bestMask = NULL; + bestMask = (unsigned char *)malloc(w2); + if(bestMask == NULL) return NULL; for(i=0; i Date: Wed, 10 Sep 2014 00:19:49 +0900 Subject: Frame caches have been eliminated. --- ChangeLog | 10 ++++++++++ mqrspec.c | 47 +---------------------------------------------- mqrspec.h | 5 ----- qrencode.c | 6 ------ qrencode.h | 7 ------- qrspec.c | 47 +---------------------------------------------- qrspec.h | 7 ------- tests/prof_qrencode.c | 2 -- tests/pthread_qrencode.c | 2 -- tests/test_mask.c | 2 -- tests/test_mmask.c | 2 -- tests/test_monkey.c | 2 -- tests/test_mqrspec.c | 2 -- tests/test_qrencode.c | 2 -- tests/test_qrspec.c | 2 -- 15 files changed, 12 insertions(+), 133 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1f451bf03..46e0deb280 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,16 @@ * mask.[ch], tests/test_mask.c: - Run length calculation has been slightly improved. - Reduce malloc calls. + [noframecache] + * qrspec.[ch], mqrspec.[ch]: + - Frame caches have been eliminated. It improves both memory efficiency + and performance... Wait, caches were completely meaningless? orz... + * qrencode.[ch]: + - QRcode_clearCache() has been eliminated. + * tests/prof_qrencode.c, tests/pthread_qrencode.c, tests/test_mask.c, + tests/test_mmask.c, tests/test_monkey.c, tests/test_mqrspec.c, + tests/test_qrencode.c, tests/test_qrspec.c: + - Removed cache clearing calls. 2014.09.08 Kentaro FUKUCHI * qrenc.c: diff --git a/mqrspec.c b/mqrspec.c index 76d2d261a6..9bde5c7743 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -156,16 +156,6 @@ unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level) * Frame *****************************************************************************/ -/** - * Cache of initial frames. - */ -/* C99 says that static storage shall be initialized to a null pointer - * by compiler. */ -static unsigned char *frames[MQRSPEC_VERSION_MAX + 1]; -#ifdef HAVE_LIBPTHREAD -static pthread_mutex_t frames_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif - /** * Put a finder pattern. * @param frame @@ -239,42 +229,7 @@ static unsigned char *MQRspec_createFrame(int version) unsigned char *MQRspec_newFrame(int version) { - unsigned char *frame; - int width; - if(version < 1 || version > MQRSPEC_VERSION_MAX) return NULL; -#ifdef HAVE_LIBPTHREAD - pthread_mutex_lock(&frames_mutex); -#endif - if(frames[version] == NULL) { - frames[version] = MQRspec_createFrame(version); - } -#ifdef HAVE_LIBPTHREAD - pthread_mutex_unlock(&frames_mutex); -#endif - if(frames[version] == NULL) return NULL; - - width = mqrspecCapacity[version].width; - frame = (unsigned char *)malloc(width * width); - if(frame == NULL) return NULL; - memcpy(frame, frames[version], width * width); - - return frame; -} - -void MQRspec_clearCache(void) -{ - int i; - -#ifdef HAVE_LIBPTHREAD - pthread_mutex_lock(&frames_mutex); -#endif - for(i=1; i<=MQRSPEC_VERSION_MAX; i++) { - free(frames[i]); - frames[i] = NULL; - } -#ifdef HAVE_LIBPTHREAD - pthread_mutex_unlock(&frames_mutex); -#endif + return MQRspec_createFrame(version); } diff --git a/mqrspec.h b/mqrspec.h index 2d4b90d281..7ab838b319 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -137,11 +137,6 @@ extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level */ extern unsigned char *MQRspec_newFrame(int version); -/** - * Clear the frame cache. Typically for debug. - */ -extern void MQRspec_clearCache(void); - /****************************************************************************** * Mode indicator *****************************************************************************/ diff --git a/qrencode.c b/qrencode.c index f7b0d3f137..e61340d285 100644 --- a/qrencode.c +++ b/qrencode.c @@ -911,9 +911,3 @@ char *QRcode_APIVersionString(void) { return VERSION; } - -void QRcode_clearCache(void) -{ - QRspec_clearCache(); - MQRspec_clearCache(); -} diff --git a/qrencode.h b/qrencode.h index 02aa023aad..090082ca28 100644 --- a/qrencode.h +++ b/qrencode.h @@ -552,13 +552,6 @@ extern void QRcode_APIVersion(int *major_version, int *minor_version, int *micro */ extern char *QRcode_APIVersionString(void); -/** - * Clear all caches. This is only for debug purpose. If you are attacking a - * complicated memory leak bug, try this to reduce the reachable blocks record. - * @warning This function is THREAD UNSAFE when pthread is disabled. - */ -extern void QRcode_clearCache(void); - #if defined(__cplusplus) } #endif diff --git a/qrspec.c b/qrspec.c index 039a5be47c..b67452f48f 100644 --- a/qrspec.c +++ b/qrspec.c @@ -394,16 +394,6 @@ unsigned int QRspec_getFormatInfo(int mask, QRecLevel level) * Frame *****************************************************************************/ -/** - * Cache of initial frames. - */ -/* C99 says that static storage shall be initialized to a null pointer - * by compiler. */ -static unsigned char *frames[QRSPEC_VERSION_MAX + 1]; -#ifdef HAVE_LIBPTHREAD -static pthread_mutex_t frames_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif - /** * Put a finder pattern. * @param frame @@ -521,42 +511,7 @@ static unsigned char *QRspec_createFrame(int version) unsigned char *QRspec_newFrame(int version) { - unsigned char *frame; - int width; - if(version < 1 || version > QRSPEC_VERSION_MAX) return NULL; -#ifdef HAVE_LIBPTHREAD - pthread_mutex_lock(&frames_mutex); -#endif - if(frames[version] == NULL) { - frames[version] = QRspec_createFrame(version); - } -#ifdef HAVE_LIBPTHREAD - pthread_mutex_unlock(&frames_mutex); -#endif - if(frames[version] == NULL) return NULL; - - width = qrspecCapacity[version].width; - frame = (unsigned char *)malloc(width * width); - if(frame == NULL) return NULL; - memcpy(frame, frames[version], width * width); - - return frame; -} - -void QRspec_clearCache(void) -{ - int i; - -#ifdef HAVE_LIBPTHREAD - pthread_mutex_lock(&frames_mutex); -#endif - for(i=1; i<=QRSPEC_VERSION_MAX; i++) { - free(frames[i]); - frames[i] = NULL; - } -#ifdef HAVE_LIBPTHREAD - pthread_mutex_unlock(&frames_mutex); -#endif + return QRspec_createFrame(version); } diff --git a/qrspec.h b/qrspec.h index e15624c0bd..d504edcfe7 100644 --- a/qrspec.h +++ b/qrspec.h @@ -149,18 +149,11 @@ extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); /** * Return a copy of initialized frame. - * When the same version is requested twice or more, a copy of cached frame - * is returned. * @param version * @return Array of unsigned char. You can free it by free(). */ extern unsigned char *QRspec_newFrame(int version); -/** - * Clear the frame cache. Typically for debug. - */ -extern void QRspec_clearCache(void); - /****************************************************************************** * Mode indicator *****************************************************************************/ diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index 6c285e80b5..5bf3f40e28 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -68,7 +68,5 @@ int main(int argc, char **argv) prof_ver1to10(); prof_ver31to40(); - QRcode_clearCache(); - return 0; } diff --git a/tests/pthread_qrencode.c b/tests/pthread_qrencode.c index 77655583ea..eefde37e02 100644 --- a/tests/pthread_qrencode.c +++ b/tests/pthread_qrencode.c @@ -101,7 +101,5 @@ int main(int argc, char **argv) prof_ver1to10(); prof_ver31to40(); - QRcode_clearCache(); - return 0; } diff --git a/tests/test_mask.c b/tests/test_mask.c index c52add2e9b..e313127fd7 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -402,7 +402,5 @@ int main(int argc, char **argv) report(); - QRspec_clearCache(); - return 0; } diff --git a/tests/test_mmask.c b/tests/test_mmask.c index c81dd866e8..e8b6d88b47 100644 --- a/tests/test_mmask.c +++ b/tests/test_mmask.c @@ -146,7 +146,5 @@ int main(int argc, char **argv) report(); - MQRspec_clearCache(); - return 0; } diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 756ca8f6d2..3acd2dc4c2 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -562,7 +562,5 @@ int main(int argc, char **argv) monkey_encode_kanji(loop); monkey_split_structure(loop); - QRcode_clearCache(); - return 0; } diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index 56c5a89864..217611cd15 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -170,8 +170,6 @@ int main(int argc, char **argv) test_format(); test_dataLength(); - MQRspec_clearCache(); - report(); return 0; diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index cc92463183..34372ebf0f 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -994,8 +994,6 @@ int main(int argc, char **argv) test_mqrencode(); test_apiversion(); - QRcode_clearCache(); - report(); return 0; diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 53a60eaa84..cc39534178 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -320,8 +320,6 @@ int main(int argc, char **argv) //print_newFrame(); test_format(); - QRspec_clearCache(); - report(); return 0; -- cgit 0.0.5-2-1-g0f52 From b9a50bad00d00b8afc747a37281d7f5422da6198 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 10 Sep 2014 00:39:40 +0900 Subject: FrameFiller allocation has been moved from heap to stack. --- ChangeLog | 2 ++ qrencode.c | 60 +++++++++++++++--------------------------------------------- 2 files changed, 17 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46e0deb280..f57bd656bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ tests/test_mmask.c, tests/test_monkey.c, tests/test_mqrspec.c, tests/test_qrencode.c, tests/test_qrspec.c: - Removed cache clearing calls. + * qrencode.c: + - FrameFiller now allocated in stack, not heap. 2014.09.08 Kentaro FUKUCHI * qrenc.c: diff --git a/qrencode.c b/qrencode.c index e61340d285..02de8188e9 100644 --- a/qrencode.c +++ b/qrencode.c @@ -284,12 +284,8 @@ typedef struct { int mqr; } FrameFiller; -static FrameFiller *FrameFiller_new(int width, unsigned char *frame, int mqr) +static void FrameFiller_set(FrameFiller *filler, int width, unsigned char *frame, int mqr) { - FrameFiller *filler; - - filler = (FrameFiller *)malloc(sizeof(FrameFiller)); - if(filler == NULL) return NULL; filler->width = width; filler->frame = frame; filler->x = width - 1; @@ -297,8 +293,6 @@ static FrameFiller *FrameFiller_new(int width, unsigned char *frame, int mqr) filler->dir = -1; filler->bit = -1; filler->mqr = mqr; - - return filler; } static unsigned char *FrameFiller_next(FrameFiller *filler) @@ -363,30 +357,24 @@ extern unsigned char *FrameFiller_test(int version) { int width; unsigned char *frame, *p; - FrameFiller *filler; int i, length; + FrameFiller filler; width = QRspec_getWidth(version); frame = QRspec_newFrame(version); if(frame == NULL) return NULL; - filler = FrameFiller_new(width, frame, 0); - if(filler == NULL) { - free(frame); - return NULL; - } + FrameFiller_set(&filler, width, frame, 0); length = QRspec_getDataLength(version, QR_ECLEVEL_L) * 8 + QRspec_getECCLength(version, QR_ECLEVEL_L) * 8 + QRspec_getRemainder(version); for(i=0; imqr) { errno = EINVAL; @@ -480,19 +462,14 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) QRraw_free(raw); return NULL; } - filler = FrameFiller_new(width, frame, 0); - if(filler == NULL) { - QRraw_free(raw); - free(frame); - return NULL; - } + FrameFiller_set(&filler, width, frame, 0); /* inteleaved data and ecc codes */ for(i=0; idataLength + raw->eccLength; i++) { code = QRraw_getCode(raw); bit = 0x80; for(j=0; j<8; j++) { - p = FrameFiller_next(filler); + p = FrameFiller_next(&filler); if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; @@ -503,7 +480,7 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) /* remainder bits */ j = QRspec_getRemainder(version); for(i=0; imqr) { errno = EINVAL; @@ -564,12 +540,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) MQRraw_free(raw); return NULL; } - filler = FrameFiller_new(width, frame, 1); - if(filler == NULL) { - MQRraw_free(raw); - free(frame); - return NULL; - } + FrameFiller_set(&filler, width, frame, 1); /* inteleaved data and ecc codes */ for(i=0; idataLength + raw->eccLength; i++) { @@ -577,7 +548,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) if(raw->oddbits && i == raw->dataLength - 1) { bit = 1 << (raw->oddbits - 1); for(j=0; joddbits; j++) { - p = FrameFiller_next(filler); + p = FrameFiller_next(&filler); if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; @@ -585,7 +556,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) } else { bit = 0x80; for(j=0; j<8; j++) { - p = FrameFiller_next(filler); + p = FrameFiller_next(&filler); if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); bit = bit >> 1; @@ -609,7 +580,6 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) EXIT: MQRraw_free(raw); - free(filler); free(frame); return qrcode; } -- cgit 0.0.5-2-1-g0f52 From 4106aca62b85f049027c4b5d389fd6bf287060b1 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 10 Sep 2014 00:50:56 +0900 Subject: Avoid race condition. --- mask.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mask.c b/mask.c index 71b7cd78c4..8a7809ded4 100644 --- a/mask.c +++ b/mask.c @@ -321,17 +321,21 @@ __STATIC int Mask_evaluateSymbol(int width, unsigned char *frame) unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) { - static unsigned char mask[QRSPEC_WIDTH_MAX * QRSPEC_WIDTH_MAX]; int i; - unsigned char *bestMask; + unsigned char *mask, *bestMask; int minDemerit = INT_MAX; int blacks; int bratio; int demerit; int w2 = width * width; + mask = (unsigned char *)malloc(w2); + if(mask == NULL) return NULL; bestMask = (unsigned char *)malloc(w2); - if(bestMask == NULL) return NULL; + if(bestMask == NULL) { + free(mask); + return NULL; + } for(i=0; i Date: Wed, 10 Sep 2014 01:16:41 +0900 Subject: Introduced mutex to avoid race condition. --- ChangeLog | 3 ++- rsecc.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f57bd656bd..a6cf3f72ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,6 @@ * mask.[ch], tests/test_mask.c: - Run length calculation has been slightly improved. - Reduce malloc calls. - [noframecache] * qrspec.[ch], mqrspec.[ch]: - Frame caches have been eliminated. It improves both memory efficiency and performance... Wait, caches were completely meaningless? orz... @@ -16,6 +15,8 @@ - Removed cache clearing calls. * qrencode.c: - FrameFiller now allocated in stack, not heap. + * rsecc.c: + - Introduced mutex to avoid race condition. 2014.09.08 Kentaro FUKUCHI * qrenc.c: diff --git a/rsecc.c b/rsecc.c index bcf99e2f28..483910161e 100644 --- a/rsecc.c +++ b/rsecc.c @@ -27,9 +27,16 @@ #endif #include #include +#ifdef HAVE_LIBPTHREAD +#include +#endif #include "rsecc.h" +#ifdef HAVE_LIBPTHREAD +static pthread_mutex_t RSECC_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + static int initialized = 0; #define SYMBOL_SIZE (8) @@ -105,14 +112,26 @@ int RSECC_encode(int data_length, int ecc_length, const unsigned char *data, uns unsigned char feedback; unsigned char *gen; +#ifdef HAVE_LIBPTHREAD + pthread_mutex_lock(&RSECC_mutex); +#endif if(!initialized) { RSECC_init(); } +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&RSECC_mutex); +#endif if(ecc_length > max_length) return -1; memset(ecc, 0, ecc_length); +#ifdef HAVE_LIBPTHREAD + pthread_mutex_lock(&RSECC_mutex); +#endif if(!generatorInitialized[ecc_length - min_length]) generator_init(ecc_length); +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&RSECC_mutex); +#endif gen = generator[ecc_length - min_length]; for(i = 0; i < data_length; i++) { -- cgit 0.0.5-2-1-g0f52 From ff80df65ed1a13619609bfc367e497d4db62d81f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 10 Sep 2014 01:16:52 +0900 Subject: Removed unused includes. --- mqrspec.c | 3 --- qrspec.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/mqrspec.c b/mqrspec.c index 9bde5c7743..92831a40ad 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -32,9 +32,6 @@ #include #include #include -#ifdef HAVE_LIBPTHREAD -#include -#endif #include "mqrspec.h" diff --git a/qrspec.c b/qrspec.c index b67452f48f..29a5d8999a 100644 --- a/qrspec.c +++ b/qrspec.c @@ -32,9 +32,6 @@ #include #include #include -#ifdef HAVE_LIBPTHREAD -#include -#endif #include "qrspec.h" #include "qrinput.h" -- cgit 0.0.5-2-1-g0f52 From cd8b1d2089cf0856bc7ff58791de14173ac6559c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 17 Sep 2014 09:16:27 +0900 Subject: Explicit "-pthread" introduced. --- ChangeLog | 6 ++++++ configure.ac | 1 + tests/Makefile.am | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a6cf3f72ac..ebd0d8c842 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014.09.17 Kentaro FUKUCHI + * configure.ac: + - Added "-pthread" option to CFLAGS. + * tests/Makefile.am: + - Removed explicit "-lpthread" which is not required anymore. + 2014.09.09 Kentaro FUKUCHI * NEWS: - Added an entry about 4.0.0. (not released yet) diff --git a/configure.ac b/configure.ac index 1a0e67d3d2..03cbd2a1ef 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,7 @@ AM_CONDITIONAL([HAVE_LIBPTHREAD], [test "x$ac_cv_lib_pthread_pthread_mutex_init" # FIXME: isn't it able to integrate the followings to AC_CHECK_LIB? if test x$ac_cv_lib_pthread_pthread_mutex_init = xyes ; then AC_DEFINE([HAVE_LIBPTHREAD], [1], [Define to 1 if using pthread is enabled.]) + CFLAGS="$CFLAGS -pthread" fi diff --git a/tests/Makefile.am b/tests/Makefile.am index 252f2d8871..9af8f4dd27 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -67,7 +67,7 @@ prof_qrencode_SOURCES = prof_qrencode.c prof_qrencode_LDADD = ../libqrencode.la pthread_qrencode_SOURCES = pthread_qrencode.c -pthread_qrencode_LDADD = ../libqrencode.la $(LIBPTHREAD) +pthread_qrencode_LDADD = ../libqrencode.la if HAVE_PNG create_frame_pattern_SOURCES = create_frame_pattern.c -- cgit 0.0.5-2-1-g0f52 From f29b62ad7d4499f48451ccfe14ebdc22bd555246 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 17 Sep 2014 16:29:29 +0900 Subject: Acknowledgment updated. --- ChangeLog | 2 +- README | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ebd0d8c842..43bac22f87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ 2014.09.17 Kentaro FUKUCHI * configure.ac: - - Added "-pthread" option to CFLAGS. + - Added "-pthread" option to CFLAGS. (Thanks to Danomi Manchego) * tests/Makefile.am: - Removed explicit "-lpthread" which is not required anymore. diff --git a/README b/README index a1b48677cb..fc14d4d1c1 100644 --- a/README +++ b/README @@ -143,5 +143,5 @@ Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, -Sunil Maganally, Norman Gray +Sunil Maganally, Norman Gray, Danomi Manchego - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 7bfc9b68a4a205c686f539588f7e98307c6a7a7b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 18 Sep 2014 15:06:23 +0900 Subject: Acknowledgment updated. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b262b3a292..e87010eac8 100644 --- a/README.md +++ b/README.md @@ -140,4 +140,4 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - Viona - bug fix patch for string splitting - Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration - Greg Hart - PNG32 support patch -- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, Sunil Maganally, Norman Gray - bug report / suggestion +- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From c69aef483d201cdb1c5354d063c333a2fce22da9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 18 Sep 2014 15:27:09 +0900 Subject: Minor documentation fix. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6bf424a8eb..9deed09d8c 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,7 @@ Version 4.0.0 (2014.x.x) * PNG32 (direct color mode). (Thanks to Greg Hart) * EPS output now supports foreground and background color. * Various bug fixes. -* Various fixes for developers. +* Various improves for developers. Release Note: While no API changes are introduced with this major update, we incremented the -- cgit 0.0.5-2-1-g0f52 From 18343276730be5101d193fd292c957fb3223843d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 18 Sep 2014 16:00:33 +0900 Subject: Rollbacked the previous change (6a4b2e3710b) around the main part. --- ChangeLog | 4 ++++ tests/view_qrcode.c | 19 +++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 43bac22f87..95b08ca5a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014.09.18 Kentaro FUKUCHI + * tests/view_qrcode.c: + - Rollbacked the previous change (6a4b2e3710b) around the main part. + 2014.09.17 Kentaro FUKUCHI * configure.ac: - Added "-pthread" option to CFLAGS. (Thanks to Danomi Manchego) diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 43481d0928..62d070db14 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -539,16 +539,9 @@ int main(int argc, char **argv) } } - if(structured) { - if(version == 0) { - fprintf(stderr, "Version must be specified to encode structured symbols.\n"); - exit(EXIT_FAILURE); - } - if(argc - optind > 1) { - view_multiText(argv + optind, argc - optind); - } else { - view_simple(intext, length); - } + if(structured && version == 0) { + fprintf(stderr, "Version must be specified to encode structured symbols.\n"); + exit(EXIT_FAILURE); } if(SDL_Init(SDL_INIT_VIDEO) < 0) { @@ -556,6 +549,12 @@ int main(int argc, char **argv) return -1; } + if(structured && (argc - optind > 1)) { + view_multiText(argv + optind, argc - optind); + } else { + view_simple(intext, length); + } + SDL_Quit(); return 0; -- cgit 0.0.5-2-1-g0f52 From 4b4db0e3c0e8679f34f61223c9e54783060bf8ee Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 18 Sep 2014 16:59:25 +0900 Subject: Some code cleanups. --- ChangeLog | 2 ++ rsecc.c | 19 +++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95b08ca5a0..e6a42932cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2014.09.18 Kentaro FUKUCHI * tests/view_qrcode.c: - Rollbacked the previous change (6a4b2e3710b) around the main part. + * rsecc.c: + - Some code cleanups. 2014.09.17 Kentaro FUKUCHI * configure.ac: diff --git a/rsecc.c b/rsecc.c index 483910161e..d22987c2a2 100644 --- a/rsecc.c +++ b/rsecc.c @@ -81,22 +81,17 @@ void RSECC_init(void) static void generator_init(int length) { - int i, j, a; + int i, j; int g[max_generatorSize + 1]; g[0] = 1; - a = 0; - for(i = 1; i <= length; i++) { - g[i] = 1; - for(j = i - 1; j > 0; j--) { - if(g[0] != 0) { - g[j] = g[j - 1] ^ alpha[(aindex[g[j]] + a) % symbols]; - } else { - g[j] = g[j - 1]; - } + for(i = 0; i < length; i++) { + g[i + 1] = 1; + /* Because g[0] never be zero, skipped some conditional checks. */ + for(j = i; j > 0; j--) { + g[j] = g[j - 1] ^ alpha[(aindex[g[j]] + i) % symbols]; } - g[0] = alpha[(aindex[g[0]] + a) % symbols]; - a++; + g[0] = alpha[(aindex[g[0]] + i) % symbols]; } for(i = 0; i <= length; i++) { -- cgit 0.0.5-2-1-g0f52 From dd7305461717792bea5ddb92a67d5907eedffaae Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 18 Sep 2014 19:27:43 +0900 Subject: Syndrome checker has been added. --- tests/Makefile.am | 4 ++-- tests/rsecc_decoder.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/rsecc_decoder.h | 7 ++++++ tests/test_rs.c | 7 ++++++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 tests/rsecc_decoder.c create mode 100644 tests/rsecc_decoder.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 9af8f4dd27..1c21c829c5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,7 +25,7 @@ endif EXTRA_DIST = frame -libdecoder_a_SOURCES = decoder.c decoder.h +libdecoder_a_SOURCES = decoder.c decoder.h rsecc_decoder.c rsecc_decoder.h test_qrinput_SOURCES = test_qrinput.c test_qrinput_LDADD = ../libqrencode.la $(DECODER_LIBS) @@ -43,7 +43,7 @@ test_mqrspec_SOURCES = test_mqrspec.c test_mqrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) test_rs_SOURCES = test_rs.c rscode.c -test_rs_LDADD = ../libqrencode.la +test_rs_LDADD = ../libqrencode.la $(DECODER_LIBS) test_qrencode_SOURCES = test_qrencode.c test_qrencode_LDADD = ../libqrencode.la $(DECODER_LIBS) diff --git a/tests/rsecc_decoder.c b/tests/rsecc_decoder.c new file mode 100644 index 0000000000..55fa44cd7f --- /dev/null +++ b/tests/rsecc_decoder.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include "../qrspec.h" +#include "rsecc_decoder.h" + +#define SYMBOL_SIZE (8) +#define symbols ((1 << SYMBOL_SIZE) - 1) +static const int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see pp.37 of JIS X0510:2004) */ + +/* min/max codeword length of ECC, calculated from the specification. */ +#define min_length (2) +#define max_length (30) +#define max_generatorSize (max_length) + +static unsigned char alpha[symbols + 1]; +static unsigned char aindex[symbols + 1]; + +void RSECC_decoder_init() { + int i, b; + + alpha[symbols] = 0; + aindex[0] = symbols; + + b = 1; + for(i = 0; i < symbols; i++) { + alpha[i] = b; + aindex[b] = i; + b <<= 1; + if(b & (symbols + 1)) { + b ^= proot; + } + b &= symbols; + } +} + +int RSECC_decoder_checkSyndrome(int dl, unsigned char *data, int el, unsigned char *ecc) +{ + int i, j; + int s; + + for(i=0; i Date: Tue, 23 Sep 2014 14:46:14 +0900 Subject: Some typo fixes. --- ChangeLog | 6 ++++++ README | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e6a42932cf..363fa4397b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,14 @@ +2014.09.23 Kentaro FUKUCHI + * README: + - Some typo fixes. (Thanks to Danomi Manchego) + 2014.09.18 Kentaro FUKUCHI * tests/view_qrcode.c: - Rollbacked the previous change (6a4b2e3710b) around the main part. * rsecc.c: - Some code cleanups. + * tests/rsecc_decoder.[ch], tests/test_rs.c, Makefile.am: + - Syndrome checker has been added. 2014.09.17 Kentaro FUKUCHI * configure.ac: diff --git a/README b/README index fc14d4d1c1..b259f58f63 100644 --- a/README +++ b/README @@ -67,7 +67,7 @@ You can generate a manual of the library by using Doxygen. WARNINGS ======== -The library is distributed WITHOUT ANY WRRANTY. +The library is distributed WITHOUT ANY WARRANTY. Micro QR Code support is EXPERIMENTAL. @@ -123,7 +123,7 @@ countries. Reed-Solomon encoder is written by Phil Karn, KA9Q. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q -NANKI Haruo - improved lower-case characteres encoding +NANKI Haruo - improved lower-case characters encoding Philippe Delcroix - improved mask evaluation Yusuke Mihara - structured-append support David Dahl - DPI and SVG support patch -- cgit 0.0.5-2-1-g0f52 From ca465caa9f497beab26dd17dc45cd08c76634820 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 23 Sep 2014 14:49:00 +0900 Subject: Some typo fixes. --- ChangeLog | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 363fa4397b..48d4e9cae6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 2014.09.23 Kentaro FUKUCHI - * README: + * README, README.md: - Some typo fixes. (Thanks to Danomi Manchego) 2014.09.18 Kentaro FUKUCHI diff --git a/README.md b/README.md index e87010eac8..168b2a5ca3 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ You can generate a manual of the library by using Doxygen. WARNINGS ======== -The library is distributed WITHOUT ANY WRRANTY. +The library is distributed WITHOUT ANY WARRANTY. Micro QR Code support is EXPERIMENTAL. @@ -125,7 +125,7 @@ countries. Reed-Solomon encoder is written by Phil Karn, KA9Q. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q -- NANKI Haruo - improved lower-case characteres encoding +- NANKI Haruo - improved lower-case characters encoding - Philippe Delcroix - improved mask evaluation - Yusuke Mihara - structured-append support - David Dahl - DPI and SVG support patch -- cgit 0.0.5-2-1-g0f52 From eef79f664a549c7763a02f413b27d975cf6b810e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 5 Mar 2015 14:13:47 +0100 Subject: qrenc: Fix array overrun in color_set If len is 8 we read 4 members from the string and store them in the temporary array col (which is only 3 elements long). Fix it by increasing the size of col. --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index 78f1c1200d..796ab01b91 100644 --- a/qrenc.c +++ b/qrenc.c @@ -189,7 +189,7 @@ static int color_set(unsigned char color[4], const char *value) { int len = strlen(value); int i, count; - unsigned int col[3]; + unsigned int col[4]; if(len == 6) { count = sscanf(value, "%02x%02x%02x%n", &col[0], &col[1], &col[2], &len); if(count < 3 || len != 6) { -- cgit 0.0.5-2-1-g0f52 From 732abc627614986ee316d6ebdad18bc73a5b5df0 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 6 Mar 2015 12:27:41 +0100 Subject: qrencode: Implement X Pixmap (XPM) support closes #52 --- qrenc.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index 78f1c1200d..17b74ab220 100644 --- a/qrenc.c +++ b/qrenc.c @@ -54,6 +54,7 @@ enum imageType { PNG32_TYPE, EPS_TYPE, SVG_TYPE, + XPM_TYPE, ANSI_TYPE, ANSI256_TYPE, ASCII_TYPE, @@ -168,7 +169,7 @@ static void usage(int help, int longopt, int status) " -v NUMBER specify the version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" +" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" " specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" @@ -613,6 +614,86 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) return 0; } +static int writeXPM(const QRcode *qrcode, const char *outfile) +{ + FILE *fp; + int x, xx, y, yy, realwidth, realmargin; + char *row; + char fg[7], bg[7]; + unsigned char *p; + + fp = openFile(outfile); + + realwidth = (qrcode->width + margin * 2) * size; + realmargin = margin * size; + + row = malloc(realwidth + 1); + if (!row ) { + fprintf(stderr, "Failed to allocate memory.\n"); + exit(EXIT_FAILURE); + } + + snprintf(fg, 7, "%02x%02x%02x", fg_color[0], fg_color[1], fg_color[2]); + snprintf(bg, 7, "%02x%02x%02x", bg_color[0], bg_color[1], bg_color[2]); + + fputs("/* XPM */\n", fp); + fputs("static const char *const qrcode_xpm[] = {\n", fp); + fputs("/* width height ncolors chars_per_pixel */\n", fp); + fprintf(fp, "\"%d %d 2 1\",\n", realwidth, realwidth); + + fputs("/* colors */\n", fp); + fprintf(fp, "\"F c #%s\",\n", fg); + fprintf(fp, "\"B c #%s\",\n", bg); + + fputs("/* pixels */\n", fp); + memset(row, 'B', realwidth); + row[realwidth] = '\0'; + + for (y = 0; y < realmargin; y++) { + fprintf(fp, "\"%s\",\n", row); + } + + p = qrcode->data; + for (y = 0; y < qrcode->width; y++) { + for (yy = 0; yy < size; yy++) { + fputs("\"", fp); + + for (x = 0; x < margin; x++) { + for (xx = 0; xx < size; xx++) { + fputs("B", fp); + } + } + + for (x = 0; x < qrcode->width; x++) { + for (xx = 0; xx < size; xx++) { + if (p[(y * qrcode->width) + x] & 0x1) { + fputs("F", fp); + } else { + fputs("B", fp); + } + } + } + + for (x = 0; x < margin; x++) { + for (xx = 0; xx < size; xx++) { + fputs("B", fp); + } + } + + fputs("\",\n", fp); + } + } + + for (y = 0; y < realmargin; y++) { + fprintf(fp, "\"%s\"%s\n", row, y < (size - 1) ? "," : "};"); + } + + free(row); + fclose(fp); + + return 0; +} + static void writeANSI_margin(FILE* fp, int realwidth, char* buffer, const char* white, int white_s ) { @@ -919,6 +1000,9 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil case SVG_TYPE: writeSVG(qrcode, outfile); break; + case XPM_TYPE: + writeXPM(qrcode, outfile); + break; case ANSI_TYPE: case ANSI256_TYPE: writeANSI(qrcode, outfile); @@ -975,6 +1059,9 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case SVG_TYPE: type_suffix = ".svg"; break; + case XPM_TYPE: + type_suffix = ".xpm"; + break; case ANSI_TYPE: case ANSI256_TYPE: case ASCII_TYPE: @@ -1041,6 +1128,9 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case SVG_TYPE: writeSVG(p->code, filename); break; + case XPM_TYPE: + writeXPM(p->code, filename); + break; case ANSI_TYPE: case ANSI256_TYPE: writeANSI(p->code, filename); @@ -1154,6 +1244,8 @@ int main(int argc, char **argv) image_type = EPS_TYPE; } else if(strcasecmp(optarg, "svg") == 0) { image_type = SVG_TYPE; + } else if(strcasecmp(optarg, "xpm") == 0) { + image_type = XPM_TYPE; } else if(strcasecmp(optarg, "ansi") == 0) { image_type = ANSI_TYPE; } else if(strcasecmp(optarg, "ansi256") == 0) { -- cgit 0.0.5-2-1-g0f52 From 9e111aa6894609100dcfa014cd318af8de5100a5 Mon Sep 17 00:00:00 2001 From: siggi-heltau Date: Sat, 25 Apr 2015 01:52:17 +0200 Subject: Update split.c new is a reserved Keyword in C++ and should not be used as variable name. Therefore i propose the change from new to newstring. --- split.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/split.c b/split.c index e3bb6fc3f9..77867a1720 100644 --- a/split.c +++ b/split.c @@ -44,9 +44,9 @@ char *strdup(const char *s) { size_t len = strlen(s) + 1; - void *new = malloc(len); - if(new == NULL) return NULL; - return (char *)memcpy(new, s, len); + void *newstring = malloc(len); + if(newstring == NULL) return NULL; + return (char *)memcpy(newstring, s, len); } #endif -- cgit 0.0.5-2-1-g0f52 From d2f00d98bd47e4d1da10140efe472b046a6fdd42 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 00:11:20 +0900 Subject: Added changelogs and contributors name. --- ChangeLog | 10 ++++++++++ README | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 48d4e9cae6..b76d48dace 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2015.05.04 Kentaro Fukuchi + * qrenc.c: + - Merge pull request #63 from tklauser/qrenc-array-overflow-fix + - qrenc: Fix array overrun in color_set (Thanks to @tklauser and + @win32asm) + * split.c: + - Merge pull request #67 from siggi-heltau/patch-1 + - The variable name "new" has been renamed to "newstring" because "new" + is a reserved word in C++. (Thanks to @siggi-heltau) + 2014.09.23 Kentaro FUKUCHI * README, README.md: - Some typo fixes. (Thanks to Danomi Manchego) diff --git a/README b/README index b259f58f63..2c4af435b2 100644 --- a/README +++ b/README @@ -143,5 +143,5 @@ Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, -Sunil Maganally, Norman Gray, Danomi Manchego +Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, siggi-heltau - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From dd171885498b09c0e4d7e5b0d577faf48c7fbef6 Mon Sep 17 00:00:00 2001 From: Robert Petersen Date: Tue, 28 Apr 2015 15:47:46 -0700 Subject: Added -r option to read input data from a file in addition to STDIN and the command line. --- qrenc.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/qrenc.c b/qrenc.c index 796ab01b91..df6882e8d1 100644 --- a/qrenc.c +++ b/qrenc.c @@ -67,6 +67,7 @@ static enum imageType image_type = PNG_TYPE; static const struct option options[] = { {"help" , no_argument , NULL, 'h'}, {"output" , required_argument, NULL, 'o'}, + {"readin" , required_argument, NULL, 'r'}, {"level" , required_argument, NULL, 'l'}, {"size" , required_argument, NULL, 's'}, {"symversion" , required_argument, NULL, 'v'}, @@ -87,7 +88,7 @@ static const struct option options[] = { {NULL, 0, NULL, 0} }; -static char *optstring = "ho:l:s:v:m:d:t:Skci8MV"; +static char *optstring = "ho:r:l:s:v:m:d:t:Skci8MV"; static void usage(int help, int longopt, int status) { @@ -107,6 +108,8 @@ static void usage(int help, int longopt, int status) " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n" " (suffix is removed from FILENAME, if specified)\n\n" +" -r FILENAME, --readin=FILENAME\n" +" read nput data from FILENAME.\n" " -s NUMBER, --size=NUMBER\n" " specify module size in dots (pixels). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" @@ -162,6 +165,7 @@ static void usage(int help, int longopt, int status) " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n" " (suffix is removed from FILENAME, if specified)\n" +" -r FILENAME read nput data from FILENAME.\n" " -s NUMBER specify module size in dots (pixels). (default=3)\n" " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" @@ -214,7 +218,7 @@ static int color_set(unsigned char color[4], const char *value) } #define MAX_DATA_SIZE (7090 * 16) /* from the specification */ -static unsigned char *readStdin(int *length) +static unsigned char *readFile(FILE *fp, int *length) { unsigned char *buffer; int ret; @@ -224,12 +228,12 @@ static unsigned char *readStdin(int *length) fprintf(stderr, "Memory allocation failed.\n"); exit(EXIT_FAILURE); } - ret = fread(buffer, 1, MAX_DATA_SIZE, stdin); + ret = fread(buffer, 1, MAX_DATA_SIZE, fp); if(ret == 0) { fprintf(stderr, "No input data.\n"); exit(EXIT_FAILURE); } - if(feof(stdin) == 0) { + if(feof(fp) == 0) { fprintf(stderr, "Input data is too large.\n"); exit(EXIT_FAILURE); } @@ -1076,9 +1080,10 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch int main(int argc, char **argv) { int opt, lindex = -1; - char *outfile = NULL; + char *outfile = NULL, *infile = NULL; unsigned char *intext = NULL; int length = 0; + FILE *fp; while((opt = getopt_long(argc, argv, optstring, options, &lindex)) != -1) { switch(opt) { @@ -1093,6 +1098,9 @@ int main(int argc, char **argv) case 'o': outfile = optarg; break; + case 'r': + infile = optarg; + break; case 's': size = atoi(optarg); if(size <= 0) { @@ -1229,7 +1237,9 @@ int main(int argc, char **argv) length = strlen((char *)intext); } if(intext == NULL) { - intext = readStdin(&length); + fp = infile == NULL ? stdin : fopen(infile,"r"); + intext = readFile(fp,&length); + } if(micro && version > MQRSPEC_VERSION_MAX) { -- cgit 0.0.5-2-1-g0f52 From e206bf32646e8bb570e1ddca4f730539c877d113 Mon Sep 17 00:00:00 2001 From: Robert Petersen Date: Tue, 28 Apr 2015 15:50:46 -0700 Subject: Fixed type in help text --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index df6882e8d1..25a01a84f5 100644 --- a/qrenc.c +++ b/qrenc.c @@ -109,7 +109,7 @@ static void usage(int help, int longopt, int status) " symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n" " (suffix is removed from FILENAME, if specified)\n\n" " -r FILENAME, --readin=FILENAME\n" -" read nput data from FILENAME.\n" +" read input data from FILENAME.\n" " -s NUMBER, --size=NUMBER\n" " specify module size in dots (pixels). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" -- cgit 0.0.5-2-1-g0f52 From 809891413091e8e7766d4976c51c1b649a45437b Mon Sep 17 00:00:00 2001 From: Robert Petersen Date: Tue, 28 Apr 2015 15:57:36 -0700 Subject: check the file pointer to make sure the input file is readable --- qrenc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qrenc.c b/qrenc.c index 25a01a84f5..5f1d7fa7ba 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1238,6 +1238,10 @@ int main(int argc, char **argv) } if(intext == NULL) { fp = infile == NULL ? stdin : fopen(infile,"r"); + if(fp == 0) { + fprintf(stderr, "Can not read input file %s.\n", infile); + exit(EXIT_FAILURE); + } intext = readFile(fp,&length); } -- cgit 0.0.5-2-1-g0f52 From 3035b5ea81aedb8670bfc6013c025f6636e2e67c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 00:30:30 +0900 Subject: Fixed some typos. --- qrenc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qrenc.c b/qrenc.c index 5f1d7fa7ba..90f137d7c8 100644 --- a/qrenc.c +++ b/qrenc.c @@ -67,7 +67,7 @@ static enum imageType image_type = PNG_TYPE; static const struct option options[] = { {"help" , no_argument , NULL, 'h'}, {"output" , required_argument, NULL, 'o'}, - {"readin" , required_argument, NULL, 'r'}, + {"read-from" , required_argument, NULL, 'r'}, {"level" , required_argument, NULL, 'l'}, {"size" , required_argument, NULL, 's'}, {"symversion" , required_argument, NULL, 'v'}, @@ -108,8 +108,8 @@ static void usage(int help, int longopt, int status) " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n" " (suffix is removed from FILENAME, if specified)\n\n" -" -r FILENAME, --readin=FILENAME\n" -" read input data from FILENAME.\n" +" -r FILENAME, --read-from=FILENAME\n" +" read input data from FILENAME.\n\n" " -s NUMBER, --size=NUMBER\n" " specify module size in dots (pixels). (default=3)\n\n" " -l {LMQH}, --level={LMQH}\n" @@ -165,7 +165,7 @@ static void usage(int help, int longopt, int status) " will be output to standard output. If -S is given, structured\n" " symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n" " (suffix is removed from FILENAME, if specified)\n" -" -r FILENAME read nput data from FILENAME.\n" +" -r FILENAME read input data from FILENAME.\n" " -s NUMBER specify module size in dots (pixels). (default=3)\n" " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" -- cgit 0.0.5-2-1-g0f52 From 5eada2e2e67a5c95a75e7b6afe8609bec0224b9b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 00:30:46 +0900 Subject: Updated the usage. --- qrencode.1.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qrencode.1.in b/qrencode.1.in index 12d14368e8..68ac9c69e1 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -23,6 +23,9 @@ display help message. .B \-o FILENAME, \-\-output=FILENAME write image to FILENAME. If '\-' is specified, the result will be output to standard output. If \-S is given, structured symbols are written to FILENAME-01.png, FILENAME-02.png, ... (suffix is removed from FILENAME, if specified) .TP +.B \-r FILENAME, \-\-read\-from=FILENAME +read input data from FILENAME. +.TP .B \-s NUMBER, \-\-size=NUMBER specify the size of dot (pixel). (default=3) .TP @@ -97,8 +100,8 @@ encode into a symbol version 1, level L. read standard input and encode it into a structured-appended symbols in case-insensitive mode. .TP -.B cat bigfile.txt | qrencode \-S \-v 40 \-l L \-o output.png -encode into a symbol version 40, level L. +.B qrencode \-S \-v 40 \-l L \-r bigfile.txt \-o output.png +read input data from bigfile.txt and encode into a symbol version 40, level L. .SH AUTHOR Written by Kentaro Fukuchi. -- cgit 0.0.5-2-1-g0f52 From c49c4e58b8093bae5770845d2406b2331f5275aa Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 00:32:07 +0900 Subject: Updated the list of contributors. --- README | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README b/README index 2c4af435b2..4d8706aae4 100644 --- a/README +++ b/README @@ -139,9 +139,12 @@ Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration Greg Hart - PNG32 support patch +siggi-heltau - bug fix patch +Tobias Klauser - bug fix patch +Robert Petersen - added ability to read input data from a file Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, -Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, siggi-heltau +ralgozino, Sean McMurray, win32asm, Antenore, Yoshimichi Inoue, +Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From b01f3a643d238e73a2251c8eabeb9baaa3f74b47 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 00:32:17 +0900 Subject: Added recent changelogs. --- ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index b76d48dace..8ef00f1257 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,16 @@ - Merge pull request #67 from siggi-heltau/patch-1 - The variable name "new" has been renamed to "newstring" because "new" is a reserved word in C++. (Thanks to @siggi-heltau) + * qrenc.c: + - Added -r option to read input data from a file in addition to STDIN + and the command line. (cherry-picked from #68) + (Thanks to Robert Petersen) + - Typo fix. (cherry-picked from #68) (Thanks to Robert Petersen) + - long option "readin" has been changed to "read-from". + * qrencode.1.in: + - Updated the usage. + * README: + - Updated the list of contributors. 2014.09.23 Kentaro FUKUCHI * README, README.md: -- cgit 0.0.5-2-1-g0f52 From a7e4ba69bb1a3f5b4ca20283c9f470792f3706e7 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 00:59:58 +0900 Subject: Added URI_testset.inc to EXTRA_DIST. --- ChangeLog | 2 ++ tests/Makefile.am | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8ef00f1257..f90c2e235e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ - Updated the usage. * README: - Updated the list of contributors. + * tests/Makefile.am + - Added URI_testset.inc to EXTRA_DIST. 2014.09.23 Kentaro FUKUCHI * README, README.md: diff --git a/tests/Makefile.am b/tests/Makefile.am index 1c21c829c5..fce34a3252 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,7 +23,7 @@ if HAVE_LIBPTHREAD noinst_PROGRAMS += pthread_qrencode endif -EXTRA_DIST = frame +EXTRA_DIST = frame URI_testset.inc libdecoder_a_SOURCES = decoder.c decoder.h rsecc_decoder.c rsecc_decoder.h -- cgit 0.0.5-2-1-g0f52 From 9a8f21ec80d844b10dc6e1927939fc89b2b02a68 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 01:07:45 +0900 Subject: Added some patterns to ignore some generated files. (closes #64) --- .gitignore | 5 +++++ ChangeLog | 3 +++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index da409d12fa..8db4f08f47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +*.[oa] +*.lo +*.la *.gcno *.gcov *.gcda @@ -46,3 +49,5 @@ use/install-sh use/ltmain.sh use/missing html/ +massif.out.* +gmon.out diff --git a/ChangeLog b/ChangeLog index f90c2e235e..053414fa8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,9 @@ - Updated the list of contributors. * tests/Makefile.am - Added URI_testset.inc to EXTRA_DIST. + * .gitignore + - Added some patterns to ignore some generated files. (Thanks to + @tklauser, closes #64) 2014.09.23 Kentaro FUKUCHI * README, README.md: -- cgit 0.0.5-2-1-g0f52 From 7ee99e27265e8108c4969fc6c099bffb076ac410 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 01:43:32 +0900 Subject: Usage improved. (Thanks to @minus7) --- ChangeLog | 4 ++++ README | 22 ++++++++++++---------- qrenc.c | 8 ++++---- qrencode.1.in | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 053414fa8b..2d3289d13b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015.05.05 Kentaro Fukuchi + * qrencode.1.in: + - Usage improved. (Thanks to @minus7) + 2015.05.04 Kentaro Fukuchi * qrenc.c: - Merge pull request #63 from tklauser/qrenc-array-overflow-fix diff --git a/README b/README index 4d8706aae4..1c45247c3a 100644 --- a/README +++ b/README @@ -128,23 +128,25 @@ Philippe Delcroix - improved mask evaluation Yusuke Mihara - structured-append support David Dahl - DPI and SVG support patch Adam Shepherd - bug fix patch of the mask evaluation -Josef Eisl (zapster) - EPS support patch -Colin (moshen) - ANSI support patch +Josef Eisl (@zapster) - EPS support patch +Colin (@moshen) - ANSI support patch Ralf Ertzinger - ASCII support patch -Yutaka Niibe (gniibe) - various bug fix patches +Yutaka Niibe (@gniibe)- various bug fix patches Dan Storm (Repox) - SVG support patch -Lennart Poettering (mezcalero) +Lennart Poettering (@mezcalero) - improved text art patch Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration Greg Hart - PNG32 support patch -siggi-heltau - bug fix patch -Tobias Klauser - bug fix patch -Robert Petersen - added ability to read input data from a file +@siggi-heltau - bug fix patch +Tobias Klauser (@tklauser) + - bug fix patch +Robert Petersen (@ripetersen) + - added ability to read input data from a file Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, -Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, +Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino, Sean McMurray, win32asm, Antenore, Yoshimichi Inoue, -Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov +ralgozino, Sean McMurray, @win32asm, Antenore, Yoshimichi Inoue, +Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, @minus7 - bug report / suggestion diff --git a/qrenc.c b/qrenc.c index 90f137d7c8..f6a48c3d4c 100644 --- a/qrenc.c +++ b/qrenc.c @@ -116,8 +116,8 @@ static void usage(int help, int longopt, int status) " specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n\n" " -v NUMBER, --symversion=NUMBER\n" -" specify the version of the symbol. See SYMBOL VERSIONS for more\n" -" information. (default=auto)\n\n" +" specify the minimum version of the symbol. See SYMBOL VERSIONS\n" +" for more information. (default=auto)\n\n" " -m NUMBER, --margin=NUMBER\n" " specify the width of the margins. (default=4 (2 for Micro QR)))\n\n" " -d NUMBER, --dpi=NUMBER\n" @@ -145,7 +145,7 @@ static void usage(int help, int longopt, int status) " display verbose information to stderr.\n\n" " [STRING] input data. If it is not specified, data will be taken from\n" " standard input.\n\n" -"*SYMBOL VERSIONS\n" +"SYMBOL VERSIONS\n" " The symbol versions of QR Code range from Version 1 to Version\n" " 40. Each version has a different module configuration or number\n" " of modules, ranging from Version 1 (21 x 21 modules) up to\n" @@ -169,7 +169,7 @@ static void usage(int help, int longopt, int status) " -s NUMBER specify module size in dots (pixels). (default=3)\n" " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n" " (default=L)\n" -" -v NUMBER specify the version of the symbol. (default=auto)\n" +" -v NUMBER specify the minimum version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" " -t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" diff --git a/qrencode.1.in b/qrencode.1.in index 68ac9c69e1..50e3efc3b5 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -33,7 +33,7 @@ specify the size of dot (pixel). (default=3) specify error collectin level from L (lowest) to H (highest). (default=L) .TP .B \-v NUMBER, \-\-symversion=NUMBER -specify the version of the symbol. See SYMBOL VERSIONS for more information. (default=auto) +specify the minimum version of the symbol. See SYMBOL VERSIONS for more information. (default=auto) .TP .B \-m NUMBER, \-\-margin=NUMBER specify the width of margin. (default=4) -- cgit 0.0.5-2-1-g0f52 From d34499cbada75763c86bcfce507059d914e3fd88 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 01:46:38 +0900 Subject: Closes #62. --- ChangeLog | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d3289d13b..91fdbc9dd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ 2015.05.05 Kentaro Fukuchi - * qrencode.1.in: - - Usage improved. (Thanks to @minus7) + * qrencode.1.in, qrenc.c: + - Usage improved. (closes #62) (Thanks to @minus7) + * README: + - The list of contributors updated: '@' prefix added for github + usernames. 2015.05.04 Kentaro Fukuchi * qrenc.c: -- cgit 0.0.5-2-1-g0f52 From 6faa43bac1a06f6236839d36202898fcb2b996ab Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 02:16:48 +0900 Subject: Usage and documentation work. --- ChangeLog | 3 +++ NEWS | 5 +++-- README | 2 +- qrenc.c | 3 ++- qrencode.1.in | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 91fdbc9dd8..03a281bb3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ * README: - The list of contributors updated: '@' prefix added for github usernames. + * qrenc.c: + - X Pixmap (XPM) support has been added. (closes #52) + (Thanks to @tklauser) 2015.05.04 Kentaro Fukuchi * qrenc.c: diff --git a/NEWS b/NEWS index 9deed09d8c..592c61e185 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,13 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.0.0 (2014.x.x) +Version 4.0.0 (2015.x.x) ------------------------ * Memory efficiency has been improved. * Error correction code generating functions have been improved. * Command line tool "qrencode" has been improved: - * PNG32 (direct color mode). (Thanks to Greg Hart) + * XPM support. (Thanks to Tobias Klauser) + * PNG32 (direct color mode) support. (Thanks to Greg Hart) * EPS output now supports foreground and background color. * Various bug fixes. * Various improves for developers. diff --git a/README b/README index 1c45247c3a..2acc5634c5 100644 --- a/README +++ b/README @@ -141,7 +141,7 @@ Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration Greg Hart - PNG32 support patch @siggi-heltau - bug fix patch Tobias Klauser (@tklauser) - - bug fix patch + - bug fix patch, XPM support patch Robert Petersen (@ripetersen) - added ability to read input data from a file Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, diff --git a/qrenc.c b/qrenc.c index ecee54b378..fc4b24169e 100644 --- a/qrenc.c +++ b/qrenc.c @@ -123,7 +123,8 @@ static void usage(int help, int longopt, int status) " specify the width of the margins. (default=4 (2 for Micro QR)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={...}\n" +" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8},\n" +" --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" diff --git a/qrencode.1.in b/qrencode.1.in index 50e3efc3b5..98dd9e5fe0 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -42,10 +42,10 @@ specify the width of margin. (default=4) specify the DPI of the generated PNG. (default=72) .TP .PD 0 -.B \-t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.B \-t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} .TP .PD -.B \-\-type={PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.B \-\-type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} specify the type of the generated image. (default=PNG) .TP .B \-S, \-\-structured -- cgit 0.0.5-2-1-g0f52 From fe109bd888531834f3691eccba8f1c1ba838b3df Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 02:35:33 +0900 Subject: Typo fix. (Thanks to @Isweet) --- qrencode.1.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrencode.1.in b/qrencode.1.in index 98dd9e5fe0..9cbe2b6d97 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -30,7 +30,7 @@ read input data from FILENAME. specify the size of dot (pixel). (default=3) .TP .B \-l {LMQH}, \-\-level={LMQH} -specify error collectin level from L (lowest) to H (highest). (default=L) +specify error collection level from L (lowest) to H (highest). (default=L) .TP .B \-v NUMBER, \-\-symversion=NUMBER specify the minimum version of the symbol. See SYMBOL VERSIONS for more information. (default=auto) -- cgit 0.0.5-2-1-g0f52 From a7b4f604445c9025b30d8bbb0728e7735dcff13d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 02:36:12 +0900 Subject: Documentation work. --- ChangeLog | 3 ++- README | 10 ++++++---- README.md | 15 +++++++++------ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03a281bb3e..168bb78feb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ 2015.05.05 Kentaro Fukuchi * qrencode.1.in, qrenc.c: - Usage improved. (closes #62) (Thanks to @minus7) - * README: + - Typo fix. (Thanks to Ian Sweet (@Isweet)) + * README, README.md: - The list of contributors updated: '@' prefix added for github usernames. * qrenc.c: diff --git a/README b/README index 2acc5634c5..cb941e72d1 100644 --- a/README +++ b/README @@ -132,12 +132,13 @@ Josef Eisl (@zapster) - EPS support patch Colin (@moshen) - ANSI support patch Ralf Ertzinger - ASCII support patch Yutaka Niibe (@gniibe)- various bug fix patches -Dan Storm (Repox) - SVG support patch +Dan Storm (@Repox) - SVG support patch Lennart Poettering (@mezcalero) - improved text art patch Yann Droneaud - improved input validation patch Viona - bug fix patch for string splitting -Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration +Daniel Dörrhöfer (@d4ndo) + - RLE option, some bug fixes, Travis configuration Greg Hart - PNG32 support patch @siggi-heltau - bug fix patch Tobias Klauser (@tklauser) @@ -147,6 +148,7 @@ Robert Petersen (@ripetersen) Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -ralgozino, Sean McMurray, @win32asm, Antenore, Yoshimichi Inoue, -Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, @minus7 +@ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, +Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, @minus7, +Ian Sweet - bug report / suggestion diff --git a/README.md b/README.md index 168b2a5ca3..564ea00aeb 100644 --- a/README.md +++ b/README.md @@ -130,14 +130,17 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - Yusuke Mihara - structured-append support - David Dahl - DPI and SVG support patch - Adam Shepherd - bug fix patch of the mask evaluation -- Josef Eisl (zapster) - EPS support patch -- Colin (moshen) - ANSI support patch +- Josef Eisl (@zapster) - EPS support patch +- Colin (@moshen) - ANSI support patch - Ralf Ertzinger - ASCII support patch -- Yutaka Niibe (gniibe) - various bug fix patches -- Dan Storm (Repox) - SVG support patch -- Lennart Poettering (mezcalero) - improved text art patch +- Yutaka Niibe (@gniibe)- various bug fix patches +- Dan Storm (@Repox) - SVG support patch +- Lennart Poettering (@mezcalero) - improved text art patch - Yann Droneaud - improved input validation patch - Viona - bug fix patch for string splitting - Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration - Greg Hart - PNG32 support patch -- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, chisj, vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, ralgozino, Sean McMurray, win32asm, Tobias Klauser, Antenore, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego - bug report / suggestion +- @siggi-heltau - bug fix patch +- Tobias Klauser (@tklauser) - bug fix patch, XPM support patch +- Robert Petersen (@ripetersen) - added ability to read input data from a file +- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, @minus7, Ian Sweet - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From d75eee5a4f5c452fd7535fb4ba3ee09825a856b7 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 02:37:27 +0900 Subject: Typo fix (again). --- qrencode.1.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrencode.1.in b/qrencode.1.in index 9cbe2b6d97..d744d3d8cd 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -30,7 +30,7 @@ read input data from FILENAME. specify the size of dot (pixel). (default=3) .TP .B \-l {LMQH}, \-\-level={LMQH} -specify error collection level from L (lowest) to H (highest). (default=L) +specify error correction level from L (lowest) to H (highest). (default=L) .TP .B \-v NUMBER, \-\-symversion=NUMBER specify the minimum version of the symbol. See SYMBOL VERSIONS for more information. (default=auto) -- cgit 0.0.5-2-1-g0f52 From fb7c980581aff15bc964f880f44f8f500caf759c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 04:15:21 +0900 Subject: Some code cleanups. --- ChangeLog | 1 + bitstream.c | 12 ++++++------ mask.c | 24 ++++++++++++------------ mmask.c | 14 +++++++------- mqrspec.c | 10 +++++----- qrenc.c | 58 +++++++++++++++++++++++++++++----------------------------- qrencode.c | 22 +++++++++++----------- qrinput.c | 20 ++++++++++---------- qrspec.c | 32 ++++++++++++++++---------------- 9 files changed, 97 insertions(+), 96 deletions(-) diff --git a/ChangeLog b/ChangeLog index 168bb78feb..d819069a35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ * qrenc.c: - X Pixmap (XPM) support has been added. (closes #52) (Thanks to @tklauser) + * Some code cleanups. 2015.05.04 Kentaro Fukuchi * qrenc.c: diff --git a/bitstream.c b/bitstream.c index 866e775442..6c33612421 100644 --- a/bitstream.c +++ b/bitstream.c @@ -71,7 +71,7 @@ static void BitStream_writeNum(unsigned char *dest, int bits, unsigned int num) p = dest; mask = 1 << (bits - 1); - for(i=0; idata; - for(i=0; i> 1; } - for(i=0; i<7; i++) { + for(i = 0; i < 7; i++) { if(format & 1) { blacks += 2; v = 0x85; @@ -87,8 +87,8 @@ __STATIC int Mask_writeFormatInformation(int width, unsigned char *frame, int ma int x, y;\ int b = 0;\ \ - for(y=0; y= 5) { demerit += N1 + (runLength[i] - 5); //n1 += N1 + (runLength[i] - 5); @@ -226,8 +226,8 @@ __STATIC int Mask_calcN2(int width, unsigned char *frame) int demerit = 0; p = frame + width + 1; - for(y=1; y> 1; } - for(i=0; i<7; i++) { + for(i = 0; i < 7; i++) { v = 0x84 | (format & 1); frame[width * 8 + 7 - i] = v; format = format >> 1; @@ -54,8 +54,8 @@ __STATIC void MMask_writeFormatInformation(int version, int width, unsigned char #define MASKMAKER(__exp__) \ int x, y;\ \ - for(y=0; ydata; - for(y=0; ywidth; y++) { + for(y = 0; y < qrcode->width; y++) { memset(row, 0xff, (realwidth + 7) / 8); q = row; q += margin * size / 8; bit = 7 - (margin * size % 8); - for(x=0; xwidth; x++) { - for(xx=0; xxwidth; x++) { + for(xx = 0; xx < size; xx++) { *q ^= (*p & 1) << bit; bit--; if(bit < 0) { @@ -395,41 +395,41 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty } p++; } - for(yy=0; yydata; - for(y=0; ywidth; y++) { + for(y = 0; y < qrcode->width; y++) { fillRow(row, realwidth, bg_color); - for(x=0; xwidth; x++) { - for(xx=0; xxwidth; x++) { + for(xx = 0; xx < size; xx++) { if(*p & 1) { memcpy(&row[((margin + x) * size + xx) * 4], fg_color, 4); } } p++; } - for(yy=0; yydata; - for(y=0; ywidth; y++) { + for(y = 0; y < qrcode->width; y++) { row = (p+(y*qrcode->width)); yy = (margin + qrcode->width - y - 1); - for(x=0; xwidth; x++) { + for(x = 0; x < qrcode->width; x++) { if(*(row+x)&0x1) { fprintf(fp, "%d %d p ", margin + x, yy); } @@ -574,12 +574,12 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) /* Write data */ p = qrcode->data; - for(y=0; ywidth; y++) { + for(y = 0; y < qrcode->width; y++) { row = (p+(y*qrcode->width)); if( !rle ) { /* no RLE */ - for(x=0; xwidth; x++) { + for(x = 0; x < qrcode->width; x++) { if(*(row+x)&0x1) { writeSVG_writeRect(fp, margin + x, margin + y, 1, @@ -590,7 +590,7 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) /* simple RLE */ pen = 0; x0 = 0; - for(x=0; xwidth; x++) { + for(x = 0; x < qrcode->width; x++) { if( !pen ) { pen = *(row+x)&0x1; x0 = x; @@ -707,7 +707,7 @@ static void writeANSI_margin(FILE* fp, int realwidth, strncpy(buffer, white, white_s); memset(buffer + white_s, ' ', realwidth * 2); strcpy(buffer + white_s + realwidth * 2, "\033[0m\n"); // reset to default colors - for(y=0; ydata; - for(y=0; ywidth; y++) { + for(y = 0; y < qrcode->width; y++) { row = (p+(y*qrcode->width)); memset(buffer, 0, buffer_s); strncpy(buffer, white, white_s); - for(x=0; xwidth; x++) { + for(x = 0; x < qrcode->width; x++) { if(*(row+x)&0x1) { if( last != 1 ){ strncat(buffer, black, black_s); @@ -782,7 +782,7 @@ static int writeANSI(const QRcode *qrcode, const char *outfile) if( last != 0 ){ strncat(buffer, white, white_s); } - for(x=0; xwidth; y++) { + for(y = 0; y < qrcode->width; y++) { row = qrcode->data+(y*qrcode->width); p = buffer; memset(p, white, margin * 2); p += margin * 2; - for(x=0; xwidth; x++) { + for(x = 0; x < qrcode->width; x++) { if(row[x]&0x1) { *p++ = black; *p++ = black; diff --git a/qrencode.c b/qrencode.c index 02de8188e9..daa74b2a03 100644 --- a/qrencode.c +++ b/qrencode.c @@ -82,7 +82,7 @@ static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsig block = blocks; dp = data; ep = ecc; - for(i=0; idataLength + raw->eccLength; i++) { + for(i = 0; i < raw->dataLength + raw->eccLength; i++) { code = QRraw_getCode(raw); bit = 0x80; - for(j=0; j<8; j++) { + for(j = 0; j < 8; j++) { p = FrameFiller_next(&filler); if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); @@ -479,7 +479,7 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) raw = NULL; /* remainder bits */ j = QRspec_getRemainder(version); - for(i=0; idataLength + raw->eccLength; i++) { + for(i = 0; i < raw->dataLength + raw->eccLength; i++) { code = MQRraw_getCode(raw); if(raw->oddbits && i == raw->dataLength - 1) { bit = 1 << (raw->oddbits - 1); - for(j=0; joddbits; j++) { + for(j = 0; j < raw->oddbits; j++) { p = FrameFiller_next(&filler); if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); @@ -555,7 +555,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) } } else { bit = 0x80; - for(j=0; j<8; j++) { + for(j = 0; j < 8; j++) { p = FrameFiller_next(&filler); if(p == NULL) goto EXIT; *p = 0x02 | ((bit & code) != 0); @@ -749,7 +749,7 @@ static unsigned char QRcode_parity(const char *str, int size) unsigned char parity = 0; int i; - for(i=0; ihead; while(list != NULL) { if(list->mode != QR_MODE_STRUCTURE) { - for(i=list->size-1; i>=0; i--) { + for(i = list->size-1; i >= 0; i--) { parity ^= list->data[i]; } } @@ -365,7 +365,7 @@ static int QRinput_checkModeNum(int size, const char *data) { int i; - for(i=0; i '9') return -1; } @@ -429,7 +429,7 @@ static int QRinput_encodeModeNum(QRinput_List *entry, BitStream *bstream, int ve } words = entry->size / 3; - for(i=0; idata[i*3 ] - '0') * 100; val += (entry->data[i*3+1] - '0') * 10; val += (entry->data[i*3+2] - '0'); @@ -477,7 +477,7 @@ static int QRinput_checkModeAn(int size, const char *data) { int i; - for(i=0; isize / 2; - for(i=0; idata[i*2 ]) * 45; val += (unsigned int)QRinput_lookAnTable(entry->data[i*2+1]); @@ -632,7 +632,7 @@ static int QRinput_checkModeKanji(int size, const unsigned char *data) if(size & 1) return -1; - for(i=0; i 0x9ffc && val < 0xe040) || val > 0xebbf) { return -1; @@ -673,7 +673,7 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int if(ret < 0) return -1; } - for(i=0; isize; i+=2) { + for(i = 0; i < entry->size; i+=2) { val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1]; if(val <= 0x9ffc) { val -= 0x8140; @@ -760,7 +760,7 @@ static unsigned int QRinput_decodeECIfromByteArray(unsigned char *data) unsigned int ecinum; ecinum = 0; - for(i=0; i<4; i++) { + for(i = 0; i < 4; i++) { ecinum = ecinum << 8; ecinum |= data[3-i]; } @@ -1161,7 +1161,7 @@ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) padlen = maxwords - words; if(padlen > 0) { - for(i=0; i 0) { - for(i=0; i= size) return i; } @@ -298,8 +298,8 @@ static void QRspec_putAlignmentMarker(unsigned char *frame, int width, int ox, i frame += (oy - 2) * width + ox - 2; s = finder; - for(y=0; y<5; y++) { - for(x=0; x<5; x++) { + for(y = 0; y < 5; y++) { + for(x = 0; x < 5; x++) { frame[x] = s[x]; } frame += width; @@ -328,16 +328,16 @@ static void QRspec_putAlignmentPattern(int version, unsigned char *frame, int wi } cx = alignmentPattern[version][0]; - for(x=1; x> 1; } @@ -492,8 +492,8 @@ static unsigned char *QRspec_createFrame(int version) p = frame + width - 11; v = verinfo; - for(y=0; y<6; y++) { - for(x=0; x<3; x++) { + for(y = 0; y < 6; y++) { + for(x = 0; x < 3; x++) { p[x] = 0x88 | (v & 1); v = v >> 1; } -- cgit 0.0.5-2-1-g0f52 From c73a6bad5e649623880fa40147cb6a075f9884a5 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 16:29:07 +0900 Subject: Empty descriptions of some @params are filled. --- ChangeLog | 2 ++ mqrspec.h | 36 ++++++++++++++++++------------------ qrspec.h | 36 ++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index d819069a35..982ecb107c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ * qrenc.c: - X Pixmap (XPM) support has been added. (closes #52) (Thanks to @tklauser) + * qrspec.h, mqrspec.h: + - empty descriptions of some @params are filled. * Some code cleanups. 2015.05.04 Kentaro Fukuchi diff --git a/mqrspec.h b/mqrspec.h index 7ab838b319..caaf772c09 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -35,24 +35,24 @@ /** * Return maximum data code length (bits) for the version. - * @param version - * @param level + * @param version version of the symbol + * @param level error correction level * @return maximum size (bits) */ extern int MQRspec_getDataLengthBit(int version, QRecLevel level); /** * Return maximum data code length (bytes) for the version. - * @param version - * @param level + * @param version version of the symbol + * @param level error correction level * @return maximum size (bytes) */ extern int MQRspec_getDataLength(int version, QRecLevel level); /** * Return maximum error correction code length (bytes) for the version. - * @param version - * @param level + * @param version version of the symbol + * @param level error correction level * @return ECC size (bytes) */ extern int MQRspec_getECCLength(int version, QRecLevel level); @@ -60,21 +60,21 @@ extern int MQRspec_getECCLength(int version, QRecLevel level); /** * Return a version number that satisfies the input code length. * @param size input code length (byte) - * @param level + * @param level error correction level * @return version number */ extern int MQRspec_getMinimumVersion(int size, QRecLevel level); /** * Return the width of the symbol for the version. - * @param version + * @param version version of the symbol * @return width */ extern int MQRspec_getWidth(int version); /** * Return the numer of remainder bits. - * @param version + * @param version version of the symbol * @return number of remainder bits */ extern int MQRspec_getRemainder(int version); @@ -85,16 +85,16 @@ extern int MQRspec_getRemainder(int version); /** * Return the size of lenght indicator for the mode and version. - * @param mode - * @param version + * @param mode encode mode + * @param version vesion of the symbol * @return the size of the appropriate length indicator (bits). */ extern int MQRspec_lengthIndicator(QRencodeMode mode, int version); /** * Return the maximum length for the mode and version. - * @param mode - * @param version + * @param mode encode mode + * @param version vesion of the symbol * @return the maximum length (bytes) */ extern int MQRspec_maximumWords(QRencodeMode mode, int version); @@ -106,7 +106,7 @@ extern int MQRspec_maximumWords(QRencodeMode mode, int version); /** * Return BCH encoded version information pattern that is used for the symbol * of version 7 or greater. Use lower 18 bits. - * @param version + * @param version vesion of the symbol * @return BCH encoded version information pattern */ extern unsigned int MQRspec_getVersionPattern(int version); @@ -117,9 +117,9 @@ extern unsigned int MQRspec_getVersionPattern(int version); /** * Return BCH encoded format information pattern. - * @param mask - * @param version - * @param level + * @param mask mask number + * @param version version of the symbol + * @param level error correction level * @return BCH encoded format information pattern */ extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level); @@ -132,7 +132,7 @@ extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level * Return a copy of initialized frame. * When the same version is requested twice or more, a copy of cached frame * is returned. - * @param version + * @param version version of the symbol * @return Array of unsigned char. You can free it by free(). */ extern unsigned char *MQRspec_newFrame(int version); diff --git a/qrspec.h b/qrspec.h index d504edcfe7..601481b124 100644 --- a/qrspec.h +++ b/qrspec.h @@ -35,16 +35,16 @@ /** * Return maximum data code length (bytes) for the version. - * @param version - * @param level + * @param version version of the symbol + * @param level error correction level * @return maximum size (bytes) */ extern int QRspec_getDataLength(int version, QRecLevel level); /** * Return maximum error correction code length (bytes) for the version. - * @param version - * @param level + * @param version version of the symbol + * @param level error correction level * @return ECC size (bytes) */ extern int QRspec_getECCLength(int version, QRecLevel level); @@ -52,21 +52,21 @@ extern int QRspec_getECCLength(int version, QRecLevel level); /** * Return a version number that satisfies the input code length. * @param size input code length (byte) - * @param level + * @param level error correction level * @return version number */ extern int QRspec_getMinimumVersion(int size, QRecLevel level); /** * Return the width of the symbol for the version. - * @param version - * @return width + * @param version vesion of the symbol + * @return width of the symbol */ extern int QRspec_getWidth(int version); /** * Return the numer of remainder bits. - * @param version + * @param version vesion of the symbol * @return number of remainder bits */ extern int QRspec_getRemainder(int version); @@ -77,16 +77,16 @@ extern int QRspec_getRemainder(int version); /** * Return the size of lenght indicator for the mode and version. - * @param mode - * @param version + * @param mode encode mode + * @param version vesion of the symbol * @return the size of the appropriate length indicator (bits). */ extern int QRspec_lengthIndicator(QRencodeMode mode, int version); /** * Return the maximum length for the mode and version. - * @param mode - * @param version + * @param mode encode mode + * @param version vesion of the symbol * @return the maximum length (bytes) */ extern int QRspec_maximumWords(QRencodeMode mode, int version); @@ -97,8 +97,8 @@ extern int QRspec_maximumWords(QRencodeMode mode, int version); /** * Return an array of ECC specification. - * @param version - * @param level + * @param version version of the symbol + * @param level error correction level * @param spec an array of ECC specification contains as following: * {# of type1 blocks, # of data code, # of ecc code, * # of type2 blocks, # of data code} @@ -126,7 +126,7 @@ void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]); /** * Return BCH encoded version information pattern that is used for the symbol * of version 7 or greater. Use lower 18 bits. - * @param version + * @param version version of the symbol * @return BCH encoded version information pattern */ extern unsigned int QRspec_getVersionPattern(int version); @@ -137,8 +137,8 @@ extern unsigned int QRspec_getVersionPattern(int version); /** * Return BCH encoded format information pattern. - * @param mask - * @param level + * @param mask mask number + * @param level error correction level * @return BCH encoded format information pattern */ extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); @@ -149,7 +149,7 @@ extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); /** * Return a copy of initialized frame. - * @param version + * @param version version of the symbol * @return Array of unsigned char. You can free it by free(). */ extern unsigned char *QRspec_newFrame(int version); -- cgit 0.0.5-2-1-g0f52 From 9f7a28c5d83c6d0cb1aea193db287af32aa93cfd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 16:30:07 +0900 Subject: Empty descriptions of some @params are filled. --- ChangeLog | 2 +- qrencode.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 982ecb107c..d4ebbb0acf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,7 +8,7 @@ * qrenc.c: - X Pixmap (XPM) support has been added. (closes #52) (Thanks to @tklauser) - * qrspec.h, mqrspec.h: + * qrspec.h, mqrspec.h, qrencode.h: - empty descriptions of some @params are filled. * Some code cleanups. diff --git a/qrencode.h b/qrencode.h index 090082ca28..075187e292 100644 --- a/qrencode.h +++ b/qrencode.h @@ -472,7 +472,7 @@ extern void QRcode_free(QRcode *qrcode); /** * Create structured symbols from the input data. * @warning This function is THREAD UNSAFE when pthread is disabled. - * @param s + * @param s input data, structured. * @return a singly-linked list of QRcode. */ extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s); @@ -539,9 +539,9 @@ extern void QRcode_List_free(QRcode_List *qrlist); /** * Return a string that identifies the library version. - * @param major_version - * @param minor_version - * @param micro_version + * @param major_version major version number + * @param minor_version minor version number + * @param micro_version micro version number */ extern void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version); -- cgit 0.0.5-2-1-g0f52 From 4d5d2efa4b2570bb4125e258d8dead1952f290a3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 16:36:46 +0900 Subject: Suppress a warning message about enum loop. --- tests/test_mask.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mask.c b/tests/test_mask.c index e313127fd7..334548634a 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -296,7 +296,7 @@ void test_format(void) for(version=1; version<=QRSPEC_VERSION_MAX; version++) { frame = QRspec_newFrame(version); width = QRspec_getWidth(version); - for(level=0; level<4; level++) { + for(level=QR_ECLEVEL_L; level<=QR_ECLEVEL_H; level++) { for(mask=0; mask<8; mask++) { masked = Mask_makeMask(width, frame, mask, level); code = QRcode_new(version, width, masked); -- cgit 0.0.5-2-1-g0f52 From 31a73bc6ea5aa89a4c6e8cd8bda201000499d8b9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 16:43:21 +0900 Subject: Suppress a warning message of 'unused variable'. --- qrinput.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrinput.c b/qrinput.c index 0c3470e631..15431249dc 100644 --- a/qrinput.c +++ b/qrinput.c @@ -729,7 +729,7 @@ static int QRinput_encodeModeStructure(QRinput_List *entry, BitStream *bstream, * FNC1 *****************************************************************************/ -static int QRinput_checkModeFNC1Second(int size, const unsigned char *data) +static int QRinput_checkModeFNC1Second(int size) { if(size != 1) return -1; @@ -836,7 +836,7 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) case QR_MODE_FNC1FIRST: return 0; case QR_MODE_FNC1SECOND: - return QRinput_checkModeFNC1Second(size, data); + return QRinput_checkModeFNC1Second(size); case QR_MODE_NUL: break; } -- cgit 0.0.5-2-1-g0f52 From 6bb3fb1035075fd091a060aaa3f9dc83f7a93396 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 5 May 2015 17:05:55 +0900 Subject: Short note about the credit has been improved. --- ChangeLog | 2 ++ README | 3 ++- rsecc.c | 3 ++- rsecc.h | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4ebbb0acf..2c9382b998 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ (Thanks to @tklauser) * qrspec.h, mqrspec.h, qrencode.h: - empty descriptions of some @params are filled. + * rsecc.[ch], README: + - Short note about the credit has been improved. * Some code cleanups. 2015.05.04 Kentaro Fukuchi diff --git a/README b/README index cb941e72d1..43b8996baa 100644 --- a/README +++ b/README @@ -120,7 +120,8 @@ ACKNOWLEDGMENTS QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other countries. -Reed-Solomon encoder is written by Phil Karn, KA9Q. +Reed-Solomon encoder is rewritten by Kentaro Fukuchi, referring to the FEC +library developed by Phil Karn (KA9Q). Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q NANKI Haruo - improved lower-case characters encoding diff --git a/rsecc.c b/rsecc.c index d22987c2a2..292fb16a3b 100644 --- a/rsecc.c +++ b/rsecc.c @@ -2,7 +2,8 @@ * qrencode - QR Code encoder * * Reed solomon error correction code encoder specialized for QR code. - * This code is based on Phil Karn's libfec and rewriten by Kentaro Fukuchi. + * This code is rewritten by Kentaro Fukuchi, referring to the FEC library + * developed by Phil Karn (KA9Q). * * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Copyright (C) 2014 Kentaro Fukuchi diff --git a/rsecc.h b/rsecc.h index 5d2e400af6..41941e9eb2 100644 --- a/rsecc.h +++ b/rsecc.h @@ -2,7 +2,8 @@ * qrencode - QR Code encoder * * Reed solomon error correction code encoder specialized for QR code. - * This code is based on Phil Karn's libfec and rewriten by Kentaro Fukuchi. + * This code is rewritten by Kentaro Fukuchi, referring to the FEC library + * developed by Phil Karn (KA9Q). * * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Copyright (C) 2014 Kentaro Fukuchi -- cgit 0.0.5-2-1-g0f52 From b4205db51e5cd4699ddabdef6b312ed3acf88d78 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 May 2015 05:41:50 +0900 Subject: New option "--svg-path" has been added, that uses a single path instead of multiple rectangles to draw the modules. --- ChangeLog | 5 ++++ qrenc.c | 95 ++++++++++++++++++++++++++++++++++++++------------------------- 2 files changed, 62 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c9382b998..54db523c43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015.05.06 Kentaro Fukuchi + * qrenc.c: + - New option "--svg-path" has been added, that uses a single path + instead of multiple rectangles to draw the modules. + 2015.05.05 Kentaro Fukuchi * qrencode.1.in, qrenc.c: - Usage improved. (closes #62) (Thanks to @minus7) diff --git a/qrenc.c b/qrenc.c index 1b6697ef7a..3211872364 100644 --- a/qrenc.c +++ b/qrenc.c @@ -41,6 +41,7 @@ static int margin = -1; static int dpi = 72; static int structured = 0; static int rle = 0; +static int svg_path = 0; static int micro = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; @@ -81,6 +82,7 @@ static const struct option options[] = { {"ignorecase" , no_argument , NULL, 'i'}, {"8bit" , no_argument , NULL, '8'}, {"rle" , no_argument , &rle, 1}, + {"svg-path" , no_argument , &svg_path, 1}, {"micro" , no_argument , NULL, 'M'}, {"foreground" , required_argument, NULL, 'f'}, {"background" , required_argument, NULL, 'b'}, @@ -135,6 +137,8 @@ static void usage(int help, int longopt, int status) " ignore case distinctions and use only upper-case characters.\n\n" " -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" " --rle enable run-length encoding for SVG.\n\n" +" --svg-path\n" +" use single path to draw modules for SVG.\n\n" " -M, --micro encode in a Micro QR Code. (experimental)\n\n" " --foreground=RRGGBB[AA]\n" " --background=RRGGBB[AA]\n" @@ -452,7 +456,7 @@ static int writeEPS(const QRcode *qrcode, const char *outfile) int realwidth; fp = openFile(outfile); - + realwidth = (qrcode->width + margin * 2) * size; /* EPS file header */ fprintf(fp, "%%!PS-Adobe-2.0 EPSF-1.2\n" @@ -500,16 +504,20 @@ static int writeEPS(const QRcode *qrcode, const char *outfile) return 0; } -static void writeSVG_writeRect(FILE *fp, int x, int y, int width, const char* col, float opacity) +static void writeSVG_drawModules(FILE *fp, int x, int y, int width, const char* col, float opacity) { - if(fg_color[3] != 255) { - fprintf(fp, "\t\t\t\n", - x, y, width, col, opacity ); + if(svg_path) { + fprintf(fp, "M%d,%dh%d", x, y, width); } else { - fprintf(fp, "\t\t\t\n", - x, y, width, col ); + if(fg_color[3] != 255) { + fprintf(fp, "\t\t\t\n", + x, y, width, col, opacity ); + } else { + fprintf(fp, "\t\t\t\n", + x, y, width, col ); + } } } @@ -539,38 +547,46 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) /* XML declaration */ fputs( "\n", fp ); - /* DTD - No document type specified because "while a DTD is provided in [the SVG] - specification, the use of DTDs for validating XML documents is known to be - problematic. In particular, DTDs do not handle namespaces gracefully. It - is *not* recommended that a DOCTYPE declaration be included in SVG - documents." + /* DTD + No document type specified because "while a DTD is provided in [the SVG] + specification, the use of DTDs for validating XML documents is known to + be problematic. In particular, DTDs do not handle namespaces gracefully. + It is *not* recommended that a DOCTYPE declaration be included in SVG + documents." http://www.w3.org/TR/2003/REC-SVG11-20030114/intro.html#Namespace */ /* Vanity remark */ - fprintf( fp, "\n", - QRcode_APIVersionString() ); + fprintf(fp, "\n", QRcode_APIVersionString()); /* SVG code start */ - fprintf( fp, "\n", + " xmlns=\"http://www.w3.org/2000/svg\">\n", realwidth / scale, realwidth / scale, symwidth, symwidth ); /* Make named group */ - fputs( "\t\n", fp ); + fputs("\t\n", fp); /* Make solid background */ if(bg_color[3] != 255) { - fprintf(fp, "\t\t\n", symwidth, symwidth, bg, bg_opacity); + fprintf(fp, "\t\t\n", symwidth, symwidth, bg, bg_opacity); } else { - fprintf(fp, "\t\t\n", symwidth, symwidth, bg); + fprintf(fp, "\t\t\n", symwidth, symwidth, bg); } - /* Create new viewbox for QR data */ - fputs( "\t\t\n", fp); + if(svg_path) { + if(fg_color[3] != 255) { + fprintf(fp, "\t\t\n", margin, margin); + } /* Write data */ p = qrcode->data; @@ -581,9 +597,7 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) /* no RLE */ for(x = 0; x < qrcode->width; x++) { if(*(row+x)&0x1) { - writeSVG_writeRect(fp, margin + x, - margin + y, 1, - fg, fg_opacity); + writeSVG_drawModules(fp, x, y, 1, fg, fg_opacity); } } } else { @@ -596,25 +610,30 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) x0 = x; } else { if(!(*(row+x)&0x1)) { - writeSVG_writeRect(fp, x0 + margin, y + margin, x-x0, fg, fg_opacity); + writeSVG_drawModules(fp, x0, y, x-x0, fg, fg_opacity); pen = 0; } } } if( pen ) { - writeSVG_writeRect(fp, x0 + margin, y + margin, qrcode->width - x0, fg, fg_opacity); + writeSVG_drawModules(fp, x0, y, qrcode->width - x0, fg, fg_opacity); } } } - /* Close QR data viewbox */ - fputs( "\t\t\n", fp ); + + if(svg_path) { + fputs("\"/>\n", fp); + } else { + /* Close QR data viewbox */ + fputs("\t\t\n", fp); + } /* Close group */ - fputs( "\t\n", fp ); + fputs("\t\n", fp); /* Close SVG code */ - fputs( "\n", fp ); - fclose( fp ); + fputs("\n", fp); + fclose(fp); return 0; } @@ -1123,14 +1142,14 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch } switch(image_type) { - case PNG_TYPE: - case PNG32_TYPE: + case PNG_TYPE: + case PNG32_TYPE: writePNG(p->code, filename, image_type); break; - case EPS_TYPE: + case EPS_TYPE: writeEPS(p->code, filename); break; - case SVG_TYPE: + case SVG_TYPE: writeSVG(p->code, filename); break; case XPM_TYPE: -- cgit 0.0.5-2-1-g0f52 From ab04a3b101757c65ba0afa1cd8f630bd52b9329e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 May 2015 06:15:16 +0900 Subject: Added an unfinished test script for qrencode has been added. --- ChangeLog | 2 ++ tests/test_images/.gitignore | 2 ++ tests/test_qrenc.sh | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 tests/test_images/.gitignore create mode 100755 tests/test_qrenc.sh diff --git a/ChangeLog b/ChangeLog index 54db523c43..bfc6326392 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * qrenc.c: - New option "--svg-path" has been added, that uses a single path instead of multiple rectangles to draw the modules. + * tests/test_qrenc.sh, tests/test_images/.gitignore: + - Added an unfinished test script for qrencode has been added. 2015.05.05 Kentaro Fukuchi * qrencode.1.in, qrenc.c: diff --git a/tests/test_images/.gitignore b/tests/test_images/.gitignore new file mode 100644 index 0000000000..d6b7ef32c8 --- /dev/null +++ b/tests/test_images/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/test_qrenc.sh b/tests/test_qrenc.sh new file mode 100755 index 0000000000..ca056893f9 --- /dev/null +++ b/tests/test_qrenc.sh @@ -0,0 +1,10 @@ +#!/bin/sh -e + +COMMAND=../qrencode +TEXT="hello" +TARGET_DIR="test_images" + +$COMMAND -t SVG -o $TARGET_DIR/svg.svg $TEXT +$COMMAND -t SVG --rle -o $TARGET_DIR/svg-rle.svg $TEXT +$COMMAND -t SVG --svg-path -o $TARGET_DIR/svg-path.svg $TEXT +$COMMAND -t SVG --rle --svg-path -o $TARGET_DIR/svg-rle-path.svg $TEXT -- cgit 0.0.5-2-1-g0f52 From f29491835fd61413052fddbfaf78584eac2b6bed Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 May 2015 06:20:22 +0900 Subject: Acknowledgements updated. --- ChangeLog | 1 + README | 1 + README.md | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bfc6326392..821cde8235 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * qrenc.c: - New option "--svg-path" has been added, that uses a single path instead of multiple rectangles to draw the modules. + (cherry-picked from #41) (Thanks to @Oblomov) * tests/test_qrenc.sh, tests/test_images/.gitignore: - Added an unfinished test script for qrencode has been added. diff --git a/README b/README index 43b8996baa..cbecd1f22c 100644 --- a/README +++ b/README @@ -146,6 +146,7 @@ Tobias Klauser (@tklauser) - bug fix patch, XPM support patch Robert Petersen (@ripetersen) - added ability to read input data from a file +@Oblomov - improved SVG support patch Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, diff --git a/README.md b/README.md index 564ea00aeb..08f9887e95 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,8 @@ ACKNOWLEDGMENTS QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other countries. -Reed-Solomon encoder is written by Phil Karn, KA9Q. +Reed-Solomon encoder is rewritten by Kentaro Fukuchi, referring to the FEC +library developed by Phil Karn (KA9Q). Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - NANKI Haruo - improved lower-case characters encoding @@ -143,4 +144,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - @siggi-heltau - bug fix patch - Tobias Klauser (@tklauser) - bug fix patch, XPM support patch - Robert Petersen (@ripetersen) - added ability to read input data from a file +- @Oblomov - improved SVG support patch - Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, @minus7, Ian Sweet - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 7e5b88d8ed36f77996be9bf035b8f31b9fee6820 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 13 May 2015 05:32:18 +0900 Subject: Typo fix. --- ChangeLog | 4 ++++ mqrspec.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 821cde8235..01be797e7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015.05.13 Kentaro Fukuchi + * mqrspec.c: + - Typo fix. + 2015.05.06 Kentaro Fukuchi * qrenc.c: - New option "--svg-path" has been added, that uses a single path diff --git a/mqrspec.c b/mqrspec.c index 2a05da683c..415d44c20c 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Micor QR Code specification in convenient format. + * Micro QR Code specification in convenient format. * Copyright (C) 2006-2011 Kentaro Fukuchi * * The following data / specifications are taken from -- cgit 0.0.5-2-1-g0f52 From ee90d2e7f44f401bf7eecf1a5ba02d3b881dd44f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 13 May 2015 05:38:23 +0900 Subject: Text format improved. --- ChangeLog | 2 ++ README | 60 ++++++++++++++++++++++++++++++------------------------------ README.md | 50 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 62 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01be797e7d..e7910bbdb2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2015.05.13 Kentaro Fukuchi * mqrspec.c: - Typo fix. + * README, README.md: + - Text format improved. 2015.05.06 Kentaro Fukuchi * qrenc.c: diff --git a/README b/README index cbecd1f22c..6c5493a02c 100644 --- a/README +++ b/README @@ -124,33 +124,33 @@ Reed-Solomon encoder is rewritten by Kentaro Fukuchi, referring to the FEC library developed by Phil Karn (KA9Q). Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q -NANKI Haruo - improved lower-case characters encoding -Philippe Delcroix - improved mask evaluation -Yusuke Mihara - structured-append support -David Dahl - DPI and SVG support patch -Adam Shepherd - bug fix patch of the mask evaluation -Josef Eisl (@zapster) - EPS support patch -Colin (@moshen) - ANSI support patch -Ralf Ertzinger - ASCII support patch -Yutaka Niibe (@gniibe)- various bug fix patches -Dan Storm (@Repox) - SVG support patch -Lennart Poettering (@mezcalero) - - improved text art patch -Yann Droneaud - improved input validation patch -Viona - bug fix patch for string splitting -Daniel Dörrhöfer (@d4ndo) - - RLE option, some bug fixes, Travis configuration -Greg Hart - PNG32 support patch -@siggi-heltau - bug fix patch -Tobias Klauser (@tklauser) - - bug fix patch, XPM support patch -Robert Petersen (@ripetersen) - - added ability to read input data from a file -@Oblomov - improved SVG support patch -Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, -Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, -Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, -@ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, -Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, @minus7, -Ian Sweet - - bug report / suggestion +* NANKI Haruo - improved lower-case characters encoding +* Philippe Delcroix - improved mask evaluation +* Yusuke Mihara - structured-append support +* David Dahl - DPI and SVG support patch +* Adam Shepherd - bug fix patch of the mask evaluation +* Josef Eisl (@zapster) - EPS support patch +* Colin (@moshen) - ANSI support patch +* Ralf Ertzinger - ASCII support patch +* Yutaka Niibe (@gniibe)- various bug fix patches +* Dan Storm (@Repox) - SVG support patch +* Lennart Poettering (@mezcalero) + - improved text art patch +* Yann Droneaud - improved input validation patch +* Viona - bug fix patch for string splitting +* Daniel Dörrhöfer (@d4ndo) + - RLE option, some bug fixes, Travis configuration +* Greg Hart - PNG32 support patch +* @siggi-heltau - bug fix patch +* Tobias Klauser (@tklauser) + - bug fix patch, XPM support patch +* Robert Petersen (@ripetersen) + - added ability to read input data from a file +* @Oblomov - improved SVG support patch +* Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, + Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, + Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, + David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, + Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, + Vlad Bespalov, @minus7, Ian Sweet + - bug report / suggestion diff --git a/README.md b/README.md index 08f9887e95..8791fc4b29 100644 --- a/README.md +++ b/README.md @@ -126,23 +126,33 @@ Reed-Solomon encoder is rewritten by Kentaro Fukuchi, referring to the FEC library developed by Phil Karn (KA9Q). Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q -- NANKI Haruo - improved lower-case characters encoding -- Philippe Delcroix - improved mask evaluation -- Yusuke Mihara - structured-append support -- David Dahl - DPI and SVG support patch -- Adam Shepherd - bug fix patch of the mask evaluation -- Josef Eisl (@zapster) - EPS support patch -- Colin (@moshen) - ANSI support patch -- Ralf Ertzinger - ASCII support patch -- Yutaka Niibe (@gniibe)- various bug fix patches -- Dan Storm (@Repox) - SVG support patch -- Lennart Poettering (@mezcalero) - improved text art patch -- Yann Droneaud - improved input validation patch -- Viona - bug fix patch for string splitting -- Daniel Dörrhöfer - RLE option, some bug fixes, Travis configuration -- Greg Hart - PNG32 support patch -- @siggi-heltau - bug fix patch -- Tobias Klauser (@tklauser) - bug fix patch, XPM support patch -- Robert Petersen (@ripetersen) - added ability to read input data from a file -- @Oblomov - improved SVG support patch -- Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, Vlad Bespalov, @minus7, Ian Sweet - bug report / suggestion +* NANKI Haruo - improved lower-case characters encoding +* Philippe Delcroix - improved mask evaluation +* Yusuke Mihara - structured-append support +* David Dahl - DPI and SVG support patch +* Adam Shepherd - bug fix patch of the mask evaluation +* Josef Eisl (@zapster) - EPS support patch +* Colin (@moshen) - ANSI support patch +* Ralf Ertzinger - ASCII support patch +* Yutaka Niibe (@gniibe)- various bug fix patches +* Dan Storm (@Repox) - SVG support patch +* Lennart Poettering (@mezcalero) + - improved text art patch +* Yann Droneaud - improved input validation patch +* Viona - bug fix patch for string splitting +* Daniel Dörrhöfer (@d4ndo) + - RLE option, some bug fixes, Travis configuration +* Greg Hart - PNG32 support patch +* @siggi-heltau - bug fix patch +* Tobias Klauser (@tklauser) + - bug fix patch, XPM support patch +* Robert Petersen (@ripetersen) + - added ability to read input data from a file +* @Oblomov - improved SVG support patch +* Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, + Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, + Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, + David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, + Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, + Vlad Bespalov, @minus7, Ian Sweet + - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 1b565c7b599029818fc596e7da4371a3083da36c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 13 May 2015 05:53:05 +0900 Subject: Slightly updated. --- ChangeLog | 2 ++ NEWS | 1 + 2 files changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index e7910bbdb2..23b686ea8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ - Typo fix. * README, README.md: - Text format improved. + * NEWS: + - Slightly updated. 2015.05.06 Kentaro Fukuchi * qrenc.c: diff --git a/NEWS b/NEWS index 592c61e185..7ee46087d8 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Version 4.0.0 (2015.x.x) * XPM support. (Thanks to Tobias Klauser) * PNG32 (direct color mode) support. (Thanks to Greg Hart) * EPS output now supports foreground and background color. + * New options "-r" and "--svg-path" have been added. * Various bug fixes. * Various improves for developers. -- cgit 0.0.5-2-1-g0f52 From 08069c6e8ef392e9f71184fd44067822794788f4 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Mon, 17 Aug 2015 17:22:15 +0200 Subject: Remove trailing whitespaces. --- ChangeLog | 10 +++++----- NEWS | 2 +- mqrspec.c | 4 ++-- mqrspec.h | 2 +- qrenc.c | 8 ++++---- qrencode.h | 6 +++--- qrinput.c | 8 ++++---- qrspec.c | 4 ++-- qrspec.h | 4 ++-- split.h | 2 +- tests/decoder.c | 2 +- tests/rscode.c | 4 ++-- tests/test_mqrspec.c | 2 +- tests/test_qrinput.c | 2 +- tests/test_qrspec.c | 2 +- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23b686ea8e..44815ddb59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -253,7 +253,7 @@ 2013.07.29 Kentaro FUKUCHI [3.4] - * configure.ac, README, NEWS: + * configure.ac, README, NEWS: - Bumped version to 3.4.3. 2013.07.16 Kentaro FUKUCHI @@ -299,7 +299,7 @@ 2013.02.16 Kentaro FUKUCHI [3.4, master] - * configure.ac, README, NEWS: + * configure.ac, README, NEWS: - Bumped version to 3.4.2. 2013.02.16 Kentaro FUKUCHI @@ -340,7 +340,7 @@ - HAVE_LIBPTHREAD was not correctly defined in config.h.in. * tests/test_configure.sh: - New test script checking autoconf-related scripts has been added. - * configure.ac, README, NEWS: + * configure.ac, README, NEWS: - Bumped version to 3.4.1. 2012.10.15 Kentaro FUKUCHI @@ -359,7 +359,7 @@ 2012.10.09 Kentaro FUKUCHI [3.4] - * configure.ac, README, NEWS: + * configure.ac, README, NEWS: - Bumped version to 3.4.0. * qrencode.1.in: - Added SVG option to --type. @@ -916,7 +916,7 @@ - Number of malloc()s in RSblock_initBlock() has been integrated to one malloc() in QRraw_new(). * rscode.c: - - A very small code improvement. + - A very small code improvement. * qrinput.[ch]: - More return value checks. - Code cleanups. diff --git a/NEWS b/NEWS index 7ee46087d8..42b605b7fb 100644 --- a/NEWS +++ b/NEWS @@ -47,7 +47,7 @@ given. Version 3.4.2 (2013.3.1) ------------------------ -* Bug fix release. (Thanks to chisj, vlad417, Petr and Viona) +* Bug fix release. (Thanks to chisj, vlad417, Petr and Viona) Release Note: Micro QR Code encoder had a bug that caused incorrect output (issue #25). Now diff --git a/mqrspec.c b/mqrspec.c index 415d44c20c..fe7b5d5018 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -1,13 +1,13 @@ /* * qrencode - QR Code encoder * - * Micro QR Code specification in convenient format. + * Micro QR Code specification in convenient format. * Copyright (C) 2006-2011 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) * or - * "Automatic identification and data capture techniques -- + * "Automatic identification and data capture techniques -- * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) * * This library is free software; you can redistribute it and/or diff --git a/mqrspec.h b/mqrspec.h index caaf772c09..fa6d1e4043 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Micro QR Code specification in convenient format. + * Micro QR Code specification in convenient format. * Copyright (C) 2006-2011 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or diff --git a/qrenc.c b/qrenc.c index 3211872364..5d5ec3fc6d 100644 --- a/qrenc.c +++ b/qrenc.c @@ -484,13 +484,13 @@ static int writeEPS(const QRcode *qrcode, const char *outfile) (float)fg_color[1] / 255, (float)fg_color[2] / 255); fprintf(fp, "%d %d scale\n", size, size); - + /* data */ p = qrcode->data; for(y = 0; y < qrcode->width; y++) { row = (p+(y*qrcode->width)); yy = (margin + qrcode->width - y - 1); - + for(x = 0; x < qrcode->width; x++) { if(*(row+x)&0x1) { fprintf(fp, "%d %d p ", margin + x, yy); @@ -998,7 +998,7 @@ static QRcode *encode(const unsigned char *intext, int length) static void qrencode(const unsigned char *intext, int length, const char *outfile) { QRcode *qrcode; - + qrcode = encode(intext, length); if(qrcode == NULL) { if(errno == ERANGE) { @@ -1115,7 +1115,7 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch *q = '\0'; } } - + qrlist = encodeStructured(intext, length); if(qrlist == NULL) { if(errno == ERANGE) { diff --git a/qrencode.h b/qrencode.h index 075187e292..b121b3ba9f 100644 --- a/qrencode.h +++ b/qrencode.h @@ -23,8 +23,8 @@ * symbology. * * \section encoding Encoding - * - * There are two methods to encode data: encoding a string/data or + * + * There are two methods to encode data: encoding a string/data or * encoding a structured data. * * \subsection encoding-string Encoding a string/data @@ -68,7 +68,7 @@ * to generate structured-appended symbols. This functions returns an instance * of ::QRcode_List. The returned list is a singly-linked list of QRcode: you * can retrieve each QR code in this way: - * + * * \code * QRcode_List *qrcodes; * QRcode_List *entry; diff --git a/qrinput.c b/qrinput.c index 15431249dc..3a6afb261c 100644 --- a/qrinput.c +++ b/qrinput.c @@ -423,7 +423,7 @@ static int QRinput_encodeModeNum(QRinput_List *entry, BitStream *bstream, int ve } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_NUM); if(ret < 0) return -1; - + ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); if(ret < 0) return -1; } @@ -744,7 +744,7 @@ static int QRinput_encodeModeFNC1Second(QRinput_List *entry, BitStream *bstream) ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_FNC1SECOND); if(ret < 0) return -1; - + ret = BitStream_appendBytes(bstream, 1, entry->data); if(ret < 0) return -1; @@ -805,7 +805,7 @@ static int QRinput_encodeModeECI(QRinput_List *entry, BitStream *bstream) ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_ECI); if(ret < 0) return -1; - + ret = BitStream_appendNum(bstream, words * 8, code); if(ret < 0) return -1; @@ -1406,7 +1406,7 @@ int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input) void QRinput_Struct_free(QRinput_Struct *s) { QRinput_InputList *list, *next; - + if(s != NULL) { list = s->head; while(list != NULL) { diff --git a/qrspec.c b/qrspec.c index ad35d52528..a4d5ba4453 100644 --- a/qrspec.c +++ b/qrspec.c @@ -1,13 +1,13 @@ /* * qrencode - QR Code encoder * - * QR Code specification in convenient format. + * QR Code specification in convenient format. * Copyright (C) 2006-2013 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) * or - * "Automatic identification and data capture techniques -- + * "Automatic identification and data capture techniques -- * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) * * This library is free software; you can redistribute it and/or diff --git a/qrspec.h b/qrspec.h index 601481b124..3bd00ca0aa 100644 --- a/qrspec.h +++ b/qrspec.h @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * QR Code specification in convenient format. + * QR Code specification in convenient format. * Copyright (C) 2006-2013 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or @@ -170,5 +170,5 @@ extern unsigned char *QRspec_newFrame(int version); #define QRSPEC_MODEID_FNC1SECOND 9 #define QRSPEC_MODEID_STRUCTURE 3 #define QRSPEC_MODEID_TERMINATOR 0 - + #endif /* __QRSPEC_H__ */ diff --git a/split.h b/split.h index 2817ccfcad..829a34453b 100644 --- a/split.h +++ b/split.h @@ -7,7 +7,7 @@ * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) * or - * "Automatic identification and data capture techniques -- + * "Automatic identification and data capture techniques -- * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) * * This library is free software; you can redistribute it and/or diff --git a/tests/decoder.c b/tests/decoder.c index 4d7c109bb6..61d36ba352 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -47,7 +47,7 @@ static int decodeLength(int *bits_length, unsigned char **bits, QRencodeMode mod int i; int length = 0; int lbits; - + if(mqr) { lbits = MQRspec_lengthIndicator(mode, version); } else { diff --git a/tests/rscode.c b/tests/rscode.c index 7d14651448..2d4c47e15a 100644 --- a/tests/rscode.c +++ b/tests/rscode.c @@ -68,7 +68,7 @@ static inline int modnn(RS *rs, int x){ #define MM (rs->mm) #define NN (rs->nn) -#define ALPHA_TO (rs->alpha_to) +#define ALPHA_TO (rs->alpha_to) #define INDEX_OF (rs->index_of) #define GENPOLY (rs->genpoly) #define NROOTS (rs->nroots) @@ -224,7 +224,7 @@ void free_rs_char(RS *rs) * NROOTS - the number of roots in the RS code generator polynomial, * which is the same as the number of parity symbols in a block. Integer variable or literal. - * + * * NN - the total number of symbols in a RS block. Integer variable or literal. * PAD - the number of pad symbols in a block. Integer variable or literal. * ALPHA_TO - The address of an array of NN elements to convert Galois field diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index 217611cd15..e5d14a51eb 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -75,7 +75,7 @@ static unsigned int calcFormatInfo(int type, int mask) code = code >> 1; b = b >> 1; } - + return (data | ecc) ^ 0x4445; } diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index e8e404a750..b937c19365 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -712,7 +712,7 @@ void test_splitentry3(void) list = list->next; e10 = list->input->head; e11 = e10->next; - + assert_equal(e00->mode, QR_MODE_STRUCTURE, "Structure header is missing?"); assert_equal(e01->mode, QR_MODE_8, "no data?!"); assert_null(e01->next, "Input list is not terminated!\n"); diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index cc39534178..139b592cee 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -283,7 +283,7 @@ static unsigned int calcFormatInfo(int mask, QRecLevel level) code = code >> 1; b = b >> 1; } - + return (data | ecc) ^ 0x5412; } -- cgit 0.0.5-2-1-g0f52 From d6e262a7248d37e3d430c10196ffd644415ca91d Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Mon, 17 Aug 2015 17:24:23 +0200 Subject: Make functions static. --- qrinput.c | 2 +- rsecc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qrinput.c b/qrinput.c index 3a6afb261c..ccb0c5ff09 100644 --- a/qrinput.c +++ b/qrinput.c @@ -768,7 +768,7 @@ static unsigned int QRinput_decodeECIfromByteArray(unsigned char *data) return ecinum; } -int QRinput_estimateBitsModeECI(unsigned char *data) +static int QRinput_estimateBitsModeECI(unsigned char *data) { unsigned int ecinum; diff --git a/rsecc.c b/rsecc.c index 292fb16a3b..7beb499258 100644 --- a/rsecc.c +++ b/rsecc.c @@ -73,7 +73,7 @@ static void RSECC_initLookupTable(void) } } -void RSECC_init(void) +static void RSECC_init(void) { RSECC_initLookupTable(); memset(generatorInitialized, 0, (max_length - min_length + 1)); -- cgit 0.0.5-2-1-g0f52 From 3d06f9668313fd743a52af2ce61ba0d1cf1f1462 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Mon, 17 Aug 2015 17:32:41 +0200 Subject: Remove empty statements. --- qrinput.c | 4 ++-- tests/decoder.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qrinput.c b/qrinput.c index ccb0c5ff09..ab196cd100 100644 --- a/qrinput.c +++ b/qrinput.c @@ -772,7 +772,7 @@ static int QRinput_estimateBitsModeECI(unsigned char *data) { unsigned int ecinum; - ecinum = QRinput_decodeECIfromByteArray(data);; + ecinum = QRinput_decodeECIfromByteArray(data); /* See Table 4 of JISX 0510:2004 pp.17. */ if(ecinum < 128) { @@ -789,7 +789,7 @@ static int QRinput_encodeModeECI(QRinput_List *entry, BitStream *bstream) int ret, words; unsigned int ecinum, code; - ecinum = QRinput_decodeECIfromByteArray(entry->data);; + ecinum = QRinput_decodeECIfromByteArray(entry->data); /* See Table 4 of JISX 0510:2004 pp.17. */ if(ecinum < 128) { diff --git a/tests/decoder.c b/tests/decoder.c index 61d36ba352..6658af3cdb 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -265,7 +265,7 @@ static DataChunk *decodeChunk(int *bits_length, unsigned char **bits, int versio if(*bits_length < 4) { return NULL; } - val = bitToInt(*bits, 4);; + val = bitToInt(*bits, 4); *bits_length -= 4; *bits += 4; switch(val) { -- cgit 0.0.5-2-1-g0f52 From 0b556f750f9bed13899da08bea45596d9ecbb3d3 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Mon, 17 Aug 2015 17:36:08 +0200 Subject: Remove unnecessary forward declarations. --- split.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/split.c b/split.c index 77867a1720..d894aa5eef 100644 --- a/split.c +++ b/split.c @@ -75,10 +75,8 @@ static QRencodeMode Split_identifyMode(const char *string, QRencodeMode hint) return QR_MODE_8; } -static int Split_eatNum(const char *string, QRinput *input, QRencodeMode hint); static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint); static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint); -static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint); static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint) { -- cgit 0.0.5-2-1-g0f52 From 35756318b10f44db5404ee176bd4f98c7827243d Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Mon, 17 Aug 2015 18:14:21 +0200 Subject: Removed superfluous format flags. --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index 5d5ec3fc6d..116597406f 100644 --- a/qrenc.c +++ b/qrenc.c @@ -561,7 +561,7 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) /* SVG code start */ fprintf(fp, - "\n", realwidth / scale, realwidth / scale, symwidth, symwidth -- cgit 0.0.5-2-1-g0f52 From 0d6e1c4f3a647d5b9542d3a5af36c4d467dac0c4 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Wed, 7 Oct 2015 14:55:57 +0200 Subject: Support inverted UTF8 output Add support for UTF8i and ANSIUTF8i formats that provide reverse mappings of UTF8 and ANSIUTF8 formats respective. This is useful for black-on-white media. --- qrenc.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/qrenc.c b/qrenc.c index 3211872364..99ab615eb7 100644 --- a/qrenc.c +++ b/qrenc.c @@ -61,7 +61,9 @@ enum imageType { ASCII_TYPE, ASCIIi_TYPE, UTF8_TYPE, - ANSIUTF8_TYPE + ANSIUTF8_TYPE, + UTF8i_TYPE, + ANSIUTF8i_TYPE }; static enum imageType image_type = PNG_TYPE; @@ -818,25 +820,43 @@ static int writeANSI(const QRcode *qrcode, const char *outfile) } static void writeUTF8_margin(FILE* fp, int realwidth, const char* white, - const char *reset) + const char *reset, const char* full) { int x, y; for (y = 0; y < margin/2; y++) { fputs(white, fp); for (x = 0; x < realwidth; x++) - fputs("\342\226\210", fp); + fputs(full, fp); fputs(reset, fp); fputc('\n', fp); } } -static int writeUTF8(const QRcode *qrcode, const char *outfile, int use_ansi) +static int writeUTF8(const QRcode *qrcode, const char *outfile, int use_ansi, int invert) { FILE *fp; int x, y; int realwidth; const char *white, *reset; + const char *empty, *lowhalf, *uphalf, *full; + + empty = " "; + lowhalf = "\342\226\204"; + uphalf = "\342\226\200"; + full = "\342\226\210"; + + if (invert) { + const char *tmp; + + tmp = empty; + empty = full; + full = tmp; + + tmp = lowhalf; + lowhalf = uphalf; + uphalf = tmp; + } if (use_ansi){ white = "\033[40;37;1m"; @@ -851,7 +871,7 @@ static int writeUTF8(const QRcode *qrcode, const char *outfile, int use_ansi) realwidth = (qrcode->width + margin * 2); /* top margin */ - writeUTF8_margin(fp, realwidth, white, reset); + writeUTF8_margin(fp, realwidth, white, reset, full); /* data */ for(y = 0; y < qrcode->width; y += 2) { @@ -861,34 +881,35 @@ static int writeUTF8(const QRcode *qrcode, const char *outfile, int use_ansi) fputs(white, fp); - for (x = 0; x < margin; x++) - fputs("\342\226\210", fp); + for (x = 0; x < margin; x++) { + fputs(full, fp); + }; for (x = 0; x < qrcode->width; x++) { if(row1[x] & 1) { if(y < qrcode->width - 1 && row2[x] & 1) { - fputc(' ', fp); + fputs(empty, fp); } else { - fputs("\342\226\204", fp); + fputs(lowhalf, fp); } } else { if(y < qrcode->width - 1 && row2[x] & 1) { - fputs("\342\226\200", fp); + fputs(uphalf, fp); } else { - fputs("\342\226\210", fp); + fputs(full, fp); } } } for (x = 0; x < margin; x++) - fputs("\342\226\210", fp); + fputs(full, fp); fputs(reset, fp); fputc('\n', fp); } /* bottom margin */ - writeUTF8_margin(fp, realwidth, white, reset); + writeUTF8_margin(fp, realwidth, white, reset, full); fclose(fp); @@ -1038,10 +1059,16 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil writeASCII(qrcode, outfile, 0); break; case UTF8_TYPE: - writeUTF8(qrcode, outfile, 0); + writeUTF8(qrcode, outfile, 0, 0); break; case ANSIUTF8_TYPE: - writeUTF8(qrcode, outfile, 1); + writeUTF8(qrcode, outfile, 1, 0); + break; + case UTF8i_TYPE: + writeUTF8(qrcode, outfile, 0, 1); + break; + case ANSIUTF8i_TYPE: + writeUTF8(qrcode, outfile, 1, 1); break; default: fprintf(stderr, "Unknown image type.\n"); @@ -1091,6 +1118,8 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case ASCII_TYPE: case UTF8_TYPE: case ANSIUTF8_TYPE: + case UTF8i_TYPE: + case ANSIUTF8i_TYPE: type_suffix = ".txt"; break; default: @@ -1166,10 +1195,16 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch writeASCII(p->code, filename, 0); break; case UTF8_TYPE: - writeUTF8(p->code, filename, 0); + writeUTF8(p->code, filename, 0, 0); break; case ANSIUTF8_TYPE: - writeUTF8(p->code, filename, 0); + writeUTF8(p->code, filename, 0, 0); + break; + case UTF8i_TYPE: + writeUTF8(p->code, filename, 0, 1); + break; + case ANSIUTF8i_TYPE: + writeUTF8(p->code, filename, 0, 1); break; default: @@ -1286,6 +1321,10 @@ int main(int argc, char **argv) image_type = UTF8_TYPE; } else if(strcasecmp(optarg, "ansiutf8") == 0) { image_type = ANSIUTF8_TYPE; + } else if(strcasecmp(optarg, "utf8i") == 0) { + image_type = UTF8i_TYPE; + } else if(strcasecmp(optarg, "ansiutf8i") == 0) { + image_type = ANSIUTF8i_TYPE; } else { fprintf(stderr, "Invalid image type: %s\n", optarg); exit(EXIT_FAILURE); -- cgit 0.0.5-2-1-g0f52 From 5e8d2391ab8c914662fa85cf37a13e73ebe9c98b Mon Sep 17 00:00:00 2001 From: wood Date: Wed, 28 Oct 2015 14:49:16 +0800 Subject: spelling mistake The line of comment have a spelling mistake. --- qrspec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrspec.h b/qrspec.h index 601481b124..0c11e54558 100644 --- a/qrspec.h +++ b/qrspec.h @@ -76,7 +76,7 @@ extern int QRspec_getRemainder(int version); *****************************************************************************/ /** - * Return the size of lenght indicator for the mode and version. + * Return the size of length indicator for the mode and version. * @param mode encode mode * @param version vesion of the symbol * @return the size of the appropriate length indicator (bits). -- cgit 0.0.5-2-1-g0f52 From a880e3df13385631019dcb7a5289483a578446d8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 4 Nov 2015 01:05:41 +0900 Subject: Typo fix. --- mqrspec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mqrspec.h b/mqrspec.h index caaf772c09..2a20b84987 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -84,7 +84,7 @@ extern int MQRspec_getRemainder(int version); *****************************************************************************/ /** - * Return the size of lenght indicator for the mode and version. + * Return the size of length indicator for the mode and version. * @param mode encode mode * @param version vesion of the symbol * @return the size of the appropriate length indicator (bits). -- cgit 0.0.5-2-1-g0f52 From e2f75eab6cc008bf8ece21f35aac166f0fa12266 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 4 Nov 2015 01:05:50 +0900 Subject: Documentation updates. --- ChangeLog | 9 +++++++++ README | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 23b686ea8e..62c31f7850 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015.11.04 Kentaro Fukuchi + * qrspec.h, mqrspec.h: + - Typo fix. (Thanks to @qianchenglenger) + * qrenc.c: + - Merged pull-request #74. (Thanks to @mgorny) + - Added support for UTF8i and ANSIUTF8i formats that provide reverse + mappings of UTF8 and ANSIUTF8 formats respective. This is useful for + black-on-white media. + 2015.05.13 Kentaro Fukuchi * mqrspec.c: - Typo fix. diff --git a/README b/README index 6c5493a02c..3759c710df 100644 --- a/README +++ b/README @@ -147,10 +147,11 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Robert Petersen (@ripetersen) - added ability to read input data from a file * @Oblomov - improved SVG support patch +* @mgorny - reverse mappings of UTF8 and ANSIUTF8. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, - Vlad Bespalov, @minus7, Ian Sweet + Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From d028483745528c88326e071390fda6379d49ab0f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 4 Nov 2015 02:01:31 +0900 Subject: Added new configure option "--without-png". (closes #70) --- ChangeLog | 2 ++ Makefile.am | 2 -- configure.ac | 8 ++++++-- qrenc.c | 11 ++++++++++- rsecc.c | 12 ++++++------ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62c31f7850..10154c88e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ - Added support for UTF8i and ANSIUTF8i formats that provide reverse mappings of UTF8 and ANSIUTF8 formats respective. This is useful for black-on-white media. + * configure.ac, Makefile.am, qrenc.c, rsecc.c: + - Added new configure option "--without-png". (closes #70) 2015.05.13 Kentaro Fukuchi * mqrspec.c: diff --git a/Makefile.am b/Makefile.am index ae56671942..9c02b81220 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,11 +31,9 @@ EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \ qrencode.1.in Doxyfile tests/test_all.sh if BUILD_TOOLS -if HAVE_PNG bin_PROGRAMS = qrencode qrencode_SOURCES = qrenc.c qrencode_CFLAGS = $(png_CFLAGS) qrencode_LDADD = libqrencode.la $(png_LIBS) man1_MANS = qrencode.1 endif -endif diff --git a/configure.ac b/configure.ac index 03cbd2a1ef..36cfec09d9 100644 --- a/configure.ac +++ b/configure.ac @@ -53,15 +53,19 @@ if test x$ac_cv_lib_pthread_pthread_mutex_init = xyes ; then CFLAGS="$CFLAGS -pthread" fi +AC_ARG_WITH(png, + [AC_HELP_STRING([--without-png], + [disable PNG support])], + [with_png=$withval], [with_png=yes]) dnl --with-tools AC_ARG_WITH([tools], [AS_HELP_STRING([--with-tools], [build utility tools [default=yes]])], [build_tools=$withval], [build_tools=yes]) AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ]) -if test x$build_tools = xyes ; then +if test x$build_tools = xyes && test x$with_png = xyes ; then PKG_CHECK_MODULES(png, "libpng", [AC_DEFINE([HAVE_PNG], [1], [Define to 1 if using libpng is enabled.])], [AC_DEFINE([HAVE_PNG], [0])]) - if test x$png_CFLAGS = x ; then + if test x$png_CFLAGS = x && test x$with_png = xyes ; then echo " !!!!!!!!!! LIBPNG is required to build the utility tools. Temporarily disabled. diff --git a/qrenc.c b/qrenc.c index 99ab615eb7..5736b20e8e 100644 --- a/qrenc.c +++ b/qrenc.c @@ -25,9 +25,11 @@ #include #include #include -#include #include #include +#if HAVE_PNG +#include +#endif #include "qrencode.h" @@ -270,6 +272,7 @@ static FILE *openFile(const char *outfile) return fp; } +#if HAVE_PNG static void fillRow(unsigned char *row, int num, const unsigned char color[]) { int i; @@ -279,9 +282,11 @@ static void fillRow(unsigned char *row, int num, const unsigned char color[]) row += 4; } } +#endif static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType type) { +#if HAVE_PNG static FILE *fp; // avoid clobbering by setjmp. png_structp png_ptr; png_infop info_ptr; @@ -448,6 +453,10 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty free(palette); return 0; +#else + fputs("PNG output is disabled at compile time. No output generated.\n", stderr); + return 0; +#endif } static int writeEPS(const QRcode *qrcode, const char *outfile) diff --git a/rsecc.c b/rsecc.c index 292fb16a3b..2cdae5aca2 100644 --- a/rsecc.c +++ b/rsecc.c @@ -28,13 +28,13 @@ #endif #include #include -#ifdef HAVE_LIBPTHREAD +#if HAVE_LIBPTHREAD #include #endif #include "rsecc.h" -#ifdef HAVE_LIBPTHREAD +#if HAVE_LIBPTHREAD static pthread_mutex_t RSECC_mutex = PTHREAD_MUTEX_INITIALIZER; #endif @@ -108,24 +108,24 @@ int RSECC_encode(int data_length, int ecc_length, const unsigned char *data, uns unsigned char feedback; unsigned char *gen; -#ifdef HAVE_LIBPTHREAD +#if HAVE_LIBPTHREAD pthread_mutex_lock(&RSECC_mutex); #endif if(!initialized) { RSECC_init(); } -#ifdef HAVE_LIBPTHREAD +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&RSECC_mutex); #endif if(ecc_length > max_length) return -1; memset(ecc, 0, ecc_length); -#ifdef HAVE_LIBPTHREAD +#if HAVE_LIBPTHREAD pthread_mutex_lock(&RSECC_mutex); #endif if(!generatorInitialized[ecc_length - min_length]) generator_init(ecc_length); -#ifdef HAVE_LIBPTHREAD +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&RSECC_mutex); #endif gen = generator[ecc_length - min_length]; -- cgit 0.0.5-2-1-g0f52 From 7c5baf081979f09f6b1fbe2778dd104ba51e9027 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 21 Feb 2016 02:05:15 +0900 Subject: Migrated from SDL 1.2 to 2.0. --- configure.ac | 4 +-- tests/common.h | 30 +++++++++++++---- tests/view_qrcode.c | 93 ++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 99 insertions(+), 28 deletions(-) diff --git a/configure.ac b/configure.ac index 36cfec09d9..b8d3f0e44e 100644 --- a/configure.ac +++ b/configure.ac @@ -94,8 +94,8 @@ echo "/* #undef WITH_TESTS */" >>confdefs.h fi if test x$build_tests = xyes ; then - SDL_REQUIRED_VERSION=1.2.0 - PKG_CHECK_MODULES(SDL, [sdl >= $SDL_REQUIRED_VERSION], [AC_DEFINE([HAVE_SDL], [1], [Define to 1 if using SDL is enabled.])], [AC_DEFINE([HAVE_SDL], [0])]) + SDL_REQUIRED_VERSION=2.0.0 + PKG_CHECK_MODULES(SDL, [sdl2 >= $SDL_REQUIRED_VERSION], [AC_DEFINE([HAVE_SDL], [1], [Define to 1 if using SDL is enabled.])], [AC_DEFINE([HAVE_SDL], [0])]) AM_ICONV_LINK fi AM_CONDITIONAL(HAVE_SDL, [test "x$SDL_CFLAGS" != "x" ]) diff --git a/tests/common.h b/tests/common.h index 322a45b319..3f53247402 100644 --- a/tests/common.h +++ b/tests/common.h @@ -205,13 +205,17 @@ void printBstream(BitStream *bstream) /* You can call show_QRcode(QRcode *code) to display the QR Code from anywhere * in test code using SDL. */ #include -static SDL_Surface *screen = NULL; -static void draw_QRcode(QRcode *qrcode, int ox, int oy, int margin, int size) +static void draw_QRcode(QRcode *qrcode, int ox, int oy, int margin, int size, SDL_Surface *surface) { int x, y, width; unsigned char *p; SDL_Rect rect; + Uint32 color[2]; + + color[0] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + color[1] = SDL_MapRGBA(surface->format, 0, 0, 0, 255); + SDL_FillRect(surface, NULL, color[0]); ox += margin * size; oy += margin * size; @@ -223,7 +227,7 @@ static void draw_QRcode(QRcode *qrcode, int ox, int oy, int margin, int size) rect.y = oy + y * size; rect.w = size; rect.h = size; - SDL_FillRect(screen, &rect, (*p&1)?0:0xffffff); + SDL_FillRect(surface, &rect, color[*p&1]); p++; } } @@ -232,18 +236,26 @@ static void draw_QRcode(QRcode *qrcode, int ox, int oy, int margin, int size) void show_QRcode(QRcode *qrcode) { SDL_Event event; + SDL_Window *window; + SDL_Renderer *renderer; + SDL_Surface *surface; + SDL_Texture *texture; if(!SDL_WasInit(SDL_INIT_VIDEO)) { SDL_Init(SDL_INIT_VIDEO); atexit(SDL_Quit); } int width = (qrcode->width + 4 * 2) * 4; //maring = 4, size = 4 - screen = SDL_SetVideoMode(width, width, 32, 0); - SDL_FillRect(screen, NULL, 0xffffff); + SDL_CreateWindowAndRenderer(width, width, SDL_WINDOW_SHOWN, &window, &renderer); + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_RenderClear(renderer); + surface = SDL_CreateRGBSurface(0, width, width, 32, 0, 0, 0, 0); - draw_QRcode(qrcode, 0, 0, 4, 4); + draw_QRcode(qrcode, 0, 0, 4, 4, surface); - SDL_Flip(screen); + texture = SDL_CreateTextureFromSurface(renderer, surface); + SDL_RenderCopy(renderer, texture, NULL, NULL); + SDL_RenderPresent(renderer); fprintf(stderr, "Press any key on the QR Code window to proceed.\n"); int loop = 1; @@ -253,6 +265,10 @@ void show_QRcode(QRcode *qrcode) loop = 0; } } + + SDL_FreeSurface(surface); + SDL_DestroyTexture(texture); + SDL_DestroyRenderer(renderer); } #else void show_QRcode() { diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index 62d070db14..aba9574ea1 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -10,7 +10,10 @@ #include "../split.h" #include "../qrencode_inner.h" -static SDL_Surface *screen = NULL; +static SDL_Window *window; +static SDL_Renderer *renderer; +static SDL_Texture *texture = NULL; +static SDL_Surface *surface = NULL; static int casesensitive = 1; static int eightbit = 0; static int version = 0; @@ -145,6 +148,7 @@ static void draw_QRcode(QRcode *qrcode, int ox, int oy) int x, y, width; unsigned char *p; SDL_Rect rect; + Uint32 color; ox += margin * size; oy += margin * size; @@ -156,7 +160,15 @@ static void draw_QRcode(QRcode *qrcode, int ox, int oy) rect.y = oy + y * size; rect.w = size; rect.h = size; - SDL_FillRect(screen, &rect, (*p&1)?0:0xffffff); + if(*p & 1) { + //SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + color = SDL_MapRGBA(surface->format, 0, 0, 0, 255); + } else { + //SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + color = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + } + //SDL_RenderFillRect(renderer, &rect); + SDL_FillRect(surface, &rect, color); p++; } } @@ -181,12 +193,19 @@ void draw_singleQRcode(QRinput *stream, int mask) width = (qrcode->width + margin * 2) * size; } - screen = SDL_SetVideoMode(width, width, 32, 0); - SDL_FillRect(screen, NULL, 0xffffff); + SDL_SetWindowSize(window, width, width); + if(surface != NULL) { + SDL_FreeSurface(surface); + } + surface = SDL_CreateRGBSurface(0, width, width, 32, 0, 0, 0, 0); + SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, 255, 255, 255, 255)); if(qrcode) { draw_QRcode(qrcode, 0, 0); } - SDL_Flip(screen); + if(texture != NULL) { + SDL_DestroyTexture(texture); + } + texture = SDL_CreateTextureFromSurface(renderer, surface); QRcode_free(qrcode); } @@ -204,8 +223,12 @@ void draw_structuredQRcode(QRinput_Struct *s) w = (n < 4)?n:4; h = (n - 1) / 4 + 1; - screen = SDL_SetVideoMode(swidth * w, swidth * h, 32, 0); - SDL_FillRect(screen, NULL, 0xffffff); + SDL_SetWindowSize(window, swidth * w, swidth * h); + if(surface != NULL) { + SDL_FreeSurface(surface); + } + surface = SDL_CreateRGBSurface(0, swidth * w, swidth * h, 32, 0, 0, 0, 0); + SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, 255, 255, 255, 255)); p = qrcodes; for(i=0; icode, x, y); p = p->next; } - SDL_Flip(screen); + if(texture != NULL) { + SDL_DestroyTexture(texture); + } + texture = SDL_CreateTextureFromSurface(renderer, surface); QRcode_List_free(qrcodes); } @@ -280,26 +306,34 @@ void view(int mode, QRinput *input) int mask = -1; SDL_Event event; int loop; + int codeChanged = 1; while(flag) { - if(mode) { - draw_structuredQRcodeFromText(textc, textv); - } else { - if(structured) { - draw_structuredQRcodeFromQRinput(input); + if(codeChanged) { + if(mode) { + draw_structuredQRcodeFromText(textc, textv); } else { - draw_singleQRcode(input, mask); + if(structured) { + draw_structuredQRcodeFromQRinput(input); + } else { + draw_singleQRcode(input, mask); + } + } + if(mode || structured) { + printf("Version %d, Level %c.\n", version, levelChar[level]); + } else { + printf("Version %d, Level %c, Mask %d.\n", version, levelChar[level], mask); } } - if(mode || structured) { - printf("Version %d, Level %c.\n", version, levelChar[level]); - } else { - printf("Version %d, Level %c, Mask %d.\n", version, levelChar[level], mask); - } + SDL_RenderClear(renderer); + SDL_RenderCopy(renderer, texture, NULL, NULL); + SDL_RenderPresent(renderer); loop = 1; + codeChanged = 0; while(loop) { SDL_WaitEvent(&event); if(event.type == SDL_KEYDOWN) { + codeChanged = 1; switch(event.key.keysym.sym) { case SDLK_RIGHT: version++; @@ -369,6 +403,18 @@ void view(int mode, QRinput *input) flag = 0; } } + if (event.type == SDL_WINDOWEVENT) { + switch (event.window.event) { + case SDL_WINDOWEVENT_SHOWN: + case SDL_WINDOWEVENT_EXPOSED: + case SDL_WINDOWEVENT_SIZE_CHANGED: + case SDL_WINDOWEVENT_RESIZED: + loop = 0; + break; + default: + break; + } + } } } } @@ -415,6 +461,7 @@ int main(int argc, char **argv) int opt, lindex = -1; unsigned char *intext = NULL; int length = 0; + int ret; while((opt = getopt_long(argc, argv, optstring, options, &lindex)) != -1) { switch(opt) { @@ -549,6 +596,14 @@ int main(int argc, char **argv) return -1; } + ret = SDL_CreateWindowAndRenderer(100, 100, SDL_WINDOW_SHOWN, &window, &renderer); + if(ret < 0) { + fprintf(stderr, "Failed to create a window: %s\n", SDL_GetError()); + return -1; + } + + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + if(structured && (argc - optind > 1)) { view_multiText(argv + optind, argc - optind); } else { -- cgit 0.0.5-2-1-g0f52 From 954256283ebd7e4b0f196c4f70ef42e92444990c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 21 Feb 2016 02:11:11 +0900 Subject: Improved the install instruction. (Thanks to Ronald Michaels) --- ChangeLog | 6 ++++++ README | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 10154c88e0..e3f2769e0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016.02.21 Kentaro Fukuchi + * configure.ac, tests/common.h, tests/view_qrcode.c: + - Migrated from SDL 1.2 to 2.0. + * README: + - Modified the install instruction. (Thanks to Ronald Michaels) + 2015.11.04 Kentaro Fukuchi * qrspec.h, mqrspec.h: - Typo fix. (Thanks to @qianchenglenger) diff --git a/README b/README index 3759c710df..11cff79032 100644 --- a/README +++ b/README @@ -45,7 +45,8 @@ Just try ./configure make -make install +sudo make install +sudo ldconfig This compiles and installs the library and header file to the appropriate directories. By default, /usr/local/lib and /usr/local/include. You can change -- cgit 0.0.5-2-1-g0f52 From 47f6101473dc4d8443e55879112bca0057c03a07 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 21 Feb 2016 02:13:14 +0900 Subject: ACKNOWLEDGMENTS has been updated. --- ChangeLog | 4 ++-- README | 2 +- README.md | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3f2769e0d..d814cb45f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,8 @@ 2016.02.21 Kentaro Fukuchi * configure.ac, tests/common.h, tests/view_qrcode.c: - Migrated from SDL 1.2 to 2.0. - * README: - - Modified the install instruction. (Thanks to Ronald Michaels) + * README, README.md: + - Improved the install instruction. (Thanks to Ronald Michaels) 2015.11.04 Kentaro Fukuchi * qrspec.h, mqrspec.h: diff --git a/README b/README index 11cff79032..7293b677b7 100644 --- a/README +++ b/README @@ -154,5 +154,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, - Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger + Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels - bug report / suggestion diff --git a/README.md b/README.md index 8791fc4b29..25f56646a1 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,8 @@ Just try ``` ./configure make -make install +sudo make install +sudo ldconfig ``` This compiles and installs the library and header file to the appropriate @@ -154,5 +155,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, - Vlad Bespalov, @minus7, Ian Sweet + Vlad Bespalov, @minus7, Ian Sweet, Ronald Michaels - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From b2ee56b35701fd353370a2b00fc815a793e618bf Mon Sep 17 00:00:00 2001 From: Edric Date: Fri, 4 Mar 2016 14:37:56 -0500 Subject: Add LDFLAGS for mingw compilation --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index b8d3f0e44e..c135e628dd 100644 --- a/configure.ac +++ b/configure.ac @@ -35,6 +35,10 @@ AC_PROG_LIBTOOL AC_PROG_RANLIB PKG_PROG_PKG_CONFIG +case "${host}" in +*mingw*) LDFLAGS+="-no-undefined -avoid-version -Wl,--nxcompat -Wl,--dynamicbase" +esac + AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1]) AC_CHECK_FUNCS([strdup]) -- cgit 0.0.5-2-1-g0f52 From 9c77b8f44ccd87ca1feed423a4fb0cfe0ab1786c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 29 Mar 2016 00:03:07 +0900 Subject: Added mask=-2 mode for debug purpose. --- ChangeLog | 4 ++++ tests/view_qrcode.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index d814cb45f8..79a847a65b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016.03.29 Kentaro Fukuchi + * tests/view_qrcode.c: + - Added mask=-2 mode for debug purpose. + 2016.02.21 Kentaro Fukuchi * configure.ac, tests/common.h, tests/view_qrcode.c: - Migrated from SDL 1.2 to 2.0. diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index aba9574ea1..a6508ad427 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -375,6 +375,12 @@ void view(int mode, QRinput *input) loop = 0; } break; + case SDLK_9: + if(!mode && !structured) { + mask = -2; + loop = 0; + } + break; case SDLK_l: level = QR_ECLEVEL_L; loop = 0; -- cgit 0.0.5-2-1-g0f52 From 65423b21a1f02f7b48f9ffb4fc93595466549890 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 29 Mar 2016 03:39:05 +0900 Subject: Some missed contributros have been added. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25f56646a1..bd94b3b54e 100644 --- a/README.md +++ b/README.md @@ -150,10 +150,11 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Robert Petersen (@ripetersen) - added ability to read input data from a file * @Oblomov - improved SVG support patch +* @mgorny - reverse mappings of UTF8 and ANSIUTF8. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, - Vlad Bespalov, @minus7, Ian Sweet, Ronald Michaels + Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels - bug report / suggestion -- cgit 0.0.5-2-1-g0f52 From 734fd125dc96c91d04de37350e538b1ea6c732c7 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 29 Mar 2016 03:42:06 +0900 Subject: Incorrect bit padding has been fixed. --- ChangeLog | 9 +++++++++ README | 3 ++- README.md | 3 ++- bitstream.c | 9 +++++---- qrencode.c | 30 ++++++++++++++---------------- tests/test_bitstream.c | 4 ++-- tests/test_qrencode.c | 2 +- 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79a847a65b..2f0923d654 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,15 @@ 2016.03.29 Kentaro Fukuchi * tests/view_qrcode.c: - Added mask=-2 mode for debug purpose. + * bitstream.c, qrencode.c: + - Incorrect bit padding has been fixed. (Thanks to Yuji Ueno) + * tests/test_bitstream.c, tests/test_qrencode.c: + - Incorrect bit padding has been fixed. + * README: + - ACKNOWLEDGMENTS has been updated. + * README.md: + - ACKNOWLEDGMENTS has been updated. + - Some missed contributors have been added to README.md. 2016.02.21 Kentaro Fukuchi * configure.ac, tests/common.h, tests/view_qrcode.c: diff --git a/README b/README index 7293b677b7..78b44c25e7 100644 --- a/README +++ b/README @@ -154,5 +154,6 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, - Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels + Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, + Yuji Ueno - bug report / suggestion diff --git a/README.md b/README.md index bd94b3b54e..7293292ef7 100644 --- a/README.md +++ b/README.md @@ -156,5 +156,6 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, - Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels + Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, + Yuji Ueno - bug report / suggestion diff --git a/bitstream.c b/bitstream.c index 6c33612421..2b7c3ed084 100644 --- a/bitstream.c +++ b/bitstream.c @@ -159,7 +159,7 @@ int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) unsigned char *BitStream_toByte(BitStream *bstream) { - int i, j, size, bytes; + int i, j, size, bytes, oddbits; unsigned char *data, v; unsigned char *p; @@ -184,14 +184,15 @@ unsigned char *BitStream_toByte(BitStream *bstream) } data[i] = v; } - if(size & 7) { + oddbits = size & 7; + if(oddbits > 0) { v = 0; - for(j = 0; j < (size & 7); j++) { + for(j = 0; j < oddbits; j++) { v = v << 1; v |= *p; p++; } - data[bytes] = v; + data[bytes] = v << (8 - oddbits); } return data; diff --git a/qrencode.c b/qrencode.c index daa74b2a03..618701005b 100644 --- a/qrencode.c +++ b/qrencode.c @@ -513,7 +513,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) int width, version; MQRRawCode *raw; unsigned char *frame, *masked, *p, code, bit; - int i, j; + int i, j, length; QRcode *qrcode = NULL; FrameFiller filler; @@ -545,29 +545,27 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) /* inteleaved data and ecc codes */ for(i = 0; i < raw->dataLength + raw->eccLength; i++) { code = MQRraw_getCode(raw); + bit = 0x80; if(raw->oddbits && i == raw->dataLength - 1) { - bit = 1 << (raw->oddbits - 1); - for(j = 0; j < raw->oddbits; j++) { - p = FrameFiller_next(&filler); - if(p == NULL) goto EXIT; - *p = 0x02 | ((bit & code) != 0); - bit = bit >> 1; - } + length = raw->oddbits; } else { - bit = 0x80; - for(j = 0; j < 8; j++) { - p = FrameFiller_next(&filler); - if(p == NULL) goto EXIT; - *p = 0x02 | ((bit & code) != 0); - bit = bit >> 1; - } + length = 8; + } + for(j = 0; j < length; j++) { + p = FrameFiller_next(&filler); + if(p == NULL) goto EXIT; + *p = 0x02 | ((bit & code) != 0); + bit = bit >> 1; } } MQRraw_free(raw); raw = NULL; /* masking */ - if(mask < 0) { + if(mask == -2) { // just for debug purpose + masked = (unsigned char *)malloc(width * width); + memcpy(masked, frame, width * width); + } else if(mask < 0) { masked = MMask_mask(version, frame, input->level); } else { masked = MMask_makeMask(version, frame, mask, input->level); diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 85e634ecd0..4a6393e146 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -128,7 +128,7 @@ void test_toByte_4bitpadding(void) bstream = BitStream_new(); BitStream_appendNum(bstream, 4, 0xb); result = BitStream_toByte(bstream); - assert_equal(result[0], 0xb, "incorrect paddings\n"); + assert_equal(result[0], 0xb0, "incorrect paddings\n"); BitStream_free(bstream); free(result); @@ -136,7 +136,7 @@ void test_toByte_4bitpadding(void) BitStream_appendNum(bstream, 12, 0x335); result = BitStream_toByte(bstream); assert_equal(result[0], 0x33, "incorrect paddings\n"); - assert_equal(result[1], 0x05, "incorrect paddings\n"); + assert_equal(result[1], 0x50, "incorrect paddings\n"); BitStream_free(bstream); free(result); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 34372ebf0f..64ec0dab2c 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -688,7 +688,7 @@ void test_mqrraw_new(void) { QRinput *stream; char *num = "01234"; - unsigned char datacode[] = {0xa0, 0x62, 0x02}; + unsigned char datacode[] = {0xa0, 0x62, 0x20}; MQRRawCode *raw; testStart("Test MQRRaw_new()"); -- cgit 0.0.5-2-1-g0f52 From 9fee3e403d0f5b740aaa93f0f6303d6fe6f4dee2 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 30 Mar 2016 01:52:54 +0900 Subject: Added new function BitStream_newWithBits() and tests for it. --- ChangeLog | 4 ++++ bitstream.c | 25 +++++++++++++++++++++++++ bitstream.h | 3 +++ tests/test_bitstream.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2f0923d654..9cf306ea8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016.03.30 Kentaro Fukuchi + * bitstream.[ch], tests/test_bitstream.c: + - Added new function BitStream_newWithBits() and tests for it. + 2016.03.29 Kentaro Fukuchi * tests/view_qrcode.c: - Added mask=-2 mode for debug purpose. diff --git a/bitstream.c b/bitstream.c index 2b7c3ed084..9d5fc90d67 100644 --- a/bitstream.c +++ b/bitstream.c @@ -48,6 +48,31 @@ BitStream *BitStream_new(void) return bstream; } +#ifdef WITH_TESTS +BitStream *BitStream_newWithBits(int size, unsigned char *bits) +{ + BitStream *bstream; + + if(size < 0) return NULL; + if(size == 0) return BitStream_new(); + + bstream = (BitStream *)malloc(sizeof(BitStream)); + if(bstream == NULL) return NULL; + + bstream->data = (unsigned char *)malloc(size); + if(bstream->data == NULL) { + free(bstream); + return NULL; + } + + bstream->length = size; + bstream->datasize = size; + memcpy(bstream->data, bits, size); + + return bstream; +} +#endif + static int BitStream_expand(BitStream *bstream) { unsigned char *data; diff --git a/bitstream.h b/bitstream.h index 601f10f2e6..ce4d7e0e5d 100644 --- a/bitstream.h +++ b/bitstream.h @@ -29,6 +29,9 @@ typedef struct { } BitStream; extern BitStream *BitStream_new(void); +#ifdef WITH_TESTS +extern BitStream *BitStream_newWithBits(int size, unsigned char *bits); +#endif extern int BitStream_append(BitStream *bstream, BitStream *arg); extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num); extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data); diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 4a6393e146..8f0d242ce1 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -203,6 +203,35 @@ void test_append(void) BitStream_free(bs2); } +void test_newWithBits(void) +{ + BitStream *bstream; + unsigned char data[4] = {0, 1, 0, 1}; + + testStart("New with bits"); + + bstream = BitStream_newWithBits(4, data); + assert_equal(bstream->length, 4, "Internal bit length is incorrect.\n"); + assert_equal(bstream->datasize, 4, "Internal buffer size is incorrect.\n"); + assert_zero(cmpBin("0101", bstream), "Internal data is incorrect.\n"); + + testFinish(); +} + +void test_newWithBits_size0(void) +{ + BitStream *bstream; + + testStart("New with bits (size = 0)"); + + bstream = BitStream_newWithBits(0, NULL); + assert_equal(bstream->length, 0, "Internal bit length is incorrect.\n"); + assert_nonzero(bstream->datasize, "Internal buffer size is incorrect.\n"); + assert_nonnull(bstream->data, "Internal buffer not allocated.\n"); + + testFinish(); +} + int main(int argc, char **argv) { test_null(); @@ -214,6 +243,8 @@ int main(int argc, char **argv) test_toByte_4bitpadding(); test_size(); test_append(); + test_newWithBits(); + test_newWithBits_size0(); report(); -- cgit 0.0.5-2-1-g0f52 From 0ab5c472d212966685b0aa90f8cc086d172cc566 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 30 Mar 2016 02:14:58 +0900 Subject: Code refactoring. --- ChangeLog | 2 ++ tests/decoder.c | 91 ++++++++++++++++++++++++++++++----------------------- tests/decoder.h | 4 +-- tests/test_monkey.c | 6 ++-- 4 files changed, 59 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cf306ea8f..6a29eb5b6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2016.03.30 Kentaro Fukuchi * bitstream.[ch], tests/test_bitstream.c: - Added new function BitStream_newWithBits() and tests for it. + * tests/decoder.[ch], tests/test_monkey.c: + - Code refactoring. 2016.03.29 Kentaro Fukuchi * tests/view_qrcode.c: diff --git a/tests/decoder.c b/tests/decoder.c index 4d7c109bb6..72079d0f86 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -2,6 +2,7 @@ #include #include #include +#include "../config.h" #include "../qrspec.h" #include "../bitstream.h" #include "../mask.h" @@ -766,8 +767,9 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) return &p[y * w + x]; } -static unsigned char *extractBits(int width, unsigned char *frame, int spec[5]) +static BitStream *extractBits(int width, unsigned char *frame, int spec[5]) { + BitStream *bstream; unsigned char *bits, *p, *q; FrameFiller *filler; int i, j; @@ -800,12 +802,16 @@ static unsigned char *extractBits(int width, unsigned char *frame, int spec[5]) } free(filler); - return bits; + bstream = BitStream_newWithBits(words * 8, bits); + free(bits); + + return bstream; } -unsigned char *QRcode_extractBits(QRcode *code, int *length) +BitStream *QRcode_extractBits(QRcode *code) { - unsigned char *unmasked, *bits; + BitStream *bstream; + unsigned char *unmasked; int spec[5]; int ret, version, mask; QRecLevel level; @@ -816,15 +822,14 @@ unsigned char *QRcode_extractBits(QRcode *code, int *length) if(ret < 0) return NULL; QRspec_getEccSpec(version, level, spec); - *length = QRspec_rsDataLength(spec) * 8; unmasked = unmask(code, level, mask); if(unmasked == NULL) return NULL; - bits = extractBits(code->width, unmasked, spec); + bstream = extractBits(code->width, unmasked, spec); free(unmasked); - return bits; + return bstream; } static void printBits(int length, unsigned char *bits) @@ -869,7 +874,8 @@ static int checkRemainderWords(int length, unsigned char *bits, int remainder) QRdata *QRcode_decodeBits(QRcode *code) { - unsigned char *unmasked, *bits; + BitStream *bstream; + unsigned char *unmasked; int spec[5]; int ret, version, mask; int length; @@ -887,18 +893,18 @@ QRdata *QRcode_decodeBits(QRcode *code) unmasked = unmask(code, level, mask); if(unmasked == NULL) return NULL; - bits = extractBits(code->width, unmasked, spec); + bstream = extractBits(code->width, unmasked, spec); free(unmasked); qrdata = QRdata_new(); qrdata->version = version; qrdata->level = level; - ret = QRdata_decodeBits(qrdata, length, bits); + ret = QRdata_decodeBitStream(qrdata, bstream); if(ret > 0) { - checkRemainderWords(length, bits, ret); + checkRemainderWords(length, bstream->data, ret); } - free(bits); + BitStream_free(bstream); return qrdata; } @@ -979,14 +985,15 @@ unsigned char *QRcode_unmaskMQR(QRcode *code) return unmaskMQR(code, level, mask); } -static unsigned char *extractBitsMQR(int width, unsigned char *frame, int version, QRecLevel level) +static BitStream *extractBitsMQR(int width, unsigned char *frame, int version, QRecLevel level) { + BitStream *bstream; unsigned char *bits; FrameFiller *filler; int i; int size; - size = MQRspec_getDataLengthBit(version, level); + size = MQRspec_getDataLengthBit(version, level) + MQRspec_getECCLength(version, level) * 8; bits = (unsigned char *)malloc(size); filler = FrameFiller_new(width, frame, 1); for(i=0; iwidth, unmasked, version, level); + *dataLength = MQRspec_getDataLengthBit(*version, *level); + *eccLength = MQRspec_getECCLength(*version, *level) * 8; + bstream = extractBitsMQR(code->width, unmasked, *version, *level); free(unmasked); - return bits; + return bstream; } static int checkRemainderWordsMQR(int length, unsigned char *bits, int remainder, int version) @@ -1064,31 +1075,29 @@ static int checkRemainderWordsMQR(int length, unsigned char *bits, int remainder QRdata *QRcode_decodeBitsMQR(QRcode *code) { - unsigned char *unmasked, *bits; - int ret, version, mask; - int length; + BitStream *bstream; + int ret, version, dataLength, eccLength; QRecLevel level; QRdata *qrdata; - ret = QRcode_decodeFormatMQR(code, &version, &level, &mask); - if(ret < 0) return NULL; - - unmasked = unmaskMQR(code, level, mask); - if(unmasked == NULL) return NULL; - - length = MQRspec_getDataLengthBit(version, level); - bits = extractBitsMQR(code->width, unmasked, version, level); - free(unmasked); + bstream = QRcode_extractBitsMQR(code, &dataLength, &eccLength, &version, &level); + if(bstream == NULL) { + return NULL; + } qrdata = QRdata_newMQR(); qrdata->version = version; qrdata->level = level; - ret = QRdata_decodeBits(qrdata, length, bits); + ret = QRdata_decodeBits(qrdata, dataLength, bstream->data); if(ret > 0) { - checkRemainderWordsMQR(length, bits, ret, version); + ret = checkRemainderWordsMQR(dataLength, bstream->data, ret, version); + if(ret < 0) { + QRdata_free(qrdata); + qrdata = NULL; + } } - free(bits); + BitStream_free(bstream); return qrdata; } @@ -1097,7 +1106,9 @@ QRdata *QRcode_decodeMQR(QRcode *code) { QRdata *qrdata; qrdata = QRcode_decodeBitsMQR(code); - QRdata_concatChunks(qrdata); + if(qrdata != NULL) { + QRdata_concatChunks(qrdata); + } return qrdata; } diff --git a/tests/decoder.h b/tests/decoder.h index afff7764b6..c3e3284b6d 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -36,13 +36,13 @@ void QRdata_free(QRdata *data); int QRcode_decodeVersion(QRcode *code); int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask); unsigned char *QRcode_unmask(QRcode *code); -unsigned char *QRcode_extractBits(QRcode *code, int *length); +BitStream *QRcode_extractBits(QRcode *code); QRdata *QRcode_decodeBits(QRcode *code); QRdata *QRcode_decode(QRcode *code); int QRcode_decodeFormatMQR(QRcode *code, int *vesion, QRecLevel *level, int *mask); unsigned char *QRcode_unmaskMQR(QRcode *code); -unsigned char *QRcode_extractBitsMQR(QRcode *code, int *length); +BitStream *QRcode_extractBitsMQR(QRcode *code, int *dataLength, int *eccLength, int *version, QRecLevel *level); QRdata *QRcode_decodeBitsMQR(QRcode *code); QRdata *QRcode_decodeMQR(QRcode *code); diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 3acd2dc4c2..860014131c 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -159,7 +159,9 @@ void test_encode_an(int num) snprintf(buf, 256, "monkey-result-bits-%d.dat", num); fp = fopen(buf, "w"); - p = QRcode_extractBits(qrcode, &y); + bstream = QRcode_extractBits(qrcode); + y = bstream->length; + p = bstream->data; c = 0; for(x=0; x Date: Sat, 2 Apr 2016 21:25:30 +0900 Subject: refactoring and new functions. --- ChangeLog | 5 +++++ tests/common.h | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a29eb5b6f..6bf468319a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016.04.02 Kentaro Fukuchi + * tests/common.h: + - Code refactoring. + - New debug functions have been added. + 2016.03.30 Kentaro Fukuchi * bitstream.[ch], tests/test_bitstream.c: - Added new function BitStream_newWithBits() and tests for it. diff --git a/tests/common.h b/tests/common.h index 3f53247402..a3c869d398 100644 --- a/tests/common.h +++ b/tests/common.h @@ -102,6 +102,27 @@ void printQRcode(QRcode *code) printFrame(code->width, code->data); } +void printQRRawCodeFromQRinput(QRinput *input) +{ + QRRawCode *raw; + int i; + + puts("QRRawCode dump image:"); + raw = QRraw_new(input); + if(raw == NULL) { + puts("Failed to generate QRRawCode from this input.\n"); + return; + } + for(i=0; idataLength; i++) { + printf(" %02x", raw->datacode[i]); + } + for(i=0; ieccLength; i++) { + printf(" %02x", raw->ecccode[i]); + } + printf("\n"); + QRraw_free(raw); +} + void testStartReal(const char *func, const char *name) { tests++; @@ -189,17 +210,21 @@ int cmpBin(char *correct, BitStream *bstream) return ncmpBin(correct, bstream, len); } -void printBstream(BitStream *bstream) +void printBinary(unsigned char *data, int length) { - int i, size; + int i; - size = BitStream_size(bstream); - for(i=0; idata[i]?"1":"0"); + for(i=0; idata, BitStream_size(bstream)); +} + #if HAVE_SDL /* Experimental debug function */ /* You can call show_QRcode(QRcode *code) to display the QR Code from anywhere -- cgit 0.0.5-2-1-g0f52 From dd00acdc5512049b266941d56775e3cde22f3654 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 2 Apr 2016 21:48:08 +0900 Subject: QRcode_extractBits() has been extended. --- ChangeLog | 2 ++ tests/decoder.c | 5 ++++- tests/decoder.h | 2 +- tests/test_monkey.c | 5 +++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6bf468319a..04ec9b501a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * tests/common.h: - Code refactoring. - New debug functions have been added. + * tests/decoder.[ch], tests/test_monkey.c: + - QRcode_extractBits() has been extended. This will be used later. 2016.03.30 Kentaro Fukuchi * bitstream.[ch], tests/test_bitstream.c: diff --git a/tests/decoder.c b/tests/decoder.c index 72079d0f86..e57e6195c5 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -808,7 +808,7 @@ static BitStream *extractBits(int width, unsigned char *frame, int spec[5]) return bstream; } -BitStream *QRcode_extractBits(QRcode *code) +BitStream *QRcode_extractBits(QRcode *code, int *dataLength, int *eccLength) { BitStream *bstream; unsigned char *unmasked; @@ -829,6 +829,9 @@ BitStream *QRcode_extractBits(QRcode *code) bstream = extractBits(code->width, unmasked, spec); free(unmasked); + *dataLength = QRspec_rsDataLength(spec) * 8; + *eccLength = QRspec_rsEccLength(spec) * 8; + return bstream; } diff --git a/tests/decoder.h b/tests/decoder.h index c3e3284b6d..bf2c2e6bfd 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -36,7 +36,7 @@ void QRdata_free(QRdata *data); int QRcode_decodeVersion(QRcode *code); int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask); unsigned char *QRcode_unmask(QRcode *code); -BitStream *QRcode_extractBits(QRcode *code); +BitStream *QRcode_extractBits(QRcode *code, int *dataLength, int *eccLength); QRdata *QRcode_decodeBits(QRcode *code); QRdata *QRcode_decode(QRcode *code); diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 860014131c..2ab0546482 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -84,7 +84,8 @@ void test_encode_an(int num) ret = memcmp(qrdata->data, data, len); if(ret != 0) { unsigned char *frame, *p; - int x,y, c; + int x,y,c; + int dataLength, eccLength; QRinput *input; QRcode *origcode; BitStream *bstream; @@ -159,7 +160,7 @@ void test_encode_an(int num) snprintf(buf, 256, "monkey-result-bits-%d.dat", num); fp = fopen(buf, "w"); - bstream = QRcode_extractBits(qrcode); + bstream = QRcode_extractBits(qrcode, &dataLength, &eccLength); y = bstream->length; p = bstream->data; c = 0; -- cgit 0.0.5-2-1-g0f52 From dce6486820023eed4231ceba54c8e6bfb4e446d0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 2 Apr 2016 22:28:16 +0900 Subject: 'eccResult' has been added to QRdata. --- ChangeLog | 3 +++ tests/decoder.c | 5 ++++- tests/decoder.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 04ec9b501a..fe5b4a3bc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ - New debug functions have been added. * tests/decoder.[ch], tests/test_monkey.c: - QRcode_extractBits() has been extended. This will be used later. + * tests/decoder.[ch]: + - eccResult has been added to QRdata. + - Code refactoring. 2016.03.30 Kentaro Fukuchi * bitstream.[ch], tests/test_bitstream.c: diff --git a/tests/decoder.c b/tests/decoder.c index e57e6195c5..e4c400a96c 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -507,6 +507,8 @@ QRdata *QRdata_new(void) qrdata = (QRdata *)calloc(sizeof(QRdata), 1); if(qrdata == NULL) return NULL; + qrdata->eccResult = 0; + return qrdata; } @@ -514,8 +516,9 @@ QRdata *QRdata_newMQR(void) { QRdata *qrdata; - qrdata = (QRdata *)calloc(sizeof(QRdata), 1); + qrdata = QRdata_new(); if(qrdata == NULL) return NULL; + qrdata->mqr = 1; return qrdata; diff --git a/tests/decoder.h b/tests/decoder.h index bf2c2e6bfd..bd32cab807 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -18,6 +18,7 @@ typedef struct { int version; QRecLevel level; DataChunk *chunks, *last; + int eccResult; } QRdata; struct FormatInfo { -- cgit 0.0.5-2-1-g0f52 From 40fe3148d15290f77ce17aba4e47434818e744a1 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 2 Apr 2016 23:31:44 +0900 Subject: Made some functions static. --- tests/decoder.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/decoder.c b/tests/decoder.c index e4c400a96c..0506d8b502 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -340,17 +340,17 @@ static DataChunk *decodeChunkMQR(int *bits_length, unsigned char **bits, int ver return NULL; } -void dumpNum(DataChunk *chunk) +static void dumpNum(DataChunk *chunk) { printf("%s\n", chunk->data); } -void dumpAn(DataChunk *chunk) +static void dumpAn(DataChunk *chunk) { printf("%s\n", chunk->data); } -void dump8(DataChunk *chunk) +static void dump8(DataChunk *chunk) { int i, j; unsigned char c; @@ -389,7 +389,7 @@ void dump8(DataChunk *chunk) } } -void dumpKanji(DataChunk *chunk) +static void dumpKanji(DataChunk *chunk) { iconv_t conv; char *inbuf, *outbuf, *outp; @@ -437,7 +437,7 @@ static void dumpChunk(DataChunk *chunk) } } -void dumpChunks(QRdata *qrdata) +static void dumpChunks(QRdata *qrdata) { DataChunk *chunk; @@ -477,7 +477,7 @@ void QRdata_concatChunks(QRdata *qrdata) qrdata->data = data; } -int appendChunk(QRdata *qrdata, int *bits_length, unsigned char **bits) +static int appendChunk(QRdata *qrdata, int *bits_length, unsigned char **bits) { DataChunk *chunk; -- cgit 0.0.5-2-1-g0f52 From ed60ec46102cbb56306e67c1954ad3d3d4ea43b8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 2 Apr 2016 23:47:08 +0900 Subject: Code refactoring. --- ChangeLog | 2 + tests/Makefile.am | 2 +- tests/datachunk.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/datachunk.h | 18 ++++++++ tests/decoder.c | 129 +---------------------------------------------------- tests/decoder.h | 9 +--- 6 files changed, 153 insertions(+), 137 deletions(-) create mode 100644 tests/datachunk.c create mode 100644 tests/datachunk.h diff --git a/ChangeLog b/ChangeLog index fe5b4a3bc1..33f4d8ed92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ * tests/decoder.[ch]: - eccResult has been added to QRdata. - Code refactoring. + * tests/decoder.[ch], tests/datachunk.[ch], tests/Makefile.am: + - Code refactoring. 2016.03.30 Kentaro Fukuchi * bitstream.[ch], tests/test_bitstream.c: diff --git a/tests/Makefile.am b/tests/Makefile.am index fce34a3252..58adf4c773 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,7 +25,7 @@ endif EXTRA_DIST = frame URI_testset.inc -libdecoder_a_SOURCES = decoder.c decoder.h rsecc_decoder.c rsecc_decoder.h +libdecoder_a_SOURCES = decoder.c decoder.h datachunk.c datachunk.h rsecc_decoder.c rsecc_decoder.h test_qrinput_SOURCES = test_qrinput.c test_qrinput_LDADD = ../libqrencode.la $(DECODER_LIBS) diff --git a/tests/datachunk.c b/tests/datachunk.c new file mode 100644 index 0000000000..180bc44051 --- /dev/null +++ b/tests/datachunk.c @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include "datachunk.h" + +DataChunk *DataChunk_new(QRencodeMode mode) +{ + DataChunk *chunk; + + chunk = (DataChunk *)calloc(1, sizeof(DataChunk)); + if(chunk == NULL) return NULL; + + chunk->mode = mode; + + return chunk; +} + +void DataChunk_free(DataChunk *chunk) +{ + if(chunk) { + if(chunk->data) free(chunk->data); + free(chunk); + } +} + +static void dumpNum(DataChunk *chunk) +{ + printf("%s\n", chunk->data); +} + +static void dumpAn(DataChunk *chunk) +{ + printf("%s\n", chunk->data); +} + +static void dump8(DataChunk *chunk) +{ + int i, j; + unsigned char c; + int count = 0; + unsigned char buf[16]; + + for(i=0; isize; i++) { + buf[count] = chunk->data[i]; + c = chunk->data[i]; + if(c >= ' ' && c <= '~') { + putchar(c); + } else { + putchar('.'); + } + count++; + + if(count >= 16) { + putchar(' '); + for(j=0; j<16; j++) { + printf(" %02x", buf[j]); + } + count = 0; + putchar('\n'); + } + } + if(count > 0) { + for(i=0; i<16 - count; i++) { + putchar(' '); + } + putchar(' '); + for(j=0; jsize; + inbuf = (char *)chunk->data; + outbytes = inbytes * 4 + 1; + outbuf = (char *)malloc(inbytes * 4 + 1); + outp = outbuf; + ret = iconv(conv, &inbuf, &inbytes, &outp, &outbytes); + if(ret == (size_t) -1) { perror(NULL); } + *outp = '\0'; + + printf("%s\n", outbuf); + + iconv_close(conv); + free(outbuf); +} + +static void dumpChunk(DataChunk *chunk) +{ + switch(chunk->mode) { + case QR_MODE_NUM: + printf("Numeric: %d bytes\n", chunk->size); + dumpNum(chunk); + break; + case QR_MODE_AN: + printf("AlphaNumeric: %d bytes\n", chunk->size); + dumpAn(chunk); + break; + case QR_MODE_8: + printf("8-bit data: %d bytes\n", chunk->size); + dump8(chunk); + break; + case QR_MODE_KANJI: + printf("Kanji: %d bytes\n", chunk->size); + dumpKanji(chunk); + break; + default: + printf("Invalid or reserved: %d bytes\n", chunk->size); + dump8(chunk); + break; + } +} + +void DataChunk_dumpChunkList(DataChunk *list) +{ + while(list != NULL) { + dumpChunk(list); + list = list->next; + } +} diff --git a/tests/datachunk.h b/tests/datachunk.h new file mode 100644 index 0000000000..d225d779d7 --- /dev/null +++ b/tests/datachunk.h @@ -0,0 +1,18 @@ +#ifndef __DATACHUNK_H__ +#define __DATACHUNK_H__ + +#include "../qrencode.h" + +typedef struct _DataChunk { + QRencodeMode mode; + int size; + int bits; + unsigned char *data; + struct _DataChunk *next; +} DataChunk; + +DataChunk *DataChunk_new(QRencodeMode mode); +void DataChunk_free(DataChunk *chunk); +void DataChunk_dumpChunkList(DataChunk *list); + +#endif /* __DATACHUNK_H__ */ diff --git a/tests/decoder.c b/tests/decoder.c index 0506d8b502..3393bec074 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -23,26 +23,6 @@ static unsigned int bitToInt(unsigned char *bits, int length) return val; } -DataChunk *DataChunk_new(QRencodeMode mode) -{ - DataChunk *chunk; - - chunk = (DataChunk *)calloc(1, sizeof(DataChunk)); - if(chunk == NULL) return NULL; - - chunk->mode = mode; - - return chunk; -} - -void DataChunk_free(DataChunk *chunk) -{ - if(chunk) { - if(chunk->data) free(chunk->data); - free(chunk); - } -} - static int decodeLength(int *bits_length, unsigned char **bits, QRencodeMode mode, int version, int mqr) { int i; @@ -340,113 +320,6 @@ static DataChunk *decodeChunkMQR(int *bits_length, unsigned char **bits, int ver return NULL; } -static void dumpNum(DataChunk *chunk) -{ - printf("%s\n", chunk->data); -} - -static void dumpAn(DataChunk *chunk) -{ - printf("%s\n", chunk->data); -} - -static void dump8(DataChunk *chunk) -{ - int i, j; - unsigned char c; - int count = 0; - unsigned char buf[16]; - - for(i=0; isize; i++) { - buf[count] = chunk->data[i]; - c = chunk->data[i]; - if(c >= ' ' && c <= '~') { - putchar(c); - } else { - putchar('.'); - } - count++; - - if(count >= 16) { - putchar(' '); - for(j=0; j<16; j++) { - printf(" %02x", buf[j]); - } - count = 0; - putchar('\n'); - } - } - if(count > 0) { - for(i=0; i<16 - count; i++) { - putchar(' '); - } - putchar(' '); - for(j=0; jsize; - inbuf = (char *)chunk->data; - outbytes = inbytes * 4 + 1; - outbuf = (char *)malloc(inbytes * 4 + 1); - outp = outbuf; - ret = iconv(conv, &inbuf, &inbytes, &outp, &outbytes); - if(ret == (size_t) -1) { perror(NULL); } - *outp = '\0'; - - printf("%s\n", outbuf); - - iconv_close(conv); - free(outbuf); -} - -static void dumpChunk(DataChunk *chunk) -{ - switch(chunk->mode) { - case QR_MODE_NUM: - printf("Numeric: %d bytes\n", chunk->size); - dumpNum(chunk); - break; - case QR_MODE_AN: - printf("AlphaNumeric: %d bytes\n", chunk->size); - dumpAn(chunk); - break; - case QR_MODE_8: - printf("8-bit data: %d bytes\n", chunk->size); - dump8(chunk); - break; - case QR_MODE_KANJI: - printf("Kanji: %d bytes\n", chunk->size); - dumpKanji(chunk); - break; - default: - printf("Invalid or reserved: %d bytes\n", chunk->size); - dump8(chunk); - break; - } -} - -static void dumpChunks(QRdata *qrdata) -{ - DataChunk *chunk; - - chunk = qrdata->chunks; - while(chunk != NULL) { - dumpChunk(chunk); - chunk = chunk->next; - } -} void QRdata_concatChunks(QRdata *qrdata) { @@ -559,7 +432,7 @@ int QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream) void QRdata_dump(QRdata *data) { - dumpChunks(data); + DataChunk_dumpChunkList(data->chunks); } int QRcode_decodeVersion(QRcode *code) diff --git a/tests/decoder.h b/tests/decoder.h index bd32cab807..af1fe096ea 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -2,14 +2,7 @@ #define __DECODER_H__ #include "../qrencode.h" - -typedef struct _DataChunk { - QRencodeMode mode; - int size; - int bits; - unsigned char *data; - struct _DataChunk *next; -} DataChunk; +#include "datachunk.h" typedef struct { int size; -- cgit 0.0.5-2-1-g0f52 From 8ea1504acacbf3a16698595e61079f0ce23a2fd1 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 3 Apr 2016 00:51:17 +0900 Subject: Code refactoring. --- tests/datachunk.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ tests/datachunk.h | 3 +++ tests/decoder.c | 45 ++++++--------------------------------------- 3 files changed, 53 insertions(+), 39 deletions(-) diff --git a/tests/datachunk.c b/tests/datachunk.c index 180bc44051..0291c5379d 100644 --- a/tests/datachunk.c +++ b/tests/datachunk.c @@ -24,6 +24,17 @@ void DataChunk_free(DataChunk *chunk) } } +void DataChunk_freeList(DataChunk *list) +{ + DataChunk *next; + + while(list != NULL) { + next = list->next; + DataChunk_free(list); + list = next; + } +} + static void dumpNum(DataChunk *chunk) { printf("%s\n", chunk->data); @@ -128,3 +139,36 @@ void DataChunk_dumpChunkList(DataChunk *list) list = list->next; } } + +int DataChunk_totalSize(DataChunk *list) +{ + int size = 0; + + while(list != NULL) { + size += list->size; + list = list->next; + } + + return size; +} + +unsigned char *DataChunk_concatChunkList(DataChunk *list, int *retsize) +{ + int size, idx; + unsigned char *data; + + size = DataChunk_totalSize(list); + if(size <= 0) return NULL; + + data = (unsigned char *)malloc(size + 1); + idx = 0; + while(list != NULL) { + memcpy(&data[idx], list->data, list->size); + idx += list->size; + list = list->next; + } + data[size] = '\0'; + + *retsize = size; + return data; +} diff --git a/tests/datachunk.h b/tests/datachunk.h index d225d779d7..fb2bf34d70 100644 --- a/tests/datachunk.h +++ b/tests/datachunk.h @@ -13,6 +13,9 @@ typedef struct _DataChunk { DataChunk *DataChunk_new(QRencodeMode mode); void DataChunk_free(DataChunk *chunk); +void DataChunk_freeList(DataChunk *list); void DataChunk_dumpChunkList(DataChunk *list); +int DataChunk_totalSize(DataChunk *list); +unsigned char *DataChunk_concatChunkList(DataChunk *list, int *retsize); #endif /* __DATACHUNK_H__ */ diff --git a/tests/decoder.c b/tests/decoder.c index 3393bec074..76ea249818 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -320,36 +320,6 @@ static DataChunk *decodeChunkMQR(int *bits_length, unsigned char **bits, int ver return NULL; } - -void QRdata_concatChunks(QRdata *qrdata) -{ - int idx; - unsigned char *data; - DataChunk *chunk; - int size = 0; - - chunk = qrdata->chunks; - while(chunk != NULL) { - size += chunk->size; - chunk = chunk->next; - } - if(size <= 0) { - return; - } - - data = malloc(size + 1); - chunk = qrdata->chunks; - idx = 0; - while(chunk != NULL) { - memcpy(&data[idx], chunk->data, chunk->size); - idx += chunk->size; - chunk = chunk->next; - } - data[size] = '\0'; - qrdata->size = size; - qrdata->data = data; -} - static int appendChunk(QRdata *qrdata, int *bits_length, unsigned char **bits) { DataChunk *chunk; @@ -399,15 +369,7 @@ QRdata *QRdata_newMQR(void) void QRdata_free(QRdata *qrdata) { - DataChunk *chunk, *next; - - chunk = qrdata->chunks; - while(chunk != NULL) { - next = chunk->next; - DataChunk_free(chunk); - chunk = next; - } - + DataChunk_freeList(qrdata->chunks); if(qrdata->data != NULL) { free(qrdata->data); } @@ -788,6 +750,11 @@ QRdata *QRcode_decodeBits(QRcode *code) return qrdata; } +void QRdata_concatChunks(QRdata *qrdata) +{ + qrdata->data = DataChunk_concatChunkList(qrdata->chunks, &qrdata->size); +} + QRdata *QRcode_decode(QRcode *code) { QRdata *qrdata; -- cgit 0.0.5-2-1-g0f52 From a1d6c0ccf60df5ef66627ad8004a144c37af9384 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 3 Apr 2016 03:53:59 +0900 Subject: Code refactoring. --- tests/Makefile.am | 34 +++---- tests/common.c | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/common.h | 290 ++++-------------------------------------------------- tests/decoder.c | 19 +--- 4 files changed, 321 insertions(+), 301 deletions(-) create mode 100644 tests/common.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 58adf4c773..33402b8bcf 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,59 +27,59 @@ EXTRA_DIST = frame URI_testset.inc libdecoder_a_SOURCES = decoder.c decoder.h datachunk.c datachunk.h rsecc_decoder.c rsecc_decoder.h -test_qrinput_SOURCES = test_qrinput.c +test_qrinput_SOURCES = test_qrinput.c common.c test_qrinput_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_bitstream_SOURCES = test_bitstream.c +test_bitstream_SOURCES = test_bitstream.c common.c test_bitstream_LDADD = ../libqrencode.la -test_estimatebit_SOURCES = test_estimatebit.c +test_estimatebit_SOURCES = test_estimatebit.c common.c test_estimatebit_LDADD = ../libqrencode.la -test_qrspec_SOURCES = test_qrspec.c +test_qrspec_SOURCES = test_qrspec.c common.c test_qrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_mqrspec_SOURCES = test_mqrspec.c +test_mqrspec_SOURCES = test_mqrspec.c common.c test_mqrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_rs_SOURCES = test_rs.c rscode.c +test_rs_SOURCES = test_rs.c rscode.c common.c test_rs_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_qrencode_SOURCES = test_qrencode.c +test_qrencode_SOURCES = test_qrencode.c common.c test_qrencode_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_split_SOURCES = test_split.c +test_split_SOURCES = test_split.c common.c test_split_LDADD = ../libqrencode.la -test_split_urls_SOURCES = test_split_urls.c +test_split_urls_SOURCES = test_split_urls.c common.c test_split_urls_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_monkey_SOURCES = test_monkey.c +test_monkey_SOURCES = test_monkey.c common.c test_monkey_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_mask_SOURCES = test_mask.c +test_mask_SOURCES = test_mask.c common.c test_mask_LDADD = ../libqrencode.la $(DECODER_LIBS) -test_mmask_SOURCES = test_mmask.c +test_mmask_SOURCES = test_mmask.c common.c test_mmask_LDADD = ../libqrencode.la $(DECODER_LIBS) -prof_qrencode_SOURCES = prof_qrencode.c +prof_qrencode_SOURCES = prof_qrencode.c common.c prof_qrencode_LDADD = ../libqrencode.la -pthread_qrencode_SOURCES = pthread_qrencode.c +pthread_qrencode_SOURCES = pthread_qrencode.c common.c pthread_qrencode_LDADD = ../libqrencode.la if HAVE_PNG -create_frame_pattern_SOURCES = create_frame_pattern.c +create_frame_pattern_SOURCES = create_frame_pattern.c common.c create_frame_pattern_CFLAGS = $(png_CFLAGS) $(AM_CFLAGS) create_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) -create_mqr_frame_pattern_SOURCES = create_mqr_frame_pattern.c +create_mqr_frame_pattern_SOURCES = create_mqr_frame_pattern.c common.c create_mqr_frame_pattern_CFLAGS = $(png_CFLAGS) $(AM_CFLAGS) create_mqr_frame_pattern_LDADD = ../libqrencode.la $(png_LIBS) endif if HAVE_SDL -view_qrcode_SOURCES = view_qrcode.c +view_qrcode_SOURCES = view_qrcode.c common.c view_qrcode_LDADD = ../libqrencode.la endif diff --git a/tests/common.c b/tests/common.c new file mode 100644 index 0000000000..525dc3aa51 --- /dev/null +++ b/tests/common.c @@ -0,0 +1,279 @@ +#include +#include +#include "common.h" + +static int tests = 0; +static int failed = 0; +int assertionFailed = 0; +int assertionNum = 0; +static const char *testName = NULL; +static const char *testFunc = NULL; + +const char levelChar[4] = {'L', 'M', 'Q', 'H'}; +const char *modeStr[5] = {"nm", "an", "8", "kj", "st"}; + +int ncmpBin(char *correct, BitStream *bstream, int len) +{ + int i, bit; + char *p; + + if(len != BitStream_size(bstream)) { + printf("Length is not match: %d, %d expected.\n", BitStream_size(bstream), len); + return -1; + } + + p = correct; + i = 0; + while(*p != '\0') { + while(*p == ' ') { + p++; + } + bit = (*p == '1')?1:0; + if(bstream->data[i] != bit) return -1; + i++; + p++; + if(i == len) break; + } + + return 0; +} + +int cmpBin(char *correct, BitStream *bstream) +{ + int len = 0; + char *p; + + + for(p = correct; *p != '\0'; p++) { + if(*p != ' ') len++; + } + return ncmpBin(correct, bstream, len); +} + +void testStartReal(const char *func, const char *name) +{ + tests++; + testName = name; + testFunc = func; + assertionFailed = 0; + assertionNum = 0; + printf("_____%d: %s: %s...\n", tests, func, name); +} + +void testEnd(int result) +{ + printf(".....%d: %s: %s, ", tests, testFunc, testName); + if(result) { + puts("FAILED."); + failed++; + } else { + puts("PASSED."); + } +} + +void testFinish(void) +{ + printf(".....%d: %s: %s, ", tests, testFunc, testName); + if(assertionFailed) { + printf("FAILED. (%d assertions failed.)\n", assertionFailed); + failed++; + } else { + printf("PASSED. (%d assertions passed.)\n", assertionNum); + } +} + +void report() +{ + printf("Total %d tests, %d fails.\n", tests, failed); + if(failed) exit(-1); +} + + +void printBinary(unsigned char *data, int length) +{ + int i; + + for(i=0; idata, BitStream_size(bstream)); +} + +void printQRinput(QRinput *input) +{ + QRinput_List *list; + int i; + + list = input->head; + while(list != NULL) { + for(i=0; isize; i++) { + printf("0x%02x,", list->data[i]); + } + list = list->next; + } + printf("\n"); +} + +void printQRinputInfo(QRinput *input) +{ + QRinput_List *list; + BitStream *b; + int i, ret; + + printf("QRinput info:\n"); + printf(" version: %d\n", input->version); + printf(" level : %c\n", levelChar[input->level]); + list = input->head; + i = 0; + while(list != NULL) { + i++; + list = list->next; + } + printf(" chunks: %d\n", i); + b = BitStream_new(); + ret = QRinput_mergeBitStream(input, b); + if(ret == 0) { + printf(" bitstream-size: %d\n", BitStream_size(b)); + BitStream_free(b); + } + + list = input->head; + i = 0; + while(list != NULL) { + printf("\t#%d: mode = %s, size = %d\n", i, modeStr[list->mode], list->size); + i++; + list = list->next; + } +} + +void printQRinputStruct(QRinput_Struct *s) +{ + QRinput_InputList *list; + int i = 1; + + printf("Struct size: %d\n", s->size); + printf("Struct parity: %08x\n", s->parity); + for(list = s->head; list != NULL; list = list->next) { + printf("Symbol %d - ", i); + printQRinputInfo(list->input); + i++; + } +} + +void printFrame(int width, unsigned char *frame) +{ + int x, y; + + for(y=0; ywidth, code->data); +} + +void printQRRawCodeFromQRinput(QRinput *input) +{ + QRRawCode *raw; + int i; + + puts("QRRawCode dump image:"); + raw = QRraw_new(input); + if(raw == NULL) { + puts("Failed to generate QRRawCode from this input.\n"); + return; + } + for(i=0; idataLength; i++) { + printf(" %02x", raw->datacode[i]); + } + for(i=0; ieccLength; i++) { + printf(" %02x", raw->ecccode[i]); + } + printf("\n"); + QRraw_free(raw); +} + +#if HAVE_SDL +/* Experimental debug function */ +/* You can call show_QRcode(QRcode *code) to display the QR Code from anywhere + * in test code using SDL. */ +#include + +static void draw_QRcode(QRcode *qrcode, int ox, int oy, int margin, int size, SDL_Surface *surface) +{ + int x, y, width; + unsigned char *p; + SDL_Rect rect; + Uint32 color[2]; + + color[0] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + color[1] = SDL_MapRGBA(surface->format, 0, 0, 0, 255); + SDL_FillRect(surface, NULL, color[0]); + + ox += margin * size; + oy += margin * size; + width = qrcode->width; + p = qrcode->data; + for(y=0; ywidth + 4 * 2) * 4; //maring = 4, size = 4 + SDL_CreateWindowAndRenderer(width, width, SDL_WINDOW_SHOWN, &window, &renderer); + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_RenderClear(renderer); + surface = SDL_CreateRGBSurface(0, width, width, 32, 0, 0, 0, 0); + + draw_QRcode(qrcode, 0, 0, 4, 4, surface); + + texture = SDL_CreateTextureFromSurface(renderer, surface); + SDL_RenderCopy(renderer, texture, NULL, NULL); + SDL_RenderPresent(renderer); + fprintf(stderr, "Press any key on the QR Code window to proceed.\n"); + + int loop = 1; + while(loop) { + SDL_WaitEvent(&event); + if(event.type == SDL_KEYDOWN) { + loop = 0; + } + } + + SDL_FreeSurface(surface); + SDL_DestroyTexture(texture); + SDL_DestroyRenderer(renderer); +} +#else +void show_QRcode(QRcode *qrcode) { +} +#endif diff --git a/tests/common.h b/tests/common.h index a3c869d398..554fcfd2dd 100644 --- a/tests/common.h +++ b/tests/common.h @@ -12,137 +12,17 @@ #include "../bitstream.h" #include "../qrencode_inner.h" +extern int assertionFailed; +extern int assertionNum; +extern const char levelChar[4]; +extern const char *modeStr[5]; + #define testStart(__arg__) (testStartReal(__func__, __arg__)) #define testEndExp(__arg__) (testEnd(!(__arg__))) - -static int tests = 0; -static int failed = 0; -static int assertionFailed = 0; -static int assertionNum = 0; -static const char *testName = NULL; -static const char *testFunc = NULL; -char levelChar[4] = {'L', 'M', 'Q', 'H'}; -const char *modeStr[5] = {"nm", "an", "8", "kj", "st"}; - -void printQRinput(QRinput *input) -{ - QRinput_List *list; - int i; - - list = input->head; - while(list != NULL) { - for(i=0; isize; i++) { - printf("0x%02x,", list->data[i]); - } - list = list->next; - } - printf("\n"); -} - -void printQRinputInfo(QRinput *input) -{ - QRinput_List *list; - BitStream *b; - int i, ret; - - printf("QRinput info:\n"); - printf(" version: %d\n", input->version); - printf(" level : %c\n", levelChar[input->level]); - list = input->head; - i = 0; - while(list != NULL) { - i++; - list = list->next; - } - printf(" chunks: %d\n", i); - b = BitStream_new(); - ret = QRinput_mergeBitStream(input, b); - if(ret == 0) { - printf(" bitstream-size: %d\n", BitStream_size(b)); - BitStream_free(b); - } - - list = input->head; - i = 0; - while(list != NULL) { - printf("\t#%d: mode = %s, size = %d\n", i, modeStr[list->mode], list->size); - i++; - list = list->next; - } -} - -void printQRinputStruct(QRinput_Struct *s) -{ - QRinput_InputList *list; - int i = 1; - - printf("Struct size: %d\n", s->size); - printf("Struct parity: %08x\n", s->parity); - for(list = s->head; list != NULL; list = list->next) { - printf("Symbol %d - ", i); - printQRinputInfo(list->input); - i++; - } -} - -void printFrame(int width, unsigned char *frame) -{ - int x, y; - - for(y=0; ywidth, code->data); -} - -void printQRRawCodeFromQRinput(QRinput *input) -{ - QRRawCode *raw; - int i; - - puts("QRRawCode dump image:"); - raw = QRraw_new(input); - if(raw == NULL) { - puts("Failed to generate QRRawCode from this input.\n"); - return; - } - for(i=0; idataLength; i++) { - printf(" %02x", raw->datacode[i]); - } - for(i=0; ieccLength; i++) { - printf(" %02x", raw->ecccode[i]); - } - printf("\n"); - QRraw_free(raw); -} - -void testStartReal(const char *func, const char *name) -{ - tests++; - testName = name; - testFunc = func; - assertionFailed = 0; - assertionNum = 0; - printf("_____%d: %s: %s...\n", tests, func, name); -} - -void testEnd(int result) -{ - printf(".....%d: %s: %s, ", tests, testFunc, testName); - if(result) { - puts("FAILED."); - failed++; - } else { - puts("PASSED."); - } -} +void testStartReal(const char *func, const char *name); +void testEnd(int result); +void testFinish(void); +void report(); #define assert_exp(__exp__, ...) \ {assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__VA_ARGS__);}} @@ -155,149 +35,19 @@ void testEnd(int result) #define assert_notequal(__e1__, __e2__, ...) assert_exp((__e1__) != (__e2__), __VA_ARGS__) #define assert_nothing(__exp__, ...) {printf(__VA_ARGS__); __exp__;} -void testFinish(void) -{ - printf(".....%d: %s: %s, ", tests, testFunc, testName); - if(assertionFailed) { - printf("FAILED. (%d assertions failed.)\n", assertionFailed); - failed++; - } else { - printf("PASSED. (%d assertions passed.)\n", assertionNum); - } -} - -void report() -{ - printf("Total %d tests, %d fails.\n", tests, failed); - if(failed) exit(-1); -} - -int ncmpBin(char *correct, BitStream *bstream, int len) -{ - int i, bit; - char *p; - - if(len != BitStream_size(bstream)) { - printf("Length is not match: %d, %d expected.\n", BitStream_size(bstream), len); - return -1; - } - - p = correct; - i = 0; - while(*p != '\0') { - while(*p == ' ') { - p++; - } - bit = (*p == '1')?1:0; - if(bstream->data[i] != bit) return -1; - i++; - p++; - if(i == len) break; - } - - return 0; -} - -int cmpBin(char *correct, BitStream *bstream) -{ - int len = 0; - char *p; - - - for(p = correct; *p != '\0'; p++) { - if(*p != ' ') len++; - } - return ncmpBin(correct, bstream, len); -} - -void printBinary(unsigned char *data, int length) -{ - int i; - - for(i=0; idata, BitStream_size(bstream)); -} - -#if HAVE_SDL -/* Experimental debug function */ -/* You can call show_QRcode(QRcode *code) to display the QR Code from anywhere - * in test code using SDL. */ -#include - -static void draw_QRcode(QRcode *qrcode, int ox, int oy, int margin, int size, SDL_Surface *surface) -{ - int x, y, width; - unsigned char *p; - SDL_Rect rect; - Uint32 color[2]; - - color[0] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); - color[1] = SDL_MapRGBA(surface->format, 0, 0, 0, 255); - SDL_FillRect(surface, NULL, color[0]); - - ox += margin * size; - oy += margin * size; - width = qrcode->width; - p = qrcode->data; - for(y=0; ywidth + 4 * 2) * 4; //maring = 4, size = 4 - SDL_CreateWindowAndRenderer(width, width, SDL_WINDOW_SHOWN, &window, &renderer); - SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); - SDL_RenderClear(renderer); - surface = SDL_CreateRGBSurface(0, width, width, 32, 0, 0, 0, 0); - - draw_QRcode(qrcode, 0, 0, 4, 4, surface); +int ncmpBin(char *correct, BitStream *bstream, int len); +int cmpBin(char *correct, BitStream *bstream); - texture = SDL_CreateTextureFromSurface(renderer, surface); - SDL_RenderCopy(renderer, texture, NULL, NULL); - SDL_RenderPresent(renderer); - fprintf(stderr, "Press any key on the QR Code window to proceed.\n"); +void printFrame(int width, unsigned char *frame); +void printQRcode(QRcode *code); +void printQRRawCodeFromQRinput(QRinput *input); +void printQRinput(QRinput *input); +void printQRinputInfo(QRinput *input); +void printQRinputStruct(QRinput_Struct *s); - int loop = 1; - while(loop) { - SDL_WaitEvent(&event); - if(event.type == SDL_KEYDOWN) { - loop = 0; - } - } +void printBinary(unsigned char *data, int length); +void printBstream(BitStream *bstream); - SDL_FreeSurface(surface); - SDL_DestroyTexture(texture); - SDL_DestroyRenderer(renderer); -} -#else -void show_QRcode() { -} -#endif +void show_QRcode(QRcode *qrcode); #endif /* __COMMON_H__ */ diff --git a/tests/decoder.c b/tests/decoder.c index 76ea249818..8eecf46320 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -8,6 +8,7 @@ #include "../mask.h" #include "../mqrspec.h" #include "../mmask.h" +#include "common.h" #include "decoder.h" static unsigned int bitToInt(unsigned char *bits, int length) @@ -673,16 +674,6 @@ BitStream *QRcode_extractBits(QRcode *code, int *dataLength, int *eccLength) return bstream; } -static void printBits(int length, unsigned char *bits) -{ - int i; - - for(i=0; i Date: Fri, 15 Apr 2016 12:19:22 +0900 Subject: Small document improvements. --- README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index 78b44c25e7..126be9ac75 100644 --- a/README +++ b/README @@ -35,9 +35,9 @@ INSTALL Requirements ------------ -Some test programs or utility tools uses SDL or PNG, but the library itself -has no dependencies. You can skip compiling those tools if you want not to -install programs using SDL or PNG. +While the command-line utility and some test programs use libpng or SDL 2.0, +the libqrencode library itself has no dependencies. You can skip compiling +tests and/or tools if you want not to install programs using SDL or PNG. Compile & install ----------------- -- cgit 0.0.5-2-1-g0f52 From c185673632df5affb3238833181514abe5303e35 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 18 May 2016 00:21:52 +0900 Subject: iconv.m4 has been updated to serial 19. --- ChangeLog | 9 +++++++++ acinclude.m4 | 63 +++++++++++++++++++++++++++++++----------------------------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33f4d8ed92..5375b1c477 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2016.05.18 Kentaro Fukuchi + * acinclude.m4: + - iconv.m4 has been updated to serial 19. + +2016.05.15 Kentaro Fukuchi + * configure.ac: + - Merged pull-request #80. (Thanks to @EckoEdc) + - Add LDFLAGS for mingw compilation. + 2016.04.02 Kentaro Fukuchi * tests/common.h: - Code refactoring. diff --git a/acinclude.m4 b/acinclude.m4 index 6f48ebd1b1..bfd896e613 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,5 +1,5 @@ -# iconv.m4 serial 18 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc. +# iconv.m4 serial 19 (gettext-0.18.2) +dnl Copyright (C) 2000-2002, 2007-2014 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -72,27 +72,33 @@ AC_DEFUN([AM_ICONV_LINK], if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ + am_cv_func_iconv_works=no + for ac_iconv_const in '' 'const'; do + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[ #include #include -int main () -{ - int result = 0; + +#ifndef ICONV_CONST +# define ICONV_CONST $ac_iconv_const +#endif + ]], + [[int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { - static const char input[] = "\342\202\254"; /* EURO SIGN */ + static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; - const char *inptr = input; + ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, - (char **) &inptr, &inbytesleft, + &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 1; @@ -105,14 +111,14 @@ int main () iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { - static const char input[] = "\263"; + static ICONV_CONST char input[] = "\263"; char buf[10]; - const char *inptr = input; + ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, - (char **) &inptr, &inbytesleft, + &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 2; @@ -124,14 +130,14 @@ int main () iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { - static const char input[] = "\304"; + static ICONV_CONST char input[] = "\304"; static char buf[2] = { (char)0xDE, (char)0xAD }; - const char *inptr = input; + ICONV_CONST char *inptr = input; size_t inbytesleft = 1; char *outptr = buf; size_t outbytesleft = 1; size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, + &inptr, &inbytesleft, &outptr, &outbytesleft); if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) result |= 4; @@ -144,14 +150,14 @@ int main () iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { - static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; - const char *inptr = input; + ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, + &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) result |= 8; @@ -171,17 +177,14 @@ int main () && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) result |= 16; return result; -}]])], - [am_cv_func_iconv_works=yes], - [am_cv_func_iconv_works=no], - [ -changequote(,)dnl - case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac -changequote([,])dnl - ]) +]])], + [am_cv_func_iconv_works=yes], , + [case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac]) + test "$am_cv_func_iconv_works" = no || break + done LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in -- cgit 0.0.5-2-1-g0f52 From 38bf88744b4e3da8bcddec7802d62dc6af8ab113 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 18 May 2016 02:11:05 +0900 Subject: MinGW support has been improved. --- ChangeLog | 2 ++ Makefile.am | 4 ++++ configure.ac | 6 ++++-- tests/Makefile.am | 18 +++++++++--------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5375b1c477..0dd186e978 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2016.05.18 Kentaro Fukuchi * acinclude.m4: - iconv.m4 has been updated to serial 19. + * configure.ac, Makefile.am, tests/Makefile.am: + - MinGW support has been improved. 2016.05.15 Kentaro Fukuchi * configure.ac: diff --git a/Makefile.am b/Makefile.am index 9c02b81220..b9ff20768c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,3 +37,7 @@ qrencode_CFLAGS = $(png_CFLAGS) qrencode_LDADD = libqrencode.la $(png_LIBS) man1_MANS = qrencode.1 endif + +if MINGW +libqrencode_la_LDFLAGS += -no-undefined -avoid-version -Wl,--nxcompat -Wl,--dynamicbase +endif diff --git a/configure.ac b/configure.ac index c135e628dd..2f1945f6b0 100644 --- a/configure.ac +++ b/configure.ac @@ -35,9 +35,11 @@ AC_PROG_LIBTOOL AC_PROG_RANLIB PKG_PROG_PKG_CONFIG -case "${host}" in -*mingw*) LDFLAGS+="-no-undefined -avoid-version -Wl,--nxcompat -Wl,--dynamicbase" +case "${target}" in +*-*-mingw*) + mingw=yes esac +AM_CONDITIONAL(MINGW, [test "x$mingw" = "xyes" ]) AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 33402b8bcf..c63eccdecf 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,7 +28,7 @@ EXTRA_DIST = frame URI_testset.inc libdecoder_a_SOURCES = decoder.c decoder.h datachunk.c datachunk.h rsecc_decoder.c rsecc_decoder.h test_qrinput_SOURCES = test_qrinput.c common.c -test_qrinput_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_qrinput_LDADD = $(DECODER_LIBS) ../libqrencode.la test_bitstream_SOURCES = test_bitstream.c common.c test_bitstream_LDADD = ../libqrencode.la @@ -37,31 +37,31 @@ test_estimatebit_SOURCES = test_estimatebit.c common.c test_estimatebit_LDADD = ../libqrencode.la test_qrspec_SOURCES = test_qrspec.c common.c -test_qrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_qrspec_LDADD = $(DECODER_LIBS) ../libqrencode.la test_mqrspec_SOURCES = test_mqrspec.c common.c -test_mqrspec_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_mqrspec_LDADD = $(DECODER_LIBS) ../libqrencode.la test_rs_SOURCES = test_rs.c rscode.c common.c -test_rs_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_rs_LDADD = $(DECODER_LIBS) ../libqrencode.la test_qrencode_SOURCES = test_qrencode.c common.c -test_qrencode_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_qrencode_LDADD = $(DECODER_LIBS) ../libqrencode.la test_split_SOURCES = test_split.c common.c test_split_LDADD = ../libqrencode.la test_split_urls_SOURCES = test_split_urls.c common.c -test_split_urls_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_split_urls_LDADD = $(DECODER_LIBS) ../libqrencode.la test_monkey_SOURCES = test_monkey.c common.c -test_monkey_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_monkey_LDADD = $(DECODER_LIBS) ../libqrencode.la test_mask_SOURCES = test_mask.c common.c -test_mask_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_mask_LDADD = $(DECODER_LIBS) ../libqrencode.la test_mmask_SOURCES = test_mmask.c common.c -test_mmask_LDADD = ../libqrencode.la $(DECODER_LIBS) +test_mmask_LDADD = $(DECODER_LIBS) ../libqrencode.la prof_qrencode_SOURCES = prof_qrencode.c common.c prof_qrencode_LDADD = ../libqrencode.la -- cgit 0.0.5-2-1-g0f52 From 5690f92133b6f26bfaa597d6b68c968a28370211 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 18 May 2016 02:22:08 +0900 Subject: ACKNOWLEDGMENTS has been updated. --- ChangeLog | 2 ++ README | 1 + README.md | 1 + 3 files changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0dd186e978..7ccf60a2a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ - iconv.m4 has been updated to serial 19. * configure.ac, Makefile.am, tests/Makefile.am: - MinGW support has been improved. + * README, README.md: + - ACKNOWLEDGMENTS has been updated. 2016.05.15 Kentaro Fukuchi * configure.ac: diff --git a/README b/README index 126be9ac75..d7b938187b 100644 --- a/README +++ b/README @@ -149,6 +149,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - added ability to read input data from a file * @Oblomov - improved SVG support patch * @mgorny - reverse mappings of UTF8 and ANSIUTF8. +* @EckoEdc - MinGW support patch. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, diff --git a/README.md b/README.md index 7293292ef7..ecaaddc331 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - added ability to read input data from a file * @Oblomov - improved SVG support patch * @mgorny - reverse mappings of UTF8 and ANSIUTF8. +* @EckoEdc - MinGW support patch. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 39a56d13249af8112ff217fabcbe6aba0d4f8284 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 18 May 2016 02:32:01 +0900 Subject: Memory leak bug fixed. (Closes #81) --- ChangeLog | 2 ++ README | 6 +++--- README.md | 6 +++--- qrencode.c | 3 +++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ccf60a2a4..562a00e664 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ - MinGW support has been improved. * README, README.md: - ACKNOWLEDGMENTS has been updated. + * qrencode.c: + - Memory leak bug fixed. (Closes #81. Thanks to @win32asm) 2016.05.15 Kentaro Fukuchi * configure.ac: diff --git a/README b/README index d7b938187b..e46e1573eb 100644 --- a/README +++ b/README @@ -153,8 +153,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, - David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, - Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, - Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, + David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), + Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, + Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno - bug report / suggestion diff --git a/README.md b/README.md index ecaaddc331..615fbfd934 100644 --- a/README.md +++ b/README.md @@ -155,8 +155,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, - David Binderman, @ralgozino, Sean McMurray, @win32asm, Antenore Gatta, - Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, - Vlad Bespalov, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, + David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), + Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, + Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno - bug report / suggestion diff --git a/qrencode.c b/qrencode.c index 618701005b..1d7ebec00c 100644 --- a/qrencode.c +++ b/qrencode.c @@ -575,6 +575,9 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) } qrcode = QRcode_new(version, width, masked); + if(qrcode == NULL) { + free(masked); + } EXIT: MQRraw_free(raw); -- cgit 0.0.5-2-1-g0f52 From 1126e261aa528726c8ee56ffd22f85eeda0f719e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 18 May 2016 02:57:28 +0900 Subject: ACKNOWLEDGMENTS has been updated. --- ChangeLog | 1 + README | 4 +++- README.md | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 728afd83a6..8560f15634 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ - ACKNOWLEDGMENTS has been updated. * qrencode.c: - Memory leak bug fixed. (Closes #81. Thanks to @win32asm) + * Various code cleanups. (Merged #72. Thanks to @UniQP) 2016.05.15 Kentaro Fukuchi * configure.ac: diff --git a/README b/README index e46e1573eb..befaae4242 100644 --- a/README +++ b/README @@ -35,7 +35,7 @@ INSTALL Requirements ------------ -While the command-line utility and some test programs use libpng or SDL 2.0, +While the command-line utility and some test programs use libpng or SDL 2.0, the libqrencode library itself has no dependencies. You can skip compiling tests and/or tools if you want not to install programs using SDL or PNG. @@ -150,6 +150,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * @Oblomov - improved SVG support patch * @mgorny - reverse mappings of UTF8 and ANSIUTF8. * @EckoEdc - MinGW support patch. +* Sebastian Buchwald (@UniQP) + - Various code cleanups. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, diff --git a/README.md b/README.md index 615fbfd934..f47a11967d 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ INSTALL Requirements ------------ -Some test programs or utility tools uses SDL or PNG, but the library itself -has no dependencies. You can skip compiling those tools if you want not to -install programs using SDL or PNG. +While the command-line utility and some test programs use libpng or SDL 2.0, +the libqrencode library itself has no dependencies. You can skip compiling +tests and/or tools if you want not to install programs using SDL or PNG. Compile & install ----------------- @@ -152,6 +152,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * @Oblomov - improved SVG support patch * @mgorny - reverse mappings of UTF8 and ANSIUTF8. * @EckoEdc - MinGW support patch. +* Sebastian Buchwald (@UniQP) + - Various code cleanups. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 04dafaac4274ebc22bb21ca0a8f872a91606c976 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Sat, 28 May 2016 19:59:35 +0200 Subject: Remove empty statement --- qrenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index 4c1240c5e4..8ec76ae60b 100644 --- a/qrenc.c +++ b/qrenc.c @@ -892,7 +892,7 @@ static int writeUTF8(const QRcode *qrcode, const char *outfile, int use_ansi, in for (x = 0; x < margin; x++) { fputs(full, fp); - }; + } for (x = 0; x < qrcode->width; x++) { if(row1[x] & 1) { -- cgit 0.0.5-2-1-g0f52 From b2ed28b0fc1ac9d3173fe0fc2ba5a3a3a349cfa5 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Sat, 28 May 2016 20:00:51 +0200 Subject: Remove unreachable code --- qrenc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/qrenc.c b/qrenc.c index 8ec76ae60b..ae6d60ac48 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1248,7 +1248,6 @@ int main(int argc, char **argv) usage(1, 0, EXIT_SUCCESS); } exit(EXIT_SUCCESS); - break; case 'o': outfile = optarg; break; @@ -1290,7 +1289,6 @@ int main(int argc, char **argv) default: fprintf(stderr, "Invalid level: %s\n", optarg); exit(EXIT_FAILURE); - break; } break; case 'm': @@ -1372,13 +1370,11 @@ int main(int argc, char **argv) case 'V': usage(0, 0, EXIT_SUCCESS); exit(EXIT_SUCCESS); - break; case 0: break; default: fprintf(stderr, "Try \"qrencode --help\" for more information.\n"); exit(EXIT_FAILURE); - break; } } -- cgit 0.0.5-2-1-g0f52 From 817d291fe83459fe447a7cc96d97c778939e8e32 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Sat, 28 May 2016 20:38:08 +0200 Subject: Simplify else if combinations --- qrenc.c | 32 ++++++++++++-------------------- qrencode.c | 16 +++++++--------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/qrenc.c b/qrenc.c index ae6d60ac48..e8c9a59ed5 100644 --- a/qrenc.c +++ b/qrenc.c @@ -619,11 +619,9 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) if( !pen ) { pen = *(row+x)&0x1; x0 = x; - } else { - if(!(*(row+x)&0x1)) { - writeSVG_drawModules(fp, x0, y, x-x0, fg, fg_opacity); - pen = 0; - } + } else if(!(*(row+x)&0x1)) { + writeSVG_drawModules(fp, x0, y, x-x0, fg, fg_opacity); + pen = 0; } } if( pen ) { @@ -800,11 +798,9 @@ static int writeANSI(const QRcode *qrcode, const char *outfile) strncat(buffer, black, black_s); last = 1; } - } else { - if( last != 0 ){ - strncat(buffer, white, white_s); - last = 0; - } + } else if( last != 0 ){ + strncat(buffer, white, white_s); + last = 0; } strncat(buffer, " ", 2); } @@ -901,12 +897,10 @@ static int writeUTF8(const QRcode *qrcode, const char *outfile, int use_ansi, in } else { fputs(lowhalf, fp); } + } else if(y < qrcode->width - 1 && row2[x] & 1) { + fputs(uphalf, fp); } else { - if(y < qrcode->width - 1 && row2[x] & 1) { - fputs(uphalf, fp); - } else { - fputs(full, fp); - } + fputs(full, fp); } } @@ -1014,12 +1008,10 @@ static QRcode *encode(const unsigned char *intext, int length) } else { code = QRcode_encodeStringMQR((char *)intext, version, level, hint, casesensitive); } + } else if(eightbit) { + code = QRcode_encodeData(length, intext, version, level); } else { - if(eightbit) { - code = QRcode_encodeData(length, intext, version, level); - } else { - code = QRcode_encodeString((char *)intext, version, level, hint, casesensitive); - } + code = QRcode_encodeString((char *)intext, version, level, hint, casesensitive); } return code; diff --git a/qrencode.c b/qrencode.c index 1d7ebec00c..4e6e80d5c3 100644 --- a/qrencode.c +++ b/qrencode.c @@ -329,15 +329,13 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) y = 9; } } - } else { - if(y == w) { - y = w - 1; - x -= 2; - filler->dir = -1; - if(!filler->mqr && x == 6) { - x--; - y -= 8; - } + } else if(y == w) { + y = w - 1; + x -= 2; + filler->dir = -1; + if(!filler->mqr && x == 6) { + x--; + y -= 8; } } if(x < 0 || y < 0) return NULL; -- cgit 0.0.5-2-1-g0f52 From 86916d6d6967ff755ec37deb4cbb56e922bc0307 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Sat, 28 May 2016 20:38:37 +0200 Subject: Remove superfluous else blocks --- split.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/split.c b/split.c index d894aa5eef..4ba7a7404a 100644 --- a/split.c +++ b/split.c @@ -142,9 +142,8 @@ static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint) - QRinput_estimateBitsModeAn(q - string) /* - 4 - la */; if(dif < 0) { break; - } else { - p = q; } + p = q; } else { p++; } @@ -220,9 +219,8 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) - QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */; if(dif < 0) { break; - } else { - p = q; } + p = q; } else if(mode == QR_MODE_AN) { q = p; while(isalnum(*q)) { @@ -239,9 +237,8 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) - QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */; if(dif < 0) { break; - } else { - p = q; } + p = q; } else { p++; } -- cgit 0.0.5-2-1-g0f52 From aa6078490f6d9409436f8e43b6fc6dc057d80474 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Sat, 28 May 2016 20:39:16 +0200 Subject: Fix typos --- qrencode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrencode.c b/qrencode.c index 4e6e80d5c3..f43ad7c9c4 100644 --- a/qrencode.c +++ b/qrencode.c @@ -462,7 +462,7 @@ __STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) } FrameFiller_set(&filler, width, frame, 0); - /* inteleaved data and ecc codes */ + /* interleaved data and ecc codes */ for(i = 0; i < raw->dataLength + raw->eccLength; i++) { code = QRraw_getCode(raw); bit = 0x80; @@ -540,7 +540,7 @@ __STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) } FrameFiller_set(&filler, width, frame, 1); - /* inteleaved data and ecc codes */ + /* interleaved data and ecc codes */ for(i = 0; i < raw->dataLength + raw->eccLength; i++) { code = MQRraw_getCode(raw); bit = 0x80; -- cgit 0.0.5-2-1-g0f52 From 247559ebfe4bb41e8634d7509e4155a6a9cf6455 Mon Sep 17 00:00:00 2001 From: André Klitzing Date: Thu, 16 Jun 2016 08:09:07 +0200 Subject: Add CMakeLists.txt to build project with cmake This will help to build library on non-unix systems. Example Linux: cmake . -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=true -DCMAKE_BUILD_TYPE=release make make install Example MinGW: cmake . -DBUILD_SHARED_LIBS=true -DCMAKE_BUILD_TYPE=release -G "MinGW Makefiles" mingw32-make closes #78 --- .gitignore | 4 ++++ CMakeLists.txt | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index 8db4f08f47..cdde2d2c3f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,10 @@ .libs/ autom4te.cache/ m4/ +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake Makefile Makefile.in config.log diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..90cf4baff1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,70 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) + +PROJECT(QREncodingLibrary VERSION 4.0.0 LANGUAGES C) + + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") + +OPTION(GPROF "Generate extra code to write profile information" OFF) +IF(GPROF) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") +ENDIF() + +OPTION(COVERAGE "Generate extra code to write coverage information" OFF) +IF(COVERAGE) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") +ENDIF() + +OPTION(ASAN "Use AddressSanitizer" OFF) +IF(ASAN) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls") +ENDIF() + +ADD_DEFINITIONS(-DMAJOR_VERSION=${PROJECT_VERSION_MAJOR}) +ADD_DEFINITIONS(-DMINOR_VERSION=${PROJECT_VERSION_MINOR}) +ADD_DEFINITIONS(-DMICRO_VERSION=${PROJECT_VERSION_PATCH}) +ADD_DEFINITIONS(-DVERSION="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") +ADD_DEFINITIONS(-D__STATIC=) + + +SET(LIB_FILES qrencode.c + qrinput.c + bitstream.c + qrspec.c + rsecc.c + split.c + mask.c + mqrspec.c + mmask.c) +ADD_LIBRARY(qrencode ${LIB_FILES}) +OPTION(BUILD_SHARED_LIBS "Enable build of shared libraries") + + +SET(EXE_FILES qrenc.c) +ADD_EXECUTABLE(qrenc ${EXE_FILES} ${PNG_LIBRARIES}) +SET_TARGET_PROPERTIES(qrenc PROPERTIES OUTPUT_NAME "qrencode") +TARGET_LINK_LIBRARIES(qrenc qrencode) + + +FIND_PACKAGE(PNG) +IF(PNG_FOUND) + ADD_DEFINITIONS(-DHAVE_PNG=1) + IF(TARGET PNG::PNG) + TARGET_LINK_LIBRARIES(qrenc PNG::PNG) + ELSE() + TARGET_INCLUDE_DIRECTORIES(qrenc SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) + TARGET_LINK_LIBRARIES(qrenc ${PNG_LIBRARIES}) + ADD_DEFINITIONS(${PNG_DEFINITIONS}) + ENDIF() +ENDIF() + +INSTALL(TARGETS qrenc DESTINATION bin) +CONFIGURE_FILE(qrencode.1.in qrencode.1 @ONLY) +INSTALL(FILES qrencode.1 DESTINATION share/man/man1) +IF(BUILD_SHARED_LIBS) + CONFIGURE_FILE(libqrencode.pc.in libqrencode.pc @ONLY) + INSTALL(FILES libqrencode.pc DESTINATION lib/pkgconfig) + INSTALL(TARGETS qrencode DESTINATION lib) + INSTALL(FILES qrencode.h DESTINATION include) +ENDIF() + -- cgit 0.0.5-2-1-g0f52 From 7eb1629e1b1fb70c3923312f092451ac68c51851 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 18 Sep 2016 17:37:58 +0900 Subject: Added some notes about CMake. --- ChangeLog | 9 +++++++++ README | 7 +++++++ README.md | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8560f15634..d08b027eda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2016.09.18 Kentaro Fukuchi + * CMakeLists.txt: + - Merged #83. (Thansk to @misery) + - This allows CMake users building the library without configure script. + IF you are using incomplete UNIX-like environment and configure script + does not work as expected, try CMake. + * README, README.md: + - Added some notes about CMake. + 2016.05.18 Kentaro Fukuchi * acinclude.m4: - iconv.m4 has been updated to serial 19. diff --git a/README b/README index befaae4242..42298a61c0 100644 --- a/README +++ b/README @@ -59,6 +59,11 @@ install it, give "--without-tools" option to the configure script. When you downloaded a development tree from github, it is required to run "autogen.sh" at first to generate configure script. +If the configure script does not work well, try CMake contributed by André. + +cmake . +make + USAGE ===== @@ -152,6 +157,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * @EckoEdc - MinGW support patch. * Sebastian Buchwald (@UniQP) - Various code cleanups. +* André Klitzing (@misery) + - CMake support. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, diff --git a/README.md b/README.md index f47a11967d..c8f14fc9ff 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,13 @@ install it, give "--without-tools" option to the configure script. When you downloaded a development tree from github, it is required to run "autogen.sh" at first to generate configure script. +If the configure script does not work well, try CMake contributed by André. + +``` +cmake . +make +``` + USAGE ===== @@ -154,6 +161,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * @EckoEdc - MinGW support patch. * Sebastian Buchwald (@UniQP) - Various code cleanups. +* André Klitzing (@misery) + - CMake support. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 95e8c05bbb47b5d47689ecbcf3fcae4515f87c73 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 19 Sep 2016 13:05:32 +0900 Subject: Merged #82. --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index d08b027eda..604aeba768 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016.09.19 Kentaro Fukuchi + * qrenc.c, qrencode.c, split.c: + - Merged #82. (Thanks to @UniQP) + - Various code cleanups. + 2016.09.18 Kentaro Fukuchi * CMakeLists.txt: - Merged #83. (Thansk to @misery) -- cgit 0.0.5-2-1-g0f52 From 319c2da1d56bbc13ee5d1ed779558a553f9f6954 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 19 Sep 2016 13:14:45 +0900 Subject: Renamed reserved identifiers. --- ChangeLog | 5 +++++ bitstream.h | 6 +++--- configure.ac | 6 +++--- mask.c | 12 ++++++------ mask.h | 6 +++--- mmask.c | 4 ++-- mmask.h | 6 +++--- mqrspec.h | 6 +++--- qrencode.c | 22 +++++++++++----------- qrencode.h | 6 +++--- qrencode_inner.h | 6 +++--- qrinput.c | 12 ++++++------ qrinput.h | 6 +++--- qrspec.h | 6 +++--- rsecc.h | 6 +++--- split.h | 6 +++--- 16 files changed, 63 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 604aeba768..15f1a7db21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ * qrenc.c, qrencode.c, split.c: - Merged #82. (Thanks to @UniQP) - Various code cleanups. + * *.h: + - Removed double underscores (__) from macro names in include guards. + (follows C99 standard) + * configure.ac, *.c: + - Renamed __STATIC macro to STATIC_IN_RELEASE. (follows C99 standard) 2016.09.18 Kentaro Fukuchi * CMakeLists.txt: diff --git a/bitstream.h b/bitstream.h index ce4d7e0e5d..e138ec5ff9 100644 --- a/bitstream.h +++ b/bitstream.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __BITSTREAM_H__ -#define __BITSTREAM_H__ +#ifndef BITSTREAM_H +#define BITSTREAM_H typedef struct { int length; @@ -40,4 +40,4 @@ extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *da extern unsigned char *BitStream_toByte(BitStream *bstream); extern void BitStream_free(BitStream *bstream); -#endif /* __BITSTREAM_H__ */ +#endif /* BITSTREAM_H */ diff --git a/configure.ac b/configure.ac index 2f1945f6b0..1c34dc2852 100644 --- a/configure.ac +++ b/configure.ac @@ -88,14 +88,14 @@ AC_ARG_WITH([tests], [AS_HELP_STRING([--with-tests], [build tests [default=no]]) AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes" ]) AH_VERBATIM([tests], [/* Define to 'static' if no test programs will be compiled. */ -#define __STATIC static +#define STATIC_IN_RELEASE static #undef WITH_TESTS ]) if test x$build_tests = xyes ; then -echo "#define __STATIC" >>confdefs.h +echo "#define STATIC_IN_RELEASE" >>confdefs.h echo "#define WITH_TESTS 1" >>confdefs.h else -echo "#define __STATIC static" >>confdefs.h +echo "#define STATIC_IN_RELEASE static" >>confdefs.h echo "/* #undef WITH_TESTS */" >>confdefs.h fi diff --git a/mask.c b/mask.c index 1033b58e3c..dea1a079ba 100644 --- a/mask.c +++ b/mask.c @@ -31,7 +31,7 @@ #include "qrspec.h" #include "mask.h" -__STATIC int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level) +STATIC_IN_RELEASE int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level) { unsigned int format; unsigned char v; @@ -185,7 +185,7 @@ unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLeve //static int n3; //static int n4; -__STATIC int Mask_calcN1N3(int length, int *runLength) +STATIC_IN_RELEASE int Mask_calcN1N3(int length, int *runLength) { int i; int demerit = 0; @@ -218,7 +218,7 @@ __STATIC int Mask_calcN1N3(int length, int *runLength) return demerit; } -__STATIC int Mask_calcN2(int width, unsigned char *frame) +STATIC_IN_RELEASE int Mask_calcN2(int width, unsigned char *frame) { int x, y; unsigned char *p; @@ -241,7 +241,7 @@ __STATIC int Mask_calcN2(int width, unsigned char *frame) return demerit; } -__STATIC int Mask_calcRunLengthH(int width, unsigned char *frame, int *runLength) +STATIC_IN_RELEASE int Mask_calcRunLengthH(int width, unsigned char *frame, int *runLength) { int head; int i; @@ -269,7 +269,7 @@ __STATIC int Mask_calcRunLengthH(int width, unsigned char *frame, int *runLength return head + 1; } -__STATIC int Mask_calcRunLengthV(int width, unsigned char *frame, int *runLength) +STATIC_IN_RELEASE int Mask_calcRunLengthV(int width, unsigned char *frame, int *runLength) { int head; int i; @@ -297,7 +297,7 @@ __STATIC int Mask_calcRunLengthV(int width, unsigned char *frame, int *runLength return head + 1; } -__STATIC int Mask_evaluateSymbol(int width, unsigned char *frame) +STATIC_IN_RELEASE int Mask_evaluateSymbol(int width, unsigned char *frame) { int x, y; int demerit = 0; diff --git a/mask.h b/mask.h index 1750686469..28c3afef8f 100644 --- a/mask.h +++ b/mask.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __MASK_H__ -#define __MASK_H__ +#ifndef MASK_H +#define MASK_H extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level); extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); @@ -35,4 +35,4 @@ extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); #endif -#endif /* __MASK_H__ */ +#endif /* MASK_H */ diff --git a/mmask.c b/mmask.c index babdaec4fd..143c51259e 100644 --- a/mmask.c +++ b/mmask.c @@ -31,7 +31,7 @@ #include "mqrspec.h" #include "mmask.h" -__STATIC void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level) +STATIC_IN_RELEASE void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level) { unsigned int format; unsigned char v; @@ -125,7 +125,7 @@ unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecL return masked; } -__STATIC int MMask_evaluateSymbol(int width, unsigned char *frame) +STATIC_IN_RELEASE int MMask_evaluateSymbol(int width, unsigned char *frame) { int x, y; unsigned char *p; diff --git a/mmask.h b/mmask.h index f6556e877d..57229a450a 100644 --- a/mmask.h +++ b/mmask.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __MMASK_H__ -#define __MMASK_H__ +#ifndef MMASK_H +#define MMASK_H extern unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level); extern unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level); @@ -31,4 +31,4 @@ extern void MMask_writeFormatInformation(int version, int width, unsigned char * extern unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask); #endif -#endif /* __MMASK_H__ */ +#endif /* MMASK_H */ diff --git a/mqrspec.h b/mqrspec.h index 4d1202c8e6..291783f63a 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __MQRSPEC_H__ -#define __MQRSPEC_H__ +#ifndef MQRSPEC_H +#define MQRSPEC_H #include "qrencode.h" @@ -149,4 +149,4 @@ extern unsigned char *MQRspec_newFrame(int version); #define MQRSPEC_MODEID_8 2 #define MQRSPEC_MODEID_KANJI 3 -#endif /* __MQRSPEC_H__ */ +#endif /* MQRSPEC_H */ diff --git a/qrencode.c b/qrencode.c index f43ad7c9c4..6c948a0a25 100644 --- a/qrencode.c +++ b/qrencode.c @@ -103,8 +103,8 @@ static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsig return 0; } -__STATIC void QRraw_free(QRRawCode *raw); -__STATIC QRRawCode *QRraw_new(QRinput *input) +STATIC_IN_RELEASE void QRraw_free(QRRawCode *raw); +STATIC_IN_RELEASE QRRawCode *QRraw_new(QRinput *input) { QRRawCode *raw; int spec[5], ret; @@ -154,7 +154,7 @@ __STATIC QRRawCode *QRraw_new(QRinput *input) * @param raw raw code. * @return code */ -__STATIC unsigned char QRraw_getCode(QRRawCode *raw) +STATIC_IN_RELEASE unsigned char QRraw_getCode(QRRawCode *raw) { int col, row; unsigned char ret; @@ -177,7 +177,7 @@ __STATIC unsigned char QRraw_getCode(QRRawCode *raw) return ret; } -__STATIC void QRraw_free(QRRawCode *raw) +STATIC_IN_RELEASE void QRraw_free(QRRawCode *raw) { if(raw != NULL) { free(raw->datacode); @@ -202,8 +202,8 @@ typedef struct { int count; } MQRRawCode; -__STATIC void MQRraw_free(MQRRawCode *raw); -__STATIC MQRRawCode *MQRraw_new(QRinput *input) +STATIC_IN_RELEASE void MQRraw_free(MQRRawCode *raw); +STATIC_IN_RELEASE MQRRawCode *MQRraw_new(QRinput *input) { MQRRawCode *raw; @@ -245,7 +245,7 @@ __STATIC MQRRawCode *MQRraw_new(QRinput *input) * @param raw raw code. * @return code */ -__STATIC unsigned char MQRraw_getCode(MQRRawCode *raw) +STATIC_IN_RELEASE unsigned char MQRraw_getCode(MQRRawCode *raw) { unsigned char ret; @@ -260,7 +260,7 @@ __STATIC unsigned char MQRraw_getCode(MQRRawCode *raw) return ret; } -__STATIC void MQRraw_free(MQRRawCode *raw) +STATIC_IN_RELEASE void MQRraw_free(MQRRawCode *raw) { if(raw != NULL) { free(raw->datacode); @@ -406,7 +406,7 @@ extern unsigned char *FrameFiller_testMQR(int version) * QR-code encoding *****************************************************************************/ -__STATIC QRcode *QRcode_new(int version, int width, unsigned char *data) +STATIC_IN_RELEASE QRcode *QRcode_new(int version, int width, unsigned char *data) { QRcode *qrcode; @@ -428,7 +428,7 @@ void QRcode_free(QRcode *qrcode) } } -__STATIC QRcode *QRcode_encodeMask(QRinput *input, int mask) +STATIC_IN_RELEASE QRcode *QRcode_encodeMask(QRinput *input, int mask) { int width, version; QRRawCode *raw; @@ -506,7 +506,7 @@ EXIT: return qrcode; } -__STATIC QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) +STATIC_IN_RELEASE QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) { int width, version; MQRRawCode *raw; diff --git a/qrencode.h b/qrencode.h index b121b3ba9f..eaef5dd859 100644 --- a/qrencode.h +++ b/qrencode.h @@ -96,8 +96,8 @@ * encoding symbols. */ -#ifndef __QRENCODE_H__ -#define __QRENCODE_H__ +#ifndef QRENCODE_H +#define QRENCODE_H #if defined(__cplusplus) extern "C" { @@ -556,4 +556,4 @@ extern char *QRcode_APIVersionString(void); } #endif -#endif /* __QRENCODE_H__ */ +#endif /* QRENCODE_H */ diff --git a/qrencode_inner.h b/qrencode_inner.h index 3c40d0622a..f78136fa8e 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __QRENCODE_INNER_H__ -#define __QRENCODE_INNER_H__ +#ifndef QRENCODE_INNER_H +#define QRENCODE_INNER_H /** * This header file includes definitions for test use. @@ -85,4 +85,4 @@ extern QRcode *QRcode_encodeMask(QRinput *input, int mask); extern QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask); extern QRcode *QRcode_new(int version, int width, unsigned char *data); -#endif /* __QRENCODE_INNER_H__ */ +#endif /* QRENCODE_INNER_H */ diff --git a/qrinput.c b/qrinput.c index ab196cd100..71c619fb04 100644 --- a/qrinput.c +++ b/qrinput.c @@ -245,7 +245,7 @@ int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned c * @throw EINVAL invalid parameter. * @throw ENOMEM unable to allocate memory. */ -__STATIC int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int number, unsigned char parity) +STATIC_IN_RELEASE int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int number, unsigned char parity) { QRinput_List *entry; unsigned char buf[3]; @@ -910,7 +910,7 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version * @param version version of the symbol * @return number of bits */ -__STATIC int QRinput_estimateBitStreamSize(QRinput *input, int version) +STATIC_IN_RELEASE int QRinput_estimateBitStreamSize(QRinput *input, int version) { QRinput_List *list; int bits = 0; @@ -951,7 +951,7 @@ static int QRinput_estimateVersion(QRinput *input) * @param bits * @return required length of code words in bytes. */ -__STATIC int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) +STATIC_IN_RELEASE int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) { int payload, size, chunks, remain, maxsize; @@ -1263,7 +1263,7 @@ static int QRinput_insertFNC1Header(QRinput *input) * @return merged bit stream */ -__STATIC int QRinput_mergeBitStream(QRinput *input, BitStream *bstream) +STATIC_IN_RELEASE int QRinput_mergeBitStream(QRinput *input, BitStream *bstream) { if(input->mqr) { if(QRinput_createBitStream(input, bstream) < 0) { @@ -1289,7 +1289,7 @@ __STATIC int QRinput_mergeBitStream(QRinput *input, BitStream *bstream) * @return padded merged bit stream */ -__STATIC int QRinput_getBitStream(QRinput *input, BitStream *bstream) +STATIC_IN_RELEASE int QRinput_getBitStream(QRinput *input, BitStream *bstream) { int ret; @@ -1449,7 +1449,7 @@ static int QRinput_List_shrinkEntry(QRinput_List *entry, int bytes) return 0; } -__STATIC int QRinput_splitEntry(QRinput_List *entry, int bytes) +STATIC_IN_RELEASE int QRinput_splitEntry(QRinput_List *entry, int bytes) { QRinput_List *e; int ret; diff --git a/qrinput.h b/qrinput.h index dd6dcf35d4..432fb44357 100644 --- a/qrinput.h +++ b/qrinput.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __QRINPUT_H__ -#define __QRINPUT_H__ +#ifndef QRINPUT_H +#define QRINPUT_H #include "qrencode.h" #include "bitstream.h" @@ -120,4 +120,4 @@ extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); #endif -#endif /* __QRINPUT_H__ */ +#endif /* QRINPUT_H */ diff --git a/qrspec.h b/qrspec.h index f28af81f1e..d8cbcc9a51 100644 --- a/qrspec.h +++ b/qrspec.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __QRSPEC_H__ -#define __QRSPEC_H__ +#ifndef QRSPEC_H +#define QRSPEC_H #include "qrencode.h" @@ -171,4 +171,4 @@ extern unsigned char *QRspec_newFrame(int version); #define QRSPEC_MODEID_STRUCTURE 3 #define QRSPEC_MODEID_TERMINATOR 0 -#endif /* __QRSPEC_H__ */ +#endif /* QRSPEC_H */ diff --git a/rsecc.h b/rsecc.h index 41941e9eb2..a9374c003a 100644 --- a/rsecc.h +++ b/rsecc.h @@ -23,9 +23,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __RSECC_H__ -#define __RSECC_H__ +#ifndef RSECC_H +#define RSECC_H extern int RSECC_encode(int data_length, int ecc_length, const unsigned char *data, unsigned char *ecc); -#endif /* __RSECC_H__ */ +#endif /* RSECC_H */ diff --git a/split.h b/split.h index 829a34453b..4c97c3dee1 100644 --- a/split.h +++ b/split.h @@ -25,8 +25,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __SPLIT_H__ -#define __SPLIT_H__ +#ifndef SPLIT_H +#define SPLIT_H #include "qrencode.h" @@ -44,4 +44,4 @@ extern int Split_splitStringToQRinput(const char *string, QRinput *input, QRencodeMode hint, int casesensitive); -#endif /* __SPLIT_H__ */ +#endif /* SPLIT_H */ -- cgit 0.0.5-2-1-g0f52 From a119d72a7b14d90be86ee2cc21ffdf5a93d2e132 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 19 Sep 2016 13:54:17 +0900 Subject: Removed unnecessary 'extern' from some functions. --- ChangeLog | 4 +++- qrencode.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15f1a7db21..21ef7cec4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,10 +7,12 @@ (follows C99 standard) * configure.ac, *.c: - Renamed __STATIC macro to STATIC_IN_RELEASE. (follows C99 standard) + * qrencode.c: + - Removed unnecessary 'extern' from some functions. 2016.09.18 Kentaro Fukuchi * CMakeLists.txt: - - Merged #83. (Thansk to @misery) + - Merged #83. (Thanks to @misery) - This allows CMake users building the library without configure script. IF you are using incomplete UNIX-like environment and configure script does not work as expected, try CMake. diff --git a/qrencode.c b/qrencode.c index 6c948a0a25..b55f43c9e2 100644 --- a/qrencode.c +++ b/qrencode.c @@ -351,7 +351,7 @@ static unsigned char *FrameFiller_next(FrameFiller *filler) } #ifdef WITH_TESTS -extern unsigned char *FrameFiller_test(int version) +unsigned char *FrameFiller_test(int version) { int width; unsigned char *frame, *p; @@ -376,7 +376,7 @@ extern unsigned char *FrameFiller_test(int version) return frame; } -extern unsigned char *FrameFiller_testMQR(int version) +unsigned char *FrameFiller_testMQR(int version) { int width; unsigned char *frame, *p; -- cgit 0.0.5-2-1-g0f52 From f0f0dd3f41ce8f685d4b2006adb813158b10d029 Mon Sep 17 00:00:00 2001 From: André Klitzing Date: Tue, 27 Sep 2016 13:45:17 +0200 Subject: Fix cmake build and add support for tests --- .gitignore | 1 + .travis.yml | 18 +++++++++++++----- CMakeLists.txt | 14 +++++++++++--- tests/CMakeLists.txt | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/common.h | 2 ++ tests/decoder.c | 2 ++ 6 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 tests/CMakeLists.txt diff --git a/.gitignore b/.gitignore index cdde2d2c3f..2c3a96eb50 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ CMakeFiles/ cmake_install.cmake Makefile Makefile.in +build config.log configure config.status diff --git a/.travis.yml b/.travis.yml index 57935372df..ba1c6ecfe1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,18 +3,26 @@ language: c compiler: - gcc -install: +before_install: - sudo apt-get update - sudo apt-get install libsdl-image1.2-dev - sudo apt-get install libpng12-dev + +install: - ./autogen.sh - ./configure --with-tests && make - sudo make install - -before_script: -- cd tests -- ./create_frame_pattern frame +- mkdir build && cd build +- wget https://cmake.org/files/v3.1/cmake-3.1.0-Linux-x86_64.tar.gz +- tar xf cmake-3.1.0-Linux-x86_64.tar.gz +- ./cmake-3.1.0-Linux-x86_64/bin/cmake .. -DBUILD_SHARED_LIBS=on -DBUILD_TESTING=on && make +- DESTDIR=$PWD/install make install script: +- cd $TRAVIS_BUILD_DIR/tests +- ./create_frame_pattern frame - ./test_configure.sh - ./test_all.sh +- cd $TRAVIS_BUILD_DIR/build/tests +- ./create_frame_pattern frame +- make test diff --git a/CMakeLists.txt b/CMakeLists.txt index 90cf4baff1..fc584dc4f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ ADD_DEFINITIONS(-DMAJOR_VERSION=${PROJECT_VERSION_MAJOR}) ADD_DEFINITIONS(-DMINOR_VERSION=${PROJECT_VERSION_MINOR}) ADD_DEFINITIONS(-DMICRO_VERSION=${PROJECT_VERSION_PATCH}) ADD_DEFINITIONS(-DVERSION="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -ADD_DEFINITIONS(-D__STATIC=) +ADD_DEFINITIONS(-DSTATIC_IN_RELEASE=) SET(LIB_FILES qrencode.c @@ -46,6 +46,8 @@ SET_TARGET_PROPERTIES(qrenc PROPERTIES OUTPUT_NAME "qrencode") TARGET_LINK_LIBRARIES(qrenc qrencode) +ADD_DEFINITIONS(-DHAVE_SDL=0) + FIND_PACKAGE(PNG) IF(PNG_FOUND) ADD_DEFINITIONS(-DHAVE_PNG=1) @@ -60,11 +62,17 @@ ENDIF() INSTALL(TARGETS qrenc DESTINATION bin) CONFIGURE_FILE(qrencode.1.in qrencode.1 @ONLY) -INSTALL(FILES qrencode.1 DESTINATION share/man/man1) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION share/man/man1) IF(BUILD_SHARED_LIBS) CONFIGURE_FILE(libqrencode.pc.in libqrencode.pc @ONLY) - INSTALL(FILES libqrencode.pc DESTINATION lib/pkgconfig) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION lib/pkgconfig) INSTALL(TARGETS qrencode DESTINATION lib) INSTALL(FILES qrencode.h DESTINATION include) ENDIF() + +IF(BUILD_TESTING) + ENABLE_TESTING() + ADD_DEFINITIONS(-DWITH_TESTS=) + ADD_SUBDIRECTORY(tests) +ENDIF() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000000..e89766da67 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,50 @@ +IF(NOT PNG_FOUND) + MESSAGE(FATAL_ERROR "PNG is required for tests") +ENDIF() + + +SET(TEST_FILES test_bitstream.c + test_estimatebit.c + test_mask.c + test_mmask.c + test_monkey.c + test_mqrspec.c + test_qrencode.c + test_qrinput.c + test_qrspec.c + test_rs.c + test_split.c + test_split_urls.c) + +SET(TEST_COMMON_FILES common.c + decoder.c + datachunk.c + rsecc_decoder.c + rscode.c) + + +ADD_EXECUTABLE(create_frame_pattern create_frame_pattern.c ${TEST_COMMON_FILES}) +ADD_EXECUTABLE(create_mqr_frame_pattern create_mqr_frame_pattern.c ${TEST_COMMON_FILES}) +TARGET_LINK_LIBRARIES(create_frame_pattern qrencode) +TARGET_LINK_LIBRARIES(create_mqr_frame_pattern qrencode) + +IF(TARGET PNG::PNG) + TARGET_LINK_LIBRARIES(create_frame_pattern PNG::PNG) + TARGET_LINK_LIBRARIES(create_mqr_frame_pattern PNG::PNG) +ELSE() + TARGET_INCLUDE_DIRECTORIES(create_frame_pattern SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) + TARGET_LINK_LIBRARIES(create_frame_pattern ${PNG_LIBRARIES}) + + TARGET_INCLUDE_DIRECTORIES(create_mqr_frame_pattern SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) + TARGET_LINK_LIBRARIES(create_mqr_frame_pattern ${PNG_LIBRARIES}) +ENDIF() + + + +FOREACH(testfile ${TEST_FILES}) + SET(binary ${testfile}.bin) + ADD_EXECUTABLE(${binary} ${testfile} ${TEST_COMMON_FILES}) + TARGET_LINK_LIBRARIES(${binary} qrencode) + ADD_TEST(${testfile} ${binary}) +ENDFOREACH() + diff --git a/tests/common.h b/tests/common.h index 554fcfd2dd..d68ef03f53 100644 --- a/tests/common.h +++ b/tests/common.h @@ -6,7 +6,9 @@ #define __COMMON_H__ #include +#if HAVE_CONFIG_H #include "../config.h" +#endif #include "../qrencode.h" #include "../qrinput.h" #include "../bitstream.h" diff --git a/tests/decoder.c b/tests/decoder.c index d851a62292..a07bb7175d 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -2,7 +2,9 @@ #include #include #include +#if HAVE_CONFIG_H #include "../config.h" +#endif #include "../qrspec.h" #include "../bitstream.h" #include "../mask.h" -- cgit 0.0.5-2-1-g0f52 From ad32a9533501e4c8734e736841cead29c911e2d1 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 17 Nov 2016 10:10:28 +0900 Subject: Merged #85. (Thanks to @misery) --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 21ef7cec4e..09e85bfb62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016.11.17 Kentaro Fukuchi + * CMakeLists.txt, tests/CMakeLists.txt, travis.yml, tests/common.h, + tests/decoder.c, .gitignore: + - Merged #85. (Thanks to @misery) + 2016.09.19 Kentaro Fukuchi * qrenc.c, qrencode.c, split.c: - Merged #82. (Thanks to @UniQP) -- cgit 0.0.5-2-1-g0f52 From 9a525f3c9ee8f9de2625fbb4da01eeef001a9026 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 17 Nov 2016 17:10:23 +0900 Subject: Release note has been updated. --- ChangeLog | 2 ++ NEWS | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 09e85bfb62..ceae54baff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * CMakeLists.txt, tests/CMakeLists.txt, travis.yml, tests/common.h, tests/decoder.c, .gitignore: - Merged #85. (Thanks to @misery) + * NEWS: + - Release note for version 4 has been updated. 2016.09.19 Kentaro Fukuchi * qrenc.c, qrencode.c, split.c: diff --git a/NEWS b/NEWS index 42b605b7fb..bb534977c8 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.0.0 (2015.x.x) +Version 4.0.0 (2016.x.x) ------------------------ * Memory efficiency has been improved. * Error correction code generating functions have been improved. @@ -10,13 +10,21 @@ Version 4.0.0 (2015.x.x) * PNG32 (direct color mode) support. (Thanks to Greg Hart) * EPS output now supports foreground and background color. * New options "-r" and "--svg-path" have been added. +* CMake support has been added. (optional) * Various bug fixes. -* Various improves for developers. +* Various performance improvements. Release Note: -While no API changes are introduced with this major update, we incremented the -major version number of libqrencode to 4, because its internal are widely -improved. +While the API is not changed from previous major release, we incremented the +major version number of libqrencode to 4. + +This release improves the performance of code generation. Its memory footprint +is also reduced. + +Now you can build libqrencode with CMake optionally. + +If you are going to build the test programs, please note that required SDL +version is changed from 1.2 to 2.0. Version 3.4.4 (2014.7.24) -- cgit 0.0.5-2-1-g0f52 From 49b0875e9780870a910bbc340facc7bd0a5a91fa Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 17 Nov 2016 18:37:05 +0900 Subject: Three cheers for Google translate! --- NEWS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index bb534977c8..df6f18c8cb 100644 --- a/NEWS +++ b/NEWS @@ -15,16 +15,16 @@ Version 4.0.0 (2016.x.x) * Various performance improvements. Release Note: -While the API is not changed from previous major release, we incremented the -major version number of libqrencode to 4. +While the API has not been changed since the previous major release, we +incremented the major version number of libqrencode to 4. This release improves the performance of code generation. Its memory footprint is also reduced. Now you can build libqrencode with CMake optionally. -If you are going to build the test programs, please note that required SDL -version is changed from 1.2 to 2.0. +When building the test programs, please note that the required SDL version has +changed from 1.2 to 2.0. Version 3.4.4 (2014.7.24) -- cgit 0.0.5-2-1-g0f52 From 06b0dc037f2e32ad76d6cc49922fa3373ffd9826 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 20 Nov 2016 00:14:37 +0900 Subject: Some warnings suppressed. --- ChangeLog | 6 +++++- tests/test_qrinput.c | 2 +- tests/test_qrspec.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ceae54baff..e3474e2541 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,11 @@ +2016.11.20 Kentaro Fukuchi + * tests/test_qrinput.c, tests/test_qrspec.c: + - Some warnings suppresed. + 2016.11.17 Kentaro Fukuchi * CMakeLists.txt, tests/CMakeLists.txt, travis.yml, tests/common.h, tests/decoder.c, .gitignore: - - Merged #85. (Thanks to @misery) + - Merged #85. (Thanks to @misery) * NEWS: - Release note for version 4 has been updated. diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index b937c19365..cf510c19c0 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -57,7 +57,7 @@ int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct) void test_encodeKanji(void) { - char str[5]= {0x93, 0x5f,0xe4, 0xaa, 0x00}; + char str[5]= {0x93, 0x5f, 0xe4, 0xaa, 0x00}; char *correct = "10000000001001101100111111101010101010"; testStart("Encoding kanji stream."); diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 139b592cee..756adbf66d 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -145,7 +145,7 @@ void test_newframe(void) assert_zero(memcmp(frame, buf, len), "frame pattern mismatch (version %d)\n", i); qrcode = QRcode_new(i, width, frame); version = QRcode_decodeVersion(qrcode); - assert_equal(version, i, "Decoded version number is wrong: %d, expected %d.\n", version, i); + assert_equal(version, (unsigned int)i, "Decoded version number is wrong: %d, expected %d.\n", version, i); QRcode_free(qrcode); } -- cgit 0.0.5-2-1-g0f52 From 2bad46ea287bfb62def83ee038ad3bb8b9ccc8b6 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Fri, 13 Jan 2017 13:13:44 +0300 Subject: cmake command case --- CMakeLists.txt | 110 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc584dc4f0..142c8be6b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,33 +1,33 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) +cmake_minimum_required(VERSION 3.1.0) -PROJECT(QREncodingLibrary VERSION 4.0.0 LANGUAGES C) +project(QREncodingLibrary VERSION 4.0.0 LANGUAGES C) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -OPTION(GPROF "Generate extra code to write profile information" OFF) -IF(GPROF) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") -ENDIF() +option(GPROF "Generate extra code to write profile information" OFF) +if(GPROF) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") +endif() -OPTION(COVERAGE "Generate extra code to write coverage information" OFF) -IF(COVERAGE) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") -ENDIF() +option(COVERAGE "Generate extra code to write coverage information" OFF) +if(COVERAGE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") +endif() -OPTION(ASAN "Use AddressSanitizer" OFF) -IF(ASAN) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls") -ENDIF() +option(ASAN "Use AddressSanitizer" OFF) +if(ASAN) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls") +endif() -ADD_DEFINITIONS(-DMAJOR_VERSION=${PROJECT_VERSION_MAJOR}) -ADD_DEFINITIONS(-DMINOR_VERSION=${PROJECT_VERSION_MINOR}) -ADD_DEFINITIONS(-DMICRO_VERSION=${PROJECT_VERSION_PATCH}) -ADD_DEFINITIONS(-DVERSION="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -ADD_DEFINITIONS(-DSTATIC_IN_RELEASE=) +add_definitions(-DMAJOR_VERSION=${PROJECT_VERSION_MAJOR}) +add_definitions(-DMINOR_VERSION=${PROJECT_VERSION_MINOR}) +add_definitions(-DMICRO_VERSION=${PROJECT_VERSION_PATCH}) +add_definitions(-DVERSION="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") +add_definitions(-DSTATIC_IN_RELEASE=) -SET(LIB_FILES qrencode.c +set(LIB_FILES qrencode.c qrinput.c bitstream.c qrspec.c @@ -36,43 +36,43 @@ SET(LIB_FILES qrencode.c mask.c mqrspec.c mmask.c) -ADD_LIBRARY(qrencode ${LIB_FILES}) -OPTION(BUILD_SHARED_LIBS "Enable build of shared libraries") +add_library(qrencode ${LIB_FILES}) +option(BUILD_SHARED_LIBS "Enable build of shared libraries") -SET(EXE_FILES qrenc.c) -ADD_EXECUTABLE(qrenc ${EXE_FILES} ${PNG_LIBRARIES}) -SET_TARGET_PROPERTIES(qrenc PROPERTIES OUTPUT_NAME "qrencode") -TARGET_LINK_LIBRARIES(qrenc qrencode) +set(EXE_FILES qrenc.c) +add_executable(qrenc ${EXE_FILES} ${PNG_LIBRARIES}) +set_target_properties(qrenc PROPERTIES OUTPUT_NAME "qrencode") +target_link_libraries(qrenc qrencode) -ADD_DEFINITIONS(-DHAVE_SDL=0) +add_definitions(-DHAVE_SDL=0) -FIND_PACKAGE(PNG) -IF(PNG_FOUND) - ADD_DEFINITIONS(-DHAVE_PNG=1) - IF(TARGET PNG::PNG) - TARGET_LINK_LIBRARIES(qrenc PNG::PNG) - ELSE() +find_package(PNG) +if(PNG_FOUND) + add_definitions(-DHAVE_PNG=1) + if(TARGET PNG::PNG) + target_link_libraries(qrenc PNG::PNG) + else() TARGET_INCLUDE_DIRECTORIES(qrenc SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(qrenc ${PNG_LIBRARIES}) - ADD_DEFINITIONS(${PNG_DEFINITIONS}) - ENDIF() -ENDIF() - -INSTALL(TARGETS qrenc DESTINATION bin) -CONFIGURE_FILE(qrencode.1.in qrencode.1 @ONLY) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION share/man/man1) -IF(BUILD_SHARED_LIBS) - CONFIGURE_FILE(libqrencode.pc.in libqrencode.pc @ONLY) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION lib/pkgconfig) - INSTALL(TARGETS qrencode DESTINATION lib) - INSTALL(FILES qrencode.h DESTINATION include) -ENDIF() - - -IF(BUILD_TESTING) - ENABLE_TESTING() - ADD_DEFINITIONS(-DWITH_TESTS=) - ADD_SUBDIRECTORY(tests) -ENDIF() + target_link_libraries(qrenc ${PNG_LIBRARIES}) + add_definitions(${PNG_DEFINITIONS}) + endif() +endif(PNG_FOUND) + +install(TARGETS qrenc DESTINATION bin) +configure_file(qrencode.1.in qrencode.1 @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION share/man/man1) +if(BUILD_SHARED_LIBS) + configure_file(libqrencode.pc.in libqrencode.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION lib/pkgconfig) + install(TARGETS qrencode DESTINATION lib) + install(FILES qrencode.h DESTINATION include) +endif(BUILD_SHARED_LIBS) + + +if(BUILD_TESTING) + enable_testing() + add_definitions(-DWITH_TESTS=) + add_subdirectory(tests) +endif(BUILD_TESTING) -- cgit 0.0.5-2-1-g0f52 From e87c3dc44f98c5a97d432621dfa917caa5642e19 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Fri, 13 Jan 2017 19:47:36 +0300 Subject: Compiled with Ladislav Sopko fork. Added FindIconv.cmake --- CMakeLists.txt | 167 ++++++++++++++++++++++++++++++++++++-------------- cmake/FindIconv.cmake | 118 +++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 59 ++++++++++-------- 3 files changed, 271 insertions(+), 73 deletions(-) create mode 100644 cmake/FindIconv.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 142c8be6b0..6605eea874 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,49 @@ cmake_minimum_required(VERSION 3.1.0) -project(QREncodingLibrary VERSION 4.0.0 LANGUAGES C) +project(QRencode VERSION 3.9.0 LANGUAGES C) +option(WITH_TOOLS "Build utility tools" YES ) +option(WITH_TESTS "Build tests" NO ) +option(GPROF "Generate extra code to write profile information" OFF) +option(COVERAGE "Generate extra code to write coverage information" OFF) +option(ASAN "Use AddressSanitizer" OFF) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + +find_package(Threads) +find_package(PNG) +find_package(Iconv) + +## Check for system include files +include(CheckIncludeFile) +include(CheckFunctionExists) + +check_include_file(dlfcn.h HAVE_DLFCN_H ) +check_include_file(inttypes.h HAVE_INTTYPES_H) +check_include_file(memory.h HAVE_MEMORY_H ) +check_include_file(stdint.h HAVE_STDINT_H ) +check_include_file(stdlib.h HAVE_STDLIB_H ) +check_include_file(strings.h HAVE_STRINGS_H ) +check_include_file(string.h HAVE_STRING_H ) +check_include_file(getopt.h HAVE_GETOPT_H ) +check_function_exists(strdup HAVE_STRDUP) + +if(HAVE_STRDUP) + add_definitions(-DHAVE_STRDUP=1) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +endif() -option(GPROF "Generate extra code to write profile information" OFF) if(GPROF) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") endif() -option(COVERAGE "Generate extra code to write coverage information" OFF) if(COVERAGE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") endif() -option(ASAN "Use AddressSanitizer" OFF) if(ASAN) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls") endif() @@ -25,54 +53,99 @@ add_definitions(-DMINOR_VERSION=${PROJECT_VERSION_MINOR}) add_definitions(-DMICRO_VERSION=${PROJECT_VERSION_PATCH}) add_definitions(-DVERSION="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") add_definitions(-DSTATIC_IN_RELEASE=) - - -set(LIB_FILES qrencode.c - qrinput.c - bitstream.c - qrspec.c - rsecc.c - split.c - mask.c - mqrspec.c - mmask.c) -add_library(qrencode ${LIB_FILES}) -option(BUILD_SHARED_LIBS "Enable build of shared libraries") - - -set(EXE_FILES qrenc.c) -add_executable(qrenc ${EXE_FILES} ${PNG_LIBRARIES}) -set_target_properties(qrenc PROPERTIES OUTPUT_NAME "qrencode") -target_link_libraries(qrenc qrencode) - - add_definitions(-DHAVE_SDL=0) -find_package(PNG) -if(PNG_FOUND) - add_definitions(-DHAVE_PNG=1) - if(TARGET PNG::PNG) - target_link_libraries(qrenc PNG::PNG) - else() - TARGET_INCLUDE_DIRECTORIES(qrenc SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) - target_link_libraries(qrenc ${PNG_LIBRARIES}) - add_definitions(${PNG_DEFINITIONS}) - endif() -endif(PNG_FOUND) - -install(TARGETS qrenc DESTINATION bin) +if(MSVC) + add_definitions(-Dstrcasecmp=_stricmp) + add_definitions(-Dstrncasecmp=_strnicmp) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + + find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include) + find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib) + include_directories(${GETOPT_INCLUDE_DIR}) +endif(MSVC) + +set(QRENCODE_SRCS qrencode.c + qrinput.c + bitstream.c + qrspec.c + rsecc.c + split.c + mask.c + mqrspec.c + mmask.c) + +set(QRENCODE_HDRS qrencode_inner.h + qrinput.h + bitstream.h + qrspec.h + rsecc.h + split.h + mask.h + mqrspec.h + mmask.h) + +add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS}) + configure_file(qrencode.1.in qrencode.1 @ONLY) +configure_file(libqrencode.pc.in libqrencode.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION share/man/man1) -if(BUILD_SHARED_LIBS) - configure_file(libqrencode.pc.in libqrencode.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION lib/pkgconfig) - install(TARGETS qrencode DESTINATION lib) - install(FILES qrencode.h DESTINATION include) -endif(BUILD_SHARED_LIBS) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION lib/pkgconfig) +install(FILES qrencode.h DESTINATION include) +install(TARGETS qrencode DESTINATION lib) +## Build utility tools +if(WITH_TOOLS AND PNG_FOUND) + add_definitions(-DHAVE_PNG=1) + add_definitions(${PNG_DEFINITIONS}) + add_executable(qrenc qrenc.c) + set_target_properties(qrenc PROPERTIES OUTPUT_NAME qrencode) + + target_include_directories(qrenc SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) + target_link_libraries(qrenc qrencode ${PNG_LIBRARIES}) + + if(MSVC) + target_link_libraries(qrenc ${GETOPT_LIBRARIES}) + endif(MSVC) + + install(TARGETS qrenc DESTINATION bin) +endif() -if(BUILD_TESTING) +if(WITH_TESTS) enable_testing() add_definitions(-DWITH_TESTS=) add_subdirectory(tests) -endif(BUILD_TESTING) +endif(WITH_TESTS) + +## ============================================================================== +## +## Configuration summary +## +## ============================================================================== + +message(STATUS "------------------------------------------------------------" ) +message(STATUS "[QRencode] Configuration summary." ) +message(STATUS "------------------------------------------------------------ ") +message(STATUS " System configuration:" ) +message(STATUS " .. Processor type .............. = ${CMAKE_SYSTEM_PROCESSOR}") +message(STATUS " .. CMake executable ............ = ${CMAKE_COMMAND}" ) +message(STATUS " .. CMake version ............... = ${CMAKE_VERSION}" ) +message(STATUS " .. System name ................. = ${CMAKE_SYSTEM}" ) +message(STATUS " .. C++ compiler ................ = ${CMAKE_CXX_COMPILER}" ) +message(STATUS " .. C compiler .................. = ${CMAKE_C_COMPILER}" ) +message(STATUS " .. size(void*) ................. = ${CMAKE_SIZEOF_VOID_P}" ) +message(STATUS " Dependencies:" ) +#message(STATUS " .. Doxygen ..................... = ${DOXYGEN_EXECUTABLE}" ) +message(STATUS " .. Thread library of the system = ${CMAKE_THREAD_LIBS_INIT}") +message(STATUS " .. Iconv includes .............. = ${ICONV_INCLUDES}" ) +message(STATUS " .. Iconv library ............... = ${ICONV_LIBRARIES}" ) +message(STATUS " .. PNG includes ................ = ${PNG_INCLUDE_DIR}" ) +message(STATUS " .. PNG library ................. = ${PNG_LIBRARIES}" ) +#message(STATUS " .. Memory checker .............. = ${MEMORYCHECK_COMMAND}" ) +message(STATUS " Project configuration:" ) +message(STATUS " .. Build test programs ........ = ${WITH_TESTS}" ) +message(STATUS " .. Build utility tools ........ = ${WITH_TOOLS}" ) +message(STATUS " .. Installation prefix ......... = ${CMAKE_INSTALL_PREFIX}" ) +message(STATUS "------------------------------------------------------------ ") \ No newline at end of file diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake new file mode 100644 index 0000000000..c8bf9c5037 --- /dev/null +++ b/cmake/FindIconv.cmake @@ -0,0 +1,118 @@ +# vim:ts=4:sw=4:expandtab:autoindent: +# +# The MIT License +# +# Copyright (c) 2008, 2009 Flusspferd contributors (see "CONTRIBUTORS" or +# http://flusspferd.org/contributors.txt) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +include(CheckFunctionExists) +if(ICONV_INCLUDE_DIR) + set(ICONV_FIND_QUIETLY TRUE) +endif() + +find_path(ICONV_INCLUDE_DIR iconv.h + HINTS + ${CMAKE_PREFIX_PATH} + ${ICONV_DIR} + $ENV{ICONV_DIR} + PATH_SUFFIXES include +) + +if(NOT ICONV_INCLUDE_DIR STREQUAL "ICONV_INCLUDE_DIR-NOTFOUND") + set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) + check_function_exists(iconv_open ICONV_IN_GLIBC) +endif() + +if(NOT ICONV_IN_GLIBC) + if (CMAKE_CL_64) + find_library(ICONV_LIBRARY + NAMES iconv64 + HINTS + ${CMAKE_PREFIX_PATH} + ${ICONV_DIR} + $ENV{ICONV_DIR} + PATH_SUFFIXES lib64 lib + ) + else() + find_library(ICONV_LIBRARY + NAMES iconv + HINTS + ${CMAKE_PREFIX_PATH} + ${ICONV_DIR} + $ENV{ICONV_DIR} + PATH_SUFFIXES lib64 lib + ) + endif() + set(ICONV_TEST ${ICONV_LIBRARY}) +else() + set(ICONV_TEST "In glibc") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ICONV DEFAULT_MSG ICONV_TEST ICONV_INCLUDE_DIR ICONV_COMPILES) + +if(ICONV_FOUND) + set(ICONV_LIBRARIES ${ICONV_LIBRARY}) +else(ICONV_FOUND) + set(ICONV_LIBRARIES) +endif(ICONV_FOUND) + +if(ICONV_FOUND) + set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) + + if (NOT DEFINED ICONV_ACCEPTS_NONCONST_INPUT) + # Display a useful message first time we come through here + message(STATUS "One (and only one) of the ICONV_ACCEPTS_... tests must pass") + endif() + + include(CheckCXXSourceCompiles) + + check_cxx_source_compiles( + "#include + int main() { + char *p = 0; + iconv(iconv_t(-1), &p, 0, 0, 0); + }" + ICONV_ACCEPTS_NONCONST_INPUT) + + check_cxx_source_compiles( + "#include + int main() { + char const *p = 0; + iconv(iconv_t(-1), &p, 0, 0, 0); + }" + ICONV_ACCEPTS_CONST_INPUT) + + if (ICONV_LIBRARY) + list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY}) + list(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES) + endif() + + if(NOT ICONV_ACCEPTS_CONST_INPUT AND NOT ICONV_ACCEPTS_NONCONST_INPUT) + MESSAGE(FATAL_ERROR "Unable to determine iconv() signature") + elseif(ICONV_ACCEPTS_CONST_INPUT AND ICONV_ACCEPTS_NONCONST_INPUT) + MESSAGE(FATAL_ERROR "Unable to determine iconv() signature - both test cases passed!") + endif() +endif() + +mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e89766da67..3c3912c1ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,9 +1,16 @@ -IF(NOT PNG_FOUND) - MESSAGE(FATAL_ERROR "PNG is required for tests") -ENDIF() - - -SET(TEST_FILES test_bitstream.c +if(ICONV_FOUND) + include_directories(${ICONV_INCLUDES}) +else(ICONV_FOUND) + message(FATAL_ERROR "Iconv is required for tests") +endif(ICONV_FOUND) + +if(PNG_FOUND) + include_directories(${PNG_INCLUDE_DIR}) +else(PNG_FOUND) + message(FATAL_ERROR "PNG is required for tests") +endif(PNG_FOUND) + +set(TEST_FILES test_bitstream.c test_estimatebit.c test_mask.c test_mmask.c @@ -16,35 +23,35 @@ SET(TEST_FILES test_bitstream.c test_split.c test_split_urls.c) -SET(TEST_COMMON_FILES common.c +set(TEST_COMMON_FILES common.c decoder.c datachunk.c rsecc_decoder.c rscode.c) -ADD_EXECUTABLE(create_frame_pattern create_frame_pattern.c ${TEST_COMMON_FILES}) -ADD_EXECUTABLE(create_mqr_frame_pattern create_mqr_frame_pattern.c ${TEST_COMMON_FILES}) -TARGET_LINK_LIBRARIES(create_frame_pattern qrencode) -TARGET_LINK_LIBRARIES(create_mqr_frame_pattern qrencode) +add_executable(create_frame_pattern create_frame_pattern.c ${TEST_COMMON_FILES}) +add_executable(create_mqr_frame_pattern create_mqr_frame_pattern.c ${TEST_COMMON_FILES}) +target_link_libraries(create_frame_pattern qrencode) +target_link_libraries(create_mqr_frame_pattern qrencode) -IF(TARGET PNG::PNG) - TARGET_LINK_LIBRARIES(create_frame_pattern PNG::PNG) - TARGET_LINK_LIBRARIES(create_mqr_frame_pattern PNG::PNG) -ELSE() - TARGET_INCLUDE_DIRECTORIES(create_frame_pattern SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(create_frame_pattern ${PNG_LIBRARIES}) +if(TARGET PNG::PNG) + target_link_libraries(create_frame_pattern PNG::PNG) + target_link_libraries(create_mqr_frame_pattern PNG::PNG) +else() + target_include_directories(create_frame_pattern SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) + target_link_libraries(create_frame_pattern ${PNG_LIBRARIES}) - TARGET_INCLUDE_DIRECTORIES(create_mqr_frame_pattern SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(create_mqr_frame_pattern ${PNG_LIBRARIES}) -ENDIF() + target_include_directories(create_mqr_frame_pattern SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) + target_link_libraries(create_mqr_frame_pattern ${PNG_LIBRARIES}) +endif() -FOREACH(testfile ${TEST_FILES}) - SET(binary ${testfile}.bin) - ADD_EXECUTABLE(${binary} ${testfile} ${TEST_COMMON_FILES}) - TARGET_LINK_LIBRARIES(${binary} qrencode) - ADD_TEST(${testfile} ${binary}) -ENDFOREACH() +foreach(testfile ${TEST_FILES}) + set(binary ${testfile}.bin) + add_executable(${binary} ${testfile} ${TEST_COMMON_FILES}) + target_link_libraries(${binary} qrencode) + add_test(${testfile} ${binary}) +endforeach() -- cgit 0.0.5-2-1-g0f52 From a4c9fda58d223d576712f5a224e7010e2a60dff9 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Mon, 16 Jan 2017 14:00:32 +0300 Subject: Made imported target for ICONV. Organized the tests by dependencies. --- CMakeLists.txt | 2 ++ cmake/FindIconv.cmake | 35 ++++++++++++++++--- tests/CMakeLists.txt | 95 ++++++++++++++++++++++++--------------------------- 3 files changed, 78 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6605eea874..ae959e5798 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,8 @@ check_include_file(stdlib.h HAVE_STDLIB_H ) check_include_file(strings.h HAVE_STRINGS_H ) check_include_file(string.h HAVE_STRING_H ) check_include_file(getopt.h HAVE_GETOPT_H ) +check_include_file(sys/time.h HAVE_SYS_TIME_H) + check_function_exists(strdup HAVE_STRDUP) if(HAVE_STRDUP) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index c8bf9c5037..fb966609fa 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -71,10 +71,37 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(ICONV DEFAULT_MSG ICONV_TEST ICONV_INCLUDE_DIR ICONV_COMPILES) if(ICONV_FOUND) - set(ICONV_LIBRARIES ${ICONV_LIBRARY}) -else(ICONV_FOUND) - set(ICONV_LIBRARIES) -endif(ICONV_FOUND) + set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) + + if(NOT ICONV_LIBRARIES) + set(ICONV_LIBRARIES ${ICONV_LIBRARY}) + endif() + + if(NOT TARGET ICONV::ICONV) + add_library(ICONV::ICONV UNKNOWN IMPORTED) + set_target_properties(ICONV::ICONV PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIRS}") + + if(ICONV_LIBRARY_RELEASE) + set_property(TARGET ICONV::ICONV APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(ICONV::ICONV PROPERTIES + IMPORTED_LOCATION_RELEASE "${ICONV_LIBRARY_RELEASE}") + endif() + + if(ICONV_LIBRARY_DEBUG) + set_property(TARGET ICONV::ICONV APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(ICONV::ICONV PROPERTIES + IMPORTED_LOCATION_DEBUG "${ICONV_LIBRARY_DEBUG}") + endif() + + if(NOT ICONV_LIBRARY_RELEASE AND NOT ICONV_LIBRARY_DEBUG) + set_property(TARGET ICONV::ICONV APPEND PROPERTY + IMPORTED_LOCATION "${ICONV_LIBRARY}") + endif() + endif() +endif() if(ICONV_FOUND) set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3c3912c1ad..0e54ed2b8a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,57 +1,52 @@ -if(ICONV_FOUND) - include_directories(${ICONV_INCLUDES}) -else(ICONV_FOUND) - message(FATAL_ERROR "Iconv is required for tests") -endif(ICONV_FOUND) - -if(PNG_FOUND) - include_directories(${PNG_INCLUDE_DIR}) -else(PNG_FOUND) - message(FATAL_ERROR "PNG is required for tests") -endif(PNG_FOUND) - -set(TEST_FILES test_bitstream.c - test_estimatebit.c - test_mask.c - test_mmask.c - test_monkey.c - test_mqrspec.c - test_qrencode.c - test_qrinput.c - test_qrspec.c - test_rs.c - test_split.c - test_split_urls.c) - -set(TEST_COMMON_FILES common.c - decoder.c - datachunk.c - rsecc_decoder.c - rscode.c) - - -add_executable(create_frame_pattern create_frame_pattern.c ${TEST_COMMON_FILES}) -add_executable(create_mqr_frame_pattern create_mqr_frame_pattern.c ${TEST_COMMON_FILES}) -target_link_libraries(create_frame_pattern qrencode) -target_link_libraries(create_mqr_frame_pattern qrencode) +set(TEST_COMMON_FILES common.c common.h) + +macro(MAKE_TEST test_name) + set(ADDITIONAL_LIBS "${ARGN}") + add_executable(${test_name} ${test_name}.c ${TEST_COMMON_FILES}) + target_link_libraries(${test_name} qrencode ${ADDITIONAL_LIBS}) + add_test(${test_name} ${test_name}) +endmacro(MAKE_TEST) if(TARGET PNG::PNG) - target_link_libraries(create_frame_pattern PNG::PNG) - target_link_libraries(create_mqr_frame_pattern PNG::PNG) -else() - target_include_directories(create_frame_pattern SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) - target_link_libraries(create_frame_pattern ${PNG_LIBRARIES}) - - target_include_directories(create_mqr_frame_pattern SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) - target_link_libraries(create_mqr_frame_pattern ${PNG_LIBRARIES}) + add_executable(create_frame_pattern create_frame_pattern.c ${TEST_COMMON_FILES}) + target_link_libraries(create_frame_pattern qrencode PNG::PNG) + + add_executable(create_mqr_frame_pattern create_mqr_frame_pattern.c ${TEST_COMMON_FILES}) + target_link_libraries(create_mqr_frame_pattern qrencode PNG::PNG) endif() +if(HAVE_SDL) + add_executable(view_qrcode view_qrcode.c ${TEST_COMMON_FILES}) + target_link_libraries(view_qrcode qrencode) +endif(HAVE_SDL) +if(HAVE_SYS_TIME_H) + add_executable(prof_qrencode prof_qrencode.c ${TEST_COMMON_FILES}) + target_link_libraries(prof_qrencode qrencode) -foreach(testfile ${TEST_FILES}) - set(binary ${testfile}.bin) - add_executable(${binary} ${testfile} ${TEST_COMMON_FILES}) - target_link_libraries(${binary} qrencode) - add_test(${testfile} ${binary}) -endforeach() + add_executable(pthread_qrencode pthread_qrencode.c ${TEST_COMMON_FILES}) + target_link_libraries(pthread_qrencode qrencode) +endif() + +MAKE_TEST(test_bitstream) +MAKE_TEST(test_estimatebit) +MAKE_TEST(test_split) + +if(TARGET ICONV::ICONV) + add_library(decoder + decoder.c decoder.h + datachunk.c datachunk.h + rsecc_decoder.c rsecc_decoder.h) + target_link_libraries(decoder ICONV::ICONV) + + MAKE_TEST(test_qrinput decoder) + MAKE_TEST(test_qrspec decoder) + MAKE_TEST(test_mqrspec decoder) + MAKE_TEST(test_rs decoder) + MAKE_TEST(test_qrencode decoder) + MAKE_TEST(test_split_urls decoder) + MAKE_TEST(test_monkey decoder) + MAKE_TEST(test_mask decoder) + MAKE_TEST(test_mmask decoder) +endif() -- cgit 0.0.5-2-1-g0f52 From eb618fc704f83ab424ea36842d5b38afe8afb3cb Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Mon, 16 Jan 2017 14:51:50 +0300 Subject: MSVC debug postfix --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae959e5798..c03a90d983 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,8 @@ add_definitions(-DSTATIC_IN_RELEASE=) add_definitions(-DHAVE_SDL=0) if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") + add_definitions(-Dstrcasecmp=_stricmp) add_definitions(-Dstrncasecmp=_strnicmp) add_definitions(-D_CRT_SECURE_NO_WARNINGS) -- cgit 0.0.5-2-1-g0f52 From 84d45786c1d78d7ba81aeb5d629c9ec634ef4a05 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Mon, 16 Jan 2017 18:52:51 +0300 Subject: Unused option ICONV_COMPILES --- cmake/FindIconv.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index fb966609fa..4d89f285b2 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -68,7 +68,7 @@ else() endif() include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ICONV DEFAULT_MSG ICONV_TEST ICONV_INCLUDE_DIR ICONV_COMPILES) +find_package_handle_standard_args(ICONV DEFAULT_MSG ICONV_TEST ICONV_INCLUDE_DIR) if(ICONV_FOUND) set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) -- cgit 0.0.5-2-1-g0f52 From 5433a479b6fb739f0e27eaf1b817c58dee6f68d6 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Mon, 16 Jan 2017 19:18:10 +0300 Subject: Missing include CheckCXXSourceCompiles --- cmake/FindIconv.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index 4d89f285b2..8b5b2221c4 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -25,6 +25,8 @@ # include(CheckFunctionExists) +include(CheckCXXSourceCompiles) + if(ICONV_INCLUDE_DIR) set(ICONV_FIND_QUIETLY TRUE) endif() @@ -111,9 +113,7 @@ if(ICONV_FOUND) # Display a useful message first time we come through here message(STATUS "One (and only one) of the ICONV_ACCEPTS_... tests must pass") endif() - - include(CheckCXXSourceCompiles) - + check_cxx_source_compiles( "#include int main() { -- cgit 0.0.5-2-1-g0f52 From a7cf9d4a4a020516fdf2c3b1e8f073cbc9d0b43a Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Mon, 16 Jan 2017 19:31:27 +0300 Subject: Change language to C instead cxx --- cmake/FindIconv.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index 8b5b2221c4..c445535b4b 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -25,7 +25,7 @@ # include(CheckFunctionExists) -include(CheckCXXSourceCompiles) +include(CheckCSourceCompiles) if(ICONV_INCLUDE_DIR) set(ICONV_FIND_QUIETLY TRUE) @@ -114,7 +114,7 @@ if(ICONV_FOUND) message(STATUS "One (and only one) of the ICONV_ACCEPTS_... tests must pass") endif() - check_cxx_source_compiles( + check_c_source_compiles( "#include int main() { char *p = 0; @@ -122,7 +122,7 @@ if(ICONV_FOUND) }" ICONV_ACCEPTS_NONCONST_INPUT) - check_cxx_source_compiles( + check_c_source_compiles( "#include int main() { char const *p = 0; -- cgit 0.0.5-2-1-g0f52 From d566b57a65656d4c7a811a8fcf000e0814de908c Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Mon, 16 Jan 2017 19:37:48 +0300 Subject: Removed iconv() signature checks --- cmake/FindIconv.cmake | 72 +++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index c445535b4b..e0eac483b7 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -105,41 +105,41 @@ if(ICONV_FOUND) endif() endif() -if(ICONV_FOUND) - set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) - - if (NOT DEFINED ICONV_ACCEPTS_NONCONST_INPUT) - # Display a useful message first time we come through here - message(STATUS "One (and only one) of the ICONV_ACCEPTS_... tests must pass") - endif() - - check_c_source_compiles( - "#include - int main() { - char *p = 0; - iconv(iconv_t(-1), &p, 0, 0, 0); - }" - ICONV_ACCEPTS_NONCONST_INPUT) - - check_c_source_compiles( - "#include - int main() { - char const *p = 0; - iconv(iconv_t(-1), &p, 0, 0, 0); - }" - ICONV_ACCEPTS_CONST_INPUT) - - if (ICONV_LIBRARY) - list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY}) - list(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES) - endif() - - if(NOT ICONV_ACCEPTS_CONST_INPUT AND NOT ICONV_ACCEPTS_NONCONST_INPUT) - MESSAGE(FATAL_ERROR "Unable to determine iconv() signature") - elseif(ICONV_ACCEPTS_CONST_INPUT AND ICONV_ACCEPTS_NONCONST_INPUT) - MESSAGE(FATAL_ERROR "Unable to determine iconv() signature - both test cases passed!") - endif() -endif() +#if(ICONV_FOUND) +# set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) +# set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) +# +# if (NOT DEFINED ICONV_ACCEPTS_NONCONST_INPUT) +# # Display a useful message first time we come through here +# message(STATUS "One (and only one) of the ICONV_ACCEPTS_... tests must pass") +# endif() +# +# check_c_source_compiles( +# "#include +# int main() { +# char *p = 0; +# iconv(iconv_t(-1), &p, 0, 0, 0); +# }" +# ICONV_ACCEPTS_NONCONST_INPUT) +# +# check_c_source_compiles( +# "#include +# int main() { +# char const *p = 0; +# iconv(iconv_t(-1), &p, 0, 0, 0); +# }" +# ICONV_ACCEPTS_CONST_INPUT) +# +# if (ICONV_LIBRARY) +# list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY}) +# list(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES) +# endif() +# +# if(NOT ICONV_ACCEPTS_CONST_INPUT AND NOT ICONV_ACCEPTS_NONCONST_INPUT) +# MESSAGE(FATAL_ERROR "Unable to determine iconv() signature") +# elseif(ICONV_ACCEPTS_CONST_INPUT AND ICONV_ACCEPTS_NONCONST_INPUT) +# MESSAGE(FATAL_ERROR "Unable to determine iconv() signature - both test cases passed!") +# endif() +#endif() mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR) -- cgit 0.0.5-2-1-g0f52 From 5e8aa01d5f98b5b9f5c8eadbe2da9747326f9364 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Tue, 17 Jan 2017 17:31:41 +0300 Subject: Reverted the BUILD_TESTING option and marked as deprecated. Rewritten the FindIconv.cmake. --- CMakeLists.txt | 16 +++- cmake/FindIconv.cmake | 207 +++++++++++++++++++++----------------------------- 2 files changed, 99 insertions(+), 124 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c03a90d983..d31ab21150 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,11 @@ option(GPROF "Generate extra code to write profile information" OFF) option(COVERAGE "Generate extra code to write coverage information" OFF) option(ASAN "Use AddressSanitizer" OFF) +if(BUILD_TESTING) + set(WITH_TESTS ON) + message(DEPRECATION "use WITH_TESTS option instead BUILD_TESTING") +endif() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") find_package(Threads) @@ -143,10 +148,13 @@ message(STATUS " .. size(void*) ................. = ${CMAKE_SIZEOF_VOID_P}" ) message(STATUS " Dependencies:" ) #message(STATUS " .. Doxygen ..................... = ${DOXYGEN_EXECUTABLE}" ) message(STATUS " .. Thread library of the system = ${CMAKE_THREAD_LIBS_INIT}") -message(STATUS " .. Iconv includes .............. = ${ICONV_INCLUDES}" ) -message(STATUS " .. Iconv library ............... = ${ICONV_LIBRARIES}" ) -message(STATUS " .. PNG includes ................ = ${PNG_INCLUDE_DIR}" ) -message(STATUS " .. PNG library ................. = ${PNG_LIBRARIES}" ) +message(STATUS " .. Iconv ....................... = ${ICONV_FOUND}" ) +message(STATUS " .... Iconv includes ............ = ${ICONV_INCLUDE_DIR}" ) +message(STATUS " .... Iconv library ............. = ${ICONV_LIBRARIES}" ) +message(STATUS " .. ZLIB ........................ = ${ZLIB_FOUND}" ) +message(STATUS " .. PNG ......................... = ${PNG_FOUND}" ) +message(STATUS " .... PNG includes .............. = ${PNG_INCLUDE_DIR}" ) +message(STATUS " .... PNG library ............... = ${PNG_LIBRARIES}" ) #message(STATUS " .. Memory checker .............. = ${MEMORYCHECK_COMMAND}" ) message(STATUS " Project configuration:" ) message(STATUS " .. Build test programs ........ = ${WITH_TESTS}" ) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index e0eac483b7..886f40bb77 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -1,145 +1,112 @@ -# vim:ts=4:sw=4:expandtab:autoindent: -# -# The MIT License -# -# Copyright (c) 2008, 2009 Flusspferd contributors (see "CONTRIBUTORS" or -# http://flusspferd.org/contributors.txt) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - include(CheckFunctionExists) -include(CheckCSourceCompiles) -if(ICONV_INCLUDE_DIR) - set(ICONV_FIND_QUIETLY TRUE) +set(_ICONV_SEARCHES) + +# Search ICONV_DIR first if it is set. +if(NOT ICONV_DIR AND ENV{ICONV_DIR}) + set(ICONV_DIR $ENV{ICONV_DIR}) +endif() + +if(ICONV_DIR) + set(_ICONV_DIR_SEARCH PATHS ${ICONV_DIR} NO_DEFAULT_PATH) + list(APPEND _ICONV_SEARCHES _ICONV_DIR_SEARCH) endif() -find_path(ICONV_INCLUDE_DIR iconv.h - HINTS - ${CMAKE_PREFIX_PATH} - ${ICONV_DIR} - $ENV{ICONV_DIR} - PATH_SUFFIXES include -) - -if(NOT ICONV_INCLUDE_DIR STREQUAL "ICONV_INCLUDE_DIR-NOTFOUND") - set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) - check_function_exists(iconv_open ICONV_IN_GLIBC) +# Normal search. +set(_ICONV_SEARCH_NORMAL + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Iconv;InstallPath]" + "$ENV{PROGRAMFILES}/iconv" + ) +list(APPEND _ICONV_SEARCHES _ICONV_SEARCH_NORMAL) + +set(ICONV_NAMES iconv iconv2 libiconv iconv64) +set(ICONV_NAMES_DEBUG iconvd iconv64d) + +# Try each search configuration. +foreach(search ${_ICONV_SEARCHES}) + find_path(ICONV_INCLUDE_DIR NAMES iconv.h ${${search}} PATH_SUFFIXES include) +endforeach() + +# Allow ICONV_LIBRARY to be set manually, as the location of the iconv library +if(NOT ICONV_LIBRARY) + foreach(search ${_ICONV_SEARCHES}) + find_library(ICONV_LIBRARY_RELEASE NAMES ${ICONV_NAMES} ${${search}} PATH_SUFFIXES lib) + find_library(ICONV_LIBRARY_DEBUG NAMES ${ICONV_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib) + endforeach() + + include(SelectLibraryConfigurations) + select_library_configurations(ICONV) endif() -if(NOT ICONV_IN_GLIBC) - if (CMAKE_CL_64) - find_library(ICONV_LIBRARY - NAMES iconv64 - HINTS - ${CMAKE_PREFIX_PATH} - ${ICONV_DIR} - $ENV{ICONV_DIR} - PATH_SUFFIXES lib64 lib - ) - else() - find_library(ICONV_LIBRARY - NAMES iconv - HINTS - ${CMAKE_PREFIX_PATH} - ${ICONV_DIR} - $ENV{ICONV_DIR} - PATH_SUFFIXES lib64 lib - ) +unset(ICONV_NAMES) +unset(ICONV_NAMES_DEBUG) + +mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR) + +if(ICONV_INCLUDE_DIR AND EXISTS "${ICONV_INCLUDE_DIR}/iconv.h") + file(STRINGS "${ICONV_INCLUDE_DIR}/iconv.h" ICONV_H REGEX "^#define _LIBICONV_VERSION 0x([0-9]+)") + + string(REGEX MATCH "#define _LIBICONV_VERSION 0x([0-9][0-9])([0-9][0-9])?([0-9][0-9])?.*" temp_match "${ICONV_H}") + unset(temp_match) + set(ICONV_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(ICONV_VERSION_MINOR "${CMAKE_MATCH_2}") + set(ICONV_VERSION_PATCH "${CMAKE_MATCH_3}") + string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_MAJOR "${ICONV_VERSION_MAJOR}") + string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_MINOR "${ICONV_VERSION_MINOR}") + string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_PATCH "${ICONV_VERSION_PATCH}") + + set(ICONV_VERSION_STRING "${ICONV_VERSION_MAJOR}.${ICONV_VERSION_MINOR}") + if(ICONV_VERSION_PATCH) + set(ICONV_VERSION_STRING "${ICONV_VERSION_STRING}.${ICONV_VERSION_PATCH}") endif() - set(ICONV_TEST ${ICONV_LIBRARY}) -else() +endif() + +check_function_exists(iconv_open ICONV_IN_GLIBC) + +if(ICONV_IN_GLIBC) set(ICONV_TEST "In glibc") +else() + set(ICONV_TEST ${ICONV_LIBRARY}) endif() +# handle the QUIETLY and REQUIRED arguments and set ICONV_FOUND to TRUE if +# all listed variables are TRUE include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ICONV DEFAULT_MSG ICONV_TEST ICONV_INCLUDE_DIR) +find_package_handle_standard_args(ICONV + REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR + VERSION_VAR ICONV_VERSION_STRING) -if(ICONV_FOUND) - set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) +if(NOT ICONV_FOUND) + return() +endif() - if(NOT ICONV_LIBRARIES) - set(ICONV_LIBRARIES ${ICONV_LIBRARY}) - endif() +set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) - if(NOT TARGET ICONV::ICONV) - add_library(ICONV::ICONV UNKNOWN IMPORTED) - set_target_properties(ICONV::ICONV PROPERTIES +if(NOT ICONV_LIBRARIES) + set(ICONV_LIBRARIES ${ICONV_LIBRARY}) +endif() + +if(NOT TARGET ICONV::ICONV) + add_library(ICONV::ICONV UNKNOWN IMPORTED) + set_target_properties(ICONV::ICONV PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIRS}") - if(ICONV_LIBRARY_RELEASE) + if(ICONV_LIBRARY_RELEASE) set_property(TARGET ICONV::ICONV APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) + IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(ICONV::ICONV PROPERTIES - IMPORTED_LOCATION_RELEASE "${ICONV_LIBRARY_RELEASE}") - endif() + IMPORTED_LOCATION_RELEASE "${ICONV_LIBRARY_RELEASE}") + endif() - if(ICONV_LIBRARY_DEBUG) + if(ICONV_LIBRARY_DEBUG) set_property(TARGET ICONV::ICONV APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) + IMPORTED_CONFIGURATIONS DEBUG) set_target_properties(ICONV::ICONV PROPERTIES - IMPORTED_LOCATION_DEBUG "${ICONV_LIBRARY_DEBUG}") - endif() + IMPORTED_LOCATION_DEBUG "${ICONV_LIBRARY_DEBUG}") + endif() - if(NOT ICONV_LIBRARY_RELEASE AND NOT ICONV_LIBRARY_DEBUG) + if(NOT ICONV_LIBRARY_RELEASE AND NOT ICONV_LIBRARY_DEBUG) set_property(TARGET ICONV::ICONV APPEND PROPERTY - IMPORTED_LOCATION "${ICONV_LIBRARY}") - endif() + IMPORTED_LOCATION "${ICONV_LIBRARY}") endif() endif() - -#if(ICONV_FOUND) -# set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) -# set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) -# -# if (NOT DEFINED ICONV_ACCEPTS_NONCONST_INPUT) -# # Display a useful message first time we come through here -# message(STATUS "One (and only one) of the ICONV_ACCEPTS_... tests must pass") -# endif() -# -# check_c_source_compiles( -# "#include -# int main() { -# char *p = 0; -# iconv(iconv_t(-1), &p, 0, 0, 0); -# }" -# ICONV_ACCEPTS_NONCONST_INPUT) -# -# check_c_source_compiles( -# "#include -# int main() { -# char const *p = 0; -# iconv(iconv_t(-1), &p, 0, 0, 0); -# }" -# ICONV_ACCEPTS_CONST_INPUT) -# -# if (ICONV_LIBRARY) -# list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY}) -# list(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES) -# endif() -# -# if(NOT ICONV_ACCEPTS_CONST_INPUT AND NOT ICONV_ACCEPTS_NONCONST_INPUT) -# MESSAGE(FATAL_ERROR "Unable to determine iconv() signature") -# elseif(ICONV_ACCEPTS_CONST_INPUT AND ICONV_ACCEPTS_NONCONST_INPUT) -# MESSAGE(FATAL_ERROR "Unable to determine iconv() signature - both test cases passed!") -# endif() -#endif() - -mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR) -- cgit 0.0.5-2-1-g0f52 From b11c9395ed32ff066070d8adbe7f377ec80e2d55 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Tue, 17 Jan 2017 18:14:39 +0300 Subject: Threads::Threads dependencies for tests. The check that the current compiler could initialize the size of the fixed-size array from a variable. --- tests/CMakeLists.txt | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0e54ed2b8a..3b5131adae 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,12 +20,12 @@ if(HAVE_SDL) target_link_libraries(view_qrcode qrencode) endif(HAVE_SDL) -if(HAVE_SYS_TIME_H) +if(TARGET Threads::Threads) add_executable(prof_qrencode prof_qrencode.c ${TEST_COMMON_FILES}) - target_link_libraries(prof_qrencode qrencode) + target_link_libraries(prof_qrencode qrencode Threads::Threads) add_executable(pthread_qrencode pthread_qrencode.c ${TEST_COMMON_FILES}) - target_link_libraries(pthread_qrencode qrencode) + target_link_libraries(pthread_qrencode qrencode Threads::Threads) endif() MAKE_TEST(test_bitstream) @@ -42,11 +42,23 @@ if(TARGET ICONV::ICONV) MAKE_TEST(test_qrinput decoder) MAKE_TEST(test_qrspec decoder) MAKE_TEST(test_mqrspec decoder) - MAKE_TEST(test_rs decoder) MAKE_TEST(test_qrencode decoder) MAKE_TEST(test_split_urls decoder) MAKE_TEST(test_monkey decoder) - MAKE_TEST(test_mask decoder) - MAKE_TEST(test_mmask decoder) + + include(CheckCSourceCompiles) + check_c_source_compiles( + "int main(){ + const int w = 1; + char buf[w]; + return 0; + }" + FIXED_SIZE_BUFFER_INITIALIZATION) + + if(FIXED_SIZE_BUFFER_INITIALIZATION) + MAKE_TEST(test_mask decoder) + MAKE_TEST(test_mmask decoder) + MAKE_TEST(test_rs decoder) + endif() endif() -- cgit 0.0.5-2-1-g0f52 From f376266be10f1f1dc4633052713196abfaed4c85 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Tue, 17 Jan 2017 20:08:15 +0300 Subject: The check iconv without lib (it is a part of the glibc) --- CMakeLists.txt | 10 ++++------ cmake/FindIconv.cmake | 12 +++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d31ab21150..5cfc416b21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,14 +106,12 @@ install(FILES qrencode.h DESTINATION include) install(TARGETS qrencode DESTINATION lib) ## Build utility tools -if(WITH_TOOLS AND PNG_FOUND) +if(WITH_TOOLS AND TARGET PNG::PNG) add_definitions(-DHAVE_PNG=1) - add_definitions(${PNG_DEFINITIONS}) add_executable(qrenc qrenc.c) set_target_properties(qrenc PROPERTIES OUTPUT_NAME qrencode) - - target_include_directories(qrenc SYSTEM PUBLIC ${PNG_INCLUDE_DIRS}) - target_link_libraries(qrenc qrencode ${PNG_LIBRARIES}) + + target_link_libraries(qrenc qrencode PNG::PNG) if(MSVC) target_link_libraries(qrenc ${GETOPT_LIBRARIES}) @@ -150,7 +148,7 @@ message(STATUS " Dependencies:" ) message(STATUS " .. Thread library of the system = ${CMAKE_THREAD_LIBS_INIT}") message(STATUS " .. Iconv ....................... = ${ICONV_FOUND}" ) message(STATUS " .... Iconv includes ............ = ${ICONV_INCLUDE_DIR}" ) -message(STATUS " .... Iconv library ............. = ${ICONV_LIBRARIES}" ) +message(STATUS " .... Iconv library ............. = ${ICONV_TEST}" ) message(STATUS " .. ZLIB ........................ = ${ZLIB_FOUND}" ) message(STATUS " .. PNG ......................... = ${PNG_FOUND}" ) message(STATUS " .... PNG includes .............. = ${PNG_INCLUDE_DIR}" ) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index 886f40bb77..80581f0da5 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -72,9 +72,15 @@ endif() # handle the QUIETLY and REQUIRED arguments and set ICONV_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ICONV - REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR - VERSION_VAR ICONV_VERSION_STRING) +if(ICONV_LIBRARY) + find_package_handle_standard_args(ICONV + REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR + VERSION_VAR ICONV_VERSION_STRING) +elseif(ICONV_IN_GLIBC) + find_package_handle_standard_args(ICONV + REQUIRED_VARS ICONV_INCLUDE_DIR + VERSION_VAR ICONV_VERSION_STRING) +endif() if(NOT ICONV_FOUND) return() -- cgit 0.0.5-2-1-g0f52 From 5e91d7aeb5911453ca125b15bd7a24fdc7413bd3 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Tue, 17 Jan 2017 21:02:46 +0300 Subject: ICONV lib check hack when it is a part of glibc --- CMakeLists.txt | 2 +- cmake/FindIconv.cmake | 19 +++++-------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cfc416b21..280a7e1633 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,7 +148,7 @@ message(STATUS " Dependencies:" ) message(STATUS " .. Thread library of the system = ${CMAKE_THREAD_LIBS_INIT}") message(STATUS " .. Iconv ....................... = ${ICONV_FOUND}" ) message(STATUS " .... Iconv includes ............ = ${ICONV_INCLUDE_DIR}" ) -message(STATUS " .... Iconv library ............. = ${ICONV_TEST}" ) +message(STATUS " .... Iconv library ............. = ${ICONV_LIBRARIES}" ) message(STATUS " .. ZLIB ........................ = ${ZLIB_FOUND}" ) message(STATUS " .. PNG ......................... = ${PNG_FOUND}" ) message(STATUS " .... PNG includes .............. = ${PNG_INCLUDE_DIR}" ) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index 80581f0da5..bf6acc9f07 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -62,25 +62,16 @@ if(ICONV_INCLUDE_DIR AND EXISTS "${ICONV_INCLUDE_DIR}/iconv.h") endif() check_function_exists(iconv_open ICONV_IN_GLIBC) - -if(ICONV_IN_GLIBC) - set(ICONV_TEST "In glibc") -else() - set(ICONV_TEST ${ICONV_LIBRARY}) +if(ICONV_IN_GLIBC AND NOT ICONV_LIBRARY) + set(ICONV_LIBRARY " ") endif() # handle the QUIETLY and REQUIRED arguments and set ICONV_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) -if(ICONV_LIBRARY) - find_package_handle_standard_args(ICONV - REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR - VERSION_VAR ICONV_VERSION_STRING) -elseif(ICONV_IN_GLIBC) - find_package_handle_standard_args(ICONV - REQUIRED_VARS ICONV_INCLUDE_DIR - VERSION_VAR ICONV_VERSION_STRING) -endif() +find_package_handle_standard_args(ICONV + REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR + VERSION_VAR ICONV_VERSION_STRING) if(NOT ICONV_FOUND) return() -- cgit 0.0.5-2-1-g0f52 From 71feb3aaa1db3f73d1eea76321d21007a3391d2f Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Tue, 17 Jan 2017 21:57:13 +0300 Subject: More checks for iconv --- cmake/FindIconv.cmake | 58 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index bf6acc9f07..ca53df5645 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -14,9 +14,8 @@ endif() # Normal search. set(_ICONV_SEARCH_NORMAL - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Iconv;InstallPath]" - "$ENV{PROGRAMFILES}/iconv" - ) + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Iconv;InstallPath]" + "$ENV{PROGRAMFILES}/iconv") list(APPEND _ICONV_SEARCHES _ICONV_SEARCH_NORMAL) set(ICONV_NAMES iconv iconv2 libiconv iconv64) @@ -24,40 +23,39 @@ set(ICONV_NAMES_DEBUG iconvd iconv64d) # Try each search configuration. foreach(search ${_ICONV_SEARCHES}) - find_path(ICONV_INCLUDE_DIR NAMES iconv.h ${${search}} PATH_SUFFIXES include) + find_path(ICONV_INCLUDE_DIR NAMES iconv.h ${${search}} PATH_SUFFIXES include) endforeach() # Allow ICONV_LIBRARY to be set manually, as the location of the iconv library if(NOT ICONV_LIBRARY) - foreach(search ${_ICONV_SEARCHES}) - find_library(ICONV_LIBRARY_RELEASE NAMES ${ICONV_NAMES} ${${search}} PATH_SUFFIXES lib) - find_library(ICONV_LIBRARY_DEBUG NAMES ${ICONV_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib) - endforeach() + foreach(search ${_ICONV_SEARCHES}) + find_library(ICONV_LIBRARY_RELEASE NAMES ${ICONV_NAMES} ${${search}} PATH_SUFFIXES lib) + find_library(ICONV_LIBRARY_DEBUG NAMES ${ICONV_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib) + endforeach() - include(SelectLibraryConfigurations) - select_library_configurations(ICONV) + include(SelectLibraryConfigurations) + select_library_configurations(ICONV) endif() unset(ICONV_NAMES) unset(ICONV_NAMES_DEBUG) -mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR) - if(ICONV_INCLUDE_DIR AND EXISTS "${ICONV_INCLUDE_DIR}/iconv.h") file(STRINGS "${ICONV_INCLUDE_DIR}/iconv.h" ICONV_H REGEX "^#define _LIBICONV_VERSION 0x([0-9]+)") - - string(REGEX MATCH "#define _LIBICONV_VERSION 0x([0-9][0-9])([0-9][0-9])?([0-9][0-9])?.*" temp_match "${ICONV_H}") + string(REGEX MATCH "q#define _LIBICONV_VERSION 0x([0-9][0-9])([0-9][0-9])?([0-9][0-9])?.*" temp_match "${ICONV_H}") unset(temp_match) - set(ICONV_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(ICONV_VERSION_MINOR "${CMAKE_MATCH_2}") - set(ICONV_VERSION_PATCH "${CMAKE_MATCH_3}") - string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_MAJOR "${ICONV_VERSION_MAJOR}") - string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_MINOR "${ICONV_VERSION_MINOR}") - string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_PATCH "${ICONV_VERSION_PATCH}") + if(CMAKE_MATCH_0) + set(ICONV_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(ICONV_VERSION_MINOR "${CMAKE_MATCH_2}") + set(ICONV_VERSION_PATCH "${CMAKE_MATCH_3}") + string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_MAJOR "${ICONV_VERSION_MAJOR}") + string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_MINOR "${ICONV_VERSION_MINOR}") + string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_PATCH "${ICONV_VERSION_PATCH}") - set(ICONV_VERSION_STRING "${ICONV_VERSION_MAJOR}.${ICONV_VERSION_MINOR}") - if(ICONV_VERSION_PATCH) - set(ICONV_VERSION_STRING "${ICONV_VERSION_STRING}.${ICONV_VERSION_PATCH}") + set(ICONV_VERSION_STRING "${ICONV_VERSION_MAJOR}.${ICONV_VERSION_MINOR}") + if(ICONV_VERSION_PATCH) + set(ICONV_VERSION_STRING "${ICONV_VERSION_STRING}.${ICONV_VERSION_PATCH}") + endif() endif() endif() @@ -73,13 +71,15 @@ find_package_handle_standard_args(ICONV REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR VERSION_VAR ICONV_VERSION_STRING) +mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR) + if(NOT ICONV_FOUND) return() endif() set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) -if(NOT ICONV_LIBRARIES) +if(NOT ICONV_LIBRARIES AND EXISTS "${ICONV_LIBRARY}") set(ICONV_LIBRARIES ${ICONV_LIBRARY}) endif() @@ -88,6 +88,11 @@ if(NOT TARGET ICONV::ICONV) set_target_properties(ICONV::ICONV PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIRS}") + if(EXISTS "${ICONV_LIBRARY}") + set_target_properties(ICONV::ICONV PROPERTIES + IMPORTED_LOCATION "${ICONV_LIBRARY}") + endif() + if(ICONV_LIBRARY_RELEASE) set_property(TARGET ICONV::ICONV APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) @@ -101,9 +106,4 @@ if(NOT TARGET ICONV::ICONV) set_target_properties(ICONV::ICONV PROPERTIES IMPORTED_LOCATION_DEBUG "${ICONV_LIBRARY_DEBUG}") endif() - - if(NOT ICONV_LIBRARY_RELEASE AND NOT ICONV_LIBRARY_DEBUG) - set_property(TARGET ICONV::ICONV APPEND PROPERTY - IMPORTED_LOCATION "${ICONV_LIBRARY}") - endif() endif() -- cgit 0.0.5-2-1-g0f52 From d295d26621895a7c8f373e062cb54195e4f0fc4c Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Wed, 18 Jan 2017 00:37:36 +0300 Subject: Libraries common and rscode --- cmake/FindIconv.cmake | 28 +++++++++++++++++----------- tests/CMakeLists.txt | 34 ++++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index ca53df5645..94078f8891 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -15,7 +15,11 @@ endif() # Normal search. set(_ICONV_SEARCH_NORMAL PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Iconv;InstallPath]" - "$ENV{PROGRAMFILES}/iconv") + "$ENV{PROGRAMFILES}/iconv" + ENV CPATH + ENV C_INCLUDE_PATH + ENV CPLUS_INCLUDE_PATH + ENV LIBRARY_PATH) list(APPEND _ICONV_SEARCHES _ICONV_SEARCH_NORMAL) set(ICONV_NAMES iconv iconv2 libiconv iconv64) @@ -60,15 +64,17 @@ if(ICONV_INCLUDE_DIR AND EXISTS "${ICONV_INCLUDE_DIR}/iconv.h") endif() check_function_exists(iconv_open ICONV_IN_GLIBC) -if(ICONV_IN_GLIBC AND NOT ICONV_LIBRARY) - set(ICONV_LIBRARY " ") + +set(ICONV_FOUND_ANY FALSE) +if(ICONV_IN_GLIBC OR ICONV_LIBRARY) + set(ICONV_FOUND_ANY TRUE) endif() # handle the QUIETLY and REQUIRED arguments and set ICONV_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) find_package_handle_standard_args(ICONV - REQUIRED_VARS ICONV_LIBRARY ICONV_INCLUDE_DIR + REQUIRED_VARS ICONV_FOUND_ANY ICONV_INCLUDE_DIR VERSION_VAR ICONV_VERSION_STRING) mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR) @@ -79,19 +85,15 @@ endif() set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) -if(NOT ICONV_LIBRARIES AND EXISTS "${ICONV_LIBRARY}") +if(NOT ICONV_LIBRARIES) set(ICONV_LIBRARIES ${ICONV_LIBRARY}) endif() -if(NOT TARGET ICONV::ICONV) +if(NOT ICONV_LIBRARY AND NOT TARGET ICONV::ICONV) add_library(ICONV::ICONV UNKNOWN IMPORTED) set_target_properties(ICONV::ICONV PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIRS}") - - if(EXISTS "${ICONV_LIBRARY}") - set_target_properties(ICONV::ICONV PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIRS}" IMPORTED_LOCATION "${ICONV_LIBRARY}") - endif() if(ICONV_LIBRARY_RELEASE) set_property(TARGET ICONV::ICONV APPEND PROPERTY @@ -106,4 +108,8 @@ if(NOT TARGET ICONV::ICONV) set_target_properties(ICONV::ICONV PROPERTIES IMPORTED_LOCATION_DEBUG "${ICONV_LIBRARY_DEBUG}") endif() +elseif(NOT TARGET ICONV::ICONV) + add_library(ICONV::ICONV INTERFACE IMPORTED) + set_target_properties(ICONV::ICONV PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIRS}") endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3b5131adae..7365762996 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,31 +1,37 @@ -set(TEST_COMMON_FILES common.c common.h) +add_library(common + common.c common.h) +target_link_libraries(common qrencode) + +add_library(rscode + rscode.c rscode.h) +target_link_libraries(rscode common) macro(MAKE_TEST test_name) set(ADDITIONAL_LIBS "${ARGN}") - add_executable(${test_name} ${test_name}.c ${TEST_COMMON_FILES}) - target_link_libraries(${test_name} qrencode ${ADDITIONAL_LIBS}) + add_executable(${test_name} ${test_name}.c) + target_link_libraries(${test_name} common ${ADDITIONAL_LIBS}) add_test(${test_name} ${test_name}) endmacro(MAKE_TEST) if(TARGET PNG::PNG) - add_executable(create_frame_pattern create_frame_pattern.c ${TEST_COMMON_FILES}) - target_link_libraries(create_frame_pattern qrencode PNG::PNG) + add_executable(create_frame_pattern create_frame_pattern.c) + target_link_libraries(create_frame_pattern common PNG::PNG) - add_executable(create_mqr_frame_pattern create_mqr_frame_pattern.c ${TEST_COMMON_FILES}) - target_link_libraries(create_mqr_frame_pattern qrencode PNG::PNG) + add_executable(create_mqr_frame_pattern create_mqr_frame_pattern.c) + target_link_libraries(create_mqr_frame_pattern common PNG::PNG) endif() if(HAVE_SDL) - add_executable(view_qrcode view_qrcode.c ${TEST_COMMON_FILES}) - target_link_libraries(view_qrcode qrencode) + add_executable(view_qrcode view_qrcode.c) + target_link_libraries(view_qrcode common) endif(HAVE_SDL) if(TARGET Threads::Threads) - add_executable(prof_qrencode prof_qrencode.c ${TEST_COMMON_FILES}) - target_link_libraries(prof_qrencode qrencode Threads::Threads) + add_executable(prof_qrencode prof_qrencode.c) + target_link_libraries(prof_qrencode common Threads::Threads) - add_executable(pthread_qrencode pthread_qrencode.c ${TEST_COMMON_FILES}) - target_link_libraries(pthread_qrencode qrencode Threads::Threads) + add_executable(pthread_qrencode pthread_qrencode.c) + target_link_libraries(pthread_qrencode common Threads::Threads) endif() MAKE_TEST(test_bitstream) @@ -58,7 +64,7 @@ if(TARGET ICONV::ICONV) if(FIXED_SIZE_BUFFER_INITIALIZATION) MAKE_TEST(test_mask decoder) MAKE_TEST(test_mmask decoder) - MAKE_TEST(test_rs decoder) + MAKE_TEST(test_rs rscode decoder) endif() endif() -- cgit 0.0.5-2-1-g0f52 From 0c4577c083f6963dc953f1fd05eda659ff0353a7 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Wed, 18 Jan 2017 01:24:19 +0300 Subject: Fix mistake. --- cmake/FindIconv.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index 94078f8891..612709d5b5 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -89,7 +89,7 @@ if(NOT ICONV_LIBRARIES) set(ICONV_LIBRARIES ${ICONV_LIBRARY}) endif() -if(NOT ICONV_LIBRARY AND NOT TARGET ICONV::ICONV) +if(ICONV_LIBRARY AND NOT TARGET ICONV::ICONV) add_library(ICONV::ICONV UNKNOWN IMPORTED) set_target_properties(ICONV::ICONV PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIRS}" -- cgit 0.0.5-2-1-g0f52 From 8595f9012d6b10f9662c47862c7b11457f805da8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 3 Feb 2017 13:23:55 +0900 Subject: Some blanks at the end of the line eliminated. --- cmake/FindIconv.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index 612709d5b5..fede82a093 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -55,7 +55,7 @@ if(ICONV_INCLUDE_DIR AND EXISTS "${ICONV_INCLUDE_DIR}/iconv.h") string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_MAJOR "${ICONV_VERSION_MAJOR}") string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_MINOR "${ICONV_VERSION_MINOR}") string(REGEX REPLACE "0*([1-9][0-9]*).*" "\\1" ICONV_VERSION_PATCH "${ICONV_VERSION_PATCH}") - + set(ICONV_VERSION_STRING "${ICONV_VERSION_MAJOR}.${ICONV_VERSION_MINOR}") if(ICONV_VERSION_PATCH) set(ICONV_VERSION_STRING "${ICONV_VERSION_STRING}.${ICONV_VERSION_PATCH}") -- cgit 0.0.5-2-1-g0f52 From c92aeaa80136380a1dbe1cc2ee2599324de55449 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 3 Feb 2017 13:24:11 +0900 Subject: Acknowledges @aleksey-nikolaev. --- ChangeLog | 8 ++++++++ README | 10 ++++++---- README.md | 10 ++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3474e2541..dbde69110b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2017.02.03 Kentaro Fukuchi + * CMakeLists.txt, cmake/FIND*.cmake, tests/CMakeLists.txt: + - Merged #91. (Thanks to @aleksey-nikolaev) + - CMake support has been improved greatly. + * README, README.md: + - ACKNOWLEDGMENTS has been updated. + - Some text cleanups. + 2016.11.20 Kentaro Fukuchi * tests/test_qrinput.c, tests/test_qrspec.c: - Some warnings suppresed. diff --git a/README b/README index 42298a61c0..6d8bc7d111 100644 --- a/README +++ b/README @@ -153,12 +153,14 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Robert Petersen (@ripetersen) - added ability to read input data from a file * @Oblomov - improved SVG support patch -* @mgorny - reverse mappings of UTF8 and ANSIUTF8. -* @EckoEdc - MinGW support patch. +* @mgorny - reverse mappings of UTF8 and ANSIUTF8 +* @EckoEdc - MinGW support patch * Sebastian Buchwald (@UniQP) - - Various code cleanups. + - Various code cleanups * André Klitzing (@misery) - - CMake support. + - CMake support +* Alexey Nikolaev (@aleksey-nikolaev) + - improved CMake support * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, diff --git a/README.md b/README.md index c8f14fc9ff..9b598f335f 100644 --- a/README.md +++ b/README.md @@ -157,12 +157,14 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Robert Petersen (@ripetersen) - added ability to read input data from a file * @Oblomov - improved SVG support patch -* @mgorny - reverse mappings of UTF8 and ANSIUTF8. -* @EckoEdc - MinGW support patch. +* @mgorny - reverse mappings of UTF8 and ANSIUTF8 +* @EckoEdc - MinGW support patch * Sebastian Buchwald (@UniQP) - - Various code cleanups. + - Various code cleanups * André Klitzing (@misery) - - CMake support. + - CMake support +* Alexey Nikolaev (@aleksey-nikolaev) + - improved CMake support * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 6a638336953a4a1c85107563c21e723ce569e431 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 3 Feb 2017 14:00:36 +0900 Subject: Test data packed. --- .gitignore | 2 -- .travis.yml | 2 -- ChangeLog | 4 ++++ tests/frame | Bin 0 -> 477320 bytes 4 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 tests/frame diff --git a/.gitignore b/.gitignore index 2c3a96eb50..4d6336bb87 100644 --- a/.gitignore +++ b/.gitignore @@ -29,8 +29,6 @@ qrencode.spec libqrencode.pc tests/create_frame_pattern tests/create_mqr_frame_pattern -tests/frame -tests/mqrframe tests/pthread_qrencode tests/prof_qrencode tests/test_bitstream diff --git a/.travis.yml b/.travis.yml index ba1c6ecfe1..0b9fc2f513 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,9 +20,7 @@ install: script: - cd $TRAVIS_BUILD_DIR/tests -- ./create_frame_pattern frame - ./test_configure.sh - ./test_all.sh - cd $TRAVIS_BUILD_DIR/build/tests -- ./create_frame_pattern frame - make test diff --git a/ChangeLog b/ChangeLog index dbde69110b..9cd5e53755 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ * README, README.md: - ACKNOWLEDGMENTS has been updated. - Some text cleanups. + * tests/frame, .gitignore: + - Empty frame data "tests/frame" has been included in the source tree. + * .travis.yml + - Stopped creating empty frame data. 2016.11.20 Kentaro Fukuchi * tests/test_qrinput.c, tests/test_qrspec.c: diff --git a/tests/frame b/tests/frame new file mode 100644 index 0000000000..fda4eaaa8a Binary files /dev/null and b/tests/frame differ -- cgit 0.0.5-2-1-g0f52 From b88c1bc6735ba05424ac6e80a006c42b1a10edc1 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 3 Feb 2017 16:39:48 +0900 Subject: Bug fix. --- .travis.yml | 1 + ChangeLog | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0b9fc2f513..8229968071 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,4 +23,5 @@ script: - ./test_configure.sh - ./test_all.sh - cd $TRAVIS_BUILD_DIR/build/tests +- cp $TRAVIS_BUILD_DIR/tests/frame ./ - make test diff --git a/ChangeLog b/ChangeLog index 9cd5e53755..2042b08fd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ - Empty frame data "tests/frame" has been included in the source tree. * .travis.yml - Stopped creating empty frame data. + - Bug fix. 2016.11.20 Kentaro Fukuchi * tests/test_qrinput.c, tests/test_qrspec.c: -- cgit 0.0.5-2-1-g0f52 From d35350114973f45ddce1236747de9a0366442b16 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 5 Feb 2017 14:41:55 +0900 Subject: Added a note for tests programs. (closes #93) --- ChangeLog | 4 ++++ README | 3 +++ README.md | 3 +++ 3 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2042b08fd8..38b89b9b08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017.02.03 Kentaro Fukuchi + * README, README.md: + - Added some notes to compile test programs. (closes #93) + 2017.02.03 Kentaro Fukuchi * CMakeLists.txt, cmake/FIND*.cmake, tests/CMakeLists.txt: - Merged #91. (Thanks to @aleksey-nikolaev) diff --git a/README b/README index 6d8bc7d111..50c61eee0c 100644 --- a/README +++ b/README @@ -64,6 +64,9 @@ If the configure script does not work well, try CMake contributed by André. cmake . make +When you want to run the tests, give "--with-tests" option to configure, +or "-DWITH_TESTS=YES" to cmake. + USAGE ===== diff --git a/README.md b/README.md index 9b598f335f..0530aca0e0 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ cmake . make ``` +When you want to run the tests, give "--with-tests" option to `configure`, +or "-DWITH\_TESTS=YES" to `cmake`. + USAGE ===== -- cgit 0.0.5-2-1-g0f52 From 9697779e73d00be1cbb70adf094cf5b4f02a231c Mon Sep 17 00:00:00 2001 From: Vilppu Vuorinen Date: Thu, 2 Feb 2017 15:39:46 +0200 Subject: Added BUILD_SHARED_LIBS option with MSVC export all --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 280a7e1633..256cef99df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ option(WITH_TESTS "Build tests" NO ) option(GPROF "Generate extra code to write profile information" OFF) option(COVERAGE "Generate extra code to write coverage information" OFF) option(ASAN "Use AddressSanitizer" OFF) +option(BUILD_SHARED_LIBS "Enable build of shared libraries" NO) if(BUILD_TESTING) set(WITH_TESTS ON) @@ -95,7 +96,14 @@ set(QRENCODE_HDRS qrencode_inner.h mqrspec.h mmask.h) -add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS}) +if(BUILD_SHARED_LIBS) + if(MSVC) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + endif() + add_library(qrencode SHARED ${QRENCODE_SRCS} ${QRENCODE_HDRS}) +else() + add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS}) +endif() configure_file(qrencode.1.in qrencode.1 @ONLY) configure_file(libqrencode.pc.in libqrencode.pc @ONLY) -- cgit 0.0.5-2-1-g0f52 From e3410bfdda2dd8ba5a86ef62c69be70cdb6a7567 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 5 Feb 2017 14:47:23 +0900 Subject: ACKNOWLEDGMENTS has been updated. --- ChangeLog | 5 ++++- README | 2 ++ README.md | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 38b89b9b08..039a1ba871 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ -2017.02.03 Kentaro Fukuchi +2017.02.05 Kentaro Fukuchi * README, README.md: - Added some notes to compile test programs. (closes #93) + * CMakeList.txt: + - Added BUILD_SHARED_LIBS option with MSVC export all. (merged #92) + (Thanks to @vilppuvuorinen) 2017.02.03 Kentaro Fukuchi * CMakeLists.txt, cmake/FIND*.cmake, tests/CMakeLists.txt: diff --git a/README b/README index 50c61eee0c..3e0ae9c72e 100644 --- a/README +++ b/README @@ -164,6 +164,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - CMake support * Alexey Nikolaev (@aleksey-nikolaev) - improved CMake support +* Vilppu Vuorinen (@vilppuvuorinen) + - improved CMake support * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, diff --git a/README.md b/README.md index 0530aca0e0..36376725dd 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - CMake support * Alexey Nikolaev (@aleksey-nikolaev) - improved CMake support +* Vilppu Vuorinen (@vilppuvuorinen) + - improved CMake support * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From bfb798ca296ec9f6bd9e6c74ebb608e997804618 Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Tue, 28 Feb 2017 12:02:21 +0100 Subject: Fix typos. --- ChangeLog | 10 +++++----- NEWS | 2 +- TODO | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 039a1ba871..3921da5252 100644 --- a/ChangeLog +++ b/ChangeLog @@ -224,7 +224,7 @@ 2014.08.05 Kentaro FUKUCHI * configure.ac, Makefile.am, tests/Makefile.am: - Added some conditional flags for configuration/building process. - - HAVE_PNG and HAVE_SDL can be refered from both Makefile and program + - HAVE_PNG and HAVE_SDL can be referred from both Makefile and program code. * tests/view_qrcode.c: - Use SDL_WaitEvent() instead of SDL_PollEvent(). @@ -619,7 +619,7 @@ 2012.01.19 Kentaro FUKUCHI [3.2.1] - * cofigure.ac, qrencode.[hc], qrenc.c, tests/test_qrencode.c: + * configure.ac, qrencode.[hc], qrenc.c, tests/test_qrencode.c: - QRcode_APIVersion() and QRcode_APIVersionString() have been added. - New macro values {MAJOR,MINOR,MICRO}_VERSION have been introduced. - New tests have been added. @@ -787,7 +787,7 @@ - MODE_INDICATOR_SIZE has been added. - QRinput_isSplittableMode() has been added. * qrspec.c: - - QRspec_maximumWords() now returns 0 if the entry cannot be splitted. + - QRspec_maximumWords() now returns 0 if the entry cannot be split. - Now includes "qrinput.h" for QRinput_isSplittableMode(). 2010.01.25 Kentaro FUKUCHI @@ -1103,7 +1103,7 @@ * tests/test_bitstream.c: - test_null() has been added. * qrinput.c: - - A possible memory leak has been eliminated. It happend when a wrong + - A possible memory leak has been eliminated. It happened when a wrong version number was given. * tests/test_qriput.c: - Memory leaks have been eliminated. @@ -1278,7 +1278,7 @@ - Documentation improvements. 2008.04.13 Kentaro FUKUCHI - * qrencode.c, qrencode_innter.h, tests/view_qrcode.c: + * qrencode.c, qrencode_inner.h, tests/view_qrcode.c: - Changed API of QRcode_encodeMask(). * qrencode.[ch], qrinput.[ch], split.[ch]: - Some functions now set errno appropriately. diff --git a/NEWS b/NEWS index df6f18c8cb..f5aa140bc4 100644 --- a/NEWS +++ b/NEWS @@ -186,7 +186,7 @@ and the future releases will include gnulib. Version 3.0.2 (2008.5.18) ------------------------- -* Some compile-time warnings/erros with g++ have been fixed. +* Some compile-time warnings/errors with g++ have been fixed. (Thanks to wangsai) * The bit order of "Version information" has been corrected. Symbols greater than version 6 were affected. (Thanks to Paul Janssesn) diff --git a/TODO b/TODO index e9662afaff..475abfa88f 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,5 @@ Micro QR code encoding is not tested well. Documents (not only the README, but also the manual of the library) needs -revision of grammer, spell or to resolve ambiguity or incomplete descriptions. +revision of grammar, spelling or to resolve ambiguity or incomplete descriptions. Feel really free to send us your revision. -- cgit 0.0.5-2-1-g0f52 From b6a1c7ce67267977f6c22c079ec0e684775a9697 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 15 Mar 2017 12:07:05 +0900 Subject: ACKNOWLEDGMENTS has been updated. --- ChangeLog | 6 ++++++ README | 4 ++-- README.md | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3921da5252..5b936bcb11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017.03.15 Kentaro Fukuchi + * ChangeLog, NEWS, TODO: + - Typos fixed. (merged #95) (Thanks to @jwilk) + * README, README.md: + - ACKNOWLEDGMENTS has been updated. + 2017.02.05 Kentaro Fukuchi * README, README.md: - Added some notes to compile test programs. (closes #93) diff --git a/README b/README index 3e0ae9c72e..cb17b51e25 100644 --- a/README +++ b/README @@ -172,5 +172,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno - - bug report / suggestion + Yuji Ueno, Jakub Wilk + - bug report / suggestion / typo fixes diff --git a/README.md b/README.md index 36376725dd..65a46cfe59 100644 --- a/README.md +++ b/README.md @@ -176,5 +176,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno - - bug report / suggestion + Yuji Ueno, Jakub Wilk + - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From 785c587542b24cc860deb58acfe97fe10a5f76d0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 15 Mar 2017 12:12:05 +0900 Subject: The URI to the primary site has been updated. --- ChangeLog | 2 ++ README | 2 +- README.md | 2 +- qrenc.c | 2 +- qrencode.1.in | 2 +- qrencode.spec.in | 4 ++-- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b936bcb11..ea2b1fedbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ - Typos fixed. (merged #95) (Thanks to @jwilk) * README, README.md: - ACKNOWLEDGMENTS has been updated. + * README, README.md, qrenc.c, qrencode.1.in, qrencode.spec.in: + - The URI to the primary site has been updated. (http->https) 2017.02.05 Kentaro Fukuchi * README, README.md: diff --git a/README b/README index cb17b51e25..d9cfefb143 100644 --- a/README +++ b/README @@ -107,7 +107,7 @@ CONTACT ======= Visit the homepage at: -http://fukuchi.org/works/qrencode/ +https://fukuchi.org/works/qrencode/ for new releases. The git repository is available at: diff --git a/README.md b/README.md index 65a46cfe59..0a87d9b49e 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ CONTACT ======= Visit the homepage at: -http://fukuchi.org/works/qrencode/ +https://fukuchi.org/works/qrencode/ for new releases. The git repository is available at: diff --git a/qrenc.c b/qrenc.c index e8c9a59ed5..c1333c4206 100644 --- a/qrenc.c +++ b/qrenc.c @@ -568,7 +568,7 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) */ /* Vanity remark */ - fprintf(fp, "\n", QRcode_APIVersionString()); + fprintf(fp, "\n", QRcode_APIVersionString()); /* SVG code start */ fprintf(fp, diff --git a/qrencode.1.in b/qrencode.1.in index d744d3d8cd..bf39961dec 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -108,7 +108,7 @@ Written by Kentaro Fukuchi. .SH RESOURCES .TP -Main Web Site: http://fukuchi.org/works/qrencode/ +Main Web Site: https://fukuchi.org/works/qrencode/ .TP Source code repository: https://github.com/fukuchi/libqrencode/ diff --git a/qrencode.spec.in b/qrencode.spec.in index 51543947ae..0cf29256ab 100644 --- a/qrencode.spec.in +++ b/qrencode.spec.in @@ -8,8 +8,8 @@ Summary: Libqrencode is a library for encoding data in a QR Code symbol, Group: System Environment/Libraries License: LGPLv2+ -URL: http://fukuchi.org/works/qrencode/ -Source0: http://fukuchi.org/works/qrencode/%{name}-%{version}.tar.gz +URL: https://fukuchi.org/works/qrencode/ +Source0: https://fukuchi.org/works/qrencode/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description -- cgit 0.0.5-2-1-g0f52 From be5a88f873c9a87d4c9c3d46f4b52c5bfefa986b Mon Sep 17 00:00:00 2001 From: Vanilla Hsu Date: Sat, 4 Mar 2017 19:36:29 +0800 Subject: 1: Add version of shared library. 2: fix libqrencode.pc. --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 256cef99df..2bb1b6db67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,10 +101,17 @@ if(BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() add_library(qrencode SHARED ${QRENCODE_SRCS} ${QRENCODE_HDRS}) + set_target_properties(qrencode PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} SOVERSION ${PROJECT_VERSION_MAJOR}) else() add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS}) endif() +set(prefix "${CMAKE_INSTALL_PREFIX}") +set(exec_prefix "${CMAKE_INSTALL_PREFIX}/bin") +set(libdir "${CMAKE_INSTALL_PREFIX}/lib") +set(includedir "${CMAKE_INSTALL_PREFIX}/include") +set(VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") + configure_file(qrencode.1.in qrencode.1 @ONLY) configure_file(libqrencode.pc.in libqrencode.pc @ONLY) @@ -166,4 +173,4 @@ message(STATUS " Project configuration:" ) message(STATUS " .. Build test programs ........ = ${WITH_TESTS}" ) message(STATUS " .. Build utility tools ........ = ${WITH_TOOLS}" ) message(STATUS " .. Installation prefix ......... = ${CMAKE_INSTALL_PREFIX}" ) -message(STATUS "------------------------------------------------------------ ") \ No newline at end of file +message(STATUS "------------------------------------------------------------ ") -- cgit 0.0.5-2-1-g0f52 From 1ef82bd299946da694798af7def63da0cbe3d422 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 15 Mar 2017 15:24:02 +0900 Subject: Merged #96. Thanks to @vanillahsu. --- ChangeLog | 2 ++ README | 1 + README.md | 1 + 3 files changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index ea2b1fedbb..bd8eae79d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ - ACKNOWLEDGMENTS has been updated. * README, README.md, qrenc.c, qrencode.1.in, qrencode.spec.in: - The URI to the primary site has been updated. (http->https) + * CMakeLists.txt: + - Add version of shared library. (merged #96) (Thanks to @vanillahsu) 2017.02.05 Kentaro Fukuchi * README, README.md: diff --git a/README b/README index d9cfefb143..ec60e4c3bc 100644 --- a/README +++ b/README @@ -166,6 +166,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - improved CMake support * Vilppu Vuorinen (@vilppuvuorinen) - improved CMake support +* @vanillahsu - bug fix patch * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, diff --git a/README.md b/README.md index 0a87d9b49e..68f89832f3 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - improved CMake support * Vilppu Vuorinen (@vilppuvuorinen) - improved CMake support +* @vanillahsu - bug fix patch * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 9908062b0ec99f33c10437fae4f80218e921f170 Mon Sep 17 00:00:00 2001 From: KangLin Date: Fri, 4 Aug 2017 10:07:46 +0800 Subject: Fix: Getopt.h is checked only by WITH_TOOLS --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bb1b6db67..0fd953cb31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,10 +70,12 @@ if(MSVC) add_definitions(-Dstrncasecmp=_strnicmp) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - - find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include) - find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib) - include_directories(${GETOPT_INCLUDE_DIR}) + + if(WITH_TOOLS) + find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include) + find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib) + include_directories(${GETOPT_INCLUDE_DIR}) + endif(WITH_TOOLS) endif(MSVC) set(QRENCODE_SRCS qrencode.c -- cgit 0.0.5-2-1-g0f52 From a4fa46b5e61d8567c51025c0dcad02330d6822d7 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 4 Aug 2017 18:27:11 +0900 Subject: Merged #101. Thanks to @KangLin. --- ChangeLog | 7 +++++++ README | 2 +- README.md | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd8eae79d7..b7cfeb32c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2017.08.04 Kentaro Fukuchi + * CMakeLists.txt: + - Getopt.h is checked only by WITH_TOOLS. (merged #101) (Thanks to + @KangLin) + * README, README.md: + - ACKNOWLEDGMENTS has been updated. + 2017.03.15 Kentaro Fukuchi * ChangeLog, NEWS, TODO: - Typos fixed. (merged #95) (Thanks to @jwilk) diff --git a/README b/README index ec60e4c3bc..10bb5096a1 100644 --- a/README +++ b/README @@ -173,5 +173,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno, Jakub Wilk + Yuji Ueno, Jakub Wilk, @KangLin - bug report / suggestion / typo fixes diff --git a/README.md b/README.md index 68f89832f3..7e0f7bdbbb 100644 --- a/README.md +++ b/README.md @@ -177,5 +177,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno, Jakub Wilk + Yuji Ueno, Jakub Wilk, @KangLin - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From e6fe3f1dd06ffcde4e85ee4771f71f14fe7d4a88 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 2 Sep 2017 13:22:26 +0900 Subject: Replaced AC_PROG_RANLIB with LT_INIT. --- ChangeLog | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b7cfeb32c0..8df682420b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017.09.02 Kentaro Fukuchi + * configure.ac: + - Replaced AC_PROG_RANLIB with LT_INIT. + 2017.08.04 Kentaro Fukuchi * CMakeLists.txt: - Getopt.h is checked only by WITH_TOOLS. (merged #101) (Thanks to diff --git a/configure.ac b/configure.ac index 1c34dc2852..13cb68076d 100644 --- a/configure.ac +++ b/configure.ac @@ -28,11 +28,11 @@ AC_C_CONST AC_C_INLINE AC_HEADER_STDC +LT_INIT AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL AC_PROG_LIBTOOL -AC_PROG_RANLIB PKG_PROG_PKG_CONFIG case "${target}" in -- cgit 0.0.5-2-1-g0f52 From 6f2c079407ee35cfc7f7398af02f709161c5a5a8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Sep 2017 03:08:52 +0900 Subject: Documentation update. --- ChangeLog | 4 ++++ mqrspec.h | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8df682420b..5b553340ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017.09.06 Kentaro Fukuchi + * mqrspec.h: + - Documentation update. + 2017.09.02 Kentaro Fukuchi * configure.ac: - Replaced AC_PROG_RANLIB with LT_INIT. diff --git a/mqrspec.h b/mqrspec.h index 291783f63a..460cf01d4f 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -130,8 +130,6 @@ extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level /** * Return a copy of initialized frame. - * When the same version is requested twice or more, a copy of cached frame - * is returned. * @param version version of the symbol * @return Array of unsigned char. You can free it by free(). */ -- cgit 0.0.5-2-1-g0f52 From 1e72d80e0b04f4e28ad35429eedc4814eede17f3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Sep 2017 04:35:32 +0900 Subject: Copyright year updated. --- mqrspec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mqrspec.h b/mqrspec.h index 460cf01d4f..0eaa4907f5 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Micro QR Code specification in convenient format. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public -- cgit 0.0.5-2-1-g0f52 From c93b23994cb5273fd170b4e6e08039e74f87d613 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Sep 2017 04:35:46 +0900 Subject: QRcode_clearCache() revived and deprecated. --- qrencode.c | 7 ++++++- qrencode.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/qrencode.c b/qrencode.c index b55f43c9e2..99033f39d9 100644 --- a/qrencode.c +++ b/qrencode.c @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Copyright (C) 2006-2014 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -880,3 +880,8 @@ char *QRcode_APIVersionString(void) { return VERSION; } + +void QRcode_clearCache(void) +{ + return; +} diff --git a/qrencode.h b/qrencode.h index eaef5dd859..b855f0a40a 100644 --- a/qrencode.h +++ b/qrencode.h @@ -1,7 +1,7 @@ /** * qrencode - QR Code encoder * - * Copyright (C) 2006-2012 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -552,6 +552,11 @@ extern void QRcode_APIVersion(int *major_version, int *minor_version, int *micro */ extern char *QRcode_APIVersionString(void); +/** + * @deprecated + */ +extern void QRcode_clearCache(void) __attribute__ ((deprecated)); + #if defined(__cplusplus) } #endif -- cgit 0.0.5-2-1-g0f52 From 51f27950e4af1d4a66bcd759ef9a1d657828971c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Sep 2017 04:36:57 +0900 Subject: Copyright year updated. --- qrenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index c1333c4206..f1e6ce57a8 100644 --- a/qrenc.c +++ b/qrenc.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code encoding tool - * Copyright (C) 2006-2014 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -102,7 +102,7 @@ static void usage(int help, int longopt, int status) FILE *out = status ? stderr : stdout; fprintf(out, "qrencode version %s\n" -"Copyright (C) 2006-2014 Kentaro Fukuchi\n", QRcode_APIVersionString()); +"Copyright (C) 2006-2017 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { if(longopt) { fprintf(out, -- cgit 0.0.5-2-1-g0f52 From b6fc0275f84b5bfabe0c0d0504c070fed2532205 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Sep 2017 04:37:14 +0900 Subject: Documentation updated. --- ChangeLog | 7 +++++++ NEWS | 15 ++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b553340ff..b6fd03bf73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ 2017.09.06 Kentaro Fukuchi * mqrspec.h: - Documentation update. + * qrencode.[ch]: + - QRcode_clearCache() has been defined as a deprecated function for + backward compatibility. + * qrenc.c: + - Copyright year updated. + * NEWS: + - Documentation update. 2017.09.02 Kentaro Fukuchi * configure.ac: diff --git a/NEWS b/NEWS index f5aa140bc4..209e045477 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,10 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.0.0 (2016.x.x) +Version 4.0.0 (2017.9.x) ------------------------ * Memory efficiency has been improved. +* QRcode_clearCache() has been deprecated. * Error correction code generating functions have been improved. * Command line tool "qrencode" has been improved: * XPM support. (Thanks to Tobias Klauser) @@ -16,15 +17,15 @@ Version 4.0.0 (2016.x.x) Release Note: While the API has not been changed since the previous major release, we -incremented the major version number of libqrencode to 4. +incremented the major version number of libqrencode to 4 because the +implementation of the library has been largely changed. -This release improves the performance of code generation. Its memory footprint -is also reduced. +This release improves the performance and memory footprints of code generation. -Now you can build libqrencode with CMake optionally. +Now you can build libqrencode with CMake. -When building the test programs, please note that the required SDL version has -changed from 1.2 to 2.0. +If you build the test programs, please note that the required SDL version has +been changed from 1.2 to 2.0. Version 3.4.4 (2014.7.24) -- cgit 0.0.5-2-1-g0f52 From d43d4c073dd54feaf1700cb86cb0f0127615c268 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Sep 2017 04:47:11 +0900 Subject: Documentation updates. --- ChangeLog | 2 +- README | 12 ++++++------ README.md | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6fd03bf73..18358bc969 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,7 +6,7 @@ backward compatibility. * qrenc.c: - Copyright year updated. - * NEWS: + * NEWS, README, README.md: - Documentation update. 2017.09.02 Kentaro Fukuchi diff --git a/README b/README index 10bb5096a1..c86d460493 100644 --- a/README +++ b/README @@ -53,19 +53,19 @@ directories. By default, /usr/local/lib and /usr/local/include. You can change the destination directory by passing some options to the configure script. Run "./configure --help" to see the list of options. -It also installs a binary "qrencode" to /usr/local/bin. If you want not to -install it, give "--without-tools" option to the configure script. +It also installs a command line tool "qrencode" to /usr/local/bin. If you want +not to build it, give "--without-tools" option to the configure script. When you downloaded a development tree from github, it is required to run "autogen.sh" at first to generate configure script. -If the configure script does not work well, try CMake contributed by André. +If the configure script does not work well, try to use CMake. cmake . make -When you want to run the tests, give "--with-tests" option to configure, -or "-DWITH_TESTS=YES" to cmake. +When you want to build the test programs, give "--with-tests" option to +configure, or "-DWITH_TESTS=YES" to cmake. USAGE @@ -88,7 +88,7 @@ application. LICENSING INFORMATION ===================== -Copyright (C) 2006-2012 Kentaro Fukuchi +Copyright (C) 2006-2017 Kentaro Fukuchi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free diff --git a/README.md b/README.md index 7e0f7bdbbb..666291d889 100644 --- a/README.md +++ b/README.md @@ -55,21 +55,21 @@ directories. By default, /usr/local/lib and /usr/local/include. You can change the destination directory by passing some options to the configure script. Run "./configure --help" to see the list of options. -It also installs a binary "qrencode" to /usr/local/bin. If you want not to -install it, give "--without-tools" option to the configure script. +It also installs a command line tool "qrencode" to /usr/local/bin. If you want +not to build it, give "--without-tools" option to the configure script. When you downloaded a development tree from github, it is required to run "autogen.sh" at first to generate configure script. -If the configure script does not work well, try CMake contributed by André. +If the configure script does not work well, try to use CMake. ``` cmake . make ``` -When you want to run the tests, give "--with-tests" option to `configure`, -or "-DWITH\_TESTS=YES" to `cmake`. +When you want to build the test programs, give "--with-tests" option to +configure, or "-DWITH\_TESTS=YES" to cmake. USAGE @@ -92,7 +92,7 @@ application. LICENSING INFORMATION ===================== -Copyright (C) 2006-2012 Kentaro Fukuchi +Copyright (C) 2006-2017 Kentaro Fukuchi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free -- cgit 0.0.5-2-1-g0f52 From 7d196877b25cc333fd3f91f488f64942041dea4c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Sep 2017 23:48:12 +0900 Subject: Updated to the newer version bundled with gettext-0.19.8.1. --- ChangeLog | 2 ++ use/config.rpath | 18 ++++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18358bc969..bd0414f4ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ - Copyright year updated. * NEWS, README, README.md: - Documentation update. + * use/config.rpath: + - Updated to the newer version bundled with gettext-0.19.8.1. 2017.09.02 Kentaro Fukuchi * configure.ac: diff --git a/use/config.rpath b/use/config.rpath index c38b914d6b..98183ff2f2 100755 --- a/use/config.rpath +++ b/use/config.rpath @@ -2,7 +2,7 @@ # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # -# Copyright 1996-2013 Free Software Foundation, Inc. +# Copyright 1996-2016 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit , 1996 # @@ -367,11 +367,7 @@ else dgux*) hardcode_libdir_flag_spec='-L$libdir' ;; - freebsd2.2*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - freebsd2*) + freebsd2.[01]*) hardcode_direct=yes hardcode_minus_L=yes ;; @@ -548,13 +544,11 @@ case "$host_os" in dgux*) library_names_spec='$libname$shrext' ;; + freebsd[23].*) + library_names_spec='$libname$shrext$versuffix' + ;; freebsd* | dragonfly*) - case "$host_os" in - freebsd[123]*) - library_names_spec='$libname$shrext$versuffix' ;; - *) - library_names_spec='$libname$shrext' ;; - esac + library_names_spec='$libname$shrext' ;; gnu*) library_names_spec='$libname$shrext' -- cgit 0.0.5-2-1-g0f52 From 69edfbdf2d6e64329d8946d0f82d9728624f5a08 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 00:08:55 +0900 Subject: Documentation updated. --- README | 5 +++-- README.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README b/README index c86d460493..0e8839a155 100644 --- a/README +++ b/README @@ -129,8 +129,9 @@ ACKNOWLEDGMENTS QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other countries. -Reed-Solomon encoder is rewritten by Kentaro Fukuchi, referring to the FEC -library developed by Phil Karn (KA9Q). +Reed-Solomon encoder included in this library is originally taken from FEC +library developed by Phil Karn (KA9Q) and distributed under the terms of the +GNU LGPL, then rewritten by Kentaro Fukuchi. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * NANKI Haruo - improved lower-case characters encoding diff --git a/README.md b/README.md index 666291d889..23ed917e51 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,9 @@ ACKNOWLEDGMENTS QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other countries. -Reed-Solomon encoder is rewritten by Kentaro Fukuchi, referring to the FEC -library developed by Phil Karn (KA9Q). +Reed-Solomon encoder included in this library is originally taken from FEC +library developed by Phil Karn (KA9Q) and distributed under the terms of the +GNU LGPL, then rewritten by Kentaro Fukuchi. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * NANKI Haruo - improved lower-case characters encoding -- cgit 0.0.5-2-1-g0f52 From 85a3f66c9982ca71d048cf35251e5a72a8fcf441 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 00:09:07 +0900 Subject: Copyright year updated. --- ChangeLog | 2 ++ qrencode.1.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bd0414f4ff..f13dd7c346 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ - Documentation update. * use/config.rpath: - Updated to the newer version bundled with gettext-0.19.8.1. + * qrencode.1.in: + - Copyright year updated. 2017.09.02 Kentaro Fukuchi * configure.ac: diff --git a/qrencode.1.in b/qrencode.1.in index bf39961dec..57bb64ed89 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -113,4 +113,4 @@ Main Web Site: https://fukuchi.org/works/qrencode/ Source code repository: https://github.com/fukuchi/libqrencode/ .SH COPYRIGHT -Copyright (C) 2006-2012 Kentaro Fukuchi. +Copyright (C) 2006-2017 Kentaro Fukuchi. -- cgit 0.0.5-2-1-g0f52 From 6d503504be2d45a32f9e0d421586f7629410a2a3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 12:43:21 +0900 Subject: Copyright year updated for the next major update. --- ChangeLog | 4 ++++ bitstream.c | 2 +- bitstream.h | 2 +- mask.c | 2 +- mask.h | 2 +- mmask.c | 2 +- mmask.h | 2 +- mqrspec.c | 2 +- qrencode_inner.h | 2 +- qrinput.c | 2 +- qrinput.h | 2 +- qrspec.c | 2 +- qrspec.h | 2 +- rsecc.c | 2 +- rsecc.h | 2 +- split.c | 2 +- split.h | 2 +- 17 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f13dd7c346..eb4418c9ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017.09.06 Kentaro Fukuchi + * *.[ch]: + - Copyright year updated for the next major update. + 2017.09.06 Kentaro Fukuchi * mqrspec.h: - Documentation update. diff --git a/bitstream.c b/bitstream.c index 9d5fc90d67..a2ec389926 100644 --- a/bitstream.c +++ b/bitstream.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Binary sequence class. - * Copyright (C) 2006-2014 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/bitstream.h b/bitstream.h index e138ec5ff9..45373c1d20 100644 --- a/bitstream.h +++ b/bitstream.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Binary sequence class. - * Copyright (C) 2006-2014 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mask.c b/mask.c index dea1a079ba..3d7e15de33 100644 --- a/mask.c +++ b/mask.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mask.h b/mask.h index 28c3afef8f..169e64b2bb 100644 --- a/mask.h +++ b/mask.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mmask.c b/mmask.c index 143c51259e..a1fb041e60 100644 --- a/mmask.c +++ b/mmask.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking for Micro QR Code. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mmask.h b/mmask.h index 57229a450a..56a58cd2d7 100644 --- a/mmask.h +++ b/mmask.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Masking for Micro QR Code. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/mqrspec.c b/mqrspec.c index fe7b5d5018..6513a3314d 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Micro QR Code specification in convenient format. - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/qrencode_inner.h b/qrencode_inner.h index f78136fa8e..58e5b7d0ae 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Header for test use - * Copyright (C) 2006-2011 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrinput.c b/qrinput.c index 71c619fb04..0908bbfe38 100644 --- a/qrinput.c +++ b/qrinput.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006-2014 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrinput.h b/qrinput.h index 432fb44357..080e1840af 100644 --- a/qrinput.h +++ b/qrinput.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data chunk class - * Copyright (C) 2006-2014 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrspec.c b/qrspec.c index a4d5ba4453..6b845a4ca9 100644 --- a/qrspec.c +++ b/qrspec.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code specification in convenient format. - * Copyright (C) 2006-2013 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/qrspec.h b/qrspec.h index d8cbcc9a51..4d01879ed3 100644 --- a/qrspec.h +++ b/qrspec.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code specification in convenient format. - * Copyright (C) 2006-2013 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/rsecc.c b/rsecc.c index 5ca0511ab6..4ace001ae2 100644 --- a/rsecc.c +++ b/rsecc.c @@ -6,7 +6,7 @@ * developed by Phil Karn (KA9Q). * * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - * Copyright (C) 2014 Kentaro Fukuchi + * Copyright (C) 2014-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/rsecc.h b/rsecc.h index a9374c003a..42e2a09717 100644 --- a/rsecc.h +++ b/rsecc.h @@ -6,7 +6,7 @@ * developed by Phil Karn (KA9Q). * * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - * Copyright (C) 2014 Kentaro Fukuchi + * Copyright (C) 2014-2017 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/split.c b/split.c index 4ba7a7404a..a58450e1ac 100644 --- a/split.c +++ b/split.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006-2013 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) diff --git a/split.h b/split.h index 4c97c3dee1..81829e078e 100644 --- a/split.h +++ b/split.h @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * Input data splitter. - * Copyright (C) 2006-2013 Kentaro Fukuchi + * Copyright (C) 2006-2017 Kentaro Fukuchi * * The following data / specifications are taken from * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) -- cgit 0.0.5-2-1-g0f52 From c3b05cd798940e0fb14762e39c98b27a17aa30c6 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 13:47:48 +0900 Subject: Added some progress messages. --- tests/test_configure.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_configure.sh b/tests/test_configure.sh index a2f9b3f309..4a301259a0 100755 --- a/tests/test_configure.sh +++ b/tests/test_configure.sh @@ -7,6 +7,8 @@ CONFIG_H="$BASEDIR/config.h" LIBQRENCODE_PC_IN="$BASEDIR/libqrencode.pc.in" LIBQRENCODE_PC="$BASEDIR/libqrencode.pc" +echo "Testing configure scripts..." + (cd $BASEDIR; ./autogen.sh) # test config.h.in @@ -50,6 +52,10 @@ if test ! $? -eq 1; then exit 1 fi +echo "All tests of configure script passed. Now reconfiguring..." + (cd $BASEDIR; ./configure --with-tests > /dev/null) +echo "Done." + exit 0 -- cgit 0.0.5-2-1-g0f52 From 7581de60c7ce163dd7ce1eafb4a48c84e41a4e7b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 13:52:50 +0900 Subject: Added some EXTRA_DIST files. --- Makefile.am | 3 ++- tests/Makefile.am | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index b9ff20768c..0bda0742a2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,8 @@ pkgconfig_DATA = libqrencode.pc EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \ Makefile.am tests/Makefile.am qrencode.spec.in qrencode.spec \ - qrencode.1.in Doxyfile tests/test_all.sh + qrencode.1.in Doxyfile \ + CMakeLists.txt cmake/FindIconv.cmake if BUILD_TOOLS bin_PROGRAMS = qrencode diff --git a/tests/Makefile.am b/tests/Makefile.am index c63eccdecf..bc96fdec4d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,7 +23,7 @@ if HAVE_LIBPTHREAD noinst_PROGRAMS += pthread_qrencode endif -EXTRA_DIST = frame URI_testset.inc +EXTRA_DIST = test_all.sh test_configure.sh frame URI_testset.inc CMakeLists.txt libdecoder_a_SOURCES = decoder.c decoder.h datachunk.c datachunk.h rsecc_decoder.c rsecc_decoder.h -- cgit 0.0.5-2-1-g0f52 From 5ef4756952cd2f5a057d77f73ed086f416000d18 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 13:53:41 +0900 Subject: Added test_configure.sh to the list. --- tests/test_all.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_all.sh b/tests/test_all.sh index 06de1d4b02..55550159e9 100755 --- a/tests/test_all.sh +++ b/tests/test_all.sh @@ -10,3 +10,4 @@ ./test_mqrspec ./test_mmask ./test_monkey +./test_configure.sh -- cgit 0.0.5-2-1-g0f52 From d38244956c5a6c167d7daff3dda874dfd549237e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 14:40:59 +0900 Subject: Added 'CTestTestfile.cmake'. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4d6336bb87..491d2abdfe 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ autom4te.cache/ m4/ CMakeLists.txt.user CMakeCache.txt +CTestTestfile.cmake CMakeFiles/ cmake_install.cmake Makefile -- cgit 0.0.5-2-1-g0f52 From 3a35cb1d350da077189ee8162c3aa17a1eda4529 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 14:41:31 +0900 Subject: Newly added. --- makeREADME.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 makeREADME.sh diff --git a/makeREADME.sh b/makeREADME.sh new file mode 100755 index 0000000000..1132b0f60a --- /dev/null +++ b/makeREADME.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +sed '/^```$/d +s/DWITH\\_TESTS/DWITH_TESTS/ +1 { + s/^# // + s/encoding library.*/encoding library/ +} +' README.md > README -- cgit 0.0.5-2-1-g0f52 From c520fac60e58a97e5c43605b1ba84eeeb0709b6a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 14:42:27 +0900 Subject: Bumped version to 4.0.0. --- CMakeLists.txt | 2 +- ChangeLog | 13 +++++++++++++ README | 2 +- README.md | 2 +- configure.ac | 4 ++-- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fd953cb31..f08b2cb550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1.0) -project(QRencode VERSION 3.9.0 LANGUAGES C) +project(QRencode VERSION 4.0.0 LANGUAGES C) option(WITH_TOOLS "Build utility tools" YES ) option(WITH_TESTS "Build tests" NO ) diff --git a/ChangeLog b/ChangeLog index eb4418c9ec..620ad74f7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,19 @@ 2017.09.06 Kentaro Fukuchi * *.[ch]: - Copyright year updated for the next major update. + * tests/test_configure.sh: + - Added some progress messages. + * tests/test_all.sh: + - Added test_configure.sh to the list. + * Makefile.am, tests/Makefile.am: + - Added some EXTRA_DIST files. + - Moved some EXTRA_DIST files from Makefile.am to tests/Makefile.am. + * makeREADME.sh: + - Newly added. + * .gitignore: + - Added 'CTestTestfile.cmake'. + * configure.ac, CMakeLists.txt, README, README.md: + - Bumped version to 4.0.0, preparing for major update. 2017.09.06 Kentaro Fukuchi * mqrspec.h: diff --git a/README b/README index 0e8839a155..d5f0398f64 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -libqrencode 3.9.0 - QR Code encoding library +libqrencode 4.0.0 - QR Code encoding library GENERAL INFORMATION =================== diff --git a/README.md b/README.md index 23ed917e51..a5e601a2dc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# libqrencode 3.9.0 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) +# libqrencode 4.0.0 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) GENERAL INFORMATION =================== diff --git a/configure.ac b/configure.ac index 13cb68076d..b684cea92e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -m4_define([__MAJOR_VERSION], [3])dnl -m4_define([__MINOR_VERSION], [9])dnl +m4_define([__MAJOR_VERSION], [4])dnl +m4_define([__MINOR_VERSION], [0])dnl m4_define([__MICRO_VERSION], [0])dnl m4_define([__VERSION], [__MAJOR_VERSION.__MINOR_VERSION.__MICRO_VERSION])dnl AC_INIT(QRencode, __VERSION) -- cgit 0.0.5-2-1-g0f52 From 6af0665b39ffc366ef843efebc802348feb8ecb3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 15:25:50 +0900 Subject: Configuration improved. --- .travis.yml | 8 +++----- ChangeLog | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8229968071..9d21088df4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +dist: trusty +sudo: required language: c compiler: @@ -5,7 +7,6 @@ compiler: before_install: - sudo apt-get update -- sudo apt-get install libsdl-image1.2-dev - sudo apt-get install libpng12-dev install: @@ -13,14 +14,11 @@ install: - ./configure --with-tests && make - sudo make install - mkdir build && cd build -- wget https://cmake.org/files/v3.1/cmake-3.1.0-Linux-x86_64.tar.gz -- tar xf cmake-3.1.0-Linux-x86_64.tar.gz -- ./cmake-3.1.0-Linux-x86_64/bin/cmake .. -DBUILD_SHARED_LIBS=on -DBUILD_TESTING=on && make +- cmake .. -DWITH_TESTS=yes -DBUILD_SHARED_LIBS=on && make - DESTDIR=$PWD/install make install script: - cd $TRAVIS_BUILD_DIR/tests -- ./test_configure.sh - ./test_all.sh - cd $TRAVIS_BUILD_DIR/build/tests - cp $TRAVIS_BUILD_DIR/tests/frame ./ diff --git a/ChangeLog b/ChangeLog index 620ad74f7f..7674f36bba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ - Added 'CTestTestfile.cmake'. * configure.ac, CMakeLists.txt, README, README.md: - Bumped version to 4.0.0, preparing for major update. + * .travis.yml: + - Configuration improved. 2017.09.06 Kentaro Fukuchi * mqrspec.h: -- cgit 0.0.5-2-1-g0f52 From 5e244e4d20fe17db4356b3e5590dc3f3652e3f64 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 23:36:41 +0900 Subject: Added a new rule to generate README from README.md. --- Makefile.am | 4 ++ README | 178 ------------------------------------------------------------ 2 files changed, 4 insertions(+), 178 deletions(-) delete mode 100644 README diff --git a/Makefile.am b/Makefile.am index 0bda0742a2..9142664e40 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,10 @@ include_HEADERS = qrencode.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libqrencode.pc +noinst_DATA = README +CLEANFILES = README +README: README.md + - ./makeREADME.sh EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \ Makefile.am tests/Makefile.am qrencode.spec.in qrencode.spec \ diff --git a/README b/README deleted file mode 100644 index d5f0398f64..0000000000 --- a/README +++ /dev/null @@ -1,178 +0,0 @@ -libqrencode 4.0.0 - QR Code encoding library - -GENERAL INFORMATION -=================== -Libqrencode is a library for encoding data in a QR Code symbol, a 2D symbology -that can be scanned by handy terminals such as a mobile phone with CCD. The -capacity of QR Code is up to 7000 digits or 4000 characters and has high -robustness. - -Libqrencode accepts a string or a list of data chunks then encodes in a QR Code -symbol as a bitmap array. While other QR Code applications generate an image -file, using libqrencode allows applications to render QR Code symbols from raw -bitmap data directly. This library also contains a command-line utility outputs -a QR Code symbol as a PNG image. - - -SPECIFICATION -============= -Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial -Standards) X0510:2004 or ISO/IEC 18004. Most of features in the specification -are implemented such as: -- Numeric, alphabet, Japanese kanji (Shift-JIS) or any 8 bit code can be - embedded -- Optimized encoding of a string -- Structured-append of symbols -- Micro QR Code (experimental) - -Currently the following features are not supported: -- ECI and FNC1 mode -- QR Code model 1 (deprecated) - - -INSTALL -======= - -Requirements ------------- -While the command-line utility and some test programs use libpng or SDL 2.0, -the libqrencode library itself has no dependencies. You can skip compiling -tests and/or tools if you want not to install programs using SDL or PNG. - -Compile & install ------------------ -Just try - -./configure -make -sudo make install -sudo ldconfig - -This compiles and installs the library and header file to the appropriate -directories. By default, /usr/local/lib and /usr/local/include. You can change -the destination directory by passing some options to the configure script. -Run "./configure --help" to see the list of options. - -It also installs a command line tool "qrencode" to /usr/local/bin. If you want -not to build it, give "--without-tools" option to the configure script. - -When you downloaded a development tree from github, it is required to run -"autogen.sh" at first to generate configure script. - -If the configure script does not work well, try to use CMake. - -cmake . -make - -When you want to build the test programs, give "--with-tests" option to -configure, or "-DWITH_TESTS=YES" to cmake. - - -USAGE -===== -Basic usages of this library are written in the header file (qrencode.h). -You can generate a manual of the library by using Doxygen. - - -WARNINGS -======== -The library is distributed WITHOUT ANY WARRANTY. - -Micro QR Code support is EXPERIMENTAL. - -Be careful to use the command line tool (qrencode) if it is used by a web -application (e.g. CGI script). For example, giving "-s" option with a large -number to qrencode may cause DoS. The parameters should be checked by the -application. - - -LICENSING INFORMATION -===================== -Copyright (C) 2006-2017 Kentaro Fukuchi - -This library is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License as published by the Free -Software Foundation; either version 2.1 of the License, or any later version. - -This library is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along -with this library; if not, write to the Free Software Foundation, Inc., 51 -Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -CONTACT -======= -Visit the homepage at: - -https://fukuchi.org/works/qrencode/ - -for new releases. The git repository is available at: - -https://github.com/fukuchi/libqrencode - -Please mail any bug reports, suggestions, comments, and questions to: - -Kentaro Fukuchi - -or submit issues to: - -https://github.com/fukuchi/libqrencode/issues - -Questions of license compliance are also welcome. - - -ACKNOWLEDGMENTS -=============== -QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other -countries. - -Reed-Solomon encoder included in this library is originally taken from FEC -library developed by Phil Karn (KA9Q) and distributed under the terms of the -GNU LGPL, then rewritten by Kentaro Fukuchi. -Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - -* NANKI Haruo - improved lower-case characters encoding -* Philippe Delcroix - improved mask evaluation -* Yusuke Mihara - structured-append support -* David Dahl - DPI and SVG support patch -* Adam Shepherd - bug fix patch of the mask evaluation -* Josef Eisl (@zapster) - EPS support patch -* Colin (@moshen) - ANSI support patch -* Ralf Ertzinger - ASCII support patch -* Yutaka Niibe (@gniibe)- various bug fix patches -* Dan Storm (@Repox) - SVG support patch -* Lennart Poettering (@mezcalero) - - improved text art patch -* Yann Droneaud - improved input validation patch -* Viona - bug fix patch for string splitting -* Daniel Dörrhöfer (@d4ndo) - - RLE option, some bug fixes, Travis configuration -* Greg Hart - PNG32 support patch -* @siggi-heltau - bug fix patch -* Tobias Klauser (@tklauser) - - bug fix patch, XPM support patch -* Robert Petersen (@ripetersen) - - added ability to read input data from a file -* @Oblomov - improved SVG support patch -* @mgorny - reverse mappings of UTF8 and ANSIUTF8 -* @EckoEdc - MinGW support patch -* Sebastian Buchwald (@UniQP) - - Various code cleanups -* André Klitzing (@misery) - - CMake support -* Alexey Nikolaev (@aleksey-nikolaev) - - improved CMake support -* Vilppu Vuorinen (@vilppuvuorinen) - - improved CMake support -* @vanillahsu - bug fix patch -* Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, - Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, - Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, - David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), - Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, - Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno, Jakub Wilk, @KangLin - - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From 0d5d1d090528bf96810b795e0d0846c3acd4831b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Sep 2017 23:43:12 +0900 Subject: Added 'Katsumi Saito' to the section of ACKNOWLEDGMENTS. --- ChangeLog | 9 ++++++++- README.md | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7674f36bba..d8e533e91d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2017.09.06 Kentaro Fukuchi +2017.09.07 Kentaro Fukuchi * *.[ch]: - Copyright year updated for the next major update. * tests/test_configure.sh: @@ -16,6 +16,13 @@ - Bumped version to 4.0.0, preparing for major update. * .travis.yml: - Configuration improved. + * Makefile.am, README: + - Added a new rule to generate README from README.md. + - README is no longer needed in the source tree. + * README.md: + - Added Katsumi Saito, the contributor of SPEC file, has been added to + the section of ACKNOWLEDGMENTS. We apologize for this lack of + acknowledgment. 2017.09.06 Kentaro Fukuchi * mqrspec.h: diff --git a/README.md b/README.md index a5e601a2dc..a40854047f 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ GNU LGPL, then rewritten by Kentaro Fukuchi. Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * NANKI Haruo - improved lower-case characters encoding +* Katsumi Saito - SPEC file * Philippe Delcroix - improved mask evaluation * Yusuke Mihara - structured-append support * David Dahl - DPI and SVG support patch -- cgit 0.0.5-2-1-g0f52 From 077f357cd4de258322c85a74f05b0a3119815bc5 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 8 Sep 2017 00:15:11 +0900 Subject: Added 'README' to the ignore list. --- .gitignore | 1 + ChangeLog | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 491d2abdfe..df00af7ac9 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ CMakeFiles/ cmake_install.cmake Makefile Makefile.in +README build config.log configure diff --git a/ChangeLog b/ChangeLog index d8e533e91d..fc4cd9311c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,8 +10,6 @@ - Moved some EXTRA_DIST files from Makefile.am to tests/Makefile.am. * makeREADME.sh: - Newly added. - * .gitignore: - - Added 'CTestTestfile.cmake'. * configure.ac, CMakeLists.txt, README, README.md: - Bumped version to 4.0.0, preparing for major update. * .travis.yml: @@ -19,6 +17,9 @@ * Makefile.am, README: - Added a new rule to generate README from README.md. - README is no longer needed in the source tree. + * .gitignore: + - Added 'CTestTestfile.cmake'. + - Added 'README' * README.md: - Added Katsumi Saito, the contributor of SPEC file, has been added to the section of ACKNOWLEDGMENTS. We apologize for this lack of -- cgit 0.0.5-2-1-g0f52 From 3e629c7ba1dd67bcfff5d43ef338be77cfd9ed23 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 14:38:53 +0900 Subject: data buffer now allocated as a static array. --- qrenc.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/qrenc.c b/qrenc.c index f1e6ce57a8..0a0453766c 100644 --- a/qrenc.c +++ b/qrenc.c @@ -227,18 +227,13 @@ static int color_set(unsigned char color[4], const char *value) return 0; } -#define MAX_DATA_SIZE (7090 * 16) /* from the specification */ +#define MAX_DATA_SIZE (7090 * 2) /* timed by the safty factor 2 */ +static unsigned char data_buffer[MAX_DATA_SIZE]; static unsigned char *readFile(FILE *fp, int *length) { - unsigned char *buffer; int ret; - buffer = (unsigned char *)malloc(MAX_DATA_SIZE + 1); - if(buffer == NULL) { - fprintf(stderr, "Memory allocation failed.\n"); - exit(EXIT_FAILURE); - } - ret = fread(buffer, 1, MAX_DATA_SIZE, fp); + ret = fread(data_buffer, 1, MAX_DATA_SIZE, fp); if(ret == 0) { fprintf(stderr, "No input data.\n"); exit(EXIT_FAILURE); @@ -248,10 +243,10 @@ static unsigned char *readFile(FILE *fp, int *length) exit(EXIT_FAILURE); } - buffer[ret] = '\0'; + data_buffer[ret] = '\0'; *length = ret; - return buffer; + return data_buffer; } static FILE *openFile(const char *outfile) -- cgit 0.0.5-2-1-g0f52 From 8e4c09e46b6622dfc87119a22c3c6c18fd8ca6bd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 14:40:42 +0900 Subject: Documentation updates. --- ChangeLog | 7 +++++++ README.md | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc4cd9311c..856f18a013 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2017.09.11 Kentaro Fukuchi + * qrenc.c: + - Read buffer is now allocated as a static array to avoid malloc(). + Suppresses memory leak warnings. (Thanks to @c-273) + * README.md: + - INSTALL and ACKNOWLEDGMENTS sections are updated. + 2017.09.07 Kentaro Fukuchi * *.[ch]: - Copyright year updated for the next major update. diff --git a/README.md b/README.md index a40854047f..c17d090f35 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ Run "./configure --help" to see the list of options. It also installs a command line tool "qrencode" to /usr/local/bin. If you want not to build it, give "--without-tools" option to the configure script. -When you downloaded a development tree from github, it is required to run -"autogen.sh" at first to generate configure script. +When you downloaded the source code from github, run "autogen.sh" at first to +generate configure script. If the configure script does not work well, try to use CMake. @@ -125,8 +125,6 @@ or submit issues to: https://github.com/fukuchi/libqrencode/issues -Questions of license compliance are also welcome. - ACKNOWLEDGMENTS =============== @@ -179,5 +177,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno, Jakub Wilk, @KangLin + Yuji Ueno, Jakub Wilk, @KangLin, @c-273 - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From 67c89c402d830428c5fad88948099213ce57cd13 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 14:48:17 +0900 Subject: Some documentation work. --- README.md | 4 +++- makeREADME.sh | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c17d090f35..bfd36ab13e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# libqrencode 4.0.0 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) +# libqrencode - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) + +**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 3.4.4, and upcoming version is 4.0.0. GENERAL INFORMATION =================== diff --git a/makeREADME.sh b/makeREADME.sh index 1132b0f60a..d34dd8380e 100755 --- a/makeREADME.sh +++ b/makeREADME.sh @@ -1,6 +1,7 @@ #!/bin/sh sed '/^```$/d +/^\*\*Attention/d s/DWITH\\_TESTS/DWITH_TESTS/ 1 { s/^# // -- cgit 0.0.5-2-1-g0f52 From b64fad4da10c1207494cc79a2a957d11341019df Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 14:49:15 +0900 Subject: Some documentation work. --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 856f18a013..ea221656f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ Suppresses memory leak warnings. (Thanks to @c-273) * README.md: - INSTALL and ACKNOWLEDGMENTS sections are updated. + * makeREADME.sh: + - Now it removes the attention line for github.com users. 2017.09.07 Kentaro Fukuchi * *.[ch]: -- cgit 0.0.5-2-1-g0f52 From 60eb011a5d9abbf8736eed04f7cd548138d5f9e9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 15:10:40 +0900 Subject: Test script for qrencode command has been added. Dedicated to @c-273 (#102). --- ChangeLog | 4 ++++ tests/test_images/.gitignore | 2 -- tests/test_qrenc.sh | 50 ++++++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 8 deletions(-) delete mode 100644 tests/test_images/.gitignore diff --git a/ChangeLog b/ChangeLog index ea221656f1..1c87b30156 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,10 @@ - INSTALL and ACKNOWLEDGMENTS sections are updated. * makeREADME.sh: - Now it removes the attention line for github.com users. + * tests/test_qrenc.sh: + - Experimental test script for the command 'qrencode'. + - Dedicated to @c-273, who warned the possible memory leaks of qrencode. + (See #102) 2017.09.07 Kentaro Fukuchi * *.[ch]: diff --git a/tests/test_images/.gitignore b/tests/test_images/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/tests/test_images/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/test_qrenc.sh b/tests/test_qrenc.sh index ca056893f9..8f09f26a32 100755 --- a/tests/test_qrenc.sh +++ b/tests/test_qrenc.sh @@ -1,10 +1,48 @@ -#!/bin/sh -e +#!/bin/sh COMMAND=../qrencode -TEXT="hello" TARGET_DIR="test_images" +VALGRIND_COMMAND="libtool --mode=execute valgrind" +VALGRIND_OPTIONS="--leak-check=full --show-reachable=yes" -$COMMAND -t SVG -o $TARGET_DIR/svg.svg $TEXT -$COMMAND -t SVG --rle -o $TARGET_DIR/svg-rle.svg $TEXT -$COMMAND -t SVG --svg-path -o $TARGET_DIR/svg-path.svg $TEXT -$COMMAND -t SVG --rle --svg-path -o $TARGET_DIR/svg-rle-path.svg $TEXT +if [ "x$1" = 'xvalgrind' ]; then + COMMAND="$VALGRIND_COMMAND $VALGRIND_OPTIONS $COMMAND" +fi + +repeatchar() +{ + printf %${2}s | tr ' ' ${1} +} + +test_command_success() +{ + repeatchar ${1} ${2} | $COMMAND -o - -l L ${3} > /dev/null + if [ $? -ne 0 ]; then + echo "Failed to encode $fn.txt" + exit 1 + fi +} + +test_command_fail() +{ + repeatchar ${1} ${2} | $COMMAND -o - -l L ${3} > /dev/null + if [ $? -eq 0 ]; then + echo "Unexpectedly successed to encode '${1}'x'${2}' with '${3}'." + exit 1 + else + echo "^^^this is the expected error. Everything OK." + fi +} + +mkdir -p $TARGET_DIR + +test_command_success '1' 7089 +test_command_success 'A' 4296 +test_command_success 'a' 2953 +test_command_success '\211' 3634 '-k' + +test_command_fail '1' 7090 +test_command_fail 'A' 4297 +test_command_fail 'a' 2954 +test_command_fail '\211' 3636 '-k' +test_command_fail '1' 15000 -- cgit 0.0.5-2-1-g0f52 From 817e167d13b5817983fbfe19415d5cf1bc0e876d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 15:15:47 +0900 Subject: SPEC file has been removed. (closes #105) --- .gitignore | 1 - ChangeLog | 2 ++ Makefile.am | 2 +- configure.ac | 2 +- qrencode.spec.in | 72 -------------------------------------------------------- 5 files changed, 4 insertions(+), 75 deletions(-) delete mode 100644 qrencode.spec.in diff --git a/.gitignore b/.gitignore index df00af7ac9..7fd2e09a78 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,6 @@ libtool stamp-h1 qrencode qrencode.1 -qrencode.spec libqrencode.pc tests/create_frame_pattern tests/create_mqr_frame_pattern diff --git a/ChangeLog b/ChangeLog index 1c87b30156..9dccc8aed7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ - Experimental test script for the command 'qrencode'. - Dedicated to @c-273, who warned the possible memory leaks of qrencode. (See #102) + * qrencode.spec.in, Makefile.am, configure.ac: + - SPEC file has been removed. (closes #105) 2017.09.07 Kentaro Fukuchi * *.[ch]: diff --git a/Makefile.am b/Makefile.am index 9142664e40..03dde7e2b9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,7 +31,7 @@ README: README.md - ./makeREADME.sh EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \ - Makefile.am tests/Makefile.am qrencode.spec.in qrencode.spec \ + Makefile.am tests/Makefile.am \ qrencode.1.in Doxyfile \ CMakeLists.txt cmake/FindIconv.cmake diff --git a/configure.ac b/configure.ac index b684cea92e..c02ad5eb5b 100644 --- a/configure.ac +++ b/configure.ac @@ -41,7 +41,7 @@ case "${target}" in esac AM_CONDITIONAL(MINGW, [test "x$mingw" = "xyes" ]) -AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.spec qrencode.1]) +AC_CONFIG_FILES([Makefile libqrencode.pc tests/Makefile qrencode.1]) AC_CHECK_FUNCS([strdup]) diff --git a/qrencode.spec.in b/qrencode.spec.in deleted file mode 100644 index 0cf29256ab..0000000000 --- a/qrencode.spec.in +++ /dev/null @@ -1,72 +0,0 @@ -%define ver @VERSION@ -%define rel 1 - -Name: qrencode -Version: %{ver} -Release: %{rel}%{?dist} -Summary: Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D symbology that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness. - -Group: System Environment/Libraries -License: LGPLv2+ -URL: https://fukuchi.org/works/qrencode/ -Source0: https://fukuchi.org/works/qrencode/%{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -%description -Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Micro QR Code, QR Code model 1. - -%package devel -Summary: Development files for libqrencode -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} - -%description devel -Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Currently the following features are not supported: ECI and FNC1 mode, Micro QR Code, QR Code model 1. - -This package contains development files for libqrencode. - -%prep -%setup -q - - -%build -%configure --without-tests -make %{?_smp_mflags} - - -%install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT -rm -f $RPM_BUILD_ROOT%{_libdir}/*.la - - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -%defattr(-,root,root,-) -%doc COPYING TODO ChangeLog NEWS README -%{_libdir}/libqrencode.so.* -%{_bindir}/qrencode -%{_mandir}/man1/qrencode.1.gz - -%files devel -%defattr(-,root,root,-) -%{_includedir}/qrencode.h -%{_libdir}/libqrencode.so -%{_libdir}/pkgconfig/libqrencode.pc - -%changelog -* Sat Oct 09 2010 Kentaro Fukuchi 3.9.0-1 -- URL and Source0 have been updated. -* Fri May 01 2008 Kentaro Fukuchi 3.0.1-1 -- The man page has been packaged correctly. -* Tue May 15 2007 Kentaro Fukuchi 1.0.2-2 -- Summary has been synchronized to README. -* Thu May 09 2007 Katsumi Saito 1.0.2-1 -- Initial RPM release -- cgit 0.0.5-2-1-g0f52 From 0ac90bb7f16af7a1abaa33f8408e89ea37d34e16 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 16:14:13 +0900 Subject: README generation rule improved. --- Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 03dde7e2b9..d631b6dfe6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,9 +26,9 @@ include_HEADERS = qrencode.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libqrencode.pc noinst_DATA = README -CLEANFILES = README -README: README.md - - ./makeREADME.sh +README_markdown_optional := $(wildcard README.md) +README: $(README_markdown_optional) + $(if $(README_markdown_optional), ./makeREADME.sh) EXTRA_DIST = libqrencode.pc.in autogen.sh configure.ac acinclude.m4 \ Makefile.am tests/Makefile.am \ -- cgit 0.0.5-2-1-g0f52 From b67691196fae5a9ef20b6a74f0393042f7df8ee4 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 16:25:19 +0900 Subject: Documentation work. --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9dccc8aed7..0286b5c7b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,8 @@ (See #102) * qrencode.spec.in, Makefile.am, configure.ac: - SPEC file has been removed. (closes #105) + * Makefile.am: + - The generation rule for README has been improved. 2017.09.07 Kentaro Fukuchi * *.[ch]: -- cgit 0.0.5-2-1-g0f52 From 321665a55f22efcfbc9a19baeb28eff300e74b24 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 16:30:53 +0900 Subject: Almost ready to release version 4.0.0. --- ChangeLog | 4 ++++ README.md | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0286b5c7b0..d3e55fdda4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,10 @@ - SPEC file has been removed. (closes #105) * Makefile.am: - The generation rule for README has been improved. + [4.0] + * 4.0 branch has been started. + * README.md: + - Version number added to the 1st line. 2017.09.07 Kentaro Fukuchi * *.[ch]: diff --git a/README.md b/README.md index bfd36ab13e..7043a18949 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# libqrencode - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) +# libqrencode 4.0.0 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) -**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 3.4.4, and upcoming version is 4.0.0. +**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.0. GENERAL INFORMATION =================== -- cgit 0.0.5-2-1-g0f52 From f82122a595cdeeba94cec27d8c0f52e9b3adc6d1 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 21:40:57 +0900 Subject: Fixed the URL to the badge of Travis CI. --- ChangeLog | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d3e55fdda4..5f747a4138 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ * 4.0 branch has been started. * README.md: - Version number added to the 1st line. + - Fixed the URL to the badge of Travis CI. 2017.09.07 Kentaro Fukuchi * *.[ch]: diff --git a/README.md b/README.md index 7043a18949..954e7333b9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# libqrencode 4.0.0 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) +# libqrencode 4.0.0 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=4.0)](https://travis-ci.org/fukuchi/libqrencode) **Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.0. -- cgit 0.0.5-2-1-g0f52 From 839e9b3332e656a9a888472257cfe1687894f18a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 21 Sep 2017 14:48:39 +0900 Subject: Version 4.0.0 has been released. --- ChangeLog | 6 ++++++ NEWS | 2 +- qrencode.1.in | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f747a4138..d383d867d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017.09.21 Kentaro Fukuchi + [4.0] + * qrencode.1.in, NEWS: + - Release date has been updated. + * Version 4.0.0 has ben released. + 2017.09.11 Kentaro Fukuchi * qrenc.c: - Read buffer is now allocated as a static array to avoid malloc(). diff --git a/NEWS b/NEWS index 209e045477..bd8b409e3e 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.0.0 (2017.9.x) +Version 4.0.0 (2017.9.21) ------------------------ * Memory efficiency has been improved. * QRcode_clearCache() has been deprecated. diff --git a/qrencode.1.in b/qrencode.1.in index 57bb64ed89..de92208b06 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -1,4 +1,4 @@ -.TH QRENCODE 1 "Jul. 6, 2014" "qrencode @VERSION@" +.TH QRENCODE 1 "Sep. 21, 2017" "qrencode @VERSION@" .SH NAME qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS -- cgit 0.0.5-2-1-g0f52 From 07f3c5d4bf9136711422cc7dbf28aff469da220a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 21 Sep 2017 15:11:23 +0900 Subject: Documentation updated. --- ChangeLog | 1 + NEWS | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d383d867d9..a0b0eba241 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ [4.0] * qrencode.1.in, NEWS: - Release date has been updated. + - Documentation updated. * Version 4.0.0 has ben released. 2017.09.11 Kentaro Fukuchi diff --git a/NEWS b/NEWS index bd8b409e3e..dbc99a8a5f 100644 --- a/NEWS +++ b/NEWS @@ -11,7 +11,8 @@ Version 4.0.0 (2017.9.21) * PNG32 (direct color mode) support. (Thanks to Greg Hart) * EPS output now supports foreground and background color. * New options "-r" and "--svg-path" have been added. -* CMake support has been added. (optional) + (Thanks to Robert Petersen and @Oblomov) +* CMake support has been added. (optional) (Thanks to @misery) * Various bug fixes. * Various performance improvements. -- cgit 0.0.5-2-1-g0f52 From 38327c2859c037835afdaac7e45758925a7fc13d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 29 Sep 2017 13:50:29 +0900 Subject: Format fixes. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 954e7333b9..b37a356d1f 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ SPECIFICATION Libqrencode supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004. Most of features in the specification are implemented such as: + - Numeric, alphabet, Japanese kanji (Shift-JIS) or any 8 bit code can be embedded - Optimized encoding of a string @@ -28,6 +29,7 @@ are implemented such as: - Micro QR Code (experimental) Currently the following features are not supported: + - ECI and FNC1 mode - QR Code model 1 (deprecated) -- cgit 0.0.5-2-1-g0f52 From 5c40306366fe7ff124af98ca5930d5f45322d23d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 29 Sep 2017 14:02:52 +0900 Subject: Some variables' type changed from int to size_t. (see #89 and #102) --- ChangeLog | 8 ++++++++ rsecc.c | 8 ++++---- rsecc.h | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a0b0eba241..3e2a7fa22e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2017.09.29 Kentaro Fukuchi + [4.0] + * README.md: + - Format fixes. + * rsecc.[ch]: + - Some variables' type changed from int to size_t. (closing #89 and + #102) + 2017.09.21 Kentaro Fukuchi [4.0] * qrencode.1.in, NEWS: diff --git a/rsecc.c b/rsecc.c index 4ace001ae2..5f629643ca 100644 --- a/rsecc.c +++ b/rsecc.c @@ -80,9 +80,9 @@ static void RSECC_init(void) initialized = 1; } -static void generator_init(int length) +static void generator_init(size_t length) { - int i, j; + size_t i, j; int g[max_generatorSize + 1]; g[0] = 1; @@ -102,9 +102,9 @@ static void generator_init(int length) generatorInitialized[length - min_length] = 1; } -int RSECC_encode(int data_length, int ecc_length, const unsigned char *data, unsigned char *ecc) +int RSECC_encode(size_t data_length, size_t ecc_length, const unsigned char *data, unsigned char *ecc) { - int i, j; + size_t i, j; unsigned char feedback; unsigned char *gen; diff --git a/rsecc.h b/rsecc.h index 42e2a09717..2c17dedb92 100644 --- a/rsecc.h +++ b/rsecc.h @@ -26,6 +26,6 @@ #ifndef RSECC_H #define RSECC_H -extern int RSECC_encode(int data_length, int ecc_length, const unsigned char *data, unsigned char *ecc); +extern int RSECC_encode(size_t data_length, size_t ecc_length, const unsigned char *data, unsigned char *ecc); #endif /* RSECC_H */ -- cgit 0.0.5-2-1-g0f52 From 6b9b2148fb75f31e70fea9a65873600fa8dc23a8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 12:38:12 +0900 Subject: Memory alignment improved. --- ChangeLog | 7 +++++++ bitstream.h | 2 +- qrencode.c | 2 +- qrencode_inner.h | 2 +- tests/test_qrencode.c | 8 ++++---- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e2a7fa22e..341255bc31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2017.10.02 Kentaro Fukuchi + [4.0] + * bitstream.h, qrencode.c, qrencode_inner.h: + - Memory alignment improved. + * tests/test_qrencode.c: + - Error messages improved. + 2017.09.29 Kentaro Fukuchi [4.0] * README.md: diff --git a/bitstream.h b/bitstream.h index 45373c1d20..35fe4f8099 100644 --- a/bitstream.h +++ b/bitstream.h @@ -24,8 +24,8 @@ typedef struct { int length; - unsigned char *data; int datasize; + unsigned char *data; } BitStream; extern BitStream *BitStream_new(void); diff --git a/qrencode.c b/qrencode.c index 99033f39d9..f0a872fe52 100644 --- a/qrencode.c +++ b/qrencode.c @@ -42,8 +42,8 @@ typedef struct { int dataLength; - unsigned char *data; int eccLength; + unsigned char *data; unsigned char *ecc; } RSblock; diff --git a/qrencode_inner.h b/qrencode_inner.h index 58e5b7d0ae..2ea54f59d0 100644 --- a/qrencode_inner.h +++ b/qrencode_inner.h @@ -32,8 +32,8 @@ typedef struct { int dataLength; - unsigned char *data; int eccLength; + unsigned char *data; unsigned char *ecc; } RSblock; diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 64ec0dab2c..63eb0a9bcf 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -50,7 +50,7 @@ void test_qrraw_new(void) char num[9] = "01234567"; QRRawCode *raw; - testStart("Test QRRaw_new()"); + testStart("Test QRraw_new()"); stream = QRinput_new(); QRinput_setVersion(stream, 10); QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_Q); @@ -66,13 +66,13 @@ void test_qrraw_new(void) assert_equal(raw->blocks, 8, "QRraw.blocks was not as expected.\n"); for(i=0; ib1; i++) { - assert_equal(raw->rsblock[i].dataLength, 19, "QRraw.rsblock[].dataLength was not as expected.\n"); + assert_equal(raw->rsblock[i].dataLength, 19, "QRraw.rsblock[%d].dataLength was not as expected. (%d)\n", i, raw->rsblock[i].dataLength); } for(i=raw->b1; iblocks; i++) { - assert_equal(raw->rsblock[i].dataLength, 20, "QRraw.rsblock[].dataLength was not as expected.\n"); + assert_equal(raw->rsblock[i].dataLength, 20, "QRraw.rsblock[%d].dataLength was not as expected. (%d)\n", i, raw->rsblock[i].dataLength); } for(i=0; iblocks; i++) { - assert_equal(raw->rsblock[i].eccLength, 24, "QRraw.rsblock[].eccLength was not as expected.\n"); + assert_equal(raw->rsblock[i].eccLength, 24, "QRraw.rsblock[%d].eccLength was not as expected. (%d)\n", i, raw->rsblock[i].eccLength); } QRinput_free(stream); -- cgit 0.0.5-2-1-g0f52 From 966232444eae587667c21edb4dc7592c0fb87f47 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 12:46:33 +0900 Subject: Reserved macro names are replaced. --- ChangeLog | 2 ++ tests/common.h | 6 +++--- tests/datachunk.h | 6 +++--- tests/decoder.h | 6 +++--- tests/rscode.h | 6 +++--- tests/rsecc_decoder.h | 6 +++--- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 341255bc31..6a788b50d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ - Memory alignment improved. * tests/test_qrencode.c: - Error messages improved. + * tests/{common.h datachunk.h, decoder.h, rscode.h, rsecc_decoder.h}: + - Reserved macro names are replaced. 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/tests/common.h b/tests/common.h index d68ef03f53..8a401e5898 100644 --- a/tests/common.h +++ b/tests/common.h @@ -2,8 +2,8 @@ * common part of test units. */ -#ifndef __COMMON_H__ -#define __COMMON_H__ +#ifndef COMMON_H__ +#define COMMON_H__ #include #if HAVE_CONFIG_H @@ -52,4 +52,4 @@ void printBstream(BitStream *bstream); void show_QRcode(QRcode *qrcode); -#endif /* __COMMON_H__ */ +#endif /* COMMON_H__ */ diff --git a/tests/datachunk.h b/tests/datachunk.h index fb2bf34d70..d4373636ee 100644 --- a/tests/datachunk.h +++ b/tests/datachunk.h @@ -1,5 +1,5 @@ -#ifndef __DATACHUNK_H__ -#define __DATACHUNK_H__ +#ifndef DATACHUNK_H +#define DATACHUNK_H #include "../qrencode.h" @@ -18,4 +18,4 @@ void DataChunk_dumpChunkList(DataChunk *list); int DataChunk_totalSize(DataChunk *list); unsigned char *DataChunk_concatChunkList(DataChunk *list, int *retsize); -#endif /* __DATACHUNK_H__ */ +#endif /* DATACHUNK_H */ diff --git a/tests/decoder.h b/tests/decoder.h index af1fe096ea..43b3e94245 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -1,5 +1,5 @@ -#ifndef __DECODER_H__ -#define __DECODER_H__ +#ifndef DECODER_H +#define DECODER_H #include "../qrencode.h" #include "datachunk.h" @@ -40,4 +40,4 @@ BitStream *QRcode_extractBitsMQR(QRcode *code, int *dataLength, int *eccLength, QRdata *QRcode_decodeBitsMQR(QRcode *code); QRdata *QRcode_decodeMQR(QRcode *code); -#endif /* __DECODER_H__ */ +#endif /* DECODER_H */ diff --git a/tests/rscode.h b/tests/rscode.h index ba2c3141c9..d4a07c9bae 100644 --- a/tests/rscode.h +++ b/tests/rscode.h @@ -24,8 +24,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __RSCODE_H__ -#define __RSCODE_H__ +#ifndef RSCODE_H +#define RSCODE_H /* * General purpose RS codec, 8-bit symbols. @@ -37,4 +37,4 @@ extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int p extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity); extern void free_rs_char(RS *rs); -#endif /* __RSCODE_H__ */ +#endif /* RSCODE_H */ diff --git a/tests/rsecc_decoder.h b/tests/rsecc_decoder.h index a65912be22..188cec88f0 100644 --- a/tests/rsecc_decoder.h +++ b/tests/rsecc_decoder.h @@ -1,7 +1,7 @@ -#ifndef __RSECC_DECODER_H__ -#define __RSECC_DECODER_H__ +#ifndef RSECC_DECODER_H +#define RSECC_DECODER_H void RSECC_decoder_init(); int RSECC_decoder_checkSyndrome(int dl, unsigned char *data, int el, unsigned char *ecc); -#endif /* __RSECC_DECODER_H__ */ +#endif /* RSECC_DECODER_H */ -- cgit 0.0.5-2-1-g0f52 From 63eca20544a2a724ab245eb0897fec13990cfc69 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 12:56:24 +0900 Subject: Some variables' type changed from int to size_t. (closing #89 and #102) --- ChangeLog | 3 +++ bitstream.c | 23 +++++++++++------------ bitstream.h | 10 +++++----- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a788b50d8..bef6adafbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ - Error messages improved. * tests/{common.h datachunk.h, decoder.h, rscode.h, rsecc_decoder.h}: - Reserved macro names are replaced. + * bitstream.[ch]: + - Some variables' type changed from int to size_t. (closing #89 and + #102) 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/bitstream.c b/bitstream.c index a2ec389926..f5e0b95f4c 100644 --- a/bitstream.c +++ b/bitstream.c @@ -49,11 +49,10 @@ BitStream *BitStream_new(void) } #ifdef WITH_TESTS -BitStream *BitStream_newWithBits(int size, unsigned char *bits) +BitStream *BitStream_newWithBits(size_t size, unsigned char *bits) { BitStream *bstream; - if(size < 0) return NULL; if(size == 0) return BitStream_new(); bstream = (BitStream *)malloc(sizeof(BitStream)); @@ -88,10 +87,10 @@ static int BitStream_expand(BitStream *bstream) return 0; } -static void BitStream_writeNum(unsigned char *dest, int bits, unsigned int num) +static void BitStream_writeNum(unsigned char *dest, size_t bits, unsigned int num) { unsigned int mask; - int i; + size_t i; unsigned char *p; p = dest; @@ -107,10 +106,10 @@ static void BitStream_writeNum(unsigned char *dest, int bits, unsigned int num) } } -static void BitStream_writeBytes(unsigned char *dest, int size, unsigned char *data) +static void BitStream_writeBytes(unsigned char *dest, size_t size, unsigned char *data) { unsigned char mask; - int i, j; + size_t i, j; unsigned char *p; p = dest; @@ -150,7 +149,7 @@ int BitStream_append(BitStream *bstream, BitStream *arg) return 0; } -int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num) +int BitStream_appendNum(BitStream *bstream, size_t bits, unsigned int num) { int ret; @@ -166,7 +165,7 @@ int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num) return 0; } -int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) +int BitStream_appendBytes(BitStream *bstream, size_t size, unsigned char *data) { int ret; @@ -184,7 +183,7 @@ int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) unsigned char *BitStream_toByte(BitStream *bstream) { - int i, j, size, bytes, oddbits; + size_t i, j, size, bytes, oddbits; unsigned char *data, v; unsigned char *p; @@ -203,7 +202,7 @@ unsigned char *BitStream_toByte(BitStream *bstream) for(i = 0; i < bytes; i++) { v = 0; for(j = 0; j < 8; j++) { - v = v << 1; + v = (unsigned char)(v << 1); v |= *p; p++; } @@ -213,11 +212,11 @@ unsigned char *BitStream_toByte(BitStream *bstream) if(oddbits > 0) { v = 0; for(j = 0; j < oddbits; j++) { - v = v << 1; + v = (unsigned char)(v << 1); v |= *p; p++; } - data[bytes] = v << (8 - oddbits); + data[bytes] = (unsigned char)(v << (8 - oddbits)); } return data; diff --git a/bitstream.h b/bitstream.h index 35fe4f8099..70f3e1dfc5 100644 --- a/bitstream.h +++ b/bitstream.h @@ -23,18 +23,18 @@ #define BITSTREAM_H typedef struct { - int length; - int datasize; + size_t length; + size_t datasize; unsigned char *data; } BitStream; extern BitStream *BitStream_new(void); #ifdef WITH_TESTS -extern BitStream *BitStream_newWithBits(int size, unsigned char *bits); +extern BitStream *BitStream_newWithBits(size_t size, unsigned char *bits); #endif extern int BitStream_append(BitStream *bstream, BitStream *arg); -extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num); -extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data); +extern int BitStream_appendNum(BitStream *bstream, size_t bits, unsigned int num); +extern int BitStream_appendBytes(BitStream *bstream, size_t size, unsigned char *data); #define BitStream_size(__bstream__) (__bstream__->length) #define BitStream_reset(__bstream__) (__bstream__->length = 0) extern unsigned char *BitStream_toByte(BitStream *bstream); -- cgit 0.0.5-2-1-g0f52 From 2e0c31d4dc782c8885bd735c3dbc26e3607f491b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 13:17:04 +0900 Subject: Fixed some warnings. --- ChangeLog | 2 ++ tests/common.c | 9 +++++---- tests/common.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index bef6adafbe..1900172aca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ * bitstream.[ch]: - Some variables' type changed from int to size_t. (closing #89 and #102) + * tests/common.[ch]: + - Fixed some warnings. 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/tests/common.c b/tests/common.c index 525dc3aa51..07c36399a8 100644 --- a/tests/common.c +++ b/tests/common.c @@ -12,13 +12,14 @@ static const char *testFunc = NULL; const char levelChar[4] = {'L', 'M', 'Q', 'H'}; const char *modeStr[5] = {"nm", "an", "8", "kj", "st"}; -int ncmpBin(char *correct, BitStream *bstream, int len) +int ncmpBin(char *correct, BitStream *bstream, size_t len) { - int i, bit; + int bit; + size_t i; char *p; if(len != BitStream_size(bstream)) { - printf("Length is not match: %d, %d expected.\n", BitStream_size(bstream), len); + printf("Length is not match: %zu, %zu expected.\n", BitStream_size(bstream), len); return -1; } @@ -138,7 +139,7 @@ void printQRinputInfo(QRinput *input) b = BitStream_new(); ret = QRinput_mergeBitStream(input, b); if(ret == 0) { - printf(" bitstream-size: %d\n", BitStream_size(b)); + printf(" bitstream-size: %zu\n", BitStream_size(b)); BitStream_free(b); } diff --git a/tests/common.h b/tests/common.h index 8a401e5898..3fa31758db 100644 --- a/tests/common.h +++ b/tests/common.h @@ -37,7 +37,7 @@ void report(); #define assert_notequal(__e1__, __e2__, ...) assert_exp((__e1__) != (__e2__), __VA_ARGS__) #define assert_nothing(__exp__, ...) {printf(__VA_ARGS__); __exp__;} -int ncmpBin(char *correct, BitStream *bstream, int len); +int ncmpBin(char *correct, BitStream *bstream, size_t len); int cmpBin(char *correct, BitStream *bstream); void printFrame(int width, unsigned char *frame); -- cgit 0.0.5-2-1-g0f52 From 0fcd787aa190a5fc527036d458e3a8a63ea77cd8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 13:34:01 +0900 Subject: Format fixes. --- ChangeLog | 2 ++ NEWS | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1900172aca..ecb96f9080 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,8 @@ #102) * tests/common.[ch]: - Fixed some warnings. + * NEWS: + - Format fixes. 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/NEWS b/NEWS index dbc99a8a5f..0d355a3391 100644 --- a/NEWS +++ b/NEWS @@ -222,6 +222,7 @@ Many thanks to Yusuke Mihara, who contributed a patch to add support of structured-append to version 1.0.2. API changes: + * Incompatible API changes: - QRencode_encodeInput * New types: @@ -248,7 +249,6 @@ API changes: Version 2.0.0 (2008.1.24) ------------------------- -Summary: * "-i" option to ignore case distinctions has been added to qrencode and view_qrcode. * "-c" option (case-sensitive mode) of qrencode is now enabled by default and -- cgit 0.0.5-2-1-g0f52 From f3d7e2fa45bb97e4966ae83fe3f175337ea0abe3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 21:53:21 +0900 Subject: Fixed some warnings. --- ChangeLog | 2 +- tests/test_split_urls.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecb96f9080..6325fb1f32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,7 +9,7 @@ * bitstream.[ch]: - Some variables' type changed from int to size_t. (closing #89 and #102) - * tests/common.[ch]: + * tests/common.[ch], tests/test_split_url.c: - Fixed some warnings. * NEWS: - Format fixes. diff --git a/tests/test_split_urls.c b/tests/test_split_urls.c index 3de2fc83d3..6b9dd29699 100644 --- a/tests/test_split_urls.c +++ b/tests/test_split_urls.c @@ -18,7 +18,7 @@ void encodeURLandPrint(char *url) { bstream = BitStream_new(); QRinput_mergeBitStream(input, bstream); - printf("{%d,\"%s\"},\n", BitStream_size(bstream), url); + printf("{%zu,\"%s\"},\n", BitStream_size(bstream), url); QRinput_free(input); BitStream_free(bstream); -- cgit 0.0.5-2-1-g0f52 From 44290eb817f6f5ccb1137372f115d4b7633f0cb3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 22:07:55 +0900 Subject: Some variables' type changed from int to unsigned int. (closing #89 and #102) --- ChangeLog | 3 +++ mask.c | 40 ++++++++++++++++++++-------------------- mask.h | 8 ++++---- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6325fb1f32..ac1714645f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,9 @@ - Fixed some warnings. * NEWS: - Format fixes. + * mask.[ch]: + - Some variables' type changed from int to unsigned int. (closing #89 and + #102) 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/mask.c b/mask.c index 3d7e15de33..127a56ebea 100644 --- a/mask.c +++ b/mask.c @@ -31,12 +31,12 @@ #include "qrspec.h" #include "mask.h" -STATIC_IN_RELEASE int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level) +STATIC_IN_RELEASE unsigned int Mask_writeFormatInformation(unsigned int width, unsigned char *frame, int mask, QRecLevel level) { unsigned int format; unsigned char v; - int i; - int blacks = 0; + unsigned int i; + unsigned int blacks = 0; format = QRspec_getFormatInfo(mask, level); @@ -84,8 +84,8 @@ STATIC_IN_RELEASE int Mask_writeFormatInformation(int width, unsigned char *fram #define N4 (10) #define MASKMAKER(__exp__) \ - int x, y;\ - int b = 0;\ + unsigned int x, y;\ + unsigned int b = 0;\ \ for(y = 0; y < width; y++) {\ for(x = 0; x < width; x++) {\ @@ -94,61 +94,61 @@ STATIC_IN_RELEASE int Mask_writeFormatInformation(int width, unsigned char *fram } else {\ *d = *s ^ ((__exp__) == 0);\ }\ - b += (int)(*d & 1);\ + b += (unsigned int)(*d & 1);\ s++; d++;\ }\ }\ return b; -static int Mask_mask0(int width, const unsigned char *s, unsigned char *d) +static unsigned int Mask_mask0(unsigned int width, const unsigned char *s, unsigned char *d) { MASKMAKER((x+y)&1) } -static int Mask_mask1(int width, const unsigned char *s, unsigned char *d) +static unsigned int Mask_mask1(unsigned int width, const unsigned char *s, unsigned char *d) { MASKMAKER(y&1) } -static int Mask_mask2(int width, const unsigned char *s, unsigned char *d) +static unsigned int Mask_mask2(unsigned int width, const unsigned char *s, unsigned char *d) { MASKMAKER(x%3) } -static int Mask_mask3(int width, const unsigned char *s, unsigned char *d) +static unsigned int Mask_mask3(unsigned int width, const unsigned char *s, unsigned char *d) { MASKMAKER((x+y)%3) } -static int Mask_mask4(int width, const unsigned char *s, unsigned char *d) +static unsigned int Mask_mask4(unsigned int width, const unsigned char *s, unsigned char *d) { MASKMAKER(((y/2)+(x/3))&1) } -static int Mask_mask5(int width, const unsigned char *s, unsigned char *d) +static unsigned int Mask_mask5(unsigned int width, const unsigned char *s, unsigned char *d) { MASKMAKER(((x*y)&1)+(x*y)%3) } -static int Mask_mask6(int width, const unsigned char *s, unsigned char *d) +static unsigned int Mask_mask6(unsigned int width, const unsigned char *s, unsigned char *d) { MASKMAKER((((x*y)&1)+(x*y)%3)&1) } -static int Mask_mask7(int width, const unsigned char *s, unsigned char *d) +static unsigned int Mask_mask7(unsigned int width, const unsigned char *s, unsigned char *d) { MASKMAKER((((x*y)%3)+((x+y)&1))&1) } #define maskNum (8) -typedef int MaskMaker(int, const unsigned char *, unsigned char *); +typedef unsigned int MaskMaker(unsigned int, const unsigned char *, unsigned char *); static MaskMaker *maskMakers[maskNum] = { Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3, Mask_mask4, Mask_mask5, Mask_mask6, Mask_mask7 }; #ifdef WITH_TESTS -unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask) +unsigned char *Mask_makeMaskedFrame(unsigned int width, unsigned char *frame, int mask) { unsigned char *masked; @@ -161,7 +161,7 @@ unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask) } #endif -unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level) +unsigned char *Mask_makeMask(unsigned int width, unsigned char *frame, int mask, QRecLevel level) { unsigned char *masked; @@ -319,15 +319,15 @@ STATIC_IN_RELEASE int Mask_evaluateSymbol(int width, unsigned char *frame) return demerit; } -unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) +unsigned char *Mask_mask(unsigned int width, unsigned char *frame, QRecLevel level) { int i; unsigned char *mask, *bestMask; int minDemerit = INT_MAX; - int blacks; + unsigned int blacks; int bratio; int demerit; - int w2 = width * width; + unsigned int w2 = width * width; mask = (unsigned char *)malloc(w2); if(mask == NULL) return NULL; diff --git a/mask.h b/mask.h index 169e64b2bb..b0b33c34d0 100644 --- a/mask.h +++ b/mask.h @@ -22,8 +22,8 @@ #ifndef MASK_H #define MASK_H -extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level); -extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); +extern unsigned char *Mask_makeMask(unsigned int width, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *Mask_mask(unsigned int width, unsigned char *frame, QRecLevel level); #ifdef WITH_TESTS extern int Mask_calcN2(int width, unsigned char *frame); @@ -31,8 +31,8 @@ extern int Mask_calcN1N3(int length, int *runLength); extern int Mask_calcRunLengthH(int width, unsigned char *frame, int *runLength); extern int Mask_calcRunLengthV(int width, unsigned char *frame, int *runLength); extern int Mask_evaluateSymbol(int width, unsigned char *frame); -extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); -extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); +extern unsigned int Mask_writeFormatInformation(unsigned int width, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *Mask_makeMaskedFrame(unsigned int width, unsigned char *frame, int mask); #endif #endif /* MASK_H */ -- cgit 0.0.5-2-1-g0f52 From a4ce9a97d7e76b16df03181cbc25984dc18e7c0e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 22:53:24 +0900 Subject: Fixed some warnings. --- ChangeLog | 2 ++ tests/test_mask.c | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac1714645f..1cb5909921 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,8 @@ * mask.[ch]: - Some variables' type changed from int to unsigned int. (closing #89 and #102) + * tests/test_mask.c: + - Fixed some warnings. 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/tests/test_mask.c b/tests/test_mask.c index 334548634a..69bdd8d3f8 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -5,7 +5,7 @@ #include "../qrspec.h" #include "decoder.h" -char dot[2] = {'_', '#'}; +static char dot[2] = {'_', '#'}; static char *maskPatterns[8] = { /* (i + j) mod 2 = 0 */ "#_#_#_" @@ -65,9 +65,9 @@ static char *maskPatterns[8] = { "_###__" }; -void print_mask(int mask) +static void print_mask(int mask) { - const int w = 6; + const unsigned int w = 6; unsigned char frame[w * w], *masked, *p; int x, y; @@ -86,7 +86,7 @@ void print_mask(int mask) free(masked); } -void print_masks(void) +static void print_masks(void) { int i; @@ -95,7 +95,7 @@ void print_masks(void) } } -int test_mask(int mask) +static int test_mask(int mask) { const int w = 6; unsigned char frame[w * w], *masked, *p; @@ -121,7 +121,7 @@ int test_mask(int mask) return err; } -void test_masks(void) +static void test_masks(void) { int i; @@ -137,10 +137,10 @@ void test_masks(void) #define N3 (40) #define N4 (10) -void test_eval(void) +static void test_eval(void) { unsigned char *frame; - int w = 6; + unsigned int w = 6; int demerit; frame = (unsigned char *)malloc(w * w); @@ -169,12 +169,12 @@ void test_eval(void) * .....##### * #####..... */ -void test_eval2(void) +static void test_eval2(void) { unsigned char *frame; - int w = 10; + unsigned int w = 10; int demerit; - int x; + unsigned int x; frame = (unsigned char *)malloc(w * w); @@ -197,7 +197,7 @@ void test_eval2(void) free(frame); } -void test_calcN2(void) +static void test_calcN2(void) { unsigned char frame[64]; int width; @@ -235,7 +235,7 @@ void test_calcN2(void) testFinish(); } -void test_eval3(void) +static void test_eval3(void) { unsigned char *frame; int w = 15; @@ -284,7 +284,7 @@ void test_eval3(void) free(frame); } -void test_format(void) +static void test_format(void) { unsigned char *frame, *masked; int version, mask, width, dmask; @@ -312,7 +312,7 @@ void test_format(void) testFinish(); } -void test_calcRunLength(void) +static void test_calcRunLength(void) { int width = 5; unsigned char frame[width * width]; @@ -351,7 +351,7 @@ void test_calcRunLength(void) testFinish(); } -void test_calcN1N3(void) +static void test_calcN1N3(void) { int runLength[26]; int length; -- cgit 0.0.5-2-1-g0f52 From 30a987bc3e0814f12582e8a162cec3c46c76384c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 2 Oct 2017 23:12:23 +0900 Subject: Comment format fixes. --- ChangeLog | 2 ++ mqrspec.c | 4 ++-- qrencode.h | 14 +++++++------- qrinput.h | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1cb5909921..9387082954 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,8 @@ #102) * tests/test_mask.c: - Fixed some warnings. + * qrencode.h, qrinput.h, mqrspec.c: + - Comment format fixes. 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/mqrspec.c b/mqrspec.c index 6513a3314d..86e81f1f0a 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -40,8 +40,8 @@ *****************************************************************************/ typedef struct { - int width; //< Edge length of the symbol - int ec[4]; //< Number of ECC code (bytes) + int width; ///< Edge length of the symbol + int ec[4]; ///< Number of ECC code (bytes) } MQRspec_Capacity; /** diff --git a/qrencode.h b/qrencode.h index b855f0a40a..53f633bd16 100644 --- a/qrencode.h +++ b/qrencode.h @@ -107,13 +107,13 @@ extern "C" { * Encoding mode. */ typedef enum { - QR_MODE_NUL = -1, ///< Terminator (NUL character). Internal use only - QR_MODE_NUM = 0, ///< Numeric mode - QR_MODE_AN, ///< Alphabet-numeric mode - QR_MODE_8, ///< 8-bit data mode - QR_MODE_KANJI, ///< Kanji (shift-jis) mode - QR_MODE_STRUCTURE, ///< Internal use only - QR_MODE_ECI, ///< ECI mode + QR_MODE_NUL = -1, ///< Terminator (NUL character). Internal use only + QR_MODE_NUM = 0, ///< Numeric mode + QR_MODE_AN, ///< Alphabet-numeric mode + QR_MODE_8, ///< 8-bit data mode + QR_MODE_KANJI, ///< Kanji (shift-jis) mode + QR_MODE_STRUCTURE, ///< Internal use only + QR_MODE_ECI, ///< ECI mode QR_MODE_FNC1FIRST, ///< FNC1, first position QR_MODE_FNC1SECOND, ///< FNC1, second position } QRencodeMode; diff --git a/qrinput.h b/qrinput.h index 080e1840af..b504d0d910 100644 --- a/qrinput.h +++ b/qrinput.h @@ -34,8 +34,8 @@ typedef struct _QRinput_List QRinput_List; struct _QRinput_List { QRencodeMode mode; - int size; ///< Size of data chunk (byte). - unsigned char *data; ///< Data chunk. + int size; ///< Size of data chunk (byte). + unsigned char *data; ///< Data chunk. BitStream *bstream; QRinput_List *next; }; @@ -64,7 +64,7 @@ struct _QRinput_InputList { }; struct _QRinput_Struct { - int size; ///< number of structured symbols + int size; ///< number of structured symbols int parity; QRinput_InputList *head; QRinput_InputList *tail; -- cgit 0.0.5-2-1-g0f52 From a350b010bb21fcb9035b2bda75c544239424bc64 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 3 Oct 2017 00:11:30 +0900 Subject: Fixed some warnings. --- ChangeLog | 2 ++ tests/URI_testset.inc | 4 +-- tests/decoder.h | 2 +- tests/prof_qrencode.c | 12 +++---- tests/pthread_qrencode.c | 16 ++++----- tests/test_bitstream.c | 24 +++++++------- tests/test_estimatebit.c | 20 ++++++------ tests/test_mask.c | 2 +- tests/test_mmask.c | 18 +++++------ tests/test_monkey.c | 37 ++++++++++----------- tests/test_mqrspec.c | 16 ++++----- tests/test_qrencode.c | 72 ++++++++++++++++++++--------------------- tests/test_qrinput.c | 84 ++++++++++++++++++++++++------------------------ tests/test_qrspec.c | 24 +++++++------- tests/test_rs.c | 2 +- tests/test_split.c | 34 ++++++++++---------- tests/test_split_urls.c | 16 ++++----- tests/view_qrcode.c | 14 ++++---- 18 files changed, 201 insertions(+), 198 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9387082954..ad8431b2f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,8 @@ - Fixed some warnings. * qrencode.h, qrinput.h, mqrspec.c: - Comment format fixes. + * various files in tests: + - Fixed some warnings. 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/tests/URI_testset.inc b/tests/URI_testset.inc index 3aaaff0234..9d0fa35ea0 100644 --- a/tests/URI_testset.inc +++ b/tests/URI_testset.inc @@ -1,9 +1,9 @@ struct TestSet { - int expected_length; + size_t expected_length; char *url; }; -struct TestSet testset[] = { +static struct TestSet testset[] = { {3132,"http://ads.bluelithium.com/clk?3,eJytjcFqwzAQRL8mNyO0luUoiB7WcQUGS8RFbXBuqVEcxxbKwSDy93HS0P5AH3uYYXd2AKT4hpOjJ-d4njGWdxIySB2nnB0hoVJKRvkmhTXb8GRyIWBVdw0W01bRAh-Y3Vfb4ItS4Ee.fcqdQBJLQsTg2.5nmzOT479QirH4fOkKcfnfL9WDMk09vhd.ZxpM2cSD17G2yh8uetZWTfoGQ7tXY22N1xa53lfc2DYz.W.yLUnO83xdMVylapkYI7kdzyGQLvjF3wHZQ1eK,http%3A%2F%2Fomicronpath.com%2F%3Fa%3D448%26c%3D3201%26s1%3DYahooStream_917_Nevada4"}, {3745,"http://ads.bluelithium.com/clk?3,eJytjd2OgjAQhZ.GO9K0lEpJ48WwUNekdIWoBO8UCfKX7gUJ4tNv3bj6AvtlLs7knDlDiDgzSi8sqDzOAtfnviAecSuGGT25DhZCUGwN4tOAOX1lDGxUmULYZT0O4cGnyYoankQcsvrjV245oClCiDfDn8.UYQn.QsS7cP.UGwDbX9vXjdSp6uLwHUuIjtL5ay1btZPDsU3GZCf7ZCZNkcte5YdG3.c33cZY5wU7pq.LleNcx.F7QWHhSjvTNKH5dDUGlWaw-w-Jy1ek,http%3A%2F%2Ftanphysics.com%2Farticles%2Freview1.php%3Futm_source%3DUSA%26utm_medium%3DYHO%26utm_content%3D917-STRM4%26utm_campaign%3DYHO%26keyword%3DYHO-917-STRM4"}, {896,"http://amigo.geneontology.org/cgi-bin/amigo/go.cgi?view=details&search_constraint=terms&depth=0&query=GO:0042438"}, diff --git a/tests/decoder.h b/tests/decoder.h index 43b3e94245..087ec6f108 100644 --- a/tests/decoder.h +++ b/tests/decoder.h @@ -5,8 +5,8 @@ #include "datachunk.h" typedef struct { - int size; unsigned char *data; + int size; int mqr; int version; QRecLevel level; diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index 5bf3f40e28..a98b5d672f 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -5,14 +5,14 @@ #include #include "../qrencode.h" -struct timeval tv; -void timerStart(const char *str) +static struct timeval tv; +static void timerStart(const char *str) { printf("%s: START\n", str); gettimeofday(&tv, NULL); } -void timerStop(void) +static void timerStop(void) { struct timeval tc; @@ -21,7 +21,7 @@ void timerStop(void) + (tc.tv_usec - tv.tv_usec) / 1000); } -void prof_ver1to10(void) +static void prof_ver1to10(void) { QRcode *code; int i; @@ -42,7 +42,7 @@ void prof_ver1to10(void) timerStop(); } -void prof_ver31to40(void) +static void prof_ver31to40(void) { QRcode *code; int i; @@ -63,7 +63,7 @@ void prof_ver31to40(void) timerStop(); } -int main(int argc, char **argv) +int main() { prof_ver1to10(); prof_ver31to40(); diff --git a/tests/pthread_qrencode.c b/tests/pthread_qrencode.c index eefde37e02..917b0a0dec 100644 --- a/tests/pthread_qrencode.c +++ b/tests/pthread_qrencode.c @@ -10,14 +10,14 @@ static pthread_t threads[THREADS]; -struct timeval tv; -void timerStart(const char *str) +static struct timeval tv; +static void timerStart(const char *str) { printf("%s: START\n", str); gettimeofday(&tv, NULL); } -void timerStop(void) +static void timerStop(void) { struct timeval tc; @@ -26,7 +26,7 @@ void timerStop(void) + (tc.tv_usec - tv.tv_usec) / 1000); } -void *encode_ver1to10(void *arg) +static void *encode_ver1to10(void *arg) { QRcode *code; int i; @@ -47,7 +47,7 @@ void *encode_ver1to10(void *arg) return NULL; } -void prof_ver1to10(void) +static void prof_ver1to10(void) { int i; @@ -61,7 +61,7 @@ void prof_ver1to10(void) timerStop(); } -void *encode_ver31to40(void *arg) +static void *encode_ver31to40(void *arg) { QRcode *code; int i; @@ -82,7 +82,7 @@ void *encode_ver31to40(void *arg) return NULL; } -void prof_ver31to40(void) +static void prof_ver31to40(void) { int i; @@ -96,7 +96,7 @@ void prof_ver31to40(void) timerStop(); } -int main(int argc, char **argv) +int main() { prof_ver1to10(); prof_ver31to40(); diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 8f0d242ce1..3fb223520c 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -3,7 +3,7 @@ #include "common.h" #include "../bitstream.h" -void test_null(void) +static void test_null(void) { BitStream *bstream; @@ -17,7 +17,7 @@ void test_null(void) BitStream_free(bstream); } -void test_num(void) +static void test_num(void) { BitStream *bstream; unsigned int data = 0x13579bdf; @@ -31,7 +31,7 @@ void test_num(void) BitStream_free(bstream); } -void test_bytes(void) +static void test_bytes(void) { BitStream *bstream; unsigned char data[1] = {0x3a}; @@ -44,7 +44,7 @@ void test_bytes(void) BitStream_free(bstream); } -void test_appendNum(void) +static void test_appendNum(void) { BitStream *bstream; char correct[] = "10001010 11111111 11111111 00010010001101000101011001111000"; @@ -66,7 +66,7 @@ void test_appendNum(void) BitStream_free(bstream); } -void test_appendBytes(void) +static void test_appendBytes(void) { BitStream *bstream; unsigned char data[8]; @@ -96,7 +96,7 @@ void test_appendBytes(void) BitStream_free(bstream); } -void test_toByte(void) +static void test_toByte(void) { BitStream *bstream; unsigned char correct[] = { @@ -118,7 +118,7 @@ void test_toByte(void) free(result); } -void test_toByte_4bitpadding(void) +static void test_toByte_4bitpadding(void) { BitStream *bstream; unsigned char *result; @@ -144,7 +144,7 @@ void test_toByte_4bitpadding(void) } -void test_size(void) +static void test_size(void) { BitStream *bstream; @@ -160,7 +160,7 @@ void test_size(void) BitStream_free(bstream); } -void test_append(void) +static void test_append(void) { BitStream *bs1, *bs2; char c1[] = "00"; @@ -203,7 +203,7 @@ void test_append(void) BitStream_free(bs2); } -void test_newWithBits(void) +static void test_newWithBits(void) { BitStream *bstream; unsigned char data[4] = {0, 1, 0, 1}; @@ -218,7 +218,7 @@ void test_newWithBits(void) testFinish(); } -void test_newWithBits_size0(void) +static void test_newWithBits_size0(void) { BitStream *bstream; @@ -232,7 +232,7 @@ void test_newWithBits_size0(void) testFinish(); } -int main(int argc, char **argv) +int main() { test_null(); test_num(); diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index 4e65eb630c..252d151650 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -4,9 +4,9 @@ #include "common.h" #include "../qrinput.h" -QRinput *gstream; +static QRinput *gstream; -void test_numbit(void) +static void test_numbit(void) { QRinput *stream; char num[9]="01234567"; @@ -22,7 +22,7 @@ void test_numbit(void) QRinput_free(stream); } -void test_numbit2(void) +static void test_numbit2(void) { QRinput *stream; char num[17]="0123456789012345"; @@ -38,7 +38,7 @@ void test_numbit2(void) QRinput_free(stream); } -void test_numbit3(void) +static void test_numbit3(void) { QRinput *stream; char *num; @@ -59,7 +59,7 @@ void test_numbit3(void) free(num); } -void test_an(void) +static void test_an(void) { QRinput *stream; char str[6]="AC-42"; @@ -75,7 +75,7 @@ void test_an(void) QRinput_free(stream); } -void test_8(void) +static void test_8(void) { QRinput *stream; char str[9]="12345678"; @@ -91,7 +91,7 @@ void test_8(void) QRinput_free(stream); } -void test_structure(void) +static void test_structure(void) { QRinput *stream; int bits; @@ -106,7 +106,7 @@ void test_structure(void) QRinput_free(stream); } -void test_kanji(void) +static void test_kanji(void) { int res; @@ -129,7 +129,7 @@ void test_kanji(void) QRinput_free(stream); } -void test_mix(void) +static void test_mix(void) { int bits; @@ -139,7 +139,7 @@ void test_mix(void) QRinput_free(gstream); } -int main(int argc, char **argv) +int main() { gstream = QRinput_new(); diff --git a/tests/test_mask.c b/tests/test_mask.c index 69bdd8d3f8..4bf368be96 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -388,7 +388,7 @@ static void test_calcN1N3(void) testFinish(); } -int main(int argc, char **argv) +int main() { //print_masks(); test_masks(); diff --git a/tests/test_mmask.c b/tests/test_mmask.c index e8b6d88b47..2b0cfa2f0c 100644 --- a/tests/test_mmask.c +++ b/tests/test_mmask.c @@ -4,7 +4,7 @@ #include "../mmask.h" #include "../mqrspec.h" -char dot[2] = {'_', '#'}; +static char dot[2] = {'_', '#'}; static char *maskPatterns[4] = { /* i mod 2 = 0 */ "######" @@ -36,7 +36,7 @@ static char *maskPatterns[4] = { "_###__" }; -void print_mask(int mask) +static void print_mask(int mask) { const int w = 6; unsigned char frame[w * w], *masked, *p; @@ -57,7 +57,7 @@ void print_mask(int mask) free(masked); } -void print_masks(void) +static void print_masks(void) { int i; @@ -66,7 +66,7 @@ void print_masks(void) } } -int test_mask(int mask) +static int test_mask(int mask) { const int w = 6; unsigned char frame[w * w], *masked, *p; @@ -92,7 +92,7 @@ int test_mask(int mask) return err; } -void test_masks(void) +static void test_masks(void) { int i; @@ -103,13 +103,13 @@ void test_masks(void) testFinish(); } -void test_maskEvaluation(void) +static void test_maskEvaluation(void) { static const int w = 11; - unsigned char pattern[w*w]; + unsigned char pattern[w * w]; int i, score; - memset(pattern, 0, w*w); + memset(pattern, 0, w * w); testStart("Test mask evaluation"); score = MMask_evaluateSymbol(w, pattern); @@ -138,7 +138,7 @@ void test_maskEvaluation(void) testFinish(); } -int main(int argc, char **argv) +int main() { //print_masks(); test_masks(); diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 2ab0546482..488fa8ec4c 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -15,7 +15,7 @@ static const char *AN = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; #define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0)) -int fill8bitString(void) +static int fill8bitString(void) { int len, i; @@ -28,7 +28,7 @@ int fill8bitString(void) return len; } -int fill8bitData(void) +static int fill8bitData(void) { int len, i; @@ -41,7 +41,7 @@ int fill8bitData(void) return len; } -int fillANData(void) +static int fillANData(void) { int len, i; @@ -54,7 +54,7 @@ int fillANData(void) return len; } -void test_encode_an(int num) +static void test_encode_an(int num) { int ret; int len; @@ -84,7 +84,8 @@ void test_encode_an(int num) ret = memcmp(qrdata->data, data, len); if(ret != 0) { unsigned char *frame, *p; - int x,y,c; + unsigned int x; + int y,c; int dataLength, eccLength; QRinput *input; QRcode *origcode; @@ -181,7 +182,7 @@ void test_encode_an(int num) QRcode_free(qrcode); } -void monkey_encode_an(int loop) +static void monkey_encode_an(int loop) { int i; @@ -193,7 +194,7 @@ void monkey_encode_an(int loop) } -void test_split_an(int num) +static void test_split_an(int num) { QRinput *input; QRinput_List *list; @@ -244,7 +245,7 @@ void test_split_an(int num) QRinput_free(input); } -void monkey_split_an(int loop) +static void monkey_split_an(int loop) { int i; @@ -255,7 +256,7 @@ void monkey_split_an(int loop) } } -void test_encode_8(int num) +static void test_encode_8(int num) { QRcode *qrcode; QRdata *qrdata; @@ -286,7 +287,7 @@ void test_encode_8(int num) QRcode_free(qrcode); } -void monkey_encode_8(int loop) +static void monkey_encode_8(int loop) { int i; @@ -297,7 +298,7 @@ void monkey_encode_8(int loop) } } -void test_split_8(int num) +static void test_split_8(int num) { QRinput *input; QRinput_List *list; @@ -348,7 +349,7 @@ void test_split_8(int num) QRinput_free(input); } -void monkey_split_8(int loop) +static void monkey_split_8(int loop) { int i; @@ -359,7 +360,7 @@ void monkey_split_8(int loop) } } -void test_encode_kanji(int num) +static void test_encode_kanji(int num) { QRcode *qrcode; QRdata *qrdata; @@ -390,7 +391,7 @@ void test_encode_kanji(int num) QRcode_free(qrcode); } -void monkey_encode_kanji(int loop) +static void monkey_encode_kanji(int loop) { int i; @@ -401,7 +402,7 @@ void monkey_encode_kanji(int loop) } } -void test_split_kanji(int num) +static void test_split_kanji(int num) { QRinput *input; QRinput_List *list; @@ -452,7 +453,7 @@ void test_split_kanji(int num) QRinput_free(input); } -void monkey_split_kanji(int loop) +static void monkey_split_kanji(int loop) { int i; @@ -463,7 +464,7 @@ void monkey_split_kanji(int loop) } } -void test_split_structure(int num) +static void test_split_structure(int num) { QRinput *input; QRinput_Struct *s; @@ -540,7 +541,7 @@ void test_split_structure(int num) QRcode_List_free(codes); } -void monkey_split_structure(int loop) +static void monkey_split_structure(int loop) { int i; diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index e5d14a51eb..3673de0215 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -3,7 +3,7 @@ #include "common.h" #include "../mqrspec.h" -unsigned char v4frame[] = { +static unsigned char v4frame[] = { 0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc0,0x91,0x90,0x91,0x90,0x91,0x90,0x91,0x90,0x91, 0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xc1,0xc0,0xc1,0xc1,0xc1,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -23,7 +23,7 @@ unsigned char v4frame[] = { 0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -void test_newFrame(void) +static void test_newFrame(void) { int width, i, y; unsigned char *frame; @@ -40,7 +40,7 @@ void test_newFrame(void) testFinish(); } -void test_newframe_invalid(void) +static void test_newframe_invalid(void) { unsigned char *frame; @@ -87,7 +87,7 @@ static const int typeTable[4][3] = { { 5, 6, 7} }; -void test_format(void) +static void test_format(void) { unsigned int format; int version, l, mask; @@ -119,7 +119,7 @@ void test_format(void) testEnd(err); } -void print_format(void) +static void print_format(void) { unsigned int format; int i, j; @@ -136,14 +136,14 @@ void print_format(void) /** * See Table 7 of Appendix 1. */ -int datalen[4][3] = { +static int datalen[4][3] = { { 20, 0, 0}, { 40, 32, 0}, { 84, 68, 0}, {128, 112, 80}, }; -void test_dataLength(void) +static void test_dataLength(void) { int v, l; int bits; @@ -162,7 +162,7 @@ void test_dataLength(void) testEnd(err); } -int main(int argc, char **argv) +int main() { test_newFrame(); test_newframe_invalid(); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 63eb0a9bcf..15e6e733f4 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -30,7 +30,7 @@ typedef struct { #define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0)) -int inputSize(QRinput *input) +static int inputSize(QRinput *input) { BitStream *bstream; int size; @@ -43,7 +43,7 @@ int inputSize(QRinput *input) return size; } -void test_qrraw_new(void) +static void test_qrraw_new(void) { int i; QRinput *stream; @@ -80,7 +80,7 @@ void test_qrraw_new(void) testFinish(); } -void test_iterate() +static void test_iterate() { int i; QRinput *stream; @@ -108,7 +108,7 @@ void test_iterate() testEnd(err); } -void test_iterate2() +static void test_iterate2() { int i; QRinput *stream; @@ -153,7 +153,7 @@ void test_iterate2() testEnd(err); } -void print_filler(void) +static void print_filler(void) { int width; int version = 7; @@ -167,7 +167,7 @@ void print_filler(void) free(frame); } -void test_filler(void) +static void test_filler(void) { unsigned char *frame; int i, j, w, e, length; @@ -196,7 +196,7 @@ void test_filler(void) testFinish(); } -void print_fillerMQR(void) +static void print_fillerMQR(void) { int width; int version = 3; @@ -211,7 +211,7 @@ void print_fillerMQR(void) } } -void test_fillerMQR(void) +static void test_fillerMQR(void) { unsigned char *frame; int i, j, w, e, length; @@ -243,7 +243,7 @@ void test_fillerMQR(void) testFinish(); } -void test_format(void) +static void test_format(void) { unsigned char *frame; unsigned int format; @@ -336,7 +336,7 @@ unsigned int m1pat[8][21] = { 0x1fc358, 0x10544b, 0x1749cf, 0x1758e7, 0x174ae5, 0x10472a, 0x1fd0ac} }; -void test_encode(void) +static void test_encode(void) { QRinput *stream; char num[9] = "01234567"; @@ -372,7 +372,7 @@ ABORT: testEnd(err); } -void test_encode2(void) +static void test_encode2(void) { QRcode *qrcode; @@ -382,7 +382,7 @@ void test_encode2(void) QRcode_free(qrcode); } -void test_encode3(void) +static void test_encode3(void) { QRcode *code1, *code2; QRinput *input; @@ -399,7 +399,7 @@ void test_encode3(void) QRinput_free(input); } -void test_encodeNull(void) +static void test_encodeNull(void) { QRcode *qrcode; @@ -411,7 +411,7 @@ void test_encodeNull(void) } -void test_encodeEmpty(void) +static void test_encodeEmpty(void) { QRcode *qrcode; @@ -422,7 +422,7 @@ void test_encodeEmpty(void) if(qrcode != NULL) QRcode_free(qrcode); } -void test_encodeNull8(void) +static void test_encodeNull8(void) { QRcode *qrcode; @@ -434,7 +434,7 @@ void test_encodeNull8(void) } -void test_encodeEmpty8(void) +static void test_encodeEmpty8(void) { QRcode *qrcode; @@ -445,7 +445,7 @@ void test_encodeEmpty8(void) if(qrcode != NULL) QRcode_free(qrcode); } -void test_encodeLongData(void) +static void test_encodeLongData(void) { QRinput *stream; unsigned char data[7090]; @@ -500,7 +500,7 @@ void test_encodeLongData(void) testFinish(); } -void test_01234567(void) +static void test_01234567(void) { QRinput *stream; char num[9] = "01234567"; @@ -543,7 +543,7 @@ void test_01234567(void) QRcode_free(qrcode); } -void print_01234567(void) +static void print_01234567(void) { QRinput *stream; char num[9] = "01234567"; @@ -557,7 +557,7 @@ void print_01234567(void) QRcode_free(qrcode); } -void test_invalid_input(void) +static void test_invalid_input(void) { QRinput *input; QRcode *code; @@ -594,7 +594,7 @@ void test_invalid_input(void) testFinish(); } -void test_struct_semilong(void) +static void test_struct_semilong(void) { QRcode_List *codes, *list; const char *str = "asdfasdfasdfasdfasdfASDFASDASDFASDFAsdfasdfasdfasdASDFASDFADSADadsfasdf"; @@ -628,7 +628,7 @@ void test_struct_semilong(void) testFinish(); } -void test_struct_example(void) +static void test_struct_example(void) { QRcode_List *codes, *list; const char *str = "an example of four Structured Append symbols,"; @@ -648,7 +648,7 @@ void test_struct_example(void) QRcode_List_free(codes); } -void test_null_free(void) +static void test_null_free(void) { testStart("Testing free NULL pointers"); assert_nothing(QRcode_free(NULL), "Check QRcode_free(NULL).\n"); @@ -657,7 +657,7 @@ void test_null_free(void) testFinish(); } -void test_encodeTooLongMQR(void) +static void test_encodeTooLongMQR(void) { QRcode *code; char *data[] = {"012345", "ABC0EFG", "0123456789", "0123456789ABCDEFG"}; @@ -684,7 +684,7 @@ void test_encodeTooLongMQR(void) } } -void test_mqrraw_new(void) +static void test_mqrraw_new(void) { QRinput *stream; char *num = "01234"; @@ -709,7 +709,7 @@ void test_mqrraw_new(void) testFinish(); } -void test_encodeData(void) +static void test_encodeData(void) { QRcode *qrcode; @@ -725,7 +725,7 @@ void test_encodeData(void) testFinish(); } -void test_formatInfo(void) +static void test_formatInfo(void) { QRcode *qrcode; QRecLevel level; @@ -743,7 +743,7 @@ void test_formatInfo(void) testFinish(); } -void test_formatInfoMQR(void) +static void test_formatInfoMQR(void) { QRcode *qrcode; QRecLevel level; @@ -766,7 +766,7 @@ void test_formatInfoMQR(void) testFinish(); } -void test_decodeSimple(void) +static void test_decodeSimple(void) { char *str = "AC-42"; QRcode *qrcode; @@ -788,7 +788,7 @@ void test_decodeSimple(void) } -void test_decodeLong(void) +static void test_decodeLong(void) { char *str = "12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ?????????????"; QRcode *qrcode; @@ -809,7 +809,7 @@ void test_decodeLong(void) testFinish(); } -void test_decodeVeryLong(void) +static void test_decodeVeryLong(void) { char str[4000]; int i; @@ -837,7 +837,7 @@ void test_decodeVeryLong(void) testFinish(); } -void test_decodeShortMQR(void) +static void test_decodeShortMQR(void) { char str[]="55"; QRcode *qrcode; @@ -861,7 +861,7 @@ void test_decodeShortMQR(void) testFinish(); } -void test_oddBitCalcMQR(void) +static void test_oddBitCalcMQR(void) { /* test issue #25 (odd bits calculation bug) */ /* test pattern contributed by vlad417 */ @@ -893,7 +893,7 @@ void test_oddBitCalcMQR(void) testFinish(); } -void test_mqrencode(void) +static void test_mqrencode(void) { char *str = "MICROQR"; char pattern[] = { @@ -940,7 +940,7 @@ void test_mqrencode(void) testFinish(); } -void test_apiversion(void) +static void test_apiversion(void) { int major_version, minor_version, micro_version; char *str, *str2; @@ -957,7 +957,7 @@ void test_apiversion(void) testFinish(); } -int main(int argc, char **argv) +int main() { test_iterate(); test_iterate2(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index cf510c19c0..587ca64b1e 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -7,7 +7,7 @@ #include "../split.h" #include "decoder.h" -int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mode, char *data, char *correct) +static int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mode, char *data, char *correct) { QRinput *input; BitStream *bstream; @@ -33,7 +33,7 @@ int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mo return ret; } -int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct) +static int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct) { QRinput *input; BitStream *bstream; @@ -55,7 +55,7 @@ int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct) return ret; } -void test_encodeKanji(void) +static void test_encodeKanji(void) { char str[5]= {0x93, 0x5f, 0xe4, 0xaa, 0x00}; char *correct = "10000000001001101100111111101010101010"; @@ -64,7 +64,7 @@ void test_encodeKanji(void) testEnd(mergeAndCheckBStream(0, QR_MODE_KANJI, str, correct)); } -void test_encode8(void) +static void test_encode8(void) { char str[] = "AC-42"; char correct[] = "0100000001010100000101000011001011010011010000110010"; @@ -73,7 +73,7 @@ void test_encode8(void) testEnd(mergeAndCheckBStream(0, QR_MODE_8, str, correct)); } -void test_encode8_versionup(void) +static void test_encode8_versionup(void) { QRinput *stream; BitStream *bstream; @@ -95,7 +95,7 @@ void test_encode8_versionup(void) free(str); } -void test_encodeAn(void) +static void test_encodeAn(void) { char *str = "AC-42"; char correct[] = "00100000001010011100111011100111001000010"; @@ -104,7 +104,7 @@ void test_encodeAn(void) testEnd(mergeAndCheckBStream(0, QR_MODE_AN, str, correct)); } -void test_encodeAn2(void) +static void test_encodeAn2(void) { QRinput *stream; char str[] = "!,;$%"; @@ -117,7 +117,7 @@ void test_encodeAn2(void) QRinput_free(stream); } -void test_encodeNumeric(void) +static void test_encodeNumeric(void) { char *str = "01234567"; char correct[] = "00010000001000000000110001010110011000011"; @@ -126,7 +126,7 @@ void test_encodeNumeric(void) testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct)); } -void test_encodeNumeric_versionup(void) +static void test_encodeNumeric_versionup(void) { QRinput *stream; BitStream *bstream; @@ -148,7 +148,7 @@ void test_encodeNumeric_versionup(void) free(str); } -void test_encodeNumericPadded(void) +static void test_encodeNumericPadded(void) { char *str = "01234567"; char *correct; @@ -168,7 +168,7 @@ void test_encodeNumericPadded(void) free(correct); } -void test_encodeNumericPadded2(void) +static void test_encodeNumericPadded2(void) { char *str = "0123456"; char *correct; @@ -188,7 +188,7 @@ void test_encodeNumericPadded2(void) free(correct); } -void test_padding(void) +static void test_padding(void) { QRinput *input; BitStream *bstream; @@ -214,7 +214,7 @@ void test_padding(void) BitStream_free(bstream); } -void test_padding2(void) +static void test_padding2(void) { QRinput *input; BitStream *bstream; @@ -269,7 +269,7 @@ void test_padding2(void) BitStream_free(bstream); } -void test_encodeNumeric2(void) +static void test_encodeNumeric2(void) { char *str = "0123456789012345"; char *correct = "00010000010000000000110001010110011010100110111000010100111010100101"; @@ -278,7 +278,7 @@ void test_encodeNumeric2(void) testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct)); } -void test_encodeNumeric3(void) +static void test_encodeNumeric3(void) { char *str = "0123456"; char *correct = "0001 0000000111 0000001100 0101011001 0110"; @@ -287,7 +287,7 @@ void test_encodeNumeric3(void) testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct)); } -void test_encodeAnNum(void) +static void test_encodeAnNum(void) { QRinput *input; BitStream *bstream; @@ -312,7 +312,7 @@ void test_encodeAnNum(void) BitStream_free(bstream); } -void test_struct_listop(void) +static void test_struct_listop(void) { QRinput_Struct *s; QRinput *inputs[5]; @@ -345,7 +345,7 @@ void test_struct_listop(void) testFinish(); } -void test_insertStructuredAppendHeader(void) +static void test_insertStructuredAppendHeader(void) { QRinput *stream; char correct[] = "0011000011111010010101000000000101000001"; @@ -367,7 +367,7 @@ void test_insertStructuredAppendHeader(void) BitStream_free(bstream); } -void test_insertStructuredAppendHeader_error(void) +static void test_insertStructuredAppendHeader_error(void) { QRinput *stream; int ret; @@ -389,7 +389,7 @@ void test_insertStructuredAppendHeader_error(void) QRinput_free(stream); } -void test_struct_insertStructuredAppendHeaders(void) +static void test_struct_insertStructuredAppendHeaders(void) { QRinput *input; QRinput_Struct *s; @@ -422,7 +422,7 @@ static int check_lengthOfCode(QRencodeMode mode, char *data, int size, int versi { QRinput *input; BitStream *b; - int bits; + size_t bits; int bytes; input = QRinput_new(); @@ -438,7 +438,7 @@ static int check_lengthOfCode(QRencodeMode mode, char *data, int size, int versi return bytes; } -void test_lengthOfCode_num(void) +static void test_lengthOfCode_num(void) { int i, bytes; char *data; @@ -461,7 +461,7 @@ void test_lengthOfCode_num(void) free(data); } -void test_lengthOfCode_kanji(void) +static void test_lengthOfCode_kanji(void) { int i, bytes; unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; @@ -474,7 +474,7 @@ void test_lengthOfCode_kanji(void) testFinish(); } -void test_struct_split_example(void) +static void test_struct_split_example(void) { QRinput *input; QRinput_Struct *s; @@ -509,7 +509,7 @@ void test_struct_split_example(void) QRinput_Struct_free(s); } -void test_struct_split_tooLarge(void) +static void test_struct_split_tooLarge(void) { QRinput *input; QRinput_Struct *s; @@ -531,7 +531,7 @@ void test_struct_split_tooLarge(void) free(str); } -void test_struct_split_invalidVersion(void) +static void test_struct_split_invalidVersion(void) { QRinput *input; QRinput_Struct *s; @@ -553,7 +553,7 @@ void test_struct_split_invalidVersion(void) free(str); } -void test_struct_singlestructure(void) +static void test_struct_singlestructure(void) { QRinput *input; QRinput_Struct *s; @@ -573,7 +573,7 @@ void test_struct_singlestructure(void) QRinput_free(input); } -void test_splitentry(void) +static void test_splitentry(void) { QRinput *i1, *i2; QRinput_List *e; @@ -630,7 +630,7 @@ void test_splitentry(void) testFinish(); } -void test_splitentry2(void) +static void test_splitentry2(void) { QRinput *i1, *i2; QRinput_List *e; @@ -688,7 +688,7 @@ void test_splitentry2(void) testFinish(); } -void test_splitentry3(void) +static void test_splitentry3(void) { QRinput *input; QRinput_Struct *s; @@ -725,7 +725,7 @@ void test_splitentry3(void) testFinish(); } -void test_parity(void) +static void test_parity(void) { QRinput *input; QRinput_Struct *s; @@ -758,7 +758,7 @@ void test_parity(void) QRinput_Struct_free(s); } -void test_parity2(void) +static void test_parity2(void) { QRinput *input; QRinput_Struct *s; @@ -783,7 +783,7 @@ void test_parity2(void) QRinput_Struct_free(s); } -void test_null_free(void) +static void test_null_free(void) { testStart("Testing free NULL pointers"); assert_nothing(QRinput_free(NULL), "Check QRinput_free(NULL).\n"); @@ -791,7 +791,7 @@ void test_null_free(void) testFinish(); } -void test_mqr_new(void) +static void test_mqr_new(void) { QRinput *input; testStart("Testing QRinput_newMQR()."); @@ -816,7 +816,7 @@ void test_mqr_new(void) testFinish(); } -void test_mqr_setversion(void) +static void test_mqr_setversion(void) { QRinput *input; int ret; @@ -830,7 +830,7 @@ void test_mqr_setversion(void) testFinish(); } -void test_mqr_setlevel(void) +static void test_mqr_setlevel(void) { QRinput *input; int ret; @@ -844,7 +844,7 @@ void test_mqr_setlevel(void) testFinish(); } -void test_paddingMQR(void) +static void test_paddingMQR(void) { char *dataM1[] = {"65", "513", "5139", "51365"}; char *correctM1[] = {"01010000010000000000", @@ -868,7 +868,7 @@ void test_paddingMQR(void) testFinish(); } -void test_padding2MQR(void) +static void test_padding2MQR(void) { char *data[] = {"9", "513513", "513", "513"}; int ver[] = {1, 2, 2, 3}; @@ -888,7 +888,7 @@ void test_padding2MQR(void) testFinish(); } -void test_textMQR(void) +static void test_textMQR(void) { int version = 3; QRecLevel level = QR_ECLEVEL_M; @@ -902,7 +902,7 @@ void test_textMQR(void) testFinish(); } -void test_ECIinvalid(void) +static void test_ECIinvalid(void) { QRinput *stream; int ret; @@ -917,7 +917,7 @@ void test_ECIinvalid(void) testFinish(); } -void test_encodeECI(void) +static void test_encodeECI(void) { QRinput *input; BitStream *bstream; @@ -944,7 +944,7 @@ void test_encodeECI(void) testFinish(); } -int main(int argc, char **argv) +int main() { test_encodeNumeric(); test_encodeNumeric2(); diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 756adbf66d..48bf577aa5 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -5,7 +5,7 @@ #include "../qrencode_inner.h" #include "decoder.h" -void print_eccTable(void) +static void print_eccTable(void) { int i, j; int ecc; @@ -38,7 +38,7 @@ void print_eccTable(void) } } -void test_eccTable(void) +static void test_eccTable(void) { int i, j; int ecc; @@ -69,7 +69,7 @@ void test_eccTable(void) testEnd(err); } -void test_eccTable2(void) +static void test_eccTable2(void) { int i; int spec[5]; @@ -118,7 +118,7 @@ void test_eccTable2(void) testFinish(); } -void test_newframe(void) +static void test_newframe(void) { unsigned char buf[QRSPEC_WIDTH_MAX * QRSPEC_WIDTH_MAX]; int i, width; @@ -126,7 +126,7 @@ void test_newframe(void) FILE *fp; unsigned char *frame; QRcode *qrcode; - unsigned int version; + int version; testStart("Checking newly created frame."); fp = fopen("frame", "rb"); @@ -145,7 +145,7 @@ void test_newframe(void) assert_zero(memcmp(frame, buf, len), "frame pattern mismatch (version %d)\n", i); qrcode = QRcode_new(i, width, frame); version = QRcode_decodeVersion(qrcode); - assert_equal(version, (unsigned int)i, "Decoded version number is wrong: %d, expected %d.\n", version, i); + assert_equal(version, i, "Decoded version number is wrong: %d, expected %d.\n", version, i); QRcode_free(qrcode); } @@ -153,7 +153,7 @@ void test_newframe(void) fclose(fp); } -void test_newframe_invalid(void) +static void test_newframe_invalid(void) { unsigned char *frame; @@ -171,7 +171,7 @@ void test_newframe_invalid(void) * this test, change the value of the pattern marker's center dot from 0xa1 * to 0xb1 (QRspec_putAlignmentMarker() : finder). */ -void test_alignment(void) +static void test_alignment(void) { unsigned char *frame; int i, x, y, width, c; @@ -201,7 +201,7 @@ void test_alignment(void) } #endif -void test_verpat(void) +static void test_verpat(void) { int version; unsigned int pattern; @@ -242,7 +242,7 @@ void test_verpat(void) } } -void print_newFrame(void) +static void print_newFrame(void) { int width; int x, y; @@ -287,7 +287,7 @@ static unsigned int calcFormatInfo(int mask, QRecLevel level) return (data | ecc) ^ 0x5412; } -void test_format(void) +static void test_format(void) { unsigned int format; int i, j; @@ -308,7 +308,7 @@ void test_format(void) testEnd(err); } -int main(int argc, char **argv) +int main() { test_eccTable(); test_eccTable2(); diff --git a/tests/test_rs.c b/tests/test_rs.c index 128e306c87..d87aa88a1b 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -113,7 +113,7 @@ void test_allQRSizeAndECCLevel(void) testFinish(); } -int main(int argc, char **argv) +int main() { RSECC_decoder_init(); test_rscodeexample(); diff --git a/tests/test_split.c b/tests/test_split.c index d17501484a..0a64150c21 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -62,7 +62,7 @@ static int inputTest(QRinput_List *list, const char *fmt, ...) return 0; } -int inputSize(QRinput *input) +static int inputSize(QRinput *input) { BitStream *bstream; int size; @@ -75,7 +75,7 @@ int inputSize(QRinput *input) return size; } -void test_split1(void) +static void test_split1(void) { QRinput *input; BitStream *bstream; @@ -90,7 +90,7 @@ void test_split1(void) BitStream_free(bstream); } -void test_split2(void) +static void test_split2(void) { QRinput *input; QRinput_List *list; @@ -118,7 +118,7 @@ void test_split2(void) QRinput_free(input); } -void test_split3(void) +static void test_split3(void) { QRinput *input; QRinput_List *list; @@ -158,7 +158,7 @@ void test_split3(void) QRinput_free(input); } -void test_split4(void) +static void test_split4(void) { QRinput *input; QRinput *i1, *i2; @@ -219,7 +219,7 @@ void test_split4(void) QRinput_free(i2); } -void test_split5(void) +static void test_split5(void) { QRinput *input; QRinput_List *list; @@ -236,7 +236,7 @@ void test_split5(void) QRinput_free(input); } -void test_split6(void) +static void test_split6(void) { QRinput *input; QRinput_List *list; @@ -254,7 +254,7 @@ void test_split6(void) QRinput_free(input); } -void test_split7(void) +static void test_split7(void) { QRinput *input; QRinput_List *list; @@ -271,7 +271,7 @@ void test_split7(void) QRinput_free(input); } -void test_split8(void) +static void test_split8(void) { QRinput *input; QRinput_List *list; @@ -288,7 +288,7 @@ void test_split8(void) QRinput_free(input); } -void test_split3c(void) +static void test_split3c(void) { QRinput *input; QRinput_List *list; @@ -328,7 +328,7 @@ void test_split3c(void) QRinput_free(input); } -void test_toupper(void) +static void test_toupper(void) { QRinput *input; QRinput_List *list; @@ -378,7 +378,7 @@ void test_toupper(void) QRinput_free(input); } -void test_splitNum8(void) +static void test_splitNum8(void) { QRinput *input; QRinput_List *list; @@ -396,7 +396,7 @@ void test_splitNum8(void) QRinput_free(input); } -void test_splitAnNAn(void) +static void test_splitAnNAn(void) { QRinput *input1, *input2, *input3; int s1, s2, s3; @@ -429,7 +429,7 @@ void test_splitAnNAn(void) QRinput_free(input3); } -void test_splitAn8An(void) +static void test_splitAn8An(void) { QRinput *input1, *input2, *input3; int s1, s2, s3; @@ -462,7 +462,7 @@ void test_splitAn8An(void) QRinput_free(input3); } -void test_split8An8(void) +static void test_split8An8(void) { QRinput *input1, *input2, *input3; int s1, s2, s3; @@ -495,7 +495,7 @@ void test_split8An8(void) QRinput_free(input3); } -void test_split8N8(void) +static void test_split8N8(void) { QRinput *input1, *input2, *input3; int s1, s2, s3; @@ -528,7 +528,7 @@ void test_split8N8(void) QRinput_free(input3); } -int main(int argc, char **argv) +int main() { test_split1(); test_split2(); diff --git a/tests/test_split_urls.c b/tests/test_split_urls.c index 6b9dd29699..da22da5f1f 100644 --- a/tests/test_split_urls.c +++ b/tests/test_split_urls.c @@ -9,7 +9,7 @@ #include "URI_testset.inc" -void encodeURLandPrint(char *url) { +static void encodeURLandPrint(char *url) { QRinput *input; BitStream *bstream; @@ -24,7 +24,7 @@ void encodeURLandPrint(char *url) { BitStream_free(bstream); } -void print_currentBitLength() { +static void print_currentBitLength() { struct TestSet *ts = testset; puts("struct TestSet {\n\tint expected_length;\n\tchar *url;\n};"); @@ -38,7 +38,7 @@ void print_currentBitLength() { puts("{0,NULL}\n};"); } -int encodeURLandCompare(char *url, int expected_length) { +static int encodeURLandCompare(char *url, size_t expected_length) { QRinput *input; BitStream *bstream; int ret = 0; @@ -48,14 +48,14 @@ int encodeURLandCompare(char *url, int expected_length) { bstream = BitStream_new(); QRinput_mergeBitStream(input, bstream); - int length = BitStream_size(bstream); + size_t length = BitStream_size(bstream); if(length > expected_length) { - printf("The length of the encode stream is longer than expected: %d over %d\n", length, expected_length); + printf("The length of the encode stream is longer than expected: %zu over %zu\n", length, expected_length); printQRinput(input); ret = 1; } else if(length < expected_length) { - printf("The length of the encode stream is shorter than expected: %d under %d\n", length, expected_length); + printf("The length of the encode stream is shorter than expected: %zu under %zu\n", length, expected_length); printQRinput(input); ret = 1; @@ -67,7 +67,7 @@ int encodeURLandCompare(char *url, int expected_length) { return ret; } -void test_bitstream_length() { +static void test_bitstream_length() { struct TestSet *ts = testset; int err = 0; @@ -79,7 +79,7 @@ void test_bitstream_length() { testEnd(err); } -int main(int argc, char **argv) +int main() { test_bitstream_length(); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index a6508ad427..af8f381ade 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -174,7 +174,7 @@ static void draw_QRcode(QRcode *qrcode, int ox, int oy) } } -void draw_singleQRcode(QRinput *stream, int mask) +static void draw_singleQRcode(QRinput *stream, int mask) { QRcode *qrcode; int width; @@ -209,7 +209,7 @@ void draw_singleQRcode(QRinput *stream, int mask) QRcode_free(qrcode); } -void draw_structuredQRcode(QRinput_Struct *s) +static void draw_structuredQRcode(QRinput_Struct *s) { int i, w, h, n, x, y; int swidth; @@ -244,7 +244,7 @@ void draw_structuredQRcode(QRinput_Struct *s) QRcode_List_free(qrcodes); } -void draw_structuredQRcodeFromText(int argc, char **argv) +static void draw_structuredQRcodeFromText(int argc, char **argv) { QRinput_Struct *s; QRinput *input; @@ -285,7 +285,7 @@ void draw_structuredQRcodeFromText(int argc, char **argv) QRinput_Struct_free(s); } -void draw_structuredQRcodeFromQRinput(QRinput *stream) +static void draw_structuredQRcodeFromQRinput(QRinput *stream) { QRinput_Struct *s; @@ -300,7 +300,7 @@ void draw_structuredQRcodeFromQRinput(QRinput *stream) } } -void view(int mode, QRinput *input) +static void view(int mode, QRinput *input) { int flag = 1; int mask = -1; @@ -425,7 +425,7 @@ void view(int mode, QRinput *input) } } -void view_simple(const unsigned char *str, int length) +static void view_simple(const unsigned char *str, int length) { QRinput *input; int ret; @@ -454,7 +454,7 @@ void view_simple(const unsigned char *str, int length) QRinput_free(input); } -void view_multiText(char **argv, int argc) +static void view_multiText(char **argv, int argc) { textc = argc; textv = argv; -- cgit 0.0.5-2-1-g0f52 From 45c5bb70485f63727a1d1417198873fdc997bf82 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 3 Oct 2017 00:43:10 +0900 Subject: Removed unused function. --- tests/test_qrencode.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 15e6e733f4..7de7a0f556 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -30,19 +30,6 @@ typedef struct { #define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0)) -static int inputSize(QRinput *input) -{ - BitStream *bstream; - int size; - - bstream = BitStream_new(); - QRinput_mergeBitStream(input, bstream); - size = BitStream_size(bstream); - BitStream_free(bstream); - - return size; -} - static void test_qrraw_new(void) { int i; -- cgit 0.0.5-2-1-g0f52 From dc45e212768f4cd84635e2f61848b9a313da7c3b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 3 Oct 2017 00:43:21 +0900 Subject: Added a new test function. --- ChangeLog | 4 ++++ tests/test_qrinput.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad8431b2f2..3e892f3974 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,10 @@ - Comment format fixes. * various files in tests: - Fixed some warnings. + * tests/test_qrencode.c: + - Removed unused function. + * tests/test_qrinput.c: + - Added a new test function. 2017.09.29 Kentaro Fukuchi [4.0] diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 587ca64b1e..7f33fb9226 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -464,10 +464,10 @@ static void test_lengthOfCode_num(void) static void test_lengthOfCode_kanji(void) { int i, bytes; - unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa}; + unsigned char str[12]= {0x93, 0x5f, 0xe4, 0xaa, 0x81, 0x40, 0x9f, 0xfc, 0xe0, 0x40, 0xeb, 0xbf}; testStart("Checking length of code (kanji)"); - for(i=2; i<=4; i+=2) { + for(i=2; i<=12; i+=2) { bytes = check_lengthOfCode(QR_MODE_KANJI, (char *)str, i, 1); assert_equal(i, bytes, "lengthOfCode failed. (QR_MODE_KANJI, version:1, size:%d)\n", i); } @@ -965,6 +965,7 @@ int main() test_insertStructuredAppendHeader_error(); test_struct_insertStructuredAppendHeaders(); test_lengthOfCode_num(); + test_lengthOfCode_kanji(); test_splitentry(); test_splitentry2(); test_splitentry3(); -- cgit 0.0.5-2-1-g0f52 From 5040f2bc800ac4eda863a8ceafa2f86f7301341c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 5 Oct 2017 15:02:21 +0900 Subject: Code cleanups. --- ChangeLog | 6 ++++++ tests/test_mask.c | 9 ++++++--- tests/test_mmask.c | 9 ++++++--- tests/test_mqrspec.c | 9 ++++++--- tests/test_qrencode.c | 15 ++++++++++----- tests/test_qrspec.c | 27 ++++++--------------------- tests/test_split_urls.c | 2 ++ 7 files changed, 42 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e892f3974..e34585e145 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017.10.05 Kentaro Fukuchi + [4.0] + * tests/test_{mask,mmask,qrspec,mqrspec,split_urls,qrencode}.c: + - Removed or commented out unused functions. + - Command line option introduced for verbose debug information. + 2017.10.02 Kentaro Fukuchi [4.0] * bitstream.h, qrencode.c, qrencode_inner.h: diff --git a/tests/test_mask.c b/tests/test_mask.c index 4bf368be96..bfb4901f30 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -90,6 +90,7 @@ static void print_masks(void) { int i; + puts("\nPrinting mask patterns."); for(i=0; i<8; i++) { print_mask(i); } @@ -388,9 +389,8 @@ static void test_calcN1N3(void) testFinish(); } -int main() +int main(int argc, char **argv) { - //print_masks(); test_masks(); test_eval(); test_eval2(); @@ -399,8 +399,11 @@ int main() test_calcN2(); test_calcRunLength(); test_calcN1N3(); - report(); + if(argc > 1) { + print_masks(); + } + return 0; } diff --git a/tests/test_mmask.c b/tests/test_mmask.c index 2b0cfa2f0c..a083b7bf64 100644 --- a/tests/test_mmask.c +++ b/tests/test_mmask.c @@ -61,6 +61,7 @@ static void print_masks(void) { int i; + puts("\nPrinting mask patterns."); for(i=0; i<4; i++) { print_mask(i); } @@ -138,13 +139,15 @@ static void test_maskEvaluation(void) testFinish(); } -int main() +int main(int argc, char **argv) { - //print_masks(); test_masks(); test_maskEvaluation(); - report(); + if(argc > 1) { + print_masks(); + } + return 0; } diff --git a/tests/test_mqrspec.c b/tests/test_mqrspec.c index 3673de0215..4ea0d5199e 100644 --- a/tests/test_mqrspec.c +++ b/tests/test_mqrspec.c @@ -124,6 +124,7 @@ static void print_format(void) unsigned int format; int i, j; + puts("\nPrinting hex strings of format information."); for(i=0; i<4; i++) { for(j=0; j<8; j++) { format = calcFormatInfo(j, i); @@ -162,15 +163,17 @@ static void test_dataLength(void) testEnd(err); } -int main() +int main(int argc, char **argv) { test_newFrame(); test_newframe_invalid(); - //print_format(); test_format(); test_dataLength(); - report(); + if(argc > 1) { + print_format(); + } + return 0; } diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 7de7a0f556..88ed50a995 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -146,6 +146,7 @@ static void print_filler(void) int version = 7; unsigned char *frame; + puts("\nPrinting debug info of FrameFiller."); width = QRspec_getWidth(version); frame = FrameFiller_test(version); if(frame == NULL) abort(); @@ -189,6 +190,7 @@ static void print_fillerMQR(void) int version = 3; unsigned char *frame; + puts("\nPrinting debug info of FrameFiller for Micro QR."); for(version = 1; version <= MQRSPEC_VERSION_MAX; version++) { width = MQRspec_getWidth(version); frame = FrameFiller_testMQR(version); @@ -536,6 +538,7 @@ static void print_01234567(void) char num[9] = "01234567"; QRcode *qrcode; + puts("\nPrinting QR code of '01234567'."); stream = QRinput_new2(1, QR_ECLEVEL_M); QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num); qrcode = QRcode_encodeInput(stream); @@ -944,11 +947,10 @@ static void test_apiversion(void) testFinish(); } -int main() +int main(int argc, char **argv) { test_iterate(); test_iterate2(); - //print_filler(); test_filler(); test_format(); test_encode(); @@ -961,7 +963,6 @@ int main() test_encodeLongData(); test_01234567(); test_invalid_input(); -// print_01234567(); test_struct_example(); test_struct_semilong(); test_null_free(); @@ -972,7 +973,6 @@ int main() test_decodeSimple(); test_decodeLong(); test_decodeVeryLong(); - //print_fillerMQR(); test_fillerMQR(); test_formatInfoMQR(); test_encodeTooLongMQR(); @@ -980,8 +980,13 @@ int main() test_oddBitCalcMQR(); test_mqrencode(); test_apiversion(); - report(); + if(argc > 1) { + print_filler(); + print_01234567(); + print_fillerMQR(); + } + return 0; } diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 48bf577aa5..fd4084aca9 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -12,6 +12,7 @@ static void print_eccTable(void) int data; int spec[5]; + puts("\nPrinting ECC table.\n"); for(i=1; i<=QRSPEC_VERSION_MAX; i++) { printf("Version %2d\n", i); for(j=0; j<4; j++) { @@ -242,23 +243,6 @@ static void test_verpat(void) } } -static void print_newFrame(void) -{ - int width; - int x, y; - unsigned char *frame; - - frame = QRspec_newFrame(7); - width = QRspec_getWidth(7); - for(y=0; y 1) { + print_eccTable(); + } + return 0; } diff --git a/tests/test_split_urls.c b/tests/test_split_urls.c index da22da5f1f..432d3b5718 100644 --- a/tests/test_split_urls.c +++ b/tests/test_split_urls.c @@ -9,6 +9,7 @@ #include "URI_testset.inc" +#if 0 static void encodeURLandPrint(char *url) { QRinput *input; BitStream *bstream; @@ -37,6 +38,7 @@ static void print_currentBitLength() { puts("{0,NULL}\n};"); } +#endif static int encodeURLandCompare(char *url, size_t expected_length) { QRinput *input; -- cgit 0.0.5-2-1-g0f52 From f653e2329fe9eab379b8282cfbce47b8c13471bb Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 11 Sep 2017 17:16:54 +0900 Subject: Symbol data representation of QRcode object has been slightly changed. --- ChangeLog | 10 ++++++++++ qrencode.c | 25 +++++++++++++++++++++++-- qrencode.h | 2 +- tests/test_qrencode.c | 32 ++++++++++++++++---------------- tests/view_qrcode.c | 35 +++++++++++++++++++++++++++-------- 5 files changed, 77 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index e34585e145..67dcac009f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -69,6 +69,16 @@ * README.md: - Version number added to the 1st line. - Fixed the URL to the badge of Travis CI. + [master] + * qrencode.[ch]: + - Symbol data representation of QRcode object has slightly changed. This + change does not affect to most applications. + - If your application uses bits other than the LSB, read the comments of + QRCode class carefully. + * tests/test_qrencode.c: + - Modified correct pattern of a test referring non-LSB bits of QRCode. + * tests/view_qrcode.c: + - Now you can identify the feature of modules by color. 2017.09.07 Kentaro Fukuchi * *.[ch]: diff --git a/qrencode.c b/qrencode.c index f0a872fe52..cd873f44af 100644 --- a/qrencode.c +++ b/qrencode.c @@ -463,7 +463,17 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMask(QRinput *input, int mask) FrameFiller_set(&filler, width, frame, 0); /* interleaved data and ecc codes */ - for(i = 0; i < raw->dataLength + raw->eccLength; i++) { + for(i = 0; i < raw->dataLength; i++) { + code = QRraw_getCode(raw); + bit = 0x80; + for(j = 0; j < 8; j++) { + p = FrameFiller_next(&filler); + if(p == NULL) goto EXIT; + *p = ((bit & code) != 0); + bit = bit >> 1; + } + } + for(i = 0; i < raw->eccLength; i++) { code = QRraw_getCode(raw); bit = 0x80; for(j = 0; j < 8; j++) { @@ -541,7 +551,7 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) FrameFiller_set(&filler, width, frame, 1); /* interleaved data and ecc codes */ - for(i = 0; i < raw->dataLength + raw->eccLength; i++) { + for(i = 0; i < raw->dataLength; i++) { code = MQRraw_getCode(raw); bit = 0x80; if(raw->oddbits && i == raw->dataLength - 1) { @@ -549,6 +559,17 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) } else { length = 8; } + for(j = 0; j < length; j++) { + p = FrameFiller_next(&filler); + if(p == NULL) goto EXIT; + *p = ((bit & code) != 0); + bit = bit >> 1; + } + } + for(i = 0; i < raw->eccLength; i++) { + code = MQRraw_getCode(raw); + bit = 0x80; + length = 8; for(j = 0; j < length; j++) { p = FrameFiller_next(&filler); if(p == NULL) goto EXIT; diff --git a/qrencode.h b/qrencode.h index 53f633bd16..461e8690b8 100644 --- a/qrencode.h +++ b/qrencode.h @@ -363,7 +363,7 @@ extern int QRinput_setFNC1Second(QRinput *input, unsigned char appid); * @verbatim MSB 76543210 LSB |||||||`- 1=black/0=white - ||||||`-- data and ecc code area + ||||||`-- 1=ecc/0=data code area |||||`--- format information ||||`---- version information |||`----- timing pattern diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 88ed50a995..678c4f1100 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -500,23 +500,23 @@ static void test_01234567(void) 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x84, 0x03, 0x03, 0x03, 0x03, 0xc0, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x02, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x03, 0x02, 0x02, 0x02, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, -0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x03, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, -0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x03, 0xc0, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, +0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x01, 0x01, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, +0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x00, 0x01, 0xc0, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x91, 0x90, 0x91, 0x90, 0x91, 0xc0, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, -0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x85, 0x02, 0x02, 0x03, 0x03, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, -0x85, 0x84, 0x85, 0x85, 0x85, 0x85, 0x91, 0x84, 0x84, 0x03, 0x02, 0x02, 0x03, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84, -0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x90, 0x03, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02, -0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x91, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, -0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x90, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, -0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x91, 0x03, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, -0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x81, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, -0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x84, 0x03, 0x03, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, -0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x03, -0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02, -0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, -0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, -0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x84, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, -0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x85, 0x03, 0x03, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02}; +0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x85, 0x02, 0x02, 0x01, 0x01, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, +0x85, 0x84, 0x85, 0x85, 0x85, 0x85, 0x91, 0x84, 0x84, 0x03, 0x02, 0x00, 0x01, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84, +0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x90, 0x03, 0x03, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, +0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x91, 0x03, 0x02, 0x03, 0x02, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, +0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x90, 0x02, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, +0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x91, 0x03, 0x03, 0x02, 0x02, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, +0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x81, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, +0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x84, 0x03, 0x03, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, +0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, +0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, +0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x03, 0x02, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, +0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, +0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x84, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, +0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x85, 0x03, 0x03, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00}; testStart("Encode 01234567 in 1-M"); stream = QRinput_new2(1, QR_ECLEVEL_M); diff --git a/tests/view_qrcode.c b/tests/view_qrcode.c index af8f381ade..f9d1bea96b 100644 --- a/tests/view_qrcode.c +++ b/tests/view_qrcode.c @@ -21,6 +21,7 @@ static int size = 4; static int margin = -1; static int structured = 0; static int micro = 0; +static int colorize = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; @@ -148,7 +149,17 @@ static void draw_QRcode(QRcode *qrcode, int ox, int oy) int x, y, width; unsigned char *p; SDL_Rect rect; - Uint32 color; + Uint32 color[8]; + int col; + + color[0] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + color[1] = SDL_MapRGBA(surface->format, 0, 0, 0, 255); + color[2] = SDL_MapRGBA(surface->format, 192, 192, 255, 255); + color[3] = SDL_MapRGBA(surface->format, 0, 0, 64, 255); + color[4] = SDL_MapRGBA(surface->format, 255, 255, 192, 255); + color[5] = SDL_MapRGBA(surface->format, 64, 64, 0, 255); + color[6] = SDL_MapRGBA(surface->format, 255, 192, 192, 255); + color[7] = SDL_MapRGBA(surface->format, 64, 0, 0, 255); ox += margin * size; oy += margin * size; @@ -160,15 +171,19 @@ static void draw_QRcode(QRcode *qrcode, int ox, int oy) rect.y = oy + y * size; rect.w = size; rect.h = size; - if(*p & 1) { - //SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); - color = SDL_MapRGBA(surface->format, 0, 0, 0, 255); + if(!colorize) { + col = 0; } else { - //SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); - color = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + if(*p & 0x80) { + col = 6; + } else if(*p & 0x02) { + col = 4; + } else { + col = 2; + } } - //SDL_RenderFillRect(renderer, &rect); - SDL_FillRect(surface, &rect, color); + col += (*p & 1); + SDL_FillRect(surface, &rect, color[col]); p++; } } @@ -397,6 +412,10 @@ static void view(int mode, QRinput *input) level = QR_ECLEVEL_Q; loop = 0; break; + case SDLK_c: + colorize ^= 1; + loop = 0; + break; case SDLK_ESCAPE: loop = 0; flag = 0; -- cgit 0.0.5-2-1-g0f52 From da2593399c81cadf27a157b8ba1c32ab1544b576 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 12 Sep 2017 21:07:31 +0900 Subject: Documentation fix. --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67dcac009f..ad3fe78cdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -71,8 +71,8 @@ - Fixed the URL to the badge of Travis CI. [master] * qrencode.[ch]: - - Symbol data representation of QRcode object has slightly changed. This - change does not affect to most applications. + - Symbol data representation of QRcode object has been slightly changed. + This change does not affect to most applications. - If your application uses bits other than the LSB, read the comments of QRCode class carefully. * tests/test_qrencode.c: -- cgit 0.0.5-2-1-g0f52 From cf2b1a81461c7f5896db5b8cb946b21bf9f6e6ff Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 21 Sep 2017 15:55:51 +0900 Subject: Revert 67c89c40. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b37a356d1f..d8f1eb4a30 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# libqrencode 4.0.0 - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=4.0)](https://travis-ci.org/fukuchi/libqrencode) +# libqrencode - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) **Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.0. -- cgit 0.0.5-2-1-g0f52 From f6e8ba631c2c4ac7ff678756679618cc2a672311 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 Oct 2017 00:05:45 +0900 Subject: A new testing script introduced. --- ChangeLog | 8 ++++++++ tests/test_all.sh | 12 +----------- tests/test_basic.sh | 12 ++++++++++++ 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100755 tests/test_basic.sh diff --git a/ChangeLog b/ChangeLog index ad3fe78cdd..ed6af42a40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2017.10.06 Kentaro Fukuchi + [master] + * tests/test_{all,basic}.sh: + - All tests except test_configure.sh can be run by test_basic.sh now. + - test_all.sh activates test_basic.sh + test_configure.sh. + - test_basic.sh is better during active development, especially when you + gave additional options to configure script. + 2017.10.05 Kentaro Fukuchi [4.0] * tests/test_{mask,mmask,qrspec,mqrspec,split_urls,qrencode}.c: diff --git a/tests/test_all.sh b/tests/test_all.sh index 55550159e9..9ba040ae77 100755 --- a/tests/test_all.sh +++ b/tests/test_all.sh @@ -1,13 +1,3 @@ #!/bin/sh -e -./test_bitstream -./test_estimatebit -./test_qrencode -./test_qrinput -./test_qrspec -./test_rs -./test_split -./test_mask -./test_mqrspec -./test_mmask -./test_monkey +. ./test_basic.sh ./test_configure.sh diff --git a/tests/test_basic.sh b/tests/test_basic.sh new file mode 100755 index 0000000000..06de1d4b02 --- /dev/null +++ b/tests/test_basic.sh @@ -0,0 +1,12 @@ +#!/bin/sh -e +./test_bitstream +./test_estimatebit +./test_qrencode +./test_qrinput +./test_qrspec +./test_rs +./test_split +./test_mask +./test_mqrspec +./test_mmask +./test_monkey -- cgit 0.0.5-2-1-g0f52 From 72c039f4c2eb661d357c9af560b700d174956b0b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 Oct 2017 01:23:13 +0900 Subject: Fixed some warnings. --- ChangeLog | 2 ++ bitstream.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ed6af42a40..bf450b8222 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ - test_all.sh activates test_basic.sh + test_configure.sh. - test_basic.sh is better during active development, especially when you gave additional options to configure script. + * bitstream.c: + - Fixed some warnings. 2017.10.05 Kentaro Fukuchi [4.0] diff --git a/bitstream.c b/bitstream.c index f5e0b95f4c..f620050dc6 100644 --- a/bitstream.c +++ b/bitstream.c @@ -94,7 +94,7 @@ static void BitStream_writeNum(unsigned char *dest, size_t bits, unsigned int nu unsigned char *p; p = dest; - mask = 1 << (bits - 1); + mask = 1U << (bits - 1); for(i = 0; i < bits; i++) { if(num & mask) { *p = 1; -- cgit 0.0.5-2-1-g0f52 From f318155de487028ca2c6273cb6c3a0b3d22645c7 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 Oct 2017 01:27:50 +0900 Subject: Revert "Some variables' type changed from int to unsigned int. (closing #89 and #102)" This reverts commit 44290eb817f6f5ccb1137372f115d4b7633f0cb3. --- ChangeLog | 3 --- mask.c | 40 ++++++++++++++++++++-------------------- mask.h | 8 ++++---- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf450b8222..bcb03e5d23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,9 +29,6 @@ - Fixed some warnings. * NEWS: - Format fixes. - * mask.[ch]: - - Some variables' type changed from int to unsigned int. (closing #89 and - #102) * tests/test_mask.c: - Fixed some warnings. * qrencode.h, qrinput.h, mqrspec.c: diff --git a/mask.c b/mask.c index 127a56ebea..3d7e15de33 100644 --- a/mask.c +++ b/mask.c @@ -31,12 +31,12 @@ #include "qrspec.h" #include "mask.h" -STATIC_IN_RELEASE unsigned int Mask_writeFormatInformation(unsigned int width, unsigned char *frame, int mask, QRecLevel level) +STATIC_IN_RELEASE int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level) { unsigned int format; unsigned char v; - unsigned int i; - unsigned int blacks = 0; + int i; + int blacks = 0; format = QRspec_getFormatInfo(mask, level); @@ -84,8 +84,8 @@ STATIC_IN_RELEASE unsigned int Mask_writeFormatInformation(unsigned int width, u #define N4 (10) #define MASKMAKER(__exp__) \ - unsigned int x, y;\ - unsigned int b = 0;\ + int x, y;\ + int b = 0;\ \ for(y = 0; y < width; y++) {\ for(x = 0; x < width; x++) {\ @@ -94,61 +94,61 @@ STATIC_IN_RELEASE unsigned int Mask_writeFormatInformation(unsigned int width, u } else {\ *d = *s ^ ((__exp__) == 0);\ }\ - b += (unsigned int)(*d & 1);\ + b += (int)(*d & 1);\ s++; d++;\ }\ }\ return b; -static unsigned int Mask_mask0(unsigned int width, const unsigned char *s, unsigned char *d) +static int Mask_mask0(int width, const unsigned char *s, unsigned char *d) { MASKMAKER((x+y)&1) } -static unsigned int Mask_mask1(unsigned int width, const unsigned char *s, unsigned char *d) +static int Mask_mask1(int width, const unsigned char *s, unsigned char *d) { MASKMAKER(y&1) } -static unsigned int Mask_mask2(unsigned int width, const unsigned char *s, unsigned char *d) +static int Mask_mask2(int width, const unsigned char *s, unsigned char *d) { MASKMAKER(x%3) } -static unsigned int Mask_mask3(unsigned int width, const unsigned char *s, unsigned char *d) +static int Mask_mask3(int width, const unsigned char *s, unsigned char *d) { MASKMAKER((x+y)%3) } -static unsigned int Mask_mask4(unsigned int width, const unsigned char *s, unsigned char *d) +static int Mask_mask4(int width, const unsigned char *s, unsigned char *d) { MASKMAKER(((y/2)+(x/3))&1) } -static unsigned int Mask_mask5(unsigned int width, const unsigned char *s, unsigned char *d) +static int Mask_mask5(int width, const unsigned char *s, unsigned char *d) { MASKMAKER(((x*y)&1)+(x*y)%3) } -static unsigned int Mask_mask6(unsigned int width, const unsigned char *s, unsigned char *d) +static int Mask_mask6(int width, const unsigned char *s, unsigned char *d) { MASKMAKER((((x*y)&1)+(x*y)%3)&1) } -static unsigned int Mask_mask7(unsigned int width, const unsigned char *s, unsigned char *d) +static int Mask_mask7(int width, const unsigned char *s, unsigned char *d) { MASKMAKER((((x*y)%3)+((x+y)&1))&1) } #define maskNum (8) -typedef unsigned int MaskMaker(unsigned int, const unsigned char *, unsigned char *); +typedef int MaskMaker(int, const unsigned char *, unsigned char *); static MaskMaker *maskMakers[maskNum] = { Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3, Mask_mask4, Mask_mask5, Mask_mask6, Mask_mask7 }; #ifdef WITH_TESTS -unsigned char *Mask_makeMaskedFrame(unsigned int width, unsigned char *frame, int mask) +unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask) { unsigned char *masked; @@ -161,7 +161,7 @@ unsigned char *Mask_makeMaskedFrame(unsigned int width, unsigned char *frame, in } #endif -unsigned char *Mask_makeMask(unsigned int width, unsigned char *frame, int mask, QRecLevel level) +unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level) { unsigned char *masked; @@ -319,15 +319,15 @@ STATIC_IN_RELEASE int Mask_evaluateSymbol(int width, unsigned char *frame) return demerit; } -unsigned char *Mask_mask(unsigned int width, unsigned char *frame, QRecLevel level) +unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) { int i; unsigned char *mask, *bestMask; int minDemerit = INT_MAX; - unsigned int blacks; + int blacks; int bratio; int demerit; - unsigned int w2 = width * width; + int w2 = width * width; mask = (unsigned char *)malloc(w2); if(mask == NULL) return NULL; diff --git a/mask.h b/mask.h index b0b33c34d0..169e64b2bb 100644 --- a/mask.h +++ b/mask.h @@ -22,8 +22,8 @@ #ifndef MASK_H #define MASK_H -extern unsigned char *Mask_makeMask(unsigned int width, unsigned char *frame, int mask, QRecLevel level); -extern unsigned char *Mask_mask(unsigned int width, unsigned char *frame, QRecLevel level); +extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); #ifdef WITH_TESTS extern int Mask_calcN2(int width, unsigned char *frame); @@ -31,8 +31,8 @@ extern int Mask_calcN1N3(int length, int *runLength); extern int Mask_calcRunLengthH(int width, unsigned char *frame, int *runLength); extern int Mask_calcRunLengthV(int width, unsigned char *frame, int *runLength); extern int Mask_evaluateSymbol(int width, unsigned char *frame); -extern unsigned int Mask_writeFormatInformation(unsigned int width, unsigned char *frame, int mask, QRecLevel level); -extern unsigned char *Mask_makeMaskedFrame(unsigned int width, unsigned char *frame, int mask); +extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); +extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); #endif #endif /* MASK_H */ -- cgit 0.0.5-2-1-g0f52 From b25ff8609a9e763d54232f8c8effebe86dfe6e91 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 Oct 2017 01:53:02 +0900 Subject: Fixed some warnings. --- ChangeLog | 2 +- mask.c | 10 +++++----- mmask.c | 8 ++++---- mqrspec.c | 4 ++-- qrencode.c | 14 +++++++------- qrinput.c | 4 ++-- qrspec.c | 4 ++-- split.c | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index bcb03e5d23..fc29ea3248 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ - test_all.sh activates test_basic.sh + test_configure.sh. - test_basic.sh is better during active development, especially when you gave additional options to configure script. - * bitstream.c: + * split.c, qrspec.c, mqrspec.c, mask.c, mmask.c, qrencode.c, qrinput.c: - Fixed some warnings. 2017.10.05 Kentaro Fukuchi diff --git a/mask.c b/mask.c index 3d7e15de33..4bf2371765 100644 --- a/mask.c +++ b/mask.c @@ -152,7 +152,7 @@ unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask) { unsigned char *masked; - masked = (unsigned char *)malloc(width * width); + masked = (unsigned char *)malloc((size_t)(width * width)); if(masked == NULL) return NULL; maskMakers[mask](width, frame, masked); @@ -170,7 +170,7 @@ unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLeve return NULL; } - masked = (unsigned char *)malloc(width * width); + masked = (unsigned char *)malloc((size_t)(width * width)); if(masked == NULL) return NULL; maskMakers[mask](width, frame, masked); @@ -329,9 +329,9 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) int demerit; int w2 = width * width; - mask = (unsigned char *)malloc(w2); + mask = (unsigned char *)malloc((size_t)w2); if(mask == NULL) return NULL; - bestMask = (unsigned char *)malloc(w2); + bestMask = (unsigned char *)malloc((size_t)w2); if(bestMask == NULL) { free(mask); return NULL; @@ -349,7 +349,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) // printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit); if(demerit < minDemerit) { minDemerit = demerit; - memcpy(bestMask, mask, w2); + memcpy(bestMask, mask, (size_t)w2); } } free(mask); diff --git a/mmask.c b/mmask.c index a1fb041e60..5f09a1e981 100644 --- a/mmask.c +++ b/mmask.c @@ -96,7 +96,7 @@ unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask) { unsigned char *masked; - masked = (unsigned char *)malloc(width * width); + masked = (unsigned char *)malloc((size_t)(width * width)); if(masked == NULL) return NULL; maskMakers[mask](width, frame, masked); @@ -116,7 +116,7 @@ unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecL } width = MQRspec_getWidth(version); - masked = (unsigned char *)malloc(width * width); + masked = (unsigned char *)malloc((size_t)(width * width)); if(masked == NULL) return NULL; maskMakers[mask](width, frame, masked); @@ -155,7 +155,7 @@ unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level) width = MQRspec_getWidth(version); - mask = (unsigned char *)malloc(width * width); + mask = (unsigned char *)malloc((size_t)(width * width)); if(mask == NULL) return NULL; bestMask = NULL; @@ -168,7 +168,7 @@ unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level) maxScore = score; free(bestMask); bestMask = mask; - mask = (unsigned char *)malloc(width * width); + mask = (unsigned char *)malloc((size_t)(width * width)); if(mask == NULL) break; } } diff --git a/mqrspec.c b/mqrspec.c index 86e81f1f0a..87205fe970 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -191,10 +191,10 @@ static unsigned char *MQRspec_createFrame(int version) int x, y; width = mqrspecCapacity[version].width; - frame = (unsigned char *)malloc(width * width); + frame = (unsigned char *)malloc((size_t)(width * width)); if(frame == NULL) return NULL; - memset(frame, 0, width * width); + memset(frame, 0, (size_t)(width * width)); /* Finder pattern */ putFinderPattern(frame, width, 0, 0); /* Separator */ diff --git a/qrencode.c b/qrencode.c index cd873f44af..d3a2ebf578 100644 --- a/qrencode.c +++ b/qrencode.c @@ -124,7 +124,7 @@ STATIC_IN_RELEASE QRRawCode *QRraw_new(QRinput *input) raw->b1 = QRspec_rsBlockNum1(spec); raw->dataLength = QRspec_rsDataLength(spec); raw->eccLength = QRspec_rsEccLength(spec); - raw->ecccode = (unsigned char *)malloc(raw->eccLength); + raw->ecccode = (unsigned char *)malloc((size_t)raw->eccLength); if(raw->ecccode == NULL) { free(raw->datacode); free(raw); @@ -132,7 +132,7 @@ STATIC_IN_RELEASE QRRawCode *QRraw_new(QRinput *input) } raw->blocks = QRspec_rsBlockNum(spec); - raw->rsblock = (RSblock *)calloc(raw->blocks, sizeof(RSblock)); + raw->rsblock = (RSblock *)calloc((size_t)(raw->blocks), sizeof(RSblock)); if(raw->rsblock == NULL) { QRraw_free(raw); return NULL; @@ -219,7 +219,7 @@ STATIC_IN_RELEASE MQRRawCode *MQRraw_new(QRinput *input) free(raw); return NULL; } - raw->ecccode = (unsigned char *)malloc(raw->eccLength); + raw->ecccode = (unsigned char *)malloc((size_t)raw->eccLength); if(raw->ecccode == NULL) { free(raw->datacode); free(raw); @@ -495,8 +495,8 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMask(QRinput *input, int mask) /* masking */ if(mask == -2) { // just for debug purpose - masked = (unsigned char *)malloc(width * width); - memcpy(masked, frame, width * width); + masked = (unsigned char *)malloc((size_t)(width * width)); + memcpy(masked, frame, (size_t)(width * width)); } else if(mask < 0) { masked = Mask_mask(width, frame, input->level); } else { @@ -582,8 +582,8 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) /* masking */ if(mask == -2) { // just for debug purpose - masked = (unsigned char *)malloc(width * width); - memcpy(masked, frame, width * width); + masked = (unsigned char *)malloc((size_t)(width * width)); + memcpy(masked, frame, (size_t)(width * width)); } else if(mask < 0) { masked = MMask_mask(version, frame, input->level); } else { diff --git a/qrinput.c b/qrinput.c index 0908bbfe38..6e54c9b7c6 100644 --- a/qrinput.c +++ b/qrinput.c @@ -1438,10 +1438,10 @@ static int QRinput_List_shrinkEntry(QRinput_List *entry, int bytes) { unsigned char *data; - data = (unsigned char *)malloc(bytes); + data = (unsigned char *)malloc((size_t)bytes); if(data == NULL) return -1; - memcpy(data, entry->data, bytes); + memcpy(data, entry->data, (size_t)bytes); free(entry->data); entry->data = data; entry->size = bytes; diff --git a/qrspec.c b/qrspec.c index 6b845a4ca9..f3d3b2c526 100644 --- a/qrspec.c +++ b/qrspec.c @@ -431,10 +431,10 @@ static unsigned char *QRspec_createFrame(int version) unsigned int verinfo, v; width = qrspecCapacity[version].width; - frame = (unsigned char *)malloc(width * width); + frame = (unsigned char *)malloc((size_t)(width * width)); if(frame == NULL) return NULL; - memset(frame, 0, width * width); + memset(frame, 0, (size_t)(width * width)); /* Finder pattern */ putFinderPattern(frame, width, 0, 0); putFinderPattern(frame, width, width - 7, 0); diff --git a/split.c b/split.c index a58450e1ac..3a3b4c452e 100644 --- a/split.c +++ b/split.c @@ -55,7 +55,7 @@ static QRencodeMode Split_identifyMode(const char *string, QRencodeMode hint) unsigned char c, d; unsigned int word; - c = string[0]; + c = (unsigned char)string[0]; if(c == '\0') return QR_MODE_NUL; if(isdigit(c)) { @@ -63,7 +63,7 @@ static QRencodeMode Split_identifyMode(const char *string, QRencodeMode hint) } else if(isalnum(c)) { return QR_MODE_AN; } else if(hint == QR_MODE_KANJI) { - d = string[1]; + d = (unsigned char)string[1]; if(d != '\0') { word = ((unsigned int)c << 8) | d; if((word >= 0x8140 && word <= 0x9ffc) || (word >= 0xe040 && word <= 0xebbf)) { -- cgit 0.0.5-2-1-g0f52 From f40312672b2211b38cfade1a93fd24d66a6ce274 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 Oct 2017 13:36:54 +0900 Subject: Fixed some warnings. (closing #89 and #102) --- split.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/split.c b/split.c index 3a3b4c452e..1361066b63 100644 --- a/split.c +++ b/split.c @@ -93,7 +93,7 @@ static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint) while(isdigit(*p)) { p++; } - run = p - string; + run = (int)(p - string); mode = Split_identifyMode(p, hint); if(mode == QR_MODE_8) { dif = QRinput_estimateBitsModeNum(run) + 4 + ln @@ -136,10 +136,10 @@ static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint) while(isdigit(*q)) { q++; } - dif = QRinput_estimateBitsModeAn(p - string) /* + 4 + la */ - + QRinput_estimateBitsModeNum(q - p) + 4 + ln + dif = QRinput_estimateBitsModeAn((int)(p - string)) /* + 4 + la */ + + QRinput_estimateBitsModeNum((int)(q - p)) + 4 + ln + (isalnum(*q)?(4 + ln):0) - - QRinput_estimateBitsModeAn(q - string) /* - 4 - la */; + - QRinput_estimateBitsModeAn((int)(q - string)) /* - 4 - la */; if(dif < 0) { break; } @@ -149,7 +149,7 @@ static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint) } } - run = p - string; + run = (int)(p - string); if(*p && !isalnum(*p)) { dif = QRinput_estimateBitsModeAn(run) + 4 + la @@ -176,7 +176,7 @@ static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint) while(Split_identifyMode(p, hint) == QR_MODE_KANJI) { p += 2; } - run = p - string; + run = (int)(p - string); ret = QRinput_append(input, QR_MODE_KANJI, run, (unsigned char *)string); if(ret < 0) return -1; @@ -213,10 +213,10 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) } else { swcost = 0; } - dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */ - + QRinput_estimateBitsModeNum(q - p) + 4 + ln + dif = QRinput_estimateBitsMode8((int)(p - string)) /* + 4 + l8 */ + + QRinput_estimateBitsModeNum((int)(q - p)) + 4 + ln + swcost - - QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */; + - QRinput_estimateBitsMode8((int)(q - string)) /* - 4 - l8 */; if(dif < 0) { break; } @@ -231,10 +231,10 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) } else { swcost = 0; } - dif = QRinput_estimateBitsMode8(p - string) /* + 4 + l8 */ - + QRinput_estimateBitsModeAn(q - p) + 4 + la + dif = QRinput_estimateBitsMode8((int)(p - string)) /* + 4 + l8 */ + + QRinput_estimateBitsModeAn((int)(q - p)) + 4 + la + swcost - - QRinput_estimateBitsMode8(q - string) /* - 4 - l8 */; + - QRinput_estimateBitsMode8((int)(q - string)) /* - 4 - l8 */; if(dif < 0) { break; } @@ -244,7 +244,7 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) } } - run = p - string; + run = (int)(p - string); ret = QRinput_append(input, QR_MODE_8, run, (unsigned char *)string); if(ret < 0) return -1; -- cgit 0.0.5-2-1-g0f52 From 7a43e4d57fb939e46a2b41d2d416f416d1fa904d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 Oct 2017 13:46:30 +0900 Subject: Some variables' type changed from int to unsigned int. --- ChangeLog | 5 +++-- rsecc.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc29ea3248..10536e2a29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,8 +5,9 @@ - test_all.sh activates test_basic.sh + test_configure.sh. - test_basic.sh is better during active development, especially when you gave additional options to configure script. - * split.c, qrspec.c, mqrspec.c, mask.c, mmask.c, qrencode.c, qrinput.c: - - Fixed some warnings. + * split.c, qrspec.c, mqrspec.c, mask.c, mmask.c, qrencode.c, qrinput.c, + rsecc.c: + - Fixed some warnings. (closing #89 and #102) 2017.10.05 Kentaro Fukuchi [4.0] diff --git a/rsecc.c b/rsecc.c index 5f629643ca..c708de6135 100644 --- a/rsecc.c +++ b/rsecc.c @@ -41,8 +41,8 @@ static pthread_mutex_t RSECC_mutex = PTHREAD_MUTEX_INITIALIZER; static int initialized = 0; #define SYMBOL_SIZE (8) -#define symbols ((1 << SYMBOL_SIZE) - 1) -static const int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see pp.37 of JIS X0510:2004) */ +#define symbols ((1U << SYMBOL_SIZE) - 1) +static const unsigned int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see pp.37 of JIS X0510:2004) */ /* min/max codeword length of ECC, calculated from the specification. */ #define min_length (2) @@ -56,7 +56,7 @@ static unsigned char generatorInitialized[max_length - min_length + 1]; static void RSECC_initLookupTable(void) { - int i, b; + unsigned int i, b; alpha[symbols] = 0; aindex[0] = symbols; -- cgit 0.0.5-2-1-g0f52 From c4e3b9c61cc2edbf0b3e0364bc8c11eaf7e7ec2e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 6 Oct 2017 14:01:48 +0900 Subject: Fixed some warnings. (closing #89 and #102) --- ChangeLog | 2 +- qrencode.c | 10 +++++----- qrinput.c | 58 +++++++++++++++++++++++++++++----------------------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 10536e2a29..1a3b603985 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,7 +6,7 @@ - test_basic.sh is better during active development, especially when you gave additional options to configure script. * split.c, qrspec.c, mqrspec.c, mask.c, mmask.c, qrencode.c, qrinput.c, - rsecc.c: + rsecc.c, qrencode.c: - Fixed some warnings. (closing #89 and #102) 2017.10.05 Kentaro Fukuchi diff --git a/qrencode.c b/qrencode.c index d3a2ebf578..5457c6bfb9 100644 --- a/qrencode.c +++ b/qrencode.c @@ -66,7 +66,7 @@ static void RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int e block->eccLength = el; block->ecc = ecc; - RSECC_encode(dl, el, data, ecc); + RSECC_encode((size_t)dl, (size_t)el, data, ecc); } static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsigned char *ecc) @@ -696,7 +696,7 @@ QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level errno = EINVAL; return NULL; } - return QRcode_encodeDataReal((unsigned char *)string, strlen(string), version, level, 0); + return QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), version, level, 0); } QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level) @@ -710,7 +710,7 @@ QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel le errno = EINVAL; return NULL; } - return QRcode_encodeDataReal((unsigned char *)string, strlen(string), version, level, 1); + return QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), version, level, 1); } @@ -868,7 +868,7 @@ QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, errno = EINVAL; return NULL; } - return QRcode_encodeDataStructured(strlen(string), (unsigned char *)string, version, level); + return QRcode_encodeDataStructured((int)strlen(string), (unsigned char *)string, version, level); } QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) @@ -877,7 +877,7 @@ QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRec errno = EINVAL; return NULL; } - return QRcode_encodeDataStructuredReal(strlen(string), (unsigned char *)string, version, level, 0, hint, casesensitive); + return QRcode_encodeDataStructuredReal((int)strlen(string), (unsigned char *)string, version, level, 0, hint, casesensitive); } /****************************************************************************** diff --git a/qrinput.c b/qrinput.c index 6e54c9b7c6..26572ce056 100644 --- a/qrinput.c +++ b/qrinput.c @@ -61,12 +61,12 @@ static QRinput_List *QRinput_List_newEntry(QRencodeMode mode, int size, const un entry->size = size; entry->data = NULL; if(size > 0) { - entry->data = (unsigned char *)malloc(size); + entry->data = (unsigned char *)malloc((size_t)size); if(entry->data == NULL) { free(entry); return NULL; } - memcpy(entry->data, data, size); + memcpy(entry->data, data, (size_t)size); } entry->bstream = NULL; entry->next = NULL; @@ -92,12 +92,12 @@ static QRinput_List *QRinput_List_dup(QRinput_List *entry) n->mode = entry->mode; n->size = entry->size; - n->data = (unsigned char *)malloc(n->size); + n->data = (unsigned char *)malloc((size_t)n->size); if(n->data == NULL) { free(n); return NULL; } - memcpy(n->data, entry->data, entry->size); + memcpy(n->data, entry->data, (size_t)entry->size); n->bstream = NULL; n->next = NULL; @@ -415,16 +415,16 @@ static int QRinput_encodeModeNum(QRinput_List *entry, BitStream *bstream, int ve if(mqr) { if(version > 1) { - ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_NUM); + ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_NUM); if(ret < 0) return -1; } - ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); + ret = BitStream_appendNum(bstream, (size_t)MQRspec_lengthIndicator(QR_MODE_NUM, version), (unsigned int)entry->size); if(ret < 0) return -1; } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_NUM); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), entry->size); + ret = BitStream_appendNum(bstream, (size_t)QRspec_lengthIndicator(QR_MODE_NUM, version), (unsigned int)entry->size); if(ret < 0) return -1; } @@ -524,14 +524,14 @@ static int QRinput_encodeModeAn(QRinput_List *entry, BitStream *bstream, int ver errno = EINVAL; return -1; } - ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_AN); + ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_AN); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_AN, version), entry->size); + ret = BitStream_appendNum(bstream, (size_t)MQRspec_lengthIndicator(QR_MODE_AN, version), (unsigned int)entry->size); if(ret < 0) return -1; } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_AN); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_AN, version), entry->size); + ret = BitStream_appendNum(bstream, (size_t)QRspec_lengthIndicator(QR_MODE_AN, version), (unsigned int)entry->size); if(ret < 0) return -1; } @@ -586,18 +586,18 @@ static int QRinput_encodeMode8(QRinput_List *entry, BitStream *bstream, int vers errno = EINVAL; return -1; } - ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_8); + ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_8); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_8, version), entry->size); + ret = BitStream_appendNum(bstream, (size_t)MQRspec_lengthIndicator(QR_MODE_8, version), (unsigned int)entry->size); if(ret < 0) return -1; } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_8); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_8, version), entry->size); + ret = BitStream_appendNum(bstream, (size_t)QRspec_lengthIndicator(QR_MODE_8, version), (unsigned int)entry->size); if(ret < 0) return -1; } - ret = BitStream_appendBytes(bstream, entry->size, entry->data); + ret = BitStream_appendBytes(bstream, (size_t)entry->size, entry->data); if(ret < 0) return -1; return 0; @@ -662,14 +662,14 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int errno = EINVAL; return -1; } - ret = BitStream_appendNum(bstream, version - 1, MQRSPEC_MODEID_KANJI); + ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_KANJI); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, MQRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); + ret = BitStream_appendNum(bstream, (size_t)MQRspec_lengthIndicator(QR_MODE_KANJI, version), (unsigned int)entry->size/2); if(ret < 0) return -1; } else { ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_KANJI); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2); + ret = BitStream_appendNum(bstream, (size_t)QRspec_lengthIndicator(QR_MODE_KANJI, version), (unsigned int)entry->size/2); if(ret < 0) return -1; } @@ -806,7 +806,7 @@ static int QRinput_encodeModeECI(QRinput_List *entry, BitStream *bstream) ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_ECI); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, words * 8, code); + ret = BitStream_appendNum(bstream, (size_t)words * 8, code); if(ret < 0) return -1; return 0; @@ -1009,7 +1009,7 @@ static int QRinput_encodeBitStream(QRinput_List *entry, BitStream *bstream, int QRinput_List *st1 = NULL, *st2 = NULL; int prevsize; - prevsize = BitStream_size(bstream); + prevsize = (int)BitStream_size(bstream); words = QRspec_maximumWords(entry->mode, version); if(words != 0 && entry->size > words) { @@ -1055,7 +1055,7 @@ static int QRinput_encodeBitStream(QRinput_List *entry, BitStream *bstream, int if(ret < 0) return -1; } - return BitStream_size(bstream) - prevsize; + return (int)BitStream_size(bstream) - prevsize; ABORT: QRinput_List_freeEntry(st1); QRinput_List_freeEntry(st2); @@ -1138,7 +1138,7 @@ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) int bits, maxbits, words, maxwords, i, ret; int padlen; - bits = BitStream_size(bstream); + bits = (int)BitStream_size(bstream); maxwords = QRspec_getDataLength(input->version, input->level); maxbits = maxwords * 8; @@ -1151,18 +1151,18 @@ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) } if(maxbits - bits <= 4) { - return BitStream_appendNum(bstream, maxbits - bits, 0); + return (int)BitStream_appendNum(bstream, (size_t)(maxbits - bits), 0); } words = (bits + 4 + 7) / 8; - ret = BitStream_appendNum(bstream, words * 8 - bits, 0); + ret = (int)BitStream_appendNum(bstream, (size_t)(words * 8 - bits), 0); if(ret < 0) return ret; padlen = maxwords - words; if(padlen > 0) { for(i = 0; i < padlen; i++) { - ret = BitStream_appendNum(bstream, 8, (i&1)?0x11:0xec); + ret = (int)BitStream_appendNum(bstream, 8, (i&1)?0x11:0xec); if(ret < 0) { return ret; } @@ -1187,7 +1187,7 @@ static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) int bits, maxbits, words, maxwords, i, ret, termbits; int padlen; - bits = BitStream_size(bstream); + bits = (int)BitStream_size(bstream); maxbits = MQRspec_getDataLengthBit(input->version, input->level); maxwords = maxbits / 8; @@ -1202,7 +1202,7 @@ static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) termbits = input->version * 2 + 1; if(maxbits - bits <= termbits) { - return BitStream_appendNum(bstream, maxbits - bits, 0); + return (int)BitStream_appendNum(bstream, (size_t)(maxbits - bits), 0); } bits += termbits; @@ -1214,18 +1214,18 @@ static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input) } else { termbits += words * 8 - bits; } - ret = BitStream_appendNum(bstream, termbits, 0); + ret = (int)BitStream_appendNum(bstream, (size_t)termbits, 0); if(ret < 0) return ret; padlen = maxwords - words; if(padlen > 0) { for(i = 0; i < padlen; i++) { - ret = BitStream_appendNum(bstream, 8, (i&1)?0x11:0xec); + ret = (int)BitStream_appendNum(bstream, 8, (i&1)?0x11:0xec); if(ret < 0) return ret; } termbits = maxbits - maxwords * 8; if(termbits > 0) { - ret = BitStream_appendNum(bstream, termbits, 0); + ret = (int)BitStream_appendNum(bstream, (size_t)termbits, 0); if(ret < 0) return ret; } } -- cgit 0.0.5-2-1-g0f52 From 064940386fd0e1f337f4f20bae8db1c8333c1c47 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 8 Oct 2017 02:17:28 +0900 Subject: Fixed some warnings. (closing #89 and #102) --- ChangeLog | 5 +++++ qrenc.c | 42 +++++++++++++++++++++--------------------- qrinput.c | 16 ++++++++-------- rsecc.c | 4 ++-- tests/common.c | 2 +- tests/decoder.c | 26 +++++++++++++------------- 6 files changed, 50 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a3b603985..3046109f46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017.10.08 Kentaro Fukuchi + [master] + * qrenc.c, qrinput.c, rsecc.c, tests/common.c, tests/decoder.c: + - Fixed some warnings. (closing #89 and #102) + 2017.10.06 Kentaro Fukuchi [master] * tests/test_{all,basic}.sh: diff --git a/qrenc.c b/qrenc.c index 0a0453766c..ed83d8abbb 100644 --- a/qrenc.c +++ b/qrenc.c @@ -293,9 +293,9 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty realwidth = (qrcode->width + margin * 2) * size; if(type == PNG_TYPE) { - row = (unsigned char *)malloc((realwidth + 7) / 8); + row = (unsigned char *)malloc((size_t)((realwidth + 7) / 8)); } else if(type == PNG32_TYPE) { - row = (unsigned char *)malloc(realwidth * 4); + row = (unsigned char *)malloc((size_t)realwidth * 4); } else { fprintf(stderr, "Internal error.\n"); exit(EXIT_FAILURE); @@ -355,7 +355,7 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty png_init_io(png_ptr, fp); if(type == PNG_TYPE) { png_set_IHDR(png_ptr, info_ptr, - realwidth, realwidth, + (unsigned int)realwidth, (unsigned int)realwidth, 1, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, @@ -363,7 +363,7 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty PNG_FILTER_TYPE_DEFAULT); } else { png_set_IHDR(png_ptr, info_ptr, - realwidth, realwidth, + (unsigned int)realwidth, (unsigned int)realwidth, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, @@ -378,7 +378,7 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty if(type == PNG_TYPE) { /* top margin */ - memset(row, 0xff, (realwidth + 7) / 8); + memset(row, 0xff, (size_t)((realwidth + 7) / 8)); for(y = 0; y < margin * size; y++) { png_write_row(png_ptr, row); } @@ -386,7 +386,7 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty /* data */ p = qrcode->data; for(y = 0; y < qrcode->width; y++) { - memset(row, 0xff, (realwidth + 7) / 8); + memset(row, 0xff, (size_t)((realwidth + 7) / 8)); q = row; q += margin * size / 8; bit = 7 - (margin * size % 8); @@ -406,7 +406,7 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty } } /* bottom margin */ - memset(row, 0xff, (realwidth + 7) / 8); + memset(row, 0xff, (size_t)((realwidth + 7) / 8)); for(y = 0; y < margin * size; y++) { png_write_row(png_ptr, row); } @@ -655,7 +655,7 @@ static int writeXPM(const QRcode *qrcode, const char *outfile) realwidth = (qrcode->width + margin * 2) * size; realmargin = margin * size; - row = malloc(realwidth + 1); + row = malloc((size_t)realwidth + 1); if (!row ) { fprintf(stderr, "Failed to allocate memory.\n"); exit(EXIT_FAILURE); @@ -674,7 +674,7 @@ static int writeXPM(const QRcode *qrcode, const char *outfile) fprintf(fp, "\"B c #%s\",\n", bg); fputs("/* pixels */\n", fp); - memset(row, 'B', realwidth); + memset(row, 'B', (size_t)realwidth); row[realwidth] = '\0'; for (y = 0; y < realmargin; y++) { @@ -727,8 +727,8 @@ static void writeANSI_margin(FILE* fp, int realwidth, { int y; - strncpy(buffer, white, white_s); - memset(buffer + white_s, ' ', realwidth * 2); + strncpy(buffer, white, (size_t)white_s); + memset(buffer + white_s, ' ', (size_t)realwidth * 2); strcpy(buffer + white_s + realwidth * 2, "\033[0m\n"); // reset to default colors for(y = 0; y < margin; y++ ){ fputs(buffer, fp); @@ -766,7 +766,7 @@ static int writeANSI(const QRcode *qrcode, const char *outfile) realwidth = (qrcode->width + margin * 2) * size; buffer_s = (realwidth * white_s) * 2; - buffer = (char *)malloc(buffer_s); + buffer = (char *)malloc((size_t)buffer_s); if(buffer == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); exit(EXIT_FAILURE); @@ -780,8 +780,8 @@ static int writeANSI(const QRcode *qrcode, const char *outfile) for(y = 0; y < qrcode->width; y++) { row = (p+(y*qrcode->width)); - memset(buffer, 0, buffer_s); - strncpy(buffer, white, white_s); + memset(buffer, 0, (size_t)buffer_s); + strncpy(buffer, white, (size_t)white_s); for(x = 0; x < margin; x++ ){ strncat(buffer, " ", 2); } @@ -790,18 +790,18 @@ static int writeANSI(const QRcode *qrcode, const char *outfile) for(x = 0; x < qrcode->width; x++) { if(*(row+x)&0x1) { if( last != 1 ){ - strncat(buffer, black, black_s); + strncat(buffer, black, (size_t)black_s); last = 1; } } else if( last != 0 ){ - strncat(buffer, white, white_s); + strncat(buffer, white, (size_t)white_s); last = 0; } strncat(buffer, " ", 2); } if( last != 0 ){ - strncat(buffer, white, white_s); + strncat(buffer, white, (size_t)white_s); } for(x = 0; x < margin; x++ ){ strncat(buffer, " ", 2); @@ -920,7 +920,7 @@ static void writeASCII_margin(FILE* fp, int realwidth, char* buffer, int invert) h = margin; - memset(buffer, (invert?'#':' '), realwidth); + memset(buffer, (invert?'#':' '), (size_t)realwidth); buffer[realwidth] = '\n'; buffer[realwidth + 1] = '\0'; for(y = 0; y < h; y++ ){ @@ -950,7 +950,7 @@ static int writeASCII(const QRcode *qrcode, const char *outfile, int invert) realwidth = (qrcode->width + margin * 2) * 2; buffer_s = realwidth + 2; - buffer = (char *)malloc( buffer_s ); + buffer = (char *)malloc((size_t)buffer_s); if(buffer == NULL) { fprintf(stderr, "Failed to allocate memory.\n"); exit(EXIT_FAILURE); @@ -964,7 +964,7 @@ static int writeASCII(const QRcode *qrcode, const char *outfile, int invert) row = qrcode->data+(y*qrcode->width); p = buffer; - memset(p, white, margin * 2); + memset(p, white, (size_t)margin * 2); p += margin * 2; for(x = 0; x < qrcode->width; x++) { @@ -977,7 +977,7 @@ static int writeASCII(const QRcode *qrcode, const char *outfile, int invert) } } - memset(p, white, margin * 2); + memset(p, white, (size_t)margin * 2); p += margin * 2; *p++ = '\n'; *p++ = '\0'; diff --git a/qrinput.c b/qrinput.c index 26572ce056..f6a3a3cdd7 100644 --- a/qrinput.c +++ b/qrinput.c @@ -430,21 +430,21 @@ static int QRinput_encodeModeNum(QRinput_List *entry, BitStream *bstream, int ve words = entry->size / 3; for(i = 0; i < words; i++) { - val = (entry->data[i*3 ] - '0') * 100; - val += (entry->data[i*3+1] - '0') * 10; - val += (entry->data[i*3+2] - '0'); + val = (unsigned int)(entry->data[i*3 ] - '0') * 100; + val += (unsigned int)(entry->data[i*3+1] - '0') * 10; + val += (unsigned int)(entry->data[i*3+2] - '0'); ret = BitStream_appendNum(bstream, 10, val); if(ret < 0) return -1; } if(entry->size - words * 3 == 1) { - val = entry->data[words*3] - '0'; + val = (unsigned int)(entry->data[words*3] - '0'); ret = BitStream_appendNum(bstream, 4, val); if(ret < 0) return -1; } else if(entry->size - words * 3 == 2) { - val = (entry->data[words*3 ] - '0') * 10; - val += (entry->data[words*3+1] - '0'); + val = (unsigned int)(entry->data[words*3 ] - '0') * 10; + val += (unsigned int)(entry->data[words*3+1] - '0'); BitStream_appendNum(bstream, 7, val); if(ret < 0) return -1; } @@ -715,9 +715,9 @@ static int QRinput_encodeModeStructure(QRinput_List *entry, BitStream *bstream, ret = BitStream_appendNum(bstream, 4, QRSPEC_MODEID_STRUCTURE); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, 4, entry->data[1] - 1); + ret = BitStream_appendNum(bstream, 4, entry->data[1] - 1U); if(ret < 0) return -1; - ret = BitStream_appendNum(bstream, 4, entry->data[0] - 1); + ret = BitStream_appendNum(bstream, 4, entry->data[0] - 1U); if(ret < 0) return -1; ret = BitStream_appendNum(bstream, 8, entry->data[2]); if(ret < 0) return -1; diff --git a/rsecc.c b/rsecc.c index c708de6135..b88cae3071 100644 --- a/rsecc.c +++ b/rsecc.c @@ -134,12 +134,12 @@ int RSECC_encode(size_t data_length, size_t ecc_length, const unsigned char *dat feedback = aindex[data[i] ^ ecc[0]]; if(feedback != symbols) { for(j = 1; j < ecc_length; j++) { - ecc[j] ^= alpha[(feedback + gen[ecc_length - j]) % symbols]; + ecc[j] ^= alpha[(unsigned int)(feedback + gen[ecc_length - j]) % symbols]; } } memmove(&ecc[0], &ecc[1], ecc_length - 1); if(feedback != symbols) { - ecc[ecc_length - 1] = alpha[(feedback + gen[0]) % symbols]; + ecc[ecc_length - 1] = alpha[(unsigned int)(feedback + gen[0]) % symbols]; } else { ecc[ecc_length - 1] = 0; } diff --git a/tests/common.c b/tests/common.c index 07c36399a8..a5d2079843 100644 --- a/tests/common.c +++ b/tests/common.c @@ -41,7 +41,7 @@ int ncmpBin(char *correct, BitStream *bstream, size_t len) int cmpBin(char *correct, BitStream *bstream) { - int len = 0; + size_t len = 0; char *p; diff --git a/tests/decoder.c b/tests/decoder.c index a07bb7175d..706dc31e40 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -80,7 +80,7 @@ static DataChunk *decodeNum(int *bits_length, unsigned char **bits, int version, return NULL; } - buf = (char *)malloc(size + 1); + buf = (char *)malloc((size_t)size + 1); p = *bits; q = buf; for(i=0; i> 12; + return (int)(v1 >> 12); } int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask) @@ -620,7 +620,7 @@ static BitStream *extractBits(int width, unsigned char *frame, int spec[5]) words = QRspec_rsDataLength(spec); d1 = QRspec_rsDataCodes1(spec); b1 = QRspec_rsBlockNum1(spec); - bits = (unsigned char *)malloc(words * 8); + bits = (unsigned char *)malloc((size_t)words * 8); /* * 00 01 02 03 04 05 06 07 08 09 * 10 11 12 13 14 15 16 17 18 19 @@ -643,7 +643,7 @@ static BitStream *extractBits(int width, unsigned char *frame, int spec[5]) } free(filler); - bstream = BitStream_newWithBits(words * 8, bits); + bstream = BitStream_newWithBits((size_t)words * 8, bits); free(bits); return bstream; @@ -833,14 +833,14 @@ static BitStream *extractBitsMQR(int width, unsigned char *frame, int version, Q int size; size = MQRspec_getDataLengthBit(version, level) + MQRspec_getECCLength(version, level) * 8; - bits = (unsigned char *)malloc(size); + bits = (unsigned char *)malloc((size_t)size); filler = FrameFiller_new(width, frame, 1); for(i=0; i Date: Fri, 13 Oct 2017 02:05:57 +0300 Subject: Fix build on windows with Visual Studio --- qrencode.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qrencode.h b/qrencode.h index 461e8690b8..55279aaf14 100644 --- a/qrencode.h +++ b/qrencode.h @@ -555,7 +555,11 @@ extern char *QRcode_APIVersionString(void); /** * @deprecated */ +#ifndef _MSC_VER extern void QRcode_clearCache(void) __attribute__ ((deprecated)); +#else +extern void QRcode_clearCache(void); +#endif #if defined(__cplusplus) } -- cgit 0.0.5-2-1-g0f52 From 1a0db718b7c22747a7befe6e847fcfc79bceb97d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 13 Oct 2017 12:11:39 +0900 Subject: Merged #108. Thanks to @Ation. --- ChangeLog | 6 ++++++ README.md | 1 + 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3046109f46..58fdd4b6ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017.10.13 Kentaro Fukuchi + [master, 4.0] + * qrencode.h: + - Fix build on windows with Visual Studio. (merged #108) (Thanks to + @Ation) + 2017.10.08 Kentaro Fukuchi [master] * qrenc.c, qrinput.c, rsecc.c, tests/common.c, tests/decoder.c: diff --git a/README.md b/README.md index d8f1eb4a30..a59acfe3ee 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Vilppu Vuorinen (@vilppuvuorinen) - improved CMake support * @vanillahsu - bug fix patch +* @Ation - bug fix patch * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From a50e2db8b0d223383eccf752061c8ae55497961c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 13 Oct 2017 13:12:45 +0900 Subject: Documentation modified. --- ChangeLog | 3 +++ README.md | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 58fdd4b6ed..e3b02c0f29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ * qrencode.h: - Fix build on windows with Visual Studio. (merged #108) (Thanks to @Ation) + [master] + * README.md: + - libqrencode now advertised as a "fast and compact" library. 2017.10.08 Kentaro Fukuchi [master] diff --git a/README.md b/README.md index a59acfe3ee..f3a8b75ae5 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# libqrencode - QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) +# libqrencode - a fast and compact QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) **Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.0. GENERAL INFORMATION =================== -Libqrencode is a library for encoding data in a QR Code symbol, a 2D symbology -that can be scanned by handy terminals such as a mobile phone with CCD. The -capacity of QR Code is up to 7000 digits or 4000 characters and has high -robustness. +Libqrencode is a fast and compact library for encoding data in a QR Code symbol, +a 2D symbology that can be scanned by handy terminals such as a mobile phone +with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters and +has high robustness. Libqrencode accepts a string or a list of data chunks then encodes in a QR Code symbol as a bitmap array. While other QR Code applications generate an image file, using libqrencode allows applications to render QR Code symbols from raw bitmap data directly. This library also contains a command-line utility outputs -a QR Code symbol as a PNG image. +QR Code images in various formats. SPECIFICATION -- cgit 0.0.5-2-1-g0f52 From 22296ecf0c32a402c8c0514ef90b19fd9584c478 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 16 Oct 2017 11:59:23 -0500 Subject: Adds the --inline option, which omits the xml tag for SVG output. --- qrenc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qrenc.c b/qrenc.c index ed83d8abbb..373352ee8c 100644 --- a/qrenc.c +++ b/qrenc.c @@ -45,6 +45,7 @@ static int structured = 0; static int rle = 0; static int svg_path = 0; static int micro = 0; +static int inline_svg = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; static unsigned char fg_color[4] = {0, 0, 0, 255}; @@ -80,6 +81,7 @@ static const struct option options[] = { {"margin" , required_argument, NULL, 'm'}, {"dpi" , required_argument, NULL, 'd'}, {"type" , required_argument, NULL, 't'}, + {"inline" , no_argument , NULL, 'I'}, {"structured" , no_argument , NULL, 'S'}, {"kanji" , no_argument , NULL, 'k'}, {"casesensitive", no_argument , NULL, 'c'}, @@ -95,7 +97,7 @@ static const struct option options[] = { {NULL, 0, NULL, 0} }; -static char *optstring = "ho:r:l:s:v:m:d:t:Skci8MV"; +static char *optstring = "ho:r:l:s:v:m:d:t:ISkci8MV"; static void usage(int help, int longopt, int status) { @@ -132,6 +134,7 @@ static void usage(int help, int longopt, int status) " -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8},\n" " --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" " specify the type of the generated image. (default=PNG)\n\n" +" -I, --inline Only useful for SVG output, generates an svg without the XML tag\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" @@ -551,7 +554,8 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) bg_opacity = (float)bg_color[3] / 255; /* XML declaration */ - fputs( "\n", fp ); + if (!inline_svg) + fputs( "\n", fp ); /* DTD No document type specified because "while a DTD is provided in [the SVG] @@ -1324,6 +1328,9 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } break; + case 'I': + inline_svg = 1; + break; case 'S': structured = 1; break; -- cgit 0.0.5-2-1-g0f52 From 2b9af95c69fc889c8ded0a53194a832b20081f40 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 20 Oct 2017 12:32:20 +0900 Subject: Short option '-I' for '--inline' disabled. --- qrenc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/qrenc.c b/qrenc.c index 373352ee8c..b614e457a2 100644 --- a/qrenc.c +++ b/qrenc.c @@ -81,7 +81,6 @@ static const struct option options[] = { {"margin" , required_argument, NULL, 'm'}, {"dpi" , required_argument, NULL, 'd'}, {"type" , required_argument, NULL, 't'}, - {"inline" , no_argument , NULL, 'I'}, {"structured" , no_argument , NULL, 'S'}, {"kanji" , no_argument , NULL, 'k'}, {"casesensitive", no_argument , NULL, 'c'}, @@ -89,6 +88,7 @@ static const struct option options[] = { {"8bit" , no_argument , NULL, '8'}, {"rle" , no_argument , &rle, 1}, {"svg-path" , no_argument , &svg_path, 1}, + {"inline" , no_argument , &inline_svg, 1}, {"micro" , no_argument , NULL, 'M'}, {"foreground" , required_argument, NULL, 'f'}, {"background" , required_argument, NULL, 'b'}, @@ -97,7 +97,7 @@ static const struct option options[] = { {NULL, 0, NULL, 0} }; -static char *optstring = "ho:r:l:s:v:m:d:t:ISkci8MV"; +static char *optstring = "ho:r:l:s:v:m:d:t:Skci8MV"; static void usage(int help, int longopt, int status) { @@ -134,7 +134,6 @@ static void usage(int help, int longopt, int status) " -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8},\n" " --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" " specify the type of the generated image. (default=PNG)\n\n" -" -I, --inline Only useful for SVG output, generates an svg without the XML tag\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" @@ -146,6 +145,7 @@ static void usage(int help, int longopt, int status) " --rle enable run-length encoding for SVG.\n\n" " --svg-path\n" " use single path to draw modules for SVG.\n\n" +" --inline only useful for SVG output, generates an SVG without the XML tag.\n" " -M, --micro encode in a Micro QR Code. (experimental)\n\n" " --foreground=RRGGBB[AA]\n" " --background=RRGGBB[AA]\n" @@ -1328,9 +1328,6 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } break; - case 'I': - inline_svg = 1; - break; case 'S': structured = 1; break; -- cgit 0.0.5-2-1-g0f52 From 17acddffa5f5dcee1787b4ed2eba0a9446a12f16 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 20 Oct 2017 12:32:29 +0900 Subject: Documentation work. --- ChangeLog | 11 +++++++++++ README.md | 1 + qrencode.1.in | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index e3b02c0f29..07e2ecf86c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2017.10.20 Kentaro Fukuchi + [master] + * qrenc.c: + - Adds the --inline option, which omits the xml tag for SVG output. + (merged #110) (Thanks to @jp-bennett) + - Short option '-I' for '--inline' disabled. + * qrencode.1.in: + - Added some missing descriptions. + * README.md: + - Acknowledgments updated. + 2017.10.13 Kentaro Fukuchi [master, 4.0] * qrencode.h: diff --git a/README.md b/README.md index f3a8b75ae5..c83b69a03a 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - improved CMake support * @vanillahsu - bug fix patch * @Ation - bug fix patch +* Jonathan Bennett - Addedd "--inline" option to qrencode. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, diff --git a/qrencode.1.in b/qrencode.1.in index de92208b06..a9284178f4 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -63,6 +63,15 @@ ignore case distinctions and use only upper-case characters. .B \-8, \-\-8bit encode entire data in 8-bit mode. \-k, \-c and \-i will be ignored. .TP +.B \-\-rle +enable run-length encoding for SVG. +.TP +.B \-\-svg-path +use single path to draw modules for SVG. +.TP +.B \-\-inline +only useful for SVG output, generates an SVG without the XML tag. +.TP .B \-M, \-\-micro encode in a Micro QR Code. (experimental) .TP -- cgit 0.0.5-2-1-g0f52 From 34bba927199f88954fc2528713523488e376f678 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 1 Jun 2018 18:04:43 +0900 Subject: Added some notes of how to use autogen.sh. (closed #122) (Thanks to @thebunnyrules) --- ChangeLog | 6 ++++++ README.md | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07e2ecf86c..1a62bf7742 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018.06.01 Kentaro Fukuchi + [4.0] + * README.md: + - Added some notes of how to use autogen.sh. (closed #122) (Thanks to + @thebunnyrules) + 2017.10.20 Kentaro Fukuchi [master] * qrenc.c: diff --git a/README.md b/README.md index c83b69a03a..a8f9686773 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,22 @@ tests and/or tools if you want not to install programs using SDL or PNG. Compile & install ----------------- -Just try +If there is no "configure" script in the source code directory, run +"autogen.sh" at first to generate it - this is mandatory if you downloaded the +source from GitHub. Some additional software is needed to complete this +process. For example, in Ubuntu, the following packages are needed: + +- autoconf +- automake +- autotools-dev +- libtool +- pkg-config +- libpng12-dev + +You can skip this process if you have "configure" script already (typically +when you downloaded the source tarball from fukuchi.org.) + +Now you are ready to compile the library and tool. Type the following commands: ``` ./configure @@ -55,16 +70,13 @@ sudo ldconfig ``` This compiles and installs the library and header file to the appropriate -directories. By default, /usr/local/lib and /usr/local/include. You can change +directories: by default, /usr/local/lib and /usr/local/include. You can change the destination directory by passing some options to the configure script. Run "./configure --help" to see the list of options. It also installs a command line tool "qrencode" to /usr/local/bin. If you want not to build it, give "--without-tools" option to the configure script. -When you downloaded the source code from github, run "autogen.sh" at first to -generate configure script. - If the configure script does not work well, try to use CMake. ``` @@ -183,5 +195,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno, Jakub Wilk, @KangLin, @c-273 + Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From 201a5e27c41e5befc4a5c0d812737b44a7e247ae Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 2 Jun 2018 21:36:46 +0900 Subject: Added "WITHOUT_PNG" option that builds qrencode without PNG support. (closes #125) --- CMakeLists.txt | 10 +++++++--- ChangeLog | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f08b2cb550..7f9de5398b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(QRencode VERSION 4.0.0 LANGUAGES C) option(WITH_TOOLS "Build utility tools" YES ) option(WITH_TESTS "Build tests" NO ) +option(WITHOUT_PNG "Disable PNG support" NO) option(GPROF "Generate extra code to write profile information" OFF) option(COVERAGE "Generate extra code to write coverage information" OFF) option(ASAN "Use AddressSanitizer" OFF) @@ -123,8 +124,10 @@ install(FILES qrencode.h DESTINATION include) install(TARGETS qrencode DESTINATION lib) ## Build utility tools -if(WITH_TOOLS AND TARGET PNG::PNG) - add_definitions(-DHAVE_PNG=1) +if(WITH_TOOLS) + if(NOT WITHOUT_PNG) + add_definitions(-DHAVE_PNG=1) + endif() add_executable(qrenc qrenc.c) set_target_properties(qrenc PROPERTIES OUTPUT_NAME qrencode) @@ -141,7 +144,7 @@ if(WITH_TESTS) enable_testing() add_definitions(-DWITH_TESTS=) add_subdirectory(tests) -endif(WITH_TESTS) +endif() ## ============================================================================== ## @@ -174,5 +177,6 @@ message(STATUS " .... PNG library ............... = ${PNG_LIBRARIES}" ) message(STATUS " Project configuration:" ) message(STATUS " .. Build test programs ........ = ${WITH_TESTS}" ) message(STATUS " .. Build utility tools ........ = ${WITH_TOOLS}" ) +message(STATUS " .. Disable PNG support ........ = ${WITHOUT_PNG}" ) message(STATUS " .. Installation prefix ......... = ${CMAKE_INSTALL_PREFIX}" ) message(STATUS "------------------------------------------------------------ ") diff --git a/ChangeLog b/ChangeLog index 1a62bf7742..44c63d3f70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,13 @@ +2018.06.02 Kentaro Fukuchi + [4.0] + * CMakeLists.txt: + - Added "WITHOUT_PNG" option that builds qrencode without PNG support. + (closes #125) + 2018.06.01 Kentaro Fukuchi [4.0] * README.md: - - Added some notes of how to use autogen.sh. (closed #122) (Thanks to + - Added some notes of how to use autogen.sh. (closes #122) (Thanks to @thebunnyrules) 2017.10.20 Kentaro Fukuchi -- cgit 0.0.5-2-1-g0f52 From 3dd0cd51cead6c45117c0f067d35390eb9746621 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 3 Jun 2018 00:05:39 +0900 Subject: Cherry-picked 62538e. --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44c63d3f70..50fa1bcc37 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,11 @@ 2018.06.02 Kentaro Fukuchi - [4.0] + [master, 4.0] * CMakeLists.txt: - Added "WITHOUT_PNG" option that builds qrencode without PNG support. (closes #125) 2018.06.01 Kentaro Fukuchi - [4.0] + [master, 4.0] * README.md: - Added some notes of how to use autogen.sh. (closes #122) (Thanks to @thebunnyrules) -- cgit 0.0.5-2-1-g0f52 From fb59fd29fb6461669c47493763ba8f2b88cbff4e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 4 Jun 2018 18:21:53 +0900 Subject: STATIC_IN_RELEASE is now set to "static" when WITH_TESTS is disabled. (closes #126) --- CMakeLists.txt | 4 +++- ChangeLog | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f9de5398b..04e32357fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,6 @@ add_definitions(-DMAJOR_VERSION=${PROJECT_VERSION_MAJOR}) add_definitions(-DMINOR_VERSION=${PROJECT_VERSION_MINOR}) add_definitions(-DMICRO_VERSION=${PROJECT_VERSION_PATCH}) add_definitions(-DVERSION="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -add_definitions(-DSTATIC_IN_RELEASE=) add_definitions(-DHAVE_SDL=0) if(MSVC) @@ -143,7 +142,10 @@ endif() if(WITH_TESTS) enable_testing() add_definitions(-DWITH_TESTS=) + add_definitions(-DSTATIC_IN_RELEASE=) add_subdirectory(tests) +else() + add_definitions(-DSTATIC_IN_RELEASE=static) endif() ## ============================================================================== diff --git a/ChangeLog b/ChangeLog index 50fa1bcc37..a16e551217 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018.06.04 Kentaro Fukuchi + [4.0] + * CMakeLists.txt: + - STATIC_IN_RELEASE is now set to "static" when WITH_TESTS is disabled. + (closes #126) + 2018.06.02 Kentaro Fukuchi [master, 4.0] * CMakeLists.txt: -- cgit 0.0.5-2-1-g0f52 From e1a91d084de4f5266a8984ec25e7f9131e2c5277 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 4 Jun 2018 19:44:31 +0900 Subject: Tabs expanded. --- CMakeLists.txt | 24 ++++++++++++------------ ChangeLog | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04e32357fd..f3aa0b12ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,9 +72,9 @@ if(MSVC) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) if(WITH_TOOLS) - find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include) - find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib) - include_directories(${GETOPT_INCLUDE_DIR}) + find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include) + find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib) + include_directories(${GETOPT_INCLUDE_DIR}) endif(WITH_TOOLS) endif(MSVC) @@ -99,13 +99,13 @@ set(QRENCODE_HDRS qrencode_inner.h mmask.h) if(BUILD_SHARED_LIBS) - if(MSVC) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - endif() - add_library(qrencode SHARED ${QRENCODE_SRCS} ${QRENCODE_HDRS}) - set_target_properties(qrencode PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} SOVERSION ${PROJECT_VERSION_MAJOR}) + if(MSVC) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + endif() + add_library(qrencode SHARED ${QRENCODE_SRCS} ${QRENCODE_HDRS}) + set_target_properties(qrencode PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} SOVERSION ${PROJECT_VERSION_MAJOR}) else() - add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS}) + add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS}) endif() set(prefix "${CMAKE_INSTALL_PREFIX}") @@ -124,9 +124,9 @@ install(TARGETS qrencode DESTINATION lib) ## Build utility tools if(WITH_TOOLS) - if(NOT WITHOUT_PNG) - add_definitions(-DHAVE_PNG=1) - endif() + if(NOT WITHOUT_PNG) + add_definitions(-DHAVE_PNG=1) + endif() add_executable(qrenc qrenc.c) set_target_properties(qrenc PROPERTIES OUTPUT_NAME qrencode) diff --git a/ChangeLog b/ChangeLog index a16e551217..75467263d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ 2018.06.04 Kentaro Fukuchi - [4.0] + [master, 4.0] * CMakeLists.txt: - STATIC_IN_RELEASE is now set to "static" when WITH_TESTS is disabled. (closes #126) + - Tabs expaned. 2018.06.02 Kentaro Fukuchi [master, 4.0] -- cgit 0.0.5-2-1-g0f52 From 7c83deb8f562ae6013fea4c3e65278df93f98fb7 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 4 Jun 2018 20:13:56 +0900 Subject: Bumped version to 4.0.1. --- CMakeLists.txt | 2 +- ChangeLog | 3 +++ NEWS | 9 ++++++++- README.md | 2 +- configure.ac | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3aa0b12ba..4845642be4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1.0) -project(QRencode VERSION 4.0.0 LANGUAGES C) +project(QRencode VERSION 4.0.1 LANGUAGES C) option(WITH_TOOLS "Build utility tools" YES ) option(WITH_TESTS "Build tests" NO ) diff --git a/ChangeLog b/ChangeLog index 75467263d2..7885c5a3a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ - STATIC_IN_RELEASE is now set to "static" when WITH_TESTS is disabled. (closes #126) - Tabs expaned. + [4.0] + * configure.ac, CMakeLists.txt, README.md: + - Bumped version to 4.0.1. 2018.06.02 Kentaro Fukuchi [master, 4.0] diff --git a/NEWS b/NEWS index 0d355a3391..30c9a2b80b 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,15 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.0.0 (2017.9.21) +Version 4.0.1 (2018.6.4) ------------------------ +* CMake support improved. +* New test scripts have been added. +* Some compile time warnings have been fixed. + + +Version 4.0.0 (2017.9.21) +------------------------- * Memory efficiency has been improved. * QRcode_clearCache() has been deprecated. * Error correction code generating functions have been improved. diff --git a/README.md b/README.md index a8f9686773..770963bdfb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # libqrencode - a fast and compact QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) -**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.0. +**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.1. GENERAL INFORMATION =================== diff --git a/configure.ac b/configure.ac index c02ad5eb5b..158883d282 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ m4_define([__MAJOR_VERSION], [4])dnl m4_define([__MINOR_VERSION], [0])dnl -m4_define([__MICRO_VERSION], [0])dnl +m4_define([__MICRO_VERSION], [1])dnl m4_define([__VERSION], [__MAJOR_VERSION.__MINOR_VERSION.__MICRO_VERSION])dnl AC_INIT(QRencode, __VERSION) -- cgit 0.0.5-2-1-g0f52 From 838c2e586385ff8fb7fb578357b39fd681161295 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Tue, 5 Jun 2018 17:37:58 +0200 Subject: tests: Add missing test_basic.sh to EXTRA_DIST Add test_basic.sh to EXTRA_DIST to ensure that it's present in release tarballs. It's missing in 4.0.1 release which breaks test_all.sh. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index bc96fdec4d..b130f93320 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,7 +23,7 @@ if HAVE_LIBPTHREAD noinst_PROGRAMS += pthread_qrencode endif -EXTRA_DIST = test_all.sh test_configure.sh frame URI_testset.inc CMakeLists.txt +EXTRA_DIST = test_all.sh test_basic.sh test_configure.sh frame URI_testset.inc CMakeLists.txt libdecoder_a_SOURCES = decoder.c decoder.h datachunk.c datachunk.h rsecc_decoder.c rsecc_decoder.h -- cgit 0.0.5-2-1-g0f52 From 07805253ab5d115cb2918b4860a559967ab98bed Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Tue, 5 Jun 2018 17:44:45 +0200 Subject: cmake: Use GNUInstallDirs for configurable install directories Use CMake GNUInstallDirs module to provide variables for configurable install directories. This is necessary to install libqrencode on amd64 systems where libraries belong in /usr/lib64 rather than /usr/lib. While at it, make all install directories configurable for user's convenience. --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4845642be4..eb91765d38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,10 +117,11 @@ set(VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION configure_file(qrencode.1.in qrencode.1 @ONLY) configure_file(libqrencode.pc.in libqrencode.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION share/man/man1) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION lib/pkgconfig) -install(FILES qrencode.h DESTINATION include) -install(TARGETS qrencode DESTINATION lib) +include(GNUInstallDirs) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES qrencode.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(TARGETS qrencode DESTINATION ${CMAKE_INSTALL_LIBDIR}) ## Build utility tools if(WITH_TOOLS) @@ -136,7 +137,7 @@ if(WITH_TOOLS) target_link_libraries(qrenc ${GETOPT_LIBRARIES}) endif(MSVC) - install(TARGETS qrenc DESTINATION bin) + install(TARGETS qrenc DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() if(WITH_TESTS) -- cgit 0.0.5-2-1-g0f52 From fa8b13c58bda37e3fdc8402832b2b55802f17170 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Jun 2018 16:20:44 +0900 Subject: Preparing 4.1 branch. --- CMakeLists.txt | 2 +- NEWS | 12 ++++++++++++ README.md | 14 ++++++++------ configure.ac | 4 ++-- qrencode.1.in | 2 +- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb91765d38..38e1226116 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1.0) -project(QRencode VERSION 4.0.1 LANGUAGES C) +project(QRencode VERSION 4.1.0 LANGUAGES C) option(WITH_TOOLS "Build utility tools" YES ) option(WITH_TESTS "Build tests" NO ) diff --git a/NEWS b/NEWS index 30c9a2b80b..5f2185e169 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,18 @@ libqrencode NEWS - Overview of changes ====================================== +Version 4.1.0 (2018.6.x) +------------------------ +* Command line tool "qrencode" has been improved: + * New option "--inline" has been added. (Thanks to @jp-bennett) +* Some compile time warnings have been fixed. + +Release Note: +The internal representation of the output code has been changed slightly - +the second bit from LSB side now represents; 1:ECC bit / 0:data bit. +This is only for debug purpose and does not affect user applications. + + Version 4.0.1 (2018.6.4) ------------------------ * CMake support improved. diff --git a/README.md b/README.md index 770963bdfb..f381f01c9d 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ GENERAL INFORMATION =================== -Libqrencode is a fast and compact library for encoding data in a QR Code symbol, -a 2D symbology that can be scanned by handy terminals such as a mobile phone -with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters and -has high robustness. +Libqrencode is a fast and compact library for encoding data in a QR Code, +a 2D symbology that can be scanned by handy terminals such as a smartphone. +The capacity of QR Code is up to 7000 digits or 4000 characters and has high +robustness. Libqrencode accepts a string or a list of data chunks then encodes in a QR Code symbol as a bitmap array. While other QR Code applications generate an image @@ -91,7 +91,9 @@ configure, or "-DWITH\_TESTS=YES" to cmake. USAGE ===== Basic usages of this library are written in the header file (qrencode.h). -You can generate a manual of the library by using Doxygen. +You can generate a manual of the library by using Doxygen, or see + +https://fukuchi.org/works/qrencode/manual/index.html WARNINGS @@ -108,7 +110,7 @@ application. LICENSING INFORMATION ===================== -Copyright (C) 2006-2017 Kentaro Fukuchi +Copyright (C) 2006-2018 Kentaro Fukuchi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free diff --git a/configure.ac b/configure.ac index 158883d282..9069995e91 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ m4_define([__MAJOR_VERSION], [4])dnl -m4_define([__MINOR_VERSION], [0])dnl -m4_define([__MICRO_VERSION], [1])dnl +m4_define([__MINOR_VERSION], [1])dnl +m4_define([__MICRO_VERSION], [0])dnl m4_define([__VERSION], [__MAJOR_VERSION.__MINOR_VERSION.__MICRO_VERSION])dnl AC_INIT(QRencode, __VERSION) diff --git a/qrencode.1.in b/qrencode.1.in index a9284178f4..08b56a9521 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -122,4 +122,4 @@ Main Web Site: https://fukuchi.org/works/qrencode/ Source code repository: https://github.com/fukuchi/libqrencode/ .SH COPYRIGHT -Copyright (C) 2006-2017 Kentaro Fukuchi. +Copyright (C) 2006-2018 Kentaro Fukuchi. -- cgit 0.0.5-2-1-g0f52 From 5b40b9b7994b4788967449b1089954a5974048a5 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Jun 2018 16:25:25 +0900 Subject: Acknowledgments updated. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f381f01c9d..b879407643 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Robert Petersen (@ripetersen) - added ability to read input data from a file * @Oblomov - improved SVG support patch -* @mgorny - reverse mappings of UTF8 and ANSIUTF8 +* @mgorny - reverse mappings of UTF8 and ANSIUTF8, build script + fixes * @EckoEdc - MinGW support patch * Sebastian Buchwald (@UniQP) - Various code cleanups -- cgit 0.0.5-2-1-g0f52 From bdf581426b25d9577cb3d875156ae6ce39f4166c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Jun 2018 16:31:42 +0900 Subject: Merged #127 and #128. --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7885c5a3a1..3a5bc705f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2018.06.06 Kentaro Fukuchi + [master] + * tests/Makefile.am: + - Add missing test_basic.sh to EXTRA_DIST. (merged #127) (Thanks to + @mgorny) + * CMakeLists.txt: + - Use CMake GNUInstallDirs module to provide variables for configurable + install directories. (merged #128) (Thanks to @mgorny) + 2018.06.04 Kentaro Fukuchi [master, 4.0] * CMakeLists.txt: -- cgit 0.0.5-2-1-g0f52 From c89ac1258461dee1f2689a8da4f2dea4f44fed53 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Jun 2018 16:51:10 +0900 Subject: Cherry-picked 4.0.2 release log manually. --- ChangeLog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3a5bc705f7..e4c1638358 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,14 @@ 2018.06.06 Kentaro Fukuchi - [master] + [master, 4.0] * tests/Makefile.am: - Add missing test_basic.sh to EXTRA_DIST. (merged #127) (Thanks to @mgorny) * CMakeLists.txt: - Use CMake GNUInstallDirs module to provide variables for configurable install directories. (merged #128) (Thanks to @mgorny) + [4.0] + * configure.ac, CMakeLists.txt, README.md: + - Bumped version to 4.0.2. 2018.06.04 Kentaro Fukuchi [master, 4.0] -- cgit 0.0.5-2-1-g0f52 From 860b8fecc56a27c9446ee588f0a2c012eb8167f1 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Tue, 5 Jun 2018 18:08:45 +0200 Subject: Fix running test_qrspec when building out-of-source It is a common practice for CMake builds (and less common but still valid for autotools) to build out-of-source, that is use a separate directory for built executables than for sources. However, when that is used, test_qrspec is unable to find "frame" and crashes. Fix it by passing the source directory as compile-time definition, and therefore making test_qrspec use the correct path. --- tests/CMakeLists.txt | 1 + tests/Makefile.am | 1 + tests/test_qrspec.c | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7365762996..13a016f204 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -47,6 +47,7 @@ if(TARGET ICONV::ICONV) MAKE_TEST(test_qrinput decoder) MAKE_TEST(test_qrspec decoder) + target_compile_definitions(test_qrspec PRIVATE -DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}/") MAKE_TEST(test_mqrspec decoder) MAKE_TEST(test_qrencode decoder) MAKE_TEST(test_split_urls decoder) diff --git a/tests/Makefile.am b/tests/Makefile.am index b130f93320..55c5400685 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -37,6 +37,7 @@ test_estimatebit_SOURCES = test_estimatebit.c common.c test_estimatebit_LDADD = ../libqrencode.la test_qrspec_SOURCES = test_qrspec.c common.c +test_qrspec_CPPFLAGS = -DSRCDIR=\"$(srcdir)/\" test_qrspec_LDADD = $(DECODER_LIBS) ../libqrencode.la test_mqrspec_SOURCES = test_mqrspec.c common.c diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index fd4084aca9..7ec2929191 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -5,6 +5,10 @@ #include "../qrencode_inner.h" #include "decoder.h" +#ifndef SRCDIR +# define SRCDIR +#endif + static void print_eccTable(void) { int i, j; @@ -130,9 +134,9 @@ static void test_newframe(void) int version; testStart("Checking newly created frame."); - fp = fopen("frame", "rb"); + fp = fopen(SRCDIR "frame", "rb"); if(fp == NULL) { - perror("Failed to open \"frame\":"); + perror("Failed to open \"" SRCDIR "frame\":"); abort(); } for(i=1; i<=QRSPEC_VERSION_MAX; i++) { -- cgit 0.0.5-2-1-g0f52 From 9a857559cd3a4bd030d56b28d878cdf81cd0825f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Jun 2018 17:00:56 +0900 Subject: Cherry-picked 4.0.2 release news manually. --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 5f2185e169..c7167e4446 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,11 @@ the second bit from LSB side now represents; 1:ECC bit / 0:data bit. This is only for debug purpose and does not affect user applications. +Version 4.0.2 (2018.6.6) +------------------------ +* Build script fixes. (Thanks to @mgorny) + + Version 4.0.1 (2018.6.4) ------------------------ * CMake support improved. -- cgit 0.0.5-2-1-g0f52 From 6e18eb2c81067c769a5efb9fa76b605699bf5192 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Jun 2018 17:01:26 +0900 Subject: Merged #129. --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index e4c1638358..2233768b45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,10 @@ [4.0] * configure.ac, CMakeLists.txt, README.md: - Bumped version to 4.0.2. + [master] + * tests/{Makefile.am, CMakeLists.txt, test_qrspec.c}: + - Fix running test_qrspec when building out-of-source. (merged #129) + (Thanks to @mgorny) 2018.06.04 Kentaro Fukuchi [master, 4.0] -- cgit 0.0.5-2-1-g0f52 From 6b344a1ec5604b158519e041b6e2b63c30b0bb31 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Wed, 6 Jun 2018 17:05:24 +0900 Subject: Some documentation updates. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b879407643..d07d9da8a1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # libqrencode - a fast and compact QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) -**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.1. +**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.2. GENERAL INFORMATION =================== @@ -178,7 +178,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Robert Petersen (@ripetersen) - added ability to read input data from a file * @Oblomov - improved SVG support patch -* @mgorny - reverse mappings of UTF8 and ANSIUTF8, build script +* Michał Górny (@mgorny) + - reverse mappings of UTF8 and ANSIUTF8, build script fixes * @EckoEdc - MinGW support patch * Sebastian Buchwald (@UniQP) -- cgit 0.0.5-2-1-g0f52 From 73e9c83b4c9b77deac2df0d22a3f4d41b76350b6 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 7 Jun 2018 07:54:03 +0200 Subject: cmake: Update paths in generated pkg-config file Update paths inside the pkg-config file to respect GNUInstallDirs. Fixes: 07805253ab5d115cb2918b4860a559967ab98bed --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38e1226116..071efd1179 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,16 +108,16 @@ else() add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS}) endif() +include(GNUInstallDirs) set(prefix "${CMAKE_INSTALL_PREFIX}") -set(exec_prefix "${CMAKE_INSTALL_PREFIX}/bin") -set(libdir "${CMAKE_INSTALL_PREFIX}/lib") -set(includedir "${CMAKE_INSTALL_PREFIX}/include") +set(exec_prefix "${CMAKE_INSTALL_FULL_BINDIR}") +set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") +set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") set(VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") configure_file(qrencode.1.in qrencode.1 @ONLY) configure_file(libqrencode.pc.in libqrencode.pc @ONLY) -include(GNUInstallDirs) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(FILES qrencode.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -- cgit 0.0.5-2-1-g0f52 From 8cfd42d7973201204ce206b2fe00037df8cd353a Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 7 Jun 2018 08:05:25 +0200 Subject: cmake: Support pthread in the main library Improve pthread support for the main library when building via CMake. Explicitly request pthread when multiple threading options are available since the code is using pthread directly. Set HAVE_LIBPTHREAD to trigger the code, link the library and list it in pkg-config file. --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 071efd1179..5e1fa97bd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,10 +17,17 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +set(CMAKE_THREAD_PREFER_PTHREAD ON) find_package(Threads) find_package(PNG) find_package(Iconv) +if(CMAKE_USE_PTHREADS_INIT) + add_definitions(-DHAVE_LIBPTHREAD=1) + # for libqrencode.pc + set(LIBPTHREAD ${CMAKE_THREAD_LIBS_INIT}) +endif() + ## Check for system include files include(CheckIncludeFile) include(CheckFunctionExists) @@ -107,6 +114,9 @@ if(BUILD_SHARED_LIBS) else() add_library(qrencode ${QRENCODE_SRCS} ${QRENCODE_HDRS}) endif() +if(CMAKE_USE_PTHREADS_INIT) + target_link_libraries(qrencode Threads::Threads) +endif() include(GNUInstallDirs) set(prefix "${CMAKE_INSTALL_PREFIX}") -- cgit 0.0.5-2-1-g0f52 From 3a6954e0ff337131330e011b4e772009909d8181 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 7 Jun 2018 08:09:07 +0200 Subject: cmake: Always build libdecoder as static library libdecoder is used only for tests, and implicitly relies on printBinary() function that is not included in the library. This causes it to fail to build as a shared library on systems strict about symbols (Darwin or e.g. Linux with -Wl,-z,defs). Force static library to avoid those problems. --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 13a016f204..4234ea8c86 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,7 +39,7 @@ MAKE_TEST(test_estimatebit) MAKE_TEST(test_split) if(TARGET ICONV::ICONV) - add_library(decoder + add_library(decoder STATIC decoder.c decoder.h datachunk.c datachunk.h rsecc_decoder.c rsecc_decoder.h) -- cgit 0.0.5-2-1-g0f52 From b0920af93e05fd5f944d2c977eaca7c271b3e282 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 7 Jun 2018 16:22:24 +0900 Subject: Merged #131. (Thanks to @mgorny) --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2233768b45..015bede057 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2018.06.07 Kentaro Fukuchi + [master] + * CMakeLists.txt, tests/CMakeLists.txt: + - Merged #131 (Thanks to @mgorny): + - Update paths inside the pkg-config file to respect GNUInstallDirs. + - Improve pthread support for the main library when building via CMake. + - Always build libdecoder as static library. + 2018.06.06 Kentaro Fukuchi [master, 4.0] * tests/Makefile.am: -- cgit 0.0.5-2-1-g0f52 From 6eae956f3740d17596eb7e172796dbd801c0e03a Mon Sep 17 00:00:00 2001 From: András Veres-Szentkirályi Date: Tue, 12 Jun 2018 17:05:13 +0200 Subject: added ANSI256UTF8 format ANSI256 uses full blocks (1 pixel -> 2 characters), while ANSIUTF8 uses 3/4 bit color codes, and qrencode missed a combination of the two, which - uses UTF-8 half blocks (2 pixel -> 1 character) and - uses 8 bit color codes. --- qrenc.c | 21 +++++++++++++++++---- qrencode.1.in | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/qrenc.c b/qrenc.c index b614e457a2..4ae6cce737 100644 --- a/qrenc.c +++ b/qrenc.c @@ -65,6 +65,7 @@ enum imageType { ASCIIi_TYPE, UTF8_TYPE, ANSIUTF8_TYPE, + ANSI256UTF8_TYPE, UTF8i_TYPE, ANSIUTF8i_TYPE }; @@ -131,8 +132,8 @@ static void usage(int help, int longopt, int status) " specify the width of the margins. (default=4 (2 for Micro QR)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8},\n" -" --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" +" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8},\n" +" --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified.\n\n" @@ -185,7 +186,7 @@ static void usage(int help, int longopt, int status) " -v NUMBER specify the minimum version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n" +" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}\n" " specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version must be specified.\n" " -k assume that the input text contains kanji (shift-jis).\n" @@ -863,7 +864,11 @@ static int writeUTF8(const QRcode *qrcode, const char *outfile, int use_ansi, in } if (use_ansi){ - white = "\033[40;37;1m"; + if (use_ansi == 2) { + white = "\033[38;5;231m\033[48;5;16m"; + } else { + white = "\033[40;37;1m"; + } reset = "\033[0m"; } else { white = ""; @@ -1064,6 +1069,9 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil case ANSIUTF8_TYPE: writeUTF8(qrcode, outfile, 1, 0); break; + case ANSI256UTF8_TYPE: + writeUTF8(qrcode, outfile, 2, 0); + break; case UTF8i_TYPE: writeUTF8(qrcode, outfile, 0, 1); break; @@ -1200,6 +1208,9 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case ANSIUTF8_TYPE: writeUTF8(p->code, filename, 0, 0); break; + case ANSI256UTF8_TYPE: + writeUTF8(p->code, filename, 0, 0); + break; case UTF8i_TYPE: writeUTF8(p->code, filename, 0, 1); break; @@ -1319,6 +1330,8 @@ int main(int argc, char **argv) image_type = UTF8_TYPE; } else if(strcasecmp(optarg, "ansiutf8") == 0) { image_type = ANSIUTF8_TYPE; + } else if(strcasecmp(optarg, "ansi256utf8") == 0) { + image_type = ANSI256UTF8_TYPE; } else if(strcasecmp(optarg, "utf8i") == 0) { image_type = UTF8i_TYPE; } else if(strcasecmp(optarg, "ansiutf8i") == 0) { diff --git a/qrencode.1.in b/qrencode.1.in index 08b56a9521..bbd02769dd 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -42,10 +42,10 @@ specify the width of margin. (default=4) specify the DPI of the generated PNG. (default=72) .TP .PD 0 -.B \-t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.B \-t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8} .TP .PD -.B \-\-type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8} +.B \-\-type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8} specify the type of the generated image. (default=PNG) .TP .B \-S, \-\-structured -- cgit 0.0.5-2-1-g0f52 From ccbcb77bd7e4107e51b37a82a5340409cbd85940 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Thu, 14 Jun 2018 18:29:56 +0900 Subject: UTF8 mode now supports ANSI256 color. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to András Veres-Szentkirályi. --- ChangeLog | 6 ++++++ NEWS | 2 ++ README.md | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 015bede057..450727a793 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018.06.14 Kentaro Fukuchi + [master] + * qrenc.c, qrencode.1.in, README.md, NEWS: + - UTF8 mode now supports ANSI256 color. (Thanks to András Veres- + Szentkirályi) + 2018.06.07 Kentaro Fukuchi [master] * CMakeLists.txt, tests/CMakeLists.txt: diff --git a/NEWS b/NEWS index c7167e4446..58c6121210 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ Version 4.1.0 (2018.6.x) ------------------------ * Command line tool "qrencode" has been improved: * New option "--inline" has been added. (Thanks to @jp-bennett) + * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- + Szentkirályi) * Some compile time warnings have been fixed. Release Note: diff --git a/README.md b/README.md index d07d9da8a1..c58a5507d8 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,9 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - improved CMake support * @vanillahsu - bug fix patch * @Ation - bug fix patch -* Jonathan Bennett - Addedd "--inline" option to qrencode. +* Jonathan Bennett - Addedd "--inline" option to qrencode +* András Veres-Szentkirályi + - ANSI256UTF8 support * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 439496338bb9fcdc2718fb2e6c85771db52fc861 Mon Sep 17 00:00:00 2001 From: sdf5 Date: Fri, 27 Jul 2018 11:51:40 +0200 Subject: Change CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR in CMAKE_MODULE_PATH --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e1fa97bd9..bfc51ac224 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ if(BUILD_TESTING) message(DEPRECATION "use WITH_TESTS option instead BUILD_TESTING") endif() -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_THREAD_PREFER_PTHREAD ON) find_package(Threads) -- cgit 0.0.5-2-1-g0f52 From 953a31e57b982f049e28dec652bdc2daa748d4c2 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 28 Jul 2018 01:00:35 +0900 Subject: Merged #133. (Thanks to @sdf5) --- ChangeLog | 7 +++++++ README.md | 1 + 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 450727a793..0faf09ba56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018.07.28 Kentaro Fukuchi + [master] + * CMakeLists.txt: + - Merged #133 (Thanks to @sdf5) + - Change CMAKE_SORUCE_DIR to CMAKE_CURRENT_SORUCE_DIR in + CMAKE_MODULE_PATH + 2018.06.14 Kentaro Fukuchi [master] * qrenc.c, qrencode.1.in, README.md, NEWS: diff --git a/README.md b/README.md index c58a5507d8..a1938707da 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Jonathan Bennett - Addedd "--inline" option to qrencode * András Veres-Szentkirályi - ANSI256UTF8 support +* @sdf5 - improved CMake support * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 7f4e55a9e54ee851386788484b1f85cf807bbda0 Mon Sep 17 00:00:00 2001 From: Lonnie Abelbeck Date: Wed, 7 Nov 2018 10:07:39 -0600 Subject: configure.ac, png_CFLAGS needs to be quoted Otherwise this error: ./configure: line 13170: test: too many arguments --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9069995e91..bc0e466fbc 100644 --- a/configure.ac +++ b/configure.ac @@ -71,7 +71,7 @@ AC_ARG_WITH([tools], [AS_HELP_STRING([--with-tools], [build utility tools [defau AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ]) if test x$build_tools = xyes && test x$with_png = xyes ; then PKG_CHECK_MODULES(png, "libpng", [AC_DEFINE([HAVE_PNG], [1], [Define to 1 if using libpng is enabled.])], [AC_DEFINE([HAVE_PNG], [0])]) - if test x$png_CFLAGS = x && test x$with_png = xyes ; then + if test "x$png_CFLAGS" = "x" && test x$with_png = xyes ; then echo " !!!!!!!!!! LIBPNG is required to build the utility tools. Temporarily disabled. -- cgit 0.0.5-2-1-g0f52 From 13b159f9d9509b0c9f5ca0df7a144638337ddb15 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 9 Nov 2018 10:26:54 +0900 Subject: Document updates. --- NEWS | 2 ++ README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 58c6121210..13c96e6f2c 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ Version 4.1.0 (2018.6.x) * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- Szentkirályi) * Some compile time warnings have been fixed. +* Various CMake support improvements. (Thanks to @mgorny and @sdf5) +* Some minor bug fixes. (Thank to Lonnie Abelbeck) Release Note: The internal representation of the output code has been changed slightly - diff --git a/README.md b/README.md index a1938707da..bfa8596db9 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * András Veres-Szentkirályi - ANSI256UTF8 support * @sdf5 - improved CMake support +* Lonnie Abelbeck (@abelbeck) + - bug fix patch * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 3486d173c7e69292d020bbd9a6164289db837535 Mon Sep 17 00:00:00 2001 From: NancyLi1013 Date: Wed, 12 Feb 2020 01:37:28 -0800 Subject: Add vcpkg installation instructions --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index bfa8596db9..72bc03f124 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,20 @@ make When you want to build the test programs, give "--with-tests" option to configure, or "-DWITH\_TESTS=YES" to cmake. +Building libqrencode -use vcpkg + +You can download and install libqrencode using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: + + ``` + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.sh + ./vcpkg integrate install + vcpkg install libqrencode + ``` + +The libqrencode port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. + USAGE ===== -- cgit 0.0.5-2-1-g0f52 From e5cbbafe5bd2052829176d05f2fac00ca9dbe4b8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 23 Feb 2020 15:12:09 +0900 Subject: Indentation fixes and some updates. --- README.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 72bc03f124..91af53fcef 100644 --- a/README.md +++ b/README.md @@ -87,19 +87,23 @@ make When you want to build the test programs, give "--with-tests" option to configure, or "-DWITH\_TESTS=YES" to cmake. -Building libqrencode -use vcpkg +### Building libqrencode with vcpkg -You can download and install libqrencode using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: +You can download and install libqrencode using the +[vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: - ``` - git clone https://github.com/Microsoft/vcpkg.git - cd vcpkg - ./bootstrap-vcpkg.sh - ./vcpkg integrate install - vcpkg install libqrencode - ``` +``` +git clone https://github.com/Microsoft/vcpkg.git +cd vcpkg +./bootstrap-vcpkg.sh +./vcpkg integrate install +vcpkg install libqrencode +``` -The libqrencode port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. +The libqrencode port in vcpkg is kept up to date by Microsoft team members and +community contributors. If the version is out of date, please +[create an issue or pull request](https://github.com/Microsoft/vcpkg) on the +vcpkg repository. USAGE @@ -218,5 +222,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules + Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013 - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From ba51efc3274bc1f49d7d4807f84a1b9a8964a561 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 7 Jul 2020 17:24:51 -0700 Subject: fix qrencode without libpng Signed-off-by: Rosen Penev --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfc51ac224..bd42280c0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,11 @@ if(WITH_TOOLS) add_executable(qrenc qrenc.c) set_target_properties(qrenc PROPERTIES OUTPUT_NAME qrencode) - target_link_libraries(qrenc qrencode PNG::PNG) + if(NOT WITHOUT_PNG) + target_link_libraries(qrenc qrencode PNG::PNG) + else() + target_link_libraries(qrenc qrencode) + endif() if(MSVC) target_link_libraries(qrenc ${GETOPT_LIBRARIES}) -- cgit 0.0.5-2-1-g0f52 From 58e3a8111d22ab04e85048f98d7e362c2638cc92 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 27 Jul 2020 19:03:07 +0900 Subject: Thanks to @neheb. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 91af53fcef..8ae5e81367 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * @sdf5 - improved CMake support * Lonnie Abelbeck (@abelbeck) - bug fix patch +* Rosen Penev - CMake bug fix patch * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From ff25c8829c7e439be87f6a06905ea67082e81068 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 27 Jul 2020 19:04:10 +0900 Subject: Added github ID to the last commit. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ae5e81367..6ec143f06e 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * @sdf5 - improved CMake support * Lonnie Abelbeck (@abelbeck) - bug fix patch -* Rosen Penev - CMake bug fix patch +* Rosen Penev (@neheb) - CMake bug fix patch * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, -- cgit 0.0.5-2-1-g0f52 From 110884e878546de5c75ace5b6e55c5b5b5371554 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 12:51:54 +0900 Subject: Typo fixes. --- tests/test_qrspec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 7ec2929191..9a3ab65f0e 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -172,7 +172,7 @@ static void test_newframe_invalid(void) #if 0 /* This test is used to check positions of alignment pattern. See Appendix E - * (pp.71) of JIS X0510:2004 and compare to the output. Before comment out + * (p.71) of JIS X0510:2004 and compare to the output. Before comment out * this test, change the value of the pattern marker's center dot from 0xa1 * to 0xb1 (QRspec_putAlignmentMarker() : finder). */ @@ -247,7 +247,7 @@ static void test_verpat(void) } } -/* See Table 22 (pp.45) and Appendix C (pp. 65) of JIS X0510:2004 */ +/* See Table 22 (p.45) and Appendix C (p. 65) of JIS X0510:2004 */ static unsigned int levelIndicator[4] = {1, 0, 3, 2}; static unsigned int calcFormatInfo(int mask, QRecLevel level) { -- cgit 0.0.5-2-1-g0f52 From 1fbb517a1c293c48d5b82a4121e15d56e77d892f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 12:52:03 +0900 Subject: A precise boundary check has been introduced to QRinput_estimateVersion(). (closes #160) --- qrinput.c | 13 +++++-- qrinput.h | 1 + tests/test_qrencode.c | 29 +++++++++++++++ tests/test_qrinput.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+), 3 deletions(-) diff --git a/qrinput.c b/qrinput.c index f6a3a3cdd7..2c7839f1a8 100644 --- a/qrinput.c +++ b/qrinput.c @@ -896,7 +896,11 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version } else { l = QRspec_lengthIndicator(entry->mode, version); m = 1 << l; - num = (entry->size + m - 1) / m; + if(entry->mode == QR_MODE_KANJI) { + num = (entry->size/2 + m - 1) / m; + } else { + num = (entry->size + m - 1) / m; + } bits += num * (MODE_INDICATOR_SIZE + l); } @@ -927,9 +931,9 @@ STATIC_IN_RELEASE int QRinput_estimateBitStreamSize(QRinput *input, int version) /** * Estimate the required version number of the symbol. * @param input input data - * @return required version number + * @return required version number or -1 for failure. */ -static int QRinput_estimateVersion(QRinput *input) +STATIC_IN_RELEASE int QRinput_estimateVersion(QRinput *input) { int bits; int version, prev; @@ -939,6 +943,9 @@ static int QRinput_estimateVersion(QRinput *input) prev = version; bits = QRinput_estimateBitStreamSize(input, prev); version = QRspec_getMinimumVersion((bits + 7) / 8, input->level); + if(prev == 0 && version > 1) { + version--; + } } while (version > prev); return version; diff --git a/qrinput.h b/qrinput.h index b504d0d910..5892c48246 100644 --- a/qrinput.h +++ b/qrinput.h @@ -116,6 +116,7 @@ extern int QRinput_mergeBitStream(QRinput *input, BitStream *bstream); extern int QRinput_getBitStream(QRinput *input, BitStream *bstream); extern int QRinput_estimateBitStreamSize(QRinput *input, int version); extern int QRinput_splitEntry(QRinput_List *entry, int bytes); +extern int QRinput_estimateVersion(QRinput *input); extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); #endif diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 678c4f1100..c11848bdec 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -489,6 +489,34 @@ static void test_encodeLongData(void) testFinish(); } +static void test_encodeVer26Num(void) +{ + char data[3284]; + QRcode *qrcode; + + testStart("Encoding 3283 digits number. (issue #160)"); + + memset(data, '0', 3283); + data[3283] = '\0'; + qrcode = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 0); + assert_nonnull(qrcode, "(QRcode_encodeString) failed to encode 3283 digits number in level L.\n"); + assert_equal(qrcode->version, 26, "version number is %d (26 expected)\n", qrcode->version); + if(qrcode != NULL) { + QRcode_free(qrcode); + } + + QRinput *input; + QRinput_List *list; + + input = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(data, input, QR_MODE_8, 0); + list = input->head; + assert_equal(list->size, 3283, "chunk size is wrong. (%d, 3283 expected)\n", list->size); + QRinput_free(input); + + testFinish(); +} + static void test_01234567(void) { QRinput *stream; @@ -961,6 +989,7 @@ int main(int argc, char **argv) test_encodeNull8(); test_encodeEmpty8(); test_encodeLongData(); + test_encodeVer26Num(); test_01234567(); test_invalid_input(); test_struct_example(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 7f33fb9226..a70f01488d 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -7,6 +7,50 @@ #include "../split.h" #include "decoder.h" +/* taken from the Table 7 of JIS X0510:2018 (pp. 31-34) */ +static int maxCharacterLengths[40][4] = { + { 41, 25, 17, 10}, /* ver 1 */ + { 77, 47, 32, 20}, /* ver 2 */ + { 127, 77, 53, 32}, /* ver 3 */ + { 187, 114, 78, 48}, /* ver 4 */ + { 255, 154, 106, 65}, /* ver 5 */ + { 322, 195, 134, 82}, /* ver 6 */ + { 370, 224, 154, 95}, /* ver 7 */ + { 461, 279, 192, 118}, /* ver 8 */ + { 552, 335, 230, 141}, /* ver 9 */ + { 652, 395, 271, 167}, /* ver 10 */ + { 772, 468, 321, 198}, /* ver 11 */ + { 883, 535, 367, 226}, /* ver 12 */ + {1022, 619, 425, 262}, /* ver 13 */ + {1101, 667, 458, 282}, /* ver 14 */ + {1250, 758, 520, 320}, /* ver 15 */ + {1408, 854, 586, 361}, /* ver 16 */ + {1548, 938, 644, 397}, /* ver 17 */ + {1725, 1046, 718, 442}, /* ver 18 */ + {1903, 1153, 792, 488}, /* ver 19 */ + {2061, 1249, 858, 528}, /* ver 20 */ + {2232, 1352, 929, 572}, /* ver 21 */ + {2409, 1460, 1003, 618}, /* ver 22 */ + {2620, 1588, 1091, 672}, /* ver 23 */ + {2812, 1704, 1171, 721}, /* ver 24 */ + {3057, 1853, 1273, 784}, /* ver 25 */ + {3283, 1990, 1367, 842}, /* ver 26 */ + {3517, 2132, 1465, 902}, /* ver 27 */ + {3669, 2223, 1528, 940}, /* ver 28 */ + {3909, 2369, 1628, 1002}, /* ver 29 */ + {4158, 2520, 1732, 1066}, /* ver 30 */ + {4417, 2677, 1840, 1132}, /* ver 31 */ + {4686, 2840, 1952, 1201}, /* ver 32 */ + {4965, 3009, 2068, 1273}, /* ver 33 */ + {5253, 3183, 2188, 1347}, /* ver 34 */ + {5529, 3351, 2303, 1417}, /* ver 35 */ + {5836, 3537, 2431, 1496}, /* ver 36 */ + {6153, 3729, 2563, 1577}, /* ver 37 */ + {6479, 3927, 2699, 1661}, /* ver 38 */ + {6743, 4087, 2809, 1729}, /* ver 39 */ + {7089, 4296, 2953, 1817} /* ver 40 */ +}; + static int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mode, char *data, char *correct) { QRinput *input; @@ -791,6 +835,59 @@ static void test_null_free(void) testFinish(); } +static void fillCharacter(char *dest, char ch, int size) +{ + memset(dest, ch, size); + dest[size] = '\0'; +} + +static void checkEstimatedVersion(int ver, int mode) +{ + int estimatedVersion; + char data[7200]; + QRinput *input; + QRencodeMode hint; + int size1, size2; + static char *modeStr[4] = {"numeric", "alphanumeric", "8 bit data", "kanji"}; + static char ch[4] = {'0', 'A', 'a', '\x92'}; + + if(mode == QR_MODE_KANJI) { + hint = QR_MODE_KANJI; + size1 = maxCharacterLengths[ver - 1][mode] * 2; + size2 = size1 + 2; + } else { + hint = QR_MODE_8; + size1 = maxCharacterLengths[ver - 1][mode]; + size2 = size1 + 1; + } + + fillCharacter(data, ch[mode], size1); + input = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(data, input, hint, 1); + estimatedVersion = QRinput_estimateVersion(input); + assert_equal(estimatedVersion, ver, "Estimated version %d is not equal to the expected version %d for %d %s sequence.\n", estimatedVersion, ver, maxCharacterLengths[ver - 1][mode], modeStr[mode]); + QRinput_free(input); + + fillCharacter(data, ch[mode], size2); + input = QRinput_new2(0, QR_ECLEVEL_L); + Split_splitStringToQRinput(data, input, hint, 1); + estimatedVersion = QRinput_estimateVersion(input); + assert_equal(estimatedVersion, ver + 1, "Estimated version %d is not equal to the expected version %d for %d %s sequence.\n", estimatedVersion, ver, maxCharacterLengths[ver - 1][mode] + 1, modeStr[mode]); + QRinput_free(input); +} + +static void test_estimateVersionBoundaryCheck(void) +{ + testStart("Boundary check of estimateVersion"); + for(int ver=1; ver < QRSPEC_VERSION_MAX; ver++) { + checkEstimatedVersion(ver, QR_MODE_NUM); + checkEstimatedVersion(ver, QR_MODE_AN); + checkEstimatedVersion(ver, QR_MODE_8); + checkEstimatedVersion(ver, QR_MODE_KANJI); + } + testFinish(); +} + static void test_mqr_new(void) { QRinput *input; @@ -976,6 +1073,7 @@ int main() test_parity(); test_parity2(); test_null_free(); + test_estimateVersionBoundaryCheck(); test_mqr_new(); test_mqr_setversion(); -- cgit 0.0.5-2-1-g0f52 From 8273d891f98a4b5ee9564685cefbd55771220a65 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 13:11:11 +0900 Subject: Some documentation updates. --- NEWS | 10 +++++----- README.md | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 13c96e6f2c..25e0674e16 100644 --- a/NEWS +++ b/NEWS @@ -1,20 +1,20 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.1.0 (2018.6.x) ------------------------- +Version 4.1.0 (2020.8.xx) +------------------------- * Command line tool "qrencode" has been improved: * New option "--inline" has been added. (Thanks to @jp-bennett) * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- Szentkirályi) * Some compile time warnings have been fixed. * Various CMake support improvements. (Thanks to @mgorny and @sdf5) -* Some minor bug fixes. (Thank to Lonnie Abelbeck) +* Some minor bug fixes. (Thank to Lonnie Abelbeck and Frédéric Wang) Release Note: -The internal representation of the output code has been changed slightly - +The internal representation of the output code has been slightly changed - the second bit from LSB side now represents; 1:ECC bit / 0:data bit. -This is only for debug purpose and does not affect user applications. +This change is only for debug purposes and does not affect user applications. Version 4.0.2 (2018.6.6) diff --git a/README.md b/README.md index 6ec143f06e..4ba195adf7 100644 --- a/README.md +++ b/README.md @@ -223,5 +223,6 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm), Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, - Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013 + Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, + Frédéric Wang - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From 9a0f6c6baa4136ecb6f83353759310169d7a6080 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 13:15:41 +0900 Subject: Some documentation improvements. (Thanks to @jidanni) (closes #155) --- NEWS | 3 ++- README.md | 2 +- qrencode.1.in | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 25e0674e16..9eb751464f 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,8 @@ Version 4.1.0 (2020.8.xx) Szentkirályi) * Some compile time warnings have been fixed. * Various CMake support improvements. (Thanks to @mgorny and @sdf5) -* Some minor bug fixes. (Thank to Lonnie Abelbeck and Frédéric Wang) +* Some minor bug fixes. (Thanks to Lonnie Abelbeck and Frédéric Wang) +* Some documentation/manpage improvements. (Thanks to Dan Jacobson) Release Note: The internal representation of the output code has been slightly changed - diff --git a/README.md b/README.md index 4ba195adf7..b073bd01cc 100644 --- a/README.md +++ b/README.md @@ -224,5 +224,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, - Frédéric Wang + Frédéric Wang, Dan Jacobson - bug report / suggestion / typo fixes diff --git a/qrencode.1.in b/qrencode.1.in index bbd02769dd..803c491726 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -3,6 +3,7 @@ qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS .B "qrencode" +[-o FILENAME] [OPTION]... [STRING] -- cgit 0.0.5-2-1-g0f52 From 53b637a1f10407dc7532fef9f8ef920fc722a16c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 13:33:40 +0900 Subject: The manpage and help messages have been improved. (Thanks to @jidanni) --- qrenc.c | 24 ++++++++++++------------ qrencode.1.in | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/qrenc.c b/qrenc.c index 4ae6cce737..3f99fbea67 100644 --- a/qrenc.c +++ b/qrenc.c @@ -109,7 +109,7 @@ static void usage(int help, int longopt, int status) if(help) { if(longopt) { fprintf(out, -"Usage: qrencode [OPTION]... [STRING]\n" +"Usage: qrencode [-o FILENAME] [OPTION]... [STRING]\n" "Encode input data in a QR Code and save as a PNG or EPS image.\n\n" " -h, --help display the help message. -h displays only the help of short\n" " options.\n\n" @@ -136,7 +136,7 @@ static void usage(int help, int longopt, int status) " --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" -" make structured symbols. Version must be specified.\n\n" +" make structured symbols. Version must be specified with '-v'.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" " -c, --casesensitive\n" " encode lower-case alphabet characters in 8-bit mode. (default)\n\n" @@ -146,8 +146,8 @@ static void usage(int help, int longopt, int status) " --rle enable run-length encoding for SVG.\n\n" " --svg-path\n" " use single path to draw modules for SVG.\n\n" -" --inline only useful for SVG output, generates an SVG without the XML tag.\n" -" -M, --micro encode in a Micro QR Code. (experimental)\n\n" +" --inline only useful for SVG output, generates an SVG without the XML tag.\n\n" +" -M encode in a Micro QR Code. Version number must be specified with '-v'.\n\n" " --foreground=RRGGBB[AA]\n" " --background=RRGGBB[AA]\n" " specify foreground/background color in hexadecimal notation.\n" @@ -171,7 +171,7 @@ static void usage(int help, int longopt, int status) ); } else { fprintf(out, -"Usage: qrencode [OPTION]... [STRING]\n" +"Usage: qrencode [-o FILENAME] [OPTION]... [STRING]\n" "Encode input data in a QR Code and save as a PNG or EPS image.\n\n" " -h display this message.\n" " --help display the usage of long options.\n" @@ -188,12 +188,12 @@ static void usage(int help, int longopt, int status) " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" " -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}\n" " specify the type of the generated image. (default=PNG)\n" -" -S make structured symbols. Version must be specified.\n" +" -S make structured symbols. Version number must be specified with '-v'.\n" " -k assume that the input text contains kanji (shift-jis).\n" " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" " -i ignore case distinctions and use only upper-case characters.\n" " -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n" -" -M encode in a Micro QR Code.\n" +" -M encode in a Micro QR Code. Version number must be specified with '-v'.\n" " -V display the version number and copyrights of the qrencode.\n" " [STRING] input data. If it is not specified, data will be taken from\n" " standard input.\n\n" @@ -1399,7 +1399,7 @@ int main(int argc, char **argv) if(intext == NULL) { fp = infile == NULL ? stdin : fopen(infile,"r"); if(fp == 0) { - fprintf(stderr, "Can not read input file %s.\n", infile); + fprintf(stderr, "Cannot read input file %s.\n", infile); exit(EXIT_FAILURE); } intext = readFile(fp,&length); @@ -1407,10 +1407,10 @@ int main(int argc, char **argv) } if(micro && version > MQRSPEC_VERSION_MAX) { - fprintf(stderr, "Version should be less or equal to %d.\n", MQRSPEC_VERSION_MAX); + fprintf(stderr, "Version number should be less or equal to %d.\n", MQRSPEC_VERSION_MAX); exit(EXIT_FAILURE); } else if(!micro && version > QRSPEC_VERSION_MAX) { - fprintf(stderr, "Version should be less or equal to %d.\n", QRSPEC_VERSION_MAX); + fprintf(stderr, "Version number should be less or equal to %d.\n", QRSPEC_VERSION_MAX); exit(EXIT_FAILURE); } @@ -1424,7 +1424,7 @@ int main(int argc, char **argv) if(micro) { if(version == 0) { - fprintf(stderr, "Version must be specified to encode a Micro QR Code symbol.\n"); + fprintf(stderr, "Version number must be specified to encode a Micro QR Code symbol.\n"); exit(EXIT_FAILURE); } if(structured) { @@ -1435,7 +1435,7 @@ int main(int argc, char **argv) if(structured) { if(version == 0) { - fprintf(stderr, "Version must be specified to encode structured symbols.\n"); + fprintf(stderr, "Version number must be specified to encode structured symbols.\n"); exit(EXIT_FAILURE); } qrencodeStructured(intext, length, outfile); diff --git a/qrencode.1.in b/qrencode.1.in index 803c491726..50de17ff56 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -50,7 +50,7 @@ specify the DPI of the generated PNG. (default=72) specify the type of the generated image. (default=PNG) .TP .B \-S, \-\-structured -make structured symbols. Version must be specified. +make structured symbols. Version number must be specified with '-v'. .TP .B \-k, \-\-kanji assume that the input text contains kanji (shift-jis). @@ -74,7 +74,7 @@ use single path to draw modules for SVG. only useful for SVG output, generates an SVG without the XML tag. .TP .B \-M, \-\-micro -encode in a Micro QR Code. (experimental) +encode in a Micro QR Code. Version number must be specified with '-v'. (experimental) .TP .PD 0 .B \-\-foreground=RRGGBB[AA] -- cgit 0.0.5-2-1-g0f52 From 1c38b7f375d631743a6984d4e5b0755a848481fb Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 14:58:21 +0900 Subject: QRinput_encodeMode*() now throws ERANGE for some cases. --- qrinput.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qrinput.c b/qrinput.c index 2c7839f1a8..ad03b6f2ee 100644 --- a/qrinput.c +++ b/qrinput.c @@ -521,7 +521,7 @@ static int QRinput_encodeModeAn(QRinput_List *entry, BitStream *bstream, int ver if(mqr) { if(version < 2) { - errno = EINVAL; + errno = ERANGE; return -1; } ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_AN); @@ -583,7 +583,7 @@ static int QRinput_encodeMode8(QRinput_List *entry, BitStream *bstream, int vers if(mqr) { if(version < 3) { - errno = EINVAL; + errno = ERANGE; return -1; } ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_8); @@ -659,7 +659,7 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int if(mqr) { if(version < 2) { - errno = EINVAL; + errno = ERANGE; return -1; } ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_KANJI); -- cgit 0.0.5-2-1-g0f52 From 9ec127248ac44b6323435b52d3d6411f2a1e3c68 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 16:24:53 +0900 Subject: Now Micro QR Code also allows auto version adjustment. --- qrencode.c | 30 +++++++++++++++++++++++++++--- tests/test_qrencode.c | 12 ++++++------ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/qrencode.c b/qrencode.c index 5457c6bfb9..a6fc9806c5 100644 --- a/qrencode.c +++ b/qrencode.c @@ -653,7 +653,15 @@ QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QR QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) { - return QRcode_encodeStringReal(string, version, level, 1, hint, casesensitive); + if(version == 0) { + version = 1; + } + for(int i=version; i<=MQRSPEC_VERSION_MAX ; i++) { + QRcode *code = QRcode_encodeStringReal(string, i, level, 1, hint, casesensitive); + if(code != NULL) return code; + } + + return NULL; } static QRcode *QRcode_encodeDataReal(const unsigned char *data, int length, int version, QRecLevel level, int mqr) @@ -701,7 +709,15 @@ QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level) { - return QRcode_encodeDataReal(data, size, version, level, 1); + if(version == 0) { + version = 1; + } + for(int i=version; i<=MQRSPEC_VERSION_MAX; i++) { + QRcode *code = QRcode_encodeDataReal(data, size, i, level, 1); + if(code != NULL) return code; + } + + return NULL; } QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level) @@ -710,7 +726,15 @@ QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel le errno = EINVAL; return NULL; } - return QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), version, level, 1); + if(version == 0) { + version = 1; + } + for(int i=version; i<=MQRSPEC_VERSION_MAX; i++) { + QRcode *code = QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), i, level, 1); + if(code != NULL) return code; + } + + return NULL; } diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index c11848bdec..ffed090345 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -683,14 +683,14 @@ static void test_encodeTooLongMQR(void) testStart("Encode too large data for MQR."); code = QRcode_encodeStringMQR(data[0], 1, QR_ECLEVEL_L, QR_MODE_8, 0); - assert_null(code, "6 byte length numeric string was accepted to version 1.\n"); - assert_equal(errno, ERANGE, "errno != ERANGE\n"); + assert_nonnull(code, "6 byte length numeric string should be accepted to version 2 or larger.\n"); + assert_equal(code->version, 2, "6 byte length numeric string should be accepted to version 2.\n"); code = QRcode_encodeStringMQR(data[1], 2, QR_ECLEVEL_L, QR_MODE_8, 0); - assert_null(code, "7 byte length alphanumeric string was accepted to version 2.\n"); - assert_equal(errno, ERANGE, "errno != ERANGE\n"); + assert_nonnull(code, "7 byte length alphanumeric string should be accepted to version 3 or larger.\n"); + assert_equal(code->version, 3, "7 byte length alphanumeric string should be accepted to version 3.\n"); code = QRcode_encodeString8bitMQR(data[2], 3, QR_ECLEVEL_L); - assert_null(code, "9 byte length 8bit string was accepted to version 3.\n"); - assert_equal(errno, ERANGE, "errno != ERANGE\n"); + assert_nonnull(code, "9 byte length 8bit string should be accepted to version 4.\n"); + assert_equal(code->version, 4, "9 byte length 8bit string should be accepted to version 4.\n"); code = QRcode_encodeString8bitMQR(data[3], 4, QR_ECLEVEL_L); assert_null(code, "16 byte length 8bit string was accepted to version 4.\n"); assert_equal(errno, ERANGE, "errno != ERANGE\n"); -- cgit 0.0.5-2-1-g0f52 From d9692de89b6c453d89a58c3798d404ce3cd18105 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 16:27:27 +0900 Subject: Micro QR Code no longer requires to specify the version number. --- qrenc.c | 10 +++------- qrencode.1.in | 11 ++++++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/qrenc.c b/qrenc.c index 3f99fbea67..6ecd4e13d3 100644 --- a/qrenc.c +++ b/qrenc.c @@ -87,10 +87,10 @@ static const struct option options[] = { {"casesensitive", no_argument , NULL, 'c'}, {"ignorecase" , no_argument , NULL, 'i'}, {"8bit" , no_argument , NULL, '8'}, + {"micro" , no_argument , NULL, 'M'}, {"rle" , no_argument , &rle, 1}, {"svg-path" , no_argument , &svg_path, 1}, {"inline" , no_argument , &inline_svg, 1}, - {"micro" , no_argument , NULL, 'M'}, {"foreground" , required_argument, NULL, 'f'}, {"background" , required_argument, NULL, 'b'}, {"version" , no_argument , NULL, 'V'}, @@ -143,11 +143,11 @@ static void usage(int help, int longopt, int status) " -i, --ignorecase\n" " ignore case distinctions and use only upper-case characters.\n\n" " -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n" +" -M, --micro encode in a Micro QR Code.\n\n" " --rle enable run-length encoding for SVG.\n\n" " --svg-path\n" " use single path to draw modules for SVG.\n\n" " --inline only useful for SVG output, generates an SVG without the XML tag.\n\n" -" -M encode in a Micro QR Code. Version number must be specified with '-v'.\n\n" " --foreground=RRGGBB[AA]\n" " --background=RRGGBB[AA]\n" " specify foreground/background color in hexadecimal notation.\n" @@ -193,7 +193,7 @@ static void usage(int help, int longopt, int status) " -c encode lower-case alphabet characters in 8-bit mode. (default)\n" " -i ignore case distinctions and use only upper-case characters.\n" " -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n" -" -M encode in a Micro QR Code. Version number must be specified with '-v'.\n" +" -M encode in a Micro QR Code.\n" " -V display the version number and copyrights of the qrencode.\n" " [STRING] input data. If it is not specified, data will be taken from\n" " standard input.\n\n" @@ -1423,10 +1423,6 @@ int main(int argc, char **argv) } if(micro) { - if(version == 0) { - fprintf(stderr, "Version number must be specified to encode a Micro QR Code symbol.\n"); - exit(EXIT_FAILURE); - } if(structured) { fprintf(stderr, "Micro QR Code does not support structured symbols.\n"); exit(EXIT_FAILURE); diff --git a/qrencode.1.in b/qrencode.1.in index 50de17ff56..41f481c36a 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -64,6 +64,9 @@ ignore case distinctions and use only upper-case characters. .B \-8, \-\-8bit encode entire data in 8-bit mode. \-k, \-c and \-i will be ignored. .TP +.B \-M, \-\-micro +encode in a Micro QR Code. See MICRO QR CODE for more information. +.TP .B \-\-rle enable run-length encoding for SVG. .TP @@ -73,9 +76,6 @@ use single path to draw modules for SVG. .B \-\-inline only useful for SVG output, generates an SVG without the XML tag. .TP -.B \-M, \-\-micro -encode in a Micro QR Code. Version number must be specified with '-v'. (experimental) -.TP .PD 0 .B \-\-foreground=RRGGBB[AA] .TP @@ -101,6 +101,11 @@ ranging from Version 1 (21 x 21 modules) up to Version 40 (177 x 177 modules). Each higher version number comprises 4 additional modules per side by default. See http://www.qrcode.com/en/about/version.html for a detailed version list. +.SH MICRO QR CODE +With Micro QR Code, You can embed data in a smaller area than with QR Code, +but the data capacity is strongly limited. The symbol versions range from +Version 1 to 4. + .SH EXAMPLES .TP .B qrencode \-l L \-v 1 \-o output.png 'Hello, world!' -- cgit 0.0.5-2-1-g0f52 From df6d4a9bbbb8638d3791bf2a25f52eff246c762a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 16:36:12 +0900 Subject: A new option '--strict-version' has been introduced. --- qrenc.c | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/qrenc.c b/qrenc.c index 6ecd4e13d3..20d831e745 100644 --- a/qrenc.c +++ b/qrenc.c @@ -46,6 +46,7 @@ static int rle = 0; static int svg_path = 0; static int micro = 0; static int inline_svg = 0; +static int strict_versioning = 0; static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; static unsigned char fg_color[4] = {0, 0, 0, 255}; @@ -73,28 +74,29 @@ enum imageType { static enum imageType image_type = PNG_TYPE; static const struct option options[] = { - {"help" , no_argument , NULL, 'h'}, - {"output" , required_argument, NULL, 'o'}, - {"read-from" , required_argument, NULL, 'r'}, - {"level" , required_argument, NULL, 'l'}, - {"size" , required_argument, NULL, 's'}, - {"symversion" , required_argument, NULL, 'v'}, - {"margin" , required_argument, NULL, 'm'}, - {"dpi" , required_argument, NULL, 'd'}, - {"type" , required_argument, NULL, 't'}, - {"structured" , no_argument , NULL, 'S'}, - {"kanji" , no_argument , NULL, 'k'}, - {"casesensitive", no_argument , NULL, 'c'}, - {"ignorecase" , no_argument , NULL, 'i'}, - {"8bit" , no_argument , NULL, '8'}, - {"micro" , no_argument , NULL, 'M'}, - {"rle" , no_argument , &rle, 1}, - {"svg-path" , no_argument , &svg_path, 1}, - {"inline" , no_argument , &inline_svg, 1}, - {"foreground" , required_argument, NULL, 'f'}, - {"background" , required_argument, NULL, 'b'}, - {"version" , no_argument , NULL, 'V'}, - {"verbose" , no_argument , &verbose, 1}, + {"help" , no_argument , NULL, 'h'}, + {"output" , required_argument, NULL, 'o'}, + {"read-from" , required_argument, NULL, 'r'}, + {"level" , required_argument, NULL, 'l'}, + {"size" , required_argument, NULL, 's'}, + {"symversion" , required_argument, NULL, 'v'}, + {"margin" , required_argument, NULL, 'm'}, + {"dpi" , required_argument, NULL, 'd'}, + {"type" , required_argument, NULL, 't'}, + {"structured" , no_argument , NULL, 'S'}, + {"kanji" , no_argument , NULL, 'k'}, + {"casesensitive" , no_argument , NULL, 'c'}, + {"ignorecase" , no_argument , NULL, 'i'}, + {"8bit" , no_argument , NULL, '8'}, + {"micro" , no_argument , NULL, 'M'}, + {"rle" , no_argument , &rle, 1}, + {"svg-path" , no_argument , &svg_path, 1}, + {"inline" , no_argument , &inline_svg, 1}, + {"strict-version", no_argument , &strict_versioning, 1}, + {"foreground" , required_argument, NULL, 'f'}, + {"background" , required_argument, NULL, 'b'}, + {"version" , no_argument , NULL, 'V'}, + {"verbose" , no_argument , &verbose, 1}, {NULL, 0, NULL, 0} }; @@ -1034,6 +1036,10 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil } exit(EXIT_FAILURE); } + if(strict_versioning && version > 0 && qrcode->version != version) { + fprintf(stderr, "Failed to encode the input data: Input data too large\n"); + exit(EXIT_FAILURE); + } if(verbose) { fprintf(stderr, "File: %s, Version: %d\n", (outfile!=NULL)?outfile:"(stdout)", qrcode->version); -- cgit 0.0.5-2-1-g0f52 From 4fdf22ac6d7a11710ea151ae07f0f035a0e9c946 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 16:47:35 +0900 Subject: Documentation updates. --- NEWS | 3 +++ qrenc.c | 4 ++++ qrencode.1.in | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/NEWS b/NEWS index 9eb751464f..3323bb98b3 100644 --- a/NEWS +++ b/NEWS @@ -5,8 +5,11 @@ Version 4.1.0 (2020.8.xx) ------------------------- * Command line tool "qrencode" has been improved: * New option "--inline" has been added. (Thanks to @jp-bennett) + * New option "--strict-version" has been added. * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- Szentkirályi) + * Micro QR Code no longer requires to specify the version number. + * Some compile time warnings have been fixed. * Various CMake support improvements. (Thanks to @mgorny and @sdf5) * Some minor bug fixes. (Thanks to Lonnie Abelbeck and Frédéric Wang) diff --git a/qrenc.c b/qrenc.c index 20d831e745..5ad7fe5a57 100644 --- a/qrenc.c +++ b/qrenc.c @@ -155,6 +155,10 @@ static void usage(int help, int longopt, int status) " specify foreground/background color in hexadecimal notation.\n" " 6-digit (RGB) or 8-digit (RGBA) form are supported.\n" " Color output support available only in PNG, EPS and SVG.\n\n" +" --strict-version\n" +" disable automatic version number adjustment. If the input data is\n" +" too large for the specified version, the program exits with the\n" +" code of 1.\n\n" " -V, --version\n" " display the version number and copyrights of the qrencode.\n\n" " --verbose\n" diff --git a/qrencode.1.in b/qrencode.1.in index 41f481c36a..c9280147bb 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -85,6 +85,11 @@ specify foreground/background color in hexadecimal notation. 6-digit (RGB) or 8-digit (RGBA) form are supported. Color output support available only in PNG, EPS and SVG. .TP +.B \-\-strict\-version +disable automatic version number adjustment. If the input data is +too large for the specified version, the program exits with the +code of 1. +.TP .B \-V, \-\-version display the version number and copyrights of the qrencode. .TP -- cgit 0.0.5-2-1-g0f52 From b7b4760914b6997cc878d3f13d080d3ec56ef553 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 17:25:00 +0900 Subject: A tail recursion has been eliminated. (Thanks to @4061N) (closes #144) --- NEWS | 1 + README.md | 5 +++-- split.c | 30 ++++++++++++++++-------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/NEWS b/NEWS index 3323bb98b3..41d98b4c5f 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ Version 4.1.0 (2020.8.xx) * Various CMake support improvements. (Thanks to @mgorny and @sdf5) * Some minor bug fixes. (Thanks to Lonnie Abelbeck and Frédéric Wang) * Some documentation/manpage improvements. (Thanks to Dan Jacobson) +* Some performance improvements. (Thanks to @4061N and Mika Lindqvist) Release Note: The internal representation of the output code has been slightly changed - diff --git a/README.md b/README.md index b073bd01cc..5ce67f3a0c 100644 --- a/README.md +++ b/README.md @@ -210,12 +210,13 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - improved CMake support * @vanillahsu - bug fix patch * @Ation - bug fix patch -* Jonathan Bennett - Addedd "--inline" option to qrencode +* Jonathan Bennett - Added "--inline" option to qrencode * András Veres-Szentkirályi - ANSI256UTF8 support * @sdf5 - improved CMake support * Lonnie Abelbeck (@abelbeck) - bug fix patch +* @4061N - performance improvement patch * Rosen Penev (@neheb) - CMake bug fix patch * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, @@ -224,5 +225,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, - Frédéric Wang, Dan Jacobson + Frédéric Wang, Dan Jacobson, Mika Lindqvist - bug report / suggestion / typo fixes diff --git a/split.c b/split.c index 1361066b63..a79bf03854 100644 --- a/split.c +++ b/split.c @@ -257,21 +257,23 @@ static int Split_splitString(const char *string, QRinput *input, int length; QRencodeMode mode; - if(*string == '\0') return 0; - - mode = Split_identifyMode(string, hint); - if(mode == QR_MODE_NUM) { - length = Split_eatNum(string, input, hint); - } else if(mode == QR_MODE_AN) { - length = Split_eatAn(string, input, hint); - } else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) { - length = Split_eatKanji(string, input, hint); - } else { - length = Split_eat8(string, input, hint); + while(*string != '\0') { + mode = Split_identifyMode(string, hint); + if(mode == QR_MODE_NUM) { + length = Split_eatNum(string, input, hint); + } else if(mode == QR_MODE_AN) { + length = Split_eatAn(string, input, hint); + } else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) { + length = Split_eatKanji(string, input, hint); + } else { + length = Split_eat8(string, input, hint); + } + if(length == 0) break; + if(length < 0) return -1; + string += length; } - if(length == 0) return 0; - if(length < 0) return -1; - return Split_splitString(&string[length], input, hint); + + return 0; } static char *dupAndToUpper(const char *str, QRencodeMode hint) -- cgit 0.0.5-2-1-g0f52 From f8ceb0d269d9ef624faf42b22257a357ee6a49ac Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 18:38:00 +0900 Subject: All test programs are now TAP-ready. --- tests/common.c | 26 ++++++++++++++++++-------- tests/common.h | 3 ++- tests/test_bitstream.c | 5 +++-- tests/test_estimatebit.c | 5 +++-- tests/test_mask.c | 4 +++- tests/test_mmask.c | 4 +++- tests/test_monkey.c | 26 +++++++++++++++++++------- tests/test_mqrspec.c | 4 +++- tests/test_qrencode.c | 4 +++- tests/test_qrinput.c | 5 ++++- tests/test_qrspec.c | 6 +++++- tests/test_rs.c | 5 +++-- tests/test_split.c | 5 +++-- tests/test_split_urls.c | 5 +++-- 14 files changed, 75 insertions(+), 32 deletions(-) diff --git a/tests/common.c b/tests/common.c index a5d2079843..3d9f3041b8 100644 --- a/tests/common.c +++ b/tests/common.c @@ -51,6 +51,11 @@ int cmpBin(char *correct, BitStream *bstream) return ncmpBin(correct, bstream, len); } +void testInit(int tests) +{ + printf("1..%d\n", tests); +} + void testStartReal(const char *func, const char *name) { tests++; @@ -58,37 +63,42 @@ void testStartReal(const char *func, const char *name) testFunc = func; assertionFailed = 0; assertionNum = 0; - printf("_____%d: %s: %s...\n", tests, func, name); + //printf("_____%d: %s: %s...\n", tests, func, name); } void testEnd(int result) { - printf(".....%d: %s: %s, ", tests, testFunc, testName); if(result) { - puts("FAILED."); + printf("not ok %d %s: %s\n", tests, testFunc, testName); failed++; } else { - puts("PASSED."); + printf("ok %d %s: %s\n", tests, testFunc, testName); } } void testFinish(void) { - printf(".....%d: %s: %s, ", tests, testFunc, testName); if(assertionFailed) { - printf("FAILED. (%d assertions failed.)\n", assertionFailed); + printf("not ok %d %s: %s (%d assertions failed.)\n", tests, testFunc, testName, assertionFailed); failed++; } else { - printf("PASSED. (%d assertions passed.)\n", assertionNum); + printf("ok %d %s: %s (%d assertions passed.)\n", tests, testFunc, testName, assertionNum); } } -void report() +void testReport(int expectedTests) { printf("Total %d tests, %d fails.\n", tests, failed); if(failed) exit(-1); + if(expectedTests != tests) { + printf("WARNING: the number of the executed tests (%d) is not equal to the expecetd (%d).\n", tests, expectedTests); + } } +int testNum(void) +{ + return tests; +} void printBinary(unsigned char *data, int length) { diff --git a/tests/common.h b/tests/common.h index 3fa31758db..a0b19d83da 100644 --- a/tests/common.h +++ b/tests/common.h @@ -19,12 +19,13 @@ extern int assertionNum; extern const char levelChar[4]; extern const char *modeStr[5]; +void testInit(int tests); #define testStart(__arg__) (testStartReal(__func__, __arg__)) #define testEndExp(__arg__) (testEnd(!(__arg__))) void testStartReal(const char *func, const char *name); void testEnd(int result); void testFinish(void); -void report(); +void testReport(int tests); #define assert_exp(__exp__, ...) \ {assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__VA_ARGS__);}} diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index 3fb223520c..b4224eebdf 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -234,6 +234,8 @@ static void test_newWithBits_size0(void) int main() { + int tests = 11; + testInit(tests); test_null(); test_num(); test_bytes(); @@ -245,8 +247,7 @@ int main() test_append(); test_newWithBits(); test_newWithBits_size0(); - - report(); + testReport(tests); return 0; } diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index 252d151650..3e797e4cd8 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -143,6 +143,8 @@ int main() { gstream = QRinput_new(); + int tests = 8; + testInit(tests); test_numbit(); test_numbit2(); test_numbit3(); @@ -151,8 +153,7 @@ int main() test_kanji(); test_structure(); test_mix(); - - report(); + testReport(tests); return 0; } diff --git a/tests/test_mask.c b/tests/test_mask.c index bfb4901f30..fb0c5fdd83 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -391,6 +391,8 @@ static void test_calcN1N3(void) int main(int argc, char **argv) { + int tests = 9; + testInit(tests); test_masks(); test_eval(); test_eval2(); @@ -399,7 +401,7 @@ int main(int argc, char **argv) test_calcN2(); test_calcRunLength(); test_calcN1N3(); - report(); + testReport(tests); if(argc > 1) { print_masks(); diff --git a/tests/test_mmask.c b/tests/test_mmask.c index a083b7bf64..c6cab14a6e 100644 --- a/tests/test_mmask.c +++ b/tests/test_mmask.c @@ -141,9 +141,11 @@ static void test_maskEvaluation(void) int main(int argc, char **argv) { + int tests = 2; + testInit(tests); test_masks(); test_maskEvaluation(); - report(); + testReport(tests); if(argc > 1) { print_masks(); diff --git a/tests/test_monkey.c b/tests/test_monkey.c index 488fa8ec4c..f50fdca1dd 100644 --- a/tests/test_monkey.c +++ b/tests/test_monkey.c @@ -186,11 +186,12 @@ static void monkey_encode_an(int loop) { int i; - puts("Monkey test: QRcode_encodeString() - AlphaNumeric string."); + testStart("Monkey test: QRcode_encodeString() - AlphaNumeric string."); srand(0); for(i=0; i 1) { print_format(); diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index ffed090345..05267666b0 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -977,6 +977,8 @@ static void test_apiversion(void) int main(int argc, char **argv) { + int tests = 32; + testInit(tests); test_iterate(); test_iterate2(); test_filler(); @@ -1009,7 +1011,7 @@ int main(int argc, char **argv) test_oddBitCalcMQR(); test_mqrencode(); test_apiversion(); - report(); + testReport(tests); if(argc > 1) { print_filler(); diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index a70f01488d..c7b550c1cf 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -1043,6 +1043,9 @@ static void test_encodeECI(void) int main() { + int tests = 40; + testInit(tests); + test_encodeNumeric(); test_encodeNumeric2(); test_encodeNumeric3(); @@ -1085,7 +1088,7 @@ int main() test_ECIinvalid(); test_encodeECI(); - report(); + testReport(tests); return 0; } diff --git a/tests/test_qrspec.c b/tests/test_qrspec.c index 9a3ab65f0e..15b7bbe9d2 100644 --- a/tests/test_qrspec.c +++ b/tests/test_qrspec.c @@ -216,6 +216,7 @@ static void test_verpat(void) int i, c; unsigned int mask; + testStart("Checking version pattern."); for(version=7; version <= QRSPEC_VERSION_MAX; version++) { pattern = QRspec_getVersionPattern(version); if((pattern >> 12) != (unsigned int)version) { @@ -245,6 +246,7 @@ static void test_verpat(void) err++; } } + testEnd(err); } /* See Table 22 (p.45) and Appendix C (p. 65) of JIS X0510:2004 */ @@ -298,6 +300,8 @@ static void test_format(void) int main(int argc, char **argv) { + int tests = 6; + testInit(tests); test_eccTable(); test_eccTable2(); test_newframe(); @@ -305,7 +309,7 @@ int main(int argc, char **argv) //test_alignment(); test_verpat(); test_format(); - report(); + testReport(tests); if(argc > 1) { print_eccTable(); diff --git a/tests/test_rs.c b/tests/test_rs.c index d87aa88a1b..d0df44bfb3 100644 --- a/tests/test_rs.c +++ b/tests/test_rs.c @@ -116,10 +116,11 @@ void test_allQRSizeAndECCLevel(void) int main() { RSECC_decoder_init(); + int tests = 2; + testInit(tests); test_rscodeexample(); test_allQRSizeAndECCLevel(); - - report(); + testReport(tests); return 0; } diff --git a/tests/test_split.c b/tests/test_split.c index 0a64150c21..e46f53514f 100644 --- a/tests/test_split.c +++ b/tests/test_split.c @@ -530,6 +530,8 @@ static void test_split8N8(void) int main() { + int tests = 24; + testInit(tests); test_split1(); test_split2(); test_split3(); @@ -545,8 +547,7 @@ int main() test_splitAn8An(); test_split8An8(); test_split8N8(); - - report(); + testReport(tests); return 0; } diff --git a/tests/test_split_urls.c b/tests/test_split_urls.c index 432d3b5718..f1967ec0bd 100644 --- a/tests/test_split_urls.c +++ b/tests/test_split_urls.c @@ -83,9 +83,10 @@ static void test_bitstream_length() { int main() { + int tests = 1; + testInit(tests); test_bitstream_length(); - - report(); + testReport(tests); return 0; } -- cgit 0.0.5-2-1-g0f52 From 7478fffba0763d6ee0bd0f1164c1be0dda190036 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 18:56:06 +0900 Subject: Now you can run all test programs by 'make check'. (see #117) --- tests/Makefile.am | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 55c5400685..c7cfad1b37 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,11 +11,10 @@ if HAVE_PNG pngPROGRAMS = create_frame_pattern create_mqr_frame_pattern endif -noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \ - test_qrspec test_rs test_qrencode prof_qrencode \ - test_mqrspec test_split test_monkey test_mask test_mmask \ - test_split_urls \ - $(pngPROGRAMS) $(sdlPROGRAMS) +check_PROGRAMS = test_qrinput test_bitstream test_estimatebit test_qrspec \ + test_rs test_qrencode test_mqrspec test_split test_mask \ + test_mmask test_split_urls test_monkey +noinst_PROGRAMS = $(pngPROGRAMS) $(sdlPROGRAMS) $(check_PROGRAMS) prof_qrencode noinst_LIBRARIES = libdecoder.a DECODER_LIBS = libdecoder.a $(LIBICONV) noinst_HEADERS = common.h rscode.h @@ -23,6 +22,7 @@ if HAVE_LIBPTHREAD noinst_PROGRAMS += pthread_qrencode endif +TESTS = $(check_PROGRAMS) EXTRA_DIST = test_all.sh test_basic.sh test_configure.sh frame URI_testset.inc CMakeLists.txt libdecoder_a_SOURCES = decoder.c decoder.h datachunk.c datachunk.h rsecc_decoder.c rsecc_decoder.h -- cgit 0.0.5-2-1-g0f52 From 5d4043e8f4191cf36bb9f8c9544923f0615ea61a Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 19:12:25 +0900 Subject: Return value was ignored. (Thanks to @xiaoyur347) (closed #143) --- README.md | 2 +- qrinput.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ce67f3a0c..056b6c52bf 100644 --- a/README.md +++ b/README.md @@ -225,5 +225,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, - Frédéric Wang, Dan Jacobson, Mika Lindqvist + Frédéric Wang, Dan Jacobson, Mika Lindqvist, Jan Tojnar, @xiaoyur347 - bug report / suggestion / typo fixes diff --git a/qrinput.c b/qrinput.c index ad03b6f2ee..c8ab07bad6 100644 --- a/qrinput.c +++ b/qrinput.c @@ -445,7 +445,7 @@ static int QRinput_encodeModeNum(QRinput_List *entry, BitStream *bstream, int ve } else if(entry->size - words * 3 == 2) { val = (unsigned int)(entry->data[words*3 ] - '0') * 10; val += (unsigned int)(entry->data[words*3+1] - '0'); - BitStream_appendNum(bstream, 7, val); + ret = BitStream_appendNum(bstream, 7, val); if(ret < 0) return -1; } -- cgit 0.0.5-2-1-g0f52 From b06b5fd01993c492a37b1a02a6062f75bc96835c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 21:12:25 +0900 Subject: Documentation updates. --- ChangeLog | 45 ++++++++++++++++++++++++++++++++++++++++++++- NEWS | 3 ++- README.md | 3 ++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0faf09ba56..b582951393 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,50 @@ +2020.08.28 Kentaro Fukuchi + [develop] + * Made a develoment branch. + * test_qrspec.c: + - Typo fixes. + * qrinput.[ch], tests/{test_qrencode.c, test_qrinput.c}: + - A precise boundary check has been introduced to + QRinput_estimateVersion(). (closes #160) + * qrinput.c, qrencode.c, tests/test_qrencode.c, qrenc.c, qrencode.1.in: + - QRinput_encodeMode*() now throws ERANGE when encoding Micro QR Code + and an appropriate version number was not specified. + - Now Micro QR Code also allows auto version adjustment. + * qrenc.c, qrencode.1.in: + - The synopsis has been improved. (Thanks to @jidanni) (closes #155) + - A new option '--strict-version' has been introduced. + * split.c: + - A tail recursion has been eliminated. (Thanks to @4061N) (closes #144) + * tests/*: + - All test programs are now TAP-ready. Now you can run all test programs + by 'make check'.(Thanks to @jtojnar) (closes #117) + * qrinput.c: + - Return value was ignored. (Thanks to @xiaoyur347) (closed #143) + * README.md, NEWS: + - Various documentation improvements and updates. + +2020.02.23 Kentaro Fukuchi + [master] + * CMakeLists.txt, README.md: + - Merged #158 (Thanks to @neheb): + - Fixed the compile-time issue of the environment without libpng. + +2020.02.23 Kentaro Fukuchi + [master] + * README.md: + - Merged #151 (Thanks to @NancyLi1013): + - Added vcpkg installation instructions. + +2018.11.09 Kentaro Fukuchi + [master] + * configure.ac, README.md: + - Merged #137 (Thanks to @abelbeck and @charmander): + - 'too many arguments' bug has been fixed. + 2018.07.28 Kentaro Fukuchi [master] * CMakeLists.txt: - - Merged #133 (Thanks to @sdf5) + - Merged #133 (Thanks to @sdf5): - Change CMAKE_SORUCE_DIR to CMAKE_CURRENT_SORUCE_DIR in CMAKE_MODULE_PATH diff --git a/NEWS b/NEWS index 41d98b4c5f..55b8432107 100644 --- a/NEWS +++ b/NEWS @@ -3,12 +3,13 @@ libqrencode NEWS - Overview of changes Version 4.1.0 (2020.8.xx) ------------------------- +* Micro QR Code no longer requires to specify the version number. +* 'make check' allows to run the test programs. (Thanks to Jan Tojnar) * Command line tool "qrencode" has been improved: * New option "--inline" has been added. (Thanks to @jp-bennett) * New option "--strict-version" has been added. * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- Szentkirályi) - * Micro QR Code no longer requires to specify the version number. * Some compile time warnings have been fixed. * Various CMake support improvements. (Thanks to @mgorny and @sdf5) diff --git a/README.md b/README.md index 056b6c52bf..9b683bdf93 100644 --- a/README.md +++ b/README.md @@ -225,5 +225,6 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, - Frédéric Wang, Dan Jacobson, Mika Lindqvist, Jan Tojnar, @xiaoyur347 + Frédéric Wang, Dan Jacobson, Mika Lindqvist, Jan Tojnar, @xiaoyur347, + @charmander - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From 7d08c0e29f3d9ba51421139a6e8b16d861909eac Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 21:19:19 +0900 Subject: Follows old C standard. --- qrencode.c | 12 +++++++++--- tests/test_qrinput.c | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/qrencode.c b/qrencode.c index a6fc9806c5..51569afffd 100644 --- a/qrencode.c +++ b/qrencode.c @@ -653,10 +653,12 @@ QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QR QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) { + int i; + if(version == 0) { version = 1; } - for(int i=version; i<=MQRSPEC_VERSION_MAX ; i++) { + for(i = version; i <= MQRSPEC_VERSION_MAX ; i++) { QRcode *code = QRcode_encodeStringReal(string, i, level, 1, hint, casesensitive); if(code != NULL) return code; } @@ -709,10 +711,12 @@ QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level) { + int i; + if(version == 0) { version = 1; } - for(int i=version; i<=MQRSPEC_VERSION_MAX; i++) { + for(i = version; i <= MQRSPEC_VERSION_MAX; i++) { QRcode *code = QRcode_encodeDataReal(data, size, i, level, 1); if(code != NULL) return code; } @@ -722,6 +726,8 @@ QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, Q QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level) { + int i; + if(string == NULL) { errno = EINVAL; return NULL; @@ -729,7 +735,7 @@ QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel le if(version == 0) { version = 1; } - for(int i=version; i<=MQRSPEC_VERSION_MAX; i++) { + for(i = version; i <= MQRSPEC_VERSION_MAX; i++) { QRcode *code = QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), i, level, 1); if(code != NULL) return code; } diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index c7b550c1cf..0009007d18 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -878,8 +878,9 @@ static void checkEstimatedVersion(int ver, int mode) static void test_estimateVersionBoundaryCheck(void) { + int ver; testStart("Boundary check of estimateVersion"); - for(int ver=1; ver < QRSPEC_VERSION_MAX; ver++) { + for(ver = 1; ver < QRSPEC_VERSION_MAX; ver++) { checkEstimatedVersion(ver, QR_MODE_NUM); checkEstimatedVersion(ver, QR_MODE_AN); checkEstimatedVersion(ver, QR_MODE_8); -- cgit 0.0.5-2-1-g0f52 From 29f0434de77c8b3e34b3ca1252759ee5ffc20e57 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 21:38:08 +0900 Subject: Bumped version to 4.1.0. --- ChangeLog | 2 ++ NEWS | 2 +- README.md | 2 +- qrencode.1.in | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b582951393..ebfcbcdc1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,8 @@ - Return value was ignored. (Thanks to @xiaoyur347) (closed #143) * README.md, NEWS: - Various documentation improvements and updates. + [release-4.1.0] + * Bumped version to 4.1.0. 2020.02.23 Kentaro Fukuchi [master] diff --git a/NEWS b/NEWS index 55b8432107..e12f166c90 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.1.0 (2020.8.xx) +Version 4.1.0 (2020.8.28) ------------------------- * Micro QR Code no longer requires to specify the version number. * 'make check' allows to run the test programs. (Thanks to Jan Tojnar) diff --git a/README.md b/README.md index 9b683bdf93..c695fdb7da 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # libqrencode - a fast and compact QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) -**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.0.2. +**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.1.0. GENERAL INFORMATION =================== diff --git a/qrencode.1.in b/qrencode.1.in index c9280147bb..3b6ce819c0 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -1,4 +1,4 @@ -.TH QRENCODE 1 "Sep. 21, 2017" "qrencode @VERSION@" +.TH QRENCODE 1 "Aug. 28, 2020" "qrencode @VERSION@" .SH NAME qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS -- cgit 0.0.5-2-1-g0f52 From 557995b1d0811ebe441b531a99577d0d05760998 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 22:30:24 +0900 Subject: Document improvements. --- ChangeLog | 2 ++ qrencode.h | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index ebfcbcdc1c..1dd6a213f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,8 @@ - Various documentation improvements and updates. [release-4.1.0] * Bumped version to 4.1.0. + * qrencode.h: + - Document improvements. 2020.02.23 Kentaro Fukuchi [master] diff --git a/qrencode.h b/qrencode.h index 55279aaf14..1a934cc12c 100644 --- a/qrencode.h +++ b/qrencode.h @@ -35,8 +35,8 @@ * * If the input data contains Kanji (Shift-JIS) characters and you want to * encode them as Kanji in QR Code, you should give QR_MODE_KANJI as a hint. - * Otherwise, all of non-alphanumeric characters are encoded as 8 bit data. - * If you want to encode a whole string in 8 bit mode, you can use + * Otherwise, all of non-alphanumeric characters are encoded as 8-bit data. + * If you want to encode a whole string in 8-bit mode, you can use * QRcode_encodeString8bit() instead. * * Please note that a C string can not contain NUL characters. If your data @@ -44,16 +44,16 @@ * * \subsection encoding-input Encoding a structured data * You can construct a structured input data manually. If the structure of the - * input data is known, you can use this way. + * input data is known, you can use this method. * At first, create a ::QRinput object by QRinput_new(). Then add input data * to the QRinput object by QRinput_append(). Finally call QRcode_encodeInput() * to encode the QRinput data. - * You can reuse the QRinput data again to encode it in other symbols with + * You can reuse the QRinput object again to encode it in other symbols with * different parameters. * * \section result Result - * The encoded symbol is resulted as a ::QRcode object. It will contain - * its version number, width of the symbol and an array represents the symbol. + * The encoded symbol is generated as a ::QRcode object. It will contain its + * version number, the width of the symbol, and an array represents the symbol. * See ::QRcode for the details. You can free the object by QRcode_free(). * * Please note that the version of the result may be larger than specified. -- cgit 0.0.5-2-1-g0f52 From 77de38effc5128cdbf4f765923dafb81f3694276 Mon Sep 17 00:00:00 2001 From: Younes Khoudli Date: Sun, 18 Nov 2018 00:30:52 +0100 Subject: usage: document the existence of the UTF8i and ANSIUTF8i options --- qrenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qrenc.c b/qrenc.c index 5ad7fe5a57..c09c4ab693 100644 --- a/qrenc.c +++ b/qrenc.c @@ -134,8 +134,8 @@ static void usage(int help, int longopt, int status) " specify the width of the margins. (default=4 (2 for Micro QR)))\n\n" " -d NUMBER, --dpi=NUMBER\n" " specify the DPI of the generated PNG. (default=72)\n\n" -" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8},\n" -" --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}\n" +" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8},\n" +" --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}\n" " specify the type of the generated image. (default=PNG)\n\n" " -S, --structured\n" " make structured symbols. Version must be specified with '-v'.\n\n" @@ -192,7 +192,7 @@ static void usage(int help, int longopt, int status) " -v NUMBER specify the minimum version of the symbol. (default=auto)\n" " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n" " -d NUMBER specify the DPI of the generated PNG. (default=72)\n" -" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}\n" +" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}\n" " specify the type of the generated image. (default=PNG)\n" " -S make structured symbols. Version number must be specified with '-v'.\n" " -k assume that the input text contains kanji (shift-jis).\n" -- cgit 0.0.5-2-1-g0f52 From afa6ce68bf0265e2752506107e1e5dfdce24b0d0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 22:54:13 +0900 Subject: Added 'UTF8i' and 'ANSIUTF8i' to the descriptions of the corresponding options. --- ChangeLog | 3 +++ qrencode.1.in | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1dd6a213f3..92e9837620 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,9 @@ * Bumped version to 4.1.0. * qrencode.h: - Document improvements. + * qrenc.c, qrencode.1.in: + - Added 'UTF8i' and 'ANSIUTF8i' to the descriptions of the corresponding + options. (Thanks to @Khoyo) (merged #138) 2020.02.23 Kentaro Fukuchi [master] diff --git a/qrencode.1.in b/qrencode.1.in index 3b6ce819c0..c8e31da116 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -43,10 +43,10 @@ specify the width of margin. (default=4) specify the DPI of the generated PNG. (default=72) .TP .PD 0 -.B \-t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8} +.B \-t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8} .TP .PD -.B \-\-type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8} +.B \-\-type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8} specify the type of the generated image. (default=PNG) .TP .B \-S, \-\-structured -- cgit 0.0.5-2-1-g0f52 From d3ba592a129fda1f0774958c46ae64b91106b271 Mon Sep 17 00:00:00 2001 From: Mika Lindqvist Date: Fri, 28 Aug 2020 17:16:36 +0300 Subject: Fix for Visual C++ (#157) * Fix tests failing when compiled with Visual C++. --- CMakeLists.txt | 2 ++ tests/CMakeLists.txt | 14 ++++++++++++-- tests/prof_qrencode.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd42280c0b..b72138033a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,8 @@ check_include_file(strings.h HAVE_STRINGS_H ) check_include_file(string.h HAVE_STRING_H ) check_include_file(getopt.h HAVE_GETOPT_H ) check_include_file(sys/time.h HAVE_SYS_TIME_H) +check_include_file(time.h HAVE_TIME_H ) +check_include_file(pthread.h HAVE_PTHREAD_H ) check_function_exists(strdup HAVE_STRDUP) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4234ea8c86..4c4a5e8171 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,11 +27,21 @@ if(HAVE_SDL) endif(HAVE_SDL) if(TARGET Threads::Threads) + if(HAVE_SYS_TIME_H) + add_definitions(-DHAVE_SYS_TIME_H) + endif() + + if(HAVE_TIME_H) + add_definitions(-DHAVE_TIME_H) + endif() + add_executable(prof_qrencode prof_qrencode.c) target_link_libraries(prof_qrencode common Threads::Threads) - add_executable(pthread_qrencode pthread_qrencode.c) - target_link_libraries(pthread_qrencode common Threads::Threads) + if(HAVE_PTHREAD_H) + add_executable(pthread_qrencode pthread_qrencode.c) + target_link_libraries(pthread_qrencode common Threads::Threads) + endif() endif() MAKE_TEST(test_bitstream) diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index a98b5d672f..31fd6cd95f 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -1,24 +1,54 @@ #include #include +#ifdef HAVE_SYS_TIME_H #include +#endif +#ifdef HAVE_TIME_H #include +#endif #include #include "../qrencode.h" +#ifdef _MSC_VER +#define WIN32_LEAN_AND_MEAN +#include +static LARGE_INTEGER startTime; +static LARGE_INTEGER frequency = { .QuadPart = 0 }; +#else static struct timeval tv; +#endif + static void timerStart(const char *str) { printf("%s: START\n", str); +#ifdef _MSC_VER + (void) QueryPerformanceCounter(&startTime); +#else gettimeofday(&tv, NULL); +#endif } static void timerStop(void) { +#ifdef _MSC_VER + LARGE_INTEGER endTime, elapsed; + (void) QueryPerformanceCounter(&endTime); + if (frequency.QuadPart == 0) { + (void) QueryPerformanceFrequency(&frequency); + } + + elapsed.QuadPart = endTime.QuadPart - startTime.QuadPart; + elapsed.QuadPart *= 1000; + elapsed.QuadPart /= frequency.QuadPart; + + printf("STOP: %lld msec\n", elapsed.QuadPart); +#else struct timeval tc; gettimeofday(&tc, NULL); printf("STOP: %ld msec\n", (tc.tv_sec - tv.tv_sec) * 1000 + (tc.tv_usec - tv.tv_usec) / 1000); +#endif } static void prof_ver1to10(void) -- cgit 0.0.5-2-1-g0f52 From b74a761e0121bc7df69a81329bec620213c16ba3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 28 Aug 2020 23:43:33 +0900 Subject: Create cmake.yml --- .github/workflows/cmake.yml | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000000..ac588566eb --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,46 @@ +name: CMake + +on: [push] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{runner.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_TESTS=yes -DBUILD_SHARED_LIBS=on + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: cmake --build . --config $BUILD_TYPE + + - name: Test + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C $BUILD_TYPE -- cgit 0.0.5-2-1-g0f52 From f542dc08e0ad4c0557b3d9ce48f33605699baaff Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 00:05:03 +0900 Subject: New action script. --- .github/workflows/configure.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/configure.yml diff --git a/.github/workflows/configure.yml b/.github/workflows/configure.yml new file mode 100644 index 0000000000..766aeb6b22 --- /dev/null +++ b/.github/workflows/configure.yml @@ -0,0 +1,21 @@ +name: configure CI + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: generate configure script + run: ./autogen.sh + - name: configure + run: ./configure --with-tests + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck -- cgit 0.0.5-2-1-g0f52 From e16d288244b9fbf0140671536b5dbaeb64ea0363 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 12:06:03 +0900 Subject: A minor memory leak bug in testing program has been fixed. --- tests/test_bitstream.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_bitstream.c b/tests/test_bitstream.c index b4224eebdf..64b1e86d92 100644 --- a/tests/test_bitstream.c +++ b/tests/test_bitstream.c @@ -216,6 +216,8 @@ static void test_newWithBits(void) assert_zero(cmpBin("0101", bstream), "Internal data is incorrect.\n"); testFinish(); + + BitStream_free(bstream); } static void test_newWithBits_size0(void) @@ -230,6 +232,8 @@ static void test_newWithBits_size0(void) assert_nonnull(bstream->data, "Internal buffer not allocated.\n"); testFinish(); + + BitStream_free(bstream); } int main() -- cgit 0.0.5-2-1-g0f52 From 6e3f02cd8ea4677fb0a8fb66ca0f0cde9c6151f3 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 12:07:08 +0900 Subject: Make configure to define HAVE_SYS_TIME_H in config.h. --- configure.ac | 1 + tests/prof_qrencode.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index bc0e466fbc..72dd9d852c 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,7 @@ AC_DISABLE_STATIC AC_C_CONST AC_C_INLINE AC_HEADER_STDC +AC_CHECK_HEADERS(sys/time.h) LT_INIT AC_PROG_CC diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index 31fd6cd95f..dd79f9eb00 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -1,11 +1,11 @@ #include #include +#if HAVE_CONFIG_H +#include "../config.h" +#endif #ifdef HAVE_SYS_TIME_H #include #endif -#ifdef HAVE_TIME_H -#include -#endif #include #include "../qrencode.h" -- cgit 0.0.5-2-1-g0f52 From e1d437577e43b7af55f277df35fee217a5495326 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 12:49:39 +0900 Subject: Document updates. --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 92e9837620..4966878822 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2020.08.29 Kentaro Fukuchi + [release-4.1.0] + * .github/workflows/{cmake,configure}.yml: + - Github actions CI scripts have been added. + * tests/test_bitstream.c: + - Fixed memory leak. + * configure.ac, tests/prof_qrencode.c: + - Make configure to define HAVE_SYS_TIME_H in config.h. + 2020.08.28 Kentaro Fukuchi [develop] * Made a develoment branch. -- cgit 0.0.5-2-1-g0f52 From e1d9b66d6e453147d375c362215f3f25f396ffdf Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 14:04:52 +0900 Subject: Applied the fix of #157. --- tests/pthread_qrencode.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/pthread_qrencode.c b/tests/pthread_qrencode.c index 917b0a0dec..a450e59aa4 100644 --- a/tests/pthread_qrencode.c +++ b/tests/pthread_qrencode.c @@ -1,8 +1,12 @@ #include #include +#if HAVE_CONFIG_H +#include "../config.h" +#endif +#ifdef HAVE_SYS_TIME_H #include +#endif #include -#include #include #include "../qrencode.h" @@ -10,20 +14,46 @@ static pthread_t threads[THREADS]; +#ifdef _MSC_VER +#define WIN32_LEAN_AND_MEAN +#include +static LARGE_INTEGER startTime; +static LARGE_INTEGER frequency = { .QuadPart = 0 }; +#else static struct timeval tv; +#endif + static void timerStart(const char *str) { printf("%s: START\n", str); +#ifdef _MSC_VER + (void) QueryPerformanceCounter(&startTime); +#else gettimeofday(&tv, NULL); +#endif } static void timerStop(void) { +#ifdef _MSC_VER + LARGE_INTEGER endTime, elapsed; + (void) QueryPerformanceCounter(&endTime); + if (frequency.QuadPart == 0) { + (void) QueryPerformanceFrequency(&frequency); + } + + elapsed.QuadPart = endTime.QuadPart - startTime.QuadPart; + elapsed.QuadPart *= 1000; + elapsed.QuadPart /= frequency.QuadPart; + + printf("STOP: %lld msec\n", elapsed.QuadPart); +#else struct timeval tc; gettimeofday(&tc, NULL); printf("STOP: %ld msec\n", (tc.tv_sec - tv.tv_sec) * 1000 + (tc.tv_usec - tv.tv_usec) / 1000); +#endif } static void *encode_ver1to10(void *arg) -- cgit 0.0.5-2-1-g0f52 From 502322361812a72962f5fecbbc37c8fd4e6522a0 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 14:05:31 +0900 Subject: Testing script for Windows has been added. --- .github/workflows/cmake-windows.yml | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/cmake-windows.yml diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml new file mode 100644 index 0000000000..ef0e051190 --- /dev/null +++ b/.github/workflows/cmake-windows.yml @@ -0,0 +1,53 @@ +name: CMake + +on: [push, pull_request] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - name: run vcpkg + uses: lukka/run-vcpkg@v3 + with: + vcpkgArguments: getopt:x64-windows libiconv:x64-windows libpng:x64-windows + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgGitCommitId: 'fca18ba3572f8aebe3b8158c359db62a7e26134e' + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{runner.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DWITH_TESTS=yes + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: cmake --build . --config $BUILD_TYPE + + - name: Test + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C $BUILD_TYPE -- cgit 0.0.5-2-1-g0f52 From f63b5e6e2751fd87892f52352fc6221bc40394ac Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 14:41:19 +0900 Subject: getopt library's name has been corrected. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b72138033a..9f7fe4bfd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ if(MSVC) if(WITH_TOOLS) find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include) - find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib) + find_library(GETOPT_LIBRARIES getopt PATH_SUFFIXES lib) include_directories(${GETOPT_INCLUDE_DIR}) endif(WITH_TOOLS) endif(MSVC) -- cgit 0.0.5-2-1-g0f52 From 5d7edaed467f784e9d46d8f6cdd95dbd8f08d6dc Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 15:35:24 +0900 Subject: ECLEVEL check has been improved. --- qrencode.c | 4 ++-- tests/test_qrencode.c | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/qrencode.c b/qrencode.c index 51569afffd..2cb9ca86e2 100644 --- a/qrencode.c +++ b/qrencode.c @@ -445,7 +445,7 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMask(QRinput *input, int mask) errno = EINVAL; return NULL; } - if(input->level > QR_ECLEVEL_H) { + if(!(input->level >= QR_ECLEVEL_L && input->level <= QR_ECLEVEL_H)) { errno = EINVAL; return NULL; } @@ -533,7 +533,7 @@ STATIC_IN_RELEASE QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask) errno = EINVAL; return NULL; } - if(input->level > QR_ECLEVEL_Q) { + if(!(input->level >= QR_ECLEVEL_L && input->level <= QR_ECLEVEL_Q)) { errno = EINVAL; return NULL; } diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 05267666b0..0de41bd00c 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -911,6 +911,43 @@ static void test_oddBitCalcMQR(void) testFinish(); } +static void test_invalid_inputMQR(void) +{ + QRinput *input; + QRcode *code; + + testStart("Testing invalid input (MQR)."); + input = QRinput_newMQR(1, QR_ECLEVEL_L); + QRinput_append(input, QR_MODE_AN, 5, (unsigned char *)"TEST1"); + input->version = -1; + input->level = QR_ECLEVEL_L; + code = QRcode_encodeInput(input); + assert_null(code, "invalid version(-1) was not checked.\n"); + if(code != NULL) QRcode_free(code); + + input->version = 5; + input->level = QR_ECLEVEL_L; + code = QRcode_encodeInput(input); + assert_null(code, "invalid version(5) access was not checked.\n"); + if(code != NULL) QRcode_free(code); + + input->version = 1; + input->level = (QRecLevel)(QR_ECLEVEL_H); + code = QRcode_encodeInput(input); + assert_null(code, "invalid level(H) access was not checked.\n"); + if(code != NULL) QRcode_free(code); + + input->version = 1; + input->level = (QRecLevel)-1; + code = QRcode_encodeInput(input); + assert_null(code, "invalid level(-1) access was not checked.\n"); + if(code != NULL) QRcode_free(code); + + QRinput_free(input); + + testFinish(); +} + static void test_mqrencode(void) { char *str = "MICROQR"; @@ -977,7 +1014,7 @@ static void test_apiversion(void) int main(int argc, char **argv) { - int tests = 32; + int tests = 33; testInit(tests); test_iterate(); test_iterate2(); @@ -1009,6 +1046,7 @@ int main(int argc, char **argv) test_encodeTooLongMQR(); test_decodeShortMQR(); test_oddBitCalcMQR(); + test_invalid_inputMQR(); test_mqrencode(); test_apiversion(); testReport(tests); -- cgit 0.0.5-2-1-g0f52 From 1f0ccfc624ab0718cff67383a4ccc6c39c672f74 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 16:20:25 +0900 Subject: Document updates. --- ChangeLog | 8 ++++++-- NEWS | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4966878822..2186126c94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,15 @@ 2020.08.29 Kentaro Fukuchi [release-4.1.0] - * .github/workflows/{cmake,configure}.yml: + * .github/workflows/{cmake,configure,cmake-windows}.yml: - Github actions CI scripts have been added. * tests/test_bitstream.c: - Fixed memory leak. - * configure.ac, tests/prof_qrencode.c: + * configure.ac, tests/{prof,pthread}_qrencode.c: - Make configure to define HAVE_SYS_TIME_H in config.h. + * CMakeLists.txt: + - 'wingetopt' has been replaced to 'getopt'. + * qrencode.c, tests/test_qrencode.c: + - ECLEVEL check has been improved. 2020.08.28 Kentaro Fukuchi [develop] diff --git a/NEWS b/NEWS index e12f166c90..0b5e5492c1 100644 --- a/NEWS +++ b/NEWS @@ -1,16 +1,15 @@ libqrencode NEWS - Overview of changes ====================================== -Version 4.1.0 (2020.8.28) +Version 4.1.0 (2020.8.29) ------------------------- -* Micro QR Code no longer requires to specify the version number. -* 'make check' allows to run the test programs. (Thanks to Jan Tojnar) * Command line tool "qrencode" has been improved: * New option "--inline" has been added. (Thanks to @jp-bennett) * New option "--strict-version" has been added. * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- Szentkirályi) - +* Micro QR Code no longer requires to specify the version number. +* 'make check' allows to run the test programs. (Thanks to Jan Tojnar) * Some compile time warnings have been fixed. * Various CMake support improvements. (Thanks to @mgorny and @sdf5) * Some minor bug fixes. (Thanks to Lonnie Abelbeck and Frédéric Wang) -- cgit 0.0.5-2-1-g0f52 From 186ccf5d878e20898c29ba91db44b498afb14c80 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 18:16:09 +0900 Subject: Added 'test-driver' to the list. --- .gitignore | 1 + ChangeLog | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7fd2e09a78..4b558b6c30 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ use/depcomp use/install-sh use/ltmain.sh use/missing +use/test-driver html/ massif.out.* gmon.out diff --git a/ChangeLog b/ChangeLog index 2186126c94..7126e1944f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ - 'wingetopt' has been replaced to 'getopt'. * qrencode.c, tests/test_qrencode.c: - ECLEVEL check has been improved. + * .gitignore: + - Added 'use/test-driver'. 2020.08.28 Kentaro Fukuchi [develop] -- cgit 0.0.5-2-1-g0f52 From 0f6149e41533a34029e72ff9234a18e0f22ab992 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 29 Aug 2020 18:40:16 +0900 Subject: Document updates. --- NEWS | 4 ++-- README.md | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 0b5e5492c1..7b56724e50 100644 --- a/NEWS +++ b/NEWS @@ -4,9 +4,9 @@ libqrencode NEWS - Overview of changes Version 4.1.0 (2020.8.29) ------------------------- * Command line tool "qrencode" has been improved: - * New option "--inline" has been added. (Thanks to @jp-bennett) + * New option "--inline" has been added. (Thanks to @jp-bennett) * New option "--strict-version" has been added. - * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- + * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- Szentkirályi) * Micro QR Code no longer requires to specify the version number. * 'make check' allows to run the test programs. (Thanks to Jan Tojnar) diff --git a/README.md b/README.md index c695fdb7da..5e075e7d34 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install -vcpkg install libqrencode +./vcpkg install libqrencode ``` The libqrencode port in vcpkg is kept up to date by Microsoft team members and @@ -218,6 +218,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - bug fix patch * @4061N - performance improvement patch * Rosen Penev (@neheb) - CMake bug fix patch +* Mika Lindqvist (@mtl1979) + - replacement for gettimeofday() for Windows. * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, @@ -225,6 +227,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, - Frédéric Wang, Dan Jacobson, Mika Lindqvist, Jan Tojnar, @xiaoyur347, - @charmander + Frédéric Wang, Dan Jacobson, Jan Tojnar, @xiaoyur347, @charmander - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From 921fcd6e34cb80efa3565d166cdab5d3f731bdd6 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 30 Aug 2020 02:07:15 +0900 Subject: Action macos (#167) Added macOs CI script. --- .github/workflows/configure.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/configure.yml b/.github/workflows/configure.yml index 766aeb6b22..20d634c03e 100644 --- a/.github/workflows/configure.yml +++ b/.github/workflows/configure.yml @@ -4,11 +4,16 @@ on: [push, pull_request] jobs: build: - - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v2 + - name: brew setup + if: matrix.os == 'macos-latest' + run: brew install automake autoconf pkg-config libpng - name: generate configure script run: ./autogen.sh - name: configure -- cgit 0.0.5-2-1-g0f52 From e7f800df166549a50a1dbedffd088f00f33172fc Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 30 Aug 2020 02:12:30 +0900 Subject: Document updates. --- ChangeLog | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7126e1944f..7e4553c3ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020.08.30 Kentaro Fukuchi + [develop] + * .github/workflows/configure.yml: + - Added macOS CI script. + 2020.08.29 Kentaro Fukuchi [release-4.1.0] * .github/workflows/{cmake,configure,cmake-windows}.yml: @@ -12,6 +17,9 @@ - ECLEVEL check has been improved. * .gitignore: - Added 'use/test-driver'. + [master] + * merged release-4.1.0. + * version 4.1.0 has been released. 2020.08.28 Kentaro Fukuchi [develop] @@ -203,7 +211,7 @@ * qrencode.1.in, NEWS: - Release date has been updated. - Documentation updated. - * Version 4.0.0 has ben released. + * Version 4.0.0 has been released. 2017.09.11 Kentaro Fukuchi * qrenc.c: -- cgit 0.0.5-2-1-g0f52 From f4d82894b26bce541a59d1d005b9bfbb42d9cc6e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 30 Aug 2020 02:59:15 +0900 Subject: Detailed description of text output types has been added. (closes #142) --- qrenc.c | 7 ++++++- qrencode.1.in | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/qrenc.c b/qrenc.c index c09c4ab693..a45cebb577 100644 --- a/qrenc.c +++ b/qrenc.c @@ -136,7 +136,12 @@ static void usage(int help, int longopt, int status) " specify the DPI of the generated PNG. (default=72)\n\n" " -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8},\n" " --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}\n" -" specify the type of the generated image. (default=PNG)\n\n" +" specify the type of the generated image. (default=PNG)\n" +" If ASCII*, UTF8*, or ANSI* is specified, the image will be disp-\n" +" layed in the terminal by using text characters instead of gene-\n" +" rating an image file. If the name of the type is followed by\n" +" 'i', the light/dark character will be reversed, but its appear-\n" +" ance is inconsistent for historical reasons.\n\n" " -S, --structured\n" " make structured symbols. Version must be specified with '-v'.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" diff --git a/qrencode.1.in b/qrencode.1.in index c8e31da116..5ee4942d14 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -48,6 +48,11 @@ specify the DPI of the generated PNG. (default=72) .PD .B \-\-type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8} specify the type of the generated image. (default=PNG) +.br +If ASCII*, UTF8*, or ANSI* is specified, the image will be displayed in the terminal by using +text characters instead of generating an image file. If the name of the type is followed by 'i', +the light/dark character will be reversed, but its appearance is inconsistent for historical +reasons. .TP .B \-S, \-\-structured make structured symbols. Version number must be specified with '-v'. -- cgit 0.0.5-2-1-g0f52 From 3d086d493dcdb42ad0f0673cfb4c5eade057ef31 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 30 Aug 2020 03:25:48 +0900 Subject: Fixed invalid XPM output. (Thanks to @dlitz and @cbrt64) (closes #136) --- ChangeLog | 6 ++++++ README.md | 4 +++- qrenc.c | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e4553c3ea..604363c006 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ [develop] * .github/workflows/configure.yml: - Added macOS CI script. + * qrencode.1.in, qrenc.c: + - Detailed description of text output types has been added. + (closes #142) + * qrenc.c: + - Invalid XPM output has been fixed. (Thanks to @dlitz and @cbrt64) + (closes #136) 2020.08.29 Kentaro Fukuchi [release-4.1.0] diff --git a/README.md b/README.md index 5e075e7d34..2c633e80dc 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,8 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q * Rosen Penev (@neheb) - CMake bug fix patch * Mika Lindqvist (@mtl1979) - replacement for gettimeofday() for Windows. +* Darsey Litzenberger (@dlitz) and Edward E. (@cbrt64) + - fixed invalid XPM output * Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker, Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr, Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen, @@ -227,5 +229,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray, Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, - Frédéric Wang, Dan Jacobson, Jan Tojnar, @xiaoyur347, @charmander + Frédéric Wang, Dan Jacobson, Jan Tojnar, @xiaoyur347, @charmander, - bug report / suggestion / typo fixes diff --git a/qrenc.c b/qrenc.c index a45cebb577..a80699dc69 100644 --- a/qrenc.c +++ b/qrenc.c @@ -729,8 +729,9 @@ static int writeXPM(const QRcode *qrcode, const char *outfile) } for (y = 0; y < realmargin; y++) { - fprintf(fp, "\"%s\"%s\n", row, y < (size - 1) ? "," : "};"); + fprintf(fp, "\"%s\",\n", row); } + fputs("};\n", fp); free(row); fclose(fp); -- cgit 0.0.5-2-1-g0f52 From 756b28e0f34c6ee667bca203c3c9d6451ea6c962 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 30 Aug 2020 03:59:18 +0900 Subject: Typo fixes. --- mask.c | 2 +- mqrspec.c | 6 +++--- mqrspec.h | 2 +- qrinput.c | 4 ++-- qrinput.h | 2 +- qrspec.c | 6 +++--- qrspec.h | 2 +- rsecc.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mask.c b/mask.c index 4bf2371765..82a60c05e4 100644 --- a/mask.c +++ b/mask.c @@ -76,7 +76,7 @@ STATIC_IN_RELEASE int Mask_writeFormatInformation(int width, unsigned char *fram /** * Demerit coefficients. - * See Section 8.8.2, pp.45, JIS X0510:2004. + * See Section 8.8.2, p.45, JIS X0510:2004. */ #define N1 (3) #define N2 (3) diff --git a/mqrspec.c b/mqrspec.c index 87205fe970..0ecd882880 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -46,7 +46,7 @@ typedef struct { /** * Table of the capacity of symbols - * See Table 1 (pp.106) and Table 8 (pp.113) of Appendix 1, JIS X0510:2004. + * See Table 1 (p.106) and Table 8 (p.113) of Appendix 1, JIS X0510:2004. */ static const MQRspec_Capacity mqrspecCapacity[MQRSPEC_VERSION_MAX + 1] = { { 0, {0, 0, 0, 0}}, @@ -87,7 +87,7 @@ int MQRspec_getWidth(int version) *****************************************************************************/ /** - * See Table 3 (pp.107) of Appendix 1, JIS X0510:2004. + * See Table 3 (p.107) of Appendix 1, JIS X0510:2004. */ static const int lengthTableBits[4][4] = { { 3, 4, 5, 6}, @@ -127,7 +127,7 @@ static const unsigned int formatInfo[4][8] = { {0x4b1c, 0x5af7, 0x68ca, 0x7921, 0x0987, 0x186c, 0x2a51, 0x3bba} }; -/* See Table 10 of Appendix 1. (pp.115) */ +/* See Table 10 of Appendix 1. (p.115) */ static const int typeTable[MQRSPEC_VERSION_MAX + 1][3] = { {-1, -1, -1}, { 0, -1, -1}, diff --git a/mqrspec.h b/mqrspec.h index 0eaa4907f5..c8ab425080 100644 --- a/mqrspec.h +++ b/mqrspec.h @@ -140,7 +140,7 @@ extern unsigned char *MQRspec_newFrame(int version); *****************************************************************************/ /** - * Mode indicator. See Table 2 in Appendix 1 of JIS X0510:2004, pp.107. + * Mode indicator. See Table 2 in Appendix 1 of JIS X0510:2004, p.107. */ #define MQRSPEC_MODEID_NUM 0 #define MQRSPEC_MODEID_AN 1 diff --git a/qrinput.c b/qrinput.c index c8ab07bad6..454193eaec 100644 --- a/qrinput.c +++ b/qrinput.c @@ -774,7 +774,7 @@ static int QRinput_estimateBitsModeECI(unsigned char *data) ecinum = QRinput_decodeECIfromByteArray(data); - /* See Table 4 of JISX 0510:2004 pp.17. */ + /* See Table 4 of JISX 0510:2004 p.17. */ if(ecinum < 128) { return MODE_INDICATOR_SIZE + 8; } else if(ecinum < 16384) { @@ -791,7 +791,7 @@ static int QRinput_encodeModeECI(QRinput_List *entry, BitStream *bstream) ecinum = QRinput_decodeECIfromByteArray(entry->data); - /* See Table 4 of JISX 0510:2004 pp.17. */ + /* See Table 4 of JISX 0510:2004 p.17. */ if(ecinum < 128) { words = 1; code = ecinum; diff --git a/qrinput.h b/qrinput.h index 5892c48246..b1eb7f7fba 100644 --- a/qrinput.h +++ b/qrinput.h @@ -88,7 +88,7 @@ extern QRinput *QRinput_dup(QRinput *input); extern const signed char QRinput_anTable[128]; /** - * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). + * Look up the alphabet-numeric convesion table (see JIS X0510:2004, p.19). * @param __c__ character * @return value */ diff --git a/qrspec.c b/qrspec.c index f3d3b2c526..45cc1d98ba 100644 --- a/qrspec.c +++ b/qrspec.c @@ -49,7 +49,7 @@ typedef struct { /** * Table of the capacity of symbols - * See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004. + * See Table 1 (p.13) and Table 12-16 (pp.30-36), JIS X0510:2004. */ static const QRspec_Capacity qrspecCapacity[QRSPEC_VERSION_MAX + 1] = { { 0, 0, 0, { 0, 0, 0, 0}}, @@ -264,7 +264,7 @@ void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]) * This array includes only the second and the third position of the alignment * patterns. Rest of them can be calculated from the distance between them. * - * See Table 1 in Appendix E (pp.71) of JIS X0510:2004. + * See Table 1 in Appendix E (p.71) of JIS X0510:2004. */ static const int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = { { 0, 0}, @@ -351,7 +351,7 @@ static void QRspec_putAlignmentPattern(int version, unsigned char *frame, int wi /** * Version information pattern (BCH coded). - * See Table 1 in Appendix D (pp.68) of JIS X0510:2004. + * See Table 1 in Appendix D (p.68) of JIS X0510:2004. */ static const unsigned int versionPattern[QRSPEC_VERSION_MAX - 6] = { 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, diff --git a/qrspec.h b/qrspec.h index 4d01879ed3..017bb5518a 100644 --- a/qrspec.h +++ b/qrspec.h @@ -159,7 +159,7 @@ extern unsigned char *QRspec_newFrame(int version); *****************************************************************************/ /** - * Mode indicator. See Table 2 of JIS X0510:2004, pp.16. + * Mode indicator. See Table 2 of JIS X0510:2004, p.16. */ #define QRSPEC_MODEID_ECI 7 #define QRSPEC_MODEID_NUM 1 diff --git a/rsecc.c b/rsecc.c index b88cae3071..0e902fa8cd 100644 --- a/rsecc.c +++ b/rsecc.c @@ -42,7 +42,7 @@ static int initialized = 0; #define SYMBOL_SIZE (8) #define symbols ((1U << SYMBOL_SIZE) - 1) -static const unsigned int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see pp.37 of JIS X0510:2004) */ +static const unsigned int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see p.37 of JIS X0510:2004) */ /* min/max codeword length of ECC, calculated from the specification. */ #define min_length (2) -- cgit 0.0.5-2-1-g0f52 From 4051f3c51a5f2ff40f81c311c6a82ca0436c5241 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 30 Aug 2020 04:00:51 +0900 Subject: Typo fix. --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 604363c006..3986974dd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -573,7 +573,7 @@ - ACKNOWLEDGMENTS updates. [3.4] - Bumped version to 3.4.4. - * Version 3.4.4 has ben released. + * Version 3.4.4 has been released. 2014.07.08 Kentaro FUKUCHI * qrenc.c, qrinput.c, tests/test_qrinput.c: -- cgit 0.0.5-2-1-g0f52 From 5e65e462534d4852af624e1a0c15ec242f6b350f Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 30 Aug 2020 11:49:38 +0900 Subject: Variable 'demerit' is renamed to 'penalty'. --- mask.c | 42 +++++++++++++++++++++--------------------- tests/test_mask.c | 46 +++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/mask.c b/mask.c index 82a60c05e4..974c07455f 100644 --- a/mask.c +++ b/mask.c @@ -188,12 +188,12 @@ unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLeve STATIC_IN_RELEASE int Mask_calcN1N3(int length, int *runLength) { int i; - int demerit = 0; + int penalty = 0; int fact; for(i = 0; i < length; i++) { if(runLength[i] >= 5) { - demerit += N1 + (runLength[i] - 5); + penalty += N1 + (runLength[i] - 5); //n1 += N1 + (runLength[i] - 5); } if((i & 1)) { @@ -204,10 +204,10 @@ STATIC_IN_RELEASE int Mask_calcN1N3(int length, int *runLength) runLength[i+1] == fact && runLength[i+2] == fact) { if(i == 3 || runLength[i-3] >= 4 * fact) { - demerit += N3; + penalty += N3; //n3 += N3; } else if(i+4 >= length || runLength[i+3] >= 4 * fact) { - demerit += N3; + penalty += N3; //n3 += N3; } } @@ -215,7 +215,7 @@ STATIC_IN_RELEASE int Mask_calcN1N3(int length, int *runLength) } } - return demerit; + return penalty; } STATIC_IN_RELEASE int Mask_calcN2(int width, unsigned char *frame) @@ -223,7 +223,7 @@ STATIC_IN_RELEASE int Mask_calcN2(int width, unsigned char *frame) int x, y; unsigned char *p; unsigned char b22, w22; - int demerit = 0; + int penalty = 0; p = frame + width + 1; for(y = 1; y < width; y++) { @@ -231,14 +231,14 @@ STATIC_IN_RELEASE int Mask_calcN2(int width, unsigned char *frame) b22 = p[0] & p[-1] & p[-width] & p [-width-1]; w22 = p[0] | p[-1] | p[-width] | p [-width-1]; if((b22 | (w22 ^ 1))&1) { - demerit += N2; + penalty += N2; } p++; } p++; } - return demerit; + return penalty; } STATIC_IN_RELEASE int Mask_calcRunLengthH(int width, unsigned char *frame, int *runLength) @@ -300,23 +300,23 @@ STATIC_IN_RELEASE int Mask_calcRunLengthV(int width, unsigned char *frame, int * STATIC_IN_RELEASE int Mask_evaluateSymbol(int width, unsigned char *frame) { int x, y; - int demerit = 0; + int penalty = 0; int runLength[QRSPEC_WIDTH_MAX + 1]; int length; - demerit += Mask_calcN2(width, frame); + penalty += Mask_calcN2(width, frame); for(y = 0; y < width; y++) { length = Mask_calcRunLengthH(width, frame + y * width, runLength); - demerit += Mask_calcN1N3(length, runLength); + penalty += Mask_calcN1N3(length, runLength); } for(x = 0; x < width; x++) { length = Mask_calcRunLengthV(width, frame + x, runLength); - demerit += Mask_calcN1N3(length, runLength); + penalty += Mask_calcN1N3(length, runLength); } - return demerit; + return penalty; } unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) @@ -326,7 +326,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) int minDemerit = INT_MAX; int blacks; int bratio; - int demerit; + int penalty; int w2 = width * width; mask = (unsigned char *)malloc((size_t)w2); @@ -339,16 +339,16 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) for(i = 0; i < maskNum; i++) { // n1 = n2 = n3 = n4 = 0; - demerit = 0; + penalty = 0; blacks = maskMakers[i](width, frame, mask); blacks += Mask_writeFormatInformation(width, mask, i, level); bratio = (200 * blacks + w2) / w2 / 2; /* (int)(100*blacks/w2+0.5) */ - demerit = (abs(bratio - 50) / 5) * N4; -// n4 = demerit; - demerit += Mask_evaluateSymbol(width, mask); -// printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit); - if(demerit < minDemerit) { - minDemerit = demerit; + penalty = (abs(bratio - 50) / 5) * N4; +// n4 = penalty; + penalty += Mask_evaluateSymbol(width, mask); +// printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, penalty); + if(penalty < minDemerit) { + minDemerit = penalty; memcpy(bestMask, mask, (size_t)w2); } } diff --git a/tests/test_mask.c b/tests/test_mask.c index fb0c5fdd83..7ef7123251 100644 --- a/tests/test_mask.c +++ b/tests/test_mask.c @@ -142,19 +142,19 @@ static void test_eval(void) { unsigned char *frame; unsigned int w = 6; - int demerit; + int penalty; frame = (unsigned char *)malloc(w * w); testStart("Test mask evaluation (all white)"); memset(frame, 0, w * w); - demerit = Mask_evaluateSymbol(w, frame); - testEndExp(demerit == ((N1 + 1)*w*2 + N2 * (w - 1) * (w - 1))); + penalty = Mask_evaluateSymbol(w, frame); + testEndExp(penalty == ((N1 + 1)*w*2 + N2 * (w - 1) * (w - 1))); testStart("Test mask evaluation (all black)"); memset(frame, 1, w * w); - demerit = Mask_evaluateSymbol(w, frame); - testEndExp(demerit == ((N1 + 1)*w*2 + N2 * (w - 1) * (w - 1))); + penalty = Mask_evaluateSymbol(w, frame); + testEndExp(penalty == ((N1 + 1)*w*2 + N2 * (w - 1) * (w - 1))); free(frame); } @@ -174,7 +174,7 @@ static void test_eval2(void) { unsigned char *frame; unsigned int w = 10; - int demerit; + int penalty; unsigned int x; frame = (unsigned char *)malloc(w * w); @@ -192,8 +192,8 @@ static void test_eval2(void) frame[w*8 + x] = (x / 5) & 1; frame[w*9 + x] = ((x / 5) & 1) ^ 1; } - demerit = Mask_evaluateSymbol(w, frame); - testEndExp(demerit == N1 * 4 + N2 * 4); + penalty = Mask_evaluateSymbol(w, frame); + testEndExp(penalty == N1 * 4 + N2 * 4); free(frame); } @@ -202,7 +202,7 @@ static void test_calcN2(void) { unsigned char frame[64]; int width; - int demerit; + int penalty; int x, y; testStart("Test mask evaluation (2x2 block check)"); @@ -212,8 +212,8 @@ static void test_calcN2(void) frame[y * width + x] = ((x & 2) ^ (y & 2)) >> 1; } } - demerit = Mask_calcN2(width, frame); - assert_equal(demerit, N2 * 4, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 4); + penalty = Mask_calcN2(width, frame); + assert_equal(penalty, N2 * 4, "Calculation of N2 penalty is wrong: %d, expected %d", penalty, N2 * 4); width = 4; for(y = 0; y < width; y++) { @@ -221,8 +221,8 @@ static void test_calcN2(void) frame[y * width + x] = (((x + 1) & 2) ^ (y & 2)) >> 1; } } - demerit = Mask_calcN2(width, frame); - assert_equal(demerit, N2 * 2, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 2); + penalty = Mask_calcN2(width, frame); + assert_equal(penalty, N2 * 2, "Calculation of N2 penalty is wrong: %d, expected %d", penalty, N2 * 2); width = 6; for(y = 0; y < width; y++) { @@ -230,8 +230,8 @@ static void test_calcN2(void) frame[y * width + x] = (x / 3) ^ (y / 3); } } - demerit = Mask_calcN2(width, frame); - assert_equal(demerit, N2 * 16, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 16); + penalty = Mask_calcN2(width, frame); + assert_equal(penalty, N2 * 16, "Calculation of N2 penalty is wrong: %d, expected %d", penalty, N2 * 16); testFinish(); } @@ -240,7 +240,7 @@ static void test_eval3(void) { unsigned char *frame; int w = 15; - int demerit; + int penalty; int x, y; static unsigned char pattern[7][15] = { {0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0}, // N3x1 @@ -279,8 +279,8 @@ static void test_eval3(void) printf("\n"); } */ - demerit = Mask_evaluateSymbol(w, frame); - testEndExp(demerit == N3 * 10 + (N1 + 1) * 4); + penalty = Mask_evaluateSymbol(w, frame); + testEndExp(penalty == N3 * 10 + (N1 + 1) * 4); free(frame); } @@ -356,7 +356,7 @@ static void test_calcN1N3(void) { int runLength[26]; int length; - int demerit; + int penalty; int i; static unsigned char pattern[][16] = { {1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, N3}, @@ -378,13 +378,13 @@ static void test_calcN1N3(void) testStart("Test N3 penalty calculation"); for(i=0; i<6; i++) { length = Mask_calcRunLengthH(15, pattern[i], runLength); - demerit = Mask_calcN1N3(length, runLength); - assert_equal(pattern[i][15], demerit, "N3 penalty is wrong: %d, expected %d\n", demerit, pattern[i][15]); + penalty = Mask_calcN1N3(length, runLength); + assert_equal(pattern[i][15], penalty, "N3 penalty is wrong: %d, expected %d\n", penalty, pattern[i][15]); } for(i=0; i<5; i++) { length = Mask_calcRunLengthH(18, pattern2[i], runLength); - demerit = Mask_calcN1N3(length, runLength); - assert_equal(pattern2[i][18], demerit, "N3 penalty is wrong: %d, expected %d\n", demerit, pattern2[i][18]); + penalty = Mask_calcN1N3(length, runLength); + assert_equal(pattern2[i][18], penalty, "N3 penalty is wrong: %d, expected %d\n", penalty, pattern2[i][18]); } testFinish(); } -- cgit 0.0.5-2-1-g0f52 From dedc8bd7def95bcc95ce68d0065104723efaad6e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 31 Aug 2020 15:56:57 +0900 Subject: Code cleanups. --- qrinput.c | 4 ++-- tests/datachunk.c | 22 +++++++++++++--------- tests/datachunk.h | 3 +-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/qrinput.c b/qrinput.c index 454193eaec..8a45950d8f 100644 --- a/qrinput.c +++ b/qrinput.c @@ -140,7 +140,7 @@ QRinput *QRinput_newMQR(int version, QRecLevel level) QRinput *input; if(version <= 0 || version > MQRSPEC_VERSION_MAX) goto INVALID; - if((MQRspec_getECCLength(version, level) == 0)) goto INVALID; + if(MQRspec_getECCLength(version, level) == 0) goto INVALID; input = QRinput_new2(version, level); if(input == NULL) return NULL; @@ -192,7 +192,7 @@ int QRinput_setVersionAndErrorCorrectionLevel(QRinput *input, int version, QRecL { if(input->mqr) { if(version <= 0 || version > MQRSPEC_VERSION_MAX) goto INVALID; - if((MQRspec_getECCLength(version, level) == 0)) goto INVALID; + if(MQRspec_getECCLength(version, level) == 0) goto INVALID; } else { if(version < 0 || version > QRSPEC_VERSION_MAX) goto INVALID; if(level > QR_ECLEVEL_H) goto INVALID; diff --git a/tests/datachunk.c b/tests/datachunk.c index 0291c5379d..62bb2f964c 100644 --- a/tests/datachunk.c +++ b/tests/datachunk.c @@ -47,9 +47,9 @@ static void dumpAn(DataChunk *chunk) static void dump8(DataChunk *chunk) { - int i, j; + size_t i, j; unsigned char c; - int count = 0; + size_t count = 0; unsigned char buf[16]; for(i=0; isize; i++) { @@ -110,23 +110,27 @@ static void dumpChunk(DataChunk *chunk) { switch(chunk->mode) { case QR_MODE_NUM: - printf("Numeric: %d bytes\n", chunk->size); + printf("Numeric: %zu bytes\n", chunk->size); dumpNum(chunk); break; case QR_MODE_AN: - printf("AlphaNumeric: %d bytes\n", chunk->size); + printf("AlphaNumeric: %zu bytes\n", chunk->size); dumpAn(chunk); break; case QR_MODE_8: - printf("8-bit data: %d bytes\n", chunk->size); + printf("8-bit data: %zu bytes\n", chunk->size); dump8(chunk); break; case QR_MODE_KANJI: - printf("Kanji: %d bytes\n", chunk->size); + printf("Kanji: %zu bytes\n", chunk->size); dumpKanji(chunk); break; - default: - printf("Invalid or reserved: %d bytes\n", chunk->size); + case QR_MODE_NUL: + case QR_MODE_STRUCTURE: + case QR_MODE_ECI: + case QR_MODE_FNC1FIRST: + case QR_MODE_FNC1SECOND: + printf("Invalid or reserved: %zu bytes\n", chunk->size); dump8(chunk); break; } @@ -160,7 +164,7 @@ unsigned char *DataChunk_concatChunkList(DataChunk *list, int *retsize) size = DataChunk_totalSize(list); if(size <= 0) return NULL; - data = (unsigned char *)malloc(size + 1); + data = (unsigned char *)malloc((size_t)size + 1); idx = 0; while(list != NULL) { memcpy(&data[idx], list->data, list->size); diff --git a/tests/datachunk.h b/tests/datachunk.h index d4373636ee..8ef076c4fa 100644 --- a/tests/datachunk.h +++ b/tests/datachunk.h @@ -5,8 +5,7 @@ typedef struct _DataChunk { QRencodeMode mode; - int size; - int bits; + size_t size; unsigned char *data; struct _DataChunk *next; } DataChunk; -- cgit 0.0.5-2-1-g0f52 From a362e0574f8cc7cf3dbc544335c154a9e95f0fac Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 30 Aug 2020 11:46:31 +0900 Subject: A tail recursion in FrameFiller_next() has been eliminated. --- qrencode.c | 67 ++++++++++++++++++++++++--------------------------- tests/prof_qrencode.c | 4 +-- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/qrencode.c b/qrencode.c index 2cb9ca86e2..e3d6ef6185 100644 --- a/qrencode.c +++ b/qrencode.c @@ -297,57 +297,54 @@ static void FrameFiller_set(FrameFiller *filler, int width, unsigned char *frame static unsigned char *FrameFiller_next(FrameFiller *filler) { - unsigned char *p; int x, y, w; - if(filler->bit == -1) { - filler->bit = 0; - return filler->frame + filler->y * filler->width + filler->x; - } - x = filler->x; y = filler->y; - p = filler->frame; w = filler->width; + for(;;) { + if(filler->bit == -1) { + filler->bit = 0; + break; + } - if(filler->bit == 0) { - x--; - filler->bit++; - } else { - x++; - y += filler->dir; - filler->bit--; - } + if(filler->bit == 0) { + x--; + filler->bit++; + } else { + x++; + y += filler->dir; + filler->bit--; + } - if(filler->dir < 0) { - if(y < 0) { - y = 0; + if(filler->dir < 0) { + if(y < 0) { + y = 0; + x -= 2; + filler->dir = 1; + if(!filler->mqr && x == 6) { + x--; + y = 9; + } + } + } else if(y == w) { + y = w - 1; x -= 2; - filler->dir = 1; + filler->dir = -1; if(!filler->mqr && x == 6) { x--; - y = 9; + y -= 8; } } - } else if(y == w) { - y = w - 1; - x -= 2; - filler->dir = -1; - if(!filler->mqr && x == 6) { - x--; - y -= 8; + if(x < 0 || y < 0) return NULL; + + if(!(filler->frame[y * w + x] & 0x80)) { + break; } } - if(x < 0 || y < 0) return NULL; - filler->x = x; filler->y = y; - - if(p[y * w + x] & 0x80) { - // This tail recursion could be optimized. - return FrameFiller_next(filler); - } - return &p[y * w + x]; + return &filler->frame[filler->y * w + filler->x]; } #ifdef WITH_TESTS diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index dd79f9eb00..cfe4403b2d 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -59,7 +59,7 @@ static void prof_ver1to10(void) static const char *data = "This is test."; timerStart("Version 1 - 10 (500 symbols for each)"); - for(i=0; i<500; i++) { + for(i=0; i<5000; i++) { for(version = 0; version < 11; version++) { code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0); if(code == NULL) { @@ -80,7 +80,7 @@ static void prof_ver31to40(void) static const char *data = "This is test."; timerStart("Version 31 - 40 (50 symbols for each)"); - for(i=0; i<50; i++) { + for(i=0; i<500; i++) { for(version = 31; version < 41; version++) { code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0); if(code == NULL) { -- cgit 0.0.5-2-1-g0f52 From 9bd032b986330ed211effc693a033a8d785506a6 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 21 Sep 2020 22:54:32 +0900 Subject: Text message corrected. --- tests/prof_qrencode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/prof_qrencode.c b/tests/prof_qrencode.c index cfe4403b2d..8aa9a98b95 100644 --- a/tests/prof_qrencode.c +++ b/tests/prof_qrencode.c @@ -58,7 +58,7 @@ static void prof_ver1to10(void) int version; static const char *data = "This is test."; - timerStart("Version 1 - 10 (500 symbols for each)"); + timerStart("Version 1 - 10 (5000 symbols for each)"); for(i=0; i<5000; i++) { for(version = 0; version < 11; version++) { code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0); @@ -79,7 +79,7 @@ static void prof_ver31to40(void) int version; static const char *data = "This is test."; - timerStart("Version 31 - 40 (50 symbols for each)"); + timerStart("Version 31 - 40 (500 symbols for each)"); for(i=0; i<500; i++) { for(version = 31; version < 41; version++) { code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0); -- cgit 0.0.5-2-1-g0f52 From ccb21e1fbb2463c932b72b8292a7edf045e59a70 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 22 Sep 2020 00:19:43 +0900 Subject: Minor optimizations. --- ChangeLog | 10 ++++++++++ mask.c | 31 +++++++++++++++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3986974dd8..039e56a1ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020.09.21 Kentaro Fukuchi + [optimization] + * tests/prof_qrencode.c: + - Test numbers are extended. + * mask.c: + - Minor optimizations. + 2020.08.30 Kentaro Fukuchi [develop] * .github/workflows/configure.yml: @@ -8,6 +15,9 @@ * qrenc.c: - Invalid XPM output has been fixed. (Thanks to @dlitz and @cbrt64) (closes #136) + [optimization] + * qrencode.c: + - A tail recursion in FrameFiller_next() has been eliminated. 2020.08.29 Kentaro Fukuchi [release-4.1.0] diff --git a/mask.c b/mask.c index 974c07455f..0f1b7a000d 100644 --- a/mask.c +++ b/mask.c @@ -196,7 +196,7 @@ STATIC_IN_RELEASE int Mask_calcN1N3(int length, int *runLength) penalty += N1 + (runLength[i] - 5); //n1 += N1 + (runLength[i] - 5); } - if((i & 1)) { + if(i & 1) { if(i >= 3 && i < length-2 && (runLength[i] % 3) == 0) { fact = runLength[i] / 3; if(runLength[i-2] == fact && @@ -225,12 +225,12 @@ STATIC_IN_RELEASE int Mask_calcN2(int width, unsigned char *frame) unsigned char b22, w22; int penalty = 0; - p = frame + width + 1; + p = frame; for(y = 1; y < width; y++) { for(x = 1; x < width; x++) { - b22 = p[0] & p[-1] & p[-width] & p [-width-1]; - w22 = p[0] | p[-1] | p[-width] | p [-width-1]; - if((b22 | (w22 ^ 1))&1) { + b22 = (p[0] & p[1] & p[width] & p[width+1]) & 1; + w22 = (p[0] | p[1] | p[width] | p[width+1]) & 1; + if(b22 != 0 || w22 == 0) { penalty += N2; } p++; @@ -247,14 +247,12 @@ STATIC_IN_RELEASE int Mask_calcRunLengthH(int width, unsigned char *frame, int * int i; unsigned char prev; - if(frame[0] & 1) { + prev = frame[0]; + head = prev & 1; + if(head) { runLength[0] = -1; - head = 1; - } else { - head = 0; } runLength[head] = 1; - prev = frame[0]; for(i = 1; i < width; i++) { if((frame[i] ^ prev) & 1) { @@ -275,23 +273,24 @@ STATIC_IN_RELEASE int Mask_calcRunLengthV(int width, unsigned char *frame, int * int i; unsigned char prev; - if(frame[0] & 1) { + prev = frame[0]; + head = prev & 1; + if(head) { runLength[0] = -1; - head = 1; } else { - head = 0; } runLength[head] = 1; - prev = frame[0]; + frame += width; for(i = 1; i < width; i++) { - if((frame[i * width] ^ prev) & 1) { + if((*frame ^ prev) & 1) { head++; runLength[head] = 1; - prev = frame[i * width]; + prev = *frame; } else { runLength[head]++; } + frame += width; } return head + 1; -- cgit 0.0.5-2-1-g0f52 From bda0949f20af5f2e77d557ba174e531708670b7c Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 22 Sep 2020 21:16:22 +0900 Subject: Typos and grammar erros have been fixed. --- mask.c | 8 ++++---- qrencode.h | 14 +++++++------- qrinput.c | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/mask.c b/mask.c index 974c07455f..1524e160d7 100644 --- a/mask.c +++ b/mask.c @@ -75,7 +75,7 @@ STATIC_IN_RELEASE int Mask_writeFormatInformation(int width, unsigned char *fram } /** - * Demerit coefficients. + * Penalty coefficients. * See Section 8.8.2, p.45, JIS X0510:2004. */ #define N1 (3) @@ -323,7 +323,7 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) { int i; unsigned char *mask, *bestMask; - int minDemerit = INT_MAX; + int minPenalty = INT_MAX; int blacks; int bratio; int penalty; @@ -347,8 +347,8 @@ unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) // n4 = penalty; penalty += Mask_evaluateSymbol(width, mask); // printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, penalty); - if(penalty < minDemerit) { - minDemerit = penalty; + if(penalty < minPenalty) { + minPenalty = penalty; memcpy(bestMask, mask, (size_t)w2); } } diff --git a/qrencode.h b/qrencode.h index 1a934cc12c..e0b5591f9d 100644 --- a/qrencode.h +++ b/qrencode.h @@ -61,11 +61,11 @@ * symbol of the specified version. * * \section structured Structured append - * Libqrencode can generate "Structured-appended" symbols that enables to split - * a large data set into mulitple QR codes. A QR code reader concatenates + * Libqrencode can generate "Structured-appended" symbols that enable to split + * a large data set into multiple QR codes. A QR code reader concatenates * multiple QR code symbols into a string. * Just like QRcode_encodeString(), you can use QRcode_encodeStringStructured() - * to generate structured-appended symbols. This functions returns an instance + * to generate structured-appended symbols. This function returns an instance * of ::QRcode_List. The returned list is a singly-linked list of QRcode: you * can retrieve each QR code in this way: * @@ -191,7 +191,7 @@ extern QRinput *QRinput_newMQR(int version, QRecLevel level); * @param size size of data (byte). * @param data a pointer to the memory area of the input data. * @retval 0 success. - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. * @throw EINVAL input data is invalid. @@ -204,7 +204,7 @@ extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const uns * @param input input object. * @param ecinum ECI indicator number (0 - 999999) * @retval 0 success. - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. * @throw EINVAL input data is invalid. @@ -332,7 +332,7 @@ extern QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input); * a parity and set it if the parity is not set yet. * @param s input structure * @retval 0 success. - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw EINVAL invalid input object. * @throw ENOMEM unable to allocate memory. @@ -411,7 +411,7 @@ extern QRcode *QRcode_encodeInput(QRinput *input); * @param hint tell the library how Japanese Kanji characters should be * encoded. If QR_MODE_KANJI is given, the library assumes that the * given string contains Shift-JIS characters and encodes them in - * Kanji-mode. If QR_MODE_8 is given, all of non-alphanumerical + * Kanji-mode. If QR_MODE_8 is given, all non-alphanumerical * characters will be encoded as is. If you want to embed UTF-8 * string, choose this. Other mode will cause EINVAL error. * @param casesensitive case-sensitive(1) or not(0). diff --git a/qrinput.c b/qrinput.c index 8a45950d8f..5a74b5a6d4 100644 --- a/qrinput.c +++ b/qrinput.c @@ -241,7 +241,7 @@ int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned c * @param number index number of the symbol. (1 <= number <= size) * @param parity parity among input data. (NOTE: each symbol of a set of structured symbols has the same parity data) * @retval 0 success. - * @retval -1 error occurred and errno is set to indeicate the error. See Execptions for the details. + * @retval -1 error occurred and errno is set to indicate the error. See Execptions for the details. * @throw EINVAL invalid parameter. * @throw ENOMEM unable to allocate memory. */ @@ -404,7 +404,7 @@ int QRinput_estimateBitsModeNum(int size) * @param entry * @param mqr * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ @@ -509,7 +509,7 @@ int QRinput_estimateBitsModeAn(int size) * @param entry * @param mqr * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. * @throw EINVAL invalid version. @@ -573,7 +573,7 @@ int QRinput_estimateBitsMode8(int size) * @param entry * @param mqr * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ @@ -647,7 +647,7 @@ static int QRinput_checkModeKanji(int size, const unsigned char *data) * @param entry * @param mqr * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. * @throw EINVAL invalid version. @@ -699,7 +699,7 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int * @param entry * @param mqr * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. * @throw EINVAL invalid entry. @@ -1073,7 +1073,7 @@ ABORT: * Convert the input data to a bit stream. * @param input input data. * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. */ @@ -1100,7 +1100,7 @@ static int QRinput_createBitStream(QRinput *input, BitStream *bstream) * @param input input data. * @param bstream where the converted data is stored. * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ENOMEM unable to allocate memory. * @throw ERANGE input data is too large. @@ -1135,7 +1135,7 @@ static int QRinput_convertData(QRinput *input, BitStream *bstream) * @param bstream Bitstream to be appended. * @param input input data. * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ERANGE input data is too large. * @throw ENOMEM unable to allocate memory. @@ -1184,7 +1184,7 @@ static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input) * @param bstream Bitstream to be appended. * @param input input data. * @retval 0 success - * @retval -1 an error occurred and errno is set to indeicate the error. + * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. * @throw ERANGE input data is too large. * @throw ENOMEM unable to allocate memory. -- cgit 0.0.5-2-1-g0f52 From 2e91a7d03675020ecfcab715108b0183f3982a03 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Sep 2020 17:14:33 +0900 Subject: Minor memory leak bug in a test case has been fixed. --- ChangeLog | 11 +++++++++++ tests/test_qrencode.c | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 039e56a1ec..49920ed405 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2020.09.26 Kentaro Fukuchi + [develop] + * tests/test_qrencode.c: + - Minor memory leak bug in a test case has been fixed. + +2020.09.22 Kentaro Fukuchi + [develop] + * mask.c, qrencode.h: + - Typos and grammer errors have been fixed. + * Merge branch 'optimization'. + 2020.09.21 Kentaro Fukuchi [optimization] * tests/prof_qrencode.c: diff --git a/tests/test_qrencode.c b/tests/test_qrencode.c index 0de41bd00c..589b9b18ef 100644 --- a/tests/test_qrencode.c +++ b/tests/test_qrencode.c @@ -685,12 +685,24 @@ static void test_encodeTooLongMQR(void) code = QRcode_encodeStringMQR(data[0], 1, QR_ECLEVEL_L, QR_MODE_8, 0); assert_nonnull(code, "6 byte length numeric string should be accepted to version 2 or larger.\n"); assert_equal(code->version, 2, "6 byte length numeric string should be accepted to version 2.\n"); + if(code != NULL) { + QRcode_free(code); + } + code = QRcode_encodeStringMQR(data[1], 2, QR_ECLEVEL_L, QR_MODE_8, 0); assert_nonnull(code, "7 byte length alphanumeric string should be accepted to version 3 or larger.\n"); assert_equal(code->version, 3, "7 byte length alphanumeric string should be accepted to version 3.\n"); + if(code != NULL) { + QRcode_free(code); + } + code = QRcode_encodeString8bitMQR(data[2], 3, QR_ECLEVEL_L); assert_nonnull(code, "9 byte length 8bit string should be accepted to version 4.\n"); assert_equal(code->version, 4, "9 byte length 8bit string should be accepted to version 4.\n"); + if(code != NULL) { + QRcode_free(code); + } + code = QRcode_encodeString8bitMQR(data[3], 4, QR_ECLEVEL_L); assert_null(code, "16 byte length 8bit string was accepted to version 4.\n"); assert_equal(errno, ERANGE, "errno != ERANGE\n"); -- cgit 0.0.5-2-1-g0f52 From 8b0c2701783bfbd3819546024f6a7f4bea9b8c89 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Sep 2020 17:47:37 +0900 Subject: Various documentation updates. --- COPYING | 68 ++++++++++++++++++++++++++--------------------------------- ChangeLog | 6 ++++++ README.md | 2 +- qrenc.c | 8 +++---- qrencode.1.in | 2 +- qrencode.c | 2 +- qrencode.h | 2 +- 7 files changed, 44 insertions(+), 46 deletions(-) diff --git a/COPYING b/COPYING index 2d2d780e60..4362b49151 100644 --- a/COPYING +++ b/COPYING @@ -1,9 +1,8 @@ - GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -23,8 +22,7 @@ specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. +strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that @@ -89,9 +87,9 @@ libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. @@ -138,8 +136,8 @@ included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. +interface definition files, plus the scripts used to control compilation +and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of @@ -305,10 +303,10 @@ of these things: the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above @@ -386,10 +384,9 @@ all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any @@ -407,11 +404,11 @@ be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. @@ -465,15 +462,13 @@ DAMAGES. If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms -of the ordinary General Public License). - - To apply these terms, attach the following notices to the library. -It is safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. Copyright (C) @@ -490,21 +485,18 @@ notice is found. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. -You should also get your employer (if you work as a programmer) or -your school, if any, to sign a "copyright disclaimer" for the library, -if necessary. Here is a sample; alter the names: +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James - Random Hacker. + library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! - - diff --git a/ChangeLog b/ChangeLog index 49920ed405..888d1683a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ [develop] * tests/test_qrencode.c: - Minor memory leak bug in a test case has been fixed. + * COPYING: + - Updated to the latest revision. + * qrenc.c: + - Some URLs' schemes have been updated to https from http. + * README.md, qrenc.c, qrencode.1.in, qrencode.[ch]: + - Copyright year has been updated. 2020.09.22 Kentaro Fukuchi [develop] diff --git a/README.md b/README.md index 2c633e80dc..cec4dcfd87 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ application. LICENSING INFORMATION ===================== -Copyright (C) 2006-2018 Kentaro Fukuchi +Copyright (C) 2006-2018, 2020 Kentaro Fukuchi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free diff --git a/qrenc.c b/qrenc.c index a80699dc69..48157cc7b1 100644 --- a/qrenc.c +++ b/qrenc.c @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code encoding tool - * Copyright (C) 2006-2017 Kentaro Fukuchi + * Copyright (C) 2006-2018, 2020 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -107,7 +107,7 @@ static void usage(int help, int longopt, int status) FILE *out = status ? stderr : stdout; fprintf(out, "qrencode version %s\n" -"Copyright (C) 2006-2017 Kentaro Fukuchi\n", QRcode_APIVersionString()); +"Copyright (C) 2006-2018, 2020 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { if(longopt) { fprintf(out, @@ -176,7 +176,7 @@ static void usage(int help, int longopt, int status) " of modules, ranging from Version 1 (21 x 21 modules) up to\n" " Version 40 (177 x 177 modules). Each higher version number\n" " comprises 4 additional modules per side by default. See\n" -" http://www.qrcode.com/en/about/version.html for a detailed\n" +" https://www.qrcode.com/en/about/version.html for a detailed\n" " version list.\n" ); @@ -575,7 +575,7 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) be problematic. In particular, DTDs do not handle namespaces gracefully. It is *not* recommended that a DOCTYPE declaration be included in SVG documents." - http://www.w3.org/TR/2003/REC-SVG11-20030114/intro.html#Namespace + https://www.w3.org/TR/2003/REC-SVG11-20030114/intro.html#Namespace */ /* Vanity remark */ diff --git a/qrencode.1.in b/qrencode.1.in index 5ee4942d14..d662db3c29 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -138,4 +138,4 @@ Main Web Site: https://fukuchi.org/works/qrencode/ Source code repository: https://github.com/fukuchi/libqrencode/ .SH COPYRIGHT -Copyright (C) 2006-2018 Kentaro Fukuchi. +Copyright (C) 2006-2018, 2020 Kentaro Fukuchi. diff --git a/qrencode.c b/qrencode.c index e3d6ef6185..70d0503f66 100644 --- a/qrencode.c +++ b/qrencode.c @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Copyright (C) 2006-2017 Kentaro Fukuchi + * Copyright (C) 2006-2018, 2020 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/qrencode.h b/qrencode.h index e0b5591f9d..039176577b 100644 --- a/qrencode.h +++ b/qrencode.h @@ -1,7 +1,7 @@ /** * qrencode - QR Code encoder * - * Copyright (C) 2006-2017 Kentaro Fukuchi + * Copyright (C) 2006-2018, 2020 Kentaro Fukuchi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public -- cgit 0.0.5-2-1-g0f52 From b7c942eed0e6a0e80df296aeaec0ad9db27a0ebd Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Sep 2020 17:50:57 +0900 Subject: Workflow names have been improved. --- .github/workflows/cmake-windows.yml | 2 +- .github/workflows/cmake.yml | 2 +- .github/workflows/configure.yml | 2 +- ChangeLog | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index ef0e051190..325f3a758a 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -1,4 +1,4 @@ -name: CMake +name: CMake-build (Windows) on: [push, pull_request] diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index ac588566eb..4855871dec 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,4 +1,4 @@ -name: CMake +name: CMake-build on: [push] diff --git a/.github/workflows/configure.yml b/.github/workflows/configure.yml index 20d634c03e..fa6ace4a22 100644 --- a/.github/workflows/configure.yml +++ b/.github/workflows/configure.yml @@ -1,4 +1,4 @@ -name: configure CI +name: build on: [push, pull_request] diff --git a/ChangeLog b/ChangeLog index 888d1683a1..c0994b2d96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ - Some URLs' schemes have been updated to https from http. * README.md, qrenc.c, qrencode.1.in, qrencode.[ch]: - Copyright year has been updated. + * .github/workflows/{configure,cmake,cmake-windows}.yml: + - Workflow names have been improved. 2020.09.22 Kentaro Fukuchi [develop] -- cgit 0.0.5-2-1-g0f52 From 2191b17cb4932561f30bcc009f04a8f82785dde9 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Sep 2020 18:22:58 +0900 Subject: Status badge has been changed to show the result from the Github Actions. --- README.md | 3 ++- makeREADME.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cec4dcfd87..c92c8efa9c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# libqrencode - a fast and compact QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) +# libqrencode - a fast and compact QR Code encoding library +[![build](https://github.com/fukuchi/libqrencode/workflows/build/badge.svg)](https://github.com/fukuchi/libqrencode/actions) **Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.1.0. diff --git a/makeREADME.sh b/makeREADME.sh index d34dd8380e..d42e152d27 100755 --- a/makeREADME.sh +++ b/makeREADME.sh @@ -1,10 +1,10 @@ #!/bin/sh sed '/^```$/d +/badge\.svg/{N;d;} /^\*\*Attention/d s/DWITH\\_TESTS/DWITH_TESTS/ 1 { s/^# // - s/encoding library.*/encoding library/ } ' README.md > README -- cgit 0.0.5-2-1-g0f52 From 8cc18937b28ff58b7ec3a05ff9a49c6128f6e8ef Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sat, 26 Sep 2020 18:34:10 +0900 Subject: CI scripts have been improved. --- .github/workflows/cmake-windows.yml | 53 ------------------------------------- .github/workflows/cmake.yml | 42 +++++++++++++++++------------ .travis.yml | 25 ----------------- ChangeLog | 7 +++++ 4 files changed, 32 insertions(+), 95 deletions(-) delete mode 100644 .github/workflows/cmake-windows.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml deleted file mode 100644 index 325f3a758a..0000000000 --- a/.github/workflows/cmake-windows.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: CMake-build (Windows) - -on: [push, pull_request] - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - -jobs: - build: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - - name: run vcpkg - uses: lukka/run-vcpkg@v3 - with: - vcpkgArguments: getopt:x64-windows libiconv:x64-windows libpng:x64-windows - vcpkgDirectory: '${{ github.workspace }}/vcpkg' - vcpkgGitCommitId: 'fca18ba3572f8aebe3b8158c359db62a7e26134e' - - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands - run: cmake -E make_directory ${{runner.workspace}}/build - - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{runner.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DWITH_TESTS=yes - - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE - - - name: Test - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C $BUILD_TYPE diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 4855871dec..6cbf04d154 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,46 +1,54 @@ name: CMake-build -on: [push] +on: [push, pull_request] env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release jobs: build: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v2 + - name: run vcpkg + if: matrix.os == 'windows-latest' + uses: lukka/run-vcpkg@v3 + with: + vcpkgArguments: getopt:x64-windows libiconv:x64-windows libpng:x64-windows + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgGitCommitId: 'fca18ba3572f8aebe3b8158c359db62a7e26134e' + + - name: brew setup + if: matrix.os == 'macos-latest' + run: brew install pkg-config libpng + - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands run: cmake -E make_directory ${{runner.workspace}}/build - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system + if: matrix.os != 'windows-latest' shell: bash working-directory: ${{runner.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_TESTS=yes -DBUILD_SHARED_LIBS=on + - name: Configure CMake for Windows + if: matrix.os == 'windows-latest' + shell: bash + working-directory: ${{runner.workspace}}/build + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DWITH_TESTS=yes + + - name: Build working-directory: ${{runner.workspace}}/build shell: bash - # Execute the build. You can specify a specific target with "--target " run: cmake --build . --config $BUILD_TYPE - name: Test working-directory: ${{runner.workspace}}/build shell: bash - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail run: ctest -C $BUILD_TYPE diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9d21088df4..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -dist: trusty -sudo: required -language: c - -compiler: -- gcc - -before_install: -- sudo apt-get update -- sudo apt-get install libpng12-dev - -install: -- ./autogen.sh -- ./configure --with-tests && make -- sudo make install -- mkdir build && cd build -- cmake .. -DWITH_TESTS=yes -DBUILD_SHARED_LIBS=on && make -- DESTDIR=$PWD/install make install - -script: -- cd $TRAVIS_BUILD_DIR/tests -- ./test_all.sh -- cd $TRAVIS_BUILD_DIR/build/tests -- cp $TRAVIS_BUILD_DIR/tests/frame ./ -- make test diff --git a/ChangeLog b/ChangeLog index c0994b2d96..497f8ed00b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,13 @@ - Copyright year has been updated. * .github/workflows/{configure,cmake,cmake-windows}.yml: - Workflow names have been improved. + * .travis.yml: + - Migration to Github Actions has been completed. + * .github/workflows/{configure,cmake,cmake-windows}.yml: + - CI scripts have been improved. + * README.md, makeREADME.sh: + - Status badge has been changed to show the result from the Github Actions + instead of Travis CI. 2020.09.22 Kentaro Fukuchi [develop] -- cgit 0.0.5-2-1-g0f52 From 32a5f2001a159f26628d38ef04c9e19a82d191f6 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 27 Sep 2020 00:28:41 +0900 Subject: All tab characters have been replaced with spaces. --- NEWS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 7b56724e50..afc63645f2 100644 --- a/NEWS +++ b/NEWS @@ -4,10 +4,10 @@ libqrencode NEWS - Overview of changes Version 4.1.0 (2020.8.29) ------------------------- * Command line tool "qrencode" has been improved: - * New option "--inline" has been added. (Thanks to @jp-bennett) - * New option "--strict-version" has been added. - * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- - Szentkirályi) + * New option "--inline" has been added. (Thanks to @jp-bennett) + * New option "--strict-version" has been added. + * UTF8 mode now supports ANSI256 color. (Thanks to András Veres- + Szentkirályi) * Micro QR Code no longer requires to specify the version number. * 'make check' allows to run the test programs. (Thanks to Jan Tojnar) * Some compile time warnings have been fixed. @@ -40,11 +40,11 @@ Version 4.0.0 (2017.9.21) * QRcode_clearCache() has been deprecated. * Error correction code generating functions have been improved. * Command line tool "qrencode" has been improved: - * XPM support. (Thanks to Tobias Klauser) - * PNG32 (direct color mode) support. (Thanks to Greg Hart) - * EPS output now supports foreground and background color. - * New options "-r" and "--svg-path" have been added. - (Thanks to Robert Petersen and @Oblomov) + * XPM support. (Thanks to Tobias Klauser) + * PNG32 (direct color mode) support. (Thanks to Greg Hart) + * EPS output now supports foreground and background color. + * New options "-r" and "--svg-path" have been added. + (Thanks to Robert Petersen and @Oblomov) * CMake support has been added. (optional) (Thanks to @misery) * Various bug fixes. * Various performance improvements. -- cgit 0.0.5-2-1-g0f52 From e5ac8ca929ce643497b26e97c18b14b12ccf1122 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 27 Sep 2020 00:30:01 +0900 Subject: The effects of '--type' option's 'ASCII' and 'ASCIIi' have been swapped. (closes #142) --- ChangeLog | 8 ++++++++ NEWS | 8 ++++++++ README.md | 1 + qrenc.c | 7 +++---- qrencode.1.in | 3 +-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 497f8ed00b..674a2af36d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2020.09.27 Kentaro Fukuchi + [develop] + * NEWS: + - All tab characters have been replaced with spaces. + * qrenc.c, qrencode.1.in: + - The effects of '--type' option's 'ASCII' and 'ASCIIi' have been + swapped. (closes #142) + 2020.09.26 Kentaro Fukuchi [develop] * tests/test_qrencode.c: diff --git a/NEWS b/NEWS index afc63645f2..548406154c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,14 @@ libqrencode NEWS - Overview of changes ====================================== +Version x.x.x (2020.xx.xx) +-------------------------- +* Command line tool "qrencode" has been improved: + * The effects of '--type' option's 'ASCII' and 'ASCIIi' have been swapped. + (Thanks to Yannick Schinko) +* Some minor bug fixes. (Thanks to Darsey Litzenberger and Edward E.) +* Some performance improvements. + Version 4.1.0 (2020.8.29) ------------------------- * Command line tool "qrencode" has been improved: diff --git a/README.md b/README.md index c92c8efa9c..4f3b1c51dc 100644 --- a/README.md +++ b/README.md @@ -231,4 +231,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, Frédéric Wang, Dan Jacobson, Jan Tojnar, @xiaoyur347, @charmander, + Yannick Schinko - bug report / suggestion / typo fixes diff --git a/qrenc.c b/qrenc.c index 48157cc7b1..0c6dfe858d 100644 --- a/qrenc.c +++ b/qrenc.c @@ -140,8 +140,7 @@ static void usage(int help, int longopt, int status) " If ASCII*, UTF8*, or ANSI* is specified, the image will be disp-\n" " layed in the terminal by using text characters instead of gene-\n" " rating an image file. If the name of the type is followed by\n" -" 'i', the light/dark character will be reversed, but its appear-\n" -" ance is inconsistent for historical reasons.\n\n" +" 'i', the light/dark character will be reversed.\n" " -S, --structured\n" " make structured symbols. Version must be specified with '-v'.\n\n" " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n" @@ -1074,10 +1073,10 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil writeANSI(qrcode, outfile); break; case ASCIIi_TYPE: - writeASCII(qrcode, outfile, 1); + writeASCII(qrcode, outfile, 0); break; case ASCII_TYPE: - writeASCII(qrcode, outfile, 0); + writeASCII(qrcode, outfile, 1); break; case UTF8_TYPE: writeUTF8(qrcode, outfile, 0, 0); diff --git a/qrencode.1.in b/qrencode.1.in index d662db3c29..c61e0b1ad9 100644 --- a/qrencode.1.in +++ b/qrencode.1.in @@ -51,8 +51,7 @@ specify the type of the generated image. (default=PNG) .br If ASCII*, UTF8*, or ANSI* is specified, the image will be displayed in the terminal by using text characters instead of generating an image file. If the name of the type is followed by 'i', -the light/dark character will be reversed, but its appearance is inconsistent for historical -reasons. +the light/dark character will be reversed. .TP .B \-S, \-\-structured make structured symbols. Version number must be specified with '-v'. -- cgit 0.0.5-2-1-g0f52 From 178fb4b77cb37c386b737c81c8b4ba5dc686c260 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 27 Sep 2020 00:49:20 +0900 Subject: CI scripts have been improved to utilize multiple cores. --- .github/workflows/cmake.yml | 3 ++- .github/workflows/configure.yml | 4 ++-- ChangeLog | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6cbf04d154..134bbb08d5 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -22,6 +22,7 @@ jobs: vcpkgArguments: getopt:x64-windows libiconv:x64-windows libpng:x64-windows vcpkgDirectory: '${{ github.workspace }}/vcpkg' vcpkgGitCommitId: 'fca18ba3572f8aebe3b8158c359db62a7e26134e' + appendedCacheKey: ${{ hashFiles( '${{ github.workspace }}/.github/workflows/cmake.yml' ) }} - name: brew setup if: matrix.os == 'macos-latest' @@ -46,7 +47,7 @@ jobs: - name: Build working-directory: ${{runner.workspace}}/build shell: bash - run: cmake --build . --config $BUILD_TYPE + run: cmake --build . --config $BUILD_TYPE -j 2 - name: Test working-directory: ${{runner.workspace}}/build diff --git a/.github/workflows/configure.yml b/.github/workflows/configure.yml index fa6ace4a22..6fcf4d1a13 100644 --- a/.github/workflows/configure.yml +++ b/.github/workflows/configure.yml @@ -19,8 +19,8 @@ jobs: - name: configure run: ./configure --with-tests - name: make - run: make + run: make -j 2 - name: make check run: make check - name: make distcheck - run: make distcheck + run: make -j 2 distcheck diff --git a/ChangeLog b/ChangeLog index 674a2af36d..118b37c2f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ * qrenc.c, qrencode.1.in: - The effects of '--type' option's 'ASCII' and 'ASCIIi' have been swapped. (closes #142) + * .github/workflows/{configure,cmake}.yml: + - CI scripts have been improved to utilze multiple cores and cache. 2020.09.26 Kentaro Fukuchi [develop] -- cgit 0.0.5-2-1-g0f52 From e9936a3098ece94ac1fe79b509ccb730422874c8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 27 Sep 2020 02:17:26 +0900 Subject: Code cleanups. --- ChangeLog | 2 ++ tests/test_basic.sh | 1 + tests/test_qrenc.sh | 3 --- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 118b37c2f9..ee47db21cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ swapped. (closes #142) * .github/workflows/{configure,cmake}.yml: - CI scripts have been improved to utilze multiple cores and cache. + * tests/{test_basic.sh, test_qrenc.sh}: + - Code cleanups. 2020.09.26 Kentaro Fukuchi [develop] diff --git a/tests/test_basic.sh b/tests/test_basic.sh index 06de1d4b02..6d90180ee3 100755 --- a/tests/test_basic.sh +++ b/tests/test_basic.sh @@ -6,6 +6,7 @@ ./test_qrspec ./test_rs ./test_split +./test_split_urls ./test_mask ./test_mqrspec ./test_mmask diff --git a/tests/test_qrenc.sh b/tests/test_qrenc.sh index 8f09f26a32..8c39c6a9aa 100755 --- a/tests/test_qrenc.sh +++ b/tests/test_qrenc.sh @@ -1,7 +1,6 @@ #!/bin/sh COMMAND=../qrencode -TARGET_DIR="test_images" VALGRIND_COMMAND="libtool --mode=execute valgrind" VALGRIND_OPTIONS="--leak-check=full --show-reachable=yes" @@ -34,8 +33,6 @@ test_command_fail() fi } -mkdir -p $TARGET_DIR - test_command_success '1' 7089 test_command_success 'A' 4296 test_command_success 'a' 2953 -- cgit 0.0.5-2-1-g0f52 From 8368fb7a803e414fad0ccc6216b6bac0083e037d Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Sun, 27 Sep 2020 16:40:35 +0900 Subject: Cleanup compiler warnings. --- mqrspec.c | 4 ++-- qrenc.c | 57 +++++++++++++++++++++--------------------------- qrencode.c | 10 ++++----- qrinput.c | 60 +++++++++++++++++++++++++-------------------------- qrinput.h | 2 +- qrspec.c | 16 +++++++------- rsecc.c | 4 ++-- split.c | 8 +++---- tests/common.c | 13 ++++------- tests/common.h | 2 +- tests/rsecc_decoder.c | 4 ++-- tests/rsecc_decoder.h | 2 +- 12 files changed, 85 insertions(+), 97 deletions(-) diff --git a/mqrspec.c b/mqrspec.c index 0ecd882880..6dbc9e11a2 100644 --- a/mqrspec.c +++ b/mqrspec.c @@ -155,8 +155,8 @@ unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level) /** * Put a finder pattern. - * @param frame - * @param width + * @param frame destination frame data + * @param width frame width * @param ox,oy upper-left coordinate of the pattern */ static void putFinderPattern(unsigned char *frame, int width, int ox, int oy) diff --git a/qrenc.c b/qrenc.c index 0c6dfe858d..a5b93719e6 100644 --- a/qrenc.c +++ b/qrenc.c @@ -215,7 +215,7 @@ static void usage(int help, int longopt, int status) static int color_set(unsigned char color[4], const char *value) { - int len = strlen(value); + int len = (int)strlen(value); int i, count; unsigned int col[4]; if(len == 6) { @@ -224,7 +224,7 @@ static int color_set(unsigned char color[4], const char *value) return -1; } for(i = 0; i < 3; i++) { - color[i] = col[i]; + color[i] = (unsigned char)col[i]; } color[3] = 255; } else if(len == 8) { @@ -233,7 +233,7 @@ static int color_set(unsigned char color[4], const char *value) return -1; } for(i = 0; i < 4; i++) { - color[i] = col[i]; + color[i] = (unsigned char)col[i]; } } else { return -1; @@ -247,7 +247,7 @@ static unsigned char *readFile(FILE *fp, int *length) { int ret; - ret = fread(data_buffer, 1, MAX_DATA_SIZE, fp); + ret = (int)fread(data_buffer, 1, MAX_DATA_SIZE, fp); if(ret == 0) { fprintf(stderr, "No input data.\n"); exit(EXIT_FAILURE); @@ -385,8 +385,8 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty PNG_FILTER_TYPE_DEFAULT); } png_set_pHYs(png_ptr, info_ptr, - dpi * INCHES_PER_METER, - dpi * INCHES_PER_METER, + (png_uint_32)(dpi * INCHES_PER_METER), + (png_uint_32)(dpi * INCHES_PER_METER), PNG_RESOLUTION_METER); png_write_info(png_ptr, info_ptr); @@ -494,15 +494,15 @@ static int writeEPS(const QRcode *qrcode, const char *outfile) /* set color */ fprintf(fp, "gsave\n"); fprintf(fp, "%f %f %f setrgbcolor\n", - (float)bg_color[0] / 255, - (float)bg_color[1] / 255, - (float)bg_color[2] / 255); + (double)bg_color[0] / 255, + (double)bg_color[1] / 255, + (double)bg_color[2] / 255); fprintf(fp, "%d %d scale\n", realwidth, realwidth); fprintf(fp, "0 0 p\ngrestore\n"); fprintf(fp, "%f %f %f setrgbcolor\n", - (float)fg_color[0] / 255, - (float)fg_color[1] / 255, - (float)fg_color[2] / 255); + (double)fg_color[0] / 255, + (double)fg_color[1] / 255, + (double)fg_color[2] / 255); fprintf(fp, "%d %d scale\n", size, size); /* data */ @@ -524,7 +524,7 @@ static int writeEPS(const QRcode *qrcode, const char *outfile) return 0; } -static void writeSVG_drawModules(FILE *fp, int x, int y, int width, const char* col, float opacity) +static void writeSVG_drawModules(FILE *fp, int x, int y, int width, const char* col, double opacity) { if(svg_path) { fprintf(fp, "M%d,%dh%d", x, y, width); @@ -547,10 +547,10 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) unsigned char *row, *p; int x, y, x0, pen; int symwidth, realwidth; - float scale; + double scale; char fg[7], bg[7]; - float fg_opacity; - float bg_opacity; + double fg_opacity; + double bg_opacity; fp = openFile(outfile); @@ -561,8 +561,8 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) snprintf(fg, 7, "%02x%02x%02x", fg_color[0], fg_color[1], fg_color[2]); snprintf(bg, 7, "%02x%02x%02x", bg_color[0], bg_color[1], bg_color[2]); - fg_opacity = (float)fg_color[3] / 255; - bg_opacity = (float)bg_color[3] / 255; + fg_opacity = (double)fg_color[3] / 255; + bg_opacity = (double)bg_color[3] / 255; /* XML declaration */ if (!inline_svg) @@ -585,7 +585,7 @@ static int writeSVG(const QRcode *qrcode, const char *outfile) "\n", - realwidth / scale, realwidth / scale, symwidth, symwidth + (double)realwidth / scale, (double)realwidth / scale, symwidth, symwidth ); /* Make named group */ @@ -1021,12 +1021,12 @@ static QRcode *encode(const unsigned char *intext, int length) if(eightbit) { code = QRcode_encodeDataMQR(length, intext, version, level); } else { - code = QRcode_encodeStringMQR((char *)intext, version, level, hint, casesensitive); + code = QRcode_encodeStringMQR((const char *)intext, version, level, hint, casesensitive); } } else if(eightbit) { code = QRcode_encodeData(length, intext, version, level); } else { - code = QRcode_encodeString((char *)intext, version, level, hint, casesensitive); + code = QRcode_encodeString((const char *)intext, version, level, hint, casesensitive); } return code; @@ -1093,9 +1093,6 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil case ANSIUTF8i_TYPE: writeUTF8(qrcode, outfile, 1, 1); break; - default: - fprintf(stderr, "Unknown image type.\n"); - exit(EXIT_FAILURE); } QRcode_free(qrcode); @@ -1108,7 +1105,7 @@ static QRcode_List *encodeStructured(const unsigned char *intext, int length) if(eightbit) { list = QRcode_encodeDataStructured(length, intext, version, level); } else { - list = QRcode_encodeStringStructured((char *)intext, version, level, hint, casesensitive); + list = QRcode_encodeStringStructured((const char *)intext, version, level, hint, casesensitive); } return list; @@ -1232,10 +1229,6 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case ANSIUTF8i_TYPE: writeUTF8(p->code, filename, 0, 1); break; - - default: - fprintf(stderr, "Unknown image type.\n"); - exit(EXIT_FAILURE); } i++; } @@ -1409,15 +1402,15 @@ int main(int argc, char **argv) if(optind < argc) { intext = (unsigned char *)argv[optind]; - length = strlen((char *)intext); + length = (int)strlen((char *)intext); } if(intext == NULL) { - fp = infile == NULL ? stdin : fopen(infile,"r"); + fp = infile == NULL ? stdin : fopen(infile, "r"); if(fp == 0) { fprintf(stderr, "Cannot read input file %s.\n", infile); exit(EXIT_FAILURE); } - intext = readFile(fp,&length); + intext = readFile(fp, &length); } diff --git a/qrencode.c b/qrencode.c index 70d0503f66..3ac1e9b171 100644 --- a/qrencode.c +++ b/qrencode.c @@ -703,7 +703,7 @@ QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level errno = EINVAL; return NULL; } - return QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), version, level, 0); + return QRcode_encodeDataReal((const unsigned char *)string, (int)strlen(string), version, level, 0); } QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level) @@ -733,7 +733,7 @@ QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel le version = 1; } for(i = version; i <= MQRSPEC_VERSION_MAX; i++) { - QRcode *code = QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), i, level, 1); + QRcode *code = QRcode_encodeDataReal((const unsigned char *)string, (int)strlen(string), i, level, 1); if(code != NULL) return code; } @@ -874,7 +874,7 @@ static QRcode_List *QRcode_encodeDataStructuredReal( if(eightbit) { ret = QRinput_append(input, QR_MODE_8, size, data); } else { - ret = Split_splitStringToQRinput((char *)data, input, hint, casesensitive); + ret = Split_splitStringToQRinput((const char *)data, input, hint, casesensitive); } if(ret < 0) { QRinput_free(input); @@ -895,7 +895,7 @@ QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, errno = EINVAL; return NULL; } - return QRcode_encodeDataStructured((int)strlen(string), (unsigned char *)string, version, level); + return QRcode_encodeDataStructured((int)strlen(string), (const unsigned char *)string, version, level); } QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) @@ -904,7 +904,7 @@ QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRec errno = EINVAL; return NULL; } - return QRcode_encodeDataStructuredReal((int)strlen(string), (unsigned char *)string, version, level, 0, hint, casesensitive); + return QRcode_encodeDataStructuredReal((int)strlen(string), (const unsigned char *)string, version, level, 0, hint, casesensitive); } /****************************************************************************** diff --git a/qrinput.c b/qrinput.c index 5a74b5a6d4..762ad8b3a4 100644 --- a/qrinput.c +++ b/qrinput.c @@ -245,7 +245,7 @@ int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned c * @throw EINVAL invalid parameter. * @throw ENOMEM unable to allocate memory. */ -STATIC_IN_RELEASE int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int number, unsigned char parity) +STATIC_IN_RELEASE int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int number, int parity) { QRinput_List *entry; unsigned char buf[3]; @@ -261,7 +261,7 @@ STATIC_IN_RELEASE int QRinput_insertStructuredAppendHeader(QRinput *input, int s buf[0] = (unsigned char)size; buf[1] = (unsigned char)number; - buf[2] = parity; + buf[2] = (unsigned char)parity; entry = QRinput_List_newEntry(QR_MODE_STRUCTURE, 3, buf); if(entry == NULL) { return -1; @@ -357,8 +357,8 @@ QRinput *QRinput_dup(QRinput *input) /** * Check the input data. - * @param size - * @param data + * @param size size of the input data. + * @param data input data. * @return result */ static int QRinput_checkModeNum(int size, const char *data) @@ -375,7 +375,7 @@ static int QRinput_checkModeNum(int size, const char *data) /** * Estimate the length of the encoded bit stream of numeric data. - * @param size + * @param size size of the input data. * @return number of bits */ int QRinput_estimateBitsModeNum(int size) @@ -401,8 +401,8 @@ int QRinput_estimateBitsModeNum(int size) /** * Convert the number data and append to a bit stream. - * @param entry - * @param mqr + * @param entry input data. + * @param mqr give 1 if generating Micro QR Code. * @retval 0 success * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. @@ -469,8 +469,8 @@ const signed char QRinput_anTable[128] = { /** * Check the input data. - * @param size - * @param data + * @param size size of the input data. + * @param data input data. * @return result */ static int QRinput_checkModeAn(int size, const char *data) @@ -487,7 +487,7 @@ static int QRinput_checkModeAn(int size, const char *data) /** * Estimate the length of the encoded bit stream of alphabet-numeric data. - * @param size + * @param size size of the input data. * @return number of bits */ int QRinput_estimateBitsModeAn(int size) @@ -506,8 +506,8 @@ int QRinput_estimateBitsModeAn(int size) /** * Convert the alphabet-numeric data and append to a bit stream. - * @param entry - * @param mqr + * @param entry input data. + * @param mqr give 1 if generating Micro QR Code. * @retval 0 success * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. @@ -560,7 +560,7 @@ static int QRinput_encodeModeAn(QRinput_List *entry, BitStream *bstream, int ver /** * Estimate the length of the encoded bit stream of 8 bit data. - * @param size + * @param size size of the input data. * @return number of bits */ int QRinput_estimateBitsMode8(int size) @@ -570,8 +570,8 @@ int QRinput_estimateBitsMode8(int size) /** * Convert the 8bits data and append to a bit stream. - * @param entry - * @param mqr + * @param entry input data. + * @param mqr give 1 if generating Micro QR Code. * @retval 0 success * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. @@ -610,7 +610,7 @@ static int QRinput_encodeMode8(QRinput_List *entry, BitStream *bstream, int vers /** * Estimate the length of the encoded bit stream of kanji data. - * @param size + * @param size size of the input data. * @return number of bits */ int QRinput_estimateBitsModeKanji(int size) @@ -620,8 +620,8 @@ int QRinput_estimateBitsModeKanji(int size) /** * Check the input data. - * @param size - * @param data + * @param size size of the input data. + * @param data input data. * @return result */ static int QRinput_checkModeKanji(int size, const unsigned char *data) @@ -644,8 +644,8 @@ static int QRinput_checkModeKanji(int size, const unsigned char *data) /** * Convert the kanji data and append to a bit stream. - * @param entry - * @param mqr + * @param entry input data. + * @param mqr give 1 if generating Micro QR Code. * @retval 0 success * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. @@ -696,8 +696,8 @@ static int QRinput_encodeModeKanji(QRinput_List *entry, BitStream *bstream, int /** * Convert a structure symbol code and append to a bit stream. - * @param entry - * @param mqr + * @param entry input data. + * @param mqr give 1 if generating Micro QR Code. * @retval 0 success * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. @@ -850,9 +850,9 @@ int QRinput_check(QRencodeMode mode, int size, const unsigned char *data) /** * Estimate the length of the encoded bit stream on the current version. - * @param entry + * @param entry input data. * @param version version of the symbol - * @param mqr + * @param mqr give 1 if generating Micro QR Code. * @return number of bits */ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version, int mqr) @@ -953,9 +953,9 @@ STATIC_IN_RELEASE int QRinput_estimateVersion(QRinput *input) /** * Return required length in bytes for specified mode, version and bits. - * @param mode - * @param version - * @param bits + * @param mode encode mode. + * @param version version of the symbol. + * @param bits length of the input data in bits. * @return required length of code words in bytes. */ STATIC_IN_RELEASE int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits) @@ -1006,8 +1006,8 @@ STATIC_IN_RELEASE int QRinput_lengthOfCode(QRencodeMode mode, int version, int b /** * Convert the input data in the data chunk and append to a bit stream. - * @param entry - * @param bstream + * @param entry input data. + * @param [out] bstream destination BitStream. * @return number of bits (>0) or -1 for failure. */ static int QRinput_encodeBitStream(QRinput_List *entry, BitStream *bstream, int version, int mqr) @@ -1098,7 +1098,7 @@ static int QRinput_createBitStream(QRinput *input, BitStream *bstream) * When the version number is given and that is not sufficient, it is increased * automatically. * @param input input data. - * @param bstream where the converted data is stored. + * @param bstream Bitstream to be appended. * @retval 0 success * @retval -1 an error occurred and errno is set to indicate the error. * See Execptions for the details. diff --git a/qrinput.h b/qrinput.h index b1eb7f7fba..d1d3b25977 100644 --- a/qrinput.h +++ b/qrinput.h @@ -118,7 +118,7 @@ extern int QRinput_estimateBitStreamSize(QRinput *input, int version); extern int QRinput_splitEntry(QRinput_List *entry, int bytes); extern int QRinput_estimateVersion(QRinput *input); extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); -extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); +extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, int parity); #endif #endif /* QRINPUT_H */ diff --git a/qrspec.c b/qrspec.c index 45cc1d98ba..1232c0e0be 100644 --- a/qrspec.c +++ b/qrspec.c @@ -41,10 +41,10 @@ *****************************************************************************/ typedef struct { - int width; //< Edge length of the symbol - int words; //< Data capacity (bytes) - int remainder; //< Remainder bit (bits) - int ec[4]; //< Number of ECC code (bytes) + int width; ///< Edge length of the symbol + int words; ///< Data capacity (bytes) + int remainder; ///< Remainder bit (bits) + int ec[4]; ///< Number of ECC code (bytes) } QRspec_Capacity; /** @@ -280,8 +280,8 @@ static const int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = { /** * Put an alignment marker. - * @param frame - * @param width + * @param frame destination frame data + * @param width frame width * @param ox,oy center coordinate of the pattern */ static void QRspec_putAlignmentMarker(unsigned char *frame, int width, int ox, int oy) @@ -393,8 +393,8 @@ unsigned int QRspec_getFormatInfo(int mask, QRecLevel level) /** * Put a finder pattern. - * @param frame - * @param width + * @param frame destination frame data + * @param width frame width * @param ox,oy upper-left coordinate of the pattern */ static void putFinderPattern(unsigned char *frame, int width, int ox, int oy) diff --git a/rsecc.c b/rsecc.c index 0e902fa8cd..95be0f00c5 100644 --- a/rsecc.c +++ b/rsecc.c @@ -63,8 +63,8 @@ static void RSECC_initLookupTable(void) b = 1; for(i = 0; i < symbols; i++) { - alpha[i] = b; - aindex[b] = i; + alpha[i] = (unsigned char)b; + aindex[b] = (unsigned char)i; b <<= 1; if(b & (symbols + 1)) { b ^= proot; diff --git a/split.c b/split.c index a79bf03854..9975128a5e 100644 --- a/split.c +++ b/split.c @@ -112,7 +112,7 @@ static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint) } } - ret = QRinput_append(input, QR_MODE_NUM, run, (unsigned char *)string); + ret = QRinput_append(input, QR_MODE_NUM, run, (const unsigned char *)string); if(ret < 0) return -1; return run; @@ -160,7 +160,7 @@ static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint) } } - ret = QRinput_append(input, QR_MODE_AN, run, (unsigned char *)string); + ret = QRinput_append(input, QR_MODE_AN, run, (const unsigned char *)string); if(ret < 0) return -1; return run; @@ -177,7 +177,7 @@ static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint) p += 2; } run = (int)(p - string); - ret = QRinput_append(input, QR_MODE_KANJI, run, (unsigned char *)string); + ret = QRinput_append(input, QR_MODE_KANJI, run, (const unsigned char *)string); if(ret < 0) return -1; return run; @@ -245,7 +245,7 @@ static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint) } run = (int)(p - string); - ret = QRinput_append(input, QR_MODE_8, run, (unsigned char *)string); + ret = QRinput_append(input, QR_MODE_8, run, (const unsigned char *)string); if(ret < 0) return -1; return run; diff --git a/tests/common.c b/tests/common.c index 3d9f3041b8..696a94b3a5 100644 --- a/tests/common.c +++ b/tests/common.c @@ -51,9 +51,9 @@ int cmpBin(char *correct, BitStream *bstream) return ncmpBin(correct, bstream, len); } -void testInit(int tests) +void testInit(int testnum) { - printf("1..%d\n", tests); + printf("1..%d\n", testnum); } void testStartReal(const char *func, const char *name) @@ -95,14 +95,9 @@ void testReport(int expectedTests) } } -int testNum(void) +void printBinary(unsigned char *data, size_t length) { - return tests; -} - -void printBinary(unsigned char *data, int length) -{ - int i; + size_t i; for(i=0; i Date: Sun, 27 Sep 2020 17:17:41 +0900 Subject: Text output bug of structured append has been fixed. --- ChangeLog | 7 +++++++ qrenc.c | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee47db21cd..957a9e6e97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,13 @@ - CI scripts have been improved to utilze multiple cores and cache. * tests/{test_basic.sh, test_qrenc.sh}: - Code cleanups. + [code cleanups] + * various files: + - Cleanup compiler warnings. + [develop] + * Merged 'code cleanups' branch. + * qrenc.c: + - Text output bug of structured append has been fixed. 2020.09.26 Kentaro Fukuchi [develop] diff --git a/qrenc.c b/qrenc.c index a5b93719e6..1ce8c989b0 100644 --- a/qrenc.c +++ b/qrenc.c @@ -1072,12 +1072,12 @@ static void qrencode(const unsigned char *intext, int length, const char *outfil case ANSI256_TYPE: writeANSI(qrcode, outfile); break; - case ASCIIi_TYPE: - writeASCII(qrcode, outfile, 0); - break; case ASCII_TYPE: writeASCII(qrcode, outfile, 1); break; + case ASCIIi_TYPE: + writeASCII(qrcode, outfile, 0); + break; case UTF8_TYPE: writeUTF8(qrcode, outfile, 0, 0); break; @@ -1122,6 +1122,7 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch switch(image_type) { case PNG_TYPE: + case PNG32_TYPE: type_suffix = ".png"; break; case EPS_TYPE: @@ -1135,16 +1136,15 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch break; case ANSI_TYPE: case ANSI256_TYPE: + case ANSI256UTF8_TYPE: case ASCII_TYPE: + case ASCIIi_TYPE: case UTF8_TYPE: case ANSIUTF8_TYPE: case UTF8i_TYPE: case ANSIUTF8i_TYPE: type_suffix = ".txt"; break; - default: - fprintf(stderr, "Unknown image type.\n"); - exit(EXIT_FAILURE); } if(outfile == NULL) { @@ -1208,26 +1208,26 @@ static void qrencodeStructured(const unsigned char *intext, int length, const ch case ANSI256_TYPE: writeANSI(p->code, filename); break; - case ASCIIi_TYPE: + case ASCII_TYPE: writeASCII(p->code, filename, 1); break; - case ASCII_TYPE: + case ASCIIi_TYPE: writeASCII(p->code, filename, 0); break; case UTF8_TYPE: writeUTF8(p->code, filename, 0, 0); break; case ANSIUTF8_TYPE: - writeUTF8(p->code, filename, 0, 0); + writeUTF8(p->code, filename, 1, 0); break; case ANSI256UTF8_TYPE: - writeUTF8(p->code, filename, 0, 0); + writeUTF8(p->code, filename, 2, 0); break; case UTF8i_TYPE: writeUTF8(p->code, filename, 0, 1); break; case ANSIUTF8i_TYPE: - writeUTF8(p->code, filename, 0, 1); + writeUTF8(p->code, filename, 1, 1); break; } i++; -- cgit 0.0.5-2-1-g0f52 From d6f495ad3cb03458084fe5363e0556fbc37447c8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 28 Sep 2020 02:37:46 +0900 Subject: Fixed some minor bugs in Micro QR Code generation. --- ChangeLog | 9 +++++++++ qrinput.c | 8 ++++++-- tests/test_estimatebit.c | 26 +++++++++++++++++++++++++- tests/test_qrinput.c | 36 +++++++++++++++++++++++++++++++++++- 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7126e1944f..8d6bdd318f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2020.09.28 Kentaro Fukuchi + [hotfix] + * qrinput.c, tests/test_estimatebit.c: + - Fixed a bug in the estimation of the Micro QR Code's data length + in QRinput_estimateBitStreamSizeOfEntry() has been fixed. + - Fixed a bug in the calculation of the Micro QR Code's data capacity in + QRinput_encodeBitStream(). + - A test case to test the bugs above has been added. + 2020.08.29 Kentaro Fukuchi [release-4.1.0] * .github/workflows/{cmake,configure,cmake-windows}.yml: diff --git a/qrinput.c b/qrinput.c index c8ab07bad6..d0c066a311 100644 --- a/qrinput.c +++ b/qrinput.c @@ -890,7 +890,7 @@ static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version } if(mqr) { - l = QRspec_lengthIndicator(entry->mode, version); + l = MQRspec_lengthIndicator(entry->mode, version); m = version - 1; bits += l + m; } else { @@ -1018,7 +1018,11 @@ static int QRinput_encodeBitStream(QRinput_List *entry, BitStream *bstream, int prevsize = (int)BitStream_size(bstream); - words = QRspec_maximumWords(entry->mode, version); + if(mqr) { + words = MQRspec_maximumWords(entry->mode, version); + } else { + words = QRspec_maximumWords(entry->mode, version); + } if(words != 0 && entry->size > words) { st1 = QRinput_List_newEntry(entry->mode, words, entry->data); if(st1 == NULL) goto ABORT; diff --git a/tests/test_estimatebit.c b/tests/test_estimatebit.c index 3e797e4cd8..8392ed813a 100644 --- a/tests/test_estimatebit.c +++ b/tests/test_estimatebit.c @@ -139,11 +139,34 @@ static void test_mix(void) QRinput_free(gstream); } +/* Taken from JISX 0510:2018, p.23 */ +static void test_numbit1_mqr(void) +{ + QRinput *stream; + char *str = "0123456789012345"; + int bits; + + testStart("Estimation of Numeric stream for Micro QR Code (16 digits)"); + stream = QRinput_newMQR(3, QR_ECLEVEL_M); + QRinput_append(stream, QR_MODE_NUM, 16, (const unsigned char *)str); + bits = QRinput_estimateBitStreamSize(stream, QRinput_getVersion(stream)); + assert_equal(bits, 61, "Estimated bit length is wrong: %d, expected: %d.\n", bits, 61); + QRinput_free(stream); + + stream = QRinput_newMQR(4, QR_ECLEVEL_M); + QRinput_append(stream, QR_MODE_NUM, 16, (const unsigned char *)str); + bits = QRinput_estimateBitStreamSize(stream, QRinput_getVersion(stream)); + assert_equal(bits, 63, "Estimated bit length is wrong: %d, expected: %d.\n", bits, 63); + QRinput_free(stream); + + testFinish(); +} + int main() { gstream = QRinput_new(); - int tests = 8; + int tests = 9; testInit(tests); test_numbit(); test_numbit2(); @@ -153,6 +176,7 @@ int main() test_kanji(); test_structure(); test_mix(); + test_numbit1_mqr(); testReport(tests); return 0; diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index 0009007d18..b1ac5a981e 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -889,6 +889,38 @@ static void test_estimateVersionBoundaryCheck(void) testFinish(); } +static void test_QRinput_new_invalid(void) +{ + testStart("Invalid input to QRinput_new2()"); + QRinput *input; + + input = QRinput_new2(-1, QR_ECLEVEL_H); + assert_null(input, "QRinput_new2() returns non-null for invalid version (-1).\n"); + assert_equal(errno, EINVAL, "Error code is not EINVAL.\n"); + input = QRinput_new2(41, QR_ECLEVEL_H); + assert_null(input, "QRinput_new2() returns non-null for invalid version (41).\n"); + assert_equal(errno, EINVAL, "Error code is not EINVAL.\n"); + input = QRinput_new2(1, -1); + assert_null(input, "QRinput_new2() returns non-null for invalid level (-1).\n"); + assert_equal(errno, EINVAL, "Error code is not EINVAL.\n"); + input = QRinput_new2(1, 5); + assert_null(input, "QRinput_new2() returns non-null for invalid level (5).\n"); + assert_equal(errno, EINVAL, "Error code is not EINVAL.\n"); + testFinish(); +} + +static void test_QRinput_getErrorCorrectionLevel(void) +{ + testStart("Invalid input to QRinput_getErrorCorrectionLevel()"); + QRinput *input; + QRecLevel level; + + input = QRinput_new2(1, QR_ECLEVEL_H); + level = QRinput_getErrorCorrectionLevel(input); + assert_equal(level, QR_ECLEVEL_H, "QRinput_getErrorCorrectionLevel() fails to return expected level.\n"); + testFinish(); +} + static void test_mqr_new(void) { QRinput *input; @@ -1044,7 +1076,7 @@ static void test_encodeECI(void) int main() { - int tests = 40; + int tests = 42; testInit(tests); test_encodeNumeric(); @@ -1078,6 +1110,8 @@ int main() test_parity2(); test_null_free(); test_estimateVersionBoundaryCheck(); + test_QRinput_new_invalid(); + test_QRinput_getErrorCorrectionLevel(); test_mqr_new(); test_mqr_setversion(); -- cgit 0.0.5-2-1-g0f52 From 50b3e5725cafccfde038c0833cdaa5b1c28491e2 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 28 Sep 2020 03:01:27 +0900 Subject: Bumped version to 4.1.1. --- CMakeLists.txt | 2 +- ChangeLog | 1 + NEWS | 6 ++++++ README.md | 2 +- configure.ac | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f7fe4bfd8..773e037492 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1.0) -project(QRencode VERSION 4.1.0 LANGUAGES C) +project(QRencode VERSION 4.1.1 LANGUAGES C) option(WITH_TOOLS "Build utility tools" YES ) option(WITH_TESTS "Build tests" NO ) diff --git a/ChangeLog b/ChangeLog index 8d6bdd318f..6bb84f9266 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ - Fixed a bug in the calculation of the Micro QR Code's data capacity in QRinput_encodeBitStream(). - A test case to test the bugs above has been added. + * Bumped version to 4.1.1. 2020.08.29 Kentaro Fukuchi [release-4.1.0] diff --git a/NEWS b/NEWS index 7b56724e50..63e32fa182 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ libqrencode NEWS - Overview of changes ====================================== +Version 4.1.1 (2020.9.28) +------------------------- +* Some minor bugs in Micro QR Code generation have been fixed. + * The data capacity calculations are now correct. These bugs probably did not + affect the Micro QR Code generation. + Version 4.1.0 (2020.8.29) ------------------------- * Command line tool "qrencode" has been improved: diff --git a/README.md b/README.md index 5e075e7d34..dbbfe097df 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # libqrencode - a fast and compact QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode) -**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.1.0. +**Attention:** This repository contains the development version of libqrencode. See for the official stable releases. At this moment, the latest stable release is version 4.1.1. GENERAL INFORMATION =================== diff --git a/configure.ac b/configure.ac index 72dd9d852c..c4ef27ab38 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ m4_define([__MAJOR_VERSION], [4])dnl m4_define([__MINOR_VERSION], [1])dnl -m4_define([__MICRO_VERSION], [0])dnl +m4_define([__MICRO_VERSION], [1])dnl m4_define([__VERSION], [__MAJOR_VERSION.__MINOR_VERSION.__MICRO_VERSION])dnl AC_INIT(QRencode, __VERSION) -- cgit 0.0.5-2-1-g0f52 From ee6e2d6d881564c49a0ce44ac1bb5161b19edfef Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 28 Sep 2020 04:15:22 +0900 Subject: Release checker script has been added. --- ChangeLog | 6 ++++++ tests/release_check.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 tests/release_check.sh diff --git a/ChangeLog b/ChangeLog index 957a9e6e97..1fdf71d3ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020.09.28 Kentaro Fukuchi + [develop] + * tests/release_check.sh: + - Release checker script has been added. Currently it checks only the + version numbers among scripts. + 2020.09.27 Kentaro Fukuchi [develop] * NEWS: diff --git a/tests/release_check.sh b/tests/release_check.sh new file mode 100755 index 0000000000..531ee96ed8 --- /dev/null +++ b/tests/release_check.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# check version numbers between configure.ac and CMakeLists.txt. + +Configure_major_version=`sed -e '1{s/^.*\[\([0-9]\+\)\].*$/\1/};1!d' ../configure.ac` +Configure_minor_version=`sed -e '2{s/^.*\[\([0-9]\+\)\].*$/\1/};2!d' ../configure.ac` +Configure_micro_version=`sed -e '3{s/^.*\[\([0-9]\+\)\].*$/\1/};3!d' ../configure.ac` + +Configure_version_string="$Configure_major_version.$Configure_minor_version.$Configure_micro_version" + +Cmake_version_string=`grep project ../CMakeLists.txt | sed 's/^.*VERSION \([^ ]\+\) .*$/\1/'` + +if [ "$Configure_version_string" != "$Cmake_version_string" ]; then + echo "ERROR: Version number defined in configure.ac is not equal to the number defined in CMakeLists.txt." + echo "configure.ac: $Configure_version_string" + echo "CMakeLists.txt: $Cmake_version_string" + exit 1 +fi + +NEWS_version_string=`grep -m 1 Version ../NEWS | sed 's/^Version \([^ ]\+\) (.*$/\1/'` + +if [ "$Configure_version_string" != "$NEWS_version_string" ]; then + echo "ERROR: Version number defined in configure.ac is not equal to the newest number described in NEWS." + echo "configure.ac: $Configure_version_string" + echo "NEWS: $NEWS_version_string" + exit 1 +fi -- cgit 0.0.5-2-1-g0f52 From 9ea13e31582060824eb43cae9540c9a4f9073d7e Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 28 Sep 2020 04:40:21 +0900 Subject: README.md check has been added. --- tests/release_check.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/release_check.sh b/tests/release_check.sh index 531ee96ed8..8c52f07e04 100755 --- a/tests/release_check.sh +++ b/tests/release_check.sh @@ -14,7 +14,6 @@ if [ "$Configure_version_string" != "$Cmake_version_string" ]; then echo "ERROR: Version number defined in configure.ac is not equal to the number defined in CMakeLists.txt." echo "configure.ac: $Configure_version_string" echo "CMakeLists.txt: $Cmake_version_string" - exit 1 fi NEWS_version_string=`grep -m 1 Version ../NEWS | sed 's/^Version \([^ ]\+\) (.*$/\1/'` @@ -23,5 +22,12 @@ if [ "$Configure_version_string" != "$NEWS_version_string" ]; then echo "ERROR: Version number defined in configure.ac is not equal to the newest number described in NEWS." echo "configure.ac: $Configure_version_string" echo "NEWS: $NEWS_version_string" - exit 1 +fi + +README_version_string=`grep -m 1 Attention ../README.md | sed 's/^.*version \([^ ]\+\)\.$/\1/'` + +if [ "$Configure_version_string" != "$README_version_string" ]; then + echo "ERROR: Version number defined in configure.ac is not equal to the newest number described in README.md." + echo "configure.ac: $Configure_version_string" + echo "README.md: $README_version_string" fi -- cgit 0.0.5-2-1-g0f52 From 715e29fd4cd71b6e452ae0f4e36d917b43122ce8 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 28 Sep 2020 14:42:00 +0900 Subject: Level check failure in QRinput_new2() on Windows has been fixed. --- ChangeLog | 1 + qrinput.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6bb84f9266..e7bf3ab06b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ - Fixed a bug in the calculation of the Micro QR Code's data capacity in QRinput_encodeBitStream(). - A test case to test the bugs above has been added. + - Level check failure in QRinput_new2() on Windows has been fixed. * Bumped version to 4.1.1. 2020.08.29 Kentaro Fukuchi diff --git a/qrinput.c b/qrinput.c index d0c066a311..34bedc2a0c 100644 --- a/qrinput.c +++ b/qrinput.c @@ -117,7 +117,7 @@ QRinput *QRinput_new2(int version, QRecLevel level) { QRinput *input; - if(version < 0 || version > QRSPEC_VERSION_MAX || level > QR_ECLEVEL_H) { + if(version < 0 || version > QRSPEC_VERSION_MAX || level < 0 || level > QR_ECLEVEL_H) { errno = EINVAL; return NULL; } -- cgit 0.0.5-2-1-g0f52 From 02b01564a7732f28982c78e6bd78759757f7a2f1 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Mon, 28 Sep 2020 22:45:44 +0900 Subject: '--enable-mudflap' option has been deleted. (mudflap is deprecated since GCC 4.9) --- ChangeLog | 3 +++ NEWS | 20 ++++++++++++++++++++ configure.ac | 14 -------------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8462de20ac..5f8c899166 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,9 @@ * tests/release_check.sh: - Release checker script has been added. Currently it checks only the version numbers among scripts. + * configure.ac: + - '--enable-mudflap' option has been deleted. (mudflap is deprecated + since GCC 4.9) 2020.09.27 Kentaro Fukuchi [develop] diff --git a/NEWS b/NEWS index 6fb70cd5e9..aa9aba274d 100644 --- a/NEWS +++ b/NEWS @@ -9,12 +9,14 @@ Version x.x.x (2020.xx.xx) * Some minor bug fixes. (Thanks to Darsey Litzenberger and Edward E.) * Some performance improvements. + Version 4.1.1 (2020.9.28) ------------------------- * Some minor bugs in Micro QR Code generation have been fixed. * The data capacity calculations are now correct. These bugs probably did not affect the Micro QR Code generation. + Version 4.1.0 (2020.8.29) ------------------------- * Command line tool "qrencode" has been improved: @@ -87,6 +89,7 @@ inserted unnecessary chunk to the symbol and some QR Code readers fail to read it. Now the library omits the chunk and generate a symbol identical to non- structured symbol. + Version 3.4.3 (2013.8.12) ------------------------- * New option "--rle" has been added to the command line tool (Thanks to Daniel @@ -102,6 +105,7 @@ but it makes complicated to edit the image by SVG editors. A newly introduced command line option "--rle" enables RLE. RLE will not be applied if it is not given. + Version 3.4.2 (2013.3.1) ------------------------ * Bug fix release. (Thanks to chisj, vlad417, Petr and Viona) @@ -111,6 +115,7 @@ Micro QR Code encoder had a bug that caused incorrect output (issue #25). Now the bug has been fixed. Memory leak bug (#24) and insufficient string splitting bug have been fixed. + Version 3.4.1 (2012.10.17) -------------------------- * Bug fix release. @@ -120,6 +125,7 @@ Mutual exclusion did not work correctly since 3.3.1. If your application uses libqrencode in multithreaded environment, it is strongly recommended to update it. + Version 3.4.0 (2012.10.15) -------------------------- * SVG, UTF8, and ANSIUTF8 output supports have been added to the command line @@ -134,11 +140,13 @@ elements for high-resolution text output. Long-awaited colored QR code has been introduced. Try "--foreground" and "--background" options to set the colors. Currently PNG and SVG supports colored output. + Version 3.3.1 (2012.4.18) ------------------------- * Bugs in command line tool, manual, configure script, and libtool files have been fixed. (Thanks to Yutaka Niibe and Rob Ryan) + Version 3.3.0 (2012.4.1) ------------------------- * EPS, ANSI, and ASCII text output supports have been added. @@ -153,11 +161,13 @@ to get an ASCII-mode symbol in inverted color. QRcode_APIVersion() is requested by Matthew Baker for better support of Python ctypes binding. Check them out at https://code.google.com/p/libqrencode-ctypes/ + Version 3.2.1 (2012.4.1) ------------------------ * Bugs in configure script and libtool file has been fixed. (Thanks to Yutaka Niibe) + Version 3.2.0 (2011.11.26) -------------------------- * "--dpi" (or "-d") option has been added to qrencode. This option set DPI @@ -186,6 +196,7 @@ Experimental support of Micro QR Code encoder has been added. Some functions (QRcode_*MQR()) have been added to the library. The command line tool generates Micro QR Code when "--micro" or "-M" is given. + Version 3.1.1 (2010.2.3) ------------------------ * A bug in the library has been fixed. @@ -196,6 +207,7 @@ version 5 (error correction level Q and H) were affected. In many cases this bug did not cause serious damage thanks to the error correction mechanism, but we highly recommend you to encode symbols again using this release. + Version 3.1.0 (2009.6.6) ------------------------ * Various code cleanups and performance improves. @@ -212,6 +224,7 @@ applications that includes only qrencode.h. If your application refers the internal data representation (not recommended), see ChangeLog for further information. + Version 3.0.3 (2008.6.1) ------------------------ * Portability enhancement. (Thanks to Gavan Fantom) @@ -233,6 +246,7 @@ qrencode-3.0.3-gnulib, that contains the source code of the getopt_long(). Gnulib version is a test release. If you feel happy with it, please let us know and the future releases will include gnulib. + Version 3.0.2 (2008.5.18) ------------------------- * Some compile-time warnings/errors with g++ have been fixed. @@ -241,11 +255,13 @@ Version 3.0.2 (2008.5.18) Symbols greater than version 6 were affected. (Thanks to Paul Janssesn) * The "--without-tests" option has been added to the configure script. + Version 3.0.1 (2008.5.9) ------------------------ * A bug fix for non-POSIX platform. (Thanks to Paul Janssens) * The RPM spec file now packages the man page correctly. + Version 3.0.0 (2008.4.30) ------------------------- * The interface of QRencode_encodeInput() has been changed. User applications @@ -294,6 +310,7 @@ API changes: - QRinput_getVersion - QRinput_setVersion + Version 2.0.0 (2008.1.24) ------------------------- * "-i" option to ignore case distinctions has been added to qrencode and @@ -325,16 +342,19 @@ going to use this library. Many thanks to NANKI Haruo for his suggestions. + Version 1.0.2 (2007.03.24) -------------------------- * A small bug fix. (Thanks to NANKI Haruo) * 'extern "C"' barrier has been added to qrencode.h. + Version 1.0.1 (2006.12.27) -------------------------- * Added "force 8-bit encoding mode". * Configure script finds libpng's header correctly. + Version 1.0.0 (2006.12.12) -------------------------- * The first public release. diff --git a/configure.ac b/configure.ac index c4ef27ab38..bc1d024d9b 100644 --- a/configure.ac +++ b/configure.ac @@ -126,20 +126,6 @@ if test x$enable_gcov = xyes; then fi -dnl --enable-mudflap -AC_ARG_ENABLE([mudflap], [AS_HELP_STRING([--enable-mudflap], [generate extra code to check memory leaks [default=no]])], - [], [enable_mudflap=no]) - -if test x$enable_mudflap = xyes; then - if test x$enable_thread_safety = xyes; then - CFLAGS="$CFLAGS -fmudflapth" - LDFLAGS="$LDFLAGS -lmudflapth" - else - CFLAGS="$CFLAGS -fmudflap" - LDFLAGS="$LDFLAGS -lmudflap" - fi -fi - dnl --enable-asan AC_ARG_ENABLE([asan], [AS_HELP_STRING([--enable-asan], [use AddressSanitizer [default=no]])], [], [enable_asan=no]) -- cgit 0.0.5-2-1-g0f52 From 7c8dcced8e2463ac0aa5b4bfc5f9d0d4912dadbe Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 29 Sep 2020 00:04:17 +0900 Subject: Comments for QRcode_APIVersion() has been slightly improved. --- ChangeLog | 2 ++ qrencode.h | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f8c899166..146174b9b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,8 @@ * configure.ac: - '--enable-mudflap' option has been deleted. (mudflap is deprecated since GCC 4.9) + * qrencode.h: + - Comments for QRcode_APIVersion() has been slightly improved. 2020.09.27 Kentaro Fukuchi [develop] diff --git a/qrencode.h b/qrencode.h index 039176577b..1c66f336c4 100644 --- a/qrencode.h +++ b/qrencode.h @@ -538,10 +538,11 @@ extern void QRcode_List_free(QRcode_List *qrlist); *****************************************************************************/ /** - * Return a string that identifies the library version. - * @param major_version major version number - * @param minor_version minor version number - * @param micro_version micro version number + * Return the major.minor.micro version numbers that identifies the + * library version. + * @param major_version a pointer where to store the major version number + * @param minor_version a pointer where to store the minor version number + * @param micro_version a pointer where to store the micro version number */ extern void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version); -- cgit 0.0.5-2-1-g0f52 From 06bfbfd48db68e3acaedbc771b5100fa03dfd499 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 29 Sep 2020 11:57:36 +0900 Subject: Removed unused code. --- ChangeLog | 5 +++++ qrencode.c | 14 -------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 146174b9b1..0553a84520 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020.09.29 Kentaro Fukuchi + [develop] + * qrencode.c: + - Removed unused code. + 2020.09.28 Kentaro Fukuchi [hotfix] * qrinput.c, tests/test_estimatebit.c: diff --git a/qrencode.c b/qrencode.c index 3ac1e9b171..948d1626ce 100644 --- a/qrencode.c +++ b/qrencode.c @@ -790,20 +790,6 @@ int QRcode_List_size(QRcode_List *qrlist) return size; } -#if 0 -static unsigned char QRcode_parity(const char *str, int size) -{ - unsigned char parity = 0; - int i; - - for(i = 0; i < size; i++) { - parity ^= str[i]; - } - - return parity; -} -#endif - QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s) { QRcode_List *head = NULL; -- cgit 0.0.5-2-1-g0f52 From 0db94b7764f4433d3600191ad49daedbdd2ca73b Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Tue, 29 Sep 2020 11:59:18 +0900 Subject: Added a sample code snippet to the document. --- ChangeLog | 2 ++ qrencode.h | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0553a84520..ba479e32dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ [develop] * qrencode.c: - Removed unused code. + * qrencode.h: + - Added a sample code snippet to the document. 2020.09.28 Kentaro Fukuchi [hotfix] diff --git a/qrencode.h b/qrencode.h index 1c66f336c4..3460866321 100644 --- a/qrencode.h +++ b/qrencode.h @@ -60,6 +60,27 @@ * In such cases, the input data would be too large to be encoded in a * symbol of the specified version. * + * The following code snippet demonstrates how to use the obtained object: + * + * \code + * QRcode *qrcode; + * + * qrcode = QRcode_encodeString("TEST", 0, QR_ECLEVEL_M, QR_MODE_8, 1); + * if(qrcode == NULL) abort(); + * + * for(int y = 0; y < qrcode->width; y++) { + * for(int x = 0; x < qrcode->width; x++) { + * if(qrcode->data[y * qrcode->width + x] & 1) { + * draw_black_dot(x, y); + * } else { + * draw_white_dot(x, y); + * } + * } + * } + * + * QRcode_free(qrcode); + * \endcode + * * \section structured Structured append * Libqrencode can generate "Structured-appended" symbols that enable to split * a large data set into multiple QR codes. A QR code reader concatenates @@ -371,6 +392,9 @@ extern int QRinput_setFNC1Second(QRinput *input, unsigned char appid); |`------- finder pattern and separator `-------- non-data modules (format, timing, etc.) @endverbatim + * + * See \ref result section for a sample code snippet that shows how to use the + * obtained QRcode object. */ typedef struct { int version; ///< version of the symbol -- cgit 0.0.5-2-1-g0f52 From 848d717a682744510fe4b318d06c4b1c3d45eb04 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 8 Jan 2021 14:49:42 +0900 Subject: A minor memory leak bug in a test case has been fixed. --- ChangeLog | 5 +++++ tests/test_qrinput.c | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index ba479e32dd..284943ad88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2021.01.08 Kentaro Fukuchi + [develop] + * tests/test_qrinput.c: + - A minor memory leak bug in a test case has been fixed. + 2020.09.29 Kentaro Fukuchi [develop] * qrencode.c: diff --git a/tests/test_qrinput.c b/tests/test_qrinput.c index b1ac5a981e..2aab36a8b6 100644 --- a/tests/test_qrinput.c +++ b/tests/test_qrinput.c @@ -919,6 +919,7 @@ static void test_QRinput_getErrorCorrectionLevel(void) level = QRinput_getErrorCorrectionLevel(input); assert_equal(level, QR_ECLEVEL_H, "QRinput_getErrorCorrectionLevel() fails to return expected level.\n"); testFinish(); + QRinput_free(input); } static void test_mqr_new(void) -- cgit 0.0.5-2-1-g0f52 From 2ba8844cf64f049519792e8764cac7670d2ccd79 Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 8 Jan 2021 15:02:33 +0900 Subject: 'libpng12-dev' has been corrected to 'libpng-dev'. (closes #170) (Thanks to @a6q) --- ChangeLog | 3 +++ README.md | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 284943ad88..9d7351c4c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ [develop] * tests/test_qrinput.c: - A minor memory leak bug in a test case has been fixed. + * README.md: + - 'libpng12-dev' has been corrected to 'libpng-dev'. (closes #170) + (Thanks to @a6q) 2020.09.29 Kentaro Fukuchi [develop] diff --git a/README.md b/README.md index 17d4e4fb3f..34f557aa9f 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ process. For example, in Ubuntu, the following packages are needed: - autotools-dev - libtool - pkg-config -- libpng12-dev +- libpng-dev You can skip this process if you have "configure" script already (typically when you downloaded the source tarball from fukuchi.org.) @@ -231,5 +231,5 @@ Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels, Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013, Frédéric Wang, Dan Jacobson, Jan Tojnar, @xiaoyur347, @charmander, - Yannick Schinko + Yannick Schinko, @a6q - bug report / suggestion / typo fixes -- cgit 0.0.5-2-1-g0f52 From 49980df270e6a39738a0c886c1eef6b42e782edb Mon Sep 17 00:00:00 2001 From: Kentaro Fukuchi Date: Fri, 8 Jan 2021 17:10:27 +0900 Subject: Update ci script (#171) * Updated 'run-vcpkg' package to v6. * vcpkg's git commit ID has been updated to the latest master. --- .github/workflows/cmake.yml | 4 ++-- ChangeLog | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 134bbb08d5..1fd5c4d65d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -17,11 +17,11 @@ jobs: - name: run vcpkg if: matrix.os == 'windows-latest' - uses: lukka/run-vcpkg@v3 + uses: lukka/run-vcpkg@v6 with: vcpkgArguments: getopt:x64-windows libiconv:x64-windows libpng:x64-windows vcpkgDirectory: '${{ github.workspace }}/vcpkg' - vcpkgGitCommitId: 'fca18ba3572f8aebe3b8158c359db62a7e26134e' + vcpkgGitCommitId: '2a42024b53ebb512fb5dd63c523338bf26c8489c' appendedCacheKey: ${{ hashFiles( '${{ github.workspace }}/.github/workflows/cmake.yml' ) }} - name: brew setup diff --git a/ChangeLog b/ChangeLog index 9d7351c4c3..79713f070d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ * README.md: - 'libpng12-dev' has been corrected to 'libpng-dev'. (closes #170) (Thanks to @a6q) + * .github/workflows/cmake.yml: + - Updated 'run-vcpkg' package to v6. + - vcpkg's git commit ID has been updated to the latest master. 2020.09.29 Kentaro Fukuchi [develop] -- cgit 0.0.5-2-1-g0f52