1 % $Id: t-prot.sl,v 1.11 2005/01/07 18:15:36 jochen Exp $
2 % Copyright (c) 2003 Jochen Striepe <t-prot@tolot.escape.de>
4 % This file is provided as an example implemention for articles to be
5 % filtered through t-prot before displayed. They are still filtered if
6 % you reply to such a message so you will have to deactivate this if
7 % you want to include quotes of the original article.
9 % Activate this macro by adding
13 % If you are not happy with the suggested t-prot default parameters,
15 % variable t_prot_params = "-cemtS";
16 % variable t_prot_tmpdir = "$HOME/.tmpdir";
17 % variable t_prot_qp = "";
18 % into ~/.slrn/t-prot-cfg and add
19 % interpret .slrn/t-prot-cfg
20 % to your ~/.slrnrc (after 'interpret t-prot.sl'). However, please keep
21 % in mind that the path of the temp directory should NOT be readable to
22 % other users -- otherwise it might reveal information on what you read,
23 % and probably even be a security hole.
24 % Please see t-prot's man page for details on command line parameters.
26 % If you want to toggle t-prot filtering on/off without leaving slrn,
27 % you may want to add something like
28 % setkey article register_t_prot "\e1"
29 % setkey article unregister_t_prot "\e0"
30 % to your ~/.slrnrc -- press ESC-1 to activate t-prot filtering, and
31 % ESC-0 to disable it (this will take effect on the next article you
32 % read, see the package's TODO file).
34 % Requirements/Bugs: tr(1) and rm(1) are POSIX and should be available
35 % on any Unix-like system, mktemp(1) should be available on any recent
36 % OpenBSD or Debian Linux system -- you can get the sources there
37 % if your system happens to lack this program. This macro has been
38 % tested with slrn-0.9.7.4 to slrn-0.9.8.0 and S-Lang v1.4.5, it might
39 % fail with other versions. As always, bug reports, patches (preferrably
40 % in unified diff format), comments and suggestions are welcome.
42 % License: This file is part of the t-prot package and therefore
43 % available under the same conditions. See t-prot's man page for
47 % these should be reasonable defaults (they work fine for me, SCNR):
48 variable t_prot_params = "-aceklmtS --diff --bigq -L$HOME/.slrn/mlfooters -A$HOME/.slrn/adfooters";
49 variable t_prot_tmpdir = "$HOME/tmp/slrn";
50 variable t_prot_qp = "perl -i -p -e '$p=1 if /^Content-Transfer-Encoding: quoted-printable/i; if ($p==1) { s/=([0-9a-f][0-9a-f])/chr(hex($1))/egi; s/=\n//eg; };'";
53 variable art, f, fname, line, qp;
56 % Keep in mind that the path should NOT be readable to other users --
57 % otherwise it might reveal information on what you read, and probably
58 % even be a security hole:
59 f = popen ("mktemp -q "+t_prot_tmpdir+"/t-prot.sl.XXXXXX | tr -d '\n'", "r");
60 if (f == NULL) return;
61 if (-1 == fgets (&fname, f)) return;
65 if (t_prot_qp != "") { qp = t_prot_qp+"|"; } else { qp = ""; }
66 pipe_article (qp+"t-prot "+t_prot_params+" >"+fname);
68 f = fopen (fname, "r");
70 error (fname+" could not be opened.");
73 while (-1 != fgets (&line, f)) {
78 % The removal of the tmp file works this way but should be made a
79 % little more reliable. Any ideas?
80 system ("rm -f "+fname);
81 replace_article (art);
84 define register_t_prot () {
85 if (1 == register_hook("read_article_hook", "t_prot")) {
86 error("t-prot filtering activated");
89 error("t-prot filtering NOT activated");
93 define unregister_t_prot () {
94 if (1 == unregister_hook("read_article_hook", "t_prot")) {
95 error("t-prot filtering deactivated");
98 error("t-prot filtering NOT deactivated");
102 % filtering is enabled by default:
103 register_hook("read_article_hook", "t_prot");