Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
c4dde69d
...
c4dde69df09b046ae2e9fc3fc01e80a9424099c4
authored
2002-09-04 08:24:53 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Include http.c.texi
1 parent
ebe7501d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
113 deletions
doc/texinfo/stream.texi
doc/texinfo/stream.texi
View file @
c4dde69
...
...
@@ -114,118 +114,6 @@ Last action was @code{stream_close}.
An
example
using
@code
{
tcp_stream_create
}
to
make
a
simple
web
client
:
FIXME
:
this
example
won
'
t
build
anymore
.
@example
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <mailutils/io.h>
const
char
*
wbuf
=
"GET / HTTP/1.0
\r\n\r\n
"
;
char
rbuf
[
1024
];
int
main
(
int
argc
,
char
**
argv
)
@{
int
ret
,
off
=
0
,
fd
;
stream_t
stream
;
size_t
nb
;
fd_set
fds
;
argc
=
argc
,
argv
=
argv
;
ret
=
tcp_stream_create
(
&
stream
)
;
if
(
ret
!=
0
)
@{
fprintf
(
stderr
,
"tcp_stream_create: %s
\n
"
,
mailutils_error
(
ret
))
;
exit
(
EXIT_FAILURE
)
;
@
}
connect_again:
ret
=
stream_open
(
stream
,
"www.netscape.com"
,
80
,
MU_STREAM_NONBLOCK
)
;
if
(
ret
!=
0
)
@{
if
(
ret
==
MU_ERROR_EAGAIN
)
@{
ret
=
stream_get_fd
(
stream
,
&
fd
)
;
if
(
ret
!=
0
)
@{
fprintf
(
stderr
,
"stream_get_fd: %s
\n
"
,
mailutils_error
(
ret
))
;
exit
(
EXIT_FAILURE
)
;
@
}
FD_ZERO
(
&
fds
)
;
FD_SET
(
fd
,
&
fds
)
;
select
(
fd
+
1
,
NULL
,
&
fds
,
NULL
,
NULL
)
;
goto
connect_again
;
@
}
fprintf
(
stderr
,
"stream_open: %s
\n
"
,
mailutils_error
(
ret
))
;
exit
(
EXIT_FAILURE
)
;
@
}
ret
=
stream_get_fd
(
stream
,
&
fd
)
;
if
(
ret
!=
0
)
@{
fprintf
(
stderr
,
"stream_get_fd: %s
\n
"
,
strerror
(
ret
))
;
exit
(
EXIT_FAILURE
)
;
@
}
write_again:
ret
=
stream_write
(
stream
,
wbuf
+
off
,
strlen
(
wbuf
),
0
,
&
nb
)
;
if
(
ret
!=
0
)
@{
if
(
ret
==
EAGAIN
)
@{
FD_ZERO
(
&
fds
)
;
FD_SET
(
fd
,
&
fds
)
;
select
(
fd
+
1
,
NULL
,
&
fds
,
NULL
,
NULL
)
;
off
+=
nb
;
goto
write_again
;
@
}
fprintf
(
stderr
,
"stream_write: %s
\n
"
,
strerror
(
ret
))
;
exit
(
EXIT_FAILURE
)
@
}
if
(
nb
!=
strlen
(
wbuf
))
@{
fprintf
(
stderr
,
"stream_write: %s
\n
"
,
"nb != wbuf length"
)
;
exit
(
EXIT_FAILURE
)
;
@
}
do
@{
read_again:
ret
=
stream_read
(
stream
,
rbuf
,
sizeof
(
rbuf
),
0
,
&
nb
)
;
if
(
ret
!=
0
)
@{
if
(
ret
==
EAGAIN
)
@{
FD_ZERO
(
&
fds
)
;
FD_SET
(
fd
,
&
fds
)
;
select
(
fd
+
1
,
&
fds
,
NULL
,
NULL
,
NULL
)
;
goto
read_again
;
@
}
fprintf
(
stderr
,
"stream_read: %s
\n
"
,
strerror
(
ret
))
;
exit
(
EXIT_FAILURE
)
;
@
}
write
(
2
,
rbuf
,
nb
)
;
@
}
while
(
nb
)
;
ret
=
stream_close
(
stream
)
;
if
(
ret
!=
0
)
@{
fprintf
(
stderr
,
"stream_close: %s
\n
"
,
strerror
(
ret
))
;
exit
(
EXIT_FAILURE
)
;
@
}
stream_destroy
(
&
stream
,
NULL
)
;
exit
(
EXIT_SUCCESS
)
;
@
}
@include
http
.
c
.
texi
@end
example
...
...
Please
register
or
sign in
to post a comment