Something went wrong. Try again.
forked from cz-nic/bird
Something went wrong. Try again.
5.1 kB · 185 lines
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186## BackEnd.pm## $Id: BackEnd.pm,v 1.1.1.1 2001/05/24 15:57:41 sano Exp $## Dummy module containing backend specification.## � Copyright 1997, Cees de Groot#package LinuxDocTools::BackEnd;
die "This is a documentation package only!";
=head1 NAME
LinuxDocTools::BackEnd - LinuxDocTools back-end specification
=head1 SYNOPSIS
require LinuxDocTools::BackEnd; $BackEnd->{...};
=head1 DESCRIPTION
LinuxDoc-Tools backend modules need to conform to a certain interface which isdetailed in this document. The interface makes sure that new backend modules(or customer overrides) are compatible with what the main B<LinuxDocTools>package expects. Note that this interface is still subject to change, youshould check this document on new releases of LinuxDoc-Tools.
=head1 INTERFACE
The interface between the main package and individual backends is veryminimal - only one global variable is modified, everything else is local. Itrelies heavily on references and complex datatypes, so you want to makesure that you're up-to-date with Perl5.
Every backend creates a reference to a hash and stores this reference inthe global I<%Formats> hash:
my $BackEnd = {}; $Formats{"BackEnd"} = $BackEnd;
The rest of this document will deal with the entries in the local hashreferenced by I<$BackEnd>.
=head1 HASH ENTRIES
=over 4
=item NAME
Specify the name of the backend, for help messages etcetera.
$BackEnd->{NAME} = "BackEnd";
=item HELP
Specify an optional extra help message printed when the default usagefunction is executed (see L<LinuxDocTools::Utils>).
$BackEnd->{HELP} = "This is just and example message";
=item OPTIONS
This specifies the local set of options, which is added to the global setof options (available in I<$global>). The options are specified as anarray of hashes containing a number of keys:
=over 4
=item option
The long option name
=item type
The type of the option, one of B<f> (flag), B<l> (list of allowed values),B<s> (string), or B<i> (integer).
=item values
An array of allowed values, in case the option is of the list type.
=item short
A short (single-letter) version of the option name.
=back
Options can be specified as long options:
--papersize=a4
or as short options:
-p a4
Note that both the long options as the short options must not conflict withthe global options (an override is not - yet - possible) and should notconflict with other backends.
$BackEnd->{OPTIONS} = [ { option => "split", type => "l", 'values' => [ "0", "1", "2" ], short => "s" }, { option => "dosnames", type => "f", short => "D" }, { option => "imagebuttons", type => "f", short => "I"} ];
The long names themselves function as hash keys; a default can be givenhere and the option processing function will store any values foundat the same place:
$BackEnd->{'split'} = 1; $BackEnd->{dosnames} = 0; $BackEnd->{imagebuttons} = 0;
=item preNSGMLS
If defined, this should contain a subroutine that normally does two things: itcan modify the global value C<$global-E<gt>{NsgmlsOpts}> and it can set theglobal value C<$global-E<gt>{NsgmlsPrePipe}>. The first variable containsthe option string passed to B<nsgmls>, and the second variable can containa command that generates the input for B<nsgmls>, presumably using thecurrent input file in some way (the current input file can be foundin C<$global-E<gt>{file}>).
$BackEnd->{preNSGMLS} = sub { $global->{NsgmlsOpts} .= " -ifmtBackEnd "; $global->{NsgmlsPrePipe} = "sed 's/\@/\@\@/g' $global->{file}"; };
=item preASP
If defined, this should contain a subroutine accepting an input and an outputfile descriptor. The input file descriptor contains the raw output fromB<nsgmls>, and the output file descriptor should be filled with input to B<sgmlsasp>. This stage is often used to munch character entitiesbefore they're fed to B<sgmlsasp>, see L<LinuxDocTools::CharEnts>. If the routinedoesn't return C<0>, LinuxDocTools aborts.
$BackEnd->{preASP} = sub { my ($infile, $outfile) = @_;
while (<$infile>) { s/([^\\])\\n/$1 \\n/g; print $outfile $_; } return 0; };
=item postASP
This entry should always be defined, because it needs to contain a routinethat receives the output from B<sgmlsasp> which normally needs finalization.LinuxDocTools itself doesn't know about file-naming conventions, etcetera, ofthe backend so writing the final file is left to the backend. The subroutinereceives a reference to a filehandle (containing B<sgmlsasp> output) andshould do whatever it likes with this datastream.
$BackEnd->{postASP} = sub { my $infile = shift;
copy ($infile, "$global->{filename}.ext"); return 0; };
=back
=head1 SEE ALSO
L<LinuxDocTools> and subpackages.
=head1 AUTHOR
SGML-Tools are written by Cees de Groot, C<E<lt>cg@cdegroot.comE<gt>>, and various SGML-Tools contributors as listed in C<CONTRIBUTORS>.Taketoshi Sano C<E<lt>sano@debian.org<gt>> rename it to LinuxDocTools,and do some bug-fixes and updates on it.
=cut1;