21 |
* to[p] [msglist] |
* to[p] [msglist] |
22 |
*/ |
*/ |
23 |
|
|
24 |
int |
static int |
25 |
mail_top (int argc, char **argv) |
top0 (msgset_t *mspec, message_t msg, void *data) |
26 |
{ |
{ |
27 |
if (argc > 1) |
stream_t stream; |
28 |
return util_msglist_command (mail_top, argc, argv, 1); |
char buf[512]; |
29 |
else |
size_t n; |
30 |
{ |
off_t off; |
31 |
message_t msg; |
int lines; |
|
stream_t stream; |
|
|
char buf[512]; |
|
|
size_t n; |
|
|
off_t off; |
|
|
int lines; |
|
32 |
|
|
33 |
if (util_getenv (&lines, "toplines", Mail_env_number, 1) |
if (util_getenv (&lines, "toplines", Mail_env_number, 1) |
34 |
|| lines < 0) |
|| lines < 0) |
35 |
return 1; |
return 1; |
36 |
|
|
37 |
if (util_get_message (mbox, cursor, &msg, MSG_NODELETED)) |
message_get_stream (msg, &stream); |
38 |
return 1; |
for (n = 0, off = 0; lines > 0; lines--, off += n) |
39 |
|
{ |
40 |
message_get_stream (msg, &stream); |
int status = stream_readline (stream, buf, sizeof (buf), off, &n); |
41 |
for (n = 0, off = 0; lines > 0; lines--, off += n) |
if (status != 0 || n == 0) |
42 |
{ |
break; |
43 |
int status = stream_readline (stream, buf, sizeof (buf), off, &n); |
fprintf (ofile, "%s", buf); |
|
if (status != 0 || n == 0) |
|
|
break; |
|
|
fprintf (ofile, "%s", buf); |
|
|
} |
|
|
return 0; |
|
44 |
} |
} |
45 |
return 1; |
cursor = mspec->msg_part[0]; |
46 |
|
return 0; |
47 |
} |
} |
48 |
|
|
49 |
|
int |
50 |
|
mail_top (int argc, char **argv) |
51 |
|
{ |
52 |
|
return util_foreach_msg (argc, argv, MSG_NODELETED, top0, NULL); |
53 |
|
} |
54 |
|
|