Article View: news.software.readers
Article #40336Re: slrn/PGP
From: John E. Davis
Date: Wed, 22 Apr 1998 00:00
Date: Wed, 22 Apr 1998 00:00
126 lines
4409 bytes
4409 bytes
On 20 Apr 1998 02:01:25 +0500, Phil Humpherys <humphery@www.spire.com>
wrote:
>Any word on when PGP functionality will be placed in slrn? I
>think the mutt folks have done an awesome job with this, couldn't
>the slrn developers do something similar?
Apparantly if I put a pgp specific hook in the code then I would not
be able to make it available to those outside the US. However, here
is a patch to slrn that enables one to define a hook that can do
anything to the file immediately before posting. This differs from
the current filter hook because after the filter hook is called, slrn
MIME processes the file performs character set mapping, etc..
This patch allows one to define a hook called `post_file_hook'. Here
is an example of the hook (composed of two functions). The core
function separates the body from the header of the article and then
runs a command on the body section and then puts the header and body
back together. The `post_file_hook' function simply runs ispell on
the body but I am sure that you can think of other uses.
Below you will find the two macro functions followed by a patch to
slrn/src/post.c. The patch is with respect to 0.9.5.
define post_file_hook_command (cmd, file)
{
variable header_file, body_file;
variable fp, header_fp, body_fp;
variable line;
if (1 != get_yes_no_cancel (sprintf ("Execute %s on message", cmd)))
return;
fp = fopen (file, "r");
if (fp == NULL)
return;
header_file = file + "-header";
body_file = file + "-body";
header_fp = fopen (header_file, "w");
body_fp = fopen (body_file, "w");
if ((header_fp == NULL) or (body_fp == NULL))
return;
while (-1 != fgets (&line, fp))
{
if (line == "\n")
break;
() = fputs (line, header_fp);
}
() = fclose (header_fp);
% Now do body
while (-1 != fgets (&line, fp))
{
() = fputs (line, body_fp);
}
() = fclose (body_fp);
() = system (sprintf ("%s %s", cmd, body_file));
fp = fopen (file, "w");
body_fp = fopen (body_file, "r");
header_fp = fopen (header_file, "r");
while (-1 != fgets (&line, header_fp))
() = fputs (line, fp);
() = fputs ("\n", fp);
while (-1 != fgets (&line, body_fp))
() = fputs (line, fp);
% No need to close files unless we want to check for errors. When
% file pointer variables go out of scope, slang will close the file.
}
define post_file_hook (file)
{
post_file_hook_command ("ispell -x", file);
% post_file_hook_command ("other-commands...", file);
}
---------------------------------------
--- /nfs/wiwaxia/h1/davis/src/release/slrn/src/post.c Mon Apr 20 16:22:09 1998
+++ post.c Tue Apr 21 11:33:43 1998
@@ -792,11 +792,30 @@
if (Slrn_Use_Mime)
slrn_mime_scan_file (fp);
#endif
+#if SLRN_HAS_SLANG
+ if (NULL != SLang_get_function ("post_file_hook"))
+ {
+ fclose (fp);
+ (void) SLang_run_hooks ("post_file_hook", 1, file);
+ if (SLang_Error)
+ {
+ slrn_error ("post_file_hook returned error. %s not posted.", file);
+ return -1;
+ }
+
+ if ((fp = fopen (file, "r")) == NULL)
+ {
+ slrn_error ("File not found: %s--- message not posted.", file);
+ return -1;
+ }
+ }
+#endif
/* slrn_set_suspension (1); */
status = Slrn_Post_Obj->po_start ();
if (status != CONT_POST)
{
+ /* FIXME!! Put the file in a known place, e.g., dead.letter */
if (status != -1)
slrn_error ("Posting not allowed.");
return -1;
--
John E. Davis Center for Space Research/AXAF Science Center
617-258-8119 One Hampshire St., Building NE80-6019
http://space.mit.edu/~davis Cambridge, MA 02139-4307
Technical Details
Message-ID:
<slrn6jpik0.rcj.davis@aluche.mit.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<slrn6jlsm6.2cg.humphery@zoso.iomega.com>Show Full Headers
Complete Article Headers
Message-ID: <slrn6jpik0.rcj.davis@aluche.mit.edu> Subject: Re: slrn/PGP Date: Wed, 22 Apr 1998 00:00:00 +0000 From: davis@space.mit.edu (John E. Davis) References: <slrn6jlsm6.2cg.humphery@zoso.iomega.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 346788451 Organization: Center for Space Research Reply-To: davis@space.mit.edu Newsgroups: news.software.readers