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]

 



This is going to the list per Nathan's suggestion.

I confess I am doing this the hard way because I want to get a handle
on how to pass across that boundary.

My current angle of attack is to use the malloc.i functions in swig to
handle those strings.

I will keep you all posted. I know you care. :-)

Eric


    I have a software library that parses strings into a C language
    structure. It is a utility for C programmers.

    It contains a utility function that takes the output structure and
    formats it as a string for display.

    The goal is to demonstrate the functionality by permitting users to
    enter strings into a text box and press a button.
    The string will be passed into my code, parsed, formatted as a
    different kind of string, and returned, where it will be
    displayed on the web site.

    The code is being shipped as a Windows DLL but for the web site I am
    working with Linux dynamic libraries (*.so).
    I am able to call functions within the binary from PHP now, but
    pointers within PHP are not working far less crossing the
    PHP/C Line Of Death without dying.


please keep the responses on list for the benefit of others.

well, if you have an .so, honestly i might spend the effort to wrap it
up in a simple extension.

but if you want to roll something out quickly, i would probly just
invoke it over the shell via shell_exec() or similar.

i cant imagine what sort of noticeable impact you would see in
performance going over the shell in this case.  honestly, i think the
question is how much work do you want to do.  also, do you intend to
share this functionality w/ other php programers, that might be an
argument for an extension.

do you already have a C based program that loads up the library from
the cli and uses STDIN / STDOUT, if so i think going over the shell is
a no-brainer..

On Tue, Jan 5, 2010 at 2:56 PM, Nathan Nobbe <quickshiftin@xxxxxxxxx> wrote:
> On Tue, Jan 5, 2010 at 3:42 PM, Eric Fowler <eric.fowler@xxxxxxxxx> wrote:
>>
>> Hm, that could work, but it does produce overhead.
>
> you should consider your overall communication paradigm.  im very loosely
> familiar w/ swig, basically ive heard of it ...
> anyways, you have a few options for communication,
> . shell (call php from C or the other way around)
> . php extension, this may not make sense depending on what your C is doing
> and is by far the most complex
> . network protocol, socket, http or other..
> can you tell us a little bit more about what youre trying to accomplish and
> specifically how C and php are communicating in general in your application?
> -nathan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[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