1cpc_seterrfn(3CPC)CPU Performance Counters Library Functionscpc_seterrfn(3CPC)
2
3
4
6 cpc_seterrfn - control libcpc error reporting
7
9 cc [ flag... ] file... −lcpc [ library... ]
10 #include <libcpc.h>
11
12 typedef void (cpc_errfn_t)(const char *fn, const char *fmt, va_list ap);
13
14
15 void cpc_seterrfn(cpc_errfn_t *errfn);
16
17
19 For the convenience of programmers instrumenting their code, several
20 libcpc(3LIB) functions automatically emit to stderr error messages that
21 attempt to provide a more detailed explanation of their error return
22 values. While this can be useful for simple programs, some applica‐
23 tions may wish to report their errors differently—for example, to a
24 window or to a log file.
25
26
27 The cpc_seterrfn() function allows the caller to provide an alternate
28 function for reporting errors; the type signature is shown above. The
29 fn argument is passed the library function name that detected the
30 error, the format string fmt and argument pointer ap can be passed
31 directly to vsnprintf(3C) or similar varargs-based routine for format‐
32 ting.
33
34
35 The default printing routine can be restored by calling the routine
36 with an errfn argument of NULL.
37
39 Example 1 Debugging example.
40
41
42 This example produces error messages only when debugging the program
43 containing it, or when the cpc_strtoevent() function is reporting an
44 error when parsing an event specification
45
46
47 int debugging;
48 void
49 myapp_errfn(const char *fn, const char *fmt, va_list ap)
50 {
51 if (strcmp(fn, "strtoevent") != 0 && !debugging)
52 return;
53 (void) fprintf(stderr, "myapp: cpc_%s(): ", fn);
54 (void) vfprintf(stderr, fmt, ap);
55 }
56
57
59 See attributes(5) for descriptions of the following attributes:
60
61
62
63
64 ┌─────────────────────────────┬─────────────────────────────┐
65 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
66 ├─────────────────────────────┼─────────────────────────────┤
67 │MT-Level │Unsafe │
68 ├─────────────────────────────┼─────────────────────────────┤
69 │Interface Stability │Obsolete │
70 └─────────────────────────────┴─────────────────────────────┘
71
73 cpc(3CPC), cpc_seterrhndlr(3CPC), libcpc(3LIB), vsnprintf(3C),
74 attributes(5)
75
77 The cpc_seterrfn() function exists for binary compatibility only.
78 Source containing this function will not compile. This function is
79 obsolete and might be removed in a future release. Applications should
80 use cpc_seterrhndlr(3CPC) instead.
81
82
83
84SunOS 5.11 28 Mar 2005 cpc_seterrfn(3CPC)