diff --git a/ap/app/qrencode/Makefile b/ap/app/qrencode/Makefile
new file mode 100755
index 0000000..77c685d
--- /dev/null
+++ b/ap/app/qrencode/Makefile
@@ -0,0 +1,44 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+		
+##############USER COMIZE BEGIN################
+EXEC1 = qrencode
+EXEC2 = png2bmp
+OBJS1 = bitstream.o mask.o mmask.o mqrspec.o qrenc.o qrencode.o \
+	qrinput.o qrspec.o rscode.o split.o
+OBJS2 = common.o png2bmp.o
+
+
+LDLIBS += -lpng -L$(zte_lib_path)/libpng/install/lib
+LDLIBS += -L$(zte_lib_path)/zlib/install/lib -lz -lm
+CFLAGS += -I./
+CFLAGS += -I$(zte_lib_path)/libpng/install/include
+CFLAGS += -I$(zte_lib_path)/zlib/install/include
+
+
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC1) $(EXEC2)
+
+$(EXEC1): $(OBJS1)
+	$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+	@cp $@ $@.elf
+
+$(EXEC2): $(OBJS2)
+	$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+	@cp $@ $@.elf
+	
+romfs:
+	$(ROMFSINST) $(EXEC1) /sbin/$(EXEC1)
+	$(ROMFSINST) $(EXEC2) /sbin/$(EXEC2)
+	
+clean:
+	-rm -f $(EXEC1) *.elf *.gdb *.o
+	-rm -f $(EXEC2) *.elf *.gdb *.o
+	
diff --git a/ap/app/qrencode/bitstream.c b/ap/app/qrencode/bitstream.c
new file mode 100644
index 0000000..a0b9283
--- /dev/null
+++ b/ap/app/qrencode/bitstream.c
@@ -0,0 +1,238 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Binary sequence class.
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "bitstream.h"
+
+BitStream *BitStream_new(void)
+{
+	BitStream *bstream;
+
+	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;
+	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;
+	mask = 1 << (bits - 1);
+	for(i=0; i<bits; i++) {
+		if(num & mask) {
+			*p = 1;
+		} else {
+			*p = 0;
+		}
+		p++;
+		mask = mask >> 1;
+	}
+
+	return bstream;
+}
+
+static BitStream *BitStream_newFromBytes(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;
+	for(i=0; i<size; i++) {
+		mask = 0x80;
+		for(j=0; j<8; j++) {
+			if(data[i] & mask) {
+				*p = 1;
+			} else {
+				*p = 0;
+			}
+			p++;
+			mask = mask >> 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;
+	}
+	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;
+}
+
+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);
+
+	return ret;
+}
+
+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);
+
+	return ret;
+}
+
+unsigned char *BitStream_toByte(BitStream *bstream)
+{
+	int i, j, size, bytes;
+	unsigned char *data, v;
+	unsigned char *p;
+
+	size = BitStream_size(bstream);
+	if(size == 0) {
+		return NULL;
+	}
+	data = (unsigned char *)malloc((size + 7) / 8);
+	if(data == NULL) {
+		return NULL;
+	}
+
+	bytes = size  / 8;
+
+	p = bstream->data;
+	for(i=0; i<bytes; i++) {
+		v = 0;
+		for(j=0; j<8; j++) {
+			v = v << 1;
+			v |= *p;
+			p++;
+		}
+		data[i] = v;
+	}
+	if(size & 7) {
+		v = 0;
+		for(j=0; j<(size & 7); j++) {
+			v = v << 1;
+			v |= *p;
+			p++;
+		}
+		data[bytes] = v;
+	}
+
+	return data;
+}
+
+void BitStream_free(BitStream *bstream)
+{
+	if(bstream != NULL) {
+		free(bstream->data);
+		free(bstream);
+	}
+}
diff --git a/ap/app/qrencode/bitstream.h b/ap/app/qrencode/bitstream.h
new file mode 100644
index 0000000..ffe743c
--- /dev/null
+++ b/ap/app/qrencode/bitstream.h
@@ -0,0 +1,38 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Binary sequence class.
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 __BITSTREAM_H__
+#define __BITSTREAM_H__
+
+typedef struct {
+	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);
+#define BitStream_size(__bstream__) (__bstream__->length)
+extern unsigned char *BitStream_toByte(BitStream *bstream);
+extern void BitStream_free(BitStream *bstream);
+
+#endif /* __BITSTREAM_H__ */
diff --git a/ap/app/qrencode/bmphed.h b/ap/app/qrencode/bmphed.h
new file mode 100755
index 0000000..3379c76
--- /dev/null
+++ b/ap/app/qrencode/bmphed.h
@@ -0,0 +1,71 @@
+#ifndef BMPHED_H
+#define BMPHED_H
+
+#ifndef BI_RGB
+#define BI_RGB				0L		/* Uncompressed        */
+#define BI_RLE8				1L		/* RLE (8 bits/pixel)  */
+#define BI_RLE4				2L		/* RLE (4 bits/pixel)  */
+#define BI_BITFIELDS		3L		/* Bitfield            */
+#define BI_JPEG				4L		/* JPEG Extension      */
+#define BI_PNG				5L		/* PNG Extension       */
+#endif
+
+#define BIH_DSIZE			0		/* DWORD        biSize;          */
+#define BIH_LWIDTH			4		/* LONG         biWidth;         */
+#define BIH_LHEIGHT			8		/* LONG         biHeight;        */
+#define BIH_WPLANES			12		/* WORD         biPlanes;        */
+#define BIH_WBITCOUNT		14		/* WORD         biBitCount;      */
+#define BIH_DCOMPRESSION	16		/* DWORD        biCompression;   */
+#define BIH_DSIZEIMAGE		20		/* DWORD        biSizeImage;     */
+#define BIH_LXPELSPERMETER	24		/* LONG         biXPelsPerMeter; */
+#define BIH_LYPELSPERMETER	28		/* LONG         biYPelsPerMeter; */
+#define BIH_DCLRUSED		32		/* DWORD        biClrUsed;       */
+#define BIH_DCLRIMPORANT	36		/* DWORD        biClrImportant;  */
+#define B4H_DREDMASK		40		/* DWORD        bV4RedMask;      */
+#define B4H_DGREENMASK		44		/* DWORD        bV4GreenMask;    */
+#define B4H_DBLUEMASK		48		/* DWORD        bV4BlueMask;     */
+#define B4H_DALPHAMASK		52		/* DWORD        bV4AlphaMask;    */
+#define B4H_DCSTYPE			56		/* DWORD        bV4CSType;       */
+#define B4H_XENDPOINTS		60		/* CIEXYZTRIPLE bV4Endpoints;    */
+#define B4H_DGAMMARED		96		/* DWORD        bV4GammaRed;     */
+#define B4H_DGAMMAGREEN		100		/* DWORD        bV4GammaGreen;   */
+#define B4H_DGAMMABLUE		104		/* DWORD        bV4GammaBlue;    */
+#define B5H_DINTENT			108		/* DWORD        bV5Intent;       */
+#define B5H_DPROFILEDATA	112		/* DWORD        bV5ProfileData;  */
+#define B5H_DPROFILESIZE	116		/* DWORD        bV5ProfileSize;  */
+#define B5H_DRESERVED		120		/* DWORD        bV5Reserved;     */
+#define INFOHED_SIZE		40		/* sizeof(BITMAPINFOHEADER)      */
+#define BMPV4HED_SIZE		108		/* sizeof(BITMAPV4HEADER)        */
+#define BMPV5HED_SIZE		124		/* sizeof(BITMAPV5HEADER)        */
+
+#define BCH_DSIZE			0		/* DWORD  bcSize;                */
+#define BCH_WWIDTH			4		/* WORD   bcWidth;               */
+#define BCH_WHEIGHT			6		/* WORD   bcHeight;              */
+#define BCH_WPLANES			8		/* WORD   bcPlanes;              */
+#define BCH_WBITCOUNT		10		/* WORD   bcBitCount;            */
+#define COREHED_SIZE		12		/* sizeof(BITMAPCOREHEADER)      */
+
+#define RGBQ_BLUE			0		/* BYTE   rgbBlue;     */
+#define RGBQ_GREEN			1		/* BYTE   rgbGreen;    */
+#define RGBQ_RED			2		/* BYTE   rgbRed;      */
+#define RGBQ_RESERVED		3		/* BYTE   rgbReserved; */
+#define RGBQUAD_SIZE		4		/* sizeof(RGBQUAD)     */
+
+#define RGBT_BLUE			0		/* BYTE   rgbtBlue;    */
+#define RGBT_GREEN			1		/* BYTE   rgbtGreen;   */
+#define RGBT_RED			2		/* BYTE   rgbtRed;     */
+#define RGBTRIPLE_SIZE		3		/* sizeof(RGBTRIPLE)   */
+
+#define BMP_SIGNATURE		0x4D42
+#define BMP_SIG_BYTES		2
+
+#define BFH_WTYPE			0		/* WORD         bfType;          */
+#define BFH_DSIZE			2		/* DWORD        bfSize;          */
+#define BFH_WRESERVED1		6		/* WORD         bfReserved1;     */
+#define BFH_WRESERVED2		8		/* WORD         bfReserved2;     */
+#define BFH_DOFFBITS		10		/* DWORD        bfOffBits;       */
+#define BFH_DBIHSIZE		14		/* DWORD        biSize;          */
+#define FILEHED_SIZE		14		/* sizeof(BITMAPFILEHEADER)      */
+#define BIHSIZE_SIZE		4		/* sizeof(biSize)                */
+
+#endif /* BMPHED_H */
diff --git a/ap/app/qrencode/common.c b/ap/app/qrencode/common.c
new file mode 100755
index 0000000..c010f4c
--- /dev/null
+++ b/ap/app/qrencode/common.c
@@ -0,0 +1,512 @@
+#include "common.h"
+
+#define LINE_LEN	79
+#define STATUS_LEN	22
+#define PROGBAR_MAX	(LINE_LEN - STATUS_LEN - 1)
+
+static char status_msg[128];
+static int  progbar_scale = 0;
+static int  progbar_len   = 0;
+static int  progbar_pos   = -1;
+
+int quietmode = 0;		
+int errorlog  = 0;		
+
+static png_uint_32 counter;
+static png_uint_32 maxcount;
+static int         barlen;
+
+#define isoption(p)	(IsOptChar((p)[0]) && (p)[1]!='\0')
+
+static void print_status(void)
+{
+	fprintf(stderr, "\r%-*.*s ", STATUS_LEN, STATUS_LEN, status_msg);
+	fflush(stderr);
+	progbar_pos = 0;
+}
+
+static void put_dots(int dotchar, int num)
+{
+	int i;
+
+	if (num > PROGBAR_MAX) num = PROGBAR_MAX;
+	if (progbar_pos == -1) print_status();
+
+	for (i = progbar_pos; i < num; i++)
+		fputc(dotchar, stderr);
+
+	if (progbar_pos < num) {
+		progbar_pos = num;
+		fflush(stderr);
+	}
+}
+
+static void print_scale(void)
+{
+	if (progbar_pos != 0) print_status();
+	put_dots('.', progbar_len);
+	print_status();
+	progbar_scale = 1;
+}
+
+static void init_progress_bar(int max)
+{
+	if (quietmode) return;
+
+	progbar_len = max;
+	print_scale();
+}
+
+static void update_progress_bar(int num)
+{
+	if (quietmode) return;
+
+	if (!progbar_scale) print_scale();
+	put_dots('o', num);
+}
+
+static void clear_line(void)
+{
+	if (quietmode) return;
+
+	fprintf(stderr, "\r%*c\r", LINE_LEN, ' ');
+	progbar_scale = 0;
+	progbar_pos   = -1;
+}
+
+void xxprintf(const char *fmt, ...)
+{
+	va_list ap;
+	FILE *f;
+
+	va_start(ap, fmt);
+
+	clear_line();
+	vfprintf(stderr, fmt, ap);
+	fflush(stderr);
+
+	if (errorlog && (f = fopen(errlogfile, "a")) != NULL) {
+		vfprintf(f, fmt, ap);
+		fclose(f);
+	}
+
+	va_end(ap);
+}
+
+void set_status(const char *fmt, ...)
+{
+	va_list ap;
+
+	if (quietmode) return;
+
+	va_start(ap, fmt);
+	vsprintf(status_msg, fmt, ap);
+	va_end(ap);
+
+	print_status();
+}
+
+void feed_line(void)
+{
+	if (quietmode) return;
+
+	fputc('\n', stderr);
+	fflush(stderr);
+	progbar_scale = 0;
+	progbar_pos   = -1;
+}
+
+static png_uint_32 maxcount_adam7(png_uint_32 width, png_uint_32 height)
+{
+	png_uint_32 c = 0;
+
+	if (    1    ) c += ((height - 0 + 7) / 8) * 1;		
+	if (width > 4) c += ((height - 0 + 7) / 8) * 1;		
+	if (    1    ) c += ((height - 4 + 7) / 8) * 2;		
+	if (width > 2) c += ((height - 0 + 3) / 4) * 2;		
+	if (    1    ) c += ((height - 2 + 3) / 4) * 4;		
+	if (width > 1) c += ((height - 0 + 1) / 2) * 4;		
+	if (    1    ) c += ((height - 1 + 1) / 2) * 8;		
+
+	return c;
+}
+
+void init_progress_meter(png_structp png_ptr, png_uint_32 width,
+                         png_uint_32 height)
+{
+	enum { W = 1024, H = 768 };
+
+	if (png_set_interlace_handling(png_ptr) == 7) {
+		maxcount = maxcount_adam7(width, height);	
+	} else {
+		maxcount = height;							
+	}
+	if (height > ((png_uint_32)W * H) / width) {
+		barlen = PROGBAR_MAX;
+	} else {
+		barlen = (PROGBAR_MAX * width * height + (W * H - 1)) / (W * H);
+	}
+	counter = 0;
+	init_progress_bar(barlen);
+}
+
+void row_callback(png_structp png_ptr, png_uint_32 row, int pass)
+{
+
+	if (row == 0) pass--;
+	
+
+	counter += (1 << (pass >> 1));	/* step[pass]; */
+	update_progress_bar(barlen * counter / maxcount);
+}
+
+FILE *binary_stdio(int fd)
+{
+	FILE *fp;
+
+	if (fd != 0 && fd != 1) 
+		return NULL;
+
+	printf("---------binary_stdio----else ------\n");
+	fp = (fd == 0) ? stdin : stdout;
+
+	return fp;
+}
+
+char *suffix(const char *path)
+{
+	char c, *p, *q, *r;
+
+	for (r = q = p = basname(path); (c = *p) != '\0'; p++)
+		if (c == '.') q = p;
+	if (q == r) q = p;			/* dotfile with no suffix */
+
+	return q;
+}
+
+char *basname(const char *path)
+{
+	const char *p, *q;
+
+	for (p = path_skiproot(path);
+	     *(q = path_nextslash(p)) != '\0'; p = q + 1) ;
+
+	return (char *)p;
+}
+
+char *addslash(char *path)
+{
+	char *p, *q;
+
+	for (p = path_skiproot(path);
+	     *(q = path_nextslash(p)) != '\0'; p = q + 1) ;
+
+	if (q != p) {
+		*q++ = PATHDELIM;
+		*q   = '\0';
+	}
+
+	return path;
+}
+
+
+char *path_skiproot(const char *path)
+{
+	if (IsPathDelim(path[0])) path++;
+	return (char *)path;
+}
+
+char *path_nextslash(const char *path)
+{
+	char c;
+
+	for (; (c = *path) != '\0'; path++) {
+		if (IsDBCSLead((unsigned char)c)) {
+			if (*(++path) == '\0') break;
+			continue;
+		}
+		if (IsPathDelim(c)) break;
+	}
+	return (char *)path;
+}
+
+char *delslash(char *path)
+{
+	char *p, *q, *s;
+
+	for (p = s = path_skiproot(path);
+	     *(q = path_nextslash(p)) != '\0'; p = q + 1) ;
+
+	if (q == s) {
+		*q++ = '.';
+		*q   = '\0';
+	} else if (q == p) {
+		*--q = '\0';
+	}
+
+	return path;
+}
+
+
+void png_my_error(png_structp png_ptr, png_const_charp message)
+{
+	xxprintf("ERROR(libpng): %s - %s\n", message,
+	             (char *)png_get_error_ptr(png_ptr));
+	longjmp(png_jmpbuf(png_ptr), 1);
+}
+
+void png_my_warning(png_structp png_ptr, png_const_charp message)
+{
+	xxprintf("WARNING(libpng): %s - %s\n", message,
+	             (char *)png_get_error_ptr(png_ptr));
+}
+
+BOOL imgbuf_alloc(IMAGE *img)
+{
+	BYTE *bp, **rp;
+	LONG n;
+
+	if (img->palnum > 0) {
+		img->palette = malloc((size_t)img->palnum * sizeof(PALETTE));
+		if (img->palette == NULL) { imgbuf_init(img); return FALSE; }
+	} else {
+		img->palette = NULL;
+	}
+	img->rowbytes = ((DWORD)img->width * img->pixdepth + 31) / 32 * 4;
+	img->imgbytes = img->rowbytes * img->height;
+	img->rowptr   = malloc((size_t)img->height * sizeof(BYTE *));
+	img->bmpbits  = malloc((size_t)img->imgbytes);
+
+	if (img->rowptr == NULL || img->bmpbits == NULL) {
+		imgbuf_free(img); imgbuf_init(img); return FALSE;
+	}
+
+	n  = img->height;
+	rp = img->rowptr;
+	bp = img->bmpbits;
+
+	if (img->topdown) {
+		while (--n >= 0) {
+			*(rp++) = bp;
+			bp += img->rowbytes;
+		
+		}
+	} else {	/* bottom-up */
+		bp += img->imgbytes;
+		while (--n >= 0) {
+			
+			((DWORD *)bp)[-1] = 0;
+			bp -= img->rowbytes;
+			*(rp++) = bp;
+		}
+	}
+
+	return TRUE;
+}
+
+void imgbuf_free(IMAGE *img)
+{
+	free(img->palette);
+	free(img->rowptr);
+	free(img->bmpbits);
+}
+
+void imgbuf_init(IMAGE *img)
+{
+	img->palette = NULL;
+	img->rowptr  = NULL;
+	img->bmpbits = NULL;
+}
+
+int parsearg(int *opt, char **arg, int argc, char **argv, char *aopts)
+{
+	static int   agi = 1;
+	static char *agp = NULL;
+	char *p;
+	int c, i;
+
+	if (agp != NULL && *agp == '\0') {
+		agp = NULL;
+		agi++;
+	}
+	if (agi >= argc) 
+		return 0;		
+
+	if (p = argv[agi], agp == NULL && !isoption(p)) {
+		
+		c = 0;
+		agi++;
+	} else {
+		if (agp == NULL) agp = p + 1;
+		if (c = (*agp & 0xFF), strchr(aopts, c) != NULL) {
+			
+			if (p = agp + 1, *p != '\0') {
+				/*NULL*/;
+			} else if (i = agi + 1, p = argv[i], i < argc && !isoption(p)) {
+				agi = i;
+			} else {
+				p = NULL;
+			}
+			agp = NULL;
+			agi++;
+		} else {
+			
+			p = NULL;
+			agp++;
+		}
+	}
+	*opt = c;
+	*arg = p;
+
+	return 1;
+}
+
+char **envargv(int *argcp, char ***argvp, const char *envn)
+{
+	int argc, nagc, envc, i;
+	char **argv, **nagv, *envs, *ep;
+
+	ep = getenv(envn);
+	if (ep == NULL || ep[0] == '\0') return NULL;
+
+	envs = malloc(strlen(ep) + 1);
+	if (envs == NULL) return NULL;
+	strcpy(envs, ep);
+
+	envc = tokenize(envs, envs);
+	if (envc == 0) { free(envs); return NULL; }
+
+	argc = *argcp;
+	argv = *argvp;
+	nagv = malloc((argc + envc + 1) * sizeof(char *));
+	if (nagv == NULL) { free(envs); return NULL; }
+
+	nagc = 1;
+	nagv[0] = argv[0];
+
+	for (i = 0; i < envc; i++) {
+		nagv[nagc++] = envs;
+		while (*(envs++) != '\0') ;
+	}
+	for (i = 1; i < argc; i++) {
+		nagv[nagc++] = argv[i];
+	}
+	nagv[nagc] = NULL;
+
+	*argcp = nagc;
+	*argvp = nagv;
+
+	return argv;
+}
+
+int tokenize(char *buf, const char *str)
+{
+	enum { STR = 0x01, QUOTE = 0x02 };
+	int flag = 0;
+	int num = 0;
+	char c;
+	int i;
+
+	while ((c = *str++) != '\0') {
+		if (!(flag & QUOTE) &&
+		    (c == ' ' || c == '\t' || c == '\n' || c == '\r')) {
+			if (flag & STR) {
+				flag &= ~STR;
+				*buf++ = '\0';
+			}
+		} else {
+			if (!(flag & STR)) {
+				flag |= STR;
+				num++;
+			}
+			switch (c) {
+			case '\\':
+				
+				for (i = 1; (c = *str) == '\\'; str++, i++) ;
+				if (c == '"') {
+					while ((i -= 2) >= 0)
+						*buf++ = '\\';
+					if (i == -1) {
+						*buf++ = '"';
+						str++;
+					}
+				} else {
+					while ((--i) >= 0)
+						*buf++ = '\\';
+				}
+				break;
+
+			case '"':
+				flag ^= QUOTE;
+				break;
+
+			default:
+				*buf++ = c;
+			}
+		}
+	}
+	if (flag & STR) *buf = '\0';
+
+	return num;
+}
+
+int makedir(const char *path)
+{
+	char dir[FILENAME_MAX];
+	struct stat sbuf;
+	char *p, c;
+	int r;
+
+	delslash(strcpy(dir, path));
+	if (stat(dir, &sbuf) == 0) {
+		if ((sbuf.st_mode & S_IFMT) == S_IFDIR) return 0;
+		
+		return -1;
+	}
+	p = path_skiproot(dir);
+	do {
+		p = path_nextslash(p);
+		c = *p;  *p = '\0';
+		r = MKDIR(dir, 0777);
+		*p++ = c;
+	} while (c != '\0');
+
+	return r;
+}
+
+int renbak(const char *path)
+{
+	char bak[FILENAME_MAX];
+	struct stat sbuf;
+	char *sfx;
+	int i;
+
+	strcpy(bak, path);
+	if (stat(bak, &sbuf) != 0) return 0;
+
+	sfx = bak + strlen(bak);
+
+	strcpy(sfx, ".bak");
+	i = 0;
+	while (1) {
+		if (stat(bak, &sbuf) != 0 && rename(path, bak) == 0) return 0;
+		if (i >= 1000) break;
+		sprintf(sfx, ".%03d", i++);
+	}
+	return -1;
+}
+
+int cpyftime(const char *srcf, const char *dstf)
+{
+	struct stat sbuf;
+	struct utimbuf ubuf;
+
+	if (stat(srcf, &sbuf) != 0) return -1;
+
+	ubuf.actime  = sbuf.st_atime;
+	ubuf.modtime = sbuf.st_mtime;
+
+	return utime(dstf, &ubuf);
+}
+
+
diff --git a/ap/app/qrencode/common.h b/ap/app/qrencode/common.h
new file mode 100755
index 0000000..b6b081b
--- /dev/null
+++ b/ap/app/qrencode/common.h
@@ -0,0 +1,104 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+
+#include <utime.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "png.h"
+
+#define MKDIR(d,m) mkdir(d,m)
+
+#if (PNG_LIBPNG_VER < 10004)
+# error libpng version 1.0.4 or later is required.
+#endif
+
+#if (PNG_LIBPNG_VER == 10207) || (PNG_LIBPNG_VER == 10206) || \
+    (PNG_LIBPNG_VER == 10017) || (PNG_LIBPNG_VER == 10016)
+# error Libpng versions 1.2.7, 1.2.6, 1.0.17, and 1.0.16
+# error have a bug that will cause png2bmp to crash.
+# error Update your libpng to latest version.
+# error "http://www.libpng.org/pub/png/libpng.html"
+#endif
+
+#if !defined(PNG_READ_tRNS_SUPPORTED) || !defined(PNG_WRITE_tRNS_SUPPORTED)
+# error This software requires tRNS chunk support.
+#endif
+
+#ifndef png_jmpbuf					/* pngconf.h (libpng 1.0.6 or later) */
+# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
+#endif
+
+
+#define PATHDELIM		'/'
+#define IsPathDelim(c)	((c)==PATHDELIM)
+#define IsOptChar(c)	((c)=='-')
+#define IsDBCSLead(c)	(0)
+
+typedef char           CHAR;
+typedef unsigned char  BYTE;
+typedef short          SHORT;
+typedef unsigned short WORD;
+typedef int            INT;
+typedef unsigned int   UINT;
+typedef long           LONG;
+typedef unsigned long  DWORD;
+typedef enum { FALSE = 0, TRUE = 1 } BOOL;
+
+typedef png_color PALETTE;
+typedef struct tagIMAGE {
+	LONG    width;
+	LONG    height;
+	UINT    pixdepth;
+	UINT    palnum;
+	BOOL    topdown;
+	BOOL    alpha;
+	/* ----------- */
+	DWORD   rowbytes;
+	DWORD   imgbytes;
+	PALETTE *palette;
+	BYTE    **rowptr;
+	BYTE    *bmpbits;
+	/* ----------- */
+	png_color_8 sigbit;
+} IMAGE;
+
+extern int quietmode;
+extern int errorlog;
+extern const char errlogfile[];
+
+void xxprintf(const char *, ...);
+void set_status(const char *, ...);
+void feed_line(void);
+void init_progress_meter(png_structp, png_uint_32, png_uint_32);
+void row_callback(png_structp, png_uint_32, int);
+
+FILE *binary_stdio(int);
+char *suffix(const char *);
+char *basname(const char *);
+char *addslash(char *);
+char *delslash(char *);
+char *path_skiproot(const char *);
+char *path_nextslash(const char *);
+
+void png_my_error(png_structp, png_const_charp);
+void png_my_warning(png_structp, png_const_charp);
+BOOL imgbuf_alloc(IMAGE *);
+void imgbuf_free(IMAGE *);
+void imgbuf_init(IMAGE *);
+int parsearg(int *, char **, int, char **, char *);
+char **envargv(int *, char ***, const char *);
+int tokenize(char *, const char *);
+int makedir(const char *);
+int renbak(const char *);
+int cpyftime(const char *, const char *);
+
+
+#endif /* COMMON_H */
diff --git a/ap/app/qrencode/config.h b/ap/app/qrencode/config.h
new file mode 100644
index 0000000..09e32fd
--- /dev/null
+++ b/ap/app/qrencode/config.h
@@ -0,0 +1,95 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define if you have the iconv() function and it works. */
+/* #undef HAVE_ICONV */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#define LT_OBJDIR ".libs/"
+
+/* Major version number */
+#define MAJOR_VERSION 3
+
+/* Micro version number */
+#define MICRO_VERSION 1
+
+/* Minor version number */
+#define MINOR_VERSION 3
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+/* #undef NO_MINUS_C_MINUS_O */
+
+/* Name of package */
+#define PACKAGE "qrencode"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME ""
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION ""
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "3.3.1"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to 'static' if no test programs will be compiled. */
+#define __STATIC static
+/* #undef WITH_TESTS */
+   
diff --git a/ap/app/qrencode/mask.c b/ap/app/qrencode/mask.c
new file mode 100644
index 0000000..ccef810
--- /dev/null
+++ b/ap/app/qrencode/mask.c
@@ -0,0 +1,330 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Masking.
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#include "qrencode.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.
+ */
+#define N1 (3)
+#define N2 (3)
+#define N3 (40)
+#define N4 (10)
+
+#define MASKMAKER(__exp__) \
+	int x, y;\
+	int b = 0;\
+\
+	for(y=0; y<width; y++) {\
+		for(x=0; x<width; x++) {\
+			if(*s & 0x80) {\
+				*d = *s;\
+			} else {\
+				*d = *s ^ ((__exp__) == 0);\
+			}\
+			b += (int)(*d & 1);\
+			s++; d++;\
+		}\
+	}\
+	return b;
+
+static int Mask_mask0(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)
+{
+	MASKMAKER(y&1)
+}
+
+static int Mask_mask2(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)
+{
+	MASKMAKER((x+y)%3)
+}
+
+static int Mask_mask4(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)
+{
+	MASKMAKER(((x*y)&1)+(x*y)%3)
+}
+
+static int Mask_mask6(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)
+{
+	MASKMAKER((((x*y)%3)+((x+y)&1))&1)
+}
+
+#define maskNum (8)
+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(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;
+}
+#endif
+
+unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level)
+{
+	unsigned char *masked;
+
+	if(mask < 0 || mask >= maskNum) {
+		errno = EINVAL;
+		return NULL;
+	}
+
+	masked = (unsigned char *)malloc(width * width);
+	if(masked == NULL) return NULL;
+
+	maskMakers[mask](width, frame, masked);
+	Mask_writeFormatInformation(width, masked, mask, level);
+
+	return masked;
+}
+
+
+//static int n1;
+//static int n2;
+//static int n3;
+//static int n4;
+
+static int Mask_calcN1N3(int length, int *runLength)
+{
+	int i;
+	int demerit = 0;
+	int fact;
+
+	for(i=0; i<length; i++) {
+		if(runLength[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) {
+				fact = runLength[i] / 3;
+				if(runLength[i-2] == fact &&
+				   runLength[i-1] == fact &&
+				   runLength[i+1] == fact &&
+				   runLength[i+2] == fact) {
+					if(i == 3 || runLength[i-3] >= 4 * fact) {
+						demerit += N3;
+						//n3 += N3;
+					} else if(i+4 >= length || runLength[i+3] >= 4 * fact) {
+						demerit += N3;
+						//n3 += N3;
+					}
+				}
+			}
+		}
+	}
+
+	return demerit;
+}
+
+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<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) {
+				demerit += N2;
+			}
+			p++;
+		}
+		p++;
+	}
+
+	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;
+	if(frame[0] & 1) {
+		runLength[0] = -1;
+		head = 1;
+	} else {
+		head = 0;
+	}
+	runLength[head] = 1;
+	p = frame + pitch;
+
+	for(i=1; i<width; i++) {
+		if((p[0] ^ p[-pitch]) & 1) {
+			head++;
+			runLength[head] = 1;
+		} else {
+			runLength[head]++;
+		}
+		p += pitch;
+	}
+
+	return head + 1;
+}
+
+static int Mask_evaluateSymbol(int width, unsigned char *frame)
+{
+	int x, y;
+	int demerit = 0;
+	int runLength[QRSPEC_WIDTH_MAX + 1];
+	int length;
+
+	demerit += Mask_calcN2(width, frame);
+
+	for(y=0; y<width; y++) {
+		length = Mask_calcRunLength(width, frame + y * width, 0, runLength);
+		demerit += Mask_calcN1N3(length, runLength);
+	}
+
+	for(x=0; x<width; x++) {
+		length = Mask_calcRunLength(width, frame + x, 1, runLength);
+		demerit += Mask_calcN1N3(length, 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 blacks;
+	int bratio;
+	int demerit;
+	int w2 = width * width;
+
+	mask = (unsigned char *)malloc(w2);
+	if(mask == NULL) return NULL;
+	bestMask = NULL;
+
+	for(i=0; i<maskNum; i++) {
+//		n1 = n2 = n3 = n4 = 0;
+		demerit = 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;
+			free(bestMask);
+			bestMask = mask;
+			mask = (unsigned char *)malloc(w2);
+			if(mask == NULL) break;
+		}
+	}
+	free(mask);
+	return bestMask;
+}
diff --git a/ap/app/qrencode/mask.h b/ap/app/qrencode/mask.h
new file mode 100644
index 0000000..d9e1e5d
--- /dev/null
+++ b/ap/app/qrencode/mask.h
@@ -0,0 +1,37 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Masking.
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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__
+
+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);
+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);
+extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask);
+#endif
+
+#endif /* __MASK_H__ */
diff --git a/ap/app/qrencode/mmask.c b/ap/app/qrencode/mmask.c
new file mode 100644
index 0000000..8d14235
--- /dev/null
+++ b/ap/app/qrencode/mmask.c
@@ -0,0 +1,177 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Masking for Micro QR Code.
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.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 + 7 - i] = v;
+		format = format >> 1;
+	}
+}
+
+#define MASKMAKER(__exp__) \
+	int x, y;\
+\
+	for(y=0; y<width; y++) {\
+		for(x=0; x<width; x++) {\
+			if(*s & 0x80) {\
+				*d = *s;\
+			} else {\
+				*d = *s ^ ((__exp__) == 0);\
+			}\
+			s++; d++;\
+		}\
+	}
+
+static void Mask_mask0(int width, const unsigned char *s, unsigned char *d)
+{
+	MASKMAKER(y&1)
+}
+
+static void Mask_mask1(int width, const unsigned char *s, unsigned char *d)
+{
+	MASKMAKER(((y/2)+(x/3))&1)
+}
+
+static void Mask_mask2(int width, const unsigned char *s, unsigned char *d)
+{
+	MASKMAKER((((x*y)&1)+(x*y)%3)&1)
+}
+
+static void Mask_mask3(int width, const unsigned char *s, unsigned char *d)
+{
+	MASKMAKER((((x+y)&1)+((x*y)%3))&1)
+}
+
+#define maskNum (4)
+typedef void MaskMaker(int, const unsigned char *, unsigned char *);
+static MaskMaker *maskMakers[maskNum] = {
+	Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3
+};
+
+#ifdef WITH_TESTS
+unsigned char *MMask_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;
+}
+#endif
+
+unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level)
+{
+	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;
+
+	maskMakers[mask](width, frame, masked);
+	MMask_writeFormatInformation(version, width, masked, mask, level);
+
+	return masked;
+}
+
+static int MMask_evaluateSymbol(int width, unsigned char *frame)
+{
+	int x, y;
+	unsigned char *p;
+	int sum1 = 0, sum2 = 0;
+
+	p = frame + width * (width - 1);
+	for(x=1; x<width; x++) {
+		sum1 += (p[x] & 1);
+	}
+
+	p = frame + width * 2 - 1;
+	for(y=1; y<width; y++) {
+		sum2 += (*p & 1);
+		p += width;
+	}
+
+	return (sum1 <= sum2)?(sum1 * 16 + sum2):(sum2 * 16 + sum1);
+}
+
+unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level)
+{
+	int i;
+	unsigned char *mask, *bestMask;
+	int maxScore = 0;
+	int score;
+	int width;
+
+	width = MQRspec_getWidth(version);
+
+	mask = (unsigned char *)malloc(width * width);
+	if(mask == NULL) return NULL;
+	bestMask = NULL;
+
+	for(i=0; i<maskNum; i++) {
+		score = 0;
+		maskMakers[i](width, frame, mask);
+		MMask_writeFormatInformation(version, width, mask, i, level);
+		score = MMask_evaluateSymbol(width, mask);
+		if(score > maxScore) {
+			maxScore = score;
+			free(bestMask);
+			bestMask = mask;
+			mask = (unsigned char *)malloc(width * width);
+			if(mask == NULL) break;
+		}
+	}
+	free(mask);
+	return bestMask;
+}
diff --git a/ap/app/qrencode/mmask.h b/ap/app/qrencode/mmask.h
new file mode 100644
index 0000000..f6556e8
--- /dev/null
+++ b/ap/app/qrencode/mmask.h
@@ -0,0 +1,34 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Masking for Micro QR Code.
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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);
+
+#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/ap/app/qrencode/mqrspec.c b/ap/app/qrencode/mqrspec.c
new file mode 100644
index 0000000..76d2d26
--- /dev/null
+++ b/ap/app/qrencode/mqrspec.c
@@ -0,0 +1,280 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Micor QR Code specification in convenient format. 
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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
+ */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#ifdef HAVE_LIBPTHREAD
+#include <pthread.h>
+#endif
+
+#include "mqrspec.h"
+
+/******************************************************************************
+ * Version and capacity
+ *****************************************************************************/
+
+typedef struct {
+	int width; //< Edge length of the symbol
+	int ec[4];  //< Number of ECC code (bytes)
+} MQRspec_Capacity;
+
+/**
+ * Table of the capacity of symbols
+ * 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, 0}},
+	{ 11, {2,  0,  0, 0}},
+	{ 13, {5,  6,  0, 0}},
+	{ 15, {6,  8,  0, 0}},
+	{ 17, {8, 10, 14, 0}}
+};
+
+int MQRspec_getDataLengthBit(int version, QRecLevel level)
+{
+	int w;
+	int ecc;
+
+	w = mqrspecCapacity[version].width - 1;
+	ecc = mqrspecCapacity[version].ec[level];
+	if(ecc == 0) return 0;
+	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];
+}
+
+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;
+}
+
+/******************************************************************************
+ * Format information
+ *****************************************************************************/
+
+/* See calcFormatInfo in tests/test_mqrspec.c */
+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},
+	{0x4b1c, 0x5af7, 0x68ca, 0x7921, 0x0987, 0x186c, 0x2a51, 0x3bba}
+};
+
+/* See Table 10 of Appendix 1. (pp.115) */
+static const int 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];
+#ifdef HAVE_LIBPTHREAD
+static pthread_mutex_t frames_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
+/**
+ * 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);
+	if(frame == NULL) return NULL;
+
+	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<width-7; x++) {
+		*p =  0x90 | (x & 1);
+		*q =  0x90 | (x & 1);
+		p++;
+		q += width;
+	}
+
+	return frame;
+}
+
+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
+}
diff --git a/ap/app/qrencode/mqrspec.h b/ap/app/qrencode/mqrspec.h
new file mode 100644
index 0000000..2d4b90d
--- /dev/null
+++ b/ap/app/qrencode/mqrspec.h
@@ -0,0 +1,157 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Micro QR Code specification in convenient format. 
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 width of a symbol
+ */
+#define MQRSPEC_WIDTH_MAX 17
+
+/**
+ * Return maximum data code length (bits) for the version.
+ * @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);
+
+/**
+ * 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 MQRspec_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 MQRspec_maximumWords(QRencodeMode mode, int version);
+
+/******************************************************************************
+ * 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().
+ */
+extern unsigned char *MQRspec_newFrame(int version);
+
+/**
+ * Clear the frame cache. Typically for debug.
+ */
+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/ap/app/qrencode/png2bmp.c b/ap/app/qrencode/png2bmp.c
new file mode 100755
index 0000000..8f82f98
--- /dev/null
+++ b/ap/app/qrencode/png2bmp.c
@@ -0,0 +1,526 @@
+#include "common.h"
+#include "bmphed.h"
+
+#define PNG2BMP_VERSION		"1.62"
+#define PNG2BMP_COPYRIGHT	"Copyright"
+
+#define ZLIB_VERSION "1.2.3"
+
+char outnam[FILENAME_MAX];
+char outdir[FILENAME_MAX];
+int  deletesrc = 0;
+int  copytime  = 0;
+
+#define P2B_ALPHABMP_NONE		0
+#define P2B_ALPHABMP_ARGB		1	
+#define P2B_ALPHABMP_BITFIELD	2	
+
+int alpha_format = P2B_ALPHABMP_NONE;
+int expand_trans = 0;
+
+const char errlogfile[] = "./p2berror.log";
+
+
+const char wrn_mkdirfail[]   =
+        "WARNING: Can not create directory - %s\n"
+        "WARNING: Output directory specified by '-%c' will be ignored.\n";
+
+const char err_ropenfail[]   = "SKIPPED: No such file or directory - %s\n";
+const char err_wopenfail[]   = "SKIPPED: Cannot create - %s\n";
+const char err_outofmemory[] = "SKIPPED: Out of memory - %s\n";
+
+const char err_writeerr[]    = "SKIPPED: Write operation failed - %s\n";
+const char err_not_a_png[]   = "SKIPPED: Not a PNG file - %s\n";
+
+static BOOL read_png(char *, IMAGE *);
+static int skip_macbinary(png_structp);
+static void to4bpp(png_structp, png_row_infop, png_bytep);
+static BOOL write_bmp(char *, IMAGE *);
+static const char *write_rgb_bits(IMAGE *, FILE *);
+static void mputdwl(void *, unsigned long);
+static void mputwl(void *, unsigned int);
+static void usage_exit(char *, int);
+
+#define ERROR_ABORT(s) do { errmsg = (s); goto error_abort; } while (0)
+
+static BOOL read_png(char *fn, IMAGE *img)
+{
+	png_structp png_ptr;
+	png_infop info_ptr, end_info;
+	png_uint_32 width, height;
+	int bit_depth, color_type;
+	int xbit_depth, xcolor_type, xchannels;
+	const char *errmsg;
+	FILE *fp;
+
+	imgbuf_init(img);
+
+	if (fn == NULL) {
+		fn = " (stdin)";
+		fp = binary_stdio(fileno(stdin));
+	} else {
+		fp = fopen(fn, "rb");
+	}
+	if (fp == NULL) ERROR_ABORT(err_ropenfail);
+
+	set_status("Reading %.80s", basname(fn));
+
+	/* ------------------------------------------------------ */
+
+	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, fn,
+	                                   png_my_error, png_my_warning);
+	if (png_ptr == NULL) {
+		ERROR_ABORT(err_outofmemory);
+	}
+	info_ptr = png_create_info_struct(png_ptr);
+	end_info = png_create_info_struct(png_ptr);
+	if (info_ptr == NULL || end_info == NULL) {
+		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+		ERROR_ABORT(err_outofmemory);
+	}
+	if (setjmp(png_jmpbuf(png_ptr))) {
+		/* If we get here, we had a problem writing the file */
+		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+		ERROR_ABORT(NULL);
+	}
+	png_init_io(png_ptr, fp);
+	png_set_sig_bytes(png_ptr, skip_macbinary(png_ptr));
+
+	/* ------------------------------------------------------ */
+
+	png_read_info(png_ptr, info_ptr);
+
+	png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
+	             &color_type, NULL, NULL, NULL);
+
+	/* ------------------------------------------------------ */
+
+	if (color_type & PNG_COLOR_MASK_ALPHA) {
+		if (alpha_format == P2B_ALPHABMP_NONE) {
+			png_set_strip_alpha(png_ptr);
+			color_type &= ~PNG_COLOR_MASK_ALPHA;
+		}
+	} else if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+		if (alpha_format != P2B_ALPHABMP_NONE && expand_trans) {
+			png_set_tRNS_to_alpha(png_ptr);
+			color_type |=  PNG_COLOR_MASK_ALPHA;
+			color_type &= ~PNG_COLOR_MASK_PALETTE;
+		}
+	}
+	if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
+		png_set_gray_to_rgb(png_ptr);
+	}
+	if (color_type == PNG_COLOR_TYPE_RGB ||
+		color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
+		png_set_bgr(png_ptr);
+	}
+	if (!(color_type & PNG_COLOR_MASK_ALPHA) && bit_depth == 2) {
+		png_set_user_transform_info(png_ptr, NULL, 4, 1);
+		png_set_read_user_transform_fn(png_ptr, to4bpp);
+	}
+	if (bit_depth == 16)
+		png_set_strip_16(png_ptr);
+
+	png_read_update_info(png_ptr, info_ptr);
+
+	/* ------------------------------------------------------ */
+
+	png_get_IHDR(png_ptr, info_ptr, &width, &height, &xbit_depth,
+	             &xcolor_type, NULL, NULL, NULL);
+	xchannels = png_get_channels(png_ptr, info_ptr);
+
+	img->width    = (LONG)width;
+	img->height   = (LONG)height;
+	img->pixdepth = (UINT)xbit_depth * xchannels;
+	img->palnum   = (img->pixdepth <= 8) ? (1 << img->pixdepth) : 0;
+	img->topdown  = FALSE;
+	img->alpha    = (xcolor_type & PNG_COLOR_MASK_ALPHA) ? TRUE : FALSE;
+
+	if (!imgbuf_alloc(img)) {
+		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+		ERROR_ABORT(err_outofmemory);
+	}
+
+	if (img->palnum > 0) {
+		if (xcolor_type == PNG_COLOR_TYPE_PALETTE) {
+			png_colorp palette;
+			int num_palette;
+			png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
+			if (num_palette > (int)img->palnum) num_palette = img->palnum;
+			memset(img->palette,       0, img->palnum * sizeof(png_color));
+			memcpy(img->palette, palette, num_palette * sizeof(png_color));
+		} else {
+			int depth = (bit_depth == 16) ? 8 : bit_depth;
+			memset(img->palette, 0, img->palnum * sizeof(png_color));
+			png_build_grayscale_palette(depth, img->palette);
+		}
+	}
+
+	/* ------------------------------------------------------ */
+
+	png_set_read_status_fn(png_ptr, row_callback);
+	init_progress_meter(png_ptr, img->width, img->height);
+
+	png_read_image(png_ptr, img->rowptr);
+
+	png_read_end(png_ptr, end_info);
+	png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+
+	/* ------------------------------------------------------ */
+
+	set_status("Read OK %.80s", basname(fn));
+
+	if (fp != stdin) fclose(fp);
+
+	return TRUE;
+
+error_abort:				/* error */
+	if (errmsg != NULL) xxprintf(errmsg, fn);
+	if (fp != stdin && fp != NULL) fclose(fp);
+	imgbuf_free(img);
+
+	return FALSE;
+}
+
+static int skip_macbinary(png_structp png_ptr)
+{
+	enum { PNG_BYTES_TO_CHECK = 8, MACBIN_SIZE = 128 };
+	png_byte buf[MACBIN_SIZE];
+	png_bytep sig;
+	png_size_t check;
+	png_FILE_p fp = (png_FILE_p)png_get_io_ptr(png_ptr);
+
+	check = (png_size_t)fread(buf, 1, PNG_BYTES_TO_CHECK, fp);
+	if (check != PNG_BYTES_TO_CHECK) png_error(png_ptr, "Read Error");
+
+	if (png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK) == 0)
+								return PNG_BYTES_TO_CHECK;
+
+	check = (png_size_t)fread(buf, 1, MACBIN_SIZE, fp);
+	if (check != MACBIN_SIZE) png_error(png_ptr, "Read Error");
+
+	sig = buf + MACBIN_SIZE - PNG_BYTES_TO_CHECK;
+	if (png_sig_cmp(sig, 0, PNG_BYTES_TO_CHECK) == 0)
+								return PNG_BYTES_TO_CHECK;
+
+	xxprintf(err_not_a_png, (char *)png_get_error_ptr(png_ptr));
+	longjmp(png_jmpbuf(png_ptr), 1);
+
+	return 0;	/* to quiet compiler warnings */
+}
+
+static void to4bpp(png_structp png_ptr, png_row_infop row_info, png_bytep data)
+{
+	static const png_byte pix[] = {
+		0x00, 0x01, 0x02, 0x03,  0x10, 0x11, 0x12, 0x13,
+		0x20, 0x21, 0x22, 0x23,  0x30, 0x31, 0x32, 0x33,
+	};
+	png_uint_32 rowb;
+	png_bytep p, q;
+	png_byte c;
+
+	rowb = (row_info->width + 1) / 2;
+	q = data + rowb;
+	p = data + rowb / 2;
+
+	if (rowb % 2 == 1) {
+		c = *p;
+		*(--q) = pix[c >> 4];
+	}
+	while (p > data) {
+		c = *(--p);
+		*(--q) = pix[c & 0x0F];
+		*(--q) = pix[c >> 4];
+	}
+	row_info->bit_depth   = 4;
+	row_info->pixel_depth = 4;
+	row_info->rowbytes    = rowb;
+}
+
+static BOOL write_bmp(char *fn, IMAGE *img)
+{
+	BYTE bfh[FILEHED_SIZE + BMPV4HED_SIZE];
+	BYTE *const bih = bfh + FILEHED_SIZE;
+	BYTE rgbq[RGBQUAD_SIZE];
+	BOOL alpha_bitfield;
+	DWORD bihsize, offbits, filesize;
+	PALETTE *pal;
+	const char *errmsg;
+	FILE *fp;
+	UINT i;
+
+	if (fn == NULL) {
+		fn = " (stdout)";
+		fp = binary_stdio(fileno(stdout));
+	} else {
+		fp = fopen(fn, "wb");
+	}
+	if (fp == NULL) ERROR_ABORT(err_wopenfail);
+
+	set_status("Writing %.80s", basname(fn));
+
+	/* ------------------------------------------------------ */
+
+	alpha_bitfield = (img->alpha && alpha_format == P2B_ALPHABMP_BITFIELD);
+	bihsize = (alpha_bitfield) ? BMPV4HED_SIZE : INFOHED_SIZE;
+	offbits = FILEHED_SIZE + bihsize + RGBQUAD_SIZE * img->palnum;
+	filesize = offbits + img->imgbytes;
+
+	memset(bfh, 0, sizeof(bfh));
+
+	mputwl( bfh + BFH_WTYPE   , BMP_SIGNATURE);
+	mputdwl(bfh + BFH_DSIZE   , filesize);
+	mputdwl(bfh + BFH_DOFFBITS, offbits);
+
+	mputdwl(bih + BIH_DSIZE     , bihsize);
+	mputdwl(bih + BIH_LWIDTH    , (DWORD)img->width);
+	mputdwl(bih + BIH_LHEIGHT   , (DWORD)img->height);
+	mputwl( bih + BIH_WPLANES   , 1);
+	mputwl( bih + BIH_WBITCOUNT , img->pixdepth);
+	mputdwl(bih + BIH_DSIZEIMAGE, img->imgbytes);
+
+	if (alpha_bitfield) {
+		mputdwl(bih + BIH_DCOMPRESSION, BI_BITFIELDS);
+		mputdwl(bih + B4H_DALPHAMASK, 0xFF000000);
+		mputdwl(bih + B4H_DREDMASK  , 0x00FF0000);
+		mputdwl(bih + B4H_DGREENMASK, 0x0000FF00);
+		mputdwl(bih + B4H_DBLUEMASK , 0x000000FF);
+	}
+
+	if (fwrite(bfh, (FILEHED_SIZE + bihsize), 1, fp) != 1)
+		ERROR_ABORT(err_writeerr);
+
+	/* ------------------------------------------------------ */
+
+	memset(rgbq, 0, sizeof(rgbq));
+
+	for (pal = img->palette, i = img->palnum; i > 0; i--, pal++) {
+		rgbq[RGBQ_RED]   = pal->red;
+		rgbq[RGBQ_GREEN] = pal->green;
+		rgbq[RGBQ_BLUE]  = pal->blue;
+		if (fwrite(rgbq, RGBQUAD_SIZE, 1, fp) != 1)
+			ERROR_ABORT(err_writeerr);
+	}
+
+	/* ------------------------------------------------------ */
+
+	if ((errmsg = write_rgb_bits(img, fp)) != NULL) ERROR_ABORT(errmsg);
+
+	/* ------------------------------------------------------ */
+
+	set_status("OK      %.80s", basname(fn));
+	feed_line();
+
+	fflush(fp);
+	if (fp != stdout) fclose(fp);
+	imgbuf_free(img);
+
+	return TRUE;
+
+error_abort:				/* error */
+	xxprintf(errmsg, fn);
+	if (fp != stdout && fp != NULL) fclose(fp);
+	imgbuf_free(img);
+
+	return FALSE;
+}
+
+static const char *write_rgb_bits(IMAGE *img, FILE *fp)
+{
+	DWORD wr  = 16*1024*1024;
+	DWORD num = img->imgbytes;
+	BYTE *ptr = img->bmpbits;
+
+	while (num > 0) {
+		if (wr > num) wr = num;
+
+		if (fwrite(ptr, wr, 1, fp) != 1)
+			return err_writeerr;
+
+		ptr += wr; num -= wr;
+	}
+
+	return NULL;
+}
+
+static void mputdwl(void *ptr, unsigned long val)
+{
+	unsigned char *p = ptr;
+
+	p[0] = (unsigned char)(val       & 0xFF);
+	p[1] = (unsigned char)(val >>  8 & 0xFF);
+	p[2] = (unsigned char)(val >> 16 & 0xFF);
+	p[3] = (unsigned char)(val >> 24 & 0xFF);
+}
+
+static void mputwl(void *ptr, unsigned int val)
+{
+	unsigned char *p = ptr;
+
+	p[0] = (unsigned char)(val      & 0xFF);
+	p[1] = (unsigned char)(val >> 8 & 0xFF);
+}
+
+static void usage_exit(char *argv0, int status)
+{
+	static const char str_usage[] =
+		"png2bmp\n";
+
+	fprintf(stdout, str_usage, argv0, argv0, errlogfile);
+
+	exit(status);
+}
+
+int main(int argc, char *argv[])
+{
+	char outf[FILENAME_MAX];
+	IMAGE image;
+	int opt;
+	char *arg;
+	char *p, c;
+	int r_stdin, w_stdout;
+	int failure = 0, success = 0;
+
+	envargv(&argc, &argv, "B2P");
+
+	r_stdin  = !isatty(fileno(stdin));
+	w_stdout = !isatty(fileno(stdout));
+
+	while (parsearg(&opt, &arg, argc, argv, "DdOoFfPp")) {
+		switch (toupper(opt)) {
+		case 'E':  deletesrc ^= 1;  break;
+		case 'T':  copytime  ^= 1;  break;
+		case 'Q':  quietmode ^= 1;  break;
+		case 'L':  errorlog  ^= 1;  break;
+
+		case 'X':
+			r_stdin  = 0;
+			w_stdout = 0;
+			break;
+
+		case 'A':
+			alpha_format = (alpha_format == P2B_ALPHABMP_ARGB) ?
+			                P2B_ALPHABMP_NONE : P2B_ALPHABMP_ARGB;
+			break;
+
+		case 'B':
+			alpha_format = (alpha_format == P2B_ALPHABMP_BITFIELD) ?
+			                P2B_ALPHABMP_NONE : P2B_ALPHABMP_BITFIELD;
+			break;
+
+		case 'R':
+			expand_trans ^= 1;
+			break;
+
+		case 'F':
+			/* '-F' option of bmp2png (ignored on png2bmp) */
+			break;
+
+		case 'P':
+			/* '-P' option of bmp2png (ignored on png2bmp) */
+			break;
+
+		case 'D':				/* output directory */
+			if (*arg == '-') arg = NULL;
+			if (arg == NULL) {
+				outdir[0] = '\0';
+			} else {
+				strcpy(outdir, arg);
+				addslash(outdir);
+				if (makedir(outdir) != 0) {
+					xxprintf(wrn_mkdirfail, outdir, 'D');
+					outdir[0] = '\0';
+				}
+			}
+			break;
+
+		case 'O':				/* output filename */
+			if (arg == NULL) {
+				outnam[0] = '\0';
+			} else {
+				strcpy(outnam, arg);
+				p = basname(outnam);
+				c = *p;  *p = '\0';
+				if (makedir(outnam) != 0) {
+					xxprintf(wrn_mkdirfail, outnam, 'O');
+					outnam[0] = '\0';
+				} else {
+					*p = c;
+				}
+			}
+			break;
+
+		case 0x00:				/* input file spec */
+			if (outnam[0] != '\0') {
+				strcpy(outf, outnam);
+				outnam[0] = '\0';
+			} else if (w_stdout) {
+				if (!read_png(arg, &image)) return 1;
+				if (!write_bmp(NULL, &image)) return 1;
+				if (deletesrc) remove(arg);
+				return 0;
+			} else {
+				if (outdir[0] != '\0') {
+					strcat(strcpy(outf, outdir), basname(arg));
+				} else {
+					strcpy(outf, arg);
+				}
+
+				strcpy(suffix(outf), ".bmp");
+			}
+			/* ---------------------- */
+			printf("png2bmp read_png 2222222\n");
+			if (!read_png(arg, &image)) {
+				printf("png2bmp read_png arg image\n");
+				failure++;
+				break;
+			}
+			renbak(outf);
+			printf("png2bmp read_png 3333333\n");
+			if (!write_bmp(outf, &image)) {
+				printf("png2bmp read_png outf image\n");
+				failure++;
+				break;
+			}
+			/* ---------------------- */
+			if (copytime) cpyftime(arg, outf);
+			if (deletesrc) remove(arg);
+			/* ---------------------- */
+			success++;
+			break;
+
+		default:
+			;		/* Ignore unknown option */
+		}
+	}
+	printf("png2bmp failure is %d, success is %d,  r_stdin is %d, w_stdout is %d \n", failure, success, r_stdin, w_stdout);
+	if (failure == 0 && success == 0) {
+		if (!r_stdin)
+		{
+			printf("png2bmp  usage_exit\n");
+			usage_exit(argv[0], 255);
+		}
+		printf("png2bmp  111111111\n");
+		if (!read_png(NULL, &image))
+		{
+			printf("png2bmp  read_png NULL\n");
+			return 1;
+		}
+		if (outnam[0] != '\0') {
+			printf("png2bmp  write_bmp outnam is %s\n", outnam);
+			renbak(outnam);
+			return !write_bmp(outnam, &image);
+		} else if (w_stdout) {
+			printf("png2bmp  write_bmp w_stdout\n");
+			return !write_bmp(NULL, &image);
+		} else {
+			printf("png2bmp  write_bmp outf is %s\n", outf);
+			strcat(strcpy(outf, outdir), "___stdin.bmp");
+			renbak(outf);
+			return !write_bmp(outf, &image);
+		}
+	}
+    printf("png2bmp  end  failure is %d\n", failure);
+	return (failure > 255) ? 255 : failure;
+}
+
diff --git a/ap/app/qrencode/qrenc.c b/ap/app/qrencode/qrenc.c
new file mode 100644
index 0000000..f4b2c46
--- /dev/null
+++ b/ap/app/qrencode/qrenc.c
@@ -0,0 +1,1142 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/
+
+/**
+ * qrencode - QR Code encoder
+ *
+ * QR Code encoding tool
+ * Copyright (C) 2006-2012 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <png.h>
+#include <getopt.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;
+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,
+	EPS_TYPE,
+	SVG_TYPE,
+	ANSI_TYPE,
+	ANSI256_TYPE,
+	ASCII_TYPE,
+	ASCIIi_TYPE,
+	UTF8_TYPE,
+	ANSIUTF8_TYPE
+};
+
+static enum imageType image_type = PNG_TYPE;
+
+static const struct option options[] = {
+	{"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'},
+	{"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'},
+	{"foreground"	, required_argument, NULL, 'f'},
+	{"background"	, required_argument, NULL, 'b'},
+	{"version"      , no_argument      , NULL, 'V'},
+	{NULL, 0, NULL, 0}
+};
+
+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-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 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 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"
+"  -s NUMBER, --size=NUMBER\n"
+"               specify module size in dots (pixels). (default=3)\n\n"
+"  -l {LMQH}, --level={LMQH}\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 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"
+"               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"
+"  -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"
+"  -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"
+"               standard input.\n"
+			);
+		} else {
+			fprintf(stderr,
+"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"
+"  --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"
+"               (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,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"
+"  -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"
+"  --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"
+			);
+		}
+	}
+}
+
+static int color_set(unsigned int color[4], const char *value)
+{
+	int len = strlen(value);
+	int count;
+	if(len == 6) {
+		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) {
+		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;
+	}
+	return 0;
+}
+
+#define MAX_DATA_SIZE (7090 * 16) /* from the specification */
+static unsigned char *readStdin(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, stdin);
+	if(ret == 0) {
+		fprintf(stderr, "No input data.\n");
+		exit(EXIT_FAILURE);
+	}
+	if(feof(stdin) == 0) {
+		fprintf(stderr, "Input data is too large.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	buffer[ret] = '\0';
+	*length = ret;
+
+	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.
+	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;
+
+	realwidth = (qrcode->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) {
+		fprintf(stderr, "Failed to initialize PNG writer.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	info_ptr = png_create_info_struct(png_ptr);
+	if(info_ptr == NULL) {
+		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);
+		fprintf(stderr, "Failed to write PNG image.\n");
+		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_PALETTE,
+			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 */
+	memset(row, 0xff, (realwidth + 7) / 8);
+	for(y=0; y<margin * size; y++) {
+		png_write_row(png_ptr, row);
+	}
+
+	/* data */
+	p = qrcode->data;
+	for(y=0; y<qrcode->width; y++) {
+		bit = 7;
+		memset(row, 0xff, (realwidth + 7) / 8);
+		q = row;
+		q += margin * size / 8;
+		bit = 7 - (margin * size % 8);
+		for(x=0; x<qrcode->width; x++) {
+			for(xx=0; xx<size; xx++) {
+				*q ^= (*p & 1) << bit;
+				bit--;
+				if(bit < 0) {
+					q++;
+					bit = 7;
+				}
+			}
+			p++;
+		}
+		for(yy=0; yy<size; yy++) {
+			png_write_row(png_ptr, row);
+		}
+	}
+	/* bottom margin */
+	memset(row, 0xff, (realwidth + 7) / 8);
+	for(y=0; y<margin * size; y++) {
+		png_write_row(png_ptr, row);
+	}
+
+	png_write_end(png_ptr, info_ptr);
+	png_destroy_write_struct(&png_ptr, &info_ptr);
+
+	fclose(fp);
+	free(row);
+	if(palette != NULL)
+	{
+		free(palette);
+	}
+	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 writeSVG_writeRect(FILE *fp, int x, int y, int width, char* col, float opacity)
+{
+	if(fg_color[3] != 255) {
+		fprintf(fp, "\t\t\t<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"1\" "\
+				"fill=\"#%s\" fill-opacity=\"%f\" />\n", 
+				x, y, width, col, opacity );
+	} else {
+		fprintf(fp, "\t\t\t<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"1\" "\
+				"fill=\"#%s\" />\n", 
+				x, y, width, col );
+	}
+}
+
+static int writeSVG( QRcode *qrcode, const char *outfile )
+{
+	FILE *fp;
+	unsigned char *row, *p;
+	int x, y, x0, pen;
+	int symwidth, realwidth;
+	float scale;
+	char fg[7], bg[7];
+	float fg_opacity;
+	float bg_opacity;
+
+	fp = openFile(outfile);
+
+	scale = dpi * INCHES_PER_METER / 100.0;
+
+	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]);
+	fg_opacity = (float)fg_color[3] / 255;
+	bg_opacity = (float)bg_color[3] / 255;
+
+	/* XML declaration */
+	fputs( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\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, "<!-- Created with qrencode %s (http://fukuchi.org/works/qrencode/index.html.en) -->\n", 
+			QRcode_APIVersionString() );
+
+	/* SVG code start */
+	fprintf( fp, "<svg width=\"%0.2fcm\" height=\"%0.2fcm\" viewBox=\"0 0 %d %d\""\
+			" preserveAspectRatio=\"none\" version=\"1.1\""\
+			" xmlns=\"http://www.w3.org/2000/svg\">\n", 
+			realwidth / scale, realwidth / scale, symwidth, symwidth
+		   );
+
+	/* Make named group */
+	fputs( "\t<g id=\"QRcode\">\n", fp );
+
+	/* Make solid background */
+	if(bg_color[3] != 255) {
+		fprintf(fp, "\t\t<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" fill-opacity=\"%f\" />\n", symwidth, symwidth, bg, bg_opacity);
+	} else {
+		fprintf(fp, "\t\t<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", symwidth, symwidth, bg);
+	}
+
+	/* Create new viewbox for QR data */
+	fputs( "\t\t<g id=\"Pattern\">\n", fp);
+
+	/* Write data */
+	p = qrcode->data;
+	for(y=0; y<qrcode->width; y++) {
+		row = (p+(y*qrcode->width));
+
+		/* simple RLE */
+		pen = 0;
+		x0  = 0;
+		for(x=0; x<qrcode->width; 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</g>\n", fp );
+
+	/* Close group */
+	fputs( "\t</g>\n", fp );
+
+	/* Close SVG code */
+	fputs( "</svg>\n", fp );
+	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 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;
+
+	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;
+
+	if(micro) {
+		if(eightbit) {
+			code = QRcode_encodeDataMQR(length, intext, version, level);
+		} else {
+			code = QRcode_encodeStringMQR((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);
+		}
+	}
+
+	return code;
+}
+
+static void qrencode(const unsigned char *intext, int length, const char *outfile)
+{
+	QRcode *qrcode;
+	
+	qrcode = encode(intext, length);
+	if(qrcode == NULL) {
+		perror("Failed to encode the input data");
+		exit(EXIT_FAILURE);
+	}
+	switch(image_type) {
+		case PNG_TYPE:
+			writePNG(qrcode, outfile);
+			break;
+		case EPS_TYPE:
+			writeEPS(qrcode, outfile);
+			break;
+		case SVG_TYPE:
+			writeSVG(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;
+		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);
+	}
+	QRcode_free(qrcode);
+}
+
+static QRcode_List *encodeStructured(const unsigned char *intext, int length)
+{
+	QRcode_List *list;
+
+	if(eightbit) {
+		list = QRcode_encodeDataStructured(length, intext, version, level);
+	} else {
+		list = QRcode_encodeStringStructured((char *)intext, version, level, hint, casesensitive);
+	}
+
+	return list;
+}
+
+static void qrencodeStructured(const unsigned char *intext, int length, const char *outfile)
+{
+	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 SVG_TYPE:
+			type_suffix = ".svg";
+			break;
+		case ANSI_TYPE:
+		case ANSI256_TYPE:
+		case ASCII_TYPE:
+		case UTF8_TYPE:
+		case ANSIUTF8_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);
+	}
+	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';
+		}
+	}
+	
+	qrlist = encodeStructured(intext, length);
+	if(qrlist == NULL) {
+		perror("Failed to encode the input data");
+		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(EXIT_FAILURE);
+		}
+		if(suffix) {
+			snprintf(filename, FILENAME_MAX, "%s-%02d%s", base, i, suffix);
+		} else {
+			snprintf(filename, FILENAME_MAX, "%s-%02d", base, i);
+		}
+		switch(image_type) {
+			case PNG_TYPE: 
+				writePNG(p->code, filename);
+				break;
+			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);
+				break;
+			case ASCIIi_TYPE:
+				writeASCII(p->code, filename, 1);
+				break;
+			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);
+		}
+		i++;
+	}
+
+	free(base);
+	if(suffix) {
+		free(suffix);
+	}
+
+	QRcode_List_free(qrlist);
+}
+
+int main(int argc, char **argv)
+{
+	int opt, lindex = -1;
+	char *outfile = NULL;
+	unsigned char *intext = NULL;
+	int length = 0;
+
+	while((opt = getopt_long(argc, argv, optstring, options, &lindex)) != -1) {
+		switch(opt) {
+			case 'h':
+				if(lindex == 0) {
+					usage(1, 1);
+				} else {
+					usage(1, 0);
+				}
+				exit(EXIT_SUCCESS);
+				break;
+			case 'o':
+				outfile = optarg;
+				break;
+			case 's':
+				size = atoi(optarg);
+				if(size <= 0) {
+					fprintf(stderr, "Invalid size: %d\n", size);
+					exit(EXIT_FAILURE);
+				}
+				break;
+			case 'v':
+				version = atoi(optarg);
+				if(version < 0) {
+					fprintf(stderr, "Invalid version: %d\n", version);
+					exit(EXIT_FAILURE);
+				}
+				break;
+			case 'l':
+				switch(*optarg) {
+					case 'l':
+					case 'L':
+						level = QR_ECLEVEL_L;
+						break;
+					case 'm':
+					case 'M':
+						level = QR_ECLEVEL_M;
+						break;
+					case 'q':
+					case 'Q':
+						level = QR_ECLEVEL_Q;
+						break;
+					case 'h':
+					case 'H':
+						level = QR_ECLEVEL_H;
+						break;
+					default:
+						fprintf(stderr, "Invalid level: %s\n", optarg);
+						exit(EXIT_FAILURE);
+						break;
+				}
+				break;
+			case 'm':
+				margin = atoi(optarg);
+				if(margin < 0) {
+					fprintf(stderr, "Invalid margin: %d\n", margin);
+					exit(EXIT_FAILURE);
+				}
+				break;
+			case 'd':
+				dpi = atoi(optarg);
+				if( dpi < 0 ) {
+					fprintf(stderr, "Invalid DPI: %d\n", dpi);
+					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, "svg") == 0) {
+					image_type = SVG_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 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);
+				}
+				break;
+			case 'S':
+				structured = 1;
+			case 'k':
+				hint = QR_MODE_KANJI;
+				break;
+			case 'c':
+				casesensitive = 1;
+				break;
+			case 'i':
+				casesensitive = 0;
+				break;
+			case '8':
+				eightbit = 1;
+				break;
+			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);
+				break;
+			default:
+				fprintf(stderr, "Try `qrencode --help' for more information.\n");
+				exit(EXIT_FAILURE);
+				break;
+		}
+	}
+
+	if(argc == 1) {
+		usage(1, 0);
+		exit(EXIT_SUCCESS);
+	}
+
+	if(outfile == NULL && image_type == PNG_TYPE) {
+		fprintf(stderr, "No output filename is given.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if(optind < argc) {
+		intext = (unsigned char *)argv[optind];
+		length = strlen((char *)intext);
+	}
+	if(intext == NULL) {
+		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(structured) {
+		if(version == 0) {
+			fprintf(stderr, "Version must be specified to encode structured symbols.\n");
+			exit(EXIT_FAILURE);
+		}
+		qrencodeStructured(intext, length, outfile);
+	} else {
+		qrencode(intext, length, outfile);
+	}
+
+	return 0;
+}
diff --git a/ap/app/qrencode/qrencode.c b/ap/app/qrencode/qrencode.c
new file mode 100644
index 0000000..466c02a
--- /dev/null
+++ b/ap/app/qrencode/qrencode.c
@@ -0,0 +1,927 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Copyright (C) 2006-2012 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "qrencode.h"
+#include "qrspec.h"
+#include "mqrspec.h"
+#include "bitstream.h"
+#include "qrinput.h"
+#include "rscode.h"
+#include "split.h"
+#include "mask.h"
+#include "mmask.h"
+
+/******************************************************************************
+ * Raw code
+ *****************************************************************************/
+
+typedef struct {
+	int dataLength;
+	unsigned char *data;
+	int eccLength;
+	unsigned char *ecc;
+} RSblock;
+
+typedef struct {
+	int version;
+	int dataLength;
+	int eccLength;
+	unsigned char *datacode;
+	unsigned char *ecccode;
+	int b1;
+	int blocks;
+	RSblock *rsblock;
+	int count;
+} QRRawCode;
+
+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 = ecc;
+
+	encode_rs_char(rs, data, ecc);
+}
+
+static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsigned char *ecc)
+{
+	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; i<QRspec_rsBlockNum1(spec); i++) {
+		RSblock_initBlock(block, dl, dp, el, ep, rs);
+		dp += dl;
+		ep += el;
+		block++;
+	}
+
+	if(QRspec_rsBlockNum2(spec) == 0) return 0;
+
+	dl = QRspec_rsDataCodes2(spec);
+	el = QRspec_rsEccCodes2(spec);
+	rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el);
+	if(rs == NULL) return -1;
+	for(i=0; i<QRspec_rsBlockNum2(spec); i++) {
+		RSblock_initBlock(block, dl, dp, el, ep, rs);
+		dp += dl;
+		ep += el;
+		block++;
+	}
+
+	return 0;
+}
+
+static void QRraw_free(QRRawCode *raw);
+static QRRawCode *QRraw_new(QRinput *input)
+{
+	QRRawCode *raw;
+	int spec[5], ret;
+
+	raw = (QRRawCode *)malloc(sizeof(QRRawCode));
+	if(raw == NULL) return NULL;
+
+	raw->datacode = QRinput_getByteStream(input);
+	if(raw->datacode == NULL) {
+		free(raw);
+		return NULL;
+	}
+
+	QRspec_getEccSpec(input->version, input->level, spec);
+
+	raw->version = input->version;
+	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;
+	}
+
+	raw->blocks = QRspec_rsBlockNum(spec);
+	raw->rsblock = (RSblock *)calloc(raw->blocks, sizeof(RSblock));
+	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;
+}
+
+/**
+ * Return a code (byte).
+ * This function can be called iteratively.
+ * @param raw raw code.
+ * @return code
+ */
+static 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[0].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;
+}
+
+static void QRraw_free(QRRawCode *raw)
+{
+	if(raw != NULL) {
+		free(raw->datacode);
+		free(raw->ecccode);
+		free(raw->rsblock);
+		free(raw);
+	}
+}
+
+/******************************************************************************
+ * Raw code for Micro QR Code
+ *****************************************************************************/
+
+typedef struct {
+	int version;
+	int dataLength;
+	int eccLength;
+	unsigned char *datacode;
+	unsigned char *ecccode;
+	RSblock *rsblock;
+	int oddbits;
+	int count;
+} MQRRawCode;
+
+static void MQRraw_free(MQRRawCode *raw);
+static MQRRawCode *MQRraw_new(QRinput *input)
+{
+	MQRRawCode *raw;
+	RS *rs;
+
+	raw = (MQRRawCode *)malloc(sizeof(MQRRawCode));
+	if(raw == NULL) return NULL;
+
+	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);
+		return NULL;
+	}
+	raw->ecccode = (unsigned char *)malloc(raw->eccLength);
+	if(raw->ecccode == NULL) {
+		free(raw->datacode);
+		free(raw);
+		return NULL;
+	}
+
+	raw->rsblock = (RSblock *)calloc(1, sizeof(RSblock));
+	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, raw->dataLength, raw->datacode, raw->eccLength, raw->ecccode, rs);
+
+	raw->count = 0;
+
+	return raw;
+}
+
+/**
+ * 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);
+	}
+}
+
+
+/******************************************************************************
+ * Frame filling
+ *****************************************************************************/
+
+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];
+}
+
+#ifdef WITH_TESTS
+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, 0);
+	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; i<length; i++) {
+		p = FrameFiller_next(filler);
+		if(p == NULL) {
+			free(filler);
+			free(frame);
+			return NULL;
+		}
+		*p = (unsigned char)(i & 0x7f) | 0x80;
+	}
+	free(filler);
+	return frame;
+}
+
+extern unsigned char *FrameFiller_testMQR(int version)
+{
+	int width;
+	unsigned char *frame, *p;
+	FrameFiller *filler;
+	int i, length;
+
+	width = MQRspec_getWidth(version);
+	frame = MQRspec_newFrame(version);
+	if(frame == NULL) return NULL;
+	filler = FrameFiller_new(width, frame, 1);
+	if(filler == NULL) {
+		free(frame);
+		return NULL;
+	}
+	length = MQRspec_getDataLengthBit(version, QR_ECLEVEL_L)
+	       + MQRspec_getECCLength(version, QR_ECLEVEL_L) * 8;
+	for(i=0; i<length; i++) {
+		p = FrameFiller_next(filler);
+		if(p == NULL) {
+			fprintf(stderr, "Frame filler run over the frame!\n");
+			free(filler);
+			return frame;
+		}
+		*p = (unsigned char)(i & 0x7f) | 0x80;
+	}
+	free(filler);
+	return frame;
+}
+#endif
+
+
+/******************************************************************************
+ * QR-code encoding
+ *****************************************************************************/
+
+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;
+
+	return qrcode;
+}
+
+void QRcode_free(QRcode *qrcode)
+{
+	if(qrcode != NULL) {
+		free(qrcode->data);
+		free(qrcode);
+	}
+}
+
+static QRcode *QRcode_encodeMask(QRinput *input, int mask)
+{
+	int width, version;
+	QRRawCode *raw;
+	unsigned char *frame, *masked, *p, code, bit;
+	FrameFiller *filler;
+	int i, j;
+	QRcode *qrcode = NULL;
+
+	if(input->mqr) {
+		errno = EINVAL;
+		return NULL;
+	}
+	if(input->version < 0 || input->version > QRSPEC_VERSION_MAX) {
+		errno = EINVAL;
+		return NULL;
+	}
+	if(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);
+	if(frame == NULL) {
+		QRraw_free(raw);
+		return NULL;
+	}
+	filler = FrameFiller_new(width, frame, 0);
+	if(filler == NULL) {
+		QRraw_free(raw);
+		free(frame);
+		return NULL;
+	}
+
+	/* inteleaved data and ecc codes */
+	for(i=0; i<raw->dataLength + raw->eccLength; i++) {
+		code = QRraw_getCode(raw);
+		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; i<j; i++) {
+		p = FrameFiller_next(filler);
+		if(p == NULL)  goto EXIT;
+		*p = 0x02;
+	}
+
+	/* masking */
+	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);
+	}
+	if(masked == NULL) {
+		goto EXIT;
+	}
+	qrcode = QRcode_new(version, width, masked);
+
+EXIT:
+	QRraw_free(raw);
+	free(filler);
+	free(frame);
+	return qrcode;
+}
+
+static QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask)
+{
+	int width, version;
+	MQRRawCode *raw;
+	unsigned char *frame, *masked, *p, code, bit;
+	FrameFiller *filler;
+	int i, j;
+	QRcode *qrcode = 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;
+	}
+
+	raw = MQRraw_new(input);
+	if(raw == NULL) return NULL;
+
+	version = raw->version;
+	width = MQRspec_getWidth(version);
+	frame = MQRspec_newFrame(version);
+	if(frame == NULL) {
+		MQRraw_free(raw);
+		return NULL;
+	}
+	filler = FrameFiller_new(width, frame, 1);
+	if(filler == NULL) {
+		MQRraw_free(raw);
+		free(frame);
+		return NULL;
+	}
+
+	/* inteleaved data and ecc codes */
+	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; j<raw->oddbits; j++) {
+				p = FrameFiller_next(filler);
+				if(p == NULL) goto EXIT;
+				*p = 0x02 | ((bit & code) != 0);
+				bit = bit >> 1;
+			}
+		} 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;
+			}
+		}
+	}
+	MQRraw_free(raw);
+	raw = NULL;
+
+	/* masking */
+	if(mask < 0) {
+		masked = MMask_mask(version, frame, input->level);
+	} else {
+		masked = MMask_makeMask(version, frame, mask, input->level);
+	}
+	if(masked == NULL) {
+		goto EXIT;
+	}
+
+	qrcode = QRcode_new(version, width, masked);
+
+EXIT:
+	MQRraw_free(raw);
+	free(filler);
+	free(frame);
+	return qrcode;
+}
+
+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 mqr, QRencodeMode hint, int casesensitive)
+{
+	QRinput *input;
+	QRcode *code;
+	int ret;
+
+	if(string == NULL) {
+		errno = EINVAL;
+		return NULL;
+	}
+	if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) {
+		errno = EINVAL;
+		return NULL;
+	}
+
+	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(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 {
+		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;
+	}
+	code = QRcode_encodeInput(input);
+	QRinput_free(input);
+
+	return code;
+}
+
+QRcode *QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level)
+{
+	return QRcode_encodeDataReal(data, size, version, level, 0);
+}
+
+QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level)
+{
+	if(string == NULL) {
+		errno = EINVAL;
+		return NULL;
+	}
+	return QRcode_encodeDataReal((unsigned char *)string, strlen(string), version, level, 0);
+}
+
+QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level)
+{
+	return QRcode_encodeDataReal(data, size, version, level, 1);
+}
+
+QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level)
+{
+	if(string == NULL) {
+		errno = EINVAL;
+		return NULL;
+	}
+	return QRcode_encodeDataReal((unsigned char *)string, strlen(string), version, level, 1);
+}
+
+
+/******************************************************************************
+ * 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 != 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; i<size; i++) {
+		parity ^= str[i];
+	}
+
+	return parity;
+}
+#endif
+
+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) {
+			entry = QRcode_List_newEntry();
+			if(entry == NULL) goto ABORT;
+			head = entry;
+			tail = head;
+		} else {
+			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) {
+			goto ABORT;
+		}
+		list = list->next;
+	}
+
+	return head;
+ABORT:
+	QRcode_List_free(head);
+	return NULL;
+}
+
+static QRcode_List *QRcode_encodeInputToStructured(QRinput *input)
+{
+	QRinput_Struct *s;
+	QRcode_List *codes;
+
+	s = QRinput_splitQRinputToStruct(input);
+	if(s == NULL) return NULL;
+
+	codes = QRcode_encodeInputStructured(s);
+	QRinput_Struct_free(s);
+
+	return codes;
+}
+
+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;
+	int ret;
+
+	if(version <= 0) {
+		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;
+
+	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;
+	}
+	codes = QRcode_encodeInputToStructured(input);
+	QRinput_free(input);
+
+	return codes;
+}
+
+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);
+}
+
+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);
+}
+
+QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
+{
+	if(string == NULL) {
+		errno = EINVAL;
+		return NULL;
+	}
+	return QRcode_encodeDataStructuredReal(strlen(string), (unsigned char *)string, version, level, 0, hint, casesensitive);
+}
+
+/******************************************************************************
+ * 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();
+	MQRspec_clearCache();
+	free_rs_cache();
+}
diff --git a/ap/app/qrencode/qrencode.h b/ap/app/qrencode/qrencode.h
new file mode 100644
index 0000000..e554bb9
--- /dev/null
+++ b/ap/app/qrencode/qrencode.h
@@ -0,0 +1,566 @@
+/**
+ * qrencode - QR Code encoder
+ *
+ * Copyright (C) 2006-2012 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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
+ */
+
+/** \mainpage
+ * Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D
+ * symbology.
+ *
+ * \section encoding Encoding
+ * 
+ * There are two methods to encode data: <b>encoding a string/data</b> or 
+ * <b>encoding a structured data</b>.
+ *
+ * \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
+ * 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.
+ * 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
+ * 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
+ * input data is known, you can use this way.
+ * 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.
+ *
+ * \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().
+ *
+ * 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 a
+ * 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__
+#define __QRENCODE_H__
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * 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_FNC1FIRST,  ///< FNC1, first position
+	QR_MODE_FNC1SECOND, ///< FNC1, second position
+} QRencodeMode;
+
+/**
+ * Level of error correction.
+ */
+typedef enum {
+	QR_ECLEVEL_L = 0, ///< lowest
+	QR_ECLEVEL_M,
+	QR_ECLEVEL_Q,
+	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)
+ *****************************************************************************/
+
+/**
+ * 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. 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);
+
+/**
+ * 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);
+
+/**
+ * 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.
+ * @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_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data);
+
+/**
+ * Append ECI header.
+ * @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.
+ *            See Execptions for the details.
+ * @throw ENOMEM unable to allocate memory.
+ * @throw EINVAL input data is invalid.
+ *
+ */
+extern int QRinput_appendECIheader(QRinput *input, unsigned int ecinum);
+
+/**
+ * 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.
+ * This function cannot be applied to Micro QR Code.
+ * @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.
+ * This function cannot be applied to Micro QR Code.
+ * @param input input object.
+ * @param level Error correction level.
+ * @retval 0 success.
+ * @retval -1 invalid argument.
+ */
+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.
+ * @param input input object.
+ */
+extern void QRinput_free(QRinput *input);
+
+/**
+ * Validate the input data.
+ * @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. 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);
+
+/**
+ * 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. 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
+ *         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);
+
+/**
+ * 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)
+ *****************************************************************************/
+
+/**
+ * QRcode class.
+ * 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 its specification is described.
+ *
+ * <pre>
+ * 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.)
+ * </pre>
+ */
+typedef struct {
+	int version;         ///< version of the symbol
+	int width;           ///< width of the symbol
+	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 *code;
+	struct _QRcode_List *next;
+} QRcode_List;
+
+/**
+ * Create a symbol from the input data.
+ * @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,
+ *         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);
+
+/**
+ * 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 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.
+ * @param level error correction level.
+ * @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,
+ *         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.
+ * @throw ERANGE input data is too large.
+ */
+extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
+
+/**
+ * Same to QRcode_encodeString(), but encode whole data in 8-bit mode.
+ * @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 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 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 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
+ *                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 when pthread is disabled.
+ */
+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.
+ */
+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
+ * @return a singly-linked list of QRcode.
+ */
+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 when pthread is disabled.
+ * @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 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.
+ * @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_encodeStringStructured(), but encode whole data in 8-bit mode.
+ * @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 when pthread is disabled.
+ * @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.
+ * @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);
+
+
+/******************************************************************************
+ * 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.
+ * @warning This function is THREAD UNSAFE when pthread is disabled.
+ */
+extern void QRcode_clearCache(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __QRENCODE_H__ */
diff --git a/ap/app/qrencode/qrencode_inner.h b/ap/app/qrencode/qrencode_inner.h
new file mode 100644
index 0000000..3c40d06
--- /dev/null
+++ b/ap/app/qrencode/qrencode_inner.h
@@ -0,0 +1,88 @@
+/**
+ * qrencode - QR Code encoder
+ *
+ * Header for test use
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 __QRENCODE_INNER_H__
+#define __QRENCODE_INNER_H__
+
+/**
+ * This header file includes definitions for test use.
+ */
+
+/******************************************************************************
+ * Raw code
+ *****************************************************************************/
+
+typedef struct {
+	int dataLength;
+	unsigned char *data;
+	int eccLength;
+	unsigned char *ecc;
+} RSblock;
+
+typedef struct {
+	int version;
+	int dataLength;
+	int eccLength;
+	unsigned char *datacode;
+	unsigned char *ecccode;
+	int b1;
+	int blocks;
+	RSblock *rsblock;
+	int count;
+} QRRawCode;
+
+extern QRRawCode *QRraw_new(QRinput *input);
+extern unsigned char QRraw_getCode(QRRawCode *raw);
+extern void QRraw_free(QRRawCode *raw);
+
+/******************************************************************************
+ * Raw code for Micro QR Code
+ *****************************************************************************/
+
+typedef struct {
+	int version;
+	int dataLength;
+	int eccLength;
+	unsigned char *datacode;
+	unsigned char *ecccode;
+	RSblock *rsblock;
+	int oddbits;
+	int count;
+} MQRRawCode;
+
+extern MQRRawCode *MQRraw_new(QRinput *input);
+extern unsigned char MQRraw_getCode(MQRRawCode *raw);
+extern void MQRraw_free(MQRRawCode *raw);
+
+/******************************************************************************
+ * Frame filling
+ *****************************************************************************/
+extern unsigned char *FrameFiller_test(int version);
+extern unsigned char *FrameFiller_testMQR(int version);
+
+/******************************************************************************
+ * QR-code encoding
+ *****************************************************************************/
+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__ */
diff --git a/ap/app/qrencode/qrinput.c b/ap/app/qrencode/qrinput.c
new file mode 100644
index 0000000..f5e9e8e
--- /dev/null
+++ b/ap/app/qrencode/qrinput.c
@@ -0,0 +1,1729 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Input data chunk class
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "qrencode.h"
+#include "qrspec.h"
+#include "mqrspec.h"
+#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
+ *****************************************************************************/
+
+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;
+	if(size > 0) {
+		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;
+
+	return entry;
+}
+
+static void QRinput_List_freeEntry(QRinput_List *entry)
+{
+	if(entry != NULL) {
+		free(entry->data);
+		BitStream_free(entry->bstream);
+		free(entry);
+	}
+}
+
+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_H) {
+		errno = EINVAL;
+		return NULL;
+	}
+
+	input = (QRinput *)malloc(sizeof(QRinput));
+	if(input == NULL) return NULL;
+
+	input->head = NULL;
+	input->tail = NULL;
+	input->version = version;
+	input->level = level;
+	input->mqr = 0;
+	input->fnc1 = 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;
+}
+
+int QRinput_setVersion(QRinput *input, int version)
+{
+	if(input->mqr || version < 0 || version > QRSPEC_VERSION_MAX) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	input->version = version;
+
+	return 0;
+}
+
+QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input)
+{
+	return input->level;
+}
+
+int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level)
+{
+	if(input->mqr || level > QR_ECLEVEL_H) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	input->level = 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) {
+		input->head = entry;
+		input->tail = entry;
+	} else {
+		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;
+}
+
+/**
+ * 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];
+
+	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;
+}
+
+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;
+
+	if(input != NULL) {
+		list = input->head;
+		while(list != NULL) {
+			next = list->next;
+			QRinput_List_freeEntry(list);
+			list = next;
+		}
+		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;
+
+	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;
+	while(list != NULL) {
+		e = QRinput_List_dup(list);
+		if(e == NULL) {
+			QRinput_free(n);
+			return NULL;
+		}
+		QRinput_appendEntry(n, e);
+		list = list->next;
+	}
+
+	return n;
+}
+
+/******************************************************************************
+ * Numeric data
+ *****************************************************************************/
+
+/**
+ * Check the input data.
+ * @param size
+ * @param data
+ * @return result
+ */
+static int QRinput_checkModeNum(int size, const char *data)
+{
+	int i;
+
+	for(i=0; i<size; i++) {
+		if(data[i] < '0' || data[i] > '9')
+			return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * Estimates the length of the encoded bit stream of numeric data.
+ * @param size
+ * @return number of bits
+ */
+int QRinput_estimateBitsModeNum(int size)
+{
+	int w;
+	int bits;
+
+	w = size / 3;
+	bits = w * 10;
+	switch(size - w * 3) {
+		case 1:
+			bits += 4;
+			break;
+		case 2:
+			bits += 7;
+			break;
+		default:
+			break;
+	}
+
+	return bits;
+}
+
+/**
+ * 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, 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);
+			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, QRSPEC_MODEID_NUM);
+		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; 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');
+
+		ret = BitStream_appendNum(entry->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);
+		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;
+}
+
+/******************************************************************************
+ * Alphabet-numeric data
+ *****************************************************************************/
+
+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,
+	 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, -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
+};
+
+/**
+ * Check the input data.
+ * @param size
+ * @param data
+ * @return result
+ */
+static int QRinput_checkModeAn(int size, const char *data)
+{
+	int i;
+
+	for(i=0; i<size; i++) {
+		if(QRinput_lookAnTable(data[i]) < 0)
+			return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * Estimates the length of the encoded bit stream of alphabet-numeric data.
+ * @param size
+ * @return number of bits
+ */
+int QRinput_estimateBitsModeAn(int size)
+{
+	int w;
+	int bits;
+
+	w = size / 2;
+	bits = w * 11;
+	if(size & 1) {
+		bits += 6;
+	}
+
+	return bits;
+}
+
+/**
+ * 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, 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);
+		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, 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;
+	}
+
+	words = entry->size / 2;
+	for(i=0; i<words; i++) {
+		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);
+		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);
+		if(ret < 0) goto ABORT;
+	}
+
+	return 0;
+ABORT:
+	BitStream_free(entry->bstream);
+	entry->bstream = NULL;
+	return -1;
+}
+
+/******************************************************************************
+ * 8 bit data
+ *****************************************************************************/
+
+/**
+ * Estimates the length of the encoded bit stream of 8 bit data.
+ * @param size
+ * @return number of bits
+ */
+int QRinput_estimateBitsMode8(int size)
+{
+	return size * 8;
+}
+
+/**
+ * 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, 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);
+		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, 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;
+	}
+
+	ret = BitStream_appendBytes(entry->bstream, entry->size, entry->data);
+	if(ret < 0) goto ABORT;
+
+	return 0;
+ABORT:
+	BitStream_free(entry->bstream);
+	entry->bstream = NULL;
+	return -1;
+}
+
+
+/******************************************************************************
+ * Kanji data
+ *****************************************************************************/
+
+/**
+ * Estimates the length of the encoded bit stream of kanji data.
+ * @param size
+ * @return number of bits
+ */
+int QRinput_estimateBitsModeKanji(int size)
+{
+	return (size / 2) * 13;
+}
+
+/**
+ * Check the input data.
+ * @param size
+ * @param data
+ * @return result
+ */
+static int QRinput_checkModeKanji(int size, const unsigned char *data)
+{
+	int i;
+	unsigned int val;
+
+	if(size & 1)
+		return -1;
+
+	for(i=0; i<size; i+=2) {
+		val = ((unsigned int)data[i] << 8) | data[i+1];
+		if(val < 0x8140 || (val > 0x9ffc && val < 0xe040) || val > 0xebbf) {
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+/**
+ * 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, 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);
+		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, 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;
+	}
+
+	for(i=0; i<entry->size; 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;
+
+		ret = BitStream_appendNum(entry->bstream, 13, val);
+		if(ret < 0) goto ABORT;
+	}
+
+	return 0;
+ABORT:
+	BitStream_free(entry->bstream);
+	entry->bstream = NULL;
+	return -1;
+}
+
+/******************************************************************************
+ * Structured Symbol
+ *****************************************************************************/
+
+/**
+ * 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, int mqr)
+{
+	int ret;
+
+	if(mqr) {
+		errno = EINVAL;
+		return -1;
+	}
+	entry->bstream = BitStream_new();
+	if(entry->bstream == NULL) return -1;
+
+	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;
+	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;
+}
+
+/******************************************************************************
+ * 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;
+}
+
+/******************************************************************************
+ * 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
+ *****************************************************************************/
+
+int QRinput_check(QRencodeMode mode, int size, const unsigned char *data)
+{
+	if((mode == QR_MODE_FNC1FIRST && size < 0) || size <= 0) return -1;
+
+	switch(mode) {
+		case QR_MODE_NUM:
+			return QRinput_checkModeNum(size, (const char *)data);
+		case QR_MODE_AN:
+			return QRinput_checkModeAn(size, (const char *)data);
+		case QR_MODE_KANJI:
+			return QRinput_checkModeKanji(size, data);
+		case QR_MODE_8:
+			return 0;
+		case QR_MODE_STRUCTURE:
+			return 0;
+		case QR_MODE_ECI:
+			return 0;
+		case QR_MODE_FNC1FIRST:
+			return 0;
+		case QR_MODE_FNC1SECOND:
+			return QRinput_checkModeFNC1Second(size, data);
+		case QR_MODE_NUL:
+			break;
+	}
+
+	return -1;
+}
+
+/******************************************************************************
+ * 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
+ * @param mqr
+ * @return number of bits
+ */
+static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version, int mqr)
+{
+	int bits = 0;
+	int l, m;
+	int num;
+
+	if(version == 0) version = 1;
+
+	switch(entry->mode) {
+		case QR_MODE_NUM:
+			bits = QRinput_estimateBitsModeNum(entry->size);
+			break;
+		case QR_MODE_AN:
+			bits = QRinput_estimateBitsModeAn(entry->size);
+			break;
+		case QR_MODE_8:
+			bits = QRinput_estimateBitsMode8(entry->size);
+			break;
+		case QR_MODE_KANJI:
+			bits = QRinput_estimateBitsModeKanji(entry->size);
+			break;
+		case QR_MODE_STRUCTURE:
+			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;
+	}
+
+	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 * (MODE_INDICATOR_SIZE + l);
+	}
+
+	return bits;
+}
+
+/**
+ * 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
+ */
+static int QRinput_estimateBitStreamSize(QRinput *input, int version)
+{
+	QRinput_List *list;
+	int bits = 0;
+
+	list = input->head;
+	while(list != NULL) {
+		bits += QRinput_estimateBitStreamSizeOfEntry(list, version, input->mqr);
+		list = list->next;
+	}
+
+	return bits;
+}
+
+/**
+ * Estimates the required version number of the symbol.
+ * @param input input data
+ * @return required version number
+ */
+static int QRinput_estimateVersion(QRinput *input)
+{
+	int bits;
+	int version, prev;
+
+	version = 0;
+	do {
+		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;
+}
+
+/**
+ * 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.
+ */
+static 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(maxsize > 0 && size > maxsize) size = maxsize;
+
+	return size;
+}
+
+/******************************************************************************
+ * Data conversion
+ *****************************************************************************/
+
+/**
+ * Convert the input data in the data chunk to a bit stream.
+ * @param entry
+ * @return number of bits (>0) or -1 for failure.
+ */
+static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr)
+{
+	int words, ret;
+	QRinput_List *st1 = NULL, *st2 = NULL;
+
+	if(entry->bstream != NULL) {
+		BitStream_free(entry->bstream);
+		entry->bstream = NULL;
+	}
+
+	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;
+		st2 = QRinput_List_newEntry(entry->mode, entry->size - words, &entry->data[words]);
+		if(st2 == NULL) goto ABORT;
+
+		ret = QRinput_encodeBitStream(st1, version, 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);
+		if(ret < 0) goto ABORT;
+		QRinput_List_freeEntry(st1);
+		QRinput_List_freeEntry(st2);
+	} else {
+		ret = 0;
+		switch(entry->mode) {
+			case QR_MODE_NUM:
+				ret = QRinput_encodeModeNum(entry, version, mqr);
+				break;
+			case QR_MODE_AN:
+				ret = QRinput_encodeModeAn(entry, version, mqr);
+				break;
+			case QR_MODE_8:
+				ret = QRinput_encodeMode8(entry, version, mqr);
+				break;
+			case QR_MODE_KANJI:
+				ret = QRinput_encodeModeKanji(entry, version, mqr);
+				break;
+			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:
+				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.
+ * @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, total = 0;
+
+	list = input->head;
+	while(list != NULL) {
+		bits = QRinput_encodeBitStream(list, input->version, input->mqr);
+		if(bits < 0) return -1;
+		total += bits;
+		list = list->next;
+	}
+
+	return total;
+}
+
+/**
+ * Convert the input data to a bit stream.
+ * When the version number is given and that is not sufficient, it is increased
+ * automatically.
+ * @param input 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 ERANGE input is too large.
+ */
+static int QRinput_convertData(QRinput *input)
+{
+	int bits;
+	int ver;
+
+	ver = QRinput_estimateVersion(input);
+	if(ver > QRinput_getVersion(input)) {
+		QRinput_setVersion(input, ver);
+	}
+
+	for(;;) {
+		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)) {
+			QRinput_setVersion(input, ver);
+		} else {
+			break;
+		}
+	}
+
+	return 0;
+}
+
+/**
+ * Append padding bits for the input data.
+ * @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.
+ *            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)
+{
+	int bits, maxbits, words, maxwords, i, ret;
+	BitStream *padding = NULL;
+	unsigned char *padbuf;
+	int padlen;
+
+	bits = BitStream_size(bstream);
+	maxwords = QRspec_getDataLength(input->version, input->level);
+	maxbits = maxwords * 8;
+
+	if(maxbits < bits) {
+		errno = ERANGE;
+		return -1;
+	}
+	if(maxbits == bits) {
+		return 0;
+	}
+
+	if(maxbits - bits <= 4) {
+		ret = BitStream_appendNum(bstream, maxbits - bits, 0);
+		goto DONE;
+	}
+
+	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; i<padlen; i++) {
+			padbuf[i] = (i&1)?0x11:0xec;
+		}
+		ret = BitStream_appendBytes(padding, padlen, padbuf);
+		free(padbuf);
+		if(ret < 0) {
+			goto DONE;
+		}
+	}
+
+	ret = BitStream_append(bstream, padding);
+
+DONE:
+	BitStream_free(padding);
+	return ret;
+}
+
+/**
+ * Append padding bits for the input data - Micro QR Code version.
+ * @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.
+ *            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)
+{
+	int bits, maxbits, words, maxwords, i, ret, termbits;
+	BitStream *padding = NULL;
+	unsigned char *padbuf;
+	int padlen;
+
+	bits = BitStream_size(bstream);
+	maxbits = MQRspec_getDataLengthBit(input->version, input->level);
+	maxwords = maxbits / 8;
+
+	if(maxbits < bits) {
+		errno = ERANGE;
+		return -1;
+	}
+	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, termbits, 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; i<padlen; i++) {
+			padbuf[i] = (i&1)?0x11:0xec;
+		}
+		ret = BitStream_appendBytes(padding, padlen, padbuf);
+		free(padbuf);
+		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);
+
+DONE:
+	BitStream_free(padding);
+	return ret;
+}
+
+static int QRinput_insertFNC1Header(QRinput *input)
+{
+	QRinput_List *entry = NULL;
+
+	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.
+ * @return merged bit stream
+ */
+
+static BitStream *QRinput_mergeBitStream(QRinput *input)
+{
+	BitStream *bstream;
+	QRinput_List *list;
+	int ret;
+
+	if(input->mqr) {
+		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;
+		}
+	}
+
+	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;
+		}
+		list = list->next;
+	}
+
+	return bstream;
+}
+
+/**
+ * Merge all bit streams in the input data and append padding bits
+ * @param input input data.
+ * @return padded merged bit stream
+ */
+
+static BitStream *QRinput_getBitStream(QRinput *input)
+{
+	BitStream *bstream;
+	int ret;
+
+	bstream = QRinput_mergeBitStream(input);
+	if(bstream == NULL) {
+		return NULL;
+	}
+	if(input->mqr) {
+		ret = QRinput_appendPaddingBitMQR(bstream, input);
+	} else {
+		ret = QRinput_appendPaddingBit(bstream, input);
+	}
+	if(ret < 0) {
+		BitStream_free(bstream);
+		return NULL;
+	}
+
+	return bstream;
+}
+
+/**
+ * Pack all bit streams padding bits into a byte array.
+ * @param input input data.
+ * @return padded merged byte stream
+ */
+
+unsigned char *QRinput_getByteStream(QRinput *input)
+{
+	BitStream *bstream;
+	unsigned char *array;
+
+	bstream = QRinput_getBitStream(input);
+	if(bstream == NULL) {
+		return NULL;
+	}
+	array = BitStream_toByte(bstream);
+	BitStream_free(bstream);
+
+	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 void QRinput_InputList_freeEntry(QRinput_InputList *entry)
+{
+	if(entry != NULL) {
+		QRinput_free(entry->input);
+		free(entry);
+	}
+}
+
+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;
+
+	if(input->mqr) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	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, *next;
+	
+	if(s != NULL) {
+		list = s->head;
+		while(list != NULL) {
+			next = list->next;
+			QRinput_InputList_freeEntry(list);
+			list = next;
+		}
+		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;
+}
+
+static 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, ret;
+	QRinput_List *list, *next, *prev;
+
+	if(input->mqr) {
+		errno = EINVAL;
+		return NULL;
+	}
+
+	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_SIZE;
+
+	if(maxbits <= 0) {
+		QRinput_Struct_free(s);
+		QRinput_free(input);
+		return NULL;
+	}
+
+	bits = 0;
+	list = input->head;
+	prev = NULL;
+	while(list != NULL) {
+		nextbits = QRinput_estimateBitStreamSizeOfEntry(list, input->version, input->mqr);
+		if(bits + nextbits <= maxbits) {
+			ret = QRinput_encodeBitStream(list, input->version, input->mqr);
+			if(ret < 0) goto ABORT;
+			bits += ret;
+			prev = list;
+			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) {
+					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->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->head = list;
+				p->tail = input->tail;
+				input->tail = prev;
+			}
+			ret = QRinput_Struct_appendInput(s, input);
+			if(ret < 0) {
+				QRinput_free(p);
+				goto ABORT;
+			}
+			input = p;
+			bits = 0;
+		}
+	}
+	ret = QRinput_Struct_appendInput(s, input);
+	if(ret < 0) goto ABORT;
+	if(s->size > MAX_STRUCTURED_SYMBOLS) {
+		QRinput_Struct_free(s);
+		errno = ERANGE;
+		return NULL;
+	}
+	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)
+{
+	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;
+}
+
+/******************************************************************************
+ * 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/ap/app/qrencode/qrinput.h b/ap/app/qrencode/qrinput.h
new file mode 100644
index 0000000..9e6bad6
--- /dev/null
+++ b/ap/app/qrencode/qrinput.h
@@ -0,0 +1,123 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Input data chunk class
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 __QRINPUT_H__
+#define __QRINPUT_H__
+
+#include "qrencode.h"
+#include "bitstream.h"
+
+int QRinput_isSplittableMode(QRencodeMode mode);
+
+/******************************************************************************
+ * Entry of input data
+ *****************************************************************************/
+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
+ *****************************************************************************/
+struct _QRinput {
+	int version;
+	QRecLevel level;
+	QRinput_List *head;
+	QRinput_List *tail;
+	int mqr;
+	int fnc1;
+	unsigned char appid;
+};
+
+/******************************************************************************
+ * Structured append input data
+ *****************************************************************************/
+typedef struct _QRinput_InputList QRinput_InputList;
+
+struct _QRinput_InputList {
+	QRinput *input;
+	QRinput_InputList *next;
+};
+
+struct _QRinput_Struct {
+	int size;					///< number of structured symbols
+	int parity;
+	QRinput_InputList *head;
+	QRinput_InputList *tail;
+};
+
+/**
+ * Pack all bit streams padding bits into a byte array.
+ * @param input input data.
+ * @return padded merged byte stream
+ */
+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);
+extern int QRinput_estimateBitsModeKanji(int size);
+
+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).
+ * @param __c__ character
+ * @return value
+ */
+#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_SIZE 20
+
+/**
+ * Maximum number of symbols in a set of structured-appended symbols.
+ */
+#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__ */
diff --git a/ap/app/qrencode/qrspec.c b/ap/app/qrencode/qrspec.c
new file mode 100644
index 0000000..a42706f
--- /dev/null
+++ b/ap/app/qrencode/qrspec.c
@@ -0,0 +1,562 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * QR Code specification in convenient format. 
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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
+ */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#ifdef HAVE_LIBPTHREAD
+#include <pthread.h>
+#endif
+
+#include "qrspec.h"
+#include "qrinput.h"
+
+/******************************************************************************
+ * Version and capacity
+ *****************************************************************************/
+
+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)
+} QRspec_Capacity;
+
+/**
+ * Table of the capacity of symbols
+ * See Table 1 (pp.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}},
+	{ 21,   26, 0, {   7,   10,   13,   17}}, // 1
+	{ 25,   44, 7, {  10,   16,   22,   28}},
+	{ 29,   70, 7, {  15,   26,   36,   44}},
+	{ 33,  100, 7, {  20,   36,   52,   64}},
+	{ 37,  134, 7, {  26,   48,   72,   88}}, // 5
+	{ 41,  172, 7, {  36,   64,   96,  112}},
+	{ 45,  196, 0, {  40,   72,  108,  130}},
+	{ 49,  242, 0, {  48,   88,  132,  156}},
+	{ 53,  292, 0, {  60,  110,  160,  192}},
+	{ 57,  346, 0, {  72,  130,  192,  224}}, //10
+	{ 61,  404, 0, {  80,  150,  224,  264}},
+	{ 65,  466, 0, {  96,  176,  260,  308}},
+	{ 69,  532, 0, { 104,  198,  288,  352}},
+	{ 73,  581, 3, { 120,  216,  320,  384}},
+	{ 77,  655, 3, { 132,  240,  360,  432}}, //15
+	{ 81,  733, 3, { 144,  280,  408,  480}},
+	{ 85,  815, 3, { 168,  308,  448,  532}},
+	{ 89,  901, 3, { 180,  338,  504,  588}},
+	{ 93,  991, 3, { 196,  364,  546,  650}},
+	{ 97, 1085, 3, { 224,  416,  600,  700}}, //20
+	{101, 1156, 4, { 224,  442,  644,  750}},
+	{105, 1258, 4, { 252,  476,  690,  816}},
+	{109, 1364, 4, { 270,  504,  750,  900}},
+	{113, 1474, 4, { 300,  560,  810,  960}},
+	{117, 1588, 4, { 312,  588,  870, 1050}}, //25
+	{121, 1706, 4, { 336,  644,  952, 1110}},
+	{125, 1828, 4, { 360,  700, 1020, 1200}},
+	{129, 1921, 3, { 390,  728, 1050, 1260}},
+	{133, 2051, 3, { 420,  784, 1140, 1350}},
+	{137, 2185, 3, { 450,  812, 1200, 1440}}, //30
+	{141, 2323, 3, { 480,  868, 1290, 1530}},
+	{145, 2465, 3, { 510,  924, 1350, 1620}},
+	{149, 2611, 3, { 540,  980, 1440, 1710}},
+	{153, 2761, 3, { 570, 1036, 1530, 1800}},
+	{157, 2876, 0, { 570, 1064, 1590, 1890}}, //35
+	{161, 3034, 0, { 600, 1120, 1680, 1980}},
+	{165, 3196, 0, { 630, 1204, 1770, 2100}},
+	{169, 3362, 0, { 660, 1260, 1860, 2220}},
+	{173, 3532, 0, { 720, 1316, 1950, 2310}},
+	{177, 3706, 0, { 750, 1372, 2040, 2430}} //40
+};
+
+int QRspec_getDataLength(int version, QRecLevel level)
+{
+	return qrspecCapacity[version].words - qrspecCapacity[version].ec[level];
+}
+
+int QRspec_getECCLength(int version, QRecLevel level)
+{
+	return qrspecCapacity[version].ec[level];
+}
+
+int QRspec_getMinimumVersion(int size, QRecLevel level)
+{
+	int i;
+	int words;
+
+	for(i=1; i<= QRSPEC_VERSION_MAX; i++) {
+		words  = qrspecCapacity[i].words - qrspecCapacity[i].ec[level];
+		if(words >= size) return i;
+	}
+
+	return -1;
+}
+
+int QRspec_getWidth(int version)
+{
+	return qrspecCapacity[version].width;
+}
+
+int QRspec_getRemainder(int version)
+{
+	return qrspecCapacity[version].remainder;
+}
+
+/******************************************************************************
+ * Length indicator
+ *****************************************************************************/
+
+static const int lengthTableBits[4][3] = {
+	{10, 12, 14},
+	{ 9, 11, 13},
+	{ 8, 16, 16},
+	{ 8, 10, 12}
+};
+
+int QRspec_lengthIndicator(QRencodeMode mode, int version)
+{
+	int l;
+
+	if(!QRinput_isSplittableMode(mode)) return 0;
+	if(version <= 9) {
+		l = 0;
+	} else if(version <= 26) {
+		l = 1;
+	} else {
+		l = 2;
+	}
+
+	return lengthTableBits[mode][l];
+}
+
+int QRspec_maximumWords(QRencodeMode mode, int version)
+{
+	int l;
+	int bits;
+	int words;
+
+	if(!QRinput_isSplittableMode(mode)) return 0;
+	if(version <= 9) {
+		l = 0;
+	} else if(version <= 26) {
+		l = 1;
+	} else {
+		l = 2;
+	}
+
+	bits = lengthTableBits[mode][l];
+	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 12-16 (pp.30-36), JIS X0510:2004.
+ */
+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}},
+	{{ 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
+};
+
+void QRspec_getEccSpec(int version, QRecLevel level, int spec[5])
+{
+	int b1, b2;
+	int data, ecc;
+
+	b1 = eccTable[version][level][0];
+	b2 = eccTable[version][level][1];
+	data = QRspec_getDataLength(version, level);
+	ecc  = QRspec_getECCLength(version, level);
+
+	if(b2 == 0) {
+		spec[0] = b1;
+		spec[1] = data / b1;
+		spec[2] = ecc / b1;
+		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;
+	}
+}
+
+/******************************************************************************
+ * 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 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
+	{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
+};
+
+/**
+ * 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)
+{
+	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 void QRspec_putAlignmentPattern(int version, unsigned char *frame, int width)
+{
+	int d, w, x, y, cx, cy;
+
+	if(version < 2) return;
+
+	d = alignmentPattern[version][1] - alignmentPattern[version][0];
+	if(d < 0) {
+		w = 2;
+	} else {
+		w = (width - alignmentPattern[version][0]) / d + 2;
+	}
+
+	if(w * w - 3 == 1) {
+		x = alignmentPattern[version][0];
+		y = alignmentPattern[version][0];
+		QRspec_putAlignmentMarker(frame, width, x, y);
+		return;
+	}
+
+	cx = alignmentPattern[version][0];
+	for(x=1; x<w - 1; x++) {
+		QRspec_putAlignmentMarker(frame, width,  6, cx);
+		QRspec_putAlignmentMarker(frame, width, cx,  6);
+		cx += d;
+	}
+
+	cy = alignmentPattern[version][0];
+	for(y=0; y<w-1; y++) {
+		cx = alignmentPattern[version][0];
+		for(x=0; x<w-1; x++) {
+			QRspec_putAlignmentMarker(frame, width, cx, cy);
+			cx += d;
+		}
+		cy += d;
+	}
+}
+
+/******************************************************************************
+ * Version information pattern
+ *****************************************************************************/
+
+/**
+ * Version information pattern (BCH coded).
+ * See Table 1 in Appendix D (pp.68) of JIS X0510:2004.
+ */
+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,
+	0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64,
+	0x27541, 0x28c69
+};
+
+unsigned int QRspec_getVersionPattern(int version)
+{
+	if(version < 7 || version > QRSPEC_VERSION_MAX) return 0;
+
+	return versionPattern[version - 7];
+}
+
+/******************************************************************************
+ * Format information
+ *****************************************************************************/
+
+/* See calcFormatInfo in tests/test_qrspec.c */
+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},
+	{0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b}
+};
+
+unsigned int QRspec_getFormatInfo(int mask, QRecLevel level)
+{
+	if(mask < 0 || mask > 7) return 0;
+
+	return formatInfo[level][mask];
+}
+
+/******************************************************************************
+ * 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
+ * @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 *QRspec_createFrame(int version)
+{
+	unsigned char *frame, *p, *q;
+	int width;
+	int x, y;
+	unsigned int verinfo, v;
+
+	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);
+	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] = 0xc0;
+		p[width - 8] = 0xc0;
+		q[7] = 0xc0;
+		p += width;
+		q += width;
+	}
+	memset(frame + width * 7, 0xc0, 8);
+	memset(frame + width * 8 - 8, 0xc0, 8);
+	memset(frame + width * (width - 8), 0xc0, 8);
+	/* Mask format information area */
+	memset(frame + width * 8, 0x84, 9);
+	memset(frame + width * 9 - 8, 0x84, 8);
+	p = frame + 8;
+	for(y=0; y<8; y++) {
+		*p = 0x84;
+		p += width;
+	}
+	p = frame + width * (width - 7) + 8;
+	for(y=0; y<7; y++) {
+		*p = 0x84;
+		p += width;
+	}
+	/* Timing pattern */
+	p = frame + width * 6 + 8;
+	q = frame + width * 8 + 6;
+	for(x=1; x<width-15; x++) {
+		*p =  0x90 | (x & 1);
+		*q =  0x90 | (x & 1);
+		p++;
+		q += width;
+	}
+	/* Alignment pattern */
+	QRspec_putAlignmentPattern(version, frame, width);
+
+	/* Version information */
+	if(version >= 7) {
+		verinfo = QRspec_getVersionPattern(version);
+
+		p = frame + width * (width - 11);
+		v = verinfo;
+		for(x=0; x<6; x++) {
+			for(y=0; y<3; y++) {
+				p[width * y + x] = 0x88 | (v & 1);
+				v = v >> 1;
+			}
+		}
+
+		p = frame + width - 11;
+		v = verinfo;
+		for(y=0; y<6; y++) {
+			for(x=0; x<3; x++) {
+				p[x] = 0x88 | (v & 1);
+				v = v >> 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;
+
+#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
+}
diff --git a/ap/app/qrencode/qrspec.h b/ap/app/qrencode/qrspec.h
new file mode 100644
index 0000000..54a3d9f
--- /dev/null
+++ b/ap/app/qrencode/qrspec.h
@@ -0,0 +1,181 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * QR Code specification in convenient format. 
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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 __QRSPEC_H__
+#define __QRSPEC_H__
+
+#include "qrencode.h"
+
+/******************************************************************************
+ * Version and capacity
+ *****************************************************************************/
+
+/**
+ * Maximum width of a symbol
+ */
+#define QRSPEC_WIDTH_MAX 177
+
+/**
+ * Return maximum data code length (bytes) for the version.
+ * @param version
+ * @param 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
+ * @return ECC size (bytes)
+ */
+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
+ * @return version number
+ */
+extern int QRspec_getMinimumVersion(int size, QRecLevel 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
+ *****************************************************************************/
+
+/**
+ * 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
+ * @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}
+ */
+void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]);
+
+#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__[2])
+
+#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
+ *****************************************************************************/
+
+/**
+ * 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 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, 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().
+ */
+extern unsigned char *QRspec_newFrame(int version);
+
+/**
+ * Clear the frame cache. Typically for debug.
+ */
+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_FNC1FIRST  5
+#define QRSPEC_MODEID_FNC1SECOND 9
+#define QRSPEC_MODEID_STRUCTURE  3
+#define QRSPEC_MODEID_TERMINATOR 0
+ 
+#endif /* __QRSPEC_H__ */
diff --git a/ap/app/qrencode/rscode.c b/ap/app/qrencode/rscode.c
new file mode 100644
index 0000000..edc32e2
--- /dev/null
+++ b/ap/app/qrencode/rscode.c
@@ -0,0 +1,327 @@
+/*
+ * 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 <kentaro@fukuchi.org>
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#ifdef HAVE_LIBPTHREAD
+#  include <pthread.h>
+#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<<mm)-1) */
+	data_t *alpha_to;     /* log lookup table */
+	data_t *index_of;     /* Antilog lookup table */
+	data_t *genpoly;      /* Generator polynomial */
+	int nroots;     /* Number of generator roots = number of parity symbols */
+	int fcr;        /* First consecutive root, index form */
+	int prim;       /* Primitive element, index form */
+	int iprim;      /* prim-th root of 1, index form */
+	int pad;        /* Padding bytes in shortened block */
+	int gfpoly;
+	struct _RS *next;
+};
+
+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) {
+		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<<symsize))
+    goto done;
+  if(prim <= 0 || prim >= (1<<symsize))
+    goto done;
+  if(nroots < 0 || nroots >= (1<<symsize))
+    goto done; /* Can't have more roots than symbol values! */
+  if(pad < 0 || pad >= ((1<<symsize) -1 - nroots))
+    goto done; /* Too much padding */
+
+  rs = (RS *)calloc(1,sizeof(RS));
+  if(rs == NULL)
+    goto done;
+
+  rs->mm = symsize;
+  rs->nn = (1<<symsize)-1;
+  rs->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;i<rs->nn;i++){
+    rs->index_of[sr] = i;
+    rs->alpha_to[i] = sr;
+    sr <<= 1;
+    if(sr & (1<<symsize))
+      sr ^= gfpoly;
+    sr &= rs->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 <string.h>) 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<NN-NROOTS-PAD;i++){
+    feedback = INDEX_OF[data[i] ^ parity[0]];
+    if(feedback != A0){      /* feedback term is non-zero */
+#ifdef UNNORMALIZED
+      /* This line is unnecessary when GENPOLY[NROOTS] is unity, as it must
+       * always be for the polynomials constructed by init_rs()
+       */
+      feedback = MODNN(NN - GENPOLY[NROOTS] + feedback);
+#endif
+      for(j=1;j<NROOTS;j++)
+	parity[j] ^= ALPHA_TO[MODNN(feedback + GENPOLY[NROOTS-j])];
+    }
+    /* Shift */
+    memmove(&parity[0],&parity[1],sizeof(data_t)*(NROOTS-1));
+    if(feedback != A0)
+      parity[NROOTS-1] = ALPHA_TO[MODNN(feedback + GENPOLY[0])];
+    else
+      parity[NROOTS-1] = 0;
+  }
+}
diff --git a/ap/app/qrencode/rscode.h b/ap/app/qrencode/rscode.h
new file mode 100644
index 0000000..5b976b2
--- /dev/null
+++ b/ap/app/qrencode/rscode.h
@@ -0,0 +1,41 @@
+/*
+ * 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 <kentaro@fukuchi.org>
+ *
+ * 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/ap/app/qrencode/split.c b/ap/app/qrencode/split.c
new file mode 100644
index 0000000..a2cb0e0
--- /dev/null
+++ b/ap/app/qrencode/split.c
@@ -0,0 +1,326 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Input data splitter.
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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
+ */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#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)
+
+#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;
+	unsigned int word;
+
+	c = string[0];
+
+	if(c == '\0') return QR_MODE_NUL;
+	if(isdigit(c)) {
+		return QR_MODE_NUM;
+	} else if(isalnum(c)) {
+		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);
+static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint);
+
+static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint)
+{
+	const char *p;
+	int ret;
+	int run;
+	int dif;
+	int ln;
+	QRencodeMode mode;
+
+	ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version);
+
+	p = string;
+	while(isdigit(*p)) {
+		p++;
+	}
+	run = p - string;
+	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 */;
+		if(dif > 0) {
+			return Split_eat8(string, input, hint);
+		}
+	}
+	if(mode == QR_MODE_AN) {
+		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, hint);
+		}
+	}
+
+	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, QRencodeMode hint)
+{
+	const char *p, *q;
+	int ret;
+	int run;
+	int dif;
+	int la, ln;
+
+	la = QRspec_lengthIndicator(QR_MODE_AN, input->version);
+	ln = QRspec_lengthIndicator(QR_MODE_NUM, input->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
+				+ (isalnum(*q)?(4 + ln):0)
+				- QRinput_estimateBitsModeAn(q - string) /* - 4 - la */;
+			if(dif < 0) {
+				break;
+			} else {
+				p = q;
+			}
+		} else {
+			p++;
+		}
+	}
+
+	run = p - string;
+
+	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, hint);
+		}
+	}
+
+	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, QRencodeMode hint)
+{
+	const char *p;
+	int ret;
+	int run;
+
+	p = string;
+	while(Split_identifyMode(p, hint) == QR_MODE_KANJI) {
+		p += 2;
+	}
+	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, QRencodeMode hint)
+{
+	const char *p, *q;
+	QRencodeMode mode;
+	int ret;
+	int run;
+	int dif;
+	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') {
+		mode = Split_identifyMode(p, hint);
+		if(mode == QR_MODE_KANJI) {
+			break;
+		}
+		if(mode == QR_MODE_NUM) {
+			q = p;
+			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;
+			} else {
+				p = q;
+			}
+		} else if(mode == QR_MODE_AN) {
+			q = p;
+			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;
+			} else {
+				p = q;
+			}
+		} else {
+			p++;
+		}
+	}
+
+	run = p - string;
+	ret = QRinput_append(input, QR_MODE_8, run, (unsigned char *)string);
+	if(ret < 0) return -1;
+
+	return run;
+}
+
+static int Split_splitString(const char *string, QRinput *input,
+		QRencodeMode hint)
+{
+	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);
+	}
+	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)
+{
+	char *newstr, *p;
+	QRencodeMode mode;
+
+	newstr = strdup(str);
+	if(newstr == NULL) return NULL;
+
+	p = newstr;
+	while(*p != '\0') {
+		mode = Split_identifyMode(p, hint);
+		if(mode == QR_MODE_KANJI) {
+			p += 2;
+		} else {
+			if (*p >= 'a' && *p <= 'z') {
+				*p = (char)((int)*p - 32);
+			}
+			p++;
+		}
+	}
+
+	return newstr;
+}
+
+int Split_splitStringToQRinput(const char *string, QRinput *input,
+		QRencodeMode hint, int casesensitive)
+{
+	char *newstr;
+	int ret;
+
+	if(string == NULL || *string == '\0') {
+		errno = EINVAL;
+		return -1;
+	}
+	if(!casesensitive) {
+		newstr = dupAndToUpper(string, hint);
+		if(newstr == NULL) return -1;
+		ret = Split_splitString(newstr, input, hint);
+		free(newstr);
+	} else {
+		ret = Split_splitString(string, input, hint);
+	}
+
+	return ret;
+}
diff --git a/ap/app/qrencode/split.h b/ap/app/qrencode/split.h
new file mode 100644
index 0000000..b2cdbe5
--- /dev/null
+++ b/ap/app/qrencode/split.h
@@ -0,0 +1,47 @@
+/*
+ * qrencode - QR Code encoder
+ *
+ * Input data splitter.
+ * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org>
+ *
+ * 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"
+
+/**
+ * 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. 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);
+
+#endif /* __SPLIT_H__ */
