1explain_strtol_or_die(3) Library Functions Manual explain_strtol_or_die(3)
2
3
4
6 explain_strtol_or_die - convert a string to a long integer and report
7 errors
8
10 #include <libexplain/strtol.h>
11 long explain_strtol_or_die(const char *nptr, char **endptr, int base);
12 long explain_strtol_on_error(const char *nptr, char **endptr, int
13 base))
14
16 The explain_strtol_or_die function is used to call the strtol(3) system
17 call. On failure an explanation will be printed to stderr, obtained
18 from the explain_strtol(3) function, and then the process terminates by
19 calling exit(EXIT_FAILURE).
20
21 The explain_strtol_on_error function is used to call the strtol(3) sys‐
22 tem call. On failure an explanation will be printed to stderr, obtained
23 from the explain_strtol(3) function, but still returns to the caller.
24
25 nptr The nptr, exactly as to be passed to the strtol(3) system call.
26
27 endptr The endptr, exactly as to be passed to the strtol(3) system
28 call.
29
30 base The base, exactly as to be passed to the strtol(3) system call.
31
33 The explain_strtol_or_die function only returns on success, see str‐
34 tol(3) for more information. On failure, prints an explanation and
35 exits, it does not return.
36
37 The explain_strtol_on_error function always returns the value return by
38 the wrapped strtol(3) system call.
39
41 The explain_strtol_or_die function is intended to be used in a fashion
42 similar to the following example:
43 long result = explain_strtol_or_die(nptr, endptr, base);
44
46 strtol(3)
47 convert a string to a long integer
48
49 explain_strtol(3)
50 explain strtol(3) errors
51
52 exit(2) terminate the calling process
53
55 libexplain version 1.4
56 Copyright (C) 2009 Peter Miller
57
58
59
60 explain_strtol_or_die(3)