From 1a4696492e3cd478080e438950a7664a68fefcd6 Mon Sep 17 00:00:00 2001 From: axtloss Date: Sat, 13 Jul 2024 13:32:53 +0200 Subject: Add manpages for each extlib function --- doc/fcopy.3 | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 doc/fcopy.3 (limited to 'doc/fcopy.3') diff --git a/doc/fcopy.3 b/doc/fcopy.3 new file mode 100644 index 0000000..5096fe4 --- /dev/null +++ b/doc/fcopy.3 @@ -0,0 +1,75 @@ +'\" t +.\" Copyright 2024 axtlos (axtlos@disroot.org) +.\" +.\" SPDX-License-Identifier: BSD-3-Clause + +.TH fcopy 3 2024-07-13 "extlib" +.SH NAME +fcopy \- copy a file +.SH LIBRARY +extlib extended standard library +.RI ( libextlib ", " \-lextlib ) +.SH SYNOPSIS +.nf +.B #include +.P +.BI "size_t fcopy(FILE *src, FILE *dst);" +.fi +.SH DESCRIPTION +If +.I *src +or +.I *dst +is NULL, the +.BR fcopy () +function will return -1 and do nothing else. +Otherwise, this function copies the contents +of +.I *src +to +.IR *dst . +.fi +.SH RETURN VALUE +The +.BR fcopy () +function returns the amount of bytes copied from +.I *src +to +.IR *dst . +.SH EXAMPLES +The following code will write the text "hello" into +a memstream, and then copy the contents of that +file into a second memstream buffer. +.fi +\& +.\" SRC BEGIN (fcopy.c) +.EX +#include +#include +#include +\& +int +main(void) +{ + char *buf_a, *buf_b; + size_t len_a, len_b; + FILE *file_buf_a = open_memstream (&buf_a, &len_a); + FILE *file_buf_b = open_memstream (&buf_b, &len_b); +\& + fprintf (file_test_a, "hello"); + fflush (file_test_a); + fclose (file_test_a); + file_test_a = fmemopen(buf_a, len_a, "r"); +\& + fcopy (file_test_a, file_test_b); + fclose (file_test_b); +\& + puts (buf_a); + puts (buf_b); + free (buf_a); + free (buf_b); +\& + exit(EXIT_SUCCESS); +} +.EE +.\" SRC END -- cgit v1.2.3