Skip to content

Commit

Permalink
1: add new constant type.
Browse files Browse the repository at this point in the history
2: return false when qrcode == NULL.
3: use different function when mode = 8bit.
  • Loading branch information
Vanilla Hsu committed May 1, 2008
1 parent babbbfb commit 974e0ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 7 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ only 2 function to generate qr code.

<code>
$qr = qr_encode ('test for qrcode');
qr_save ($qr, '1.png');
if (is_resource ($qr))
qr_save ($qr, '1.png');
</code>

or you can output direct to stdout.

<code>
$qr = qr_encode ('test for qrcode');
header ("Content-type: image/PNG");
qr_save ($qr);
if (is_resource ($qr))
{
header ("Content-type: image/PNG");
qr_save ($qr);
}
</code>

resource = qr_encode (string $text, [ int $version, int $mode, int $casesensitive]);
Expand Down
18 changes: 12 additions & 6 deletions qrencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
+----------------------------------------------------------------------+
*/

/*
* $Header: /home/ncvs/php_extension/qrencode/qrencode.c,v 1.2 2008/01/24 02:44:41 vanilla Exp $
*/

/**
* $file qrencode.c
* @brief source file of php qrencode extension.
Expand Down Expand Up @@ -58,7 +54,7 @@ zend_module_entry qrencode_module_entry = {
NULL,
PHP_MINFO(qrencode),
#if ZEND_MODULE_API_NO >= 20010901
"$Revision: 1.2 $",
"0.3",
#endif
STANDARD_MODULE_PROPERTIES
};
Expand All @@ -71,6 +67,7 @@ PHP_MINIT_FUNCTION(qrencode)
{
le_qr = zend_register_list_destructors_ex(qr_dtor, NULL, "qr", module_number);

REGISTER_LONG_CONSTANT ("QR_MODE_NUL", QR_MODE_NUL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT ("QR_MODE_NUM", QR_MODE_NUM, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT ("QR_MODE_AN", QR_MODE_AN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT ("QR_MODE_8", QR_MODE_8, CONST_CS | CONST_PERSISTENT);
Expand Down Expand Up @@ -115,7 +112,16 @@ PHP_FUNCTION(qr_encode)
RETURN_FALSE;

qr = (php_qrcode *) emalloc (sizeof (php_qrcode));
qr->c = QRcode_encodeString(text, version, level, mode, casesensitive);
if (mode == QR_MODE_8)
qr->c = QRcode_encodeString8bit(text, version, level);
else
qr->c = QRcode_encodeString(text, version, level, mode, casesensitive);

if (qr->c == NULL)
{
efree (qr);
RETURN_FALSE;
}

ZEND_REGISTER_RESOURCE (return_value, qr, le_qr);
}
Expand Down

0 comments on commit 974e0ec

Please sign in to comment.