]> granicus.if.org Git - php/commitdiff
- Cosmetic changes.
authorJouni Ahto <jah@php.net>
Fri, 9 Jun 2000 18:04:17 +0000 (18:04 +0000)
committerJouni Ahto <jah@php.net>
Fri, 9 Jun 2000 18:04:17 +0000 (18:04 +0000)
- Optionally, create function entries, stubs and declarations from names
  listed in a file.

ext/ext_skel
ext/skeleton/php_skeleton.h
ext/skeleton/skeleton.c
ext/skeleton/skeleton.php

index 4d8954d17f7695148c0d3e85bc6dc352e2cca342..3204ea57f3cd1a66b7f5ade4495b37174574a6c7 100755 (executable)
@@ -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 *
 
index fb4b3739e2886eb172d4833ce95f79c8d613568d..aaf157925f173efef420eae7eba612e9ae39d141 100644 (file)
  
 /* $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:
index c24dc52b6c81630150ca41e66d4a7795f7e27510..bb7e390ca61310ae6474bab137d9245b88b9367f 100644 (file)
 
 #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:
index 953ea2cf6fb7fffae30fb1d5d3d3744cecbd2bc7..fec1a05d98f21099b49a335b8c868758fcfed43d 100644 (file)
@@ -1,6 +1,6 @@
 <?
-$module = '_extname_';
-$function = $module . '_test';
+$module = 'extname';
+$function = 'confirm_' . $module . '_compiled';
 if (extension_loaded($module)) {
        $str = $function($module);
 } else {