wreckman Posted March 11, 2004 Share Posted March 11, 2004 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 More sharing options...
wreckman Posted March 11, 2004 Author Share Posted March 11, 2004 The problem is found......... forgot to emalloc a reception variable for toto StcRepTest.text = (char *) emalloc(strlen("toto")+1); GOOD LUCK, EXT'CODERS Link to comment https://forums.phpfreaks.com/topic/1737-calling-internal-function/#findComment-5651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.