1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
/*
* 13 Jun 91 wsak (wk0x@andrew) added mips support
*/
#ifndef linux
#include <sys/types.h>
#include <stdio.h>
#include "asn1.h"
#include "snmp_impl.h"
#ifndef NULL
#define NULL 0
#endif
static int kmem;
int swap, mem;
void
init_kmem(file)
char *file;
{
kmem = open(file, 0);
if (kmem < 0){
fprintf(stderr, "cannot open ");
perror(file);
exit(1);
}
mem = open("/dev/mem",0);
if (mem < 0){
fprintf(stderr, "cannot open ");
perror(file);
exit(1);
}
swap = open("/dev/drum",0);
if (swap < 0){
fprintf(stderr, "cannot open ");
perror(file);
exit(1);
}
}
/*
* Seek into the kernel for a value.
*/
off_t
klseek(base)
off_t base;
{
return (lseek(kmem, (off_t)base, 0));
}
/*
* Read from the kernel
*/
int
klread(buf, buflen)
char *buf;
int buflen;
{
return (read(kmem, buf, buflen));
}
/*
* klookup:
*
* It seeks to the location off in kmem
* It does a read into target of siz bytes.
*
* Return NULL on failure and 1 on sucess.
*
*/
int
klookup(off, target, siz)
int off;
char *target;
int siz;
{
klseek(off);
if (siz != klread(target, siz)) {
ERROR("klread\n");
exit(-1);
}
return (1);
}
#endif /* ! linux */
|