× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello,

However when I ask for the entire document, because it's a binary stream, there is no cr/lf, or - better - there can be any somewhere or none and it's difficult to know the exact amount of data returned.

In that case, don't use fdopen() or fgets(). Simply use the read() and write() APIs (the ones you may have previously used for working with the IFS). The file descriptor returned by the pipe() API is no different from any other FD. You can read from it using the read() API...

So, in pseudo-code, you'd do something like this:

   a) Create/open a new IFS file with the open() API.

   b) Create the pipes with the pipe() API.

   c) Spawn a new job (mapping the pipes to stdin/stdout/stderr)
        for your "C API" to run under.

   d) Use the read() API to read a chunk of data from the pipe.
        (reading from the FD for the pipe.)

          len = read(pipe: %addr(buf): %size(buf));

   e) If len > 0, write the data to the IFS File.  Be sure to use
      the length returned by read() to avoid extra garbage chars.

          callp write(stmf: %addr(buf): len);

   f) if len > 0, go back to step (d).  Keep doing this until
      len <= 0, that's when you've reached the end of the data
      on the pipe.

   g) Close the IFS file and the pipes.

Does that make sense?

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.