Skip to content

Commit

Permalink
- support over PHP 7
Browse files Browse the repository at this point in the history
- unsupport PHP 3/4/5
  • Loading branch information
Joungkyun committed Dec 27, 2015
1 parent f1b59ce commit 13a4421
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
7 changes: 7 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ $Id$

PHP filebin Extensoin Changelog

* 3.0.0
--------------------------------------------------------------------------------
* Sun Dec 28 2015 JoungKyun.Kim <http://oops.org>
- support over PHP 7
- unsupport PHP 3/4/5


* 2.0.0
--------------------------------------------------------------------------------
* Sun Nov 4 2012 JoungKyun.Kim <http://oops.org>
Expand Down
34 changes: 20 additions & 14 deletions filebin.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
#include "php_filebin.h"
/* }}} */

#if PHP_API_VERSION < 20151012
#error "************ PHP version dependency problems *******************"
#error "This package requires over php 7.0.0 !!"
#error "If you build with php under 7.0.0, use mod_filebin 2.x version"
#error "You can download mod_filebin 2.x at http://mirror.oops.org/pub/oops/php/extensions/mod_filebin/"
#endif

#if HAVE_FILEBIN

/* True global resources - no need for thread safety here */
Expand Down Expand Up @@ -151,15 +158,14 @@ PHP_MINIT_FUNCTION(filebin)
*/
PHP_FUNCTION(filebin) {
zval * zflag;
char * path = NULL;
zend_string * path = NULL;
zend_string * mpath = NULL;
char * magicpath = NULL;
const char * type;
int path_len = 0,
magic_len = 0,
flags = 0,
flag = 0,
action = 0, // FILE_LOAD
chkargs = ZEND_NUM_ARGS ();
int flags = 0,
flag = 0,
action = 0, // FILE_LOAD
chkargs = ZEND_NUM_ARGS ();

struct stat filestat;
struct magic_set * magic = NULL;
Expand All @@ -177,18 +183,17 @@ PHP_FUNCTION(filebin) {

if (
zend_parse_parameters (
chkargs TSRMLS_CC,
"s|zs", &path, &path_len, &zflag, &magicpath, &magic_len) == FAILURE
chkargs, "S|zS", &path, &zflag, &mpath) == FAILURE
)
return;

if ( path_len == 0 ) {
if ( ZSTR_LEN (path) == 0 ) {
php_error (E_WARNING, "Must need filename for checking.");
RETURN_NULL ();
}

if ( stat (path, &filestat) != 0 ) {
php_error (E_WARNING, "%s is not found.", path);
if ( stat (ZSTR_VAL (path), &filestat) != 0 ) {
php_error (E_WARNING, "%s is not found.", ZSTR_VAL (path));
RETURN_NULL ();
}

Expand All @@ -214,6 +219,7 @@ PHP_FUNCTION(filebin) {
}

flag = Z_LVAL_P (zflag);
magicpath = ZSTR_LEN (mpath) ? ZSTR_VAL (mpath) : NULL;
}

if ( flag )
Expand All @@ -231,13 +237,13 @@ PHP_FUNCTION(filebin) {
RETURN_NULL ();
}

if ( (type = magic_file (magic, path)) == NULL ) {
if ( (type = magic_file (magic, ZSTR_VAL (path))) == NULL ) {
php_error (E_WARNING, magic_error(magic));
magic_close (magic);
RETURN_NULL ();
}

RETVAL_STRING (type, 1);
RETVAL_STRING (type);
magic_close (magic);
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion init.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
[ -f Makefile ] && make distclean
rm -f config.guess config.h config.h.in config.nice config.sub configure configure.in
rm -f acinclude.m4 aclocal.m4
rm -f acinclude.m4 aclocal.m4 tags
rm -rf autom4te.cache build include modules
rm -f install-sh missing mkinstalldirs ltmain.sh
rm -f .deps Makefile.global
Expand Down
8 changes: 6 additions & 2 deletions php_filebin.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,18 @@ PHP_FUNCTION(filebin);

#endif

#define FILEBIN_BUILDVER "2.0.0"
#define FILEBIN_BUILDVER "3.0.0"

#define phpext_filebin_ptr filebin_module_ptr

int file_main(int argc, char *argv[]);


#if ZEND_MODULE_API_NO >= 20050922
#if ZEND_MODULE_API_NO >= 20151012
# define OB_START_BUFFER php_output_start_default()
# define OB_GET_BUFFER php_output_get_contents
# define OB_END_BUFFER php_output_discard()
#elif ZEND_MODULE_API_NO >= 20050922
# define OB_START_BUFFER php_output_start_default(TSRMLS_C)
# define OB_GET_BUFFER php_output_get_contents
# define OB_END_BUFFER php_output_discard(TSRMLS_C)
Expand Down

0 comments on commit 13a4421

Please sign in to comment.