Gnus development mailing list
 help / color / mirror / Atom feed
* External delivery: methods.
@ 1995-11-15  8:18 Sudish Joseph
  1995-11-15  8:52 ` Sudish Joseph
  1995-11-15 17:12 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Sudish Joseph @ 1995-11-15  8:18 UTC (permalink / raw)


Joe Hildebrand's add-active-nov script was(is?) the most common way of
implementing external delivery from procmail.  Essentially, it's a
perl script to be run out of your filter, after the filter has
delivered the article.  Needs one argument, the full path name of the
delivered article.  The problem with this is load on your mail hub,
since you're running a perl script in addition to one procmail
invocation for every message you receive.  It's also a tad slow.

You can work around any speed/excess processes problems by doing the
NOV/active update from procmail itself.  I've attached a small
procmail recipe file as an example of how you might do this.  It's not
finished, just an example I used for testing.  Some of the stuff in
the Notes hasn't been added yet, but they're trivial additions.  Heck,
the whole thing is trivial.

If you're using mailagent as your filter, you can use mailagent's
(well-defined and well-docmented) interface to adding new commands to
create a command that also updates the nov/active files in addition to
saving it.  This avoids the load problem, since only one invocation of
mailagent is active at any given time.

Finally, Joe has a Tcl biffing script if you use the recommended
.spool method for delivery.  I've got a perl5/Tk script for external
delivery biffing. 

And that's the whole story so far,
-Sudish


# nov.rc		-*- text -*-
#
# procmail rc file to generate NOV entries and to update active files
# meant to be used for asynchronous delivery to GNUS nnml folders
#
# $Id: nov.rc,v 1.1.1.1 1995/11/12 01:48:00 joseph Exp $
#
# Copyright (C) 1995 Sudish Joseph <joseph@cis.ohio-state.edu>
#
#    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.
#
#
# Usage:
#
#	:0
#	* ^TOsome-list@some.where
#	{ NNDIR=mail/some/list NNGROUP=mail.some.list }
#
#	:0
#       * NNDIR ?? .
#	{ INCLUDERC=nov.rc }
#
#
# Notes:
#
# * The NNDIR values are relative to MAILDIR.  MAILDIR isn't changed
#   by this recipe.
#
# * The actual delivery to the nnml directory is done within this
#   recipe, but only if NNDIR is set.  If NNDIR isn't set, including
#   this recipe is a no-op.
#
# * The setting of NNGROUP is optional.  It's value is used to update
#   the active file.  If it's not set, no active file update will be
#   done.
# 
# * Though it seems redundant to have these two variables, it saves us
#   a call to tr later.  It also lets us turn off active file update
#   selectively.
#

# for debugging
#VERBOSE=ON

# Play it safe and check to see if we should be in here at all.
# It would be better if this were done in $HOME/.procmailrc, as shown above.
:0
* NNDIR ?? .
{
	# Get the header fields we require.

	# Normalize all fields to have no leading/trailing whitespace,
	# reduce all contiguous whitespace to a single space.
	
	# Supply sensible defaults where appropriate

	# Subject:
	:0
	* ^Subject: *\/[^ ].*
	{ SUBJECT=`echo $MATCH` }
	:0 E
	{ SUBJECT='(no subject)' }

	# From:
	:0
	* ^From: *\/[^ ].*
	{ FROM=`echo $MATCH` }
	:0 E
	{ FROM=nobody }

	# Date:
	:0
	* ^Date: *\/[^ ].*
	{ DATE=`echo $MATCH` }
	:0 E
	{ DATE='' }

	# Message-Id:
	:0
	* ^Message-Id: *\/[^ ].*
	{ MSGID=`echo $MATCH` }
	:0 E
	{ MSGID='<bogus.id@nowhere.we.know>' }

	# References:
	:0
	* ^References: *\/[^ ].*
	{ REFERENCES=`echo $MATCH` }
	:0 E                    # grab any possibilities in In-Reply-To:
	* ^In-Reply-To:.*\/<[^<>]*@[^<>]*>
	{ REFERENCES=`echo $MATCH` }
	:0 E
	{ REFERENCES='' }

	# size
	:0
	* BH ?? 1^1 .
	{ SIZE="$=" }

	# Lines:
	:0
	* ^Lines: *\/[^ ].*
	{ LINES=`echo $MATCH` }
	:0 
	* B ?? 1^1 ^(.|$)
	{ LINES="$=" }

	# Save the article now, so that we may grab the article number
	:0 c
	$NNDIR/.

	# Article No.
	:0
	* LASTFOLDER ?? .*\/[0-9]+$
	{ ARTICLE=$MATCH }

	# create the nov entry
	# note that this is the actual delivering recipe
	:0:
	| echo "$ARTICLE	$SUBJECT	$FROM	$DATE	$MSGID	$REFERENCES	$SIZE	$LINES" >> $NNDIR/.overview

}

VERBOSE=OFF

# Local Variables:
# auto-fill-function: nil
# eval: (progn (setq font-lock-keywords (list '("#.*" . font-lock-comment-face) '("^[\t ]*:.*" . font-lock-type-face) '("[A-Za-z_]+=.*" . font-lock-keyword-face) '("^[ 	]*\\*.*" . font-lock-reference-face))) (font-lock-mode))
# End:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: External delivery: methods.
  1995-11-15  8:18 External delivery: methods Sudish Joseph
@ 1995-11-15  8:52 ` Sudish Joseph
  1995-11-15 17:12 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Sudish Joseph @ 1995-11-15  8:52 UTC (permalink / raw)


I forgot to add that the best approach in all ways would be to write a
small C program to do what add-active-nov or the procmail recipe I
posted does.  It'd be small, since it could be linked against the code
in procmail itself.  The only factor here is the time needed in
understanding the code in procmail, which isn't very easy reading coz
of all the optimizations the author does.  (2 of the files break both
GNU and BSD indent, for starters :-).

-Sudish

PS: It's a pity that I have to do all those echo's to strip
whitespace, since procmail itself does this for pipe actions that
don't contain shell metachars (try an `echo tabbed and spaced string`
with VERBOSE=ON).  I can't think of any way to access this feature w/o
doing an echo/pipe, tho.  If anyone has any suggestions as to how to
do this, I'd be very grateful.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: External delivery: methods.
  1995-11-15  8:18 External delivery: methods Sudish Joseph
  1995-11-15  8:52 ` Sudish Joseph
@ 1995-11-15 17:12 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 1995-11-15 17:12 UTC (permalink / raw)
  Cc: The Ding List

> delivered article.  The problem with this is load on your mail hub,
> since you're running a perl script in addition to one procmail
> invocation for every message you receive.  It's also a tad slow.

I don't know how procmail implements the backquote operator, but if does it the
obvious way (pass the string to sh), then a perl script is probably faster than
the numerous backquotes in your procmail script !


	Stefan



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1995-11-15 17:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-11-15  8:18 External delivery: methods Sudish Joseph
1995-11-15  8:52 ` Sudish Joseph
1995-11-15 17:12 ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).