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
c26dfb8b
...
c26dfb8bbb29ad49e05395a7d47d2499ee01b28d
authored
2004-01-19 20:57:57 +0000
by
Wojciech Polak
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Updated
1 parent
e0dd325d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
38 deletions
examples/addr.c
examples/http.c
examples/mailcap.c
examples/addr.c
View file @
c26dfb8
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001
, 2004
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -16,8 +16,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <errno.h>
#include <mailutils/address.h>
#include <mailutils/errno.h>
...
...
@@ -35,19 +35,17 @@ parse (const char *str)
address_t
address
=
NULL
;
mu_set_user_email_domain
(
"localhost"
);
status
=
address_create
(
&
address
,
str
);
address_get_count
(
address
,
&
pcount
);
if
(
status
)
{
printf
(
"%s=> error %s
\n\n
"
,
str
,
mu_errname
(
status
));
mu_error
(
"%s => error: %s"
,
str
,
mu_strerror
(
status
));
return
0
;
}
else
{
printf
(
"%s=> pcount %lu
\n
"
,
str
,
(
unsigned
long
)
pcount
);
printf
(
"%s
=> pcount %lu
\n
"
,
str
,
(
unsigned
long
)
pcount
);
}
for
(
no
=
1
;
no
<=
pcount
;
no
++
)
...
...
@@ -56,29 +54,24 @@ parse (const char *str)
int
isgroup
;
address_is_group
(
address
,
no
,
&
isgroup
);
printf
(
"%lu "
,
(
unsigned
long
)
no
);
if
(
isgroup
)
{
address_get_personal
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
printf
(
"group <%s>
\n
"
,
buf
);
}
else
{
address_get_email
(
address
,
no
,
buf
,
sizeof
(
buf
),
0
);
printf
(
"email <%s>
\n
"
,
buf
);
}
address_get_personal
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
&&
!
isgroup
)
printf
(
" personal <%s>
\n
"
,
buf
);
address_get_comments
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
printf
(
" comments <%s>
\n
"
,
buf
);
...
...
@@ -89,7 +82,6 @@ parse (const char *str)
printf
(
" local-part <%s>"
,
buf
);
address_get_domain
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
printf
(
" domain <%s>"
,
buf
);
...
...
@@ -97,14 +89,12 @@ parse (const char *str)
}
address_get_route
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
printf
(
" route <%s>
\n
"
,
buf
);
}
address_destroy
(
&
address
);
printf
(
"
\n
"
);
return
0
;
}
...
...
@@ -128,19 +118,14 @@ main (int argc, const char *argv[])
argc
=
1
;
if
(
!
argv
[
argc
])
{
return
parseinput
();
}
return
parseinput
();
for
(;
argv
[
argc
];
argc
++
)
{
if
(
strcmp
(
argv
[
argc
],
"-"
)
==
0
)
{
parseinput
();
}
parseinput
();
else
{
parse
(
argv
[
argc
]);
}
parse
(
argv
[
argc
]);
}
return
0
;
...
...
examples/http.c
View file @
c26dfb8
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001
, 2004
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -19,10 +19,10 @@
It connects to a remote HTTP server and prints the contents of its
index page */
#include <stdlib.h>
#include <stdio.h>
#include <
errno
.h>
#include <
stdlib
.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <mailutils/mailutils.h>
...
...
@@ -31,7 +31,7 @@ const char *wbuf = "GET / HTTP/1.0\r\n\r\n";
char
rbuf
[
1024
];
int
main
()
main
(
void
)
{
int
ret
,
off
=
0
,
fd
;
stream_t
stream
;
...
...
@@ -41,7 +41,7 @@ main ()
ret
=
tcp_stream_create
(
&
stream
,
"www.gnu.org"
,
80
,
MU_STREAM_NONBLOCK
);
if
(
ret
!=
0
)
{
mu_error
(
"tcp_stream_create: %s
\n
"
,
mu_strerror
(
ret
));
mu_error
(
"tcp_stream_create: %s
"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
...
...
@@ -54,7 +54,7 @@ connect_again:
ret
=
stream_get_fd
(
stream
,
&
fd
);
if
(
ret
!=
0
)
{
mu_error
(
"stream_get_fd: %s
\n
"
,
mu_strerror
(
ret
));
mu_error
(
"stream_get_fd: %s
"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
FD_ZERO
(
&
fds
);
...
...
@@ -62,14 +62,14 @@ connect_again:
select
(
fd
+
1
,
NULL
,
&
fds
,
NULL
,
NULL
);
goto
connect_again
;
}
mu_error
(
"stream_open: %s
\n
"
,
mu_strerror
(
ret
));
mu_error
(
"stream_open: %s
"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
ret
=
stream_get_fd
(
stream
,
&
fd
);
if
(
ret
!=
0
)
{
mu_error
(
"stream_get_fd: %s
\n
"
,
mu_strerror
(
ret
));
mu_error
(
"stream_get_fd: %s
"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
...
...
@@ -85,13 +85,13 @@ write_again:
off
+=
nb
;
goto
write_again
;
}
mu_error
(
"stream_write: %s
\n
"
,
mu_strerror
(
ret
));
mu_error
(
"stream_write: %s
"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
if
(
nb
!=
strlen
(
wbuf
))
{
mu_error
(
"stream_write: %s
\n
"
,
"nb != wbuf length"
);
mu_error
(
"stream_write: %s
"
,
"nb != wbuf length"
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -108,7 +108,7 @@ write_again:
}
else
{
mu_error
(
"stream_read: %s
\n
"
,
mu_strerror
(
ret
));
mu_error
(
"stream_read: %s
"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
}
...
...
@@ -119,7 +119,7 @@ write_again:
ret
=
stream_close
(
stream
);
if
(
ret
!=
0
)
{
mu_error
(
"stream_close: %s
\n
"
,
mu_strerror
(
ret
));
mu_error
(
"stream_close: %s
"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
...
...
examples/mailcap.c
View file @
c26dfb8
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001
, 2004
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -21,13 +21,13 @@
#include <mailutils/error.h>
int
main
(
int
argc
,
char
**
argv
)
main
(
int
argc
,
char
**
argv
)
{
stream_t
stream
=
NULL
;
int
status
=
0
;
char
*
file
=
argc
==
1
?
"/etc/mailcap"
:
argv
[
1
];
mu_mailcap_t
mailcap
=
NULL
;
status
=
file_stream_create
(
&
stream
,
file
,
MU_STREAM_READ
);
if
(
status
)
{
...
...
Please
register
or
sign in
to post a comment