X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=macro.h;h=29b27942558900dd5ed2f5ad5ed51cfa73d26dc3;hp=ab0716c72886259f0d93db39f0fd0c9f75e9aa02;hb=cf1ea15cc320019d7b41eb56aeeb3c1956fbb7a0;hpb=d2b113f2c4f11acfaee1b2e0fd2f03744a89f6d4 diff --git a/macro.h b/macro.h index ab0716c..29b2794 100644 --- a/macro.h +++ b/macro.h @@ -14,7 +14,7 @@ /* safe strcpy/strncpy */ #define SCPY(dst, src) scpy(dst, src, sizeof(dst)) -static inline void scpy(char *dst, char *src, unsigned int siz) +static inline void scpy(char *dst, const char *src, unsigned int siz) { strncpy(dst, src, siz); dst[siz-1] = '\0'; @@ -22,8 +22,8 @@ static inline void scpy(char *dst, char *src, unsigned int siz) /* safe strcat/strncat */ -#define SCAT(dst, src) scat(dst, src, sizeof(dst)) -static inline void scat(char *dst, char *src, unsigned int siz) +#define SCAT(dst, src) scat(dst, src, sizeof(dst)-strlen(dst)-1) +static inline void scat(char *dst, const char *src, unsigned int siz) { strncat(dst, src, siz); dst[siz-1] = '\0'; @@ -44,7 +44,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) -static inline void sprint(char *dst, unsigned int siz, char *fmt, ...) +static inline void sprint(char *dst, unsigned int siz, const char *fmt, ...) { va_list args; @@ -65,7 +65,7 @@ static inline void sprint(char *dst, unsigned int siz, char *fmt, ...) /* fatal error with error message and exit */ #define FATAL(fmt, arg...) fatal(__FUNCTION__, __LINE__, fmt, ##arg) -static inline void fatal(const char *function, int line, char *fmt, ...) +static inline void fatal(const char *function, int line, const char *fmt, ...) { va_list args; char buffer[256]; @@ -78,7 +78,7 @@ static inline void fatal(const char *function, int line, char *fmt, ...) fprintf(stderr, "This error is not recoverable, must exit here.\n"); #ifdef DEBUG_FUNC debug(function, line, "FATAL ERROR", buffer); - debug(function, line, "FATAL ERROR", "This error is not recoverable, must exit here.\n"); + debug(function, line, "FATAL ERROR", (char *)"This error is not recoverable, must exit here.\n"); #endif exit(EXIT_FAILURE); }