\section{util/dll-src/lx.c File Reference}
\label{lx_8c}\index{util/dll-src/lx.c@{util/dll-src/lx.c}}
Brick\-OS executable file support. 

{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$unistd.h$>$}\par
{\tt \#include $<$fcntl.h$>$}\par
{\tt \#include $<$sys/stat.h$>$}\par
{\tt \#include $<$errno.h$>$}\par
{\tt \#include $<$netinet/in.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$lx.h$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf ASSURED\_\-WRITE}(fd, buf, len)
\item 
\#define {\bf ASSURED\_\-READ}(fd, buf, len)
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int {\bf lx\_\-write} (const {\bf lx\_\-t} $\ast$lx, const unsigned char $\ast$filename)
\begin{CompactList}\small\item\em write a Brick\-OS exectutable to a file \item\end{CompactList}\item 
int {\bf lx\_\-read} ({\bf lx\_\-t} $\ast$lx, const unsigned char $\ast$filename)
\begin{CompactList}\small\item\em read a Brick\-OS executable from a file \item\end{CompactList}\item 
void {\bf lx\_\-relocate} ({\bf lx\_\-t} $\ast$lx, unsigned short base)
\begin{CompactList}\small\item\em relocate a Brick\-OS executable to a new base address (may be called repeatedly). \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Brick\-OS executable file support. 

\begin{Desc}
\item[Author:]Markus L. Noga $<${\tt markus@noga.de}$>$\end{Desc}


Definition in file {\bf lx.c}.

\subsection{Define Documentation}
\index{lx.c@{lx.c}!ASSURED_READ@{ASSURED\_\-READ}}
\index{ASSURED_READ@{ASSURED\_\-READ}!lx.c@{lx.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define ASSURED\_\-READ(fd, buf, len)}\label{lx_8c_a1}


{\bf Value:}

\footnotesize\begin{verbatim}if((rc=read(fd,buf,len))!=(len)) { \
    close(fd); \
    return rc; \
  }
\end{verbatim}\normalsize 


Definition at line 44 of file lx.c.

Referenced by lx\_\-read().\index{lx.c@{lx.c}!ASSURED_WRITE@{ASSURED\_\-WRITE}}
\index{ASSURED_WRITE@{ASSURED\_\-WRITE}!lx.c@{lx.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define ASSURED\_\-WRITE(fd, buf, len)}\label{lx_8c_a0}


{\bf Value:}

\footnotesize\begin{verbatim}if((rc=write(fd,buf,len))!=(len)) { \
    close(fd); \
    return rc; \
  }
\end{verbatim}\normalsize 


Definition at line 38 of file lx.c.

Referenced by lx\_\-write().

\subsection{Function Documentation}
\index{lx.c@{lx.c}!lx_read@{lx\_\-read}}
\index{lx_read@{lx\_\-read}!lx.c@{lx.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int lx\_\-read ({\bf lx\_\-t} $\ast$ {\em lx}, const unsigned char $\ast$ {\em filename})}\label{lx_8c_a3}


read a Brick\-OS executable from a file 



Definition at line 87 of file lx.c.

References ASSURED\_\-READ, lx\_\-t::data\_\-size, malloc(), lx\_\-t::num\_\-relocs, lx\_\-t::reloc, strcmp(), lx\_\-t::text, and lx\_\-t::text\_\-size.

Referenced by main().\index{lx.c@{lx.c}!lx_relocate@{lx\_\-relocate}}
\index{lx_relocate@{lx\_\-relocate}!lx.c@{lx.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void lx\_\-relocate ({\bf lx\_\-t} $\ast$ {\em lx}, unsigned short {\em base})}\label{lx_8c_a4}


relocate a Brick\-OS executable to a new base address (may be called repeatedly). 



Definition at line 139 of file lx.c.

References lx\_\-t::base, lx\_\-t::num\_\-relocs, lx\_\-t::reloc, and lx\_\-t::text.

Referenced by main().\index{lx.c@{lx.c}!lx_write@{lx\_\-write}}
\index{lx_write@{lx\_\-write}!lx.c@{lx.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int lx\_\-write (const {\bf lx\_\-t} $\ast$ {\em lx}, const unsigned char $\ast$ {\em filename})}\label{lx_8c_a2}


write a Brick\-OS exectutable to a file 



Definition at line 51 of file lx.c.

References ASSURED\_\-WRITE, lx\_\-t::data\_\-size, lx\_\-t::num\_\-relocs, lx\_\-t::reloc, lx\_\-t::text, and lx\_\-t::text\_\-size.

Referenced by main().