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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.