268 |
|
} |
269 |
|
#endif |
270 |
|
|
271 |
+ |
#ifndef HAVE_STRLCPY |
272 |
+ |
* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ |
273 |
+ |
|
274 |
+ |
/* |
275 |
+ |
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
276 |
+ |
* |
277 |
+ |
* Permission to use, copy, modify, and distribute this software for any |
278 |
+ |
* purpose with or without fee is hereby granted, provided that the above |
279 |
+ |
* copyright notice and this permission notice appear in all copies. |
280 |
+ |
* |
281 |
+ |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
282 |
+ |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
283 |
+ |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
284 |
+ |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
285 |
+ |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
286 |
+ |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
287 |
+ |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
288 |
+ |
*/ |
289 |
+ |
|
290 |
+ |
/* |
291 |
+ |
* Copy src to string dst of size siz. At most siz-1 characters |
292 |
+ |
* will be copied. Always NUL terminates (unless siz == 0). |
293 |
+ |
* Returns strlen(src); if retval >= siz, truncation occurred. |
294 |
+ |
*/ |
295 |
+ |
size_t strlcpy(char *dst, const char *src, size_t siz){ |
296 |
+ |
register char *d = dst; |
297 |
+ |
register const char *s = src; |
298 |
+ |
register size_t n = siz; |
299 |
+ |
|
300 |
+ |
/* Copy as many bytes as will fit */ |
301 |
+ |
if (n != 0 && --n != 0) { |
302 |
+ |
do { |
303 |
+ |
if ((*d++ = *s++) == 0) |
304 |
+ |
break; |
305 |
+ |
} while (--n != 0); |
306 |
+ |
} |
307 |
+ |
|
308 |
+ |
/* Not enough room in dst, add NUL and traverse rest of src */ |
309 |
+ |
if (n == 0) { |
310 |
+ |
if (siz != 0) |
311 |
+ |
*d = '\0'; /* NUL-terminate dst */ |
312 |
+ |
while (*s++) |
313 |
+ |
; |
314 |
+ |
} |
315 |
+ |
|
316 |
+ |
return(s - src - 1); /* count does not include NUL */ |
317 |
+ |
} |
318 |
+ |
#endif |
319 |
+ |
|
320 |
+ |
#ifndef HAVE_STRLCAT |
321 |
+ |
/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */ |
322 |
+ |
|
323 |
+ |
/* |
324 |
+ |
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
325 |
+ |
* |
326 |
+ |
* Permission to use, copy, modify, and distribute this software for any |
327 |
+ |
* purpose with or without fee is hereby granted, provided that the above |
328 |
+ |
* copyright notice and this permission notice appear in all copies. |
329 |
+ |
* |
330 |
+ |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
331 |
+ |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
332 |
+ |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
333 |
+ |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
334 |
+ |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
335 |
+ |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
336 |
+ |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
337 |
+ |
*/ |
338 |
+ |
|
339 |
+ |
/* |
340 |
+ |
* Appends src to string dst of size siz (unlike strncat, siz is the |
341 |
+ |
* full size of dst, not space left). At most siz-1 characters |
342 |
+ |
* will be copied. Always NUL terminates (unless siz <= strlen(dst)). |
343 |
+ |
* Returns strlen(src) + MIN(siz, strlen(initial dst)). |
344 |
+ |
* If retval >= siz, truncation occurred. |
345 |
+ |
*/ |
346 |
+ |
size_t strlcat(char *dst, const char *src, size_t siz){ |
347 |
+ |
register char *d = dst; |
348 |
+ |
register const char *s = src; |
349 |
+ |
register size_t n = siz; |
350 |
+ |
size_t dlen; |
351 |
+ |
|
352 |
+ |
/* Find the end of dst and adjust bytes left but don't go past end */ |
353 |
+ |
while (n-- != 0 && *d != '\0') |
354 |
+ |
d++; |
355 |
+ |
dlen = d - dst; |
356 |
+ |
n = siz - dlen; |
357 |
+ |
|
358 |
+ |
if (n == 0) |
359 |
+ |
return(dlen + strlen(s)); |
360 |
+ |
while (*s != '\0') { |
361 |
+ |
if (n != 1) { |
362 |
+ |
*d++ = *s; |
363 |
+ |
n--; |
364 |
+ |
} |
365 |
+ |
s++; |
366 |
+ |
} |
367 |
+ |
*d = '\0'; |
368 |
+ |
|
369 |
+ |
return(dlen + (s - src)); /* count does not include NUL */ |
370 |
+ |
} |
371 |
+ |
|
372 |
+ |
#endif |
373 |
+ |
|
374 |
|
long long get_ll_match(char *line, regmatch_t *match){ |
375 |
|
char *ptr; |
376 |
|
long long num; |