*** empty log message ***
This commit is contained in:
18
tecs/util.c
18
tecs/util.c
@@ -163,10 +163,20 @@ int str_cmp(const char *str1, const char *str2) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
int str_ncpy(char *dst, const char *src, int n) {
|
||||
strncpy(dst, src, n);
|
||||
if (dst[n-1]!='\0') {
|
||||
dst[n-1]='\0';
|
||||
int str_ncpy(char *dst, const char *src, int maxdest) {
|
||||
strncpy(dst, src, maxdest);
|
||||
if (dst[maxdest-1]!='\0') {
|
||||
dst[maxdest-1]='\0';
|
||||
ERR_MSG("destination string too short");
|
||||
}
|
||||
return(0);
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int str_ncat(char *dst, const char *src, int maxdest) {
|
||||
strncat(dst, src, maxdest-strlen(dst)-1);
|
||||
if (dst[maxdest-1]!='\0') {
|
||||
dst[maxdest-1]='\0';
|
||||
ERR_MSG("destination string too short");
|
||||
}
|
||||
return(0);
|
||||
|
||||
Reference in New Issue
Block a user