Welcome, Guest. Please login or register.

Author Topic: fdopen and libnix  (Read 1618 times)

Description:

0 Members and 1 Guest are viewing this topic.

  • Guest
fdopen and libnix
« on: April 03, 2003, 10:19:51 AM »
The "unix" function fdopen isn't implemented in libnix. how can I solve that? Ripping it from ixemul or rewriting so it uses something else?
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: fdopen and libnix
« Reply #1 on: April 03, 2003, 10:27:33 AM »
Roll your own :-)

That's usually what I end up doing. Make a good solid job of it anf put it into your own link library for reuse later.
int p; // A
 

  • Guest
Re: fdopen and libnix
« Reply #2 on: April 03, 2003, 09:43:30 PM »
Yes, that was exactly what I was trying to do with the fdopen from the ixemul sources, but I got tangled and dragged down by a viciuos monster called "header". I managed to escape it's grip and went here to ask you, wise man, of advice :)

I though maybe you could give me a secret formula or reveal the monsters weak points so I can slay it.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: fdopen and libnix
« Reply #3 on: April 03, 2003, 09:48:22 PM »
Could you be a tad more specific, old fellow?

Are you having trouble creating a header file?

-edit-

PS don't get too sarcastic :-D
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: fdopen and libnix
« Reply #4 on: April 03, 2003, 10:05:13 PM »
Just looking at POSIX compliant fdopen() as defined under Watcom..

To my eye, it looks like youre probably best off replacing the stuff all together with ANSI IO.

Maybe I got this wrong but (from Watcom example doc)


#include
#include
#include

void main()
{
   int handle;
   FILE *fp;

   handle = open( "file", O_RDONLY | O_TEXT );
   if( handle != -1 ) {
      fp = fdopen( handle, "r" );
      if( fp != NULL ) {
         /*
            process the stream
      */
      fclose( fp );
      } else {
      close( handle );
      }
   }
}


doesn't look especially useful. You could just use fopen("file", "r") and skip the open() / fdopen() stuff.
Well, in the above example at least :-)
int p; // A