93 |
if (buf_size <= 0) |
if (buf_size <= 0) |
94 |
return; |
return; |
95 |
|
|
96 |
for(;;) { |
for (;;) { |
97 |
c = *str++; |
c = *str++; |
98 |
if (c == 0 || q >= buf + buf_size - 1) |
if (c == 0 || q >= buf + buf_size - 1) |
99 |
break; |
break; |
112 |
return buf; |
return buf; |
113 |
} |
} |
114 |
|
|
115 |
|
/* copy the n first char of a string and truncate it. */ |
116 |
|
char *pstrncpy(char *buf, int buf_size, const char *s, int len) |
117 |
|
{ |
118 |
|
char *q; |
119 |
|
int c; |
120 |
|
|
121 |
|
if (buf_size > 0) { |
122 |
|
q = buf; |
123 |
|
if (len >= buf_size) |
124 |
|
len = buf_size - 1; |
125 |
|
while (len > 0) { |
126 |
|
c = *s++; |
127 |
|
if (c == '\0') |
128 |
|
break; |
129 |
|
*q++ = c; |
130 |
|
len--; |
131 |
|
} |
132 |
|
*q = '\0'; |
133 |
|
} |
134 |
|
return buf; |
135 |
|
} |
136 |
|
|
137 |
#endif |
#endif |
138 |
|
|
139 |
/** |
/** |