# HtagPlugin.pm
-# (C) Copyright 2000-2001 Simon Huggins <huggie@earth.li>
+# (C) Copyright 2000-2003 Simon Huggins <huggie@earth.li>
# 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
# 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 {
}
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;
Note if you package this please package all the files in the docs/ subdir.
Simon Huggins <huggie@earth.li>
-Mon, 4 Jun 2001 22:18:35 +0200
+Wed Jun 18 23:08:46 BST 2003
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.
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.
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.
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
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
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
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
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).
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.
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
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).
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
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;"
-htag-0.0.18
-16th April 2000
+htag-0.0.23
+18th June 2003
1. Plugins
==========
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.
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
===========
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 <huggie@earth.li>".
-htag.pl 0.0.18
+htag.pl 0.0.23
Simon Huggins <huggie@earth.li>
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
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.
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 :)
+++ /dev/null
-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 <huggie@earth.li>
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
+++ /dev/null
-Simon Huggins <huggie@earth.li>
-
-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 :)
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 <huggie@earth.li>
# http://www.earth.li/projectpurple/progs/htag.html
# 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
# 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/;
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 <RETURN> to continue\n";
-# my $throwaway=<STDIN>;
-# }
-# die "\n";
-#}
-
sub print_header {
print STDERR "Htag.pl $cfg{'VERSION'} - Simon Huggins <huggie\@earth.li> 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 {
"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
my $file;
if (defined $cfg{'changeheaders'}) {
- open(HANDLE, $cfg{'msgfile'});
my (@headers,$match,@l);
- while (my $line = <HANDLE>) {
- last if ($line =~ /^$/); # end of headers
- push @headers, $line;
+ if (open(HANDLE, $cfg{'msgfile'})) {
+ while (my $line = <HANDLE>) {
+ last if ($line =~ /^$/); # end of headers
+ push @headers, $line;
+ }
+ close(HANDLE);
}
foreach (@{$cfg{'changeheaders'}}) {
$file = pop;
}
}
- close(HANDLE);
}
}
--- /dev/null
+#!/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>) {
+ $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";
+ $_ = <STDIN>;
+ return 255 if /^q(?:uit)?$/i;
+ return 255 if /^(?:no?|\n)$/i;
+}
+
#!/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
#!/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
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;
}
#!/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
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;
}
#!/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
$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";
#!/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.
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'}) {
#!/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)
# 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>) {
+ $sig .= $_;
+}
+close(SIG);
+
+if (grep { /\@NOTAG\@/ } $sig) {
+ $cfg{'notag'}=1;
+ return 15;
+}
htagdie <<EOF if (not defined $cfg{'tagfile'} and not defined $cfg{'tagfiles'} and not defined $cfg{'fortune'} and not defined $cfg{'tagdir'});
No tagfile defined! I'm good but I'm not psychic
#!/usr/bin/perl -w
-# Copyright (C) 2000-2001 Simon Huggins
+# Copyright (C) 2000-2003 Simon Huggins
# substtag performs substitutions on the tagline.
# This program is free software; you can redistribute it and/or modify it
#!/usr/bin/perl -w
-# Copyright (C) 2000-2001 Simon Huggins
+# Copyright (C) 2000-2003 Simon Huggins
# merge merges the sig and the tag but also merges the sig and the new style
# plugin things (i.e. all those silly files in $cfg{'tmpdir'}
my ($plugin,$len,$align,$wascr);
$wascr=0;
- while ($sig =~ /@([A-Za-z]?)([1-9][0-9]*)([RC]?)@/) {
+ while ($sig =~ /@([A-Za-z]?)(\*|(?:[1-9][0-9]*))([RC]?)@/) {
# Ick.
if (defined $3) {
$plugin = $1;
$chunk = getplugin($plugin);
print STDERR "Got plugin $plugin and $chunk\n"
if $anal_merge_debug;
+ $len = quotemeta $len; # escape * if it is *
$sig =~ s/\@$plugin$len[RC]?@/$chunk/;
print STDERR "Sig is now:\n$sig" if $anal_merge_debug;
$chunk = "";
} else {
my $extra;
$notag=0;
- $chunk = substr $tag, 0, $len;
+ if ($len ne "*") {
+ $chunk = substr $tag, 0, $len;
print STDERR "chunk,tag = #$chunk#,#$tag#".length($tag)." ".length($chunk)."\n"
if $anal_merge_debug;
- if ($chunk =~ s/^([^\n]+)\n+(.*)$/$1/s) {
- $extra = $2;
- print STDERR "\$extra = [$extra]\n"
- if $anal_merge_debug;
- }
- if (length($chunk) < $len) {
- print STDERR "length(chunk) < $len\n"
- if $anal_merge_debug;
- $chunk=&chunksizealign($chunk,$len,$align);
- print STDERR "chunk = #$chunk#\n"
- if $anal_merge_debug;
- }
- if (length($tag) < $len + 1) {
- $tag= $extra ? $extra : "";
+ if ($chunk =~ s/^([^\n]+)\n+(.*)$/$1/s) {
+ $extra = $2;
+ print STDERR "\$extra = [$extra]\n"
+ if $anal_merge_debug;
+ }
+ if (length($chunk) < $len) {
+ print STDERR "length(chunk) < $len\n"
+ if $anal_merge_debug;
+ $chunk=&chunksizealign($chunk,$len,$align);
+ print STDERR "chunk = #$chunk#\n"
+ if $anal_merge_debug;
+ }
+ if (length($tag) < $len + 1) {
+ $tag= $extra ? $extra : "";
print STDERR "length(tag) < $len + 1, tag now = #$tag#(extra = #$extra#)\n"
if $anal_merge_debug;
- } elsif (substr $tag, 0, $len + 1 eq ' ') {
- $tag=substr $tag, $len + 1;
- $tag=$extra . $tag if defined $extra;
+ } elsif (substr $tag, 0, $len + 1 eq ' ') {
+ $tag=substr $tag, $len + 1;
+ $tag=$extra . $tag if defined $extra;
print STDERR "substr tag, 0, $len + 1 was a space. tag now = #$tag#\n"
if $anal_merge_debug;
- } else {
- $tag=substr $tag, $len;
- ### Back up a word in $chunk
- $tag=$extra . $tag if defined $extra;
+ } else {
+ $tag=substr $tag, $len;
+ ### Back up a word in $chunk
+ $tag=$extra . $tag if defined $extra;
print STDERR "didn't break at space. Backing up word. tag now = #$tag#\n"
if $anal_merge_debug;
- if ($chunk =~ s/(.*) (.*)$/$1/) {
- $tag=$2 . $tag;
- $chunk=&chunksizealign($chunk,$len,$align);
- }
+ if ($chunk =~ s/(.*) (.*)$/$1/) {
+ $tag=$2 . $tag;
+ $chunk=&chunksizealign($chunk,$len,$align);
+ }
print STDERR "If space in chunk then change chunk and add word to tag.".
"Reformat chunk now = #$chunk# (tag = #$tag#)\n" if $anal_merge_debug;
+ }
+ } else {
+ $chunk = $tag;
+ $tag = "";
}
+ $len = quotemeta $len; # escape * if it's *
$sig =~ s/\@$plugin$len[RC]?@/$chunk/;
}
}
$sig =~ s/@([0-9]+)[RC]?@/" " x $1/eg;
+ $sig =~ s/@\*[RC]?@//g;
$cfg{'notag'} = $notag;
if ($tag and not $notag) {
return undef;
$sig .= $_;
}
close(SIG);
-open(TAG, "<$cfg{'tmptagfile'}") or htagdie "$1: Could not open $cfg{'tmptagfile'}: $!\n";
-while(<TAG>) {
- $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>) {
+ $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);
print SIG "\n" while $cfg{'newline'}--;
print SIG $sig;
close(SIG);
- return;
+ return $ret;
} else {
return(10);
}
#!/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
#!/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
# 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;
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);
}
close(SIG);
if (defined $sig) {
- $sig = reformat($sig);
+ $sig = reformat($sig);
+ $sig = remove_space($sig);
if (defined $sig) {
open(SIG, ">$cfg{'tmpsigfile'}")
or htagdie
#!/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
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=<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";
$_ = <STDIN>;
-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";
#!/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...
#!/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
#!/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