93 lines
3.7 KiB
TeX
93 lines
3.7 KiB
TeX
\subsection{Data Number}
|
|
In some points of its life SICS has to write data files. The file names
|
|
usually consist of a header, a serial number and an indicator for the
|
|
year. The serial number must be unique and steadliy increasing. In order to
|
|
achieve this, the serial number are written into a file after any change.
|
|
Incrementing the serial number thus involves the following steps:
|
|
\begin{itemize}
|
|
\item Open file and read current number.
|
|
\item Increment number
|
|
\item Write File and close
|
|
\end{itemize}
|
|
This little task is implemented in this module.
|
|
|
|
The interface to this looks like:
|
|
\begin{flushleft} \small
|
|
\begin{minipage}{\linewidth} \label{scrap1}
|
|
$\langle$dni {\footnotesize ?}$\rangle\equiv$
|
|
\vspace{-1ex}
|
|
\begin{list}{}{} \item
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ typedef struct __DataNumber *pDataNumber;@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ pDataNumber CreateDataNumber(char *pFilename);@\\
|
|
\mbox{}\verb@ void DeleteDataNumber(void *pData);@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ int IncrementDataNumber(pDataNumber self, int *iYear);@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ int DecrementDataNumber(pDataNumber self);@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ int DNWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
|
|
\mbox{}\verb@ int argc, char *argv[]);@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ int DEWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
|
|
\mbox{}\verb@ int argc, char *argv[]);@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ int DNFactory(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
|
|
\mbox{}\verb@ int argc, char *argv[]);@\\
|
|
\mbox{}\verb@@$\diamond$
|
|
\end{list}
|
|
\vspace{-1ex}
|
|
\footnotesize\addtolength{\baselineskip}{-1ex}
|
|
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
|
|
\item Macro referenced in scrap ?.
|
|
\end{list}
|
|
\end{minipage}\\[4ex]
|
|
\end{flushleft}
|
|
\begin{description}
|
|
\item [CreateDataNumber] creates a data number data structure. It checks if
|
|
the file requested as parameter exists and asserts if not. Returns a pointer
|
|
on success, NULL else.
|
|
\item [DeleteDataNumber] deletes a data number structure form memory.
|
|
\item [IncrementDataNumber] is the main working function of this module.
|
|
It performs the steps listed above. It returns a new id for the data number
|
|
in case of success, a negative value otherwise. iYear is filled with a value
|
|
for the year.
|
|
\item[DecrementDataNumber] decrements the data number and is used for
|
|
implementing the killdata function. Whis is the invalidation of a
|
|
data file by overwriting it.
|
|
\item[DNWrapper] is the wrapper function which makes DataNumber accessible
|
|
from within SICS.
|
|
\item[DEWrapper] is the wrapper for the killdata functionality.
|
|
\item [DNFactory] is the SICS factory function which creates a Data Number
|
|
object from the initialisation file. Only parameter is the filename.
|
|
\end{description}
|
|
|
|
\begin{flushleft} \small
|
|
\begin{minipage}{\linewidth} \label{scrap2}
|
|
\verb@"danu.h"@ {\footnotesize ? }$\equiv$
|
|
\vspace{-1ex}
|
|
\begin{list}{}{} \item
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@/*-----------------------------------------------------------------------@\\
|
|
\mbox{}\verb@ D A T A N U M B E R@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ A module to provide a unique data number for data file writing.@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ Mark Koennecke, Juli 1997@\\
|
|
\mbox{}\verb@ @\\
|
|
\mbox{}\verb@ copyright: see implementation file.@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@---------------------------------------------------------------------------*/@\\
|
|
\mbox{}\verb@#ifndef SICSDATANUMBER@\\
|
|
\mbox{}\verb@#define SICSDATANUMBER@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@@$\langle$dni {\footnotesize ?}$\rangle$\verb@@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@#endif@\\
|
|
\mbox{}\verb@@$\diamond$
|
|
\end{list}
|
|
\vspace{-2ex}
|
|
\end{minipage}\\[4ex]
|
|
\end{flushleft}
|