X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=macro.h;h=08c8a9bd603b1be4e0904813b3f35868f756b33d;hp=5d2bce50f8a9e0a2747a9ae6abda19094f553600;hb=034d3a91404addedc1c7a3494862c79532b0b878;hpb=877a2dfd52782f72ba2d28483212166f2326b1fa diff --git a/macro.h b/macro.h index 5d2bce5..08c8a9b 100644 --- a/macro.h +++ b/macro.h @@ -13,7 +13,7 @@ /* safe strcpy/strncpy */ -#define SCPY(dst, src) scpy(dst, src, sizeof(dst)) +#define SCPY(dst, src) scpy((char *)dst, src, sizeof(dst)) static inline void scpy(char *dst, const char *src, unsigned int siz) { strncpy(dst, src, siz); @@ -22,16 +22,16 @@ static inline void scpy(char *dst, const char *src, unsigned int siz) /* safe strcat/strncat */ -#define SCAT(dst, src) scat(dst, src, sizeof(dst)-strlen(dst)-1) +#define SCAT(dst, src) scat((char *)dst, src, sizeof(dst)) static inline void scat(char *dst, const char *src, unsigned int siz) { - strncat(dst, src, siz); + strncat(dst, src, siz-strlen(dst)-1); dst[siz-1] = '\0'; } /* safe concat of a byte */ -#define SCCAT(dst, src) sccat(dst, src, sizeof(dst)) +#define SCCAT(dst, src) sccat((char *)dst, src, sizeof(dst)) static inline void sccat(char *dst, char chr, unsigned int siz) { if (strlen(dst) < siz-1) @@ -43,7 +43,7 @@ static inline void sccat(char *dst, char chr, unsigned int siz) /* safe sprintf/snprintf */ -#define SPRINT(dst, fmt, arg...) sprint(dst, sizeof(dst), fmt, ## arg) +#define SPRINT(dst, fmt, arg...) sprint((char *)dst, sizeof(dst), fmt, ## arg) static inline void sprint(char *dst, unsigned int siz, const char *fmt, ...) { va_list args;