PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
strlcpy.c File Reference
#include "c.h"
Include dependency graph for strlcpy.c:

Go to the source code of this file.

Functions

size_t strlcpy (char *dst, const char *src, size_t siz)
 

Function Documentation

size_t strlcpy ( char *  dst,
const char *  src,
size_t  siz 
)

Definition at line 45 of file strlcpy.c.

Referenced by _tarGetHeader(), AuxiliaryProcessMain(), BaseBackup(), be_tls_get_cipher(), be_tls_get_peerdn_name(), be_tls_get_version(), chkpass_in(), chkpass_out(), ChooseIndexNameAddition(), CleanupPriorWALFiles(), connectFailureMessage(), ConvertTimeZoneAbbrevs(), create_script_for_old_cluster_deletion(), createNewConnection(), descriptor_variable(), DetermineTimeZoneAbbrevOffsetInternal(), expand_tilde(), fetch_fp_info(), find_in_dynamic_libpath(), find_other_exec_or_die(), from_char_parse_int_len(), from_char_seq_search(), fsync_parent_path(), get_configdata(), get_control_data(), get_home_path(), get_prompt(), hash_create(), identify_system_timezone(), init(), initialize_SSL(), InitPostgres(), internal_cancel(), isolation_init(), join_path_components(), KeepFileRestoredFromArchive(), logfile_getname(), main(), make_oper_cache_key(), make_relative_path(), parseCommandLine(), ParseLongOption(), parseServiceInfo(), pg_getnameinfo_all(), pg_open_tzfile(), pg_perm_setlocale(), pg_timezone_abbrevs(), pg_TZDIR(), pgarch_archiveXlog(), pgstat_bestart(), PQcancel(), pqGetErrorNotice3(), pqGetHomeDirectory(), pqParseInput2(), pqParseInput3(), PQrequestCancel(), pqStrerror(), process_file(), process_postgres_switches(), ReceiveAndUnpackTarFile(), recoveryStopsAfter(), replace_string(), RequestXLogStreaming(), resolve_symlinks(), results_differ(), scan_available_timezones(), scan_directory_ci(), SerializeLibraryState(), set_ps_display(), setup_bin_paths(), SetWALFileNameForCleanup(), SimpleLruInit(), SSLerrmessage(), StartupXLOG(), syncTargetDirectory(), tar_close(), tarCreateHeader(), test_postmaster_connection(), timestamptz_to_str(), uuid_generate_internal(), validate_exec(), WalReceiverMain(), and XLogRestorePoint().

46 {
47  char *d = dst;
48  const char *s = src;
49  size_t n = siz;
50 
51  /* Copy as many bytes as will fit */
52  if (n != 0)
53  {
54  while (--n != 0)
55  {
56  if ((*d++ = *s++) == '\0')
57  break;
58  }
59  }
60 
61  /* Not enough room in dst, add NUL and traverse rest of src */
62  if (n == 0)
63  {
64  if (siz != 0)
65  *d = '\0'; /* NUL-terminate dst */
66  while (*s++)
67  ;
68  }
69 
70  return (s - src - 1); /* count does not include NUL */
71 }