summaryrefslogtreecommitdiff
path: root/src/libstddjb/cdb_read.c
blob: 1fb15dad199e5ec4f60a597ce52fa82ec1679d3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* ISC license. */

#include <string.h>
#include <errno.h>

#include <skalibs/cdb.h>
#include <skalibs/posixishard.h>

int cdb_read (struct cdb *c, char *buf, unsigned int len, uint32_t pos)
{
  if ((pos > c->size) || (c->size - pos < len)) return (errno = EPROTO, -1) ;
  memcpy(buf, c->map + pos, len) ;
  return 0 ;
}