%%
%% This is file `abc.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% abc.dtx  (with options: `package')
%% 
%%  Copyright 2005 Enrico Gregorio
%% 
%%  This program is provided under the terms of the
%%  LaTeX Project Public License distributed from CTAN
%%  archives in directory macros/latex/base/lppl.txt.
%% 
%%  Author: Enrico Gregorio
%%          Enrico dot Gregorio at univr dot it
%% 
%%  This work has the LPPL maintenance status "author-maintained".
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{abc}
  [2005/11/18 v0.7dev Enrico Gregorio]

\newif\ifabc@shellescape
\newif\ifabc@generate
\DeclareOption{noshellescape}{\abc@shellescapefalse}
\DeclareOption{shellescape}{\abc@shellescapetrue}
\DeclareOption{nogenerate}{\abc@generatefalse}
\DeclareOption{generate}{\abc@generatetrue}
\def\abc@epsext{eps}
\DeclareOption{ps2eps}{\def\abc@pscmd{ps2eps -f}}
\DeclareOption{ps2epsi}{\def\abc@pscmd{ps2epsi}\def\abc@epsext{epsi}}
\DeclareOption{ps2epsidos}{\def\abc@pscmd{ps2epsi}\def\abc@epsext{epi}}
\ExecuteOptions{generate,shellescape,ps2eps}
\ProcessOptions\relax
\RequirePackage{verbatim}
\RequirePackage{graphicx}
\RequirePackage{ifpdf}
\RequirePackage{keyval}
\newcommand{\abc@cmd}{abcm2ps}       % virtually no choice
\newcommand{\abc@parm}{-O= -c}       % -O= MUST stay
\newcommand{\abc@epstopdfcmd}{epstopdf}
\newcommand{\abc@pdfext}{pdf}
\ifpdf
  \let\abc@finalext\abc@pdfext
\else
  \let\abc@finalext\abc@epsext
\fi
\newcommand{\abcwidth}{\linewidth}  % only fractions of \linewidth
\newwrite\abc@out
\def\abc@startgen{%
  \@bsphack
  \immediate\openout\abc@out\abc@tempfile.abc
  \let\do\@makeother\dospecials
  \catcode`\^^M\active \catcode`\^^I=12
  \def\verbatim@processline{%
  \immediate\write\abc@out
    {\the\verbatim@line}}%
  \verbatim@start}
\def\abc@finishgen{%
  \immediate\closeout\abc@out
  \@esphack
  \abc@process
}
\def\abc@doshellcommand{%
  \immediate\write18{%
    \abc@cmd\space
    \abc@parm\space
    \abc@opt\space
    \abc@tempfile.abc
    \ifx\abc@postopt\@empty
    \else\space\abc@postopt\fi}%
  \immediate\write18{%
    \abc@pscmd\space\abc@tempfile.ps}%
  \ifpdf
    \immediate\write18{%
      \abc@epstopdfcmd\space\abc@tempfile.\abc@epsext}%
  \fi
}
\def\abc@nodoshellcommand{%
  \PackageWarning{abc}{Remember to generate the [eps,pdf]
  file\MessageBreak prior to compiling again}%
  }
\ifabc@shellescape
  \let\abc@process\abc@doshellcommand
\else
  \let\abc@process\abc@nodoshellcommand
\fi
\ifabc@generate
  \let\abc@start\abc@startgen
  \let\abc@finish\abc@finishgen
\else
  \let\abc@start\comment
  \let\abc@finish\endcomment
\fi
\def\normalabcoutputfile{out-abc}
\def\abc@tempfile{\normalabcoutputfile}
\def\abc@opt{}
\let\abc@postopt\@empty
\def\abc{\@ifnextchar[\abc@grab{\abc@grab[]}}
\define@key{abc}{name}{\def\abc@tempfile{#1}}
\define@key{abc}{options}{\def\abc@opt{#1}}
\define@key{abc}{postoptions}{\def\abc@postopt{#1}}
\define@key{abc}{program}{\def\abc@cmd{#1}\let\abc@parm\@empty}
\def\abc@grab[#1]{\setkeys{abc}{#1}\abc@start}
\def\endabc{%
  \abc@finish
  \begin{center}
  \IfFileExists{\abc@tempfile.\abc@finalext}
    {\includegraphics[width=\abcwidth]{\abc@tempfile.\abc@finalext}}%
    {\fbox{\abc@tempfile}}%
  \end{center}
}
\def\abcinput{\@ifnextchar[\abc@grabinput{\abc@grabinput[]}}
\def\abc@grabinput[#1]#2{\setkeys{abc}{#1}%
  \gdef\abc@tempfile{#2}%
  \IfFileExists{\abc@tempfile.abc}
  {%
    \abc@process
    \begin{center}
    \IfFileExists{\abc@tempfile.\abc@finalext}
      {\includegraphics[width=\abcwidth]{\abc@tempfile.\abc@finalext}}%
      {\fbox{\abc@tempfile}}%
    \end{center}%
  }
  {\PackageWarning{abc}{No file \abc@tempfile.abc found}}%
}
\endinput
%%
%% End of file `abc.sty'.
