diff --git a/ap/app/qrencode/Makefile b/ap/app/qrencode/Makefile
new file mode 100644
index 0000000..a78c42a
--- /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
+LDLIBS += -L$(zte_lib_path)/zlib/build -lz -lm
+CFLAGS += -I./
+CFLAGS += -I$(zte_lib_path)/libpng
+CFLAGS += -I$(zte_lib_path)/zlib/zlib-1.2.11
+
+
+
+##############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__ */
