Watt-32 tcp/ip  2.2 dev-rel.10
stream.c
Go to the documentation of this file.
1 
37 #include "socket.h"
38 
39 #if defined(USE_BSD_API)
40 
41 /*
42  * How does this fit in with djgpp's FSextensions ?
43  * Does it support fdopen() ?
44  */
45 
46 int sock_fgets (char *buf, int max, FILE *stream)
47 {
48  int rc, s = fileno (stream);
49  Socket *sock = _socklist_find (s);
50  sock_type *sk = NULL;
51 
52  SOCK_PROLOGUE (sock, "\nsock_fgets:%d", s);
53 
54  if (sock->tcp_sock)
55  sk = (sock_type*) sock->tcp_sock;
56  else if (sock->udp_sock)
57  sk = (sock_type*) sock->udp_sock;
58 
59  rc = sk ? sock_gets (sk, (BYTE*)buf, max) : -1;
60 
61  SOCK_DEBUGF ((", rc %d", rc));
62  return (rc);
63 }
64 
65 int sock_fputs (const char *text, FILE *stream)
66 {
67  int s = fileno (stream);
68  Socket *sock = _socklist_find (s);
69 
70  SOCK_PROLOGUE (sock, "\nsock_fputs:%d", s);
71  return write_s (s, text, strlen(text));
72 }
73 
74 #endif /* USE_BSD_API */
Definition: socket.h:137
Socket * _socklist_find(int s)
Returns a pointer to the Socket structure associated with socket 's'.
Definition: socket.c:1534