version 1.3, 1997/02/09 23:58:36 |
version 1.4, 1998/07/10 15:05:27 |
|
|
* 4. This notice may not be removed or altered. |
* 4. This notice may not be removed or altered. |
*/ |
*/ |
|
|
|
#include <sys/types.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <time.h> |
#include <time.h> |
#include <sys/types.h> |
#include <err.h> |
|
|
#include "file.h" |
#include "file.h" |
|
|
|
|
|
|
if (tmpoff == NULL) |
if (tmpoff == NULL) |
if ((tmpoff = (int32 *) malloc(tmplen = 20)) == NULL) |
if ((tmpoff = (int32 *) malloc(tmplen = 20)) == NULL) |
error("out of memory\n"); |
err(1, "malloc"); |
|
|
for (magindex = 0; magindex < nmagic; magindex++) { |
for (magindex = 0; magindex < nmagic; magindex++) { |
/* if main entry matches, print it... */ |
/* if main entry matches, print it... */ |
|
|
if (++cont_level >= tmplen) |
if (++cont_level >= tmplen) |
if ((tmpoff = (int32 *) realloc(tmpoff, |
if ((tmpoff = (int32 *) realloc(tmpoff, |
tmplen += 20)) == NULL) |
tmplen += 20)) == NULL) |
error("out of memory\n"); |
err(1, "malloc"); |
while (magic[magindex+1].cont_level != 0 && |
while (magic[magindex+1].cont_level != 0 && |
++magindex < nmagic) { |
++magindex < nmagic) { |
if (cont_level >= magic[magindex].cont_level) { |
if (cont_level >= magic[magindex].cont_level) { |
|
|
if ((tmpoff = |
if ((tmpoff = |
(int32 *) realloc(tmpoff, |
(int32 *) realloc(tmpoff, |
tmplen += 20)) == NULL) |
tmplen += 20)) == NULL) |
error("out of memory\n"); |
err(1, "malloc"); |
} |
} |
if (magic[magindex].flag & ADD) { |
if (magic[magindex].flag & ADD) { |
magic[magindex].offset = oldoff; |
magic[magindex].offset = oldoff; |
|
|
break; |
break; |
|
|
default: |
default: |
error("invalid m->type (%d) in mprint().\n", m->type); |
errx(1, "invalid m->type (%d) in mprint().", m->type); |
/*NOTREACHED*/ |
/*NOTREACHED*/ |
} |
} |
return(t); |
return(t); |
|
|
((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0])); |
((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0])); |
return 1; |
return 1; |
default: |
default: |
error("invalid type %d in mconvert().\n", m->type); |
errx(1, "invalid type %d in mconvert().", m->type); |
return 0; |
return 0; |
} |
} |
} |
} |
|
|
} |
} |
break; |
break; |
default: |
default: |
error("invalid type %d in mcheck().\n", m->type); |
errx(1, "invalid type %d in mcheck().", m->type); |
return 0;/*NOTREACHED*/ |
return 0;/*NOTREACHED*/ |
} |
} |
|
|
|
|
|
|
default: |
default: |
matched = 0; |
matched = 0; |
error("mcheck: can't happen: invalid relation %d.\n", m->reln); |
errx(1, "mcheck: can't happen: invalid relation %d.", m->reln); |
break;/*NOTREACHED*/ |
break;/*NOTREACHED*/ |
} |
} |
|
|