summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/genmisc/hexdump.sty
blob: 7246ef87f911e789d4add079e9e4aac5b0a4d4fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
%%% File Hexdump.sty
%%% Reads an ASCII hexdump file and puts it formated into 
%%% the document
%%%
%%% Author : Thomas Hillebrand  (thillebrand@my-deja.com)
%%% Date   : 04/17/2000
%%% Version: 0.1
%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{hexdump}[2000/21/06 v0.1 format hexdumps]
%
% Test weather the package 'moreverb.sty' is loaded
%
\RequirePackage{moreverb}
%
%
% Dump title, defaults to 'Dump'
% The command \dumpname{} sets the title of the dump
%
\newcommand{\dump@head}{Dump}  % Default title is 'Dump'
\newcommand{\dumpname}[1]{\renewcommand{\dump@head}{#1}}
%
% Set the fontsize, default is \scriptsize,
% use \dumpfontsize{<size>} to change it
%
\newcommand{\dump@font@size}{\scriptsize}
\newcommand{\dumpfontsize}[1]{\renewcommand{\dump@font@size}{#1}}
%
% Calculate the width
%
\newlength{\dumpwidth}  % Variable for textwidth
\settowidth{\dumpwidth}%
   {\dump@font@size\texttt{00000000\space\space{}FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FFFFFFFFFFFFFFFF}}
% The double \space puts two spaces between address and values
%
% Define new counter, arabic numbers
% reset counter, if chapter changes
%
\newcounter{dumpcount}[chapter]
\renewcommand{\thedumpcount}{\thechapter.\arabic{dumpcount}\space}
%
% Now to the page 'list of dumps'
% Set titleword with \dumptocname, this is used for the lod page.
%
\newcommand{\dump@word}{directory}
\newcommand{\dumptocname}[1]{\renewcommand{\dump@word}{#1}}
%
% Define own list of dumps, use \listofdumps
% First let's define the top line of the list of dumps
% then define an entry in the lod file
\newcommand{\listofdumps}{\chapter*{\dump@head\dump@word}\@starttoc{lod}}
\newcommand{\dcaption}[1]{\addcontentsline{lod}{table}%
           {\protect\numberline{\thedumpcount}#1}#1}
%
% Now to the main thing: the dump itself.
% Define \inputdump{<file>}{<caption>}
% command to read hex-dump file and put it formatted into document
% Parameter #1 : Floatposition - this is optional
% Parameter #2 : Filename
% Parameter #3 : Caption
%
% A label is also defined: use \ref{dumpname:filename} (see example).
%
\newcommand{\inputdump}[3][htbp]{%
  \begin{table}[#1]
    \begin{center}
    \begin{minipage}{\dumpwidth}
      \refstepcounter{dumpcount}
      \rule[0.1\baselineskip]{\dumpwidth}{.8pt}
        \dump@head \space \thedumpcount{}:\space\dcaption{#3}
        \label{\dump@head:#2} % Label contains title and filename
        \newline
      \rule[0.33\baselineskip]{\dumpwidth}{.8pt}
      \ttfamily\dump@font@size
        \verbatimtabinput{#2}
      \rule[0.75\baselineskip]{\dumpwidth}{.8pt}
    \end{minipage}
   \end{center}

  \end{table}
} % end newcommand
%
% End of file hexdump.sty
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Here's a sample tex file
%
%\documentclass{book} 
%\usepackage{hexdump}
%
%\dumpsize{\tiny} % will give _very_ small dumps, better use default setting
%\dumptocname{directoy}
%\dumpname{Dump}
%
%\begin{document}
%\listofdumps % the title will be 'Dumpdirectory', see above
%
%\capter{Bar}
%
%\inputdump{test.hex} % assumed that file test.hex contains the dump
%
%The dump is shown in dump \ref{Dump:test.hex}.
%\end{document}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Now to the legal stuff:
%
% Copyright (c) Thomas Hillebrand 2000
%
% Usage of this file is unlimited, but I guarantee for nothing - except
% that it uses space on your harddisk. As usual, use this file at your
% own risk.
%
% You are encouraged to modify this file, but please be so kind to e-mail
% me your modifications. Maybe they are included in the next release...
%