aboutsummaryrefslogtreecommitdiffstats
path: root/rdoff/rdoff.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2005-01-15 22:15:51 +0000
committerH. Peter Anvin <hpa@zytor.com>2005-01-15 22:15:51 +0000
commite2c80181b6a6338f0381fc9c44fae32d8b8a20fc (patch)
treef9919ba3c0489d886c9a79e73257ef6a4584aafc /rdoff/rdoff.c
parent5180bc8a598aa5bff7bfb3726771e5bf348e61a2 (diff)
downloadnasm-e2c80181b6a6338f0381fc9c44fae32d8b8a20fc.tar.gz
nasm-e2c80181b6a6338f0381fc9c44fae32d8b8a20fc.tar.xz
nasm-e2c80181b6a6338f0381fc9c44fae32d8b8a20fc.zip
Apply Nindent to all .c and .h filesnasm-0.98.39LATEST
Diffstat (limited to 'rdoff/rdoff.c')
-rw-r--r--rdoff/rdoff.c517
1 files changed, 262 insertions, 255 deletions
diff --git a/rdoff/rdoff.c b/rdoff/rdoff.c
index bfdb9cc1..8f19702d 100644
--- a/rdoff/rdoff.c
+++ b/rdoff/rdoff.c
@@ -41,87 +41,89 @@
* how long it is).
* ======================================================================== */
-
-memorybuffer * newmembuf()
+memorybuffer *newmembuf()
{
- memorybuffer * t;
+ memorybuffer *t;
t = malloc(sizeof(memorybuffer));
- if (!t) return NULL;
+ if (!t)
+ return NULL;
t->length = 0;
t->next = NULL;
return t;
}
-void membufwrite(memorybuffer *const b, void *data, int bytes)
+void membufwrite(memorybuffer * const b, void *data, int bytes)
{
uint16 w;
long l;
- if (b->next) { /* memory buffer full - use next buffer */
- membufwrite(b->next,data,bytes);
- return;
+ if (b->next) { /* memory buffer full - use next buffer */
+ membufwrite(b->next, data, bytes);
+ return;
}
if ((bytes < 0 && b->length - bytes > BUF_BLOCK_LEN)
- || (bytes > 0 && b->length + bytes > BUF_BLOCK_LEN))
- {
-
- /* buffer full and no next allocated... allocate and initialise next
- * buffer */
- b->next = newmembuf();
- membufwrite(b->next,data,bytes);
- return;
+ || (bytes > 0 && b->length + bytes > BUF_BLOCK_LEN)) {
+
+ /* buffer full and no next allocated... allocate and initialise next
+ * buffer */
+ b->next = newmembuf();
+ membufwrite(b->next, data, bytes);
+ return;
}
- switch(bytes) {
- case -4: /* convert to little-endian */
- l = * (long *) data ;
- b->buffer[b->length++] = l & 0xFF;
- l >>= 8 ;
- b->buffer[b->length++] = l & 0xFF;
- l >>= 8 ;
- b->buffer[b->length++] = l & 0xFF;
- l >>= 8 ;
- b->buffer[b->length++] = l & 0xFF;
- break;
+ switch (bytes) {
+ case -4: /* convert to little-endian */
+ l = *(long *)data;
+ b->buffer[b->length++] = l & 0xFF;
+ l >>= 8;
+ b->buffer[b->length++] = l & 0xFF;
+ l >>= 8;
+ b->buffer[b->length++] = l & 0xFF;
+ l >>= 8;
+ b->buffer[b->length++] = l & 0xFF;
+ break;
case -2:
- w = * (uint16 *) data ;
- b->buffer[b->length++] = w & 0xFF;
- w >>= 8 ;
- b->buffer[b->length++] = w & 0xFF;
- break;
+ w = *(uint16 *) data;
+ b->buffer[b->length++] = w & 0xFF;
+ w >>= 8;
+ b->buffer[b->length++] = w & 0xFF;
+ break;
default:
- while(bytes--) {
- b->buffer[b->length++] = *(* (unsigned char **) &data);
-
- (* (unsigned char **) &data)++ ;
- }
- break;
+ while (bytes--) {
+ b->buffer[b->length++] = *(*(unsigned char **)&data);
+
+ (*(unsigned char **)&data)++;
+ }
+ break;
}
}
-void membufdump(memorybuffer *b,FILE *fp)
+void membufdump(memorybuffer * b, FILE * fp)
{
- if (!b) return;
+ if (!b)
+ return;
+
+ fwrite(b->buffer, 1, b->length, fp);
- fwrite (b->buffer, 1, b->length, fp);
-
- membufdump(b->next,fp);
+ membufdump(b->next, fp);
}
-int membuflength(memorybuffer *b)
+int membuflength(memorybuffer * b)
{
- if (!b) return 0;
+ if (!b)
+ return 0;
return b->length + membuflength(b->next);
}
-void freemembuf(memorybuffer *b)
+void freemembuf(memorybuffer * b)
{
- if (!b) return;
+ if (!b)
+ return;
freemembuf(b->next);
free(b);
}
@@ -135,7 +137,7 @@ void freemembuf(memorybuffer *b)
*
* translate from little endian to local representation
*/
-long translatelong(long in)
+long translatelong(long in)
{
long r;
unsigned char *i;
@@ -149,11 +151,11 @@ long translatelong(long in)
return r;
}
-uint16 translateshort(uint16 in)
+uint16 translateshort(uint16 in)
{
uint16 r;
- unsigned char * i;
-
+ unsigned char *i;
+
i = (unsigned char *)&in;
r = (i[1] << 8) + i[0];
@@ -171,17 +173,17 @@ static char *knownsegtypes[8] = {
char *translatesegmenttype(uint16 type)
{
if (type < 8)
- return knownsegtypes[type];
+ return knownsegtypes[type];
if (type < 0x0020)
- return "reserved";
+ return "reserved";
if (type < 0x1000)
- return "reserved - Moscow";
+ return "reserved - Moscow";
if (type < 0x8000)
- return "reserved - system dependant";
+ return "reserved - system dependant";
if (type < 0xFFFF)
- return "reserved - other";
+ return "reserved - other";
if (type == 0xFFFF)
- return "invalid type code";
+ return "invalid type code";
return "type code out of range";
}
@@ -190,17 +192,17 @@ const char *RDOFFId = RDOFF2_SIGNATURE;
/* Error messages. Must correspond to the codes defined in rdoff.h */
const char *rdf_errors[11] = {
- /* 0 */ "no error occurred",
- /* 1 */ "could not open file",
- /* 2 */ "invalid file format",
- /* 3 */ "error reading file",
- /* 4 */ "unknown error",
- /* 5 */ "header not read",
- /* 6 */ "out of memory",
- /* 7 */ "RDOFF v1 not supported",
- /* 8 */ "unknown extended header record",
- /* 9 */ "header record of known type but unknown length",
- /* 10 */ "no such segment"
+ /* 0 */ "no error occurred",
+ /* 1 */ "could not open file",
+ /* 2 */ "invalid file format",
+ /* 3 */ "error reading file",
+ /* 4 */ "unknown error",
+ /* 5 */ "header not read",
+ /* 6 */ "out of memory",
+ /* 7 */ "RDOFF v1 not supported",
+ /* 8 */ "unknown extended header record",
+ /* 9 */ "header record of known type but unknown length",
+ /* 10 */ "no such segment"
};
int rdf_errno = 0;
@@ -209,18 +211,18 @@ int rdf_errno = 0;
The library functions
======================================================================== */
-int rdfopen(rdffile *f, const char *name)
+int rdfopen(rdffile * f, const char *name)
{
- FILE * fp;
+ FILE *fp;
- fp = fopen(name,"rb");
+ fp = fopen(name, "rb");
if (!fp)
- return rdf_errno = RDF_ERR_OPEN;
+ return rdf_errno = RDF_ERR_OPEN;
- return rdfopenhere(f,fp,NULL,name);
+ return rdfopenhere(f, fp, NULL, name);
}
-int rdfopenhere(rdffile *f, FILE *fp, int *refcount, const char *name)
+int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name)
{
char buf[8];
long initpos;
@@ -229,84 +231,87 @@ int rdfopenhere(rdffile *f, FILE *fp, int *refcount, const char *name)
if (translatelong(0x01020304) != 0x01020304) {
/* fix this to be portable! */
- fputs("*** this program requires a little endian machine\n",stderr);
- fprintf(stderr,"01020304h = %08lxh\n",translatelong(0x01020304));
+ fputs("*** this program requires a little endian machine\n",
+ stderr);
+ fprintf(stderr, "01020304h = %08lxh\n", translatelong(0x01020304));
exit(3);
}
f->fp = fp;
initpos = ftell(fp);
- fread(buf,6,1,f->fp); /* read header */
+ fread(buf, 6, 1, f->fp); /* read header */
buf[6] = 0;
- if (strcmp(buf,RDOFFId)) {
- fclose(f->fp);
- if (!strcmp(buf,"RDOFF1"))
- return rdf_errno = RDF_ERR_VER;
- return rdf_errno = RDF_ERR_FORMAT;
+ if (strcmp(buf, RDOFFId)) {
+ fclose(f->fp);
+ if (!strcmp(buf, "RDOFF1"))
+ return rdf_errno = RDF_ERR_VER;
+ return rdf_errno = RDF_ERR_FORMAT;
}
- if (fread(&l,1,4,f->fp) != 4 || fread(&f->header_len,1,4,f->fp) != 4) {
- fclose(f->fp);
- return rdf_errno = RDF_ERR_READ;
+ if (fread(&l, 1, 4, f->fp) != 4
+ || fread(&f->header_len, 1, 4, f->fp) != 4) {
+ fclose(f->fp);
+ return rdf_errno = RDF_ERR_READ;
}
f->header_ofs = ftell(f->fp);
f->eof_offset = f->header_ofs + translatelong(l) - 4;
- if (fseek(f->fp,f->header_len,SEEK_CUR)) {
- fclose(f->fp);
- return rdf_errno = RDF_ERR_FORMAT; /* seek past end of file...? */
+ if (fseek(f->fp, f->header_len, SEEK_CUR)) {
+ fclose(f->fp);
+ return rdf_errno = RDF_ERR_FORMAT; /* seek past end of file...? */
}
- if (fread(&s,1,2,f->fp) != 2) {
- fclose(f->fp);
- return rdf_errno = RDF_ERR_READ;
+ if (fread(&s, 1, 2, f->fp) != 2) {
+ fclose(f->fp);
+ return rdf_errno = RDF_ERR_READ;
}
f->nsegs = 0;
while (s != 0) {
- f->seg[f->nsegs].type = s;
- if (fread(&f->seg[f->nsegs].number,1,2,f->fp) != 2 ||
- fread(&f->seg[f->nsegs].reserved,1,2,f->fp) != 2 ||
- fread(&f->seg[f->nsegs].length,1,4,f->fp) != 4) {
- fclose(f->fp);
- return rdf_errno = RDF_ERR_READ;
- }
-
- f->seg[f->nsegs].offset = ftell(f->fp);
- if (fseek(f->fp,f->seg[f->nsegs].length,SEEK_CUR)) {
- fclose(f->fp);
- return rdf_errno = RDF_ERR_FORMAT;
- }
- f->nsegs++;
-
- if (fread(&s,1,2,f->fp) != 2) {
- fclose(f->fp);
- return rdf_errno = RDF_ERR_READ;
- }
+ f->seg[f->nsegs].type = s;
+ if (fread(&f->seg[f->nsegs].number, 1, 2, f->fp) != 2 ||
+ fread(&f->seg[f->nsegs].reserved, 1, 2, f->fp) != 2 ||
+ fread(&f->seg[f->nsegs].length, 1, 4, f->fp) != 4) {
+ fclose(f->fp);
+ return rdf_errno = RDF_ERR_READ;
+ }
+
+ f->seg[f->nsegs].offset = ftell(f->fp);
+ if (fseek(f->fp, f->seg[f->nsegs].length, SEEK_CUR)) {
+ fclose(f->fp);
+ return rdf_errno = RDF_ERR_FORMAT;
+ }
+ f->nsegs++;
+
+ if (fread(&s, 1, 2, f->fp) != 2) {
+ fclose(f->fp);
+ return rdf_errno = RDF_ERR_READ;
+ }
}
- if (f->eof_offset != ftell(f->fp) + 8) { /* +8 = skip null segment header */
- fprintf(stderr, "warning: eof_offset [%ld] and actual eof offset "
- "[%ld] don't match\n", f->eof_offset, ftell(f->fp) + 8);
+ if (f->eof_offset != ftell(f->fp) + 8) { /* +8 = skip null segment header */
+ fprintf(stderr, "warning: eof_offset [%ld] and actual eof offset "
+ "[%ld] don't match\n", f->eof_offset, ftell(f->fp) + 8);
}
- fseek(f->fp,initpos,SEEK_SET);
+ fseek(f->fp, initpos, SEEK_SET);
f->header_loc = NULL;
f->name = newstr(name);
f->refcount = refcount;
- if (refcount) (*refcount)++;
+ if (refcount)
+ (*refcount)++;
return RDF_OK;
}
-int rdfclose(rdffile *f)
+int rdfclose(rdffile * f)
{
- if (! f->refcount || ! --(*f->refcount)) {
- fclose(f->fp);
- f->fp = NULL;
+ if (!f->refcount || !--(*f->refcount)) {
+ fclose(f->fp);
+ f->fp = NULL;
}
free(f->name);
@@ -318,9 +323,9 @@ int rdfclose(rdffile *f)
*/
void rdfperror(const char *app, const char *name)
{
- fprintf(stderr,"%s:%s: %s\n",app,name,rdf_errors[rdf_errno]);
+ fprintf(stderr, "%s:%s: %s\n", app, name, rdf_errors[rdf_errno]);
if (rdf_errno == RDF_ERR_OPEN || rdf_errno == RDF_ERR_READ) {
- perror(app);
+ perror(app);
}
}
@@ -332,39 +337,40 @@ int rdffindsegment(rdffile * f, int segno)
{
int i;
for (i = 0; i < f->nsegs; i++)
- if (f->seg[i].number == segno) return i;
+ if (f->seg[i].number == segno)
+ return i;
return -1;
}
/*
* Load the segment. Returns status.
*/
-int rdfloadseg(rdffile *f,int segment,void *buffer)
+int rdfloadseg(rdffile * f, int segment, void *buffer)
{
long fpos, slen;
- switch(segment) {
- case RDOFF_HEADER:
- fpos = f->header_ofs;
- slen = f->header_len;
- f->header_loc = (byte *)buffer;
- f->header_fp = 0;
- break;
- default:
- if (segment < f->nsegs) {
- fpos = f->seg[segment].offset;
- slen = f->seg[segment].length;
- f->seg[segment].data = (byte *)buffer;
- } else {
- return rdf_errno = RDF_ERR_SEGMENT;
- }
+ switch (segment) {
+ case RDOFF_HEADER:
+ fpos = f->header_ofs;
+ slen = f->header_len;
+ f->header_loc = (byte *) buffer;
+ f->header_fp = 0;
+ break;
+ default:
+ if (segment < f->nsegs) {
+ fpos = f->seg[segment].offset;
+ slen = f->seg[segment].length;
+ f->seg[segment].data = (byte *) buffer;
+ } else {
+ return rdf_errno = RDF_ERR_SEGMENT;
+ }
}
- if (fseek(f->fp,fpos,SEEK_SET))
- return rdf_errno = RDF_ERR_UNKNOWN;
-
- if (fread(buffer,1,slen,f->fp) != slen)
- return rdf_errno = RDF_ERR_READ;
+ if (fseek(f->fp, fpos, SEEK_SET))
+ return rdf_errno = RDF_ERR_UNKNOWN;
+
+ if (fread(buffer, 1, slen, f->fp) != slen)
+ return rdf_errno = RDF_ERR_READ;
return RDF_OK;
}
@@ -389,78 +395,79 @@ int rdfloadseg(rdffile *f,int segment,void *buffer)
* Read a header record.
* Returns the address of record, or NULL in case of error.
*/
-rdfheaderrec *rdfgetheaderrec(rdffile *f)
+rdfheaderrec *rdfgetheaderrec(rdffile * f)
{
static rdfheaderrec r;
int i;
if (!f->header_loc) {
- rdf_errno = RDF_ERR_HEADER;
- return NULL;
+ rdf_errno = RDF_ERR_HEADER;
+ return NULL;
}
- if (f->header_fp >= f->header_len) return 0;
+ if (f->header_fp >= f->header_len)
+ return 0;
RI8(r.type);
RI8(r.g.reclen);
- switch(r.type) {
- case RDFREC_RELOC: /* Relocation record */
- case RDFREC_SEGRELOC:
- if (r.r.reclen != 8) {
- rdf_errno = RDF_ERR_RECLEN;
- return NULL;
- }
- RI8(r.r.segment);
- RI32(r.r.offset);
- RI8(r.r.length);
- RI16(r.r.refseg);
- break;
-
- case RDFREC_IMPORT: /* Imported symbol record */
- case RDFREC_FARIMPORT:
- RI8(r.i.flags);
- RI16(r.i.segment);
- RS(r.i.label, EXIM_LABEL_MAX);
- break;
-
- case RDFREC_GLOBAL: /* Exported symbol record */
- RI8(r.e.flags);
- RI8(r.e.segment);
- RI32(r.e.offset);
- RS(r.e.label, EXIM_LABEL_MAX);
- break;
-
- case RDFREC_DLL: /* DLL record */
- RS(r.d.libname, MODLIB_NAME_MAX);
- break;
-
- case RDFREC_BSS: /* BSS reservation record */
- if (r.r.reclen != 4) {
- rdf_errno = RDF_ERR_RECLEN;
- return NULL;
- }
- RI32(r.b.amount);
- break;
-
- case RDFREC_MODNAME: /* Module name record */
- RS(r.m.modname, MODLIB_NAME_MAX);
- break;
-
- case RDFREC_COMMON: /* Common variable */
- RI16(r.c.segment);
- RI32(r.c.size);
- RI16(r.c.align);
- RS(r.c.label, EXIM_LABEL_MAX);
- break;
-
- default:
+ switch (r.type) {
+ case RDFREC_RELOC: /* Relocation record */
+ case RDFREC_SEGRELOC:
+ if (r.r.reclen != 8) {
+ rdf_errno = RDF_ERR_RECLEN;
+ return NULL;
+ }
+ RI8(r.r.segment);
+ RI32(r.r.offset);
+ RI8(r.r.length);
+ RI16(r.r.refseg);
+ break;
+
+ case RDFREC_IMPORT: /* Imported symbol record */
+ case RDFREC_FARIMPORT:
+ RI8(r.i.flags);
+ RI16(r.i.segment);
+ RS(r.i.label, EXIM_LABEL_MAX);
+ break;
+
+ case RDFREC_GLOBAL: /* Exported symbol record */
+ RI8(r.e.flags);
+ RI8(r.e.segment);
+ RI32(r.e.offset);
+ RS(r.e.label, EXIM_LABEL_MAX);
+ break;
+
+ case RDFREC_DLL: /* DLL record */
+ RS(r.d.libname, MODLIB_NAME_MAX);
+ break;
+
+ case RDFREC_BSS: /* BSS reservation record */
+ if (r.r.reclen != 4) {
+ rdf_errno = RDF_ERR_RECLEN;
+ return NULL;
+ }
+ RI32(r.b.amount);
+ break;
+
+ case RDFREC_MODNAME: /* Module name record */
+ RS(r.m.modname, MODLIB_NAME_MAX);
+ break;
+
+ case RDFREC_COMMON: /* Common variable */
+ RI16(r.c.segment);
+ RI32(r.c.size);
+ RI16(r.c.align);
+ RS(r.c.label, EXIM_LABEL_MAX);
+ break;
+
+ default:
#ifdef STRICT_ERRORS
- rdf_errno = RDF_ERR_RECTYPE; /* unknown header record */
- return NULL;
+ rdf_errno = RDF_ERR_RECTYPE; /* unknown header record */
+ return NULL;
#else
- for (i = 0; i < r.g.reclen; i++)
- RI8(r.g.data[i]);
+ for (i = 0; i < r.g.reclen; i++)
+ RI8(r.g.data[i]);
#endif
}
return &r;
@@ -468,17 +475,17 @@ rdfheaderrec *rdfgetheaderrec(rdffile *f)
/*
* Rewind to the beginning of the file
- */
-void rdfheaderrewind(rdffile *f)
+ */
+void rdfheaderrewind(rdffile * f)
{
f->header_fp = 0;
}
-
-rdf_headerbuf * rdfnewheader(void)
+rdf_headerbuf *rdfnewheader(void)
{
- rdf_headerbuf * hb = malloc(sizeof(rdf_headerbuf));
- if (hb == NULL) return NULL;
+ rdf_headerbuf *hb = malloc(sizeof(rdf_headerbuf));
+ if (hb == NULL)
+ return NULL;
hb->buf = newmembuf();
hb->nsegments = 0;
@@ -492,81 +499,81 @@ int rdfaddheader(rdf_headerbuf * h, rdfheaderrec * r)
#ifndef STRICT_ERRORS
int i;
#endif
- membufwrite(h->buf,&r->type,1);
- membufwrite(h->buf,&r->g.reclen,1);
+ membufwrite(h->buf, &r->type, 1);
+ membufwrite(h->buf, &r->g.reclen, 1);
switch (r->type) {
- case RDFREC_GENERIC: /* generic */
- membufwrite(h->buf, &r->g.data, r->g.reclen);
- break;
+ case RDFREC_GENERIC: /* generic */
+ membufwrite(h->buf, &r->g.data, r->g.reclen);
+ break;
case RDFREC_RELOC:
case RDFREC_SEGRELOC:
- membufwrite(h->buf,&r->r.segment,1);
- membufwrite(h->buf,&r->r.offset,-4);
- membufwrite(h->buf,&r->r.length,1);
- membufwrite(h->buf,&r->r.refseg,-2); /* 9 bytes written */
- break;
+ membufwrite(h->buf, &r->r.segment, 1);
+ membufwrite(h->buf, &r->r.offset, -4);
+ membufwrite(h->buf, &r->r.length, 1);
+ membufwrite(h->buf, &r->r.refseg, -2); /* 9 bytes written */
+ break;
- case RDFREC_IMPORT: /* import */
+ case RDFREC_IMPORT: /* import */
case RDFREC_FARIMPORT:
- membufwrite(h->buf,&r->i.flags,1);
- membufwrite(h->buf,&r->i.segment,-2);
- membufwrite(h->buf,&r->i.label,strlen(r->i.label) + 1);
- break ;
-
- case RDFREC_GLOBAL: /* export */
- membufwrite(h->buf,&r->e.flags,1);
- membufwrite(h->buf,&r->e.segment,1);
- membufwrite(h->buf,&r->e.offset,-4);
- membufwrite(h->buf,&r->e.label,strlen(r->e.label) + 1);
- break ;
-
- case RDFREC_DLL: /* DLL */
- membufwrite(h->buf,&r->d.libname,strlen(r->d.libname) + 1);
- break ;
-
- case RDFREC_BSS: /* BSS */
- membufwrite(h->buf,&r->b.amount,-4);
- break ;
-
- case RDFREC_MODNAME: /* Module name */
- membufwrite(h->buf,&r->m.modname,strlen(r->m.modname) + 1);
- break ;
-
+ membufwrite(h->buf, &r->i.flags, 1);
+ membufwrite(h->buf, &r->i.segment, -2);
+ membufwrite(h->buf, &r->i.label, strlen(r->i.label) + 1);
+ break;
+
+ case RDFREC_GLOBAL: /* export */
+ membufwrite(h->buf, &r->e.flags, 1);
+ membufwrite(h->buf, &r->e.segment, 1);
+ membufwrite(h->buf, &r->e.offset, -4);
+ membufwrite(h->buf, &r->e.label, strlen(r->e.label) + 1);
+ break;
+
+ case RDFREC_DLL: /* DLL */
+ membufwrite(h->buf, &r->d.libname, strlen(r->d.libname) + 1);
+ break;
+
+ case RDFREC_BSS: /* BSS */
+ membufwrite(h->buf, &r->b.amount, -4);
+ break;
+
+ case RDFREC_MODNAME: /* Module name */
+ membufwrite(h->buf, &r->m.modname, strlen(r->m.modname) + 1);
+ break;
+
default:
#ifdef STRICT_ERRORS
- return rdf_errno = RDF_ERR_RECTYPE;
+ return rdf_errno = RDF_ERR_RECTYPE;
#else
- for (i = 0; i < r->g.reclen; i++)
- membufwrite(h->buf, r->g.data[i], 1);
+ for (i = 0; i < r->g.reclen; i++)
+ membufwrite(h->buf, r->g.data[i], 1);
#endif
}
return 0;
}
-int rdfaddsegment(rdf_headerbuf *h, long seglength)
+int rdfaddsegment(rdf_headerbuf * h, long seglength)
{
- h->nsegments ++;
+ h->nsegments++;
h->seglength += seglength;
return 0;
}
int rdfwriteheader(FILE * fp, rdf_headerbuf * h)
{
- long l, l2;
+ long l, l2;
- fwrite (RDOFFId, 1, strlen(RDOFFId), fp) ;
+ fwrite(RDOFFId, 1, strlen(RDOFFId), fp);
- l = membuflength (h->buf);
- l2 = l + 14 + 10*h->nsegments + h->seglength;
+ l = membuflength(h->buf);
+ l2 = l + 14 + 10 * h->nsegments + h->seglength;
l = translatelong(l);
l2 = translatelong(l2);
- fwrite (&l2, 4, 1, fp); /* object length */
- fwrite (&l, 4, 1, fp); /* header length */
+ fwrite(&l2, 4, 1, fp); /* object length */
+ fwrite(&l, 4, 1, fp); /* header length */
membufdump(h->buf, fp);
- return 0; /* no error handling in here... CHANGE THIS! */
+ return 0; /* no error handling in here... CHANGE THIS! */
}
void rdfdoneheader(rdf_headerbuf * h)