Skip to content

Commit be27769

Browse files
committed
fixed #6 change package name
1 parent 28fe6b7 commit be27769

16 files changed

+161
-160
lines changed

README.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
# PHP file extension
1+
# PHP file magic extension
22

33
## Description
44

55
This extension is similar to the [fileinfo](https://www.php.net/manual/en/book.fileinfo.php) extension, but only one FileBin function is provided to make it a simple use.
66

7-
The filebin function returns the same result as the result of the /bin/file command as a string.
7+
The filemagic function returns the same result as the result of the /bin/file command as a string.
88

99
## Installation
1010

1111
```bash
12-
[root@host filebin]$ phpize
13-
[root@host filebin]$ ./configure
14-
[root@host filebin]$ make test PHP_EXECUTABLE=/usr/bin/php
15-
[root@host filebin]$ make install
12+
[root@host magic]$ phpize
13+
[root@host magic]$ ./configure
14+
[root@host magic]$ make test PHP_EXECUTABLE=/usr/bin/php
15+
[root@host magic]$ make install
1616
```
1717

18-
If the libmagic library is not in the OS standard path, use the ```--with-filebin=@libMagic_prefix@``` option.
18+
If the libmagic library is not in the OS standard path, use the ```--with-magic=@libMagic_prefix@``` option.
1919

2020
```bash
21-
[root@host filebin]$ phpize
22-
[root@host filebin]$ ./configure --with-filebin=/opt/libmagic
21+
[root@host magic]$ phpize
22+
[root@host magic]$ ./configure --with-magic=/opt/libmagic
2323
```
2424

2525
## Loading
2626

27-
regist filebin.so in php.ini or php sub configuration.
27+
regist magic.so in php.ini or php sub configuration.
2828

2929
```ini
3030
; for PHP 7.1 and before
31-
extension = filebin.so
31+
extension = magic.so
3232

3333
; for PHP 7.2 and after
34-
extension = filebin
34+
extension = magic
3535
; and also regist with absolute path
36-
extension = /path/filebin.so
36+
extension = /path/magic.so
3737
```
3838

3939
## Proto types:
4040
```php
41-
filebin (string path, int flag = MAGIC_NONE, string magic_path = MIGIC_FILE): string|false
42-
filebin (string path, string magic_path = MIGIC_FILE, int flag = MAGIC_NONE): string|false
41+
filemagic (string path, int flag = MAGIC_NONE, string magic_path = MIGIC_FILE): string|false
42+
filemagic (string path, string magic_path = MIGIC_FILE, int flag = MAGIC_NONE): string|false
4343
```
4444

4545
The 2th argument and the 3th argument can be swapped with each other.
@@ -92,7 +92,7 @@ Name | Description
9292
**Most common usage** :
9393
```php
9494
<?php
95-
if ( ($buf = filebin ('modules/filebin.so')) != false )
95+
if ( ($buf = filemagic ('modules/magic.so')) != false )
9696
echo "$buf\n";
9797
?>
9898

@@ -103,7 +103,7 @@ ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, Buil
103103
**Execute with custom MAGIC file** :
104104
```php
105105
<?php
106-
if ( ($buf = filebin ('modules/filebin.so', '/usr/share/misc/magic.mgc')) != false )
106+
if ( ($buf = filemagic ('modules/magic.so', '/usr/share/misc/magic.mgc')) != false )
107107
echo "$buf\n";
108108
?>
109109

@@ -113,7 +113,7 @@ ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, Buil
113113

114114
**Get only file mime type** :
115115
```php
116-
if ( ($buf = filebin ('modules/filebin.so', MAGIC_MIME_ENCODING)) != false )
116+
if ( ($buf = filemagic ('modules/magic.so', MAGIC_MIME_ENCODING)) != false )
117117
echo "$buf\n";
118118
?>
119119

@@ -123,7 +123,7 @@ binary
123123

124124
**Get only file mime type with custom MAGIC file** :
125125
```php
126-
if ( ($buf = filebin ('modules/filebin.so', MAGIC_MIME, '/usr/share/misc/magic.mgc')) != false )
126+
if ( ($buf = filemagic ('modules/magic.so', MAGIC_MIME, '/usr/share/misc/magic.mgc')) != false )
127127
echo "$buf\n";
128128
?>
129129

@@ -133,7 +133,7 @@ application/x-sharedlib; charset=binary
133133

134134
**Can enable to swap 2th and 3th argument each other** :
135135
```php
136-
if ( ($buf = filebin ('modules/filebin.so', MAGIC_MIME, '/usr/share/misc/magic.mgc')) != false )
136+
if ( ($buf = filemagic ('modules/magic.so', MAGIC_MIME, '/usr/share/misc/magic.mgc')) != false )
137137
echo "$buf\n";
138138
?>
139139

config.m4

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
dnl config.m4 for filebin extension
1+
dnl config.m4 for magic extension
22

33
dnl build support C99
44
AC_PROG_CC_C99
55

6-
AC_DEFUN([FBIN_HEADER_CHECKED], [
6+
AC_DEFUN([MAGIC_HEADER_CHECKED], [
77
for HDNAME in $1
88
do
9-
for i in $FILEBIN_PREFIX_PATH
9+
for i in $MAGIC_PREFIX_PATH
1010
do
1111
if test -f $i/include/$HDNAME; then
12-
FILEBIN_HEADER_DIR=$i/include
12+
MAGIC_HEADER_DIR=$i/include
1313
break
1414
fi
1515
done
1616
1717
for i in `sed 's/-I//g' <<< "$CPPFLAGS" `
1818
do
1919
if test -f $i/$HDNAME; then
20-
FILEBIN_HEADER_DIR=$i
20+
MAGIC_HEADER_DIR=$i
2121
break
2222
fi
2323
done
2424
2525
OLD_CPPFLAGS="$CPPFLAGS"
26-
if test "x$FILEBIN_HEADER_DIR" != "x"; then
27-
CPPFLAGS="-I$FILEBIN_HEADER_DIR"
26+
if test "x$MAGIC_HEADER_DIR" != "x"; then
27+
CPPFLAGS="-I$MAGIC_HEADER_DIR"
2828
fi
2929
AC_CHECK_HEADERS($HDNAME, [], [
3030
AC_MSG_ERROR([$HDNAME not found.])
@@ -33,56 +33,56 @@ AC_DEFUN([FBIN_HEADER_CHECKED], [
3333
done
3434
])
3535

36-
AC_DEFUN([FBIN_LIBRARY_CHECKED], [
36+
AC_DEFUN([MAGIC_LIBRARY_CHECKED], [
3737
if test "x$with_static_magic" = "xyes"; then
3838
LIBNAME="lib$1.a"
3939
else
4040
LIBNAME="lib$1.$SHLIB_SUFFIX_NAME"
4141
fi
4242
43-
for i in $FILEBIN_PREFIX_PATH
43+
for i in $MAGIC_PREFIX_PATH
4444
do
4545
if test -f $i/$PHP_LIBDIR/$LIBNAME ; then
46-
FILEBIN_LIB_DIR=$i/$PHP_LIBDIR
46+
MAGIC_LIB_DIR=$i/$PHP_LIBDIR
4747
break
4848
fi
4949
done
5050
5151
for i in `sed 's/-L//g' <<< "$LDFLAGS"`
5252
do
53-
test "x$FILEBIN_LIB_DIR" != "x" && break
53+
test "x$MAGIC_LIB_DIR" != "x" && break
5454
if test -f $i/$LIBNAME; then
55-
FILEBIN_LIB_DIR=$i
55+
MAGIC_LIB_DIR=$i
5656
break
5757
fi
5858
done
5959
60-
if test "x$FILEBIN_LIB_DIR" == "x"; then
60+
if test "x$MAGIC_LIB_DIR" == "x"; then
6161
AC_MSG_CHECKING([for $2 in -l$1])
6262
AC_MSG_ERROR([$LIBNAME not found.])
6363
fi
6464
6565
if test "x$with_static_magic" = "xyes"; then
6666
AC_MSG_CHECKING([for $2 in -l$1])
67-
strings "$FILEBIN_LIB_DIR/$LIBNAME" | grep -q "^$2\$"
67+
strings "$MAGIC_LIB_DIR/$LIBNAME" | grep -q "^$2\$"
6868
if test $? == 0; then
69-
AC_MSG_RESULT([yes, $FILEBIN_LIB_DIR/$LIBNAME])
70-
#FILEBIN_SHARED_LIBADD="-Wl,-Bstatic -lmagic"
71-
LDFLAGS="$LDFLAGS $FILEBIN_LIB_DIR/$LIBNAME"
72-
FILEBIN_LIB_DIR=
69+
AC_MSG_RESULT([yes, $MAGIC_LIB_DIR/$LIBNAME])
70+
#MAGIC_SHARED_LIBADD="-Wl,-Bstatic -lmagic"
71+
LDFLAGS="$LDFLAGS $MAGIC_LIB_DIR/$LIBNAME"
72+
MAGIC_LIB_DIR=
7373
else
7474
AC_MSG_ERROR([$LIBNAME does not include $2.])
7575
fi
7676
else
7777
OLD_LDFLAGS="$LDFLAGS"
78-
LDFLAGS="-L$FILEBIN_LIB_DIR"
78+
LDFLAGS="-L$MAGIC_LIB_DIR"
7979
AC_CHECK_LIB(magic, magic_open, [ ], [ AC_MSG_ERROR([$LIBNAME not found.]) ])
8080
LDFLAGS="$OLD_LDFLAGS"
8181
fi
8282
])
8383

84-
PHP_ARG_WITH(filebin, for filebin support,
85-
[ --with-filebin[=DIR] Include filebin support. DIR is the file
84+
PHP_ARG_WITH(magic, for magic support,
85+
[ --with-magic[=DIR] Include magic support. DIR is the file
8686
install directory.])
8787

8888
#echo "_______________________________________________________"
@@ -91,10 +91,10 @@ PHP_ARG_WITH(filebin, for filebin support,
9191
# PHP_EXECUTABLE="/usr/bin/php"
9292
#fi
9393

94-
if test "$PHP_FILEBIN" != "no"; then
95-
AC_DEFINE(HAVE_FILEBIN,1,[ ])
94+
if test "$PHP_MAGIC" != "no"; then
95+
AC_DEFINE(HAVE_MAGIC,1,[ ])
9696

97-
FILEBIN_PREFIX_PATH="$PHP_FILEBIN /usr /usr/local /opt/file /usr/local/file"
97+
MAGIC_PREFIX_PATH="$PHP_MAGIC /usr /usr/local /opt/file /usr/local/file"
9898

9999
if test "$with_libdir" != "$PHP_LIBDIR"; then
100100
parch=`uname -m`
@@ -109,7 +109,7 @@ if test "$PHP_FILEBIN" != "no"; then
109109
fi
110110
test -z "$PHP_LIBDIR" && PHP_LIBDIR="lib"
111111

112-
FILEBIN_PARAMETER=$CFLAGS
112+
MAGIC_PARAMETER=$CFLAGS
113113
PHP_SUBST(CPPFLAGS)
114114
PHP_SUBST(LDFLAGS)
115115

@@ -152,20 +152,20 @@ if test "$PHP_FILEBIN" != "no"; then
152152

153153

154154
AC_CHECK_LIB(z, gzopen)
155-
FBIN_LIBRARY_CHECKED(magic, magic_open)
155+
MAGIC_LIBRARY_CHECKED(magic, magic_open)
156156

157-
FBIN_HEADER_CHECKED(locale.h fcntl.h magic.h)
157+
MAGIC_HEADER_CHECKED(locale.h fcntl.h magic.h)
158158

159159
extra_src=""
160160

161-
PHP_EXPAND_PATH($FILEBIN_HEADER_DIR, FILEBIN_HEADER_DIR)
162-
PHP_ADD_INCLUDE($FILEBIN_HEADER_DIR)
163-
if test "x$FILEBIN_LIB_DIR" != "x"; then
164-
PHP_ADD_LIBRARY_WITH_PATH(magic, $FILEBIN_LIB_DIR, FILEBIN_SHARED_LIBADD)
161+
PHP_EXPAND_PATH($MAGIC_HEADER_DIR, MAGIC_HEADER_DIR)
162+
PHP_ADD_INCLUDE($MAGIC_HEADER_DIR)
163+
if test "x$MAGIC_LIB_DIR" != "x"; then
164+
PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_LIB_DIR, MAGIC_SHARED_LIBADD)
165165
fi
166-
PHP_SUBST(FILEBIN_PARAMTER)
167-
PHP_SUBST(FILEBIN_SHARED_LIBADD)
166+
PHP_SUBST(MAGIC_PARAMTER)
167+
PHP_SUBST(MAGIC_SHARED_LIBADD)
168168

169169

170-
PHP_NEW_EXTENSION(filebin, filebin.c $extra_src, $ext_shared,, \\$(FILEBIN_PARAMETER))
170+
PHP_NEW_EXTENSION(magic, magic.c $extra_src, $ext_shared,, \\$(MAGIC_PARAMETER))
171171
fi

filebin.stub.php

-2
This file was deleted.

0 commit comments

Comments
 (0)