%% %% This is file `bytefield.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% bytefield.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright (C) 2011 by Scott Pakin %% %% This file may be distributed and/or modified under the conditions of %% the LaTeX Project Public License, either version 1.3a of this license %% or (at your option) any later version. The latest version of this %% license is in: %% %% http://www.latex-project.org/lppl.txt %% %% and version 1.3c or later is part of all distributions of LaTeX version %% 2006/05/20 or later. %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{bytefield} [2011/01/25 v2.0 Network protocol diagrams] \RequirePackage{calc}[1998/07/07] \RequirePackage{keyval} \def\bf@newdimen#1{\advance\count11 by 1 \ch@ck1\insc@unt\dimen \allocationnumber=\count11 \dimendef#1=\allocationnumber \wlog{\string#1=\string\dimen\the\allocationnumber\space (locally)}% } \AtBeginDocument{% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname locdimen\endcsname\relax \else \let\bf@newdimen\locdimen \fi } \newlength{\bytefield@height} \newif\ifcounting@words \newlength{\bytefield@height@increment} \DeclareRobustCommand{\inc@bytefield@height}[1]{% \setlength{\bytefield@height@increment}{#1}% \global\advance\bytefield@height by \bytefield@height@increment} \newcounter{bits@wide} \newsavebox{\entire@bytefield@picture} \newenvironment{bytefield}[2][]{% \bf@bytefieldsetup{#1}% \setcounter{bits@wide}{#2}% \let\old@nl=\\% \let\amp=&% \catcode`\&=10 \openup -1pt \setlength{\bytefield@height}{0pt}% \setlength{\unitlength}{1pt}% \global\counting@wordstrue \begin{lrbox}{\entire@bytefield@picture}% \renewcommand{\\}{% \unskip \amp\show@wordlabelr\cr \ignorespaces\global\counting@wordstrue\make@lspace\amp}% \vbox\bgroup\ialign\bgroup##\amp##\amp##\cr\amp }{% \amp\show@wordlabelr\cr\egroup\egroup \end{lrbox}% \usebox{\entire@bytefield@picture}} \newcommand*{\bf@bitformatting}{\tiny} \newcommand*{\bf@boxformatting}{\centering} \newlength{\bf@bitwidth} \settowidth{\bf@bitwidth}{\bf@bitformatting{99i}} \newlength{\bf@bitheight} \setlength{\bf@bitheight}{4ex} \newlength{\units@wide} \newlength{\units@tall} \DeclareRobustCommand{\bitbox}[3][lrtb]{% \setlength{\units@wide}{\bf@bitwidth * #2}% \parse@bitbox@arg{#1}% \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\bf@bitheight}{#3}} \DeclareRobustCommand{\wordbox}[3][lrtb]{% \setlength{\units@wide}{\bf@bitwidth * \value{bits@wide}}% \setlength{\units@tall}{\bf@bitheight * #2}% \parse@bitbox@arg{#1}% \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\units@tall}{#3}} \DeclareRobustCommand{\draw@bit@picture}[3]{% \begin{picture}(#1,#2)% \put(0,0){\makebox(#1,#2){\parbox{#1\unitlength}{% \bf@newdimen\height \bf@newdimen\depth \bf@newdimen\totalheight \bf@newdimen\width \height=#2\unitlength \depth=0pt% \totalheight=#2\unitlength \width=#1\unitlength \def\widthunits{#1}% \def\heightunits{#2}% \bf@boxformatting{#3\par}}}}% \ifbitbox@top \put(0,#2){\line(1,0){#1}} \fi \ifbitbox@bottom \put(0,0){\line(1,0){#1}} \fi \ifbitbox@left \put(0,0){\line(0,1){#2}} \fi \ifbitbox@right \put(#1,0){\line(0,1){#2}} \fi \end{picture}% \ifcounting@words \inc@bytefield@height{\unitlength * \real{#2}}% \global\counting@wordsfalse \fi \ignorespaces} \newif\ifbitbox@top \newif\ifbitbox@bottom \newif\ifbitbox@left \newif\ifbitbox@right \def\parse@bitbox@arg#1{% \bitbox@topfalse \bitbox@bottomfalse \bitbox@leftfalse \bitbox@rightfalse \parse@bitbox@sides#1X} \def\parse@bitbox@sides#1{% \ifx#1X% \else \ifx#1t% \bitbox@toptrue \else \ifx#1b% \bitbox@bottomtrue \else \ifx#1l% \bitbox@lefttrue \else \ifx#1r% \bitbox@righttrue \fi \fi \fi \fi \expandafter\parse@bitbox@sides \fi} \newlength{\units@high} \DeclareRobustCommand{\skippedwords}[1][2ex]{% \setlength{\units@wide}{\bf@bitwidth * \value{bits@wide}}% \setlength{\units@high}{1pt * \ratio{\units@wide}{6.0pt}}% \setlength{\units@tall}{#1 + \units@high}% \edef\num@wide{\strip@pt\units@wide}% \edef\num@tall{\strip@pt\units@tall}% \edef\num@high{\strip@pt\units@high}% \begin{picture}(\num@wide,\num@tall) \put(0,\num@tall){\line(6,-1){\num@wide}} \put(\num@wide,0){\line(-6,1){\num@wide}} \put(0,0){\line(0,1){\num@high}} \put(\num@wide,\num@tall){\line(0,-1){\num@high}} \end{picture}% \ifcounting@words \inc@bytefield@height{\unitlength * \real{\num@tall}}% \global\counting@wordsfalse \fi} \DeclareRobustCommand{\bitheader}[2][l]{% \parse@bitbox@arg{lrtb}% \setlength{\units@wide}{\bf@bitwidth * \value{bits@wide}}% \setlength{\units@tall}{\heightof{\bf@bitformatting{1234567890}}}% \setlength{\units@high}{\units@tall * -1}% \def\bit@endianness{#1}% \begin{picture}(\strip@pt\units@wide,\strip@pt\units@tall)% (0,\strip@pt\units@high) \parse@range@list#2,X, \end{picture}% \ifcounting@words \inc@bytefield@height{\unitlength * \real{\strip@pt\units@tall}}% \global\counting@wordsfalse \fi \ignorespaces} \def\parse@range@list#1,{% \ifx X#1 \else \parse@range#1-#1-#1\relax \expandafter\parse@range@list \fi} \newlength{\header@xpos} \newcounter{header@val} \newcounter{max@header@val} \def\parse@range#1-#2-#3\relax{% \setcounter{header@val}{#1} \setcounter{max@header@val}{#2 + 1} \loop \ifnum\value{header@val}<\value{max@header@val}% \if\bit@endianness b% \setlength{\header@xpos}{% \bf@bitwidth * (\value{bits@wide}-\value{header@val}-1)} \else \setlength{\header@xpos}{\bf@bitwidth * \value{header@val}} \fi \put(\strip@pt\header@xpos,0){% \makebox(\strip@pt\bf@bitwidth,\strip@pt\units@tall){% \bf@bitformatting{\theheader@val}}} \addtocounter{header@val}{1} \repeat} \def\bf@leftcurlyshrinkage{5pt} \def\bf@rightcurlyshrinkage{5pt} \def\bf@leftcurlyspace{0pt} \def\bf@rightcurlyspace{0pt} \def\bf@leftlabelspace{0pt} \def\bf@rightlabelspace{0pt} \gdef\bf@leftcurlyspace{1ex} \gdef\bf@rightcurlyspace{1ex} \gdef\bf@leftlabelspace{0.5ex} \gdef\bf@rightlabelspace{0.5ex} \let\bf@leftcurly=\{ \let\bf@rightcurly=\} \newbox{\curly@box} \def\store@rcurly#1#2{% \begingroup \bf@newdimen\curly@height \setlength{\curly@height}{#2 - \bf@rightcurlyshrinkage}% \bf@newdimen\half@curly@height \setlength{\half@curly@height}{0.5\curly@height}% \bf@newdimen\curly@shift \setlength{\curly@shift}{\bf@rightcurlyshrinkage}% \setlength{\curly@shift}{\half@curly@height + 0.5\curly@shift}% \global\sbox{#1}{\raisebox{\curly@shift}{% $\xdef\old@axis{\the\fontdimen22\textfont2}$% $\fontdimen22\textfont2=0pt% \left. \vrule height\half@curly@height width 0pt depth\half@curly@height\right\bf@rightcurly$% $\fontdimen22\textfont2=\old@axis$}}% \endgroup } \def\store@lcurly#1#2{% \begingroup \bf@newdimen\curly@height \setlength{\curly@height}{#2 - \bf@leftcurlyshrinkage}% \bf@newdimen\half@curly@height \setlength{\half@curly@height}{0.5\curly@height}% \bf@newdimen\curly@shift \setlength{\curly@shift}{\bf@leftcurlyshrinkage}% \setlength{\curly@shift}{\half@curly@height + 0.5\curly@shift}% \global\sbox{#1}{\raisebox{\curly@shift}{% $\xdef\old@axis{\the\fontdimen22\textfont2}$% $\fontdimen22\textfont2=0pt% \left\bf@leftcurly \vrule height\half@curly@height width 0pt depth\half@curly@height\right.$% $\fontdimen22\textfont2=\old@axis$}}% \endgroup } \def\show@wordlabelr{} \newlength{\wordlabelr@start} \newlength{\wordlabelr@end} \newenvironment{rightwordgroup}[1]{% \endgroup \global\wordlabelr@start=\bytefield@height \gdef\wordlabelr@text{#1}% \ignorespaces }{% \begingroup \global\wordlabelr@end=\bytefield@height \gdef\show@wordlabelr{% \sbox{\word@label@box}{% \begin{tabular}[b]{@{}l@{}}\wordlabelr@text\end{tabular}}% \settowidth{\label@box@width}{\usebox{\word@label@box}}% \setlength{\label@box@height}{\wordlabelr@end-\wordlabelr@start}% \store@rcurly{\curly@box}{\label@box@height}% \bf@newdimen\total@box@width \setlength{\total@box@width}{% \bf@rightcurlyspace + \widthof{\usebox{\curly@box}} + \bf@rightlabelspace + \label@box@width}% \begin{picture}(\strip@pt\total@box@width,0) \put(0,0){% \hspace*{\bf@rightcurlyspace}% \usebox{\curly@box}% \hspace*{\bf@rightlabelspace}% \makebox(\strip@pt\label@box@width,\strip@pt\label@box@height){% \usebox{\word@label@box}}} \end{picture}% \gdef\show@wordlabelr{}}% \def\@currenvir{rightwordgroup}% \ignorespaces } \newlength{\wordlabell@start} \newlength{\wordlabell@end} \newlength{\total@lbox@width} \gdef\make@lspace{} \newenvironment{leftwordgroup}[1]{% \endgroup \global\wordlabell@start=\bytefield@height \gdef\wordlabell@text{#1}% \sbox{\word@label@box}{% \begin{tabular}[b]{@{}l@{}}\wordlabell@text\end{tabular}}% \settowidth{\label@box@width}{\usebox{\word@label@box}}% \store@lcurly{\curly@box}{5cm}% \setlength{\total@lbox@width}{% \bf@leftcurlyspace + \widthof{\usebox{\curly@box}} + \bf@leftlabelspace + \label@box@width}% \global\total@lbox@width=\total@lbox@width \gdef\make@lspace{% \hspace*{\total@lbox@width}% \gdef\make@lspace{}}% \ignorespaces }{% \begingroup \global\wordlabell@end=\bytefield@height \bf@newdimen\starting@point \setlength{\starting@point}{% -\total@lbox@width - \bf@bitwidth*\value{bits@wide}}% \sbox{\word@label@box}{% \begin{tabular}[b]{@{}l@{}}\wordlabell@text\end{tabular}}% \settowidth{\label@box@width}{\usebox{\word@label@box}}% \setlength{\label@box@height}{\wordlabell@end-\wordlabell@start}% \store@lcurly{\curly@box}{\label@box@height}% \begin{picture}(0,0) \put(\strip@pt\starting@point,0){% \makebox(\strip@pt\label@box@width,\strip@pt\label@box@height){% \usebox{\word@label@box}}% \hspace*{\bf@leftlabelspace}% \usebox{\curly@box}% \hspace*{\bf@leftcurlyspace}} \end{picture}% \def\@currenvir{leftwordgroup}% \ignorespaces} \newlength{\label@box@width} \newlength{\label@box@height} \newsavebox{\word@label@box} \newcommand{\bf@enter@compatibility@mode@i}{% \PackageInfo{bytefield}{Entering version 1 compatibility mode}% \newlength{\bitwidth}% \newlength{\byteheight}% \newlength{\curlyspace}% \newlength{\labelspace}% \newlength{\curlyshrinkage}% \settowidth{\bitwidth}{\tiny 99i}% \setlength{\byteheight}{4ex}% \setlength{\curlyspace}{1ex}% \setlength{\labelspace}{0.5ex}% \setlength{\curlyshrinkage}{5pt}% \let\newbytefield=\bytefield \let\endnewbytefield=\endbytefield \renewenvironment{bytefield}[1]{% \begin{newbytefield}[% bitwidth=\bitwidth, bitheight=\byteheight, curlyspace=\curlyspace, labelspace=\labelspace, curlyshrinkage=\curlyshrinkage]{##1}% }{% \end{newbytefield}% } \def\wordgroupr{\begin{rightwordgroup}} \def\endwordgroupr{\end{rightwordgroup}} \def\wordgroupl{\begin{leftwordgroup}} \def\endwordgroupl{\end{leftwordgroup}} \renewcommand{\bytefieldsetup}[1]{% \PackageError{bytefield}{% The \protect\bytefieldsetup\space macro is not available in\MessageBreak version 1 compatibility mode% }{% Remove [compat1] from the \protect\usepackage{bytefield} line to make \protect\bytefieldsetup\MessageBreak available to this document.\space\space (The document may also need to be modified to use\MessageBreak the new bytefield interface.) }% }% } \newcommand{\wordgroupr}{% \PackageError{bytefield}{% Macros \protect\wordgroupr, \protect\wordgroupl, \protect\endwordgroupr, \MessageBreak and \protect\endwordgroupl\space no longer exist% }{% Starting with version 2.0, bytefield uses \protect\begin{wordgroupr}... \MessageBreak \protect\end{wordgroupr} and \protect\begin{wordgroupl}...% \protect\end{wordgroupl}\MessageBreak to specify word groups and a new \protect\bytefieldsetup\space macro to \MessageBreak change bytefield's various formatting parameters.% }% } \let\endwordgroupr=\wordgroupr \let\wordgroupl=\wordgroupr \let\endwordgroupl=\wordgroupr \define@key{bytefield}{bitwidth}{% \def\bf@bw@arg{#1}% \def\bf@auto{auto}% \ifx\bf@bw@arg\bf@auto \settowidth{\bf@bitwidth}{\bf@bitformatting{99i}}% \else \setlength{\bf@bitwidth}{#1}% \fi } \define@key{bytefield}{bitheight}{\setlength{\bf@bitheight}{#1}} \define@key{bytefield}{bitformatting}{\def\bf@bitformatting{#1}} \define@key{bytefield}{boxformatting}{\def\bf@boxformatting{#1}} \define@key{bytefield}{leftcurly}{\def\bf@leftcurly{#1}} \define@key{bytefield}{rightcurly}{\def\bf@rightcurly{#1}} \define@key{bytefield}{leftcurlyspace}{\def\bf@leftcurlyspace{#1}} \define@key{bytefield}{rightcurlyspace}{\def\bf@rightcurlyspace{#1}} \define@key{bytefield}{curlyspace}{% \def\bf@leftcurlyspace{#1}% \def\bf@rightcurlyspace{#1}% } \define@key{bytefield}{leftlabelspace}{\def\bf@leftlabelspace{#1}} \define@key{bytefield}{rightlabelspace}{\def\bf@rightlabelspace{#1}} \define@key{bytefield}{labelspace}{% \def\bf@leftlabelspace{#1}% \def\bf@rightlabelspace{#1}% } \define@key{bytefield}{leftcurlyshrinkage}{\def\bf@leftcurlyshrinkage{#1}} \define@key{bytefield}{rightcurlyshrinkage}{\def\bf@rightcurlyshrinkage{#1}} \define@key{bytefield}{curlyshrinkage}{% \def\bf@leftcurlyshrinkage{#1}% \def\bf@rightcurlyshrinkage{#1}% } \newcommand{\bf@bytefieldsetup}{\setkeys{bytefield}} \let\bytefieldsetup=\bf@bytefieldsetup \DeclareOption{compat1}{\bf@enter@compatibility@mode@i} \def\bf@package@options{} \DeclareOption*{% \edef\next{% \noexpand\g@addto@macro\noexpand\bf@package@options{,\CurrentOption}% }% \next } \ProcessOptions\relax \expandafter\bf@bytefieldsetup\expandafter{\bf@package@options} \endinput %% %% End of file `bytefield.sty'.