• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..05-Aug-2021-

DecodeH A D05-Jan-2021349 65

Makefile.amH A D27-Jul-20214 KiB218178

Makefile.inH A D05-Aug-202169.5 KiB1,9201,733

WicketfileH A D05-Jan-2021189 87

addr.cH A D16-Jul-20212.9 KiB11883

address.atH A D05-Jan-202123.2 KiB1,062926

atlocal.inH A D05-Jan-2021276 64

base64d.atH A D05-Jan-20211.2 KiB3931

base64e.atH A D05-Jan-20211.2 KiB3931

cidr.cH A D16-Jul-20212.4 KiB9667

content-type.atH A D05-Jan-20211.6 KiB6355

conttype.cH A D16-Jul-20211.2 KiB6455

crlf.atH A D05-Jan-20212.3 KiB9891

crlfdot.atH A D05-Jan-20212.5 KiB110100

ctm.atH A D05-Jan-20212.4 KiB9688

ctm.cH A D16-Jul-20212.2 KiB10781

debugspec.atH A D05-Jan-20212.2 KiB8669

debugspec.cH A D16-Jul-20212 KiB6942

decode2047.atH A D05-Jan-20212.1 KiB6252

decode2047.cH A D16-Jul-20212 KiB7553

dot.atH A D05-Jan-20211.6 KiB8679

dump.cH A D16-Jul-20211.5 KiB8064

encode2047.atH A D05-Jan-20212.7 KiB7059

encode2047.cH A D16-Jul-20213.4 KiB150117

exp.atH A D05-Jan-20211.7 KiB5243

exp.cH A D16-Jul-20211.4 KiB6843

fltcnt.atH A D15-Jul-2021233 66

fltcnt.cH A D16-Jul-20215.9 KiB228130

fltst.cH A D27-Jul-20215.6 KiB220177

fromflt.atH A D05-Jan-20212.1 KiB9675

fromrd.atH A D16-Jul-2021556 5754

fsaf.atH A D05-Jan-20211.9 KiB9278

fsaf.cH A D16-Jul-20211.8 KiB7352

fsaftomod.atH A D05-Jan-20211.3 KiB4338

fsaftomod.cH A D16-Jul-20211.7 KiB6140

fsfolder.cH A D16-Jul-20219.2 KiB376320

fsfolder00.atH A D22-May-20211.3 KiB5449

fsfolder01.atH A D05-Jan-20212 KiB7568

fsfolder02.atH A D22-May-20211.1 KiB4035

fsfolder03.atH A D22-May-20211.1 KiB4542

fsfolder04.atH A D22-May-20211.1 KiB4338

globtest.atH A D05-Jan-20211.6 KiB4642

globtest.cH A D16-Jul-20212.9 KiB11787

hdrcpy.atH A D27-Jul-20211.2 KiB4037

hdrcpy.cH A D16-Jul-20211,007 2810

hdrflt.atH A D05-Jan-20211.2 KiB4235

htmlent.atH A D05-Jan-20211.5 KiB7467

imapio.atH A D05-Jan-20212.4 KiB130116

imapio.cH A D16-Jul-20212.5 KiB9262

inline-comment.atH A D05-Jan-20214.1 KiB237206

lck.cH A D16-Jul-20219.2 KiB372223

linecon.atH A D05-Jan-20212 KiB9077

linetrack.atH A D05-Jan-20214 KiB295278

linetrack.cH A D16-Jul-20214.3 KiB198171

list.atH A D05-Jan-20216.8 KiB543476

listop.cH A D16-Jul-202118.5 KiB916785

listsort.cH A D16-Jul-20216.1 KiB250166

lock.atH A D30-Apr-20213.1 KiB140113

logstr.atH A D05-Jan-20212.2 KiB8382

logstr.cH A D16-Jul-202119.3 KiB774519

mailcap.atH A D05-Jan-202113.6 KiB540450

mailcap.cH A D16-Jul-20215 KiB200152

mcf.cH A D16-Jul-20213.8 KiB154119

mimehdr.atH A D05-Jan-20218.8 KiB304267

mimehdr.cH A D16-Jul-20214 KiB144112

mimeitr.cH A D16-Jul-20211.6 KiB5332

modmesg.atH A D05-Jan-20211.5 KiB7260

modmesg.cH A D16-Jul-20213.4 KiB13093

modtofsaf.atH A D05-Jan-20211.3 KiB5748

modtofsaf.cH A D16-Jul-20211.5 KiB5736

msgset.atH A D05-Jan-20214.3 KiB187156

msgset.cH A D16-Jul-20215.5 KiB229184

parseopt.cH A D16-Jul-20216.6 KiB241198

parseopt00.atH A D05-Jan-20211 KiB3836

parseopt01.atH A D05-Jan-20211.1 KiB4139

parseopt02.atH A D05-Jan-20211.1 KiB4139

parseopt03.atH A D05-Jan-20211.1 KiB4139

parseopt04.atH A D05-Jan-20211.1 KiB4139

parseopt05.atH A D05-Jan-20211.1 KiB4139

parseopt06.atH A D05-Jan-20211.1 KiB4139

parseopt07.atH A D05-Jan-20211.1 KiB4139

parseopt08.atH A D05-Jan-20211.1 KiB4139

parseopt09.atH A D05-Jan-20211.1 KiB4139

parseopt10.atH A D05-Jan-20211.1 KiB4139

parseopt11.atH A D05-Jan-20211.1 KiB4139

parseopt12.atH A D05-Jan-20211.1 KiB4139

parseopt13.atH A D05-Jan-20211.1 KiB4139

parseopt14.atH A D05-Jan-20211 KiB3028

parseopt15.atH A D05-Jan-20211.1 KiB4139

parseopt16.atH A D05-Jan-20211.1 KiB3836

parseopt17.atH A D05-Jan-20211.4 KiB6562

parseopt18.atH A D05-Jan-20211.1 KiB4239

parseopt19.atH A D05-Jan-20211.1 KiB4340

parseopt20.atH A D05-Jan-2021969 2826

parseopt21.atH A D05-Jan-2021974 2826

parseopt22.atH A D05-Jan-2021949 2826

parseopt23.atH A D05-Jan-20211.1 KiB4340

parseopt24.atH A D05-Jan-2021959 2826

parseopt25.atH A D05-Jan-2021944 2725

parseopt26.atH A D05-Jan-20211 KiB3129

parseopt27.atH A D05-Jan-20211.1 KiB4038

parseopt28.atH A D05-Jan-20211.3 KiB5755

parseopt_help00.atH A D05-Jan-20211.6 KiB5242

parseopt_help01.atH A D05-Jan-20211.1 KiB3028

parseopt_help02.atH A D05-Jan-20211.6 KiB5242

parseopt_help03.atH A D05-Jan-20211.7 KiB5343

parseopt_help04.atH A D05-Jan-20211.7 KiB5242

parseopt_help05.atH A D05-Jan-20211.7 KiB5343

parseopt_help06.atH A D05-Jan-20211.8 KiB5343

parseopt_help07.atH A D05-Jan-20212.1 KiB6252

parseopt_help08.atH A D05-Jan-20211.7 KiB5041

parseopt_help09.atH A D05-Jan-20211.2 KiB3129

parseopt_help10.atH A D05-Jan-20211.2 KiB3028

parseopt_help11.atH A D05-Jan-20211.7 KiB5143

parseopt_help12.atH A D05-Jan-20211.8 KiB5444

prop.atH A D05-Jan-20212.6 KiB127113

prop.cH A D16-Jul-20213.8 KiB159130

readmesg.atH A D05-Jan-20212 KiB7263

readmesg.cH A D16-Jul-20213 KiB11279

recenv.atH A D05-Jan-20211.5 KiB5750

recenv.cH A D16-Jul-20211.6 KiB5332

scantime.atH A D05-Jan-20219.1 KiB242222

scantime.cH A D16-Jul-20212.7 KiB10276

stream-getdelim.cH A D16-Jul-20214.9 KiB219162

streams.atH A D05-Jan-20211.3 KiB4438

strerr.atH A D05-Jan-20211.1 KiB3427

strftime.atH A D05-Jan-202118.1 KiB1,9221,865

strftime.cH A D16-Jul-20212.5 KiB10680

strin.atH A D05-Jan-2021963 3326

strin.cH A D16-Jul-20212.4 KiB10160

strout.atH A D05-Jan-20211.1 KiB3326

strout.cH A D16-Jul-20213.1 KiB13679

strtoc.cH A D16-Jul-20218.8 KiB382322

t-streamshift.cH A D16-Jul-20217.2 KiB282201

t0-stream.cH A D16-Jul-20212.3 KiB7539

t1-stream.cH A D16-Jul-20212.6 KiB12493

tcli.cH A D16-Jul-20212 KiB7952

temp_stream.cH A D16-Jul-20213.2 KiB12459

tempfile.cH A D16-Jul-20214.3 KiB159122

tesh.cH A D16-Jul-20218.2 KiB402339

tesh.hH A D16-Jul-20216.7 KiB17722

testsuiteH A D05-Aug-2021930.1 KiB37,35232,281

testsuite.atH A D27-Jul-20216.8 KiB269229

tocrlf.cH A D16-Jul-2021200 1813

url-comp.atH A D05-Jan-20212.5 KiB7267

url-comp.cH A D16-Jul-20213.4 KiB148119

url-parse.cH A D16-Jul-20214.6 KiB177142

url.atH A D05-Jan-202112.2 KiB890806

vexp.cH A D16-Jul-20211.3 KiB5331

wicket.atH A D05-Jan-20212 KiB5449

wicket.cH A D16-Jul-20212.5 KiB10774

wordsplit-version.hH A D05-Aug-202170 32

wordwrap.cH A D16-Jul-20213.7 KiB163134

wordwrap00.atH A D05-Jan-20213.2 KiB4544

wordwrap01.atH A D05-Jan-20211.9 KiB3736

wordwrap02.atH A D05-Jan-20211.6 KiB3332

wordwrap03.atH A D05-Jan-2021961 2525

xml.atH A D05-Jan-20211.1 KiB4236

xscript.atH A D05-Jan-20213.2 KiB123119

xscript.cH A D16-Jul-20215.7 KiB244167

readmesg.at

1# This file is part of GNU Mailutils. -*- Autotest -*-
2# Copyright (C) 2020-2021 Free Software Foundation, Inc.
3#
4# GNU Mailutils is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License as
6# published by the Free Software Foundation; either version 3, or (at
7# your option) any later version.
8#
9# GNU Mailutils is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12# General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP([Reading message from stream])
18AT_KEYWORDS([readmesg])
19
20AT_DATA([input.mbox],
21[[From gray@example.net Sat Aug  1 10:53:43 2020
22Return-Path: <gray@example.net>
23Organization: Mailutils-tests
24Received: from example.net (localhost [127.0.0.1])
25	by example.net with ESMTP id g6G9BZb00791
26	for <gray@example.net>; Sat,  1 Aug 2020 13:53:43 +0300
27Message-Id: <200207160911.g6G9BZb00791@example.net>
28To: Bin <bin@example.org>
29Subject: Read from stream
30Date: Sat,  1 Aug 2020 13:53:43 +0300
31From: Sergey Poznyakoff <gray@example.net>
32
33This is a sample message.
34]])
35
36AT_DATA([input.mesg],
37[[Return-Path: <gray@example.net>
38Organization: Mailutils-tests
39Received: from example.net (localhost [127.0.0.1])
40	by example.net with ESMTP id g6G9BZb00791
41	for <gray@example.net>; Sat,  1 Aug 2020 13:53:43 +0300
42Message-Id: <200207160911.g6G9BZb00791@example.net>
43To: Bin <bin@example.org>
44Subject: Read from stream
45Date: Sat,  1 Aug 2020 13:53:43 +0300
46From: Sergey Poznyakoff <gray@example.net>
47
48This is a sample message.
49]])
50
51AT_DATA([expout],
52[Sender: gray@example.net
53Date: Sat Aug  1 10:53:43 2020
54Size: 425
55Lines: 12
56Headers: 8
57Header size: 399
58Header lines: 11
59Body size: 26
60Body lines: 1
61This is a sample message.
62])
63
64AT_CHECK([readmesg input.mbox],
65[0],
66[expout])
67
68AT_CHECK([readmesg input.mesg],
69[0],
70[expout])
71
72AT_CLEANUP

readmesg.c

1 /* GNU Mailutils -- a suite of utilities for electronic mail
2    Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 
4    GNU Mailutils is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3, or (at your option)
7    any later version.
8 
9    GNU Mailutils is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
16 
17 #ifdef HAVE_CONFIG_H
18 # include <config.h>
19 #endif
20 #include <mailutils/mailutils.h>
21 
22 static void
print_envelope(mu_message_t msg)23 print_envelope (mu_message_t msg)
24 {
25   mu_envelope_t env;
26   char const *sender, *date;
27 
28   MU_ASSERT (mu_message_get_envelope (msg, &env));
29   MU_ASSERT (mu_envelope_sget_sender (env, &sender));
30   mu_printf ("Sender: %s\n", sender);
31   MU_ASSERT (mu_envelope_sget_date (env, &date));
32   mu_printf ("Date: %s\n", date);
33 }
34 
35 static void
print_stats(mu_message_t msg)36 print_stats (mu_message_t msg)
37 {
38   size_t n;
39 
40   MU_ASSERT (mu_message_size (msg, &n));
41   mu_printf ("Size: %lu\n", (unsigned long) n);
42   MU_ASSERT (mu_message_lines (msg, &n));
43   mu_printf ("Lines: %lu\n", (unsigned long) n);
44 }
45 
46 static void
print_header(mu_message_t msg)47 print_header (mu_message_t msg)
48 {
49   mu_header_t hdr;
50   size_t n;
51 
52   MU_ASSERT (mu_message_get_header (msg, &hdr));
53   MU_ASSERT (mu_header_get_field_count (hdr, &n));
54   mu_printf ("Headers: %lu\n", (unsigned long) n);
55   MU_ASSERT (mu_header_size (hdr, &n));
56   mu_printf ("Header size: %lu\n", (unsigned long) n);
57   MU_ASSERT (mu_header_lines (hdr, &n));
58   mu_printf ("Header lines: %lu\n", (unsigned long) n);
59 }
60 
61 static void
print_body(mu_message_t msg)62 print_body (mu_message_t msg)
63 {
64   mu_body_t body;
65   mu_stream_t str;
66   size_t n;
67 
68   MU_ASSERT (mu_message_get_body (msg, &body));
69 
70   MU_ASSERT (mu_body_size (body, &n));
71   mu_printf ("Body size: %lu\n", (unsigned long) n);
72   MU_ASSERT (mu_body_lines (body, &n));
73   mu_printf ("Body lines: %lu\n", (unsigned long) n);
74 
75   MU_ASSERT (mu_body_get_streamref (body, &str));
76   MU_ASSERT (mu_stream_copy (mu_strout, str, 0, NULL));
77   mu_stream_destroy (&str);
78 }
79 
80 int
main(int argc,char ** argv)81 main (int argc, char **argv)
82 {
83   mu_stream_t instr;
84   mu_message_t msg;
85 
86   mu_set_program_name (argv[0]);
87   mu_cli_simple (argc, argv,
88 		 MU_CLI_OPTION_PROG_DOC, "Reads first message from FILE and "
89 		 "prints its summary (envelope, stats, header and body).",
90 		 MU_CLI_OPTION_PROG_ARGS, "FILE",
91 		 MU_CLI_OPTION_RETURN_ARGC, &argc,
92 		 MU_CLI_OPTION_RETURN_ARGV, &argv,
93 		 MU_CLI_OPTION_END);
94 
95   if (argc != 1)
96     {
97       mu_error ("required argument missing");
98       return 2;
99     }
100 
101   mu_set_user_email_domain ("localhost");
102   MU_ASSERT (mu_file_stream_create (&instr, argv[0], MU_STREAM_READ));
103   MU_ASSERT (mu_stream_to_message (instr, &msg));
104 
105   print_envelope (msg);
106   print_stats (msg);
107   print_header (msg);
108   print_body (msg);
109 
110   return 0;
111 }
112