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
9022da8a
...
9022da8a9477fa9d596dac74f2e6d5f2ff17f7f6
authored
2001-04-07 02:52:30 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Test program.
1 parent
99f8c68a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
examples/addr.c
examples/addr.c
0 → 100644
View file @
9022da8
#include <stdio.h>
#include <mailutils/address.h>
static
int
use_zero
=
1
;
static
int
parse
(
const
char
*
str
)
{
size_t
no
=
0
;
size_t
pcount
;
char
buf
[
BUFSIZ
];
address_t
address
=
NULL
;
if
(
use_zero
)
address_create0
(
&
address
,
str
);
else
address_create
(
&
address
,
str
);
address_get_count
(
address
,
&
pcount
);
printf
(
"%s=> pcount %d
\n
"
,
str
,
pcount
);
for
(
no
=
1
;
no
<=
pcount
;
no
++
)
{
size_t
got
=
0
;
printf
(
"%d "
,
no
);
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
)
printf
(
" personal <%s>
\n
"
,
buf
);
address_get_comments
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
printf
(
" comments <%s>
\n
"
,
buf
);
address_get_local_part
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
printf
(
" local-part <%s>"
,
buf
);
address_get_domain
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
printf
(
" domain <%s>
\n
"
,
buf
);
address_get_route
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
printf
(
" route <%s>
\n
"
,
buf
);
}
address_destroy
(
&
address
);
printf
(
"
\n
"
);
return
0
;
}
static
int
parseinput
(
void
)
{
char
buf
[
BUFSIZ
];
while
(
fgets
(
buf
,
sizeof
(
buf
),
stdin
)
!=
0
)
{
buf
[
strlen
(
buf
)
-
1
]
=
0
;
parse
(
buf
);
}
return
0
;
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
argc
=
1
;
if
(
argv
[
argc
]
&&
strcmp
(
argv
[
argc
],
"-1"
)
==
0
)
{
use_zero
=
0
;
argc
++
;
}
if
(
argv
[
argc
]
&&
strcmp
(
argv
[
argc
],
"-0"
)
==
0
)
{
use_zero
=
1
;
argc
++
;
}
if
(
!
argv
[
argc
])
{
return
parseinput
();
}
for
(;
argv
[
argc
];
argc
++
)
{
if
(
strcmp
(
argv
[
argc
],
"-"
)
==
0
)
{
parseinput
();
}
else
{
parse
(
argv
[
argc
]);
}
}
return
0
;
}
Please
register
or
sign in
to post a comment