Changeset 83d3320758201fc208b3a0e011af10c5e26bd7fe
- Timestamp:
- 04/29/06 16:30:49
(2 years ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1146321049 +0000
- git-parent:
[0a930be206c0211be8a48a7a31749f91eeeca424]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1146321049 +0000
- Message:
OpenBSDish strlcpy()
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r8a50049 |
r83d3320 |
|
| 405 | 405 | need_libc=false |
|---|
| 406 | 406 | |
|---|
| 407 | | AC_CHECK_FUNCS(gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon scandir fork bsearch lstat) |
|---|
| | 407 | AC_CHECK_FUNCS(gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon scandir fork bsearch lstat strlcpy) |
|---|
| 408 | 408 | |
|---|
| 409 | 409 | dnl Check for usual libc functions |
|---|
| rbe639de2 |
r83d3320 |
|
| 847 | 847 | #endif |
|---|
| 848 | 848 | |
|---|
| | 849 | #ifndef HAVE_STRLCPY |
|---|
| | 850 | # define strlcpy vlc_strlcpy |
|---|
| | 851 | VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) ); |
|---|
| | 852 | #elif !defined(__PLUGIN__) |
|---|
| | 853 | # define vlc_strlcpy NULL |
|---|
| | 854 | #endif |
|---|
| | 855 | |
|---|
| 849 | 856 | #ifndef HAVE_ATOF |
|---|
| 850 | 857 | # define atof vlc_atof |
|---|
| r2ad5cc2 |
r83d3320 |
|
| 492 | 492 | void (*decode_URI_inner) (char *psz); |
|---|
| 493 | 493 | char * (*encode_URI_component_inner) (const char *psz); |
|---|
| | 494 | size_t (*vlc_strlcpy_inner) (char *, const char *, size_t); |
|---|
| 494 | 495 | }; |
|---|
| 495 | 496 | # if defined (__PLUGIN__) |
|---|
| … | … | |
| 963 | 964 | # define decode_URI (p_symbols)->decode_URI_inner |
|---|
| 964 | 965 | # define encode_URI_component (p_symbols)->encode_URI_component_inner |
|---|
| | 966 | # define vlc_strlcpy (p_symbols)->vlc_strlcpy_inner |
|---|
| 965 | 967 | # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) |
|---|
| 966 | 968 | /****************************************************************** |
|---|
| … | … | |
| 1437 | 1439 | ((p_symbols)->decode_URI_inner) = decode_URI; \ |
|---|
| 1438 | 1440 | ((p_symbols)->encode_URI_component_inner) = encode_URI_component; \ |
|---|
| | 1441 | ((p_symbols)->vlc_strlcpy_inner) = vlc_strlcpy; \ |
|---|
| 1439 | 1442 | (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ |
|---|
| 1440 | 1443 | (p_symbols)->__stats_CounterGet_deprecated = NULL; \ |
|---|
| rf4a8731 |
r83d3320 |
|
| 458 | 458 | |
|---|
| 459 | 459 | /* Find out server and share names */ |
|---|
| 460 | | strncpy( psz_server, psz_path, sizeof( psz_server ) ); |
|---|
| 461 | | psz_server[sizeof (psz_server) - 1] = '\0'; |
|---|
| | 460 | strlcpy( psz_server, psz_path, sizeof( psz_server ) ); |
|---|
| 462 | 461 | psz_share[0] = 0; |
|---|
| 463 | 462 | psz_parser = strchr( psz_path, '/' ); |
|---|
| … | … | |
| 466 | 465 | char *psz_parser2 = strchr( ++psz_parser, '/' ); |
|---|
| 467 | 466 | if( psz_parser2 ) |
|---|
| 468 | | { |
|---|
| 469 | | strncpy( psz_share, psz_parser, sizeof( psz_share ) ); |
|---|
| 470 | | psz_parse[sizeof (psz_parse) - 1] = '\0'; |
|---|
| 471 | | } |
|---|
| | 467 | strlcpy( psz_share, psz_parser, sizeof( psz_share ) ); |
|---|
| 472 | 468 | } |
|---|
| 473 | 469 | |
|---|
| r470b47f |
r83d3320 |
|
| 2 | 2 | * libc.c: Extra libc function for some systems. |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | | * Copyright (C) 2002 the VideoLAN team |
|---|
| | 4 | * Copyright (C) 2002-2006 the VideoLAN team |
|---|
| 5 | 5 | * $Id$ |
|---|
| 6 | 6 | * |
|---|
| … | … | |
| 10 | 10 | * Derk-Jan Hartman <hartman at videolan dot org> |
|---|
| 11 | 11 | * Christophe Massiot <massiot@via.ecp.fr> |
|---|
| | 12 | * Rémi Denis-Courmont <rem à videolan.org> |
|---|
| 12 | 13 | * |
|---|
| 13 | 14 | * This program is free software; you can redistribute it and/or modify |
|---|
| … | … | |
| 354 | 355 | d.rem = numer % denom; |
|---|
| 355 | 356 | return d; |
|---|
| | 357 | } |
|---|
| | 358 | #endif |
|---|
| | 359 | |
|---|
| | 360 | |
|---|
| | 361 | /** |
|---|
| | 362 | * Copy a string to a sized buffer. The result is always nul-terminated |
|---|
| | 363 | * (contrary to strncpy()). |
|---|
| | 364 | * |
|---|
| | 365 | * @param dest destination buffer |
|---|
| | 366 | * @param src string to be copied |
|---|
| | 367 | * @param len maximum number of characters to be copied plus one for the |
|---|
| | 368 | * terminating nul. |
|---|
| | 369 | * |
|---|
| | 370 | * @return strlen(src) |
|---|
| | 371 | */ |
|---|
| | 372 | #ifndef HAVE_STRLCPY |
|---|
| | 373 | extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize) |
|---|
| | 374 | { |
|---|
| | 375 | size_t length; |
|---|
| | 376 | |
|---|
| | 377 | for (length = 1; (length < bufsize) && *src; length++) |
|---|
| | 378 | *tgt++ = *src++; |
|---|
| | 379 | |
|---|
| | 380 | if (bufsize) |
|---|
| | 381 | *tgt = '\0'; |
|---|
| | 382 | |
|---|
| | 383 | while (*src++) |
|---|
| | 384 | length++; |
|---|
| | 385 | |
|---|
| | 386 | return length - 1; |
|---|
| 356 | 387 | } |
|---|
| 357 | 388 | #endif |
|---|