summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorabs <abs@pkgsrc.org>2002-01-31 18:07:25 +0000
committerabs <abs@pkgsrc.org>2002-01-31 18:07:25 +0000
commit630731c668222aaf6ed27dd887e7f68a497f7b5e (patch)
treec773ace35637866f0ecf0df2d21d02a0b55152df
parentd7f8e624030678fe7a344a1e3082df258310f378 (diff)
downloadpkgsrc-630731c668222aaf6ed27dd887e7f68a497f7b5e.tar.gz
Import htmlfix-1.00. Simple perl script to replace latin1 characters with
HTML entities, and/or fixup line endings.
-rw-r--r--www/htmlfix/DESCR2
-rw-r--r--www/htmlfix/Makefile19
-rw-r--r--www/htmlfix/PLIST3
-rw-r--r--www/htmlfix/distinfo4
-rwxr-xr-xwww/htmlfix/files/if-psprint.pl224
5 files changed, 252 insertions, 0 deletions
diff --git a/www/htmlfix/DESCR b/www/htmlfix/DESCR
new file mode 100644
index 00000000000..3240c6820ab
--- /dev/null
+++ b/www/htmlfix/DESCR
@@ -0,0 +1,2 @@
+htmlfix will replace latin1 characters with html entities, or fix
+line endings in html files.
diff --git a/www/htmlfix/Makefile b/www/htmlfix/Makefile
new file mode 100644
index 00000000000..225f7d1961e
--- /dev/null
+++ b/www/htmlfix/Makefile
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1.1.1 2002/01/31 18:07:25 abs Exp $
+#
+
+DISTNAME= htmlfix-1.00
+CATEGORIES= www
+MASTER_SITES= http://www.mono.org/abs/tools/htmlfix/
+
+MAINTAINER= abs@netbsd.org
+COMMENT= Fix latin1 to html entities and/or line endings
+
+DEPENDS+= p5-HTML-FixEntities-[0-9]*:../../www/p5-HTML-FixEntities
+
+USE_PERL5= YES
+
+do-install:
+ ${INSTALL_SCRIPT} ${WRKSRC}/htmlfix.pl ${PREFIX}/bin/htmlfix
+ ${INSTALL_MAN} ${WRKSRC}/htmlfix.1 ${PREFIX}/man/man1/htmlfix.1
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/www/htmlfix/PLIST b/www/htmlfix/PLIST
new file mode 100644
index 00000000000..fffe6187bc5
--- /dev/null
+++ b/www/htmlfix/PLIST
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2002/01/31 18:07:25 abs Exp $
+bin/htmlfix
+man/man1/htmlfix.1
diff --git a/www/htmlfix/distinfo b/www/htmlfix/distinfo
new file mode 100644
index 00000000000..f830ef48afa
--- /dev/null
+++ b/www/htmlfix/distinfo
@@ -0,0 +1,4 @@
+$NetBSD: distinfo,v 1.1.1.1 2002/01/31 18:07:25 abs Exp $
+
+SHA1 (htmlfix-1.00.tar.gz) = c06d5f1593554dc6912074d387a66a33c845acba
+Size (htmlfix-1.00.tar.gz) = 2043 bytes
diff --git a/www/htmlfix/files/if-psprint.pl b/www/htmlfix/files/if-psprint.pl
new file mode 100755
index 00000000000..a0394e64c61
--- /dev/null
+++ b/www/htmlfix/files/if-psprint.pl
@@ -0,0 +1,224 @@
+#!@PREFIX@/bin/perl -w
+#
+# $NetBSD: if-psprint.pl,v 1.1.1.1 2002/01/31 18:07:25 abs Exp $
+#
+# Copyright (c) 2000 David Brownlee <abs@netbsd.org>. All rights
+# reserved. Provided as-is without express or implied warranties.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided the above copyright and this
+# notice is retained.
+#
+
+=head1 NAME
+
+if-psprint - send text, postscript, or native printer language to
+arbitrary printer.
+
+=head1 SYNOPSIS
+
+Designed as a quick fix for the random printers that get hooked up to
+the NetBSD server and random Windows boxes around the office. Uses enscript
+to convert text to postscript, and ghostcript to convert to native printer
+language as required.
+
+=head1 DESCRIPTION
+
+=over 4
+
+=item *
+
+Overloads 'af' entry to contain printer type, and optional location.
+in the form 'type[.model][/smb/smb_dest]'. Use type 'ps' for no gs filter.
+
+=item *
+
+Reads first 1k and calls 'file' to determine filetype.
+
+=item *
+
+Builds a spool command based on filetype:
+
+=over 4
+
+=item *
+
+If text and not postscript, use enscript text->postscript
+
+=item *
+
+If enscripted or postscript, use gs postscript->printer_format
+
+=item *
+
+Otherwise assumed to be native printer language (its your rope)
+
+=back
+
+=item *
+
+Open pipe to spool command, send first 1k, then rest of data
+
+=item *
+
+requires ghostscript, enscript, and samba if printing to smb hosts
+
+=back
+
+=head1 EXAMPLE PRINTCAP ENTRIES
+
+(Remember to create spool dir [sd])
+
+=over 4
+
+=item *
+
+HP deskjet named 'leaves' connected to smb host 'tea'.
+(using ghostscript 'hpdj' driver model 'unspec')
+
+ leaves:\
+ :if=@PREFIX@/libexec/if-psprint:lf=/var/log/lpd-errs:\
+ :sh:mx=0:lp=/dev/null:sd=/var/spool/lpd/leaves:\
+ :af=hpdj.unspec/smb/tea/leaves:
+
+=item *
+
+Canon bubblejet connected to /dev/lpa0 (using gs 'bjc800' driver)
+
+ bubbly:\
+ :if=@PREFIX@/libexec/if-psprint:lf=/var/log/lpd-errs:\
+ :sh:mx=0:lp=/dev/lpa0:sd=/var/spool/lpd/bubbly:\
+ :af=bjc800:
+
+=back
+
+=cut
+
+$ENV{'PATH'}="@PREFIX@/bin:/usr/bin:/bin";
+
+use strict;
+use Getopt::Std;
+use IPC::Open3;
+
+my( $user,
+ $dest,
+ $spoolhost,
+ $device,
+ $model,
+ %opt,
+ );
+
+# Parse options (ignore most)
+#
+
+&getopts('vw:l:i:n:h:', \%opt);
+$user = $opt{'n'};
+$user ||= $ENV{'USER'};
+$spoolhost = $opt{'h'};
+if (!$spoolhost)
+ { chomp($spoolhost = `hostname`); }
+
+if (@ARGV != 1 || $ARGV[0] !~ m#(\w+)(\.(\w+)|)(/smb/.*/.*|)#)
+ { usage_and_exit(); }
+$device = $1;
+$model = $3;
+$dest = $4;
+if ($dest)
+ { $dest =~ s#/smb/#smb:/#; }
+
+# Determine filetype
+#
+
+my($data, $filetype);
+if (!read(STDIN, $data, 1024)) # initial filetype check data
+ { &fail("No data to print"); }
+$filetype = &filetype($data);
+
+# Generate spool command
+#
+
+my($spool);
+$spool = '';
+if ($filetype =~ /^PostScript/ || $filetype =~ /text/)
+ {
+ if ($filetype !~ /^PostScript/)
+ { $spool .= '|'.filter_enscript(); }
+ if ($model || $device ne 'ps')
+ { $spool .= '|'.filter_gs($device, $model); }
+ }
+
+if ($dest)
+ { $spool .= "|smbspool smb://$dest 1 $user $spoolhost 1 -"; }
+
+if ($spool eq '')
+ { $spool = '>&STDOUT'; }
+
+if ($opt{'v'})
+ { print STDERR "$spool\n"; }
+# Spool output
+#
+if (!open(OUTPUT, $spool))
+ { &fail("Unable to run '$spool': $!"); }
+print OUTPUT $data; # print initial filetype check data
+while (read(STDIN, $data, 16*1024))
+ { print OUTPUT $data; }
+close(STDIN);
+close(OUTPUT);
+exit;
+
+sub fail
+ {
+ print STDERR "if-psprint: @_\n";
+ exit 1;
+ }
+
+sub filetype
+ {
+ my($data) = @_;
+ my($pid, $filetype);
+
+ unless ($pid = open3('WTRFH', 'RDRFH', 'ERRFH', 'file -b -'))
+ { &fail("Unable to run 'file': $!"); }
+ print WTRFH $data;
+ close(WTRFH);
+ close(ERRFH);
+ 0 && close(ERRFH); # Pacify perl's -w
+ chop($filetype = <RDRFH>);
+ close(RDRFH);
+ wait;
+ $filetype;
+ }
+
+sub filter_enscript
+ {
+ my($filter);
+
+ $filter = "enscript -q -B -p -";
+ }
+
+sub filter_gs
+ {
+ my($device, $model) = @_;
+ my($filter);
+ $filter = "gs -q -dBATCH -sDEVICE=$device";
+ if (defined $model)
+ { $filter .= " -sModel=$model"; }
+ $filter .= " -SOutputFile=- -";
+ }
+
+sub usage_and_exit
+ {
+ print "Usage: if-psprint [opts] gs_device[.gs_model]/smbdestination
+[opts]
+ -v Verbose
+ -w width
+ -l lines
+ -i indent
+ -n user
+ -h host
+
+if-psprint is intended to be used from within printcap. See manpage for more
+details.
+";
+ exit 1;
+ }