当前位置: 首页>>代码示例>>C++>>正文


C++ QRinput_free函数代码示例

本文整理汇总了C++中QRinput_free函数的典型用法代码示例。如果您正苦于以下问题:C++ QRinput_free函数的具体用法?C++ QRinput_free怎么用?C++ QRinput_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QRinput_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QRinput_newMQR

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;
}
开发者ID:liucf88,项目名称:libqrencode,代码行数:32,代码来源:qrencode.c

示例2: test_split2

void test_split2(void)
{
	QRinput *input;
	QRinput_List *list;
	int err = 0;

	testStart("Split test: single typed strings (num)");
	input = QRinput_new2(0, QR_ECLEVEL_L);
	Split_splitStringToQRinput("0123", input, QR_MODE_8, 0);
	list = input->head;
	if(inputTest(list, "n", 4)) {
		err++;
	}
	testEnd(err);
	QRinput_free(input);

	err = 0;
	testStart("Split test: single typed strings (num2)");
	input = QRinput_new2(0, QR_ECLEVEL_L);
	Split_splitStringToQRinput("12345678901234567890", input, QR_MODE_KANJI, 0);
	list = input->head;
	if(inputTest(list, "n", 20)) {
		err++;
	}
	testEnd(err);
	QRinput_free(input);
}
开发者ID:JohanAlvarado,项目名称:heroku-buildpack-ruby-with-qrencode,代码行数:27,代码来源:test_split.c

示例3: QRinput_new2

QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
{
	QRinput *input;
	QRcode_List *codes;
	int ret;

	if(version <= 0) {
		errno = EINVAL;
		return NULL;
	}
	if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) {
		errno = EINVAL;
		return NULL;
	}

	input = QRinput_new2(version, level);
	if(input == NULL) return NULL;

	ret = Split_splitStringToQRinput(string, input, hint, casesensitive);
	if(ret < 0) {
		QRinput_free(input);
		return NULL;
	}
	codes = QRcode_encodeInputToStructured(input);
	QRinput_free(input);

	return codes;
}
开发者ID:keven123,项目名称:KTV,代码行数:28,代码来源:qrencode.c

示例4: QRinput_new2

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;
}
开发者ID:liucf88,项目名称:libqrencode,代码行数:35,代码来源:qrencode.c

示例5: test_splitentry2

void test_splitentry2(void)
{
	QRinput *i1, *i2;
	QRinput_List *e;
	const char *str = "abcdefghij";
	int size1, size2, i;
	unsigned char *d1, *d2;

	testStart("Testing QRinput_splitEntry. (next != NULL)");
	i1 = QRinput_new();
	QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str);
	QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str);

	i2 = QRinput_dup(i1);
	e = i2->head;

	e = i2->head;
	QRinput_splitEntry(e, 4);

	size1 = size2 = 0;
	e = i1->head;
	while(e != NULL) {
		size1 += e->size;
		e = e->next;
	}
	e = i2->head;
	while(e != NULL) {
		size2 += e->size;
		e = e->next;
	}

	d1 = (unsigned char *)malloc(size1);
	e = i1->head;
	i = 0;
	while(e != NULL) {
		memcpy(&d1[i], e->data, e->size);
		i += e->size;
		e = e->next;
	}
	d2 = (unsigned char *)malloc(size2);
	e = i2->head;
	i = 0;
	while(e != NULL) {
		memcpy(&d2[i], e->data, e->size);
		i += e->size;
		e = e->next;
	}

	assert_equal(size1, size2, "sizes are different. (%d:%d)\n", size1, size2);
	assert_equal(i2->head->size, 4, "split failed (first half)");
	assert_equal(i2->head->next->size, 6, "split failed(second half)");
	assert_zero(memcmp(d1, d2, size1), "strings are different.");
	QRinput_free(i1);
	QRinput_free(i2);
	free(d1);
	free(d2);

	testFinish();
}
开发者ID:OldFrank,项目名称:qrencode,代码行数:59,代码来源:test_qrinput.c

示例6: test_padding2

void test_padding2(void)
{
	QRinput *input;
	BitStream *bstream;
	int i, size, ret;
	char data[] = "0123456789ABCDeF";
	char correct[153];
	unsigned char c;

	testStart("Padding bit check. (1 or 2 padding bytes)");

	/* 16 byte data (4 bit terminator and 1 byte padding) */
	memset(correct, 0, 153);
	memcpy(correct, "010000010000", 12);
	for(size=0; size<16; size++) {
		c = 0x80;
		for(i=0; i<8; i++) {
			correct[size * 8 + i + 12] = (data[size]&c)?'1':'0';
			c = c >> 1;
		}
	}
	memcpy(correct + 140, "000011101100", 12);

	input = QRinput_new2(1, QR_ECLEVEL_L);
	QRinput_append(input, QR_MODE_8, 16, (unsigned char *)data);
	bstream = BitStream_new();
	QRinput_getBitStream(input, bstream);
	size = BitStream_size(bstream);
	assert_equal(size, 152, "16byte: # of bit is incorrect (%d != 152).\n", size);
	ret = ncmpBin(correct, bstream, 152);
	assert_zero(ret, "Padding bits incorrect.\n");
	printBstream(bstream);

	QRinput_free(input);
	BitStream_free(bstream);

	/* 15 byte data (4 bit terminator and 2 byte paddings) */

	memcpy(correct, "010000001111", 12);
	memcpy(correct + 132, "00001110110000010001", 20);

	input = QRinput_new2(1, QR_ECLEVEL_L);
	QRinput_append(input, QR_MODE_8, 15, (unsigned char *)data);
	bstream = BitStream_new();
	QRinput_getBitStream(input, bstream);
	size = BitStream_size(bstream);
	assert_equal(size, 152, "15byte: # of bit is incorrect (%d != 152).\n", size);
	ret = ncmpBin(correct, bstream, 152);
	assert_zero(ret, "Padding bits incorrect.\n");
	printBstream(bstream);

	testFinish();

	QRinput_free(input);
	BitStream_free(bstream);
}
开发者ID:JaredTS486,项目名称:Inventory-Management,代码行数:56,代码来源:test_qrinput.c

示例7: test_split4

void test_split4(void)
{
	QRinput *input;
	QRinput *i1, *i2;
	int s1, s2, size;
#define CHUNKA "ABCDEFGHIJK"
#define CHUNKB "123456"
#define CHUNKC "1234567"

	testStart("Split test: an and num entries");
	input = QRinput_new2(0, QR_ECLEVEL_L);
	Split_splitStringToQRinput(CHUNKA/**/CHUNKB, input, QR_MODE_8, 0);
	i1 = QRinput_new();
	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKA/**/CHUNKB);
	i2 = QRinput_new();
	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
	QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB);

	size = inputSize(input);
	s1 = inputSize(i1);
	s2 = inputSize(i2);
	testEndExp(size == ((s1 < s2)?s1:s2));
	QRinput_free(input);
	QRinput_free(i1);
	QRinput_free(i2);

	testStart("Split test: num and an entries");
	input = QRinput_new2(0, QR_ECLEVEL_L);
	Split_splitStringToQRinput(CHUNKB/**/CHUNKA, input, QR_MODE_8, 0);
	i1 = QRinput_new();
	QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKB/**/CHUNKA);
	i2 = QRinput_new();
	QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB);
	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);

	size = inputSize(input);
	s1 = inputSize(i1);
	s2 = inputSize(i2);
	testEndExp(size == ((s1 < s2)?s1:s2));
	QRinput_free(input);
	QRinput_free(i1);
	QRinput_free(i2);

	testStart("Split test: num and an entries (should be splitted)");
	input = QRinput_new2(0, QR_ECLEVEL_L);
	Split_splitStringToQRinput(CHUNKC/**/CHUNKA, input, QR_MODE_8, 0);
	i1 = QRinput_new();
	QRinput_append(i1, QR_MODE_AN, 18, (unsigned char *)CHUNKC/**/CHUNKA);
	i2 = QRinput_new();
	QRinput_append(i2, QR_MODE_NUM, 7, (unsigned char *)CHUNKC);
	QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);

	size = inputSize(input);
	s1 = inputSize(i1);
	s2 = inputSize(i2);
	testEndExp(size == ((s1 < s2)?s1:s2));
	QRinput_free(input);
	QRinput_free(i1);
	QRinput_free(i2);
}
开发者ID:JohanAlvarado,项目名称:heroku-buildpack-ruby-with-qrencode,代码行数:60,代码来源:test_split.c

示例8: test_encodeLongData

void test_encodeLongData(void)
{
	QRinput *stream;
	unsigned char data[7090];
	int maxlength[4][4] = {{7089,5596,3993,3057},
						   {4296,3391,2420,1852},
						   {2953,2331,1663,1273},
						   {1817*2,1435*2,1024*2, 784*2}};
	int i, l, len, ret;
	QRcode *qrcode;

	testStart("Encoding long data.");

	for(i=QR_MODE_NUM; i<=QR_MODE_KANJI; i++) {
		if(i != QR_MODE_KANJI) {
			memset(data, '0', maxlength[i][0] + 1);
		} else {
			for(l=0; l<=maxlength[i][0]/2+1; l++) {
				data[l*2] = 0x93; data[l*2+1] = 0x5f;
			}
		}
		for(l=QR_ECLEVEL_L; l<=QR_ECLEVEL_H; l++) {
			stream = QRinput_new2(0, l);
			ret = QRinput_append(stream, i, maxlength[i][l], data);
			assert_zero(ret, "Failed to add %d-byte %s to a QRinput\n", maxlength[i][l], modeStr[i]);
			qrcode = QRcode_encodeInput(stream);
			assert_nonnull(qrcode, "(QRcode_encodeInput) failed to encode %d-byte %s in level %d.\n", maxlength[i][l], modeStr[i], l);
			if(qrcode != NULL) {
				QRcode_free(qrcode);
			}
			QRinput_free(stream);

			stream = QRinput_new2(0, l);
			len = maxlength[i][l];
			if(i == QR_MODE_KANJI) {
				len += 2;
			} else {
				len += 1;
			}
			ret = QRinput_append(stream, i, len, data);
			if(ret == 0) {
				qrcode = QRcode_encodeInput(stream);
				assert_null(qrcode, "(QRcode_encodeInput) incorrectly succeeded to encode %d-byte %s in level %d.\n", len, modeStr[i], l);
				if(qrcode != NULL) {
					printf("version: %d\n", qrcode->version);
					QRcode_free(qrcode);
				}
			}
			QRinput_free(stream);
		}
	}

	testFinish();
}
开发者ID:937447974,项目名称:libqrencode,代码行数:54,代码来源:test_qrencode.c

示例9: test_split_kanji

void test_split_kanji(int num)
{
	QRinput *input;
	QRinput_List *list;
	int len, i, ret;

	len = fill8bitString();

	input = QRinput_new2(0, QR_ECLEVEL_L);
	if(input == NULL) {
		perror("test_split_kanji aborted at QRinput_new2():");
		return;
	}
	ret = Split_splitStringToQRinput((char *)data, input, QR_MODE_KANJI, 1);
	if(ret < 0) {
		perror("test_split_kanji aborted at Split_splitStringToQRinput():");
		QRinput_free(input);
		return;
	}
	list = input->head;
	i = 0;
	while(list != NULL) {
		memcpy(check + i, list->data, list->size);
		i += list->size;
		list = list->next;
	}
	if(i != len) {
		printf("#%d: length is not correct. (%d should be %d)\n", num, i, len);
	}

	check[i] = '\0';
	ret = memcmp(data, check, len);
	if(ret != 0) {
		printf("#%d: data mismatched.\n", num);
		list = input->head;
		i = 0;
		while(list != NULL) {
			ret = memcmp(data + i, list->data, list->size);
			printf("wrong chunk:\n");
			printf(" position: %d\n", i);
			printf(" mode    : %d\n", list->mode);
			printf(" size    : %d\n", list->size);
			printf(" data    : %.*s\n", list->size, list->data);
			i += list->size;
			list = list->next;
		}
		exit(1);
	}
	QRinput_free(input);
}
开发者ID:01org,项目名称:irk_host_linux,代码行数:50,代码来源:test_monkey.c

示例10: test_toupper

void test_toupper(void)
{
	QRinput *input;
	QRinput_List *list;
	int err = 0;

	testStart("Split test: check dupAndToUpper (lower->upper)");
	input = QRinput_new2(0, QR_ECLEVEL_L);
	Split_splitStringToQRinput("abcde", input, QR_MODE_8, 0);
	list = input->head;
	if(inputTest(list, "a", 5)) {
		err++;
	}
	if(strncmp((char *)list->data, "ABCDE", list->size)) {
		err++;
	}
	testEnd(err);
	QRinput_free(input);

	err = 0;
	testStart("Split test: check dupAndToUpper (kanji)");
	input = QRinput_new2(0, QR_ECLEVEL_L);
	Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, QR_MODE_KANJI, 0);
	list = input->head;
	if(inputTest(list, "k", 10)) {
		printQRinputInfo(input);
		err++;
	}
	if(strncmp((char *)list->data, "\x83n\x83q\x83t\x83w\x83z", list->size)) {
		err++;
	}
	testEnd(err);
	QRinput_free(input);

	err = 0;
	testStart("Split test: check dupAndToUpper (8bit)");
	input = QRinput_new2(0, QR_ECLEVEL_L);
	Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, QR_MODE_8, 0);
	list = input->head;
	if(inputTest(list, "8", 10)) {
		printQRinputInfo(input);
		err++;
	}
	if(strncmp((char *)list->data, "\x83N\x83Q\x83T\x83W\x83Z", list->size)) {
		err++;
	}
	testEnd(err);
	QRinput_free(input);
}
开发者ID:JohanAlvarado,项目名称:heroku-buildpack-ruby-with-qrencode,代码行数:49,代码来源:test_split.c

示例11: test_encode

void test_encode(void)
{
	QRinput *stream;
	char num[9] = "01234567";
	unsigned char *frame;
	int err = 0;
	int x, y, w;
	int mask;
	QRcode *qrcode;

	testStart("Test encode (1-M)");
	stream = QRinput_new();
	QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
	for(mask=0; mask<8; mask++) {
		QRinput_setVersion(stream, 1);
		QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_M);
		qrcode = QRcode_encodeMask(stream, mask);
		w = qrcode->width;
		frame = qrcode->data;
		for(y=0; y<w; y++) {
			for(x=0; x<w; x++) {
				if(((m1pat[mask][y] >> (20-x)) & 1) != (frame[y*w+x]&1)) {
					printf("Diff in mask=%d (%d,%d)\n", mask, x, y);
					err++;
				}
			}
		}
		QRcode_free(qrcode);
	}
	QRinput_free(stream);
	testEnd(err);
}
开发者ID:zapster,项目名称:libqrencode,代码行数:32,代码来源:test_qrencode.c

示例12: test_encodeECI

void test_encodeECI(void)
{
	QRinput *input;
	BitStream *bstream;
	unsigned char str[] = {0xa1, 0xa2, 0xa3, 0xa4, 0xa5};
	char *correct = "0111 00001001 0100 00000101 10100001 10100010 10100011 10100100 10100101";
	int ret;

	testStart("Encoding characters with ECI header.");
	input = QRinput_new();
	ret = QRinput_appendECIheader(input, 9);
	assert_zero(ret, "Valid ECI header rejected.\n");

	ret = QRinput_append(input, QR_MODE_8, 5, str);
	assert_zero(ret, "Failed to append characters.\n");
	bstream = BitStream_new();
	QRinput_mergeBitStream(input, bstream);
	assert_nonnull(bstream, "Failed to merge.\n");
	if(bstream != NULL) {
		ret = ncmpBin(correct, bstream, 64);
		assert_zero(ret, "Encodation of ECI header was invalid.\n");
		BitStream_free(bstream);
	}
	QRinput_free(input);
	testFinish();
}
开发者ID:JaredTS486,项目名称:Inventory-Management,代码行数:26,代码来源:test_qrinput.c

示例13: encodeAndCheckBStream

int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mode, char *data, char *correct)
{
	QRinput *input;
	BitStream *bstream;
	int ret;

	if(mqr) {
		input = QRinput_newMQR(version, level);
	} else {
		input = QRinput_new2(version, level);
	}
	QRinput_append(input, mode, strlen(data), (unsigned char *)data);
	bstream = BitStream_new();
	QRinput_getBitStream(input, bstream);
	ret = cmpBin(correct, bstream);
	if(ret) {
		printf("result : ");
		printBstream(bstream);
		printf("correct: %s\n", correct);
	}
	QRinput_free(input);
	BitStream_free(bstream);

	return ret;
}
开发者ID:JaredTS486,项目名称:Inventory-Management,代码行数:25,代码来源:test_qrinput.c

示例14: test_padding

void test_padding(void)
{
	QRinput *input;
	BitStream *bstream;
	int i, size;
	char data[] = "0123456789ABCDeFG";
	unsigned char c;

	testStart("Padding bit check. (less than 5 bits)");
	input = QRinput_new2(1, QR_ECLEVEL_L);
	QRinput_append(input, QR_MODE_8, 17, (unsigned char *)data);
	bstream = BitStream_new();
	QRinput_getBitStream(input, bstream);
	size = BitStream_size(bstream);
	assert_equal(size, 152, "# of bit is incorrect (%d != 152).\n", size);
	c = 0;
	for(i=0; i<4; i++) {
		c += bstream->data[size - i - 1];
	}
	assert_zero(c, "Padding bits are not zero.");
	testFinish();

	QRinput_free(input);
	BitStream_free(bstream);
}
开发者ID:JaredTS486,项目名称:Inventory-Management,代码行数:25,代码来源:test_qrinput.c

示例15: test_iterate

void test_iterate()
{
	int i;
	QRinput *stream;
	char num[9] = "01234567";
	unsigned char *data;
	QRRawCode *raw;
	int err = 0;

	testStart("Test getCode (1-L)");
	stream = QRinput_new();
	QRinput_setVersion(stream, 1);
	QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_L);
	QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);

	raw = QRraw_new(stream);
	data = raw->datacode;
	for(i=0; i<raw->dataLength; i++) {
		if(data[i] != QRraw_getCode(raw)) {
			err++;
		}
	}

	QRinput_free(stream);
	QRraw_free(raw);
	testEnd(err);
}
开发者ID:zapster,项目名称:libqrencode,代码行数:27,代码来源:test_qrencode.c


注:本文中的QRinput_free函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。