1explain_fread_or_die(3) Library Functions Manual explain_fread_or_die(3)
2
3
4
6 explain_fread_or_die - binary stream input and report errors
7
9 #include <libexplain/fread.h>
10 void explain_fread_or_die(void *ptr, size_t size, size_t nmemb, FILE
11 *fp);
12
14 The explain_fread_or_die function is used to call the fread(3) system
15 call. On failure an explanation will be printed to stderr, obtained
16 from explain_fread(3), and then the process terminates by calling
17 exit(EXIT_FAILURE).
18
19 This function is intended to be used in a fashion similar to the fol‐
20 lowing example:
21 size_t how_many = explain_fread_or_die(ptr, size, nmemb, fp);
22
23 ptr The ptr, exactly as to be passed to the fread(3) system call.
24
25 size The size, exactly as to be passed to the fread(3) system call.
26
27 nmemb The nmemb, exactly as to be passed to the fread(3) system call.
28
29 fp The fp, exactly as to be passed to the fread(3) system call.
30
31 Returns:
32 This function only returns on success, the number read or 0 on
33 end‐of‐input. On failure, prints an explanation and exits.
34
36 fread(3)
37 binary stream input
38
39 explain_fread(3)
40 explain fread(3) errors
41
42 exit(2) terminate the calling process
43
45 libexplain version 1.4
46 Copyright (C) 2008 Peter Miller
47
48
49
50 explain_fread_or_die(3)