16 #define _BBUFSIZE (10240 * sizeof(struct bts_rec))
25 fprintf(stderr,
"No memory\n");
28 memset(bs, 0,
sizeof *bs);
30 bs->
fd = fopen(logname,
"r");
48 off_t foff = recno *
sizeof(
struct bts_rec);
51 fprintf(stderr,
"bts_seek: invalid BTSFD\n");
55 if (bs->
recno != recno) {
56 if (fseeko(bs->
fd, foff, SEEK_SET) == -1) {
57 fprintf(stderr,
"bts_seek: cannot seek to 0x%llx\n",
58 (
unsigned long long)foff);
76 size_t nbytes, rbytes;
79 if (bs == 0 || buf == 0) {
80 fprintf(stderr,
"bts_read: invalid BTSFD or buffer\n");
84 nbytes = maxrec *
sizeof(
struct bts_rec);
85 rbytes = fread(buf, 1, nbytes, bs->
fd);
86 if (rbytes != nbytes) {
92 nrecs = rbytes /
sizeof(
struct bts_rec);
93 if ((rbytes %
sizeof(
struct bts_rec)) != 0) {
95 fprintf(stderr,
"bts_read: got partial record!\n");
98 fprintf(stderr,
"bts_read: read not multiple of record size, "
int bts_seek(BTSFD fd, uint64_t recno)
BTSFD bts_open(const char *logname)
int bts_read(BTSFD fd, struct bts_rec *buf, int maxrec)
void * malloc(size_t size)