/* * Copyright (C) 2002 Laird Breyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Author: Laird Breyer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #if defined HAVE_LANGINFO_H #include #if !defined CODESET /* on OpenBSD, CODESET doesn't seem to be defined - we use 3, which should be US-ASCII, but it's not ideal... */ #define CODESET 3 #endif #endif #include #include #include #include #include #include #if defined HAVE_UNISTD_H #include #endif #include "dbacl.h" #include "util.h" #include "hmine.h" extern HEADER_State head; extern char *textbuf; extern charbuf_len_t textbuf_len; extern options_t u_options; extern char *progname; extern char *inputfile; extern long inputline; extern int cmd; extern long system_pagesize; int exit_code = 0; /* default */ /*********************************************************** * FUNNY FUNCTIONS * ***********************************************************/ void print_mailbox(hline_t *h, char *buf, int buflen) { char *p = NULL; char *q = NULL; parse_2822_mls_t *mls = NULL; parse_2822_mbx_t *mbx = NULL; parse_2822_als_t *als = NULL; switch(h->tag) { case hltFRM: p = "from"; mls = &h->data.frm.rfc2822; break; case hltRFR: p = "resend-from"; mls = &h->data.rfr.rfc2822; break; case hltRPT: p = "reply-to"; als = &h->data.rpt.rfc2822; break; case hltRRT: p = "resend-reply-to"; als = &h->data.rrt.rfc2822; break; case hltSND: p = "sender"; mbx = &h->data.snd.rfc2822; break; case hltRSN: p = "resend-sender"; mbx = &h->data.rsn.rfc2822; break; case hltTO: p = "to"; als = &h->data.to.rfc2822; break; case hltRTO: p = "resend-to"; als = &h->data.rto.rfc2822; break; case hltCC: p = "cc"; als = &h->data.cc.rfc2822; break; case hltRCC: p = "resend-cc"; als = &h->data.rcc.rfc2822; break; case hltBCC: p = "bcc"; als = &h->data.bcc.rfc2822; break; case hltRBC: p = "resend-bcc"; als = &h->data.rbc.rfc2822; break; default: /* nothing */ break; } if( p && !(h->state & (1<mailboxl_.begin, mls->mailboxl_.end, ','); while( q ) { bracketize_mailbox(buf, buflen); fprintf(stdout, "%s %s\n", p, buf); if( q >= mls->mailboxl_.end ) { break; } q = unfold_token(buf, buflen, q, mls->mailboxl_.end, ','); } } else if( als ) { q = unfold_token(buf, buflen, als->addressl_.begin, als->addressl_.end, ','); while( q ) { bracketize_mailbox(buf, buflen); fprintf(stdout, "%s %s\n", p, buf); if( q >= als->addressl_.end ) { break; } q = unfold_token(buf, buflen, q, als->addressl_.end, ','); } } else if( mbx ) { q = unfold_token(buf, buflen, mbx->mailbox_.begin, mbx->mailbox_.end, ','); bracketize_mailbox(buf, buflen); fprintf(stdout, "%s %s\n", p, buf); } } } void print_summary() { int i; char buf[1024]; /* time_t numsec = (time_t)-1; */ /* for(i = 0; i < head.hstack.top; i++) { */ /* if( head.hstack.hlines[i].tag == hltRCV ) { */ /* if( head.hstack.hlines[i].state & (1< -1 ) { hset_option(op, optarg); } /* set up callbacks */ if( preprocess_fun ) { (*preprocess_fun)(); } init_header_handling(); /* now process only the first file on the command line, or if none provided read stdin */ if( (optind > -1) && *(argv + optind) ) { /* if it's a filename, process it */ input = fopen(argv[optind], "rb"); if( input ) { inputfile = argv[optind]; u_options |= (1<