aboutsummaryrefslogtreecommitdiff
path: root/doc/fcopy.3
blob: f127073deb0b91429b558ea644f6f9a026d5f6c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'\" 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 <extlib.h>
.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 <stdio.h>
#include <stdlib.h>
#include <extlib.h>
\&
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_buf_a, "hello");
    fflush (file_buf_a);
    fclose (file_buf_a);
    file_buf_a = fmemopen(buf_a, len_a, "r");
\&
    fcopy (file_buf_a, file_buf_b);
    fclose (file_buf_b);
\&
    puts (buf_a);
    puts (buf_b);
    free (buf_a);
    free (buf_b);
\&
    exit(EXIT_SUCCESS);
}
.EE
.\" SRC END
.SH AUTHORS
This manual page was written by Rose
.IR <axtlos@disroot.org> .
x