%% -*- mode: LaTeX -*-
%%
%% Copyright (c) 2002 University of Utah and the Flux Group.
%% All rights reserved.
%% This file is part of the JanosVM documentation.
%% 
%% Permission to use, copy, modify, distribute, and sell this
%% documentation for any purpose is hereby granted without fee,
%% provided that the above copyright notice(s) appear in all copies.
%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Define a new `if' for draft copies.  This controls the output of RCS tag
%% information, for example.  By default, documents are not drafts.
%%
\newif\ifdraft
\draftfalse
\newcommand{\draftonly}[1]{\ifdraft{#1}\fi}

%% Define new `ifs' for our alternate target output formats, PDF and WWW (i.e.,
%% HTML with auxiliary GIF and CSS files).  These are used in our `hyperref'
%% configuration file (`hyperref.cfg') and can be used to tweak the generated
%% document for each output format.
%%
%% If neither `\pdftrue' nor `\wwwtrue', then we assume that we're targeting
%% regular old Postscript or DVI output.
%%
\newif\ifpdf
\pdffalse
\newif\ifwww
\wwwfalse

%% We don't need no steenkin' equations --- just gimme a working underscore!
%%
%% \catcode`\_=\active

%% `\rcsinfo' typesets a file's RCS information, but only in drafts.
%%
\newcommand{\rcsinfo}{\draftonly{\small\em\RCSId{}}}

%% `\com' is for comments.  Text within `\com' is output only in drafts.
%%
\newcommand{\com}[1]{\draftonly{\small\em\textbf{Comment:} #1}}

%% More commands for typesetting comments and notes that should appear in at
%% least some versions of the document (e.g., draft copies).  Note that we use
%% `\em' rather than `\emph' in these commands because `\emph' can't handle
%% multi-paragraph contents.
%%
\newcommand{\xcite}[1]{\ifdraft{\lbrack{#1}\rbrack}\else\cite{#1}\fi}
\newcommand{\Note}[1]{\draftonly{\small\em\textbf{Note:} #1}}
% If they really need to be done, we should be able to see them - ADR
\newcommand{\ToDo}[1]{\draftonly{\small\em\textbf{ToDo:} #1}}
%\newcommand{\ToDo}[1]{{\small\em\textbf{ToDo:} #1}}
\newcommand{\Advice}[2]{\draftonly{\small\em
                                   \textbf{A reader advised:} #1%
                                   \textbf{We say:} #2}}
\newcommand{\outline}[1]{\textsc{Outline:} {\itshape #1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Define certain tags used by the `\autoref' command.  (`\autoref' is provided
%% as part of the `hyperref' package.)
%%
%% These words are `\mbox'ed to prevent line breaks within them, because PDF
%% doesn't allow line breaks in hyperlinks.  So, without the box, we may get
%% different line breaks in PS- and PDF-targeted documents.  (BTW, don't use
%% `\hbox', because the box may start a paragraph.  See Exercise 13.1 in
%% _The_TeXbook_.)  Actually, even with the boxes, we may *still* get slightly
%% different line breaks in PS- and PDF-targeted output, but not very
%% different, and at least the linebreaks don't fall in the reference words.

\newcommand{\partautorefname}{\mbox{Part}}
\newcommand{\chapterautorefname}{\mbox{Chapter}}
\newcommand{\sectionautorefname}{\mbox{Section}}
\newcommand{\subsectionautorefname}{\sectionautorefname}
\newcommand{\subsubsectionautorefname}{\sectionautorefname}
\newcommand{\figureautorefname}{\mbox{Figure}}
\newcommand{\subfigureautorefname}{\figureautorefname}
\newcommand{\tableautorefname}{\mbox{Table}}
\newcommand{\appendixautorefname}{\mbox{Appendix}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Here are commands for typesetting the names of various things.

%% `\defterm' is used to typeset the first (defining) use of a new term.
%%
\newcommand{\defterm}[1]{\emph{#1}}

%% File names.
%%
%% We redefine `\UrlBreaks' not to include `.' so that we won't get line breaks
%% after the dot that separates a file name and its extension.
%%
\newcommand{\file}{\begingroup%
  \def\UrlBreaks{\do\\\do\/\do\_\do\-\do\+\do\=}%
  \Url}
\newcommand{\fileext}[1]{`\texttt{.#1}'}
\newcommand{\filefont}[1]{\def\_{\symbol{95}}\texttt{#1}}

%% Program names.
%%
\newcommand{\program}{\begingroup \Url}
%%
\newcommand{\ld}{\program{ld}}
\newcommand{\awk}{\program{awk}}
\newcommand{\gcc}{\program{gcc}}
\newcommand{\gdb}{\program{gdb}}
\newcommand{\ghc}{\program{ghc}}
\newcommand{\make}{\program{make}}
\newcommand{\gmake}{\program{gmake}}
%%
%% The JanosVM tools:
%%
\newcommand{\java}{\program{java}}
\newcommand{\kaffeh}{\program{kaffeh}}
\newcommand{\janosvm}{\program{janosvm}}
\newcommand{\jsihey}{\program{jsihey}}
\newcommand{\jsiregister}{\program{jsiregister}}
\newcommand{\jsiunregister}{\program{jsiunregister}}

%% C program identifiers, type, prototypes, and such.  These macros are defined
%% using the `url' package so that special characters (e.g., underscores) just
%% work, and so that internal line breaks (hyphenation) are allowed.  Each
%% macro takes one argument: e.g., `\cid{foo}'.
%%
\newcommand{\cid}{\begingroup \Url}
\newcommand{\javaid}{\begingroup \Url}
\newcommand{\jsiheyid}{\begingroup \Url}
% \newcommand{\ctype}{\begingroup \Url} --- need to handle spaces, though.
% \newcommand{\cprototype}{\begingroup \Url} --- need to handle spaces, though.

%% Acronyms.
%%
\newcommand{\acronym}[1]{\textsc{\lowercase{#1}}}

%% E.g.,
%% \newcommand{\TCP}{\acronym{TCP}}

\newcommand{\JanosVM}{JanosVM}
\newcommand{\JanosVMplain}{JanosVM}
\newcommand{\OSKit}{OSKit}
\newcommand{\Moab}{Moab}
\newcommand{\jnodeos}{Java NodeOS}

\newcommand{\Kaffe}{Kaffe}
\newcommand{\KaffeOS}{KaffeOS}
\newcommand{\Fluke}{Fluke}
\newcommand{\BeOS}{BeOS}

\newcommand{\OS}{\acronym{OS}}
\newcommand{\GC}{\acronym{GC}}
\newcommand{\JDK}{\acronym{JDK}}
\newcommand{\TLB}{\acronym{TLB}}
\newcommand{\BNF}{\acronym{BNF}}
\newcommand{\CPU}{\acronym{CPU}}
\newcommand{\API}{\acronym{API}}
\newcommand{\JVM}{\acronym{JVM}}
\newcommand{\JSI}{\acronym{JSI}}
\newcommand{\IPC}{\acronym{IPC}}
\newcommand{\JAR}{\acronym{JAR}}
\newcommand{\URI}{\acronym{URI}}

\newcommand{\GNU}{\acronym{GNU}}

\newcommand{\URL}{\acronym{URL}}
\newcommand{\CGI}{\acronym{CGI}}
\newcommand{\HTML}{\acronym{HTML}}

\newcommand{\TCP}{\acronym{TCP}}
\newcommand{\UDP}{\acronym{UDP}}
\newcommand{\IP}{\acronym{IP}}
\newcommand{\TCPIP}{\mbox{\acronym{TCP/IP}}}
\newcommand{\ARP}{\acronym{ARP}}
\newcommand{\NFS}{\acronym{NFS}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Define an environment for lists of filenames.  This is essentially identical
%% to the `optionlist' environment below.  If the filename is too weird, this
%% won't work; see the comments in `url.sty'.
%%
\newcommand{\filelistlabel}[1]%
  {\raisebox{0pt}[1ex][0pt]%
            {\makebox[\labelwidth][l]%
                     {\parbox[t]{\labelwidth}%
                             %% Not `\file{#1}', because we want to be able to
                             %% use macros in the label text.
                             {\raggedright\hspace{0pt}\filefont{#1}}%
                     }%
            }%
  }
\newenvironment{filelist}%
  {\begin{list}{}%
         {\renewcommand{\makelabel}{\filelistlabel}%
          \newcommand{\filepad}{\\\mbox{}}%
          \setlength{\labelwidth}{2.0in}%
          \setlength{\leftmargin}{2.4in}%
          \setlength{\parsep}{1ex plus 0.3ex}%
          \setlength{\partopsep}{0pt}%
          \setlength{\itemsep}{0pt}%
         }%
  }%
  {\end{list}}

% `\option' is not a URL because we want to be able to invoke macros with an
% option, e.g., `\optionarg' and `\optionor'.  Thus the need for the `\def\_'
% ickiness to get underscores in the correct typeface.
\newcommand{\option}[1]{\def\_{\symbol{95}}\texttt{#1}}

%% Define an environment for lists of command line options.  This `optionlist'
%% environment was adapted from the `Mentry' example on page 65 of _The_LaTeX_
%% _Companion_ by Goossens et al.
%%
\newcommand{\optionlistlabel}[1]%
  {\raisebox{0pt}[1ex][0pt]%
            {\makebox[\labelwidth][l]%
                     {\parbox[t]{\labelwidth}%
                             {\raggedright\hspace{0pt}\option{#1}}%
                     }%
            }%
  }
\newcommand{\optionarg}[1]{\option{\emph{#1}}}
\newcommand{\oroption}{\textrm{or}}
\newenvironment{optionlist}%
  {\begin{list}{}%
         {\renewcommand{\makelabel}{\optionlistlabel}%
          %
          % Provide a command for padding the height of the text.  Required
          % when the height of the text is less than the height of the item
          % label.
          \providecommand{\optionpad}{\\\mbox{}}%
          %
          % Set our various list lengths.
          \setlength{\labelwidth}{2.0in}%
          \setlength{\leftmargin}{2.4in}%
          \setlength{\parsep}{1ex plus 0.3ex}%
          \setlength{\partopsep}{0pt}%
          \setlength{\itemsep}{0pt}%
         }%
  }%
  {\end{list}}

%% Define an environment for lists of commands (i.e., command lines).  This is
%% essentially identical to the `optionlist' environment above.
%%
\newcommand{\commandlistlabel}[1]%
  {\raisebox{0pt}[1ex][0pt]%
            {\makebox[\labelwidth][l]%
                     {\parbox[t]{\labelwidth}%
                             {\raggedright\hspace{0pt}\filefont{#1}}%
                     }%
            }%
  }
\newcommand{\commandarg}[1]{\filefont{\emph{#1}}}
\newcommand{\orcommand}{\textrm{or}}
\newenvironment{commandlist}%
  {\begin{list}{}%
         {\renewcommand{\makelabel}{\commandlistlabel}%
          \newcommand{\commandpad}{\\\mbox{}}%
          \setlength{\labelwidth}{2.0in}%
          \setlength{\leftmargin}{2.4in}%
          \setlength{\parsep}{1ex plus 0.3ex}%
          \setlength{\partopsep}{0pt}%
          \setlength{\itemsep}{0pt}%
         }%
  }%
  {\end{list}}

%% Define an verbatim-like environment for shell/program transcripts.  This is
%% enclosed in `\AtBeginDocument' because this file is read before we have
%% loaded the `fancyvrb' package (via `declarations.tex').
%%
\AtBeginDocument{%
  \DefineVerbatimEnvironment{transcript}{Verbatim}{xleftmargin=.4in}%
}

%% Define verbatim-like environments and commands for java code and C code.
%%
\AtBeginDocument{%
  \DefineVerbatimEnvironment{javacode}{Verbatim}%
    {obeytabs=true,frame=single,framesep=2ex}%
  \newcommand{\javacodeinput}[2][]{%
    \VerbatimInput[obeytabs=true,frame=single,framesep=2ex,#1]{#2}%
  }
  \DefineVerbatimEnvironment{ccode}{Verbatim}%
    {obeytabs=true,frame=single,framesep=2ex}%
  \newcommand{\ccodeinput}[2][]{%
    \VerbatimInput[obeytabs=true,frame=single,framesep=2ex,#1]{#2}%
  }
}

%% Define an environment for typesetting special warning messages.
%%
\newenvironment{warning}%
  {\begin{center}%
%  \framebox{
   \begin{minipage}[b]{0.90\textwidth}%
   \textbf{WARNING:}%
  }%
  {\end{minipage}%
%  }
   \end{center}%
  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Here are new environments for typesetting our floats (figures and tables).
%% Our floats are formatted:
%%
%%   + with lines above and below (`\fancyfloatrule');
%%   + with text in `\fancyfloatsize'; and
%%   + with default placement `tbp'.
%%
%% This float style was taken from Matthew Flatt's ``TrashyTeXTools'' package.
%% See the file `figure.sty' in that package.

\newcommand{\fancyfloatrule}{\ifwww\else{\noindent\hrulefill\par}\fi}
\newcommand{\fancyfloatsize}{\small}

\newenvironment{fancyfigure}[1][tbp]%
  {\begin{figure}[#1]%
   \fancyfloatsize%
   \fancyfloatrule%
  }
  {\fancyfloatrule%
   \end{figure}}

\newenvironment{fancyfigure*}[1][tbp]%
  {\begin{figure*}[#1]%
   \fancyfloatsize%
   \fancyfloatrule%
  }
  {\fancyfloatrule%
   \end{figure*}}

\newenvironment{fancytable}[1][tbp]%
  {\begin{table}[#1]%
   \fancyfloatsize%
   \fancyfloatrule%
  }
  {\fancyfloatrule%
   \end{table}}

\newenvironment{fancytable*}[1][tbp]%
  {\begin{table*}[#1]%
   \fancyfloatsize%
   \fancyfloatrule%
  }
  {\fancyfloatrule%
   \end{table*}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Redefine `\maketitle' to include our copyright notice.  This is almost
%% identical to the `titlepage' version of `\maketitle' from the LaTeX2e
%% standard `book.cls' file.
%%
\makeatletter
\renewcommand{\maketitle}{\begin{titlepage}%
  \let\footnotesize\small
  \let\footnoterule\relax
  \let \footnote \thanks
  \null\vfil
  \vskip 60\p@
  \begin{center}%
    {\Huge\bfseries \@title \par}%
    \vskip 3em%
    {\Large
     \lineskip .75em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
      \vskip 1.5em%
    {\Large \@date \par}%       % Set date in \large size.
  \end{center}\par
  \vfill                        % <<< new
  \noindent%                    % <<< new
  {\small%                      % <<< new
   \@copyrightnotice@begin%     % <<< new
   \@copyrightnotice%           % <<< new
   \@copyrightnotice@end}%      % <<< new
  \@thanks
  \vfil\null
  \end{titlepage}%
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% End of file.

