#ifndef SAFE_H
#define SAFE_H
char *ncpy(char *dst, const char *src, int len);
/*
Copies up (and including) len chars. Terminates with a null char.
So the size of dst should be at least (len+1)
*/

int nvsprintf(char *bf, int count, const char *fmt, va_list argptr );
/*
Same as vsnprintf, but forces null-termination.
So the size of bf should be at least (count+1)
*/

int nsprintf(char *bf, int count, const char * fmt, ...);
/*
Same as snprintf, but forces null-termination.
So the size of bf should be at least (count+1)
*/

char *nstrcat(char *bf, const char *src, int n);
/*
Same as strcat, but the final string can contain at most n chars,
So the size of bf should be at least (count+1)
*/

#undef strcpy
#undef sprintf
#undef vsprintf
#undef strncpy
#undef snprintf
#undef vsnprintf
#undef strcat


int unsafe_vsprintf(char *bf, const char *fmt, va_list argptr );
/* wrapper to vsprintf incase we really want to use it */

int unsafe_sprintf(char *bf, const char * fmt, ...);
/* wrapper to sprintf incase we really want to use it */

char *unsafe_strcat(char *dst, const char *src);
/* wrapper to strcat incase we really want to use it */

int unsafe_snprintf(char *bf, int n, const char * fmt, ...);
/* wrapper to snprintf incase we really want to use it */

int unsafe_vsnprintf(char *bf, int n, const char *fmt, va_list argptr );
/* wrapper to vsnprintf incase we really want to use it */

char *unsafe_strcpy(char *dst, const char *src);
/* wrapper to strcpy incase we really want to use it */

char *unsafe_strncpy(char *dst, const char *src, int n);
/* wrapper to strncpy incase we really want to use it */

#define strcat strcat_is_unsafe__use_nstrcat_instead
#define strcpy strcpy_is_unsafe__use_ncpy_instead
#define sprintf sprintf_is_unsafe__use_nsprintf_instead
#define vsprintf vsprintf_is_unsafe__use_nvsprintf_instead
#define strncpy strncpy_is_unsafe__use_ncpy_instead
#define snprintf snprintf_is_unsafe__use_nsprintf_instead
#define vsnprintf vsnprintf_is_unsafe__use_nvsprintf_instead


#endif
