/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* mail-mlist-magic.c * * Copyright (C) 2000 Helix Code, Inc. * * 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Ettore Perazzoli */ /* Procmail-style magic mail rules for mailing lists: (from Joakim's own `.procmailrc'.) :0: * ^Sender: owner-\/[^@]+ lists/$MATCH :0: * ^X-BeenThere: \/[^@]+ lists/$MATCH :0: * ^Delivered-To: mailing list \/[^@]+ lists/$MATCH :0: * X-Mailing-List: <\/[^@]+ lists/$MATCH :0: * X-Loop: \/[^@]+ lists/$MATCH */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "camel.h" #include "mail-mlist-magic.h" /* Utility functions. */ static char * extract_until_at_sign (const char *s) { const char *at_sign; at_sign = strchr (s, '@'); if (at_sign == NULL) return g_strdup (s); if (at_sign == s) return NULL; return g_strndup (s, at_sign - s); } static const char * get_header (CamelMimeMessage *message, const char *header_name) { const char *value; value = camel_medium_get_header (CAMEL_MEDIUM (message), header_name); if (value == NULL) return NULL; /* FIXME: Correct? */ while (isspace ((int) *value)) value++; return value; } /* The checks. */ /* ^Sender: owner-\/[^@]+ */ static char * check_sender (CamelMimeMessage *message, const char **header_name_return, char **header_value_return) { const char *value; value = get_header (message, "Sender"); if (value == NULL) return NULL; if (strncmp (value, "owner-", 6) != 0) return NULL; if (value[6] == '\0' || value[6] == '@') return NULL; if (header_name_return != NULL) *header_name_return = "Sender"; if (header_value_return != NULL) *header_value_return = g_strdup (value); return extract_until_at_sign (value + 6); } /* ^X-BeenThere: \/[^@]+ */ static char * check_x_been_there (CamelMimeMessage *message, const char **header_name_return, char **header_value_return) { const char *value; value = get_header (message, "X-BeenThere"); if (value == NULL || *value == '@') return NULL; if (header_name_return != NULL) *header_name_return = "X-BeenThere"; if (header_value_return != NULL) *header_value_return = g_strdup (value); return extract_until_at_sign (value); } /* ^Delivered-To: mailing list \/[^@]+ */ static char * check_delivered_to (CamelMimeMessage *message, const char **header_name_return, char **header_value_return) { const char *value; value = get_header (message, "Delivered-To"); if (value == NULL) return NULL; /* FIXME uh? */ if (strncmp (value, "mailing list ", 13) != 0) return NULL; if (value[13] == '\0' || value[13] == '@') return NULL; if (header_name_return != NULL) *header_name_return = "Delivered-To"; if (header_value_return != NULL) *header_value_return = g_strdup (value); return extract_until_at_sign (value + 13); } /* X-Mailing-List: <\/[^@]+ */ static char * check_x_mailing_list (CamelMimeMessage *message, const char **header_name_return, char **header_value_return) { const char *value; int value_length; value = get_header (message, "X-Mailing-List"); if (value == NULL) return NULL; if (value[0] != '<' || value[1] == '\0' || value[1] == '@') return NULL; value_length = strlen (value); if (value[value_length - 1] != '>') return NULL; if (header_name_return != NULL) *header_name_return = "X-Mailing-List"; if (header_value_return != NULL) *header_value_return = g_strdup (value); return extract_until_at_sign (value + 1); } /* X-Loop: \/[^@]+ */ static char * check_x_loop (CamelMimeMessage *message, const char **header_name_return, char **header_value_return) { const char *value; value = get_header (message, "X-Loop"); if (value == NULL) return NULL; if (*value == '\0' || *value == '@') return NULL; if (header_name_return != NULL) *header_name_return = "X-Loop"; if (header_value_return != NULL) *header_value_return = g_strdup (value); return extract_until_at_sign (value); } /** * mail_mlist_magic_detect_list: * @message: * @header_name_return: * @header_value_return: * * Detect if message was delivered by a mailing list. * * Return value: The name of the mailing list, if the message appears to be * sent from a mailing list. NULL otherwise. **/ char * mail_mlist_magic_detect_list (CamelMimeMessage *message, const char **header_name_return, char **header_value_return) { char *list_name; g_return_val_if_fail (message != NULL, NULL); g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); list_name = check_sender (message, header_name_return, header_value_return); if (list_name != NULL) return list_name; list_name = check_x_been_there (message, header_name_return, header_value_return); if (list_name != NULL) return list_name; list_name = check_delivered_to (message, header_name_return, header_value_return); if (list_name != NULL) return list_name; list_name = check_x_mailing_list (message, header_name_return, header_value_return); if (list_name != NULL) return list_name; list_name = check_x_loop (message, header_name_return, header_value_return); if (list_name != NULL) return list_name; return NULL; } d-ports-gnome/stats/lang/perl5.8?h=gstreamer0.10-removal'>stats
Commit message (Expand)AuthorAgeFilesLines
* - Add option to build with -pthread, default to on. Note this is not the sameswills2012-02-151-2/+4
* - Unbreak on FreeBSD 10miwi2011-11-061-0/+30
* Remove more tags from pkg-descr files fo the form:dougb2011-10-241-2/+0
* - Track dependencies after databases/gdbm updategabor2011-09-121-2/+2
* - Fix perl configure erroneously saving /usr/local/script as a site script in...amdmi32011-08-082-1/+13
* - remove MD5ohauer2011-07-031-3/+0
* Introduce Perl 5.14.0skv2011-05-181-1/+2
* - Support = in hostnames compatiable with misc/149510.pgollucci2010-12-121-1/+1
* Do not touch /etc/manpath.config on -CURRENT after man.d/perl.conf is usedgarga2010-12-061-6/+14
* Add LICENSE_COMB (it was not checked by portlint).skv2010-11-051-0/+1
* Specify LICENSE.skv2010-11-051-0/+2
* Add patch to install a configuration file for the new man utilitygordon2010-11-054-8/+26
* Introduce Perl 5.12.1skv2010-07-151-1/+2
* Change default Perl version to 5.10.skv2010-02-061-1/+1
* Fix script "use.perl": correctly check variables 'need_*'.skv2009-11-061-7/+7
* - Fix behaviour of USE_PERL option when it is "off"skv2009-11-032-5/+12
* - Really is MAKE_JOBS_UNSAFEpav2009-08-071-1/+1
* - Add more essential bugfixesskv2009-06-082-2/+38
* Add MAKE_JOBS_SAFE variable.skv2009-03-231-0/+1
* Update "perl-after-upgrade": set correct perl package name in @pkgdep.skv2009-03-132-46/+5
* Fix PORTVERSION.skv2009-03-061-1/+1
* Remove variable PERL_VER from the ports tree at all - becauseskv2009-03-062-117/+19
* Update BSDPAN:skv2009-03-042-5/+7
* Fix install of BSDPAN (BSDPAN_WRKSRC) and unbreak.itetcu2009-02-161-1/+1
* * Fix suidperl functionality. [1]skv2009-02-163-4/+15
* Add "regression-test" make target.skv2009-01-271-3/+5
* Unbreak build of threaded perl.skv2009-01-141-1/+1
* Update to 5.8.9skv2009-01-149-308/+280
* - Remove conditional checks for FreeBSD 5.x and olderpav2009-01-062-35/+0