Skip to content

Commit af8c246

Browse files
committed
init
0 parents  commit af8c246

9 files changed

Lines changed: 392 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_*

CREDITS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ant

EXPERIMENTAL

Whitespace-only changes.

ant.c

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 7 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2018 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Author: |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
/* $Id$ */
20+
21+
#ifdef HAVE_CONFIG_H
22+
#include "config.h"
23+
#endif
24+
25+
#include "php.h"
26+
#include "php_ini.h"
27+
#include "ext/standard/info.h"
28+
#include "php_ant.h"
29+
30+
/* If you declare any globals in php_ant.h uncomment this:
31+
ZEND_DECLARE_MODULE_GLOBALS(ant)
32+
*/
33+
34+
/* True global resources - no need for thread safety here */
35+
static int le_ant;
36+
37+
/* {{{ PHP_INI
38+
*/
39+
/* Remove comments and fill if you need to have entries in php.ini
40+
PHP_INI_BEGIN()
41+
STD_PHP_INI_ENTRY("ant.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_ant_globals, ant_globals)
42+
STD_PHP_INI_ENTRY("ant.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_ant_globals, ant_globals)
43+
PHP_INI_END()
44+
*/
45+
/* }}} */
46+
47+
/* Remove the following function when you have successfully modified config.m4
48+
so that your module can be compiled into PHP, it exists only for testing
49+
purposes. */
50+
51+
/* Every user-visible function in PHP should document itself in the source */
52+
/* {{{ proto string confirm_ant_compiled(string arg)
53+
Return a string to confirm that the module is compiled in */
54+
PHP_FUNCTION(confirm_ant_compiled)
55+
{
56+
char *arg = NULL;
57+
size_t arg_len, len;
58+
zend_string *strg;
59+
60+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &arg, &arg_len) == FAILURE) {
61+
return;
62+
}
63+
64+
strg = strpprintf(0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "ant", arg);
65+
66+
RETURN_STR(strg);
67+
}
68+
/* }}} */
69+
/* The previous line is meant for vim and emacs, so it can correctly fold and
70+
unfold functions in source code. See the corresponding marks just before
71+
function definition, where the functions purpose is also documented. Please
72+
follow this convention for the convenience of others editing your code.
73+
*/
74+
75+
76+
/* {{{ php_ant_init_globals
77+
*/
78+
/* Uncomment this function if you have INI entries
79+
static void php_ant_init_globals(zend_ant_globals *ant_globals)
80+
{
81+
ant_globals->global_value = 0;
82+
ant_globals->global_string = NULL;
83+
}
84+
*/
85+
/* }}} */
86+
87+
/* {{{ PHP_MINIT_FUNCTION
88+
*/
89+
PHP_MINIT_FUNCTION(ant)
90+
{
91+
/* If you have INI entries, uncomment these lines
92+
REGISTER_INI_ENTRIES();
93+
*/
94+
return SUCCESS;
95+
}
96+
/* }}} */
97+
98+
/* {{{ PHP_MSHUTDOWN_FUNCTION
99+
*/
100+
PHP_MSHUTDOWN_FUNCTION(ant)
101+
{
102+
/* uncomment this line if you have INI entries
103+
UNREGISTER_INI_ENTRIES();
104+
*/
105+
return SUCCESS;
106+
}
107+
/* }}} */
108+
109+
/* Remove if there's nothing to do at request start */
110+
/* {{{ PHP_RINIT_FUNCTION
111+
*/
112+
PHP_RINIT_FUNCTION(ant)
113+
{
114+
#if defined(COMPILE_DL_ANT) && defined(ZTS)
115+
ZEND_TSRMLS_CACHE_UPDATE();
116+
#endif
117+
return SUCCESS;
118+
}
119+
/* }}} */
120+
121+
/* Remove if there's nothing to do at request end */
122+
/* {{{ PHP_RSHUTDOWN_FUNCTION
123+
*/
124+
PHP_RSHUTDOWN_FUNCTION(ant)
125+
{
126+
return SUCCESS;
127+
}
128+
/* }}} */
129+
130+
/* {{{ PHP_MINFO_FUNCTION
131+
*/
132+
PHP_MINFO_FUNCTION(ant)
133+
{
134+
php_info_print_table_start();
135+
php_info_print_table_header(2, "ant support", "enabled");
136+
php_info_print_table_end();
137+
138+
/* Remove comments if you have entries in php.ini
139+
DISPLAY_INI_ENTRIES();
140+
*/
141+
}
142+
/* }}} */
143+
144+
/* {{{ ant_functions[]
145+
*
146+
* Every user visible function must have an entry in ant_functions[].
147+
*/
148+
const zend_function_entry ant_functions[] = {
149+
PHP_FE(confirm_ant_compiled, NULL) /* For testing, remove later. */
150+
PHP_FE_END /* Must be the last line in ant_functions[] */
151+
};
152+
/* }}} */
153+
154+
/* {{{ ant_module_entry
155+
*/
156+
zend_module_entry ant_module_entry = {
157+
STANDARD_MODULE_HEADER,
158+
"ant",
159+
ant_functions,
160+
PHP_MINIT(ant),
161+
PHP_MSHUTDOWN(ant),
162+
PHP_RINIT(ant), /* Replace with NULL if there's nothing to do at request start */
163+
PHP_RSHUTDOWN(ant), /* Replace with NULL if there's nothing to do at request end */
164+
PHP_MINFO(ant),
165+
PHP_ANT_VERSION,
166+
STANDARD_MODULE_PROPERTIES
167+
};
168+
/* }}} */
169+
170+
#ifdef COMPILE_DL_ANT
171+
#ifdef ZTS
172+
ZEND_TSRMLS_CACHE_DEFINE()
173+
#endif
174+
ZEND_GET_MODULE(ant)
175+
#endif
176+
177+
/*
178+
* Local variables:
179+
* tab-width: 4
180+
* c-basic-offset: 4
181+
* End:
182+
* vim600: noet sw=4 ts=4 fdm=marker
183+
* vim<600: noet sw=4 ts=4
184+
*/

ant.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
$br = (php_sapi_name() == "cli")? "":"<br>";
3+
4+
if(!extension_loaded('ant')) {
5+
dl('ant.' . PHP_SHLIB_SUFFIX);
6+
}
7+
$module = 'ant';
8+
$functions = get_extension_funcs($module);
9+
echo "Functions available in the test extension:$br\n";
10+
foreach($functions as $func) {
11+
echo $func."$br\n";
12+
}
13+
echo "$br\n";
14+
$function = 'confirm_' . $module . '_compiled';
15+
if (extension_loaded($module)) {
16+
$str = $function($module);
17+
} else {
18+
$str = "Module $module is not compiled into PHP";
19+
}
20+
echo "$str\n";
21+
?>

config.m4

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
dnl $Id$
2+
dnl config.m4 for extension ant
3+
4+
dnl Comments in this file start with the string 'dnl'.
5+
dnl Remove where necessary. This file will not work
6+
dnl without editing.
7+
8+
dnl If your extension references something external, use with:
9+
10+
dnl PHP_ARG_WITH(ant, for ant support,
11+
dnl Make sure that the comment is aligned:
12+
dnl [ --with-ant Include ant support])
13+
14+
dnl Otherwise use enable:
15+
16+
PHP_ARG_ENABLE(ant, whether to enable ant support,
17+
dnl Make sure that the comment is aligned:
18+
[ --enable-ant Enable ant support])
19+
20+
if test "$PHP_ANT" != "no"; then
21+
dnl Write more examples of tests here...
22+
23+
dnl # get library FOO build options from pkg-config output
24+
dnl AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
25+
dnl AC_MSG_CHECKING(for libfoo)
26+
dnl if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists foo; then
27+
dnl if $PKG_CONFIG foo --atleast-version 1.2.3; then
28+
dnl LIBFOO_CFLAGS=`$PKG_CONFIG foo --cflags`
29+
dnl LIBFOO_LIBDIR=`$PKG_CONFIG foo --libs`
30+
dnl LIBFOO_VERSON=`$PKG_CONFIG foo --modversion`
31+
dnl AC_MSG_RESULT(from pkgconfig: version $LIBFOO_VERSON)
32+
dnl else
33+
dnl AC_MSG_ERROR(system libfoo is too old: version 1.2.3 required)
34+
dnl fi
35+
dnl else
36+
dnl AC_MSG_ERROR(pkg-config not found)
37+
dnl fi
38+
dnl PHP_EVAL_LIBLINE($LIBFOO_LIBDIR, ANT_SHARED_LIBADD)
39+
dnl PHP_EVAL_INCLINE($LIBFOO_CFLAGS)
40+
41+
dnl # --with-ant -> check with-path
42+
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
43+
dnl SEARCH_FOR="/include/ant.h" # you most likely want to change this
44+
dnl if test -r $PHP_ANT/$SEARCH_FOR; then # path given as parameter
45+
dnl ANT_DIR=$PHP_ANT
46+
dnl else # search default path list
47+
dnl AC_MSG_CHECKING([for ant files in default path])
48+
dnl for i in $SEARCH_PATH ; do
49+
dnl if test -r $i/$SEARCH_FOR; then
50+
dnl ANT_DIR=$i
51+
dnl AC_MSG_RESULT(found in $i)
52+
dnl fi
53+
dnl done
54+
dnl fi
55+
dnl
56+
dnl if test -z "$ANT_DIR"; then
57+
dnl AC_MSG_RESULT([not found])
58+
dnl AC_MSG_ERROR([Please reinstall the ant distribution])
59+
dnl fi
60+
61+
dnl # --with-ant -> add include path
62+
dnl PHP_ADD_INCLUDE($ANT_DIR/include)
63+
64+
dnl # --with-ant -> check for lib and symbol presence
65+
dnl LIBNAME=ant # you may want to change this
66+
dnl LIBSYMBOL=ant # you most likely want to change this
67+
68+
dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
69+
dnl [
70+
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $ANT_DIR/$PHP_LIBDIR, ANT_SHARED_LIBADD)
71+
dnl AC_DEFINE(HAVE_ANTLIB,1,[ ])
72+
dnl ],[
73+
dnl AC_MSG_ERROR([wrong ant lib version or lib not found])
74+
dnl ],[
75+
dnl -L$ANT_DIR/$PHP_LIBDIR -lm
76+
dnl ])
77+
dnl
78+
dnl PHP_SUBST(ANT_SHARED_LIBADD)
79+
80+
PHP_NEW_EXTENSION(ant, ant.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
81+
fi

config.w32

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// $Id$
2+
// vim:ft=javascript
3+
4+
// If your extension references something external, use ARG_WITH
5+
// ARG_WITH("ant", "for ant support", "no");
6+
7+
// Otherwise, use ARG_ENABLE
8+
ARG_ENABLE("ant", "enable ant support", "no");
9+
10+
if (PHP_ANT != "no") {
11+
EXTENSION("ant", "ant.c", PHP_EXTNAME_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
12+
}
13+

php_ant.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 7 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2018 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Author: |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
/* $Id$ */
20+
21+
#ifndef PHP_ANT_H
22+
#define PHP_ANT_H
23+
24+
extern zend_module_entry ant_module_entry;
25+
#define phpext_ant_ptr &ant_module_entry
26+
27+
#define PHP_ANT_VERSION "0.1.0" /* Replace with version number for your extension */
28+
29+
#ifdef PHP_WIN32
30+
# define PHP_ANT_API __declspec(dllexport)
31+
#elif defined(__GNUC__) && __GNUC__ >= 4
32+
# define PHP_ANT_API __attribute__ ((visibility("default")))
33+
#else
34+
# define PHP_ANT_API
35+
#endif
36+
37+
#ifdef ZTS
38+
#include "TSRM.h"
39+
#endif
40+
41+
/*
42+
Declare any global variables you may need between the BEGIN
43+
and END macros here:
44+
45+
ZEND_BEGIN_MODULE_GLOBALS(ant)
46+
zend_long global_value;
47+
char *global_string;
48+
ZEND_END_MODULE_GLOBALS(ant)
49+
*/
50+
51+
/* Always refer to the globals in your function as ANT_G(variable).
52+
You are encouraged to rename these macros something shorter, see
53+
examples in any other php module directory.
54+
*/
55+
#define ANT_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(ant, v)
56+
57+
#if defined(ZTS) && defined(COMPILE_DL_ANT)
58+
ZEND_TSRMLS_CACHE_EXTERN()
59+
#endif
60+
61+
#endif /* PHP_ANT_H */
62+
63+
/*
64+
* Local variables:
65+
* tab-width: 4
66+
* c-basic-offset: 4
67+
* End:
68+
* vim600: noet sw=4 ts=4 fdm=marker
69+
* vim<600: noet sw=4 ts=4
70+
*/

tests/001.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Check for ant presence
3+
--SKIPIF--
4+
<?php if (!extension_loaded("ant")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo "ant extension is available";
8+
/*
9+
you can add regression tests for your extension here
10+
11+
the output of your test code has to be equal to the
12+
text in the --EXPECT-- section below for the tests
13+
to pass, differences between the output and the
14+
expected text are interpreted as failure
15+
16+
see php7/README.TESTING for further information on
17+
writing regression tests
18+
*/
19+
?>
20+
--EXPECT--
21+
ant extension is available

0 commit comments

Comments
 (0)