Re: How to get a string from C library into PHP via SWIG?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2010-01-05 at 13:29 -0800, Eric Fowler wrote:

> I have a need to call a C language function from a PHP script.
> 
> The function, which I wrote, looks like this:
> 
> /*
> * foo(): Takes a string in sIn and writes another string into sOut
> according to what is passed in, and the
> * value at *pcch. Will not write more than *pcch bytes to output,
> including null terminator.
> * Upon return, *pcch contains number of chars written to sOut.
> */
> void foo(const char * sIn, char * sOut, size_t * pcch);
> 
> So basically I need to pass down a string, and get back a string.
> 
> I have been using swig but clearly I ain't getting it (I am good in C
> but new to PHP). Lots of warnings, crashes, and so on. No happiness.
> 
> The swig docs show how to pass strings between python, java, etc., and
> C, but nothing on C <---> PHP.
> 
> Can anyone help me with a fragment of sample code, or a link?
> 
> Thanks
> 
> Eric
> 


Can't you just compile the C into an executable and call it from a
shell? There are several ways to retrieve input from shell programs.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux