summaryrefslogtreecommitdiff
path: root/rdoff/rdoff.h
diff options
context:
space:
mode:
Diffstat (limited to 'rdoff/rdoff.h')
-rw-r--r--rdoff/rdoff.h183
1 files changed, 90 insertions, 93 deletions
diff --git a/rdoff/rdoff.h b/rdoff/rdoff.h
index d6c54b2..68f156b 100644
--- a/rdoff/rdoff.h
+++ b/rdoff/rdoff.h
@@ -10,7 +10,7 @@
* as acknowledgement is given in an appropriate manner to its authors,
* with instructions of how to obtain a copy via ftp.
*/
-
+
#ifndef _RDOFF_H
#define _RDOFF_H
@@ -40,7 +40,6 @@ typedef unsigned int bool;
/* Maximum number of segments that we can handle in one file */
#define RDF_MAXSEGS 64
-
/* Record types that may present the RDOFF header */
#define RDFREC_GENERIC 0
#define RDFREC_RELOC 1
@@ -53,7 +52,6 @@ typedef unsigned int bool;
#define RDFREC_MODNAME 8
#define RDFREC_COMMON 10
-
/*
* Generic record - contains the type and length field, plus a 128 byte
* char array 'data'
@@ -68,80 +66,80 @@ struct GenericRec {
* Relocation record
*/
struct RelocRec {
- byte type; /* must be 1 */
- byte reclen; /* content length */
- byte segment; /* only 0 for code, or 1 for data supported,
- but add 64 for relative refs (ie do not require
- reloc @ loadtime, only linkage) */
- long offset; /* from start of segment in which reference is loc'd */
- byte length; /* 1 2 or 4 bytes */
- uint16 refseg; /* segment to which reference refers to */
+ byte type; /* must be 1 */
+ byte reclen; /* content length */
+ byte segment; /* only 0 for code, or 1 for data supported,
+ but add 64 for relative refs (ie do not require
+ reloc @ loadtime, only linkage) */
+ long offset; /* from start of segment in which reference is loc'd */
+ byte length; /* 1 2 or 4 bytes */
+ uint16 refseg; /* segment to which reference refers to */
};
/*
* Extern/import record
*/
struct ImportRec {
- byte type; /* must be 2 */
- byte reclen; /* content length */
- byte flags; /* SYM_* flags (see below) */
- uint16 segment; /* segment number allocated to the label for reloc
- records - label is assumed to be at offset zero
- in this segment, so linker must fix up with offset
- of segment and of offset within segment */
- char label[EXIM_LABEL_MAX]; /* zero terminated, should be written to file
- until the zero, but not after it */
+ byte type; /* must be 2 */
+ byte reclen; /* content length */
+ byte flags; /* SYM_* flags (see below) */
+ uint16 segment; /* segment number allocated to the label for reloc
+ records - label is assumed to be at offset zero
+ in this segment, so linker must fix up with offset
+ of segment and of offset within segment */
+ char label[EXIM_LABEL_MAX]; /* zero terminated, should be written to file
+ until the zero, but not after it */
};
/*
* Public/export record
*/
struct ExportRec {
- byte type; /* must be 3 */
- byte reclen; /* content length */
- byte flags; /* SYM_* flags (see below) */
- byte segment; /* segment referred to (0/1/2) */
- long offset; /* offset within segment */
- char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
+ byte type; /* must be 3 */
+ byte reclen; /* content length */
+ byte flags; /* SYM_* flags (see below) */
+ byte segment; /* segment referred to (0/1/2) */
+ long offset; /* offset within segment */
+ char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
};
/*
* DLL record
*/
struct DLLRec {
- byte type; /* must be 4 */
- byte reclen; /* content length */
- char libname[MODLIB_NAME_MAX]; /* name of library to link with at load time */
+ byte type; /* must be 4 */
+ byte reclen; /* content length */
+ char libname[MODLIB_NAME_MAX]; /* name of library to link with at load time */
};
/*
* BSS record
*/
struct BSSRec {
- byte type; /* must be 5 */
- byte reclen; /* content length */
- long amount; /* number of bytes BSS to reserve */
+ byte type; /* must be 5 */
+ byte reclen; /* content length */
+ long amount; /* number of bytes BSS to reserve */
};
/*
* Module name record
*/
struct ModRec {
- byte type; /* must be 8 */
- byte reclen; /* content length */
- char modname[MODLIB_NAME_MAX]; /* module name */
+ byte type; /* must be 8 */
+ byte reclen; /* content length */
+ char modname[MODLIB_NAME_MAX]; /* module name */
};
/*
* Common variable record
*/
struct CommonRec {
- byte type; /* must be 10 */
- byte reclen; /* equals 7+label length */
- uint16 segment; /* segment number */
- long size; /* size of common variable */
- uint16 align; /* alignment (power of two) */
- char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
+ byte type; /* must be 10 */
+ byte reclen; /* equals 7+label length */
+ uint16 segment; /* segment number */
+ long size; /* size of common variable */
+ uint16 align; /* alignment (power of two) */
+ char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
};
/* Flags for ExportRec */
@@ -150,7 +148,6 @@ struct CommonRec {
#define SYM_GLOBAL 4
#define SYM_IMPORT 8
-
/*** The following part is used only by the utilities *************************/
#ifdef RDOFF_UTILS
@@ -161,15 +158,15 @@ extern char *strdup(const char *);
#endif
typedef union RDFHeaderRec {
- char type; /* invariant throughout all below */
- struct GenericRec g; /* type 0 */
- struct RelocRec r; /* type == 1 / 6 */
- struct ImportRec i; /* type == 2 / 7 */
- struct ExportRec e; /* type == 3 */
- struct DLLRec d; /* type == 4 */
- struct BSSRec b; /* type == 5 */
- struct ModRec m; /* type == 8 */
- struct CommonRec c; /* type == 10 */
+ char type; /* invariant throughout all below */
+ struct GenericRec g; /* type 0 */
+ struct RelocRec r; /* type == 1 / 6 */
+ struct ImportRec i; /* type == 2 / 7 */
+ struct ExportRec e; /* type == 3 */
+ struct DLLRec d; /* type == 4 */
+ struct BSSRec b; /* type == 5 */
+ struct ModRec m; /* type == 8 */
+ struct CommonRec c; /* type == 10 */
} rdfheaderrec;
struct SegmentHeaderRec {
@@ -177,34 +174,34 @@ struct SegmentHeaderRec {
uint16 type;
uint16 number;
uint16 reserved;
- long length;
+ long length;
/* information built up here */
- long offset;
- byte *data; /* pointer to segment data if it exists in memory */
+ long offset;
+ byte *data; /* pointer to segment data if it exists in memory */
};
typedef struct RDFFileInfo {
- FILE *fp; /* file descriptor; must be open to use this struct */
- int rdoff_ver; /* should be 1; any higher => not guaranteed to work */
+ FILE *fp; /* file descriptor; must be open to use this struct */
+ int rdoff_ver; /* should be 1; any higher => not guaranteed to work */
long header_len;
- long header_ofs;
+ long header_ofs;
- byte *header_loc; /* keep location of header */
- long header_fp; /* current location within header for reading */
+ byte *header_loc; /* keep location of header */
+ long header_fp; /* current location within header for reading */
struct SegmentHeaderRec seg[RDF_MAXSEGS];
- int nsegs;
+ int nsegs;
- long eof_offset; /* offset of the first byte beyond the end of this
- module */
+ long eof_offset; /* offset of the first byte beyond the end of this
+ module */
- char *name; /* name of module in libraries */
- int *refcount; /* pointer to reference count on file, or NULL */
+ char *name; /* name of module in libraries */
+ int *refcount; /* pointer to reference count on file, or NULL */
} rdffile;
-#define BUF_BLOCK_LEN 4088 /* selected to match page size (4096)
- * on 80x86 machines for efficiency */
+#define BUF_BLOCK_LEN 4088 /* selected to match page size (4096)
+ * on 80x86 machines for efficiency */
typedef struct memorybuffer {
int length;
byte buffer[BUF_BLOCK_LEN];
@@ -212,9 +209,9 @@ typedef struct memorybuffer {
} memorybuffer;
typedef struct {
- memorybuffer * buf; /* buffer containing header records */
- int nsegments; /* number of segments to be written */
- long seglength; /* total length of all the segments */
+ memorybuffer *buf; /* buffer containing header records */
+ int nsegments; /* number of segments to be written */
+ long seglength; /* total length of all the segments */
} rdf_headerbuf;
/* segments used by RDOFF, understood by rdoffloadseg */
@@ -230,17 +227,17 @@ extern int rdf_errno;
/* rdf_errno can hold these error codes */
enum {
- /* 0 */ RDF_OK,
- /* 1 */ RDF_ERR_OPEN,
- /* 2 */ RDF_ERR_FORMAT,
- /* 3 */ RDF_ERR_READ,
- /* 4 */ RDF_ERR_UNKNOWN,
- /* 5 */ RDF_ERR_HEADER,
- /* 6 */ RDF_ERR_NOMEM,
- /* 7 */ RDF_ERR_VER,
- /* 8 */ RDF_ERR_RECTYPE,
- /* 9 */ RDF_ERR_RECLEN,
- /* 10 */ RDF_ERR_SEGMENT
+ /* 0 */ RDF_OK,
+ /* 1 */ RDF_ERR_OPEN,
+ /* 2 */ RDF_ERR_FORMAT,
+ /* 3 */ RDF_ERR_READ,
+ /* 4 */ RDF_ERR_UNKNOWN,
+ /* 5 */ RDF_ERR_HEADER,
+ /* 6 */ RDF_ERR_NOMEM,
+ /* 7 */ RDF_ERR_VER,
+ /* 8 */ RDF_ERR_RECTYPE,
+ /* 9 */ RDF_ERR_RECLEN,
+ /* 10 */ RDF_ERR_SEGMENT
};
/* utility functions */
@@ -249,14 +246,14 @@ uint16 translateshort(uint16 in);
char *translatesegmenttype(uint16 type);
/* RDOFF file manipulation functions */
-int rdfopen(rdffile *f,const char *name);
-int rdfopenhere(rdffile *f, FILE *fp, int *refcount, const char *name);
-int rdfclose(rdffile *f);
+int rdfopen(rdffile * f, const char *name);
+int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name);
+int rdfclose(rdffile * f);
int rdffindsegment(rdffile * f, int segno);
-int rdfloadseg(rdffile *f,int segment,void *buffer);
-rdfheaderrec *rdfgetheaderrec(rdffile *f); /* returns static storage */
-void rdfheaderrewind(rdffile *f); /* back to start of header */
-void rdfperror(const char *app,const char *name);
+int rdfloadseg(rdffile * f, int segment, void *buffer);
+rdfheaderrec *rdfgetheaderrec(rdffile * f); /* returns static storage */
+void rdfheaderrewind(rdffile * f); /* back to start of header */
+void rdfperror(const char *app, const char *name);
/* functions to write a new RDOFF header to a file -
use rdfnewheader to allocate a header, rdfaddheader to add records to it,
@@ -266,11 +263,11 @@ void rdfperror(const char *app,const char *name);
to a file, and then rdfdoneheader to dispose of the header */
rdf_headerbuf *rdfnewheader(void);
-int rdfaddheader(rdf_headerbuf *h,rdfheaderrec *r);
-int rdfaddsegment(rdf_headerbuf *h, long seglength);
-int rdfwriteheader(FILE *fp,rdf_headerbuf *h);
-void rdfdoneheader(rdf_headerbuf *h);
+int rdfaddheader(rdf_headerbuf * h, rdfheaderrec * r);
+int rdfaddsegment(rdf_headerbuf * h, long seglength);
+int rdfwriteheader(FILE * fp, rdf_headerbuf * h);
+void rdfdoneheader(rdf_headerbuf * h);
-#endif /* RDOFF_UTILS */
+#endif /* RDOFF_UTILS */
-#endif /* _RDOFF_H */
+#endif /* _RDOFF_H */