File: byte_start.c

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (16 lines) | stat: -rw-r--r-- 416 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <byte.h>
#include <string.h>

int byte_start(const void* a,size_t alen,const void* b,size_t blen) {
  return blen<=alen && !memcmp(a,b,blen);
}

#ifdef UNITTEST
#include <assert.h>
int main() {
  static char buf[]="The quick brown fox jumps over the lazy dog";
  assert(byte_start(buf,sizeof(buf)-1,"The ",4));
  assert(!byte_start(buf,sizeof(buf)-1,"the ",4));
  assert(!byte_start(buf,3,buf,9));
}
#endif