Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

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 AuxiliaryProcessMain(), chkpass_in(), ChooseIndexNameAddition(), connectFailureMessage(), create_rel_filename_map(), create_script_for_old_cluster_deletion(), createNewConnection(), descriptor_variable(), exec_prog(), expand_tilde(), fetch_fp_info(), find_in_dynamic_libpath(), find_other_exec_or_die(), from_char_parse_int_len(), from_char_seq_search(), get_control_data(), get_home_path(), get_prompt(), get_rel_infos(), getPgPassFilename(), hash_create(), InitPostgres(), internal_cancel(), join_path_components(), logfile_getname(), main(), make_oper_cache_key(), make_relative_path(), old_8_3_rebuild_tsvector_tables(), ParseLongOption(), parseServiceInfo(), pg_getnameinfo_all(), pg_open_tzfile(), pg_TZDIR(), pgarch_archiveXlog(), pgstat_bestart(), PQcancel(), pqGetHomeDirectory(), PQrequestCancel(), pqStrerror(), process_file(), process_postgres_switches(), RegisterBackgroundWorker(), replace_string(), RequestXLogStreaming(), scan_available_timezones(), scan_directory_ci(), set_ps_display(), setup_bin_paths(), test_postmaster_connection(), timestamptz_to_str(), and WalReceiverMain().

{
    char       *d = dst;
    const char *s = src;
    size_t      n = siz;

    /* Copy as many bytes as will fit */
    if (n != 0)
    {
        while (--n != 0)
        {
            if ((*d++ = *s++) == '\0')
                break;
        }
    }

    /* Not enough room in dst, add NUL and traverse rest of src */
    if (n == 0)
    {
        if (siz != 0)
            *d = '\0';          /* NUL-terminate dst */
        while (*s++)
            ;
    }

    return (s - src - 1);       /* count does not include NUL */
}