/*
+ * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
* Copyright (C) 2005 QSDN,Inc. All rights reserved.
- * Copyright (C) 2005 Atsushi Konno All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
#define EXIT_MAGICK_ERROR() \
do { \
- char *description; ExceptionType severity; \
+ char *description; \
+ ExceptionType severity; \
description=MagickGetException(magick_wand,&severity); \
ap_log_rerror(APLOG_MARK,APLOG_DEBUG, 0, r,"%s %s %d %s\n",__FILE__,(__func__),__LINE__,description); \
description=(char *) MagickRelinquishMemory(description); \
DestroyMagickWand(magick_wand); \
- }while(1)
+ }while(0)
/*----------------------------------------------------------------------------*/
/* ¥â¡¼¥É»Ø¼¨»Ò¥Æ¡¼¥Ö¥ë */
};
-static char* s_get_mode_spec (qr_code_t* qrcode);
-static char* s_get_char_bit_count (qr_code_t* qrcode, int len);
-static char* s_data_to_bin_num (qr_code_t* qrcode, int data_code_count);
-static char* s_data_to_bin_alpha (qr_code_t* qrcode, int data_code_count);
-static int s_char_to_num_alpha (qr_code_t* qrcode, char src);
-static char* s_data_to_bin_8bit (qr_code_t* qrcode, int data_code_count);
-static char* s_data_to_bin_kanji (qr_code_t* qrcode, int data_code_count);
-static char* s_tidy_8bit_code (qr_code_t* qrcode, const char* indata, int data_code_count);
-static char* s_str_to_bin (qr_code_t* qrcode, char* indata, int data_code_count);
-static void s_init_modules (qr_code_t* qrcode, qr_mask_pattern_t pat, char* module[]);
-static void s_setup_probe_position(qr_code_t* qrcode, char* dst[], int pos_x, int pos_y);
-static void s_setup_timing_pattern(qr_code_t* qrcode, char* dst[]);
-static void s_setup_position_adjust(qr_code_t* qrcode, char* dst[]);
-static void s_setup_type_info (qr_code_t* qrcode, char* dst[], qr_mask_pattern_t pat);
-static void s_setup_version_info (qr_code_t* qrcode, char* dst[]);
-static void s_map_data (qr_code_t* qrcode, char* dst[], unsigned char* indata,
+static char *s_get_mode_spec (qr_code_t *qrcode);
+static char *s_get_char_bit_count (qr_code_t *qrcode, int len);
+static char *s_data_to_bin_num (qr_code_t *qrcode, int data_code_count);
+static char *s_data_to_bin_alpha (qr_code_t *qrcode, int data_code_count);
+static int s_char_to_num_alpha (qr_code_t *qrcode, char src);
+static char *s_data_to_bin_8bit (qr_code_t *qrcode, int data_code_count);
+static char *s_data_to_bin_kanji (qr_code_t *qrcode, int data_code_count);
+static char *s_tidy_8bit_code (qr_code_t *qrcode, const char *indata, int data_code_count);
+static char *s_str_to_bin (qr_code_t *qrcode, char *indata, int data_code_count);
+static void s_init_modules (qr_code_t *qrcode, qr_mask_pattern_t pat, char *module[]);
+static void s_setup_probe_position (qr_code_t *qrcode, char *dst[], int pos_x, int pos_y);
+static void s_setup_timing_pattern (qr_code_t *qrcode, char *dst[]);
+static void s_setup_position_adjust(qr_code_t *qrcode, char *dst[]);
+static void s_setup_type_info (qr_code_t *qrcode, char *dst[], qr_mask_pattern_t pat);
+static void s_setup_version_info (qr_code_t *qrcode, char *dst[]);
+static void s_map_data (qr_code_t *qrcode, char *dst[], unsigned char *indata,
int data_count, qr_mask_pattern_t pat);
static int s_get_mask (qr_mask_pattern_t pat, int yy, int xx);
static int s_get_bit_count (int data);
-static int s_calc_lost_point (qr_code_t* qrcode, char* dst[]);
+static int s_calc_lost_point (qr_code_t *qrcode, char *dst[]);
static int s_count_same_module (qr_ver_t ver, char* dst[]);
static int s_count_same_block (qr_ver_t ver, char* dst[]);
static int s_count_11311_pattern (qr_ver_t ver, char* dst[]);
static int s_count_dark_ratio (qr_ver_t ver, char* dst[]);
-static void chxj_qr_code (qr_code_t* qrcode, char* module[]);
+static void chxj_qr_code (qr_code_t *qrcode, char *module[]);
int
-chxj_qr_code_handler(request_rec* r)
+chxj_qr_code_handler(request_rec *r)
{
int sts;
size_t len;
qr_code_t qrcode;
Doc doc;
- char* img;
- Node* root;
- mod_chxj_config* conf;
+ char *img;
+ Node *root;
+ mod_chxj_config *conf;
-#ifdef QR_CODE_DEBUG
DBG(r,"start chxj_qr_code_handler()");
-#endif
+
if (strcasecmp(r->handler, "chxj-qrcode")) {
DBG(r, "end chxj_qr_code_handler()");
return DECLINED;
/*--------------------------------------------------------------------------*/
/* ¤â¤·¡¢¥¤¥á¡¼¥¸ÊÑ´¹¥Ï¥ó¥É¥éÃæ¤Ç¤¢¤ì¤Ð¡¢¤³¤³¤Ç¤Ï½èÍý¤·¤Ê¤¤ */
/*--------------------------------------------------------------------------*/
- conf = ap_get_module_config(r->per_dir_config, &chxj_module);
+ conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
if (!conf || conf->image == CHXJ_IMG_ON)
return DECLINED;
if (sts != OK)
return sts;
- ap_set_content_type(r, "image/jpg");
+ chxj_set_content_type(r, "image/jpg");
- ap_rwrite((void*)img, len, r);
+ ap_rwrite((void *)img, len, r);
return OK;
}
-char*
-chxj_qr_code_blob_handler(request_rec* r, const char* indata, size_t* len)
+char *
+chxj_qr_code_blob_handler(request_rec *r, const char *indata, size_t *len)
{
int sts;
qr_code_t qrcode;
Doc doc;
- char* img;
- Node* root;
+ char *img;
+ Node *root;
DBG(r, "start chxj_qr_code_blob_handler()");
return NULL;
}
- ap_set_content_type(r, "image/jpg");
+ chxj_set_content_type(r, "image/jpg");
DBG(r, "end chxj_qr_code_blob_handler()");
int
chxj_qrcode_create_image_data(
- qr_code_t* qrcode,
- char** img,
- size_t* img_len)
+ qr_code_t *qrcode,
+ char **img,
+ apr_size_t *img_len)
{
int xx, yy;
int module_count;
MagickBooleanType status;
- request_rec* r = qrcode->r;
- MagickWand* magick_wand;
- MagickWand* black_wand;
- unsigned char* tmp;
- char** module;
+ request_rec *r = qrcode->r;
+ MagickWand *magick_wand;
+ MagickWand *black_wand;
+ unsigned char *tmp;
+ char **module;
#ifdef QR_CODE_DEBUG
DBG(r,"start s_create_image_file()");
#endif
module_count = v_module_count_table[qrcode->version];
- module = (char**)apr_palloc(r->pool, sizeof(char*)*(module_count+1));
+ module = (char **)apr_palloc(r->pool, sizeof(char*)*(module_count+1));
for (yy=0; yy<module_count; yy++) {
module[yy] = (char*)apr_palloc(r->pool, module_count+1);
memset(module[yy], -1, module_count+1);
chxj_qr_code(qrcode, module);
-
magick_wand = NewMagickWand();
black_wand = NewMagickWand();
static void
-chxj_qr_code(qr_code_t* qrcode, char* module[])
+chxj_qr_code(qr_code_t *qrcode, char *module[])
{
- request_rec* r = qrcode->doc->r;
- unsigned char* eccstr;
+ request_rec *r = qrcode->doc->r;
+ unsigned char *eccstr;
int ii;
int data_code_count;
- char* real_data = NULL;
- char* decstr;
- char* binstr;
+ char *real_data = NULL;
+ char *decstr;
+ char *binstr;
int data_total_count;
int min_lost_point;
int min_mask_pattern;
binstr = apr_pstrcat(r->pool, binstr,
s_get_char_bit_count(qrcode, strlen(qrcode->indata)), NULL);
#ifdef QR_CODE_DEBUG
- DBG1(r, "s_get_char_bit_count()[%s]", binstr);
+ DBG(r, "s_get_char_bit_count()[%s]", binstr);
#endif
/*------------------------------------------------------------------------*/
/*------------------------------------------------------------------------*/
data_code_count = v_data_code_count[qrcode->version][qrcode->level];
#ifdef QR_CODE_DEBUG
- DBG1(r,"data_code_count=[%d]", data_code_count);
+ DBG(r,"data_code_count=[%d]", data_code_count);
#endif
/*------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
binstr = apr_pstrcat(r->pool, binstr, real_data, NULL);
#ifdef QR_CODE_DEBUG
- DBG1(r,"Before TERM BIT[%s]", binstr);
+ DBG(r,"Before TERM BIT[%s]", binstr);
#endif
- if (data_code_count * 8 > strlen(binstr)) {
+ if ((size_t)(data_code_count * 8) > strlen(binstr)) {
int binstr_len = strlen(binstr);
for (ii=0; ii< (data_code_count * 8) - binstr_len && ii < 4; ii++) {
binstr = apr_pstrcat(r->pool, binstr, "0", NULL);
}
}
#ifdef QR_CODE_DEBUG
- DBG3(r, "After TERM BIT[%s] len[%d]bit [%f]byte", binstr, strlen(binstr), (float)(((float)strlen(binstr))/8.0));
+ DBG(r, "After TERM BIT[%s] len[%d]bit [%f]byte", binstr, strlen(binstr), (float)(((float)strlen(binstr))/8.0));
DBG(r,"add term data");
#endif
/*--------------------------------------------------------------------------*/
binstr = s_tidy_8bit_code(qrcode, binstr, data_code_count);
#ifdef QR_CODE_DEBUG
- DBG1(r,"After Tidy 8 BIT[%s]", binstr);
+ DBG(r,"After Tidy 8 BIT[%s]", binstr);
DBG(r,"s_tidy_8bit_code()");
#endif
for (ii=0; ii<data_code_count; ii++) {
rows = apr_pstrcat(r->pool, rows, apr_psprintf(r->pool, "[%02x]\n", (unsigned char)decstr[ii]), NULL);
}
- DBG1(r,"decstr[%s]", rows);
+ DBG(r,"decstr[%s]", rows);
}while(0);
#endif
eccstr = apr_palloc(r->pool, module_count* module_count);
data_total_count = chxj_calc_ecc(qrcode, (unsigned char*)decstr, eccstr);
#ifdef QR_CODE_DEBUG
- DBG1(r,"chxj_calc_ecc() total_count[%d]", data_total_count);
+ DBG(r,"chxj_calc_ecc() total_count[%d]", data_total_count);
#endif
/*--------------------------------------------------------------------------*/
/* ºÇŬ¥Þ¥¹¥¯¤ÇºÆÅÙºî¤ê¤Ê¤ª¤· */
/*--------------------------------------------------------------------------*/
#ifdef QR_CODE_DEBUG
- DBG1(r, "selected mask[%d]", min_mask_pattern);
+ DBG(r, "selected mask[%d]", min_mask_pattern);
#endif
s_init_modules(qrcode, min_mask_pattern, module);
do {
int xx, yy;
int module_count = v_module_count_table[qrcode->version];
- DBG1(r,"loop to [%d]", module_count);
+ DBG(r,"loop to [%d]", module_count);
for (yy=0; yy<module_count; yy++) {
char *rows ;
for (xx=0; xx<module_count; xx++)
rows = apr_pstrcat(r->pool, rows, "[", apr_psprintf(r->pool, "%c", module[yy][xx]), "]", NULL);
- DBG2(r,"%d:%s", yy,rows);
+ DBG(r,"%d:%s", yy,rows);
}
} while(0);
/* DEBUG END */
}
void
-chxj_qrcode_node_to_qrcode(qr_code_t* qrcode, Node* node)
+chxj_qrcode_node_to_qrcode(qr_code_t *qrcode, Node *node)
{
- request_rec* r = qrcode->r;
- Doc* doc = qrcode->doc;
- Node* child;
+ request_rec *r;
+ Doc *doc;
+ Node *child;
+
+ r = qrcode->r;
+ doc = qrcode->doc;
for (child = qs_get_child_node(doc,node);
child ;
- child = qs_get_next_node(doc,child))
- {
- char* name = qs_get_node_name(doc,child);
- if (strcasecmp("qrcode",name) == 0)
- {
+ child = qs_get_next_node(doc,child)) {
+ char *name = qs_get_node_name(doc,child);
+
+ if (strcasecmp("qrcode",name) == 0) {
+
qrcode->found = QR_FOUND;
qrcode->mode_change = QR_NOT_CHANGE;
qrcode->version = QR_VER_5;
chxj_qrcode_node_to_qrcode(qrcode, child);
}
else
- if (strcasecmp("version", name) == 0)
- {
- int ver;
- Node* cchild = qs_get_child_node(doc, child);
- char* value;
- if (cchild == NULL)
- {
+ if (strcasecmp("version", name) == 0) {
+ int ver;
+ Node *cchild;
+ char *value;
+
+ cchild = qs_get_child_node(doc, child);
+
+ if (cchild == NULL) {
qrcode->version = QR_VER_1;
continue;
}
name = qs_get_node_name(doc, cchild);
value = qs_get_node_value(doc, cchild);
- if (strcasecmp("TEXT", name) != 0)
- {
+ if (strcasecmp("TEXT", name) != 0) {
qrcode->version = QR_VER_1;
continue;
}
- if (value == NULL || strlen(value) == 0)
- {
+ if (value == NULL || strlen(value) == 0) {
qrcode->version = QR_VER_1;
continue;
}
- if (chxj_chk_numeric(value))
- {
+ if (chxj_chk_numeric(value)) {
qrcode->version = QR_VER_1;
continue;
}
ver = chxj_atoi(value);
- if (ver <= 0 || ver > 40)
- {
+ if (ver <= 0 || ver > 40) {
qrcode->version = QR_VER_1;
continue;
}
qrcode->version = ver - 1;
}
else
- if (strcasecmp("level", name) == 0)
- {
- Node* cchild = qs_get_child_node(doc, child);
- char* value;
- if (cchild == NULL)
- {
+ if (strcasecmp("level", name) == 0) {
+ Node *cchild = qs_get_child_node(doc, child);
+ char *value;
+ if (cchild == NULL) {
qrcode->level = QR_LEVEL_L;
continue;
}
- name = qs_get_node_name(doc, cchild);
+ name = qs_get_node_name(doc, cchild);
value = qs_get_node_value(doc, cchild);
- if (strcasecmp("TEXT", name) != 0)
- {
+ if (strcasecmp("TEXT", name) != 0) {
qrcode->level = QR_LEVEL_L;
continue;
}
- if (value == NULL || strlen(value) == 0)
- {
+ if (value == NULL || strlen(value) == 0) {
qrcode->level = QR_LEVEL_L;
continue;
}
- if (strcasecmp("L", value) == 0)
- {
+ if (strcasecmp("L", value) == 0) {
qrcode->level = QR_LEVEL_L;
}
else
- if (strcasecmp("M", value) == 0)
- {
+ if (strcasecmp("M", value) == 0) {
qrcode->level = QR_LEVEL_M;
}
else
- if (strcasecmp("Q", value) == 0)
- {
+ if (strcasecmp("Q", value) == 0) {
qrcode->level = QR_LEVEL_Q;
}
else
- if (strcasecmp("H", value) == 0)
- {
+ if (strcasecmp("H", value) == 0) {
qrcode->level = QR_LEVEL_H;
}
else
else
if (strcasecmp("mode", name) == 0)
{
- Node* cchild = qs_get_child_node(doc, child);
- char* value;
+ Node *cchild = qs_get_child_node(doc, child);
+ char *value;
if (cchild == NULL)
{
qrcode->mode = QR_NUM_MODE;
if (strcasecmp("data", name) == 0)
{
/* TODO: ²þ¹Ô¤â²Äǽ¤Ê¤è¤¦¤Ë½¤Àµ¤¹¤ë */
- Node* cchild = qs_get_child_node(doc, child);
- char* value;
+ Node *cchild = qs_get_child_node(doc, child);
+ char *value;
qrcode->indata = apr_palloc(r->pool, 1);
qrcode->indata[0] = 0;
if (strcasecmp("size", name) == 0)
{
int size;
- char* value;
- Node* cchild = qs_get_child_node(doc, child);
+ char *value;
+ Node *cchild = qs_get_child_node(doc, child);
if (cchild == NULL)
{
}
}
#ifdef QR_CODE_DEBUG
- DBG1(r,"qrcode->version[%d]", qrcode->version);
- DBG1(r,"qrcode->level[%d]", qrcode->level);
- DBG1(r,"qrcode->mode[%d]", qrcode->mode);
- DBG1(r,"qrcode->indata[%s]", qrcode->indata);
+ DBG(r,"qrcode->version[%d]", qrcode->version);
+ DBG(r,"qrcode->level[%d]", qrcode->level);
+ DBG(r,"qrcode->mode[%d]", qrcode->mode);
+ DBG(r,"qrcode->indata[%s]", qrcode->indata);
#endif
}
/**
* ¥â¡¼¥É»Ø¼¨»Ò¤ò¼èÆÀ¤·¤Þ¤¹.
*/
-static char*
+static char *
s_get_mode_spec(qr_code_t *qrcode)
{
- char* result = (char*)apr_palloc(qrcode->r->pool, 4+1);
+ char *result = (char*)apr_palloc(qrcode->r->pool, 4+1);
memset(result, 0, 5);
memcpy(result, v_mode_table[qrcode->mode], 4);
#ifdef QR_CODE_DEBUG
- DBG1(r,"Mode Spec[%s]", result);
+ DBG(r,"Mode Spec[%s]", result);
#endif
return result;
/**
* ʸ»ú¿ô»Ø¼¨»Ò¤ò¼èÆÀ¤·¤Þ¤¹.
*/
-static char*
-s_get_char_bit_count(qr_code_t* qrcode, int len)
+static char *
+s_get_char_bit_count(qr_code_t *qrcode, int len)
{
int bit_count = v_char_count_table[qrcode->version][qrcode->mode];
int ii,jj;
- char* tmp;
- char* result;
+ char *tmp;
+ char *result;
int data_capacity = v_capacity_table[qrcode->version*4+qrcode->level].size[qrcode->mode];
- DBG1(qrcode->r, "len [%d]", len);
+ DBG(qrcode->r, "len [%d]", len);
if (qrcode->mode == QR_KANJI_MODE && data_capacity * 2 < len) {
len = data_capacity * 2;
}
len /= 2;
}
- DBG1(qrcode->r, "len [%d]", len);
+ DBG(qrcode->r, "len [%d]", len);
- tmp = (char*)apr_palloc(qrcode->r->pool, bit_count + 1);
+ tmp = (char *)apr_palloc(qrcode->r->pool, bit_count + 1);
for (ii=0; ii<bit_count; ii++) {
tmp[ii] = (len & 0x01) ? '1' : '0';
len = len >> 1;
tmp[bit_count] = '\0';
- result = (char*)apr_palloc(qrcode->r->pool, bit_count+1);
+ result = (char *)apr_palloc(qrcode->r->pool, bit_count+1);
for (jj=0,ii=bit_count-1; ii>=0 && jj < bit_count; ii--, jj++) {
result[ii] = tmp[jj];
}
result[bit_count] = '\0';
#ifdef QR_CODE_DEBUG
- DBG1(qrcode->r, "Character Count bit [%s]", result);
+ DBG(qrcode->r, "Character Count bit [%s]", result);
#endif
return result;
* ¿ô»ú¥â¡¼¥É
* ÆþÎϥǡ¼¥¿¤«¤é¡¢£²¿Êʸ»úÎó¤ò¼èÆÀ¤·¤Þ¤¹.
*/
-static char*
-s_data_to_bin_num(qr_code_t* qrcode, int data_code_count)
+static char *
+s_data_to_bin_num(qr_code_t *qrcode, int UNUSED(data_code_count))
{
int len = strlen(qrcode->indata);
int setn;
int ii;
int jj;
int kk;
- char* result;
+ char *result;
char tmp[4];
char tmp_bit[11];
int data_capacity = v_capacity_table[qrcode->version*4+qrcode->level].size[qrcode->mode];
* ±Ñ¿ô»ú¥â¡¼¥É
* ÆþÎϥǡ¼¥¿¤«¤é¡¢£²¿Êʸ»úÎó¤ò¼èÆÀ¤·¤Þ¤¹.
*/
-static char*
-s_data_to_bin_alpha(qr_code_t* qrcode, int data_code_count)
+static char *
+s_data_to_bin_alpha(qr_code_t *qrcode, int UNUSED(data_code_count))
{
int len = strlen(qrcode->indata);
int setn;
int ii;
int jj;
int kk;
- char* result;
+ char *result;
char tmp[2+1];
char tmp_bit[11+1];
int data_capacity = v_capacity_table[qrcode->version*4+qrcode->level].size[qrcode->mode];
setn = len / 2;
modn = len % 2;
- result = (char*)apr_palloc(qrcode->r->pool, setn*11 + ((modn == 1) ? 6 : 0) + 1);
+ result = (char *)apr_palloc(qrcode->r->pool, setn*11 + ((modn == 1) ? 6 : 0) + 1);
kk = 0;
for (ii=0; ii<len; ii++) {
* ±Ñ¿ô»ú¤«¤é¡¢¿ôÃͤËÊÑ´¹¤·¤Þ¤¹.
*/
static int
-s_char_to_num_alpha(qr_code_t* qrcode, char src)
+s_char_to_num_alpha(qr_code_t *qrcode, char src)
{
switch(src) {
case '0': return 0;
* 8bit¥Ð¥¤¥È¥â¡¼¥É
* ÆþÎϥǡ¼¥¿¤«¤é£²¿Êʸ»úÎó¤ò¼èÆÀ¤·¤Þ¤¹.
*/
-static char*
-s_data_to_bin_8bit(qr_code_t* qrcode, int data_code_count)
+static char *
+s_data_to_bin_8bit(qr_code_t *qrcode, int UNUSED(data_code_count))
{
int len = strlen(qrcode->indata);
int ii;
int jj;
int kk;
- char* result;
+ char *result;
char tmp_bit[8+1];
int data_capacity = v_capacity_table[qrcode->version*4+qrcode->level].size[qrcode->mode];
result[kk] = 0;
#ifdef QR_CODE_DEBUG
- DBG2(qrcode->r, "input data --> 2bin result[%s] len:[%d]", result, strlen(result));
+ DBG(qrcode->r, "input data --> 2bin result[%s] len:[%d]", result, strlen(result));
#endif
return result;
* Kanji mode.
* A binary character string is acquired from input data.
*/
-static char*
-s_data_to_bin_kanji(qr_code_t* qrcode, int data_code_count)
+static char *
+s_data_to_bin_kanji(qr_code_t *qrcode, int UNUSED(data_code_count))
{
int len = strlen(qrcode->indata);
int ii;
int jj;
int kk;
- char* result;
+ char *result;
char tmp_bit[13+1];
int data_capacity = v_capacity_table[qrcode->version*4+qrcode->level].size[qrcode->mode];
result[kk] = 0;
#ifdef QR_CODE_DEBUG
- DBG2(qrcode->r, "input data --> 2bin result[%s] len:[%d]", result, strlen(result));
+ DBG(qrcode->r, "input data --> 2bin result[%s] len:[%d]", result, strlen(result));
#endif
return result;
/**
* 8bitŤˤ¢¤ï¤»¤Þ¤¹
*/
-static char*
-s_tidy_8bit_code(qr_code_t* qrcode, const char* indata, int data_code_count)
+static char *
+s_tidy_8bit_code(qr_code_t *qrcode, const char *indata, int data_code_count)
{
int len = strlen(indata);
int ii;
int n;
int rest;
- char* tmp = NULL;
- char* result;
+ char *tmp = NULL;
+ char *result;
#ifdef QR_CODE_DEBUG
- DBG2(qrcode->r, "len[%d] data_code_count * 8 [%d]", len, data_code_count * 8);
+ DBG(qrcode->r, "len[%d] data_code_count * 8 [%d]", len, data_code_count * 8);
#endif
assert (len <= data_code_count * 8);
}
#ifdef QR_CODE_DEBUG
- DBG2(qrcode->r, "tidy len[%d] data_code_count[%d]", strlen(result)/8, data_code_count);
+ DBG(qrcode->r, "tidy len[%d] data_code_count[%d]", strlen(result)/8, data_code_count);
#endif
return result;
/**
* £²¿Êʸ»úÎó¤ò¥Ð¥¤¥Ê¥ê¤ËÊÑ´¹¤·¤Þ¤¹.
*/
-static char*
-s_str_to_bin(qr_code_t* qrcode, char* indata, int data_code_count)
+static char *
+s_str_to_bin(qr_code_t *qrcode, char *indata, int data_code_count)
{
- char* result ;
+ char *result;
int pos;
int len ;
int ii;
len = strlen(indata);
- result = (char*)apr_palloc(qrcode->r->pool, data_code_count);
+ result = (char *)apr_palloc(qrcode->r->pool, data_code_count);
memset(result, 0, data_code_count);
pos = 0;
* ¤½¤Î¤Û¤«¤Î¾ì½ê¤Ë¤Ï¡¢-1¤òÀßÄꤷ¤Þ¤¹.
*/
static void
-s_init_modules(qr_code_t* qrcode, qr_mask_pattern_t pat, char* dst[])
+s_init_modules(qr_code_t *qrcode, qr_mask_pattern_t pat, char *dst[])
{
int module_count = v_module_count_table[qrcode->version];
int yy;
* °ÌÃÖ¸¡½Ð¥Ñ¥¿¡¼¥ó¤È¤Ä¤¤¤Ç¤ËʬΥ¥Ñ¥¿¡¼¥ó¤Î½ÐÎÏ
*/
static void
-s_setup_probe_position(qr_code_t* qrcode, char* dst[], int pos_x, int pos_y)
+s_setup_probe_position(qr_code_t *qrcode, char *dst[], int pos_x, int pos_y)
{
int module_count = v_module_count_table[qrcode->version];
int xx;
* ¥¿¥¤¥ß¥ó¥°¥Ñ¥¿¡¼¥ó
*/
static void
-s_setup_timing_pattern(qr_code_t* qrcode, char* dst[])
+s_setup_timing_pattern(qr_code_t *qrcode, char *dst[])
{
int module_count = v_module_count_table[qrcode->version];
int xx, yy;
#ifdef QR_CODE_DEBUG
DBG(qrcode->r, "start s_setup_timing_pattern()");
- DBG1(qrcode->r, "module_count[%d]", module_count);
+ DBG(qrcode->r, "module_count[%d]", module_count);
#endif
yy=6;
* °ÌÃÖ¹ç¤ï¤»¥Ñ¥¿¡¼¥ó
*/
static void
-s_setup_position_adjust(qr_code_t* qrcode, char* dst[])
+s_setup_position_adjust(qr_code_t *qrcode, char *dst[])
{
int module_count = v_module_count_table[qrcode->version];
- int* pos_list = v_position_adjust_table[qrcode->version].position;
+ int *pos_list = v_position_adjust_table[qrcode->version].position;
int xx, yy;
int mxx, myy;
int dxx, dyy;
}
static void
-s_setup_type_info(qr_code_t* qrcode, char* dst[], qr_mask_pattern_t pat)
+s_setup_type_info(qr_code_t *qrcode, char *dst[], qr_mask_pattern_t pat)
{
int module_count = v_module_count_table[qrcode->version];
int typedata;
#ifdef QR_CODE_DEBUG
DBG(qrcode->r, "start s_setup_type_info()");
- DBG1(qrcode->r, "module_count[%d]", module_count);
+ DBG(qrcode->r, "module_count[%d]", module_count);
#endif
/* ·Á¼°¾ðÊó¥Ç¡¼¥¿¤ÎÀ¸À® */
static void
-s_setup_version_info(qr_code_t* qrcode, char* dst[])
+s_setup_version_info(qr_code_t *qrcode, char *dst[])
{
- char* bits = v_version_info_table[qrcode->version].bits;
+ char *bits = v_version_info_table[qrcode->version].bits;
int module_count = v_module_count_table[qrcode->version];
- int xx;
- int yy;
+ size_t xx;
+ size_t yy;
if (bits == NULL) {
/* ¥Ð¡¼¥¸¥ç¥ó£·°Ê¹ß¤Î¤ßÂÐ¾Ý */
}
static void
-s_map_data(qr_code_t* qrcode,
- char* dst[],
- unsigned char* indata, int data_count,qr_mask_pattern_t pat)
+s_map_data(qr_code_t *qrcode,
+ char *dst[],
+ unsigned char *indata, int data_count,qr_mask_pattern_t pat)
{
int module_count = v_module_count_table[qrcode->version];
int inc_yy_flag = -1;
#ifdef QR_CODE_DEBUG
DBG(qrcode->r, "start s_map_data()");
- DBG1(qrcode->r, "module_count[%d]", module_count);
- DBG1(qrcode->r, "data_count[%d]", data_count);
+ DBG(qrcode->r, "module_count[%d]", module_count);
+ DBG(qrcode->r, "data_count[%d]", data_count);
#endif
in_pos = 0;
now_bit = 7;
static int
-s_calc_lost_point(qr_code_t* qrcode, char* dst[])
+s_calc_lost_point(qr_code_t *qrcode, char *dst[])
{
int point = 0;
* ¼ºÅÀ=3+i
*/
static int
-s_count_same_module(qr_ver_t ver, char* dst[])
+s_count_same_module(qr_ver_t ver, char *dst[])
{
- int module_count = v_module_count_table[ver];
- int point = 0;
+ int module_count;
+ int point;
int xx, yy;
- int same_count = 0;
- int prev_value = -1;
+ int same_count;
+ int prev_value;
+
+ module_count = v_module_count_table[ver];
+ point = 0;
+ same_count = 0;
+ prev_value = -1;
/* ²£Êý¸þ¤Ç¥Á¥§¥Ã¥¯ */
for (yy=0; yy<module_count; yy++) {
prev_value = -1;
same_count = 0;
for (xx=0; xx<module_count; xx++) {
- if (prev_value == (unsigned char)dst[yy][xx]) {
+ if (prev_value == (unsigned char)dst[yy][xx])
same_count++;
- }
- else {
+ else
same_count = 0;
- }
- if (same_count >= 5) {
+
+ if (same_count >= 5)
point++;
- }
+
prev_value = (unsigned char)dst[yy][xx];
}
}
* Ʊ¿§¤Î¥â¥¸¥å¡¼¥ë¥Ö¥í¥Ã¥¯ ¥Ö¥í¥Ã¥¯¥µ¥¤¥º 2¡ß2
*/
static int
-s_count_same_block(qr_ver_t ver, char* dst[])
+s_count_same_block(qr_ver_t ver, char *dst[])
{
- int module_count = v_module_count_table[ver];
+ int module_count;
int point;
int count;
int xx,yy;
+ module_count = v_module_count_table[ver];
+
point = 0;
for (yy = 0; yy < module_count-1; yy++) {
for (xx = 0; xx < module_count-1; xx++) {
}
static int
-s_count_11311_pattern(qr_ver_t ver, char* dst[])
+s_count_11311_pattern(qr_ver_t ver, char *dst[])
{
- int module_count = v_module_count_table[ver];
+ int module_count;
int point;
int xx,yy;
+ module_count = v_module_count_table[ver];
+
point = 0;
/* ²£Êý¸þ¤Î¥Á¥§¥Ã¥¯ */
for (yy = 0; yy < module_count; yy++) {
return point;
}
+
+
/*
* Á´ÂΤËÀê¤á¤ë°Å¥â¥¸¥å¡¼¥ë¤Î³ä¹ç 50¡Þ(5+k)%¡Á50¡Þ(5+(k+1))%
*/
static int
-s_count_dark_ratio(qr_ver_t ver, char* dst[])
+s_count_dark_ratio(qr_ver_t ver, char *dst[])
{
- int module_count = v_module_count_table[ver];
- int dark_count = 0;
+ int module_count;
+ int dark_count;
int xx, yy;
int ratio;
- int all_count = module_count * module_count;
+ int all_count;
+
+ module_count = v_module_count_table[ver];
+ dark_count = 0;
+ all_count = module_count * module_count;
/* ñ¤Ë"°Å"¤ò¥«¥¦¥ó¥È¤¹¤ë */
for (yy=0; yy<module_count; yy++) {