]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
New page describing error () and error_at_line()
authorMichael Kerrisk <mtk.manpages@gmail.com>
Fri, 28 Apr 2006 06:44:37 +0000 (06:44 +0000)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Fri, 28 Apr 2006 06:44:37 +0000 (06:44 +0000)
man3/error.3 [new file with mode: 0644]

diff --git a/man3/error.3 b/man3/error.3
new file mode 100644 (file)
index 0000000..f0b495c
--- /dev/null
@@ -0,0 +1,126 @@
+.\" Copyright (C) 2006 Justin Pryzby <pryzbyj@justinpryzby.com>
+.\" and Copyright (C) 2006 Michael Kerrisk <mtk-manpages@gmx.net>
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be
+.\" included in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" References:
+.\"   glibc manual and source
+.TH ERROR 3 "2006-04-25" GNU
+.SH NAME
+error, error_at_line, error_message_count, error_on_per_line, \
+error_print_progname \- glibc error reporting functions
+.SH SYNOPSIS
+.nf
+.. #include <error.h>
+
+\fBvoid error(int \fIstatus, \fBint\fI errnum, \fBconst char *\fIformat, \
+\fB...);
+
+\fBvoid error_at_line(int \fIstatus, \fBint \fIerrnum, \
+\fBconst char *\fIfilename, 
+                   \fBunsigned int \fIlinenum, \
+\fBconst char *\fIformat, \fB...);
+
+\fBextern unsigned int \fIerror_message_count\fP;
+
+\fBextern int \fIerror_one_per_line\fP;
+
+\fBextern void (* \fIerror_print_progname\fB) (void);
+.fi
+.SH DESCRIPTION
+\fBerror\fP() is a general error reporting function.  
+It flushes
+.IR stdout ,
+and then outputs to 
+.I stderr 
+the program name, a colon and a space, the message specified by the 
+.BR printf(3) -style 
+format string \fIformat\fP, and, if \fIerrnum\fP is
+non-zero, a second colon and a space followed by the string given by
+\fBperror(\fIerrnum\fB)\fR.  
+Any arguments required for
+.I format 
+should follow 
+.I format
+in the argument list.
+The output is terminated by a newline character.
+
+The program name printed by 
+.BR error ()
+is the value of the global variable
+.IR program_invocation_name 
+(which initially has the same value as
+.IR main ()'s
+.IR argv[0] ), 
+declared as
+.IR "extern char *program_invocation_name" 
+in 
+.IR <errno.h> 
+if the feature test macro _GNU_SOURCE is defined.
+The value of this variable can be modified to change the output of
+.BR error ().
+
+If \fIstatus\fP has a non-zero value, then 
+.BR error ()
+calls
+.BR exit (3)
+to terminate the program using the given value as the exit status.
+
+The \fBerror_at_line\fP() function is exactly the same as \fBerror\fP(),
+except for the addition of the arguments
+.I filename
+and
+.IR linenum .
+The output produced is as for 
+.BR error (),
+except that after the program name are written: a colon, the value of
+.IR filename ,
+a colon, and the value of 
+.IR linenum .
+The preprocessor values \fB__LINE__\fP and
+\fB__FILE__\fP may be useful when calling \fBerror_at_line\fP(), 
+but other values can also be used.
+For example, these arguments could refer to a location in an input file.
+
+If global variable \fIerror_one_per_line\fP is set non-zero, a sequence of
+\fBerror_at_line\fP() calls with the 
+the same value of \fIfilename\fP and \fIlinenum\fP will result in only
+one message (the first) being output.  
+
+The global variable \fIerror_message_count\fP counts the number of 
+messages that have been output by
+\fBerror\fP() and \fBerror_at_line\fP().
+
+If the global variable \fIerror_print_progname\fP 
+is assigned the address of a function
+(i.e., is not NULL), then that function is called
+instead of prefixing the message with the program name and colon.
+The function should print a suitable string to
+.IR stderr .
+.SH "CONFORMING TO"
+These functions and variables are GNU extensions, and should not be
+used in programs intended to be portable.
+.SH SEE ALSO
+.\" FIXME . TODO Add SEE ALSO for this page under err.3 perror.3 strerror.3
+.BR errno (3),
+.BR perror (3),
+.BR strerror (3),
+.BR err (3),
+.BR exit (3)