Hi Jean, > What would be best way by using the mailutils to > get only the email address from the From: header > by using pipe and not a file?
Please find attached the source file ef.c and makefile ef.mk. To build: make -f ef.mk Usage: (something) | ef or: ef < INPUT Regards, Sergey
#include <mailutils/mailutils.h> int main (int argc, char **argv) { int rc; mu_message_t msg; mu_header_t hdr; struct mu_address hint; mu_address_t addr; char *val; char const *email; mu_stdstream_setup (MU_STDSTREAM_RESET_NONE); MU_ASSERT (mu_stdio_stream_create (&mu_strin, MU_STDIN_FD, MU_STREAM_READ|MU_STREAM_SEEK)); mu_set_program_name (argv[0]); mu_registrar_record (mu_mbox_record); MU_ASSERT (mu_stream_to_message (mu_strin, &msg)); MU_ASSERT (mu_message_get_header (msg, &hdr)); rc = mu_header_aget_value_unfold (hdr, MU_HEADER_FROM, &val); if (rc == MU_ERR_NOENT) return 1; memset (&hint, 0, sizeof hint); rc = mu_address_create_hint (&addr, val, &hint, MU_ADDR_HINT_DOMAIN); if (rc) { mu_error ("can't parse address %s: %s", val, mu_strerror (rc)); return 1; } MU_ASSERT (mu_address_sget_email (addr, 1, &email)); mu_printf ("%s\n", email); return 0; }
CPPFLAGS=`mailutils cflags` LIBS=`mailutils ldflags mbox` ef: ef.c cc $(CPPFLAGS) $(CFLAGS) -oef ef.c $(LDFLAGS) $(LIBS)
_______________________________________________ Bug-mailutils mailing list Bug-mailutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-mailutils