'\" t .\" Title: strscpy .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: January 2017 .\" Manual: Basic C Library Functions .\" Source: Kernel Hackers Manual 4.8.15 .\" Language: English .\" .TH "STRSCPY" "9" "January 2017" "Kernel Hackers Manual 4\&.8\&." "Basic C Library Functions" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" strscpy \- Copy a C\-string into a sized buffer .SH "SYNOPSIS" .HP \w'ssize_t\ strscpy('u .BI "ssize_t strscpy(char\ *\ " "dest" ", const\ char\ *\ " "src" ", size_t\ " "count" ");" .SH "ARGUMENTS" .PP \fIdest\fR .RS 4 Where to copy the string to .RE .PP \fIsrc\fR .RS 4 Where to copy the string from .RE .PP \fIcount\fR .RS 4 Size of destination buffer .RE .SH "DESCRIPTION" .PP Copy the string, or as much of it as fits, into the dest buffer\&. The routine returns the number of characters copied (not including the trailing NUL) or \-E2BIG if the destination buffer wasn\*(Aqt big enough\&. The behavior is undefined if the string buffers overlap\&. The destination buffer is always NUL terminated, unless it\*(Aqs zero\-sized\&. .PP Preferred to \fBstrlcpy\fR since the API doesn\*(Aqt require reading memory from the src string beyond the specified \(lqcount\(rq bytes, and since the return value is easier to error\-check than \fBstrlcpy\fR\*(Aqs\&. In addition, the implementation is robust to the string changing out from underneath it, unlike the current \fBstrlcpy\fR implementation\&. .PP Preferred to \fBstrncpy\fR since it always returns a valid string, and doesn\*(Aqt unnecessarily force the tail of the destination buffer to be zeroed\&. If the zeroing is desired, it\*(Aqs likely cleaner to use \fBstrscpy\fR with an overflow test, then just \fBmemset\fR the tail of the dest buffer\&. .SH "COPYRIGHT" .br