Jump to content

Calling internal function


wreckman

Recommended Posts

I can't call a C function (internal) in an exported PHP function ! (like ftp extension for exemple)

I don't understand why, if anyone can help, please.....

 

 

Here are the sources files of my module :

 

php_test.c // Zend module definition files

php_php_test.h

 

testc.c // Non exported C functions

testc.h

 

Here is a sample of php_test.c :

 

// Return a string, Takes a string

PHP_FUNCTION(test)

{

char *szNomRepToGet;

int argc = ZEND_NUM_ARGS();

int szNomRepToGet_len;

 

if(zend_parse_parameters(argc TSRMLS_CC, "s", &szNomRepToGet, szNomRepToGet_len) == FAILURE)

{ return; }

 

char *value;

value = testcc(szNomRepToGet);

RETURN_STRING(value,1);

}

 

Here is a sample of testc.c

 

static char* testcc(char* toto); // defintion

 

char* testcc(char* toto)

{

stcRep StcRepTest;

 

/* INITIALISATION DE MA STRUCTURE */

StcRepTest.num = 1;

strcpy(StcRepTest.text, "toto");

 

/* TEST CONTENU STRUCTURE */

if(StcRepTest.num == 1)

{

// zend_printf("Bien vu, ta struct est déclarée");

char* testok = "ok";

return testok;

}

char* testnok = "nok";

return testnok;

}

 

Here is a sample of testc.h

 

typedef struct

{

int num;

char* text;

}stcRep;

 

 

static char* testcc(char* toto);

 

 

Thanks in advance, Rom1

...Reading : Building Custom PHP Extensions => Very Good Book !

Link to comment
https://forums.phpfreaks.com/topic/1737-calling-internal-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.