Initial code commit

This commit is contained in:
angt
2015-10-20 16:55:54 +02:00
parent c7bb703777
commit afa530b766
3 changed files with 130 additions and 0 deletions

25
common.h Normal file
View File

@@ -0,0 +1,25 @@
#pragma once
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <unistd.h>
#include <errno.h>
#define COUNT(x) (sizeof(x)/sizeof(x[0]))
static inline size_t str_cpy (char *dst, char *src, size_t n)
{
if (!dst || !src)
return 0;
size_t i;
for (i=0; i<n && src[i]; i++)
dst[i] = src[i];
dst[i] = 0;
return i;
}