File: c_lib.tex

package info (click to toggle)
bibtool 2.57%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,268 kB
  • ctags: 1,424
  • sloc: ansic: 10,709; perl: 6,205; makefile: 477; sh: 352; tcl: 51
file content (324 lines) | stat: -rw-r--r-- 11,203 bytes parent folder | download
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
%%*** c_lib.tex ***************************************************************
%%
%% This file is part of BibTool.
%% It is distributed under the Creative Commons Attribution-Share
%% Alike 3.0 License.
%%
%% (c) 1997-2014 Gerd Neugebauer
%%
%% Net: gene@gerd-neugebauer.de
%%
%%-----------------------------------------------------------------------------
%% Usage:  latex     c_lib
%%         makeindex -s bibtool.ist bibtool
%%         latex     c_lib
%%*****************************************************************************

\NeedsTeXFormat{LaTeX2e}
\documentclass[11pt,a4paper]{scrbook}

\usepackage{array,shortvrb,makeidx}
\usepackage[colorlinks=true,
            linkcolor=blue,
            citecolor=blue]{hyperref}

\input{config}

\hypersetup{pdftitle={BibTool C Programmers Manual}}
\hypersetup{pdfauthor={Gerd Neugebauer}}
\hypersetup{pdfsubject={Version \Version}}

\makeindex

\parindent=0pt
\parskip=1ex

\makeatletter
\newcommand\ClassFont{\scriptsize\sf}
\newcommand\File[2]{\section{The File \texttt{#1}}\label{sec:#2}}
\newcommand\Header[2]{\section{The Header File \texttt{#1}}\label{sec:#2}}
\newcommand\Module[2]{\section{The Module \texttt{#1}}\label{sec:#2}}
\newcommand\Fct[1]{\textbf{\large #1}}
\newcommand\Mac[1]{\textbf{\large #1}}
\newcommand\Var[1]{\textbf{#1}}
\newcommand\Type[1]{\textbf{#1}}
\newenvironment{Function}[2]{%
  \begin{description}\item[\texttt{#1()}]\index{#2()|tt}\ 
    \hfill{\ClassFont Function}\\%
    }{\end{description}}
\newenvironment{Macro}[2]{%
  \begin{description}\item[\texttt{#1()}]\index{#2()|sf}\ 
    \hfill{\ClassFont Macro}\\%
    }{\end{description}}
\newenvironment{Constant}[2]{%
  \begin{description}\item[\texttt{#1}]\index{#2|sf}\ 
    \hfill{\ClassFont Macro}\\%
    }{\end{description}}
\newenvironment{Variable}[2]{%
  \begin{description}\item[\texttt{#1}]\index{#2|tt}\ 
    \hfill{\ClassFont Variable}\\%
    }{\end{description}}
\newenvironment{Result}{%
  \begin{description}\item[\textmd{Returns:}] }{\end{description}}
\newenvironment{Arguments}[1]{\begingroup\tt\tabcolsep=0pt
  \begin{tabular*}{.925\textwidth}{ll@{\extracolsep{\fill}}>{\it\small}p{.55\textwidth}}
    #1%
    }{\end{tabular*}\endgroup\par}

\newenvironment{Typedef}[2]{\begin{description}%
  \item[#1]\ \hfill{\ClassFont Type}\\}{}
\newcommand\STRUCT[1]{\par
    \texttt{typedef struct}%
    \textbf{\ #1 }
    \texttt{\char123}\par
    \begingroup\tt\tabcolsep=0pt\rule{1em}{0pt}%
    \begin{tabular*}{.9\textwidth}%
      {ll@{\extracolsep{\fill}}>{\it\small}p{.55\textwidth}}%
}

\newcommand\EndSTRUCT[1]{\end{tabular*}\endgroup\par
  \texttt{\char125}
  #1;
  \end{description}
  }
\newcommand\Member[1]{\textbf{#1}}
\makeatother

\MakeShortVerb{|}

\newcommand\Ccomment[1]{\hfill\parbox[t]{.5\textwidth}{\it/* #1\hfill*/}}

\newcommand\BibTool{{\sc Bib\hskip-.1em\-%
        \mbox{T\hskip-.15emo\hskip-.05emo\hskip-.05eml}}}
\newcommand\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
        T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}

\makeatletter%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
\def\ps@headings{\let\@mkboth\markboth
  \def\@oddfoot{}\def\@evenfoot{}
  \def\@evenhead{\vbox{\vss\hbox to \textwidth{\rm\thepage \hss
        {\scriptsize\sc\ \leftmark}}\kern 1.5mm\hrule depth 0.2 true pt}}
  \def\@oddhead{\vbox{\vss\hbox to \textwidth{\rm{\scriptsize\sc \rightmark\ }
        \hss \thepage}\kern 1.5mm\hrule depth 0.2 true pt}}
  \def\chaptermark##1{\markboth {\ifnum \c@secnumdepth>\m@ne
     \thechapter. \ \fi ##1}{}}
  \def\sectionmark##1{\markright
                      {\ifnum \c@secnumdepth >\z@ \thesection. \ \fi ##1}}}

\pagestyle{headings}
\addtolength{\headheight}{2pt}
\makeatother

\newfont\cminch{cminch}
\ifx\chaptername\relax\else
\renewcommand\chaptername{\cminch}
\renewcommand\appendixname{\cminch}
\fi
\newcommand\rfill[1]{\leaders\hrule height #1\hfill}

\newcommand\Link[2]{\texttt{#2}}
\newcommand\email[1]{\texttt{#1}}

\newcommand\INCOMPLETE{\begin{center}
    \unitlength=1mm\framebox(80,10)\textsf{To be completed.}
  \end{center}}

\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\thispagestyle{empty}
\null\vfill
{\begin{center}
\rule{\textwidth}{5pt}%
\bigskip\par
\hbox to \textwidth{\cminch \hss B\hss I\hss B\hss T\hss O\hss O\hss L\hss}
\medskip\par\normalsize
\mbox{}\rfill{5pt}\ A Tool to Manipulate \BibTeX\ Files\ \rfill{5pt}\null
%\medskip\par\normalsize          Version  \Version
\vfill {\Huge\bf C Programmers Manual}\vfill
{\LARGE\it        $\cal G$\kern-.1emerd $\cal N$\kern-.2emeugebauer}
\vfill\vfill
\begin{minipage}{.8\textwidth}\small
  \begin{center} \bf Abstract \end{center}
  
  \BibTool{} provides a library of useful C functions to manipulate
  \BibTeX{} files.  This library has been used to implement the
  \BibTool{} program. This document describes This library and allows
  you to write C programs dealing with \BibTeX{} files.
\end{minipage}\vfill\vfill

\textsf{\small --- This documentation is still in a rudimentary form and
  needs additional efforts. ---}
\end{center}}
%------------------------------------------------------------------------------
\newpage
\noindent
\begin{minipage}{\textwidth}\parskip=1ex
This file is part of \BibTool{} Version \Version
\medskip

Copyright {\copyright}\Year{} Gerd Neugebauer
\medskip

\BibTool{} is  free software; you can redistribute  it and/or  modify it under
the terms of the GNU General Public License as published  by the Free Software
Foundation; either version 1, or (at your option) any later version.

\BibTool{} is distributed in the hope that it will be  useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received  a copy of the GNU  General Public License along with
this documentation; see the file COPYING.  If not,  write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
\end{minipage}
\vfill\par\noindent
Gerd Neugebauer\\
Im Lerchelsb\"ohl 5\\
64521 Gro\ss-Gerau (Germany)\smallskip\par\noindent
WWW: \Link{http://www.gerd-neugebauer.de/}{http://www.gerd-neugebauer.de/}
\smallskip\par\noindent
Net: \email{gene@gerd-neugebauer.de}
%------------------------------------------------------------------------------
\tableofcontents

\chapter{Introduction}

The \BibTool{} C library provides functions to deal with \BibTeX{}
files.  These functions are described in this document. Thus it should
be fairly easy to write new C program which handle \BibTeX{}
files. The reader is assumed to be familiar with \BibTeX{} files. this
documentation will not repeat an introduction into \BibTeX.

This documentation can not only be used to write new C programs
dealing with \BibTeX{} files but also to understand \BibTool---The
Program which serves as one example for using the \BibTool C library.
In any case it is essential to understand some of the underlying
concepts. Thus it is vital to read some sections very carefully.
Especially the section





The \BibTool{} program uses the \BibTool{} C library. Well, in fact it
is the other way round. Historically the \BibTool{} program was first
and then the library has been extracted from it. Nevertheless the
\BibTool{} program can serve as an example how the \BibTool{} C
libary can be used.

\input c_main

\chapter{The \BibTool{} C Library}

\input c


\chapter{Creating and Using the \BibTool{} C Library}

\section{Creating the \BibTool{} C Library}

Creating the \BibTool{} library should not be too hard. Mainly make
\BibTool{} in the main directory according to the instructions given
there. As a side effect various object files are created. These object
files---except the one for main.c---have to be put into the library.

For UNIX this is prepared in the makefile. Usually an invocation of
make should be enough:

\begin{verbatim}
  make libbib.a
\end{verbatim}

This invocation of make is in fact the same as the following two
commands:

\begin{verbatim}
  ar r libbib.a $OFILES
  ranlib libbib.a
\end{verbatim}

Here |$OFILES| denotes the list of object files as described above. On
some systems no ranlib program is present and needed. In this case the
second command can be omitted.

For other operating systems I simply do not know how things work
there. I would be grateful to receive descriptions what to do there.


\section{Using the \BibTool{} C Library}

%First of all you need to include the appropriate header file which
%provides all



If you have written a program which uses the \BibTool{} C Library you
have to include the library into the linking list. In addition the
directory where the library can be found has to be specified.  On UNIX
this can be done with the compiler switches |-l| and |-L|
respectively.  Thus consider you have a program named |mybib.c| and
you have created the object file |mybib.o| for it. The linking step
can be performed with the following command:

\begin{verbatim}
  cc mybib.o -L$DIR -lbib -o mybib
\end{verbatim}

Here |$DIR| denotes the path containing the file |libbib.a|. This path
can be omitted if the library has been installed in a ``standard''
place like |/usr/lib|.




\chapter{Coding Standards}

Several tools are used for the development of \BibTool. Mostly they
are home grown---maybe they will be replaced by some wider used tools
some day. Among those tools are indentation routines for Emacs to
format the comments contained in the source. There is also a Lisp
function to generate the function prototypes contained in the header
files and sometimes in the C files as well. And finally there is a
Program to extract the documentation from the source files and
generate a printable manual.

All those support programs rely on standards for coding. Some of those
standards have been develped independantly but should be used for
consistency. In the following sections these coding standards are
described. 

\section{K\&R-C vs. ANSI-C}

\BibTool{} tries hard to be portable to wide variety of C systems.
Thus it can not be assumed that an ANSI C compiler is at hand. As a
consequence the function heads are written in the old style which is
also tolerated by ANSI compliant compilers. This means that the
argument types are given after the argument list.

Here it is essential that the arguments type declarations are given in
the same order as the arguments of the function. Each type variable
must have a new type declaration in a line by it's own. This feature
is used by the program which extracts the function prototypes.

Those function heads are use to generate function prototypes which can
be understood by ANSI-C compilers as well as by of K\&R
compilers. This is achieved by the od trick to introduce a macro which
expands to nothing on the old compilers and to its aregument on ANSI
compilers. This macro is defined appropriately according to the
existence of the macro \verb|__STDC__| which should indicate an ANSI
compliant compiler.


%\section{Indentation}




\printindex

\end{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Local Variables: 
% mode: latex
% TeX-master: nil
% End: