/*
- * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
* Copyright (C) 2005 QSDN,Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
};
-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;
DBG(r,"start chxj_qr_code_handler()");
/*--------------------------------------------------------------------------*/
/* ¤â¤·¡¢¥¤¥á¡¼¥¸ÊÑ´¹¥Ï¥ó¥É¥éÃæ¤Ç¤¢¤ì¤Ð¡¢¤³¤³¤Ç¤Ï½èÍý¤·¤Ê¤¤ */
/*--------------------------------------------------------------------------*/
- 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,
- apr_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;
}
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;
- Doc* 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;
-
- name = qs_get_node_name(doc,child);
+ char *name = qs_get_node_name(doc,child);
if (strcasecmp("qrcode",name) == 0) {
else
if (strcasecmp("version", name) == 0) {
int ver;
- Node* cchild;
- char* value;
+ Node *cchild;
+ char *value;
cchild = qs_get_child_node(doc, child);
}
else
if (strcasecmp("level", 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->level = QR_LEVEL_L;
continue;
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)
{
/**
* ¥â¡¼¥É»Ø¼¨»Ò¤ò¼èÆÀ¤·¤Þ¤¹.
*/
-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);
/**
* ʸ»ú¿ô»Ø¼¨»Ò¤ò¼èÆÀ¤·¤Þ¤¹.
*/
-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];
DBG(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];
}
* ¿ô»ú¥â¡¼¥É
* ÆþÎϥǡ¼¥¿¤«¤é¡¢£²¿Êʸ»úÎó¤ò¼èÆÀ¤·¤Þ¤¹.
*/
-static char*
-s_data_to_bin_num(qr_code_t* qrcode, int UNUSED(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 UNUSED(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 UNUSED(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];
* Kanji mode.
* A binary character string is acquired from input data.
*/
-static char*
-s_data_to_bin_kanji(qr_code_t* qrcode, int UNUSED(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];
/**
* 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
DBG(qrcode->r, "len[%d] data_code_count * 8 [%d]", len, data_code_count * 8);
/**
* £²¿Êʸ»úÎó¤ò¥Ð¥¤¥Ê¥ê¤ËÊÑ´¹¤·¤Þ¤¹.
*/
-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;
* °ÌÃÖ¹ç¤ï¤»¥Ñ¥¿¡¼¥ó
*/
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;
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];
size_t xx;
size_t yy;
}
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;
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;
int point;
* Ʊ¿§¤Î¥â¥¸¥å¡¼¥ë¥Ö¥í¥Ã¥¯ ¥Ö¥í¥Ã¥¯¥µ¥¤¥º 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;
int point;
}
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;
int 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;
int dark_count;