64
64
int exit_code = 0; /* default */
66
67
/***********************************************************
67
68
* FUNNY FUNCTIONS *
68
69
***********************************************************/
70
void print_mailbox(hline_t *h, char *buf, int buflen) {
73
parse_2822_mls_t *mls = NULL;
74
parse_2822_mbx_t *mbx = NULL;
75
parse_2822_als_t *als = NULL;
79
mls = &h->data.frm.rfc2822;
83
mls = &h->data.rfr.rfc2822;
87
als = &h->data.rpt.rfc2822;
90
p = "resend-reply-to";
91
als = &h->data.rrt.rfc2822;
95
mbx = &h->data.snd.rfc2822;
99
mbx = &h->data.rsn.rfc2822;
103
als = &h->data.to.rfc2822;
107
als = &h->data.rto.rfc2822;
111
als = &h->data.cc.rfc2822;
115
als = &h->data.rcc.rfc2822;
119
als = &h->data.bcc.rfc2822;
123
als = &h->data.rbc.rfc2822;
129
if( p && !(h->state & (1<<H_STATE_BAD_DATA)) ) {
131
q = unfold_token(buf, buflen, mls->mailboxl_.begin, mls->mailboxl_.end, ',');
133
bracketize_mailbox(buf, buflen);
134
fprintf(stdout, "%s %s\n", p, buf);
135
if( q >= mls->mailboxl_.end ) { break; }
136
q = unfold_token(buf, buflen, q, mls->mailboxl_.end, ',');
139
q = unfold_token(buf, buflen, als->addressl_.begin, als->addressl_.end, ',');
141
bracketize_mailbox(buf, buflen);
142
fprintf(stdout, "%s %s\n", p, buf);
143
if( q >= als->addressl_.end ) { break; }
144
q = unfold_token(buf, buflen, q, als->addressl_.end, ',');
147
q = unfold_token(buf, buflen, mbx->mailbox_.begin, mbx->mailbox_.end, ',');
148
bracketize_mailbox(buf, buflen);
149
fprintf(stdout, "%s %s\n", p, buf);
69
154
void print_summary() {
71
157
/* time_t numsec = (time_t)-1; */
72
158
/* for(i = 0; i < head.hstack.top; i++) { */
73
159
/* if( head.hstack.hlines[i].tag == hltRCV ) { */
85
171
/* printf("\n"); */
87
printf("I have nothing to say.\n");
173
if( u_options & (1<<U_OPTION_HM_ADDRESSES) ) {
174
/* we print out any mailboxes we find, preceded by type */
175
for(i = 0; i < head.hstack.top; i++) {
176
print_mailbox(head.hstack.hlines + i, buf, 1024);
91
181
/***********************************************************
253
346
/* in case no files were specified, get input from stdin */
254
if( !(u_options & (1<<U_OPTION_STDIN)) ) {
347
if( !(u_options & (1<<U_OPTION_STDIN)) &&
348
(input = fdopen(fileno(stdin), "rb")) ) {
256
350
if( (u_options & (1<<U_OPTION_VERBOSE)) &&
257
351
!(u_options & (1<<U_OPTION_CLASSIFY)) ) {
258
352
fprintf(stdout, "taking input from stdin\n");
261
hprocess_file(stdin, &head);
355
hprocess_file(input, &head);
263
357
/* must close before freeing in_iobuf, in case setvbuf was called */