Monday, November 06, 2006

EXTENSÃO SIMPLES "HelloWorld"

Ficheiro de configuração config.w32:




// $Id$
// vim:ft=javascript
// Para referir a argumentos externos -> ARG_WITH
// ARG_WITH("gpib", "for gpib support", "no");
// De outro modo -> ARG_ENABLE
// ARG_ENABLE("gpib", "enable gpib support",
"no");
if (PHP_GPIB != "no") {
EXTENSION("gpib", "gpib.c");
}


php_gpib.h



$Id: header,v 1.16.2.1 2006/01/01 12:50:00 sniper Exp $ */
#ifndef
PHP_GPIB_H#define PHP_GPIB_H
extern zend_module_entry
gpib_module_entry;#define phpext_gpib_ptr &gpib_module_entry
#ifdef
PHP_WIN32#define PHP_GPIB_API __declspec(dllexport)
#else#
define
PHP_GPIB_API#endif
#ifdef ZTS#include
"TSRM.h"
#endif
PHP_MINFO_FUNCTION(gpib);
PHP_FUNCTION(hello_world);/*
Função HelloWorld */
#ifdef ZTS#define GPIB_G(v) TSRMG(gpib_globals_id,zend_gpib_globals *, v)
#else#
define GPIB_G(v)
(gpib_globals.v)
#endif
#endif /* PHP_GPIB_H */


gpib.c

#ifdef
HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_gpib.h"
/* True global resources - no need for thread safety here
*/static int le_gpib;
/* {{{
gpib_functions[] * * Todas as Funções
visiveis ao utilizador devem
estar aqui declaradas.
*/
zend_function_entry gpib_functions[] =
{
PHP_FE(hello_world, NULL)
{NULL, NULL,NULL}
/* Sempre a ultima linha no gpib_functions[] */};/*
}}} */
/* {{{
gpib_module_entry
*/zend_module_entry
gpib_module_entry = {#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"gpib",
gpib_functions,
NULL,/*MINIT */
NULL, /* MSHUTDOWN */
NULL, /* RINIT */
NULL, /* RSHUTDOWN */

PHP_MINFO(gpib),#if
ZEND_MODULE_API_NO >= 20010901 "0.1", /* Nº da
versão da extensão
*/#endif STANDARD_MODULE_PROPERTIES};/* }}} */
#ifdef
COMPILE_DL_GPIBZEND_GET_MODULE(gpib)#endif
PHP_MINFO_FUNCTION(gpib){
php_info_print_table_start();
php_info_print_table_header(2, "GPIB Functions", "enabled");
php_info_print_table_row(2, "Gpib Version","0.1");
php_info_print_table_row(2, "Gpib Date","26/10/2006");
php_info_print_table_row(2, "Gpib Author","José Mendonça");
php_info_print_table_end();
/* Remove comments if you
have entries
in
php.ini DISPLAY_INI_ENTRIES(); */}/* }}} */
/* {{{
HelloWorld
*/PHP_FUNCTION(hello_world){ php_printf("Hello World!\n");}/* }}}
*/



1 comment:

Rodrigo Gregorio said...

Parabens , vou estudar muito todo o conteudo desse site para criar as extensoes que eu preciso para o php.

Valeu pelas dicas.

Se vc puder me ajudar a transformar uma classe em uma classe em C para modulos em php seria de grande ajuda.