From 49c39d47502a7485e7e63f7cbea8325852d25967 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Fri, 26 Jul 2019 10:10:02 -0300 Subject: [PATCH] Import Upstream version 0.0.23 --- HtagPlugin/HtagPlugin.pm | 6 +-- README | 2 +- build_util/addlicense.sh | 0 docs/AUTHORS | 3 ++ docs/BUGS | 1 - docs/Changelog.htag | 80 ++++++++++++++++++---------- docs/Changelog.htagplugin | 2 + docs/INSTALL | 18 ++----- docs/MACRO_DESCRIPTION | 3 ++ docs/README | 22 ++++---- docs/README.Multiple_Configs | 65 ----------------------- docs/TODO | 4 +- docs/WRITING_SIGS | 100 ----------------------------------- htag.pl | 37 +++++-------- plugins/01checksigsep | 41 ++++++++++++++ plugins/02catsig | 2 +- plugins/06marknlard | 7 ++- plugins/07sesame | 7 ++- plugins/08uptime | 6 ++- plugins/09date | 8 +-- plugins/10simple | 13 ++++- plugins/13substtag | 2 +- plugins/15merge | 83 +++++++++++++++++------------ plugins/20substsig | 2 +- plugins/22reformat | 56 ++++++++++++++------ plugins/25asktag | 10 ++-- plugins/35tearline | 2 +- plugins/80header | 2 +- plugins/98append | 2 +- 29 files changed, 269 insertions(+), 317 deletions(-) mode change 100755 => 100644 build_util/addlicense.sh delete mode 100644 docs/README.Multiple_Configs delete mode 100644 docs/WRITING_SIGS create mode 100644 plugins/01checksigsep diff --git a/HtagPlugin/HtagPlugin.pm b/HtagPlugin/HtagPlugin.pm index 4610874..58a4c6d 100644 --- a/HtagPlugin/HtagPlugin.pm +++ b/HtagPlugin/HtagPlugin.pm @@ -1,5 +1,5 @@ # HtagPlugin.pm -# (C) Copyright 2000-2001 Simon Huggins +# (C) Copyright 2000-2003 Simon Huggins # 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 @@ -23,7 +23,7 @@ use Carp; # This version is the version of this module and not the version of htag. # Plugins using functions only in new modules should really check the # version. -$VERSION = '0.5'; +$VERSION = '0.6'; # Do magic exporter stuff per mjd sub import { @@ -117,7 +117,7 @@ sub scansigfile($) { } close(SIG); - while ($sig =~ s/(\@$char([1-9][0-9]*)([RC])?@)//) { + while ($sig =~ s/(\@$char(\*|(?:[1-9][0-9]*))([RC]?)\@)//) { my @array = ($1,$2); push @array, defined($3) ? $3 : "L"; push @found, \@array; diff --git a/README b/README index 82944e5..8998d42 100644 --- a/README +++ b/README @@ -3,4 +3,4 @@ The real README and so on are in the docs/ subdir. Note if you package this please package all the files in the docs/ subdir. Simon Huggins -Mon, 4 Jun 2001 22:18:35 +0200 +Wed Jun 18 23:08:46 BST 2003 diff --git a/build_util/addlicense.sh b/build_util/addlicense.sh old mode 100755 new mode 100644 diff --git a/docs/AUTHORS b/docs/AUTHORS index 425ca37..0f8902f 100644 --- a/docs/AUTHORS +++ b/docs/AUTHORS @@ -12,3 +12,6 @@ who poked me a bit to do more work on it and to Lim Swee Tat who did likewise and also sent a patch which I rewrote to provide fortune support. Thanks to Jonathan McDowell again for packaging this up for Debian. + +Thanks to Alex Walker for installing it and sending me lots of mail about +useful stuff he wanted to see in it. diff --git a/docs/BUGS b/docs/BUGS index 32168db..8c0892d 100644 --- a/docs/BUGS +++ b/docs/BUGS @@ -3,7 +3,6 @@ have a really twisted mind :) Bonus points will be awarded to the first person to use this feature for a useful purpose. -* There isn't enough documentation Mail me with any you find. diff --git a/docs/Changelog.htag b/docs/Changelog.htag index 272207d..83f3557 100644 --- a/docs/Changelog.htag +++ b/docs/Changelog.htag @@ -1,7 +1,31 @@ HISTORY -04/06/2001 +2003-06-18 + Oops, 25asktag always asked for a tag regardless of $cfg{'asktag'} + Thanks to Jasper Spaans for pointing that out. +2002-06-04 + Various bugfixes and cleanups. + Added a working 22reformat instead of just the template which has + been around for a while. +2002-06-01 + Add Noodles' patch from a while back to add an option to skip back to + asking about a sig from the asktag plugin. + A few miscellaneous cleanups. + Wrote a HOWTO which is at: + http://the.earth.li/~huggie/cgi-bin/moin/HtagHowto + Made @M*@ and so on work to insert things /without/ worrying about + their length. This means they won't be padded and so is primarily + useful for the extra plugins and not taglines and allows you to put + text right up against them without worrying about extra spaces. It + does also work with taglines so @*@ inserts the tag but with /no/ + formatting. (Request from Alex Walker) + Added @NOTAG@ to stop any tagline being added. Macros still get + expanded as do non-tag plugins. (Request from Alex Walker) + Added plugin to check for existing unquoted sigsep and allow user to + quit. (Request from Alex Walker) + +2001-06-04 s/.pl$// in plugins and chmod 644 plugins/* since they don't really make sense separately from htag. Created TROUBLESHOOTING file. @@ -10,20 +34,20 @@ HISTORY subdirectories and into the docs/ dir. Move the sample config stuff into one place too. -27/05/2001 +2001-05-27 Change version number in HtagPlugin.pm to one that perl can check automagically and add a version to my use HtagPlugin line. -25/05/2001 +2001-05-25 Fixed up the cases where either the configfile has an error (always set $override{'nicedie'}) or the plugins do htagdie. htagdie has now disappeared in favour of nicedie so I've bumped the versioning in HtagPlugin.pm and nicedie has moved to HtagPlugin.pm -09/05/2001 +2001-05-09 Changed s/|$// to s/\|$// in sample.htrc Doh! -30/04/2001 - 0.0.18 +2001-04-30 - 0.0.18 Yes, I should definitely have released 0.0.18 by now. Ho hum. Added check of patterns used in changeheaders so if someone puts one @@ -31,7 +55,7 @@ HISTORY Rolled tarball - probably won't be uploaded til 2nd May. -16/04/2001 +2001-04-16 Oops, shouldn't I have released 0.0.18 by now? Checked status of 0.0.18 and cleaned it up a little. Made multiple @@ -61,7 +85,7 @@ HISTORY also doesn't parse the .dat files it just runs fortune(1) which is fairly icky really but hey. -02/02/2001 +2001-02-02 Feedback (oh my God other people use this? :)) led to a few changes: Change the cfgfile interface stuff so we eval just one file (~/.htrc or the file specified on the commandline with -c) then eval another @@ -71,21 +95,21 @@ HISTORY cases because they didn't really help and just caused config problems really. -22/01/2001 +2001-01-22 Check for UID/GID 0 before running. -28/11/2000 - 0.0.17 +2000-11-28 - 0.0.17 Put 01changeconf.pl into htag.pl instead. Tried to think about the idea of having dependencies instead of just a plugin dir or indeed a plugin list instead but gave up simply because I can't be arsed. I want to run all the plugins. This is the idea. Anyway, patches/ideas accepted. -27/11/2000 +2000-11-27 Fixed a strange bug due to a regexp in merge that meant that @B in a tagline wasn't expanding correctly sometimes. -13/11/2000 +2000-11-13 Fixed some of the eval code so it reports fatal errors. Made merge.pl remove spaces if there were only spaces between it and @@ -93,15 +117,15 @@ HISTORY quick fix and gave in and used a negative look behind assertion in my regexp. Requires perl 5.005 or higher I think. -09/11/2000 +2000-11-09 Upgraded to perl 5.6.0 and um didn't realise and ran htag.pl It seems to work with 5.6.0 :) -27/10/2000 +2000-10-27 Moved substtag.pl so it was called *after* the tag had been chosen. Oops. I should have more tags with substable bits in, yes. -11/10/2000 - 0.0.16 +2000-10-11 - 0.0.16 Fixed merge so that it works if a sig doesn't have any tagline bits. And so that multiple elements of the same plugin will work (e.g. having two separate @Uxx@ lines works now). @@ -115,14 +139,14 @@ HISTORY Moved 05* to 14* so that in the case where the tag doesn't fit and we have to go back we only go back one. -08/10/2000 - 0.0.16-pre-going-to-release-soon-honest (Eurostar :)) +2000-10-08 - 0.0.16-pre-going-to-release-soon-honest (Eurostar :)) Implemented a "read and eval" parser for the plugins if they are in perl. This may well break things. Let me know if it does. Moved plugin_util to HtagPlugin. (tab completion works better now so I'm less annoyed so I'll be more productive. Or summat :)) -24/09/2000 - 0.0.16-pre +2000-09-24 - 0.0.16-pre Changed htag.pl and all plugins not to call srand because since perl 5.004 this is done automatically and uses a better random seed than I was giving it. @@ -134,7 +158,7 @@ HISTORY It allows multiple configs based on headers finally! See README.Multiple_Config -15/08/2000 - 0.0.15 +2000-08-15 - 0.0.15 Changed HtagPlugin to only require three arguments (Message file, Cfg file and VERSION) which all need to come from htag.pl @@ -147,7 +171,7 @@ HISTORY Added some new plugins (sesame, date, uptime) using this system. -29/07/2000 - 0.0.14 +2000-07-29 - 0.0.14 Changed HtagPlugin to return 254 when htagdie is called. Made htag.pl ask for keypress if exited with 254 but NOT if exited with 255 (i.e. user requested exit). @@ -160,44 +184,44 @@ HISTORY Added protocol version number and checking for same. -28/06/2000 - 0.0.13 +2000-06-28 - 0.0.13 Changed HtagPlugin to cope with "Lastname, Firstname" -18/06/2000 - 0.0.12 +2000-06-18 - 0.0.12 Fixed the subst* plugins to use the To: address not the From: address. (Doh.) Put more common code into the HtagPlugin module. -06/06/2000 - 0.0.11 +2000-06-06 - 0.0.11 Early in the morning. Released the new one properly. -... + ... Converted to an init style plugins-invoked-in-order-of-number type thing to allow more flexibility. -05/04/2000 - 0.0.8 +2000-04-05 - 0.0.8 Allowed plugins to return the number to go back to... Infinite loops are protected against. exiting with 255 means quit htag.pl -31/03/2000 - 0.0.7 +2000-03-31 - 0.0.7 Made it like init. (Runs plugins in numerical order randomly picks ones with same order). -24/03/2000 - 0.0.6 +2000-03-24 - 0.0.6 Backends for - choosing tags. -07/02/2000 - 0.0.5 +2000-02-07 - 0.0.5 Fixed '-- ' thing. -03/01/2000 - 0.0.4 +2000-01-03 - 0.0.4 Fixed length "feature" of 0.0.3 Will now only use tags that fit the sigs' @[0-9]+@ bits. -19/12/1999 +1999-12-19 Released to the unsuspecting world... Started 6/10/1999 diff --git a/docs/Changelog.htagplugin b/docs/Changelog.htagplugin index 53f5a2d..91d7191 100644 --- a/docs/Changelog.htagplugin +++ b/docs/Changelog.htagplugin @@ -1,6 +1,8 @@ HISTORY - HtagPlugin.pm +01/06/2002 - 0.6 + Changed scansigfile to cope with @M*@ style macros. 27/05/2001 - 0.5 Change to use perl style version number so it can be verified with "use HtagPlugin.pm 0.5;" diff --git a/docs/INSTALL b/docs/INSTALL index bcacdc3..dea01d7 100644 --- a/docs/INSTALL +++ b/docs/INSTALL @@ -1,5 +1,5 @@ -htag-0.0.18 -16th April 2000 +htag-0.0.23 +18th June 2003 1. Plugins ========== @@ -8,8 +8,6 @@ Htag.pl works on a plugin system. All the plugins are in the (originally named) plugins directory. They should be moved somewhere sensible and the path to them should be put in the $cfg{'plugindir'} variable in your ~/.htrc -NOTE: Systemwide installation will get better. Honest. - If you're installing for the whole box put them in /usr/local/share/huggietag/plugins or some such. A system tagfile could live in /usr/local/share/huggietag too for instance. @@ -36,25 +34,19 @@ the advent of eval of plugins (Hooray!). NOTE: This must be an absolute path if you're going to call it from random locations. -When I write an install script it will do this for you. +If I write an install script it will do this for you. 3. Config file ============== Copy the sample.htrc to ~/.htrc and edit it lots. -If you want multiple config files then read README.Multiple_Config +See http://the.earth.li/~huggie/cgi-bin/moin/HtagHowto for more information. 4. Signatures ============= Create your own sigs. You can use some of the sigs I provide as templates. -You may find htag.pl -f useful when creating sigs with @xx[RC] macros since -it will replace these just with spaces allowing you to get the spacing right -as you're trying to line them up. - -Make sure you add at least one sig to the config file. - -Look in sigs for some of mine. +See http://the.earth.li/~huggie/cgi-bin/moin/HtagHowto for more information. 5. Using it =========== diff --git a/docs/MACRO_DESCRIPTION b/docs/MACRO_DESCRIPTION index e733e8f..bbaea99 100644 --- a/docs/MACRO_DESCRIPTION +++ b/docs/MACRO_DESCRIPTION @@ -20,6 +20,9 @@ L - Last name N - Full name V - Version in the form x.y.z +@NOTAG@ is special and means that no tagline is to be appended to this sig +but that it will still be parsed and have macros substituted etc. + The name variants are only available if htag is passed a message with headers like "To: Simon Huggins ". diff --git a/docs/README b/docs/README index 4ec3153..fd09d3e 100644 --- a/docs/README +++ b/docs/README @@ -1,12 +1,12 @@ -htag.pl 0.0.18 +htag.pl 0.0.23 Simon Huggins Description =========== - htag is a tagline adder but it has now been so over engineered that - it will also do anything you want it to[0], do lots of stuff I want - it to[1], and do stuff it wants to[2]. + htag is a tagline and signature adder but it has now been so over + engineered that it will also do anything you want it to[0], do lots + of stuff I want it to[1], and do stuff it wants to[2]. See the INSTALL file for basic usage. See the TODO file for some stuff that I need help with and stuff that @@ -14,13 +14,15 @@ will appear soon. You will probably find the other docs useful (in order of usefulness): README - This file! -INSTALL - how to install and use. -README.Multiple_Configs - How to use multiple config files (you probably - want to use this to get any use of the - power/configurability of htag) +INSTALL - how to install htag for those not using a binary + package. sample-config - a bunch of sample config files useful to base yours on. -WRITING_SIGS - tips for writing your own signatures. + +But really most of the docs are now at: +http://the.earth.li/~huggie/cgi-bin/moin/HtagHowto + +Other docs are: TROUBLESHOOTING - how to troubleshoot your own problems. MACRO_DESCRIPTION - the reference for all the magic in sigs and tags. Changelog.htag - the changes between versions of htag. @@ -34,8 +36,6 @@ LICENSE - the license. Please mail me if you: * have written some cool/useful plugins -* want to write docs -* want me to write docs * want to write an installer * think it's good * want to show off your tags and sigs :) diff --git a/docs/README.Multiple_Configs b/docs/README.Multiple_Configs deleted file mode 100644 index c8903a7..0000000 --- a/docs/README.Multiple_Configs +++ /dev/null @@ -1,65 +0,0 @@ -Multiple Config Support -======================= - -Please read the README/INSTALL before reading this document. - -In 0.0.18 this changed to eval your per header configs *after* the main -config file as opposed to only evaluating one config file making it easier -to see what is different about a particular config but breaking backward -compatibility for those that used Multiple Config File support. Sorry. -Complain at me. - -Multiple Config Support allows that you can reply to different people or -different newsgroups with different plugins. - -This is what htag.pl does when it starts up wrt configfiles: - - checks to see if one is specified on the commandline - - if not defaults the basecfgfile to ~/.htrc - - evaluates the basecfgfile - - checks to see if $cfg{'changeheaders'} is defined and if so checks - whether those patterns match the headers it has for the message. - If they match it runs this extra config file. - -So to get this working you just need to create one config file with your -defaults and your changeheaders patterns and extra config file names. Then -create the extra config files you've mentioned in changeheaders. - -changeheaders syntax is something like: -$cfg{'changeheaders'} = [ - [ 'pattern_to_match', 'more optional patterns', 'config filename' ], - one or more lines like above - ]; - -The patterns are ANDed together. If you want OR just create multiple lines. - -$cfg{'changeheaders'} = [ - [ '^From:.*support\@blackcatnetworks.co.uk', '~/.htagrc/support' ], - [ '^Newsgroups:.* fr\.', 'From:.*huggie\@foo.com', - '~/.htagrc/fr-foo.com' ] - ]; - -The first example matches all messages which I send out with a From: line of -support@blackcatnetworks.co.uk so that I can append reassuring signatures to -our customers - I don't actually do this ... yet :) -The second is a contrived example which matches a Newsgroup line which has -somewhere a group that starts with "fr." and where the From: line contains -huggie@foo.com - -There is a way of having a config per address but still only having one -rule. Put a rule which has an empty config file and at least one rule which -should (if it matches) produce the config file name in $1 (the first -parenthesized match). -e.g. - [ '^From:.*?(\w+)@earth.li','~/.htagrc/earth-li-$1' ], - -Then for every mail sent from something@earth.li it will use the config -"~/.htagrc/earth-li-something". - -This could be used for instance to have a different config per From: address -(i.e. when you send from company From: addresses, and from personal From: -addresses and want to have different configs per address). - -This documentation was written when I hadn't had enough sleep. Sorry. -Corrections/clarifications/rewrites/chocolate welcomed. - -Simon Huggins diff --git a/docs/TODO b/docs/TODO index 897b721..c79b75c 100644 --- a/docs/TODO +++ b/docs/TODO @@ -10,15 +10,17 @@ me diffs or plugins or docs etc. And have the MAGIC do things like center or right align or possibly even put over two lines if it is needed. * Write more plugins that do random stuff as examples of what can be done. -* Write documentation +* Keep updating the Wiki with more docs. * Fix bugs * Add more cunning things here. * Add an installer or very explicit Installation documentation. (paddy may do this) +* Allow searching for taglines by regexp and choosing them that way Done ==== +* I wrote some docs! http://the.earth.li/~huggie/cgi-bin/moin/HtagHowto * Add docs on how to install a module if you are not the sysadmin (request from fudge) * Add a way (probably in a plugin) to differentiate between which plugins diff --git a/docs/WRITING_SIGS b/docs/WRITING_SIGS deleted file mode 100644 index 4b952aa..0000000 --- a/docs/WRITING_SIGS +++ /dev/null @@ -1,100 +0,0 @@ -Simon Huggins - -Sigs are essentially just text files with special characters inside them. - -There are two (ish) types of special characters: - - those that just get substituted - - those that get padded and aligned - -For a full definition of reserved letters and macros that can exist please -read MACRO_DESCRIPTION. Yeah, I know there is overlap but this file is -meant to help you write sigs and MACRO_DESCRIPTION is meant to be an -authoritative reference file. - -See the end for the examples which are probably more interesting. - -Straight substitutions -====================== - - Becomes -@B A newline. This is a bit pointless for sigs - why have a macro to - insert a newline when you can just put one in yourself? - It's useful for taglines. -@F First name of person in To: line. -@L Last name of person in To: line. -@N Whole name of person in To: line. -@V Version of htag.pl (format x.y.z i.e. 0.0.17) - -Padding and Aligning -==================== - -Ok, substitutions of this sort are done to a set number of characters. - -They are of the form: -@[A-Za-z]?[1-9][0-9]*[RC]?@ - -That is: - - An @ symbol - - An optional letter - * If it's not there it means insert a bit of the tagline - you've selected (multiple ones of these are replaced with - multiple sections of tagline) - * If it does exist it means insert a bit of the plugin that - deals with that particular letter (multiple ones of these - are replaced each time with a new line from the plugin) - - A number - * This is the exact number of characters that will be - inserted. - - An optional alignment - * R for right padded with spaces - * C for centered padded with spaces - * Nothing for left aligned padded with spaces on the right. - - An @ symbol - - -What this all means -=================== - -It's probably best shown with examples: - -@40@ means insert 40 characters of the tagline chosen left aligned. -@64R@ means right align over 64 characters part of the tagline. - - -@20R@ @20@ means right align 20 characters of tagline and then put a space -and then left align another 20. - -With letters: - -@U20@ means print in 20 characters the output of the uptime plugin -(depending on the settings in htrc this is normally of the form: -up 23 days, 3:41) - -@U1@ means give me an error message because I didn't give it enough space to -put the uptime in. - -Here is one of my sigs: - --- -UK based domain, email and web hosting ***/ @28R@ /* -http://www.blackcatnetworks.co.uk/ **/ @28R@ /** -sales@blackcatnetworks.co.uk */ @28R@ /*** -Black Cat Networks / @28R@ /**** - -It just sticks the tagline inside the slanty bit right aligned. - -And another: - --- -Just another wannabie | @30C@ | Just another fool -----------------------+ @30C@ +------------------- -This message was brought to you @S30@. -htag.pl @V -- http://www.earth.li/projectpurple/progs/htag.html - -This puts the tagline in the middle over two lines and centers it. It -replaces S30 with by the letter A and the number 1 where A and 1 are -randomly chosen letters using the sesame plugin and it replaces @V with the -current version of htag.pl - -Hope that helped a bit. -Send me any good sigs that you write :) diff --git a/htag.pl b/htag.pl index 235afef..5972d89 100755 --- a/htag.pl +++ b/htag.pl @@ -3,7 +3,7 @@ use strict; # htag.pl - a tagline generator, sig manager and over engineered program. -# Copyright (C) 1999-2001 Simon Huggins +# Copyright (C) 1999-2003 Project Purple, Simon Huggins # Simon Huggins # http://www.earth.li/projectpurple/progs/htag.html @@ -12,8 +12,7 @@ use strict; # 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. +# Software Foundation; version 2 of the License only # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY @@ -35,9 +34,9 @@ if ($< == 0 or $> == 0 or $( == 0 or $) == 0) { # HtagPlugin lying around the system then uncomment the following with the # path to your local copy of HtagPlugin -# use lib '/home/huggie/htag/'; +# use lib '/home/huggie/perl/huggietag/htag-0.0.23/HtagPlugin'; -use HtagPlugin 0.5; +use HtagPlugin 0.6; use Getopt::Long; use POSIX qw/tcgetpgrp/; @@ -57,25 +56,16 @@ my $cfgdebug=0; my $infinity = 80; ### Defines -$override{'VERSION'} = $cfg{'VERSION'} = "0.0.19"; +$override{'VERSION'} = $cfg{'VERSION'} = "0.0.23"; $override{'HOME'} = $cfg{'HOME'} = $ENV{"HOME"} || $ENV{"LOGDIR"} || (getpwuid($<))[7]; +$cfg{'nicedie'} = 1; # srand(time() ^ ($$ + ($$ << 15) )); # Since 5.004 not required -#sub nicedie($) { -# my $msg = shift; -# warn $msg; -# if ($cfg{'nicedie'}) { -# warn "Press to continue\n"; -# my $throwaway=; -# } -# die "\n"; -#} - sub print_header { print STDERR "Htag.pl $cfg{'VERSION'} - Simon Huggins Released under GPL\n"; - print STDERR "Copyright (C) 1999-2001 Project Purple. http://www.earth.li/projectpurple/\n\n"; + print STDERR "Copyright (C) 1999-2002 Project Purple. http://www.earth.li/projectpurple/\n\n"; } sub process_options { @@ -97,7 +87,7 @@ sub process_options { "msgfile=s" => \$cfg{'msgfile'}, "m=s" => \$cfg{'msgfile'}); if (not &GetOptions(%getopt)) { - print <<'EOF'; + print STDERR <<'EOF'; htag.pl - tagline and general sig adder. Usage: htag.pl -t tagfile -c cfgfile -m msgfile htag.pl -h gives perldoc @@ -349,11 +339,13 @@ sub choose_configfile() { my $file; if (defined $cfg{'changeheaders'}) { - open(HANDLE, $cfg{'msgfile'}); my (@headers,$match,@l); - while (my $line = ) { - last if ($line =~ /^$/); # end of headers - push @headers, $line; + if (open(HANDLE, $cfg{'msgfile'})) { + while (my $line = ) { + last if ($line =~ /^$/); # end of headers + push @headers, $line; + } + close(HANDLE); } foreach (@{$cfg{'changeheaders'}}) { $file = pop; @@ -391,7 +383,6 @@ sub choose_configfile() { } } - close(HANDLE); } } diff --git a/plugins/01checksigsep b/plugins/01checksigsep new file mode 100644 index 0000000..fb70cff --- /dev/null +++ b/plugins/01checksigsep @@ -0,0 +1,41 @@ +#!/usr/bin/perl -w + +# Copyright (C) 2000-2003 Simon Huggins +# checksigsep checks for an existing sigsep and allows you to quit without +# adding a new sig. + +# 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 + +use strict; + +return if ($cfg{'msgfile'} eq "-"); + +my $msg=""; +open(MSG, "<$cfg{'msgfile'}") or return; +while() { + $msg .= $_; +} +close(MSG); +if (grep { /\n-- \n/ } $msg) { + my $oldmsg = $msg; + print STDERR "Looks like this message already has an unquoted sigsep:\n"; + $oldmsg =~ s/.*(-- $)/$1/ms; + print STDERR $oldmsg; + print STDERR "\n\nAdd another? ([N]o/(y)es)\n"; + $_ = ; + return 255 if /^q(?:uit)?$/i; + return 255 if /^(?:no?|\n)$/i; +} + diff --git a/plugins/02catsig b/plugins/02catsig index 62c5b72..dcbaca0 100644 --- a/plugins/02catsig +++ b/plugins/02catsig @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # catsig deals with choosing a sig # This program is free software; you can redistribute it and/or modify it diff --git a/plugins/06marknlard b/plugins/06marknlard index a6c9c82..291465c 100644 --- a/plugins/06marknlard +++ b/plugins/06marknlard @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # marknlard outputs Mark 'n Lard style attributions # This program is free software; you can redistribute it and/or modify it @@ -44,7 +44,10 @@ foreach my $f (@found) { while ($recursion < 30) { $recursion++; my $attr = pickone(); - if (length $attr <= $f[1]) { + if ($f[1] eq "*") { + print OUT $attr,"\n"; + $recursion = 255; + } elsif (length $attr <= $f[1]) { print OUT chunksizealign($attr, $f[1], $f[2]),"\n"; $recursion = 255; } diff --git a/plugins/07sesame b/plugins/07sesame index c532bf3..f8ecfc9 100644 --- a/plugins/07sesame +++ b/plugins/07sesame @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # Sesame Street style brought to you "by the letter X and the number 1" # This program is free software; you can redistribute it and/or modify it @@ -36,7 +36,10 @@ foreach my $f (@found) { while ($recursion < 30) { $recursion++; my $attr = pickone(); - if (length $attr <= $f[1]) { + if ($f[1] eq "*") { + print OUT $attr,"\n"; + $recursion = 255; + } elsif (length $attr <= $f[1]) { print OUT chunksizealign($attr, $f[1], $f[2]),"\n"; $recursion = 255; } diff --git a/plugins/08uptime b/plugins/08uptime index ffa34f6..89e53ce 100644 --- a/plugins/08uptime +++ b/plugins/08uptime @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # uptime merely calls uptime. You can influence the output a bit. # This program is free software; you can redistribute it and/or modify it @@ -36,7 +36,9 @@ $uptime =~ s/^.*?(up (?:[0-9]+ days?,)?[^,]+),.*$/$1/ if $cfg{'uptime_time'}; $uptime =~ s/[ ]+/ /g; foreach my $f (@found) { my @f = @{$f}; - if (length $uptime <= $f[1]) { + if ($f[1] eq "*") { + print OUT $uptime,"\n"; + } elsif (length $uptime <= $f[1]) { print OUT chunksizealign($uptime, $f[1], $f[2]),"\n"; } else { htagdie "Can't fit uptime in <= $f[1].\nPerhaps your space isn't big enough.\nAlternatively modify this script to give less information.\n"; diff --git a/plugins/09date b/plugins/09date index d62eaf9..decdf26 100644 --- a/plugins/09date +++ b/plugins/09date @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # date just calls date. You may pass in a strftime compatible formatting # string. @@ -35,8 +35,10 @@ reg_deletion("$cfg{'tmpdir'}/D"); foreach my $f (@found) { my @f = @{$f}; my $date = strftime($cfg{'date_format'} ? $cfg{'date_format'} : "%a %b %e %H:%M:%S %Y", localtime); - if (length $date <= $f[1]) { - print OUT chunksizealign($date, $f[1], $f[2]); + if ($f[1] eq "*") { + print OUT $date,"\n"; + } elsif (length $date <= $f[1]) { + print OUT chunksizealign($date, $f[1], $f[2]),"\n"; } else { my $diemsg = "Can't fit your chosen date format ("; if (defined $cfg{'date_format'}) { diff --git a/plugins/10simple b/plugins/10simple index 46825d6..22e67c4 100644 --- a/plugins/10simple +++ b/plugins/10simple @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # simple just chooses a random tagline in the simplest possible way # or uses fortune(1) @@ -24,6 +24,17 @@ my (@tags); # srand( time() ^ ($$ + ($$ << 15) )); # Since 5.004 not required. +my $sig=""; +open(SIG, "<$cfg{'tmpsigfile'}") or htagdie "$0: Could not open $cfg{'tmpsigfile'}: $!\n"; +while() { + $sig .= $_; +} +close(SIG); + +if (grep { /\@NOTAG\@/ } $sig) { + $cfg{'notag'}=1; + return 15; +} htagdie <) { $sig .= $_; } close(SIG); -open(TAG, "<$cfg{'tmptagfile'}") or htagdie "$1: Could not open $cfg{'tmptagfile'}: $!\n"; -while() { - $tag .= $_; +my $ret = 0; +if (grep { /\@NOTAG\@/ } $sig) { + $tag=""; + $ret=26; + $sig =~ s/\@NOTAG\@\n//; +} else { + open(TAG, "<$cfg{'tmptagfile'}") or htagdie "$1: Could not open $cfg{'tmptagfile'}: $!\n"; + while() { + $tag .= $_; + } + close(TAG); } -close(TAG); -if (defined $sig and $sig =~ /@[A-Za-z]?[1-9][0-9]*[RC]?@/) { +if (defined $sig and $sig =~ /@[A-Za-z]?\*|(?:[1-9][0-9]*)[RC]?@/) { $sig = merge($tag,$sig); } else { my $formatted_tag = Text::Wrap::wrap($cfg{'first'},$cfg{'leader'},$tag); @@ -176,7 +191,7 @@ if (defined $sig) { print SIG "\n" while $cfg{'newline'}--; print SIG $sig; close(SIG); - return; + return $ret; } else { return(10); } diff --git a/plugins/20substsig b/plugins/20substsig index d870b10..800fd27 100644 --- a/plugins/20substsig +++ b/plugins/20substsig @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # substsig substitutes parts of signatures # This program is free software; you can redistribute it and/or modify it diff --git a/plugins/22reformat b/plugins/22reformat index 910c768..02c9518 100644 --- a/plugins/22reformat +++ b/plugins/22reformat @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # reformats longer lengths after the substitutions have taken place # This program is free software; you can redistribute it and/or modify it @@ -17,16 +17,16 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place, Suite 330, Boston, MA 02111-1307 USA -return; - use strict; -use Text::Wrap; - -$Text::Wrap::columns=defined $cfg{'maxlinelen'} ? $cfg{'maxlinelen'} : 72; -$cfg{'first'} ||= ""; -$cfg{'leader'} ||= ""; +use vars qw($nomod); -my $anal_merge_debug=0; +BEGIN { + unless (eval "use Text::Balanced qw(gen_extract_tagged);1;") { + print STDERR "Text::Balanced not available, reformat plugin will not work\n"; + $nomod=1; + } +} +return if $nomod; sub remove_space($) { my $text=shift; @@ -42,14 +42,35 @@ sub remove_space($) { return $text; } -sub reformat($) { - my $sig = shift; -# LRC -#$chunk=&chunksizealign($chunk,$len,$align); - while ($sig =~ /\@(CENTER|RIGHT|LEFT)(\d+)?\@/) { - } +sub reformat ($) { + my $text = shift; + my ($ext,$end,$beg,$otag,$ctag,$stuff); + my $process = gen_extract_tagged('<(?:CENTER|RIGHT|LEFT)\d+>', + undef, + '(?s).*(?=<(?:CENTER|RIGHT|LEFT)\d+>)', + {reject => ['<(?:CENTER|RIGHT|LEFT)\d+>']} ); + while (1) { + ($stuff, $end, $beg, $otag, $ext, $ctag) = &$process($text); + if (not defined $stuff) { + if ($text =~ /<(?:CENTER|RIGHT|LEFT)\d+>/) { + nicedie($@->{'error'}); + } + } + last if !$stuff; - return $sig; + my $size = $otag; + $size =~ s/<(?:CENTER|RIGHT|LEFT)//; + $size =~ s/>//; + + my $align = $otag; + $align =~ s/^.(.).*$/$1/; + + my $c = chunksizealign($ext, $size, $align); + + $stuff=quotemeta($stuff); + $text =~ s/$stuff/$c/; + } + return $text; } my ($tag,$sig,$newsig); @@ -60,7 +81,8 @@ while() { } close(SIG); if (defined $sig) { - $sig = reformat($sig); + $sig = reformat($sig); + $sig = remove_space($sig); if (defined $sig) { open(SIG, ">$cfg{'tmpsigfile'}") or htagdie diff --git a/plugins/25asktag b/plugins/25asktag index 8ee45f6..ef8339d 100644 --- a/plugins/25asktag +++ b/plugins/25asktag @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # asktag chooses a tag like catsig chooses a sig. # This program is free software; you can redistribute it and/or modify it @@ -20,6 +20,7 @@ use strict; return if $cfg{'notag'}; +return unless $cfg{'asktag'}; open(SIG, "<$cfg{'tmpsigfile'}") or htagdie "$0: Could not open $cfg{'tmpsigfile'}: $!\n"; my @sig=; @@ -27,10 +28,11 @@ close(SIG); chomp $sig[-1]; print STDERR @sig; -print STDERR "\n\nOK? ([Y]es/(n)ew Tag/(q)uit)\n"; +print STDERR "\n\nOK? ([Y]es/(n)ew Tag/(b)ack to start/(q)uit)\n"; $_ = ; -return 255 if /^q(?:uit)?/i; -return if /^(?:y(?:es)?|\n)/i; +return 255 if /^q(?:uit)?/i; +return 2 if /^b(?:ack)?/i; +return if /^(?:y(?:es)?|\n)/i; # Remove sig, and copy old sig (unmerged copy) back over the top unlink($cfg{'tmpsigfile'}) or htagdie "Could not remove $cfg{'tmpsigfile'}: $!\n"; diff --git a/plugins/35tearline b/plugins/35tearline index ef10d8f..a2ec7fe 100644 --- a/plugins/35tearline +++ b/plugins/35tearline @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # tearline is a hang over from Fidonet days where tagline adding programs # had tearlines. It's probably no longer used by anyone anywhere but well I # live in hope that Fidonet will be reborn... diff --git a/plugins/80header b/plugins/80header index 5f9c52a..718c723 100644 --- a/plugins/80header +++ b/plugins/80header @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # header adds headers to messages like "Hi @F" # This program is free software; you can redistribute it and/or modify it diff --git a/plugins/98append b/plugins/98append index f9f3661..1d708b9 100644 --- a/plugins/98append +++ b/plugins/98append @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2001 Simon Huggins +# Copyright (C) 2000-2003 Simon Huggins # Just appends the sig onto the message file # This program is free software; you can redistribute it and/or modify it -- 2.39.5