%/****************************************************************************/
%/*                                                                          */
%/*                           (c) 1997 by vhs-soft                           */
%/*                                                                          */
%/* This file is distributed under the GNU Public License                    */
%/*                                                                          */
%/* Volker Simonis  email : simonis@informatik.uni-tuebingen.de              */
%/*                                                                          */
%/****************************************************************************/

\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{progdoc}
                  [1997/07/11 v0.8 include c/c++/java listings]
\RequirePackage{keyval, pifont, longtable}

\setlength{\LTpre}{\medskipamount}
\setlength{\LTpost}{\medskipamount}
\setlength{\LTleft}{0cm}
\setlength{\LTright}{\fill}

% only for identification
\def\vhsListing{}

% font definitions 
\newcommand{\pdFontSize}{8}    % by default in pt
\newcommand{\pdLineSep}{2.5ex}
\newcommand{\pdIndent}{0.5em}
\newcommand{\pdBaseFont}{\ttdefault}
\newcommand{\pdCommentFont}{\itshape}
\newcommand{\pdKeywordFont}{\bfseries}
\newcommand{\pdHeaderFont}{\slshape}
\newcommand{\pdPreprFont}{\bfseries\itshape}
\newcommand{\pdStringFont}{\slshape}

\newcommand{\pdLeftBrace}{\symbol{123}}
\newcommand{\pdRightBrace}{\symbol{125}}
\newcommand{\pdBackslash}{\symbol{92}}
\newcommand{\pdTilde}{\symbol{126}}
\newcommand{\pdCircum}{\symbol{94}}

\newcommand{\ProgDoc}{ProgDoc}
%begin{latexonly}
\ifx\pdfoutput\undefined
\renewcommand{\ProgDoc}{%
{\fontfamily{cmtt}\fontshape{sc}\selectfont Prog}%
{\fontencoding{OMS}\fontfamily{cmsy}\selectfont DOC}}
% For LaTeX we have to define the \texorpdfstring command
\else
\renewcommand{\ProgDoc}{%
\texorpdfstring{{\fontfamily{cmtt}\fontshape{sc}\selectfont Prog}%
{\fontencoding{OMS}\fontfamily{cmsy}\selectfont DOC}}{ProgDoc}}
\fi
%end{latexonly}
\ifx\pdfoutput\undefined
\newcommand{\texorpdfstring}[2]{#1}
\fi

%begin{latexonly}
% if we are not in german mode
\ifx\originalTeX\undefined\def\originalTeX{}\fi
%end{latexonly}
\ifx\germanTeX\undefined\def\germanTeX{}
 \def\ListingName{Listing}
 \def\LineName{Line}
 \def\toName{to}
 \def\ReferenceName{Referenced in}
 \def\PageName{on page}
 \def\NextPage{\ding{229}}
 \def\ListingContinue{continued}
\else
%begin{latexonly}
 \def\ListingName{Listing}
 \def\LineName{Zeile}
 \def\toName{bis}
 \def\ReferenceName{Referenziert in}
 \def\PageName{auf Seite}
 \def\NextPage{\ding{229}}
 \def\ListingContinue{Fortsetzung}
%end{latexonly}
\fi

\newsavebox{\ListingHead}
\newsavebox{\ListingFirstHead}
\newlength{\pdPre}
\setlength{\pdPre}{\bigskipamount}
\newlength{\pdPost}
\setlength{\pdPost}{0pt}
\newlength{\pdLeft}
\setlength{\pdLeft}{0pt}
\newlength{\pdRight}
\setlength{\pdRight}{\fill}

%\newcommand{\sourceinput}[2]{\fbox{\parbox{10cm}{Run extract on this file 
%  before processing it with latex. Then you will see the sourcecode from
%  the file #1 with the label #2 instead of this message}}}

\makeatletter
\define@key{vhs}{label}{\def\vhsLabelName{#1}}
\define@key{vhs}{fontsize}{\def\vhsFontSize{#1}}
\define@key{vhs}{fontname}{\def\vhsFont{#1}}
\define@key{vhs}{linesep}{\def\LineSep{#1}}
\define@key{vhs}{linenr}[true]{\def\LineSep{#1}}
\define@key{vhs}{center}[true]{\def\vhsCenter{#1}}
\define@key{vhs}{listing}[true]{\def\vhsListing{#1}}

\newlength{\mPageWX}
\setlength{\mPageWX}{\textwidth}
\addtolength{\mPageWX}{-2\fboxsep}

\def\sourceinput{\bgroup\catcode`\_=\active%
  \@ifnextchar[\sourceinputt{\sourceinputt[]}}
\def\sourceinputt[#1]#2#3{\setkeys{vhs}{#1}%
  \fbox{\parbox{\mPageWX}{{\scshape Warning !!!} Run {\ttfamily pdweave} on 
  this file 
  before processing it with latex. Then you will see the sourcecode 
  example labeled {\ttfamily #3} from the file {\ttfamily #2} instead 
  of this message}}\egroup \\}

\newcounter{Listing}
\setcounter{Listing}{1}

\def\myHyperLabel#1{%% Labels in the style of hyperref
  \hyperdef{Listing}{\theListing}% This enables links in the .pdf output
  \@bsphack%
  \protected@write\@auxout{}%
    {\string\newlabel{#1}{{\theListing}{\thepage}{#1}{Listing.\theListing}{}}}%
  \@esphack%
}
\def\myDefaultLabel#1{\@bsphack%% Default label style
  \protected@write\@auxout{}%
    {\string\newlabel{#1}{{\theListing}{\thepage}}}%
  \@esphack%
}

\ifx\pdfoutput\undefined
\def\mylabel#1{\expandafter{\myDefaultLabel{#1}}}
\else
\def\mylabel#1{\expandafter{\myHyperLabel{#1}}}
\fi

\newenvironment{myquoteold}
  {\begin{center}\begin{minipage}{0.9\textwidth}\small} 
  {\end{minipage}\end{center}}

\newenvironment{myquote}
  {\begin{quotation}\small\LTleft=\leftmargin} 
  {\end{quotation}}

%\newlength{\blabla}
%\newlength{\blablaA}
%\newlength{\bloblob}
%\newlength{\bloblobB}
%\newlength{\oldparindent}
%\def\syscall#1{%
%  \setlength{\blabla}{\linewidth}%
%  \addtolength{\blabla}{-2\fboxsep}\addtolength{\blabla}{-2pt}%
%  \fbox{\parbox{\blabla}{#1}}%
%}

%\def\syscall(#1,#2{%
%  \medskip\\%
%  \setlength{\oldparindent}{\parindent}%
%  \setlength{\parindent}{0pt}%
%  \setlength{\blabla}{\linewidth}%
%  \addtolength{\blabla}{-2\fboxsep}\addtolength{\blabla}{-2pt}%
%  \setlength{\blablaA}{\blabla}%
%  \settowidth{\bloblob}{\ttfamily#1 #2}%
%  \def\allArgs{\hyphenpenalty10000\ttfamily#1 \begin{bfseries}#2}\nextArg%
%}

%\def\endArg{)}
%\def\blankArg{ }
%\def\kommaArg{,}
%\def\blaArg{|}

%\def\nextArg#1{\def\next{#1}\def\nextCom{}%
%  \ifx\next\endArg\fbox{\parbox{\blabla}{\allArgs\end{bfseries}()}}%
%    \setlength{\parindent}{\oldparindent}\medskip\\%
%  \else%
%    \ifx\next\kommaArg%
%      \toks2=\expandafter{\allArgs}%
%      \addtolength{\blablaA}{-1\bloblob}%
%      \edef\allArgs{\the\toks2 \noexpand\end{bfseries}(%
%      \noexpand\begin{minipage}[t]{\noexpand\blablaA}}%
%      \def\nextCom{\nextArgA}%
%    \else\toks2=\expandafter{\allArgs}%
%      \settowidth{\bloblobB}{\ttfamily#1}%
%      \addtolength{\bloblob}{\bloblobB}%
%      \edef\allArgs{\the\toks2 #1}\def\nextCom{\nextArg}%
%    \fi%
%  \fi%
%  \nextCom%
%}

%\def\nextArgB#1,#2{-#1-hallo-#2-}

%\def\nextArgA#1,#2{\def\nextA{#1}\def\next{#2}\def\nextCom{}%
%  \ifx\nextA\blaArg\else%
%    \toks2=\expandafter{\allArgs}%
%    \edef\allArgs{\the\toks2 #1 }%
%  \fi%
%  \ifx\next\endArg\fbox{\parbox{\blabla}{\allArgs)\end{minipage}}}%
%    \setlength{\parindent}{\oldparindent}\medskip\\%
%  \else%
%    \ifx\next\kommaArg%
%      \toks2=\expandafter{\allArgs}
%      \edef\allArgs{\the\toks2 , }%
%      \def\nextCom{\nextArgA}%
%    \else\toks2=\expandafter{\allArgs}%
%      \edef\allArgs{\the\toks2 \noexpand\textit{#2}}\def\nextCom{\nextArgA |,}%
%    \fi%
%  \fi%
%  \nextCom%
%}



