%%
%%    File : localdriver.sty    (LaTeX2e package)
%%  Author : Martin Reddy (mxr@dcs.ed.ac.uk) 
%% Version : 1.0
%%
%% This package provides a simple interface to writing LaTeX code
%% that is conditional for a particular driver (e.g. dvips, oztex etc)
%%
%% It works out the current driver from the graphics package
%% configuration file, /usr/local/lib/TeX/tex/latex/config/graphics.cfg
%%
%% Commands:
%%
%% \DoIfDriver{driver-name}{conditional-code}
%%
%%    Executes the conditional-code only if the current driver is driver-name
%%    
%% \QuietDrivers 
%%
%%    Makes the \DoIfDriver{}{} command work quietly 
%%
%% see "texdoc localdriver" for further details.
%%

%% All class options are replicated from the graphics.sty package

\providecommand\LocalDriver{}

\DeclareOption{dvips}{\def\LocalDriver{dvips}}
\DeclareOption{xdvi}{\def\LocalDriver{dvips}}
\DeclareOption{dvi2ps}{\def\LocalDriver{dvi2ps}}
\DeclareOption{dvialw}{\def\LocalDriver{dvialw}}
\DeclareOption{dvilaser}{\def\LocalDriver{dvilaser}}
\DeclareOption{dvipsone}{\def\LocalDriver{dvipsone}}
\DeclareOption{dvitops}{\def\LocalDriver{dvitops}}
\DeclareOption{dviwindo}{\def\LocalDriver{dviwindo}}
\DeclareOption{emtex}{\def\LocalDriver{emtex}}
\DeclareOption{dviwin}{\def\LocalDriver{dviwin}}
\DeclareOption{oztex}{\def\LocalDriver{oztex}}
\DeclareOption{psprint}{\def\LocalDriver{psprint}}
\DeclareOption{pubps}{\def\LocalDriver{pubps}}
\DeclareOption{textures}{\def\LocalDriver{textures}}
\DeclareOption{pctexps}{\def\LocalDriver{pctexps}}
\DeclareOption{pctexwin}{\def\LocalDriver{pctexwin}}
\DeclareOption{pctexhp}{\def\LocalDriver{pctexhp}}
\DeclareOption{ln}{\def\LocalDriver{ln}}

% The graphics.cfg does an \ExecuteOptions for the appropriate option

\InputIfFileExists{graphics.cfg}{}{}
\ProcessOptions

\def\ld@isnotquiet{verbose}
\def\ld@quietmode{verbose}

% \QuietDrivers
% Makes the \DoIfDriver{}{} command work quietly 

\newcommand{\QuietDrivers}{\def\ld@quietmode{quiet}}

% \DoIfDriver{driver-name}{conditional-code}
% executes the conditional-code only if the current driver is driver-name

\newcommand{\DoIfDriver}[2]{%
   \def\TestDriver{#1}%
   \ifx\LocalDriver\TestDriver
      #2
      \ifx\ld@quietmode\ld@isnotquiet
         \typeout{Including conditional code for the "\LocalDriver" driver.}
      \fi%
   \fi%
}

%
% localdriver.sty
%
