'\" te .\" Copyright (c) 2004, Sun Microsystems, Inc. .\" All Rights Reserved. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH cpc_seterrfn 3CPC "28 Mar 2005" "SunOS 5.11" "CPU Performance Counters Library Functions" .SH NAME cpc_seterrfn \- control libcpc error reporting .SH SYNOPSIS .LP .nf cc [ \fIflag\fR... ] \fIfile\fR... \(milcpc [ \fIlibrary\fR... ] #include \fBtypedef void (\fR\fBcpc_errfn_t\fR)(\fBconst char *\fR\fIfn\fR, \fBconst char *\fR\fIfmt\fR, \fBva_list\fR \fIap\fR); .fi .LP .nf \fBvoid\fR \fBcpc_seterrfn\fR(\fBcpc_errfn_t *\fR\fIerrfn\fR); .fi .SH DESCRIPTION .sp .LP For the convenience of programmers instrumenting their code, several \fBlibcpc\fR(3LIB) functions automatically emit to \fBstderr\fR error messages that attempt to provide a more detailed explanation of their error return values. While this can be useful for simple programs, some applications may wish to report their errors differently\(emfor example, to a window or to a log file. .sp .LP The \fBcpc_seterrfn()\fR function allows the caller to provide an alternate function for reporting errors; the type signature is shown above. The \fIfn\fR argument is passed the library function name that detected the error, the format string \fIfmt\fR and argument pointer \fIap\fR can be passed directly to \fBvsnprintf\fR(3C) or similar \fBvarargs\fR-based routine for formatting. .sp .LP The default printing routine can be restored by calling the routine with an \fIerrfn\fR argument of \fINULL\fR. .SH EXAMPLES .LP \fBExample 1 \fRDebugging example. .sp .LP This example produces error messages only when debugging the program containing it, or when the \fBcpc_strtoevent()\fR function is reporting an error when parsing an event specification .sp .in +2 .nf \fBint debugging; void myapp_errfn(const char *fn, const char *fmt, va_list ap) { if (strcmp(fn, "strtoevent") != 0 && !debugging) return; (void) fprintf(stderr, "myapp: cpc_%s(): ", fn); (void) vfprintf(stderr, fmt, ap); }\fR .fi .in -2 .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ MT-LevelUnsafe _ Interface StabilityObsolete .TE .SH SEE ALSO .sp .LP \fBcpc\fR(3CPC), \fBcpc_seterrhndlr\fR(3CPC), \fBlibcpc\fR(3LIB), \fBvsnprintf\fR(3C), \fBattributes\fR(5) .SH NOTES .sp .LP The \fBcpc_seterrfn()\fR function exists for binary compatibility only. Source containing this function will not compile. This function is obsolete and might be removed in a future release. Applications should use \fBcpc_seterrhndlr\fR(3CPC) instead.