summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJouni Ahto <jah@php.net>2000-06-09 18:04:17 +0000
committerJouni Ahto <jah@php.net>2000-06-09 18:04:17 +0000
commit420d668f33e3685228f9434c8272853e08b32a4f (patch)
tree1e663a7e11593f478459e16c78faea6530c12716
parentae191806418576a788f45439710055b49e8d3391 (diff)
downloadphp-git-420d668f33e3685228f9434c8272853e08b32a4f.tar.gz
- Cosmetic changes.
- Optionally, create function entries, stubs and declarations from names listed in a file.
-rwxr-xr-xext/ext_skel60
-rw-r--r--ext/skeleton/php_skeleton.h61
-rw-r--r--ext/skeleton/skeleton.c59
-rw-r--r--ext/skeleton/skeleton.php4
4 files changed, 120 insertions, 64 deletions
diff --git a/ext/ext_skel b/ext/ext_skel
index 4d8954d17f..3204ea57f3 100755
--- a/ext/ext_skel
+++ b/ext/ext_skel
@@ -2,6 +2,9 @@
extname="$1"
EXTNAME=`echo $1|tr a-z A-Z`
+if [ ! -z $2 -a -r $2 ]; then
+ functions=`cat $2`
+fi
givup() {
echo $*
@@ -9,7 +12,7 @@ givup() {
}
if test "$extname" = ""; then
- givup "usage: $0 extension-name"
+ givup "usage: $0 extension-name [function-names]"
fi
if test -d "$extname" ; then
@@ -27,6 +30,8 @@ else
ECHO_C='\c'
fi
+ECHO_E="echo -e" # Any portability problems? If, how to test.
+
echo "Creating directory"
mkdir $extname || givup "Cannot create directory $extname"
@@ -34,6 +39,35 @@ mkdir $extname || givup "Cannot create directory $extname"
cd $extname
chmod 755 .
+touch function_entries
+touch function_declarations
+touch function_stubs
+
+if [ $2 ] ; then
+ cat > function_stubs <<EOF
+/* Don't forget to remove the '#'-mark before protos when you have finished
+ with your function, so PHP's documentation system recognizes it. And
+ you really documented your function, didn't you?
+*/
+
+EOF
+ for f in $functions; do
+ $ECHO_E "\tPHP_FE($f,\tNULL)" >> function_entries
+ $ECHO_E "PHP_FUNCTION($f);" >> function_declarations
+ cat >> function_stubs <<EOF
+
+/* {{{ #proto $f()
+ */
+PHP_FUNCTION($f)
+{
+ php_error(E_WARNING, "$f: not yet implemented");
+}
+/* }}} */
+
+EOF
+ done
+fi
+
$ECHO_N "Creating basic files:$ECHO_C"
$ECHO_N " config.m4$ECHO_C"
@@ -92,13 +126,31 @@ libs.mk
eof
$ECHO_N " $extname.c$ECHO_C"
-cat ../skeleton/skeleton.c | sed -e "s/_extname_/$extname/g" | sed -e "s/_EXTNAME_/$EXTNAME/g" > $extname.c
+cat ../skeleton/skeleton.c | sed \
+-e "s/extname/$extname/g" \
+-e "s/EXTNAME/$EXTNAME/g" \
+-e '/__function_entries_here__/r function_entries' \
+-e '/__function_stubs_here__/r function_stubs' \
+-e '/__function_entries_here__/D' \
+-e '/__function_stubs_here__/D' \
+> $extname.c
$ECHO_N " php_$extname.h$ECHO_C"
-cat ../skeleton/php_skeleton.h | sed -e "s/_extname_/$extname/g" | sed -e "s/_EXTNAME_/$EXTNAME/g" > php_$extname.h
+cat ../skeleton/php_skeleton.h | sed \
+-e "s/extname/$extname/g" \
+-e "s/EXTNAME/$EXTNAME/g" \
+-e '/__function_declarations_here__/r function_declarations' \
+-e '/__function_declarations_here__/D' \
+> php_$extname.h
$ECHO_N " $extname.php$ECHO_C"
-cat ../skeleton/skeleton.php | sed -e "s/_extname_/$extname/g" | sed -e "s/_EXTNAME_/$EXTNAME/g" > $extname.php
+cat ../skeleton/skeleton.php | sed \
+-e "s/extname/$extname/g" \
+> $extname.php
+
+rm function_entries
+rm function_declarations
+rm function_stubs
chmod 644 *
diff --git a/ext/skeleton/php_skeleton.h b/ext/skeleton/php_skeleton.h
index fb4b3739e2..aaf157925f 100644
--- a/ext/skeleton/php_skeleton.h
+++ b/ext/skeleton/php_skeleton.h
@@ -18,70 +18,71 @@
/* $Id: */
-#ifndef _PHP__EXTNAME__H
-#define _PHP__EXTNAME__H
+#ifndef _PHP_EXTNAME_H
+#define _PHP_EXTNAME_H
-#ifdef COMPILE_DL__EXTNAME_
-#undef HAVE__EXTNAME_
-#define HAVE__EXTNAME_ 1
+#ifdef COMPILE_DL_EXTNAME
+#undef HAVE_EXTNAME
+#define HAVE_EXTNAME 1
#endif
/* You should tweak config.m4 so this symbol (or some else suitable)
gets defined.
*/
-#if HAVE__EXTNAME_
+#if HAVE_EXTNAME
-extern zend_module_entry _extname__module_entry;
-#define phpext__extname__ptr &_extname__module_entry
+extern zend_module_entry extname_module_entry;
+#define phpext_extname_ptr &extname_module_entry
#ifdef PHP_WIN32
-#define PHP__EXTNAME__API __declspec(dllexport)
+#define PHP_EXTNAME_API __declspec(dllexport)
#else
-#define PHP__EXTNAME__API
+#define PHP_EXTNAME_API
#endif
-PHP_MINIT_FUNCTION(_extname_);
-PHP_MSHUTDOWN_FUNCTION(_extname_);
-PHP_RINIT_FUNCTION(_extname_);
-PHP_RSHUTDOWN_FUNCTION(_extname_);
-PHP_MINFO_FUNCTION(_extname_);
+PHP_MINIT_FUNCTION(extname);
+PHP_MSHUTDOWN_FUNCTION(extname);
+PHP_RINIT_FUNCTION(extname);
+PHP_RSHUTDOWN_FUNCTION(extname);
+PHP_MINFO_FUNCTION(extname);
-PHP_FUNCTION(_extname__test); /* For testing, remove later. */
+PHP_FUNCTION(confirm_extname_compiled); /* For testing, remove later. */
+__function_declarations_here__
+/* Fill in this structure and use entries in it
+ for thread safety instead of using true globals.
+*/
typedef struct {
- /* Fill in this structure and use entries in it
- for thread safety instead of using true globals.
- */
/* You can use the next one as type if your module registers any
resources. Oh, you can of course rename it to something more
suitable, add list entry types or remove it if it not needed.
It's just an example.
*/
- int le__extname_;
-} php__extname__globals;
+ int le_extname;
+} php_extname_globals;
-/* In every function that needs to use variables in php__extname__globals,
- do call _EXTNAME_LS_FETCH(); after declaring other variables used by
- that function, and always refer to them as _EXTNAME_G(variable).
+/* In every function that needs to use variables in php_extname_globals,
+ do call EXTNAMELS_FETCH(); after declaring other variables used by
+ that function, and always refer to them as EXTNAMEG(variable).
You are encouraged to rename these macros something shorter, see
examples in any other php module directory.
*/
#ifdef ZTS
-#define _EXTNAME_G(v) (_extname__globals->v)
-#define _EXTNAME_LS_FETCH() php__extname__globals *_extname__globals = ts_resource(gd__extname__id)
+#define EXTNAMEG(v) (extname_globals->v)
+#define EXTNAMELS_FETCH() php_extname_globals *extname_globals = ts_resource(gd_extname_id)
#else
-#define _EXTNAME_G(v) (_extname__globals.v)
-#define _EXTNAME_LS_FETCH()
+#define EXTNAMEG(v) (extname_globals.v)
+#define EXTNAMELS_FETCH()
#endif
#else
-#define php__extname__ptr NULL
+#define php_extname_ptr NULL
#endif
-#endif /* _PHP__EXTNAME__H */
+#endif /* _PHP_EXTNAME_H */
/*
* Local variables:
diff --git a/ext/skeleton/skeleton.c b/ext/skeleton/skeleton.c
index c24dc52b6c..bb7e390ca6 100644
--- a/ext/skeleton/skeleton.c
+++ b/ext/skeleton/skeleton.c
@@ -20,39 +20,40 @@
#include "php.h"
#include "php_ini.h"
-#include "php__extname_.h"
+#include "php_extname.h"
/* You should tweak config.m4 so this symbol (or some else suitable)
gets defined.
*/
-#ifdef HAVE__EXTNAME_
+#ifdef HAVE_EXTNAME
#ifdef ZTS
-int _extname__globals_id;
+int extname_globals_id;
#else
-php__extname__globals _extname__globals;
+php_extname_globals extname_globals;
#endif
-/* Every user visible function must have an entry in _extname_functions[].
+/* Every user visible function must have an entry in extname_functions[].
*/
-function_entry _extname__functions[] = {
- PHP_FE(_extname__test, NULL)
- {NULL, NULL, NULL} /* Must be the last line in $extension_functions[] */
+function_entry extname_functions[] = {
+ PHP_FE(confirm_extname_compiled, NULL) /* For testing, remove later. */
+__function_entries_here__
+ {NULL, NULL, NULL} /* Must be the last line in extname_functions[] */
};
-zend_module_entry _extname__module_entry = {
- "_extname_",
- _extname__functions,
- PHP_MINIT(_extname_),
- PHP_MSHUTDOWN(_extname_),
- PHP_RINIT(_extname_), /* Replace with NULL if there's nothing to do at request start */
- PHP_RSHUTDOWN(_extname_), /* Replace with NULL if there's nothing to do at request end */
- PHP_MINFO(_extname_),
+zend_module_entry extname_module_entry = {
+ "extname",
+ extname_functions,
+ PHP_MINIT(extname),
+ PHP_MSHUTDOWN(extname),
+ PHP_RINIT(extname), /* Replace with NULL if there's nothing to do at request start */
+ PHP_RSHUTDOWN(extname), /* Replace with NULL if there's nothing to do at request end */
+ PHP_MINFO(extname),
STANDARD_MODULE_PROPERTIES
};
-#ifdef COMPILE_DL__EXTNAME_
-ZEND_GET_MODULE(_extname_)
+#ifdef COMPILE_DL_EXTNAME
+ZEND_GET_MODULE(extname)
#endif
/* Remove comments and fill if you need to have entries in php.ini
@@ -60,7 +61,7 @@ PHP_INI_BEGIN()
PHP_INI_END()
*/
-PHP_MINIT_FUNCTION(_extname_)
+PHP_MINIT_FUNCTION(extname)
{
/* Remove comments if you have entries in php.ini
REGISTER_INI_ENTRIES();
@@ -68,7 +69,7 @@ PHP_MINIT_FUNCTION(_extname_)
return SUCCESS;
}
-PHP_MSHUTDOWN_FUNCTION(_extname_)
+PHP_MSHUTDOWN_FUNCTION(extname)
{
/* Remove comments if you have entries in php.ini
UNREGISTER_INI_ENTRIES();
@@ -77,21 +78,21 @@ PHP_MSHUTDOWN_FUNCTION(_extname_)
}
/* Remove if there's nothing to do at request start */
-PHP_RINIT_FUNCTION(_extname_)
+PHP_RINIT_FUNCTION(extname)
{
return SUCCESS;
}
/* Remove if there's nothing to do at request end */
-PHP_RSHUTDOWN_FUNCTION(_extname_)
+PHP_RSHUTDOWN_FUNCTION(extname)
{
return SUCCESS;
}
-PHP_MINFO_FUNCTION(_extname_)
+PHP_MINFO_FUNCTION(extname)
{
php_info_print_table_start();
- php_info_print_table_header(2, "_extname_ support", "enabled");
+ php_info_print_table_header(2, "extname support", "enabled");
php_info_print_table_end();
/* Remove comments if you have entries in php.ini
@@ -105,9 +106,9 @@ PHP_MINFO_FUNCTION(_extname_)
*/
/* Every user-visible function in PHP should document itself in the source */
-/* {{{ proto string _extname__test(string arg)
+/* {{{ proto string confirm_extname_compiled(string arg)
Return a string to confirm that the module is compiled in */
-PHP_FUNCTION(_extname__test)
+PHP_FUNCTION(extname_test)
{
zval **arg;
int len;
@@ -119,7 +120,7 @@ PHP_FUNCTION(_extname__test)
convert_to_string_ex(arg);
- len = sprintf(string, "Congratulations, you have successfully modified ext/_extname_/config.m4, module %s is compiled in PHP", Z_STRVAL_PP(arg));
+ len = sprintf(string, "Congratulations, you have successfully modified ext/extname/config.m4, module %s is compiled in PHP", Z_STRVAL_PP(arg));
RETVAL_STRINGL(string, len, 1);
}
/* }}} */
@@ -129,7 +130,9 @@ PHP_FUNCTION(_extname__test)
this convention for the convenience of others editing your code.
*/
-#endif /* HAVE__EXTNAME_ */
+__function_stubs_here__
+
+#endif /* HAVE_EXTNAME */
/*
* Local variables:
diff --git a/ext/skeleton/skeleton.php b/ext/skeleton/skeleton.php
index 953ea2cf6f..fec1a05d98 100644
--- a/ext/skeleton/skeleton.php
+++ b/ext/skeleton/skeleton.php
@@ -1,6 +1,6 @@
<?
-$module = '_extname_';
-$function = $module . '_test';
+$module = 'extname';
+$function = 'confirm_' . $module . '_compiled';
if (extension_loaded($module)) {
$str = $function($module);
} else {