On Mar 9, 2007, at 3:53 PM, Tim Jones wrote: > On Mar 9, 2007, at 1:41 PM, Charles Yeomans wrote: > >> On Mar 9, 2007, at 2:53 PM, Tim Jones wrote: >> >>> On Mar 9, 2007, at 11:38 AM, Charles Yeomans wrote: >>> >>>> On Mar 9, 2007, at 1:24 PM, Tim Jones wrote: >>>> >>>>> Hi Folks, >>>>> >>>>> I've a need to use popen for an operation that I can't achieve >>>>> with >>>>> the RB Shell class. Does anyone have a soft declare for popen >>>>> () in >>>>> libc? The prototype is: >>>>> >>>>> FILE * popen(const char *command, const char *type); >>>> >>>> This looks pretty simple; I'll knock out an example if I can find a >>>> bit of time. >>> >>> Thanks, Charles. What I'm running up against is the FILE being a >>> pointer to a struct. Since I'll be using fread(), fwrite(), and >>> feof >>> () to access the opened pipe, I don't really need the struct, but >>> only the filehandle. My curiosity is in how to handle the FILE >>> pointer returned and turn it into the filehandle (using fileno() ). >> >> Why not use fgets and fputs? >> > Because the pipe is a stream and the data will be coming in > continuously. I'm actually providing a DataAvailable and Completed > event so that this can be used in the stead of the Shell so I don't > need to change the existing code.
Looking at fread, I'm not sure what the problem is; popen returns a FILE*, and fread wants a FILE*. So all you need to do is to pass the value returned from popen (unless it's null, of course) to fread or fwrite and have at it. Charles Yeomans _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
