Hello community, here is the log from the commit of package qrencode for openSUSE:Factory checked in at 2012-09-23 08:45:54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/qrencode (Old) and /work/SRC/openSUSE:Factory/.qrencode.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "qrencode", Maintainer is "" Changes: -------- --- /work/SRC/openSUSE:Factory/qrencode/qrencode.changes 2012-04-19 08:51:05.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.qrencode.new/qrencode.changes 2012-09-23 08:45:56.000000000 +0200 @@ -1,0 +2,12 @@ +Fri Sep 21 11:16:10 UTC 2012 - [email protected] + +- Update to 3.3.1: + + various bug fixes in cli, manual, configure and libtool files. +- Changes from 3.3.0: + + EPS, ANSI, and ASCII text output supports have been added. + + QRcode_APIVersion() and QRcode_APIVersionString() have been + added. +- Changes from 3.2.1: + + bug fixes in configure/libtool. + +------------------------------------------------------------------- Old: ---- qrencode-3.2.0.tar.bz2 New: ---- qrencode-3.3.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ qrencode.spec ++++++ --- /var/tmp/diff_new_pack.pEZdqU/_old 2012-09-23 08:45:57.000000000 +0200 +++ /var/tmp/diff_new_pack.pEZdqU/_new 2012-09-23 08:45:57.000000000 +0200 @@ -17,7 +17,7 @@ Name: qrencode -Version: 3.2.0 +Version: 3.3.1 Release: 0 Summary: C library for encoding data in a QR Code symbol License: LGPL-2.1+ ++++++ qrencode-3.2.0.tar.bz2 -> qrencode-3.3.1.tar.bz2 ++++++ ++++ 16334 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/ChangeLog new/qrencode-3.3.1/ChangeLog --- old/qrencode-3.2.0/ChangeLog 2011-11-25 20:32:38.000000000 +0100 +++ new/qrencode-3.3.1/ChangeLog 2012-04-18 16:18:06.000000000 +0200 @@ -1,3 +1,99 @@ +2012.04.18 Kentaro FUKUCHI <[email protected]> + [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 <[email protected]> + [master] + * 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. + [3.3] + * README, configure.ac: + - Bumped version to 3.3.1. + +2012.04.01 Kentaro FUKUCHI <[email protected]> + [3.3] + * qrenc.c: + - 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. + [master] + * Merged to 3.3.0. + +2012.03.31 Kentaro FUKUCHI <[email protected]> + [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 <[email protected]> + * 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 <[email protected]> + [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 <[email protected]> + [master] + * Recent 3.2 branch has been merged into the master. + * qrenc.c: + - Quick bug fix introduced in 09b72eb3070a36461eb83c1ec5237e4855ee515b. + +2012.01.19 Kentaro FUKUCHI <[email protected]> + [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. + * qrenc.c: + - 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. + - 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. + +2011.12.12 Kentaro FUKUCHI <[email protected]> + [3.2.1] + * configure.ac, README: + - Bumped version to 3.2.1. + +2011.12.12 Kentaro FUKUCHI <[email protected]> + * qrenc.c, qrencode.1.in: + - Usage updates. + +2011.12.11 Kentaro FUKUCHI <[email protected]> + * qrenc.c: + - Pulled Zapster's EPS support patch. + - Some code cleanups. + 2011.11.26 Kentaro FUKUCHI <[email protected]> [3.2.0] * qrencode.1.in: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/NEWS new/qrencode-3.3.1/NEWS --- old/qrencode-3.2.0/NEWS 2011-11-25 19:18:10.000000000 +0100 +++ new/qrencode-3.3.1/NEWS 2012-04-18 16:11:08.000000000 +0200 @@ -1,8 +1,32 @@ libqrencode NEWS - Overview of changes ====================================== +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. + (Thanks to Zapster, Colin, and Ralf) +* QRcode_APIVersion() and QRcode_APIVersionString() have been added. + +Release Note: +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) +------------------------- +* 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 information in an output PNG image. (Thanks to David Dahl) * New option "--enable-thread-safety" has been added to the configure script diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/README new/qrencode-3.3.1/README --- old/qrencode-3.2.0/README 2011-11-25 20:24:42.000000000 +0100 +++ new/qrencode-3.3.1/README 2012-04-18 16:11:08.000000000 +0200 @@ -1,4 +1,4 @@ -libqrencode 3.2.0 - QR Code encoding library +libqrencode 3.3.1 - QR Code encoding library GENERAL INFORMATION =================== @@ -76,7 +76,7 @@ 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 @@ -120,9 +120,14 @@ 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 -Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom - 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, Rob Ryan + - bug report / suggestion diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/config.h.in new/qrencode-3.3.1/config.h.in --- old/qrencode-3.2.0/config.h.in 2011-10-23 22:22:21.000000000 +0200 +++ new/qrencode-3.3.1/config.h.in 2012-04-18 16:16:06.000000000 +0200 @@ -9,9 +9,6 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#undef HAVE_LIBPTHREAD - /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -43,6 +40,15 @@ */ #undef LT_OBJDIR +/* Major version number */ +#undef MAJOR_VERSION + +/* Micro version number */ +#undef MICRO_VERSION + +/* Minor version number */ +#undef MINOR_VERSION + /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/configure.ac new/qrencode-3.3.1/configure.ac --- old/qrencode-3.2.0/configure.ac 2011-10-23 22:21:17.000000000 +0200 +++ new/qrencode-3.3.1/configure.ac 2012-04-18 16:11:08.000000000 +0200 @@ -1,13 +1,16 @@ AC_INIT(QRencode) MAJOR_VERSION=3 -MINOR_VERSION=2 -MICRO_VERSION=0 +MINOR_VERSION=3 +MICRO_VERSION=1 VERSION=$MAJOR_VERSION.$MINOR_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]) AC_CONFIG_SRCDIR([qrencode.c]) AC_CONFIG_HEADERS([config.h]) @@ -39,9 +42,9 @@ [], [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$HAVE_LIBPTHREAD" = "xyes" ]) +AM_CONDITIONAL([HAVE_LIBPTHREAD], [test "x$ac_cv_lib_pthread_pthread_mutex_init" = "xyes" ]) dnl --with-tools diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/libqrencode.pc.in new/qrencode-3.3.1/libqrencode.pc.in --- old/qrencode-3.2.0/libqrencode.pc.in 2011-10-23 22:21:17.000000000 +0200 +++ new/qrencode-3.3.1/libqrencode.pc.in 2012-04-09 19:07:53.000000000 +0200 @@ -6,5 +6,6 @@ Name: libqrencode Description: A QR Code encoding library Version: @VERSION@ -Libs: -L${libdir} -lqrencode @LIBPTHREAD@ +Libs: -L${libdir} -lqrencode +Libs.private: @LIBPTHREAD@ Cflags: -I${includedir} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/qrenc.c new/qrencode-3.3.1/qrenc.c --- old/qrencode-3.2.0/qrenc.c 2011-10-25 16:34:36.000000000 +0200 +++ new/qrencode-3.3.1/qrenc.c 2012-04-18 16:11:08.000000000 +0200 @@ -2,7 +2,7 @@ * qrencode - QR Code encoder * * QR Code encoding tool - * Copyright (C) 2006-2011 Kentaro Fukuchi <[email protected]> + * Copyright (C) 2006-2012 Kentaro Fukuchi <[email protected]> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -42,6 +42,17 @@ static QRecLevel level = QR_ECLEVEL_L; static QRencodeMode hint = QR_MODE_8; +enum imageType { + PNG_TYPE, + EPS_TYPE, + ANSI_TYPE, + ANSI256_TYPE, + ASCII_TYPE, + ASCIIi_TYPE +}; + +static enum imageType image_type = PNG_TYPE; + static const struct option options[] = { {"help" , no_argument , NULL, 'h'}, {"output" , required_argument, NULL, 'o'}, @@ -49,7 +60,8 @@ {"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'}, + {"type" , required_argument, NULL, 't'}, {"structured" , no_argument , NULL, 'S'}, {"kanji" , no_argument , NULL, 'k'}, {"casesensitive", no_argument , NULL, 'c'}, @@ -60,25 +72,25 @@ {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) { fprintf(stderr, "qrencode version %s\n" -"Copyright (C) 2006-2011 Kentaro Fukuchi\n", VERSION); +"Copyright (C) 2006-2012 Kentaro Fukuchi\n", QRcode_APIVersionString()); if(help) { 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" +" 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" @@ -90,6 +102,8 @@ " 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" +" 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,20 +121,21 @@ } 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" +" 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" " -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" +" 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" @@ -162,6 +177,24 @@ 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. @@ -265,6 +298,228 @@ return 0; } +static int writeEPS(QRcode *qrcode, const char *outfile) +{ + FILE *fp; + unsigned char *row, *p; + int x, y, yy; + int realwidth; + + fp = openFile(outfile); + + 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 " + "%d %d scale ", 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); + } + } + } + + fprintf(fp, "\n%%%%EOF\n"); + fclose(fp); + + return 0; +} + +static void writeANSI_margin(FILE* fp, int realwidth, + char* buffer, int buffer_s, + char* white, int white_s ) +{ + int y; + + 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; y<margin; y++ ){ + fputs(buffer, fp); + } +} + +static int writeANSI(QRcode *qrcode, const char *outfile) +{ + FILE *fp; + unsigned char *row, *p; + int x, y; + 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; + + fp = openFile(outfile); + + 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); + } + + /* top margin */ + writeANSI_margin(fp, realwidth, buffer, buffer_s, white, white_s); + + /* data */ + p = qrcode->data; + for(y=0; y<qrcode->width; y++) { + row = (p+(y*qrcode->width)); + + bzero( buffer, buffer_s ); + strncpy( buffer, white, white_s ); + for(x=0; x<margin; x++ ){ + strncat( buffer, " ", 2 ); + } + last = 0; + + for(x=0; x<qrcode->width; 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 ); + } + for(x=0; x<margin; x++ ){ + strncat( buffer, " ", 2 ); + } + strncat( buffer, "\033[0m\n", 5 ); + fputs( buffer, fp ); + } + + /* bottom margin */ + writeANSI_margin(fp, realwidth, buffer, buffer_s, white, white_s); + + fclose(fp); + free(buffer); + + 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; y<h; y++ ){ + fputs(buffer, fp); + } +} + +static int writeASCII(QRcode *qrcode, const char *outfile, int invert) +{ + FILE *fp; + unsigned char *row; + int x, y; + int realwidth; + char *buffer, *p; + int buffer_s; + char black = '#'; + char white = ' '; + + if(invert) { + black = ' '; + white = '#'; + } + + size = 1; + + fp = openFile(outfile); + + realwidth = (qrcode->width + 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; y<qrcode->width; y++) { + row = qrcode->data+(y*qrcode->width); + p = buffer; + + memset(p, white, margin * 2); + p += margin * 2; + + for(x=0; x<qrcode->width; 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; @@ -295,7 +550,27 @@ 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; + case ANSI_TYPE: + 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); + } QRcode_free(qrcode); } @@ -317,16 +592,40 @@ QRcode_List *qrlist, *p; char filename[FILENAME_MAX]; char *base, *q, *suffix = NULL; + const char *type_suffix; int i = 1; + size_t suffix_size; + switch(image_type) { + case PNG_TYPE: + type_suffix = ".png"; + break; + case EPS_TYPE: + type_suffix = ".eps"; + break; + case ANSI_TYPE: + case ANSI256_TYPE: + case ASCII_TYPE: + type_suffix = ".txt"; + break; + default: + fprintf(stderr, "Unknown image type.\n"); + 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"); exit(EXIT_FAILURE); } - if(strlen(base) > 4) { - q = base + strlen(base) - 4; - if(strcasecmp(".png", q) == 0) { + suffix_size = strlen(type_suffix); + if(strlen(base) > suffix_size) { + q = base + strlen(base) - suffix_size; + if(strcasecmp(type_suffix, q) == 0) { suffix = strdup(q); *q = '\0'; } @@ -348,7 +647,27 @@ } 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; + case ANSI_TYPE: + 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); + } i++; } @@ -432,6 +751,24 @@ 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 if(strcasecmp(optarg, "ansi") == 0) { + 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); + } + break; case 'S': structured = 1; case 'k': @@ -465,7 +802,7 @@ exit(EXIT_SUCCESS); } - if(outfile == NULL) { + if(outfile == NULL && image_type == PNG_TYPE) { fprintf(stderr, "No output filename is given.\n"); exit(EXIT_FAILURE); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/qrencode.1.in new/qrencode-3.3.1/qrencode.1.in --- old/qrencode-3.2.0/qrencode.1.in 2011-11-25 20:29:34.000000000 +0100 +++ new/qrencode-3.3.1/qrencode.1.in 2012-04-09 19:07:35.000000000 +0200 @@ -1,6 +1,6 @@ -.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 image. +qrencode \- Encode input data in a QR Code and save as a PNG or EPS image. .SH SYNOPSIS .B "qrencode" [OPTION]... @@ -13,51 +13,53 @@ 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 -.B \-h, --help +.B \-h, \-\-help 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. +.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 \-S, --structured +.B \-t {PNG,EPS,ANSI,ANSI256}, \-\-type={PNG,EPS,ANSI,ANSI256} +specify the type of the generated image. (default=PNG) +.TP +.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] @@ -65,10 +67,10 @@ .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. @@ -82,4 +84,4 @@ Source code repository: https://github.com/fukuchi/libqrencode/ .SH COPYRIGHT -Copyright (C) 2006-2011 Kentaro Fukuchi. +Copyright (C) 2006-2012 Kentaro Fukuchi. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/qrencode.c new/qrencode-3.3.1/qrencode.c --- old/qrencode-3.2.0/qrencode.c 2011-10-23 22:21:17.000000000 +0200 +++ new/qrencode-3.3.1/qrencode.c 2012-04-01 17:54:32.000000000 +0200 @@ -1,7 +1,7 @@ /* * qrencode - QR Code encoder * - * Copyright (C) 2006-2011 Kentaro Fukuchi <[email protected]> + * Copyright (C) 2006-2012 Kentaro Fukuchi <[email protected]> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -903,6 +903,24 @@ * 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/qrencode.h new/qrencode-3.3.1/qrencode.h --- old/qrencode-3.2.0/qrencode.h 2011-10-23 22:21:17.000000000 +0200 +++ new/qrencode-3.3.1/qrencode.h 2012-04-01 17:16:21.000000000 +0200 @@ -538,6 +538,21 @@ *****************************************************************************/ /** + * 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/qrencode.spec new/qrencode-3.3.1/qrencode.spec --- old/qrencode-3.2.0/qrencode.spec 2011-10-23 22:22:18.000000000 +0200 +++ new/qrencode-3.3.1/qrencode.spec 2012-04-18 16:16:00.000000000 +0200 @@ -1,4 +1,4 @@ -%define ver 3.2.0 +%define ver 3.3.1 %define rel 1 Name: qrencode diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/tests/Makefile.am new/qrencode-3.3.1/tests/Makefile.am --- old/qrencode-3.2.0/tests/Makefile.am 2011-10-23 22:21:17.000000000 +0200 +++ new/qrencode-3.3.1/tests/Makefile.am 2012-04-09 19:07:53.000000000 +0200 @@ -55,7 +55,7 @@ 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) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/tests/decoder.c new/qrencode-3.3.1/tests/decoder.c --- old/qrencode-3.2.0/tests/decoder.c 2011-11-03 12:07:25.000000000 +0100 +++ new/qrencode-3.3.1/tests/decoder.c 2012-04-01 17:16:21.000000000 +0200 @@ -401,7 +401,7 @@ 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); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/qrencode-3.2.0/tests/test_qrencode.c new/qrencode-3.3.1/tests/test_qrencode.c --- old/qrencode-3.2.0/tests/test_qrencode.c 2011-11-03 12:12:02.000000000 +0100 +++ new/qrencode-3.3.1/tests/test_qrencode.c 2012-04-01 17:16:21.000000000 +0200 @@ -860,6 +860,23 @@ 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 @@ test_encodeTooLongMQR(); test_decodeShortMQR(); test_mqrencode(); + test_apiversion(); QRcode_clearCache(); -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
