dsniff  2.4b2
About: A collection of tools for network auditing
  Fossies Dox: dsniff-2.4b2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

err.c
Go to the documentation of this file.
1 /*
2  * err.c
3  *
4  * Adapted from OpenBSD libc *err* *warn* code.
5  *
6  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
7  *
8  * Copyright (c) 1993
9  * The Regents of the University of California. All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  * must display the following acknowledgement:
21  * This product includes software developed by the University of
22  * California, Berkeley and its contributors.
23  * 4. Neither the name of the University nor the names of its contributors
24  * may be used to endorse or promote products derived from this software
25  * without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37  * SUCH DAMAGE.
38  */
39 
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <stdarg.h>
43 #include <string.h>
44 #include <errno.h>
45 
46 void
47 err(int eval, const char *fmt, ...)
48 {
49  va_list ap;
50 
51  va_start(ap, fmt);
52  if (fmt != NULL) {
53  (void)vfprintf(stderr, fmt, ap);
54  (void)fprintf(stderr, ": ");
55  }
56  va_end(ap);
57  (void)fprintf(stderr, "%s\n", strerror(errno));
58  exit(eval);
59 }
60 
61 void
62 warn(const char *fmt, ...)
63 {
64  va_list ap;
65 
66  va_start(ap, fmt);
67  if (fmt != NULL) {
68  (void)vfprintf(stderr, fmt, ap);
69  (void)fprintf(stderr, ": ");
70  }
71  va_end(ap);
72  (void)fprintf(stderr, "%s\n", strerror(errno));
73 }
74 
75 void
76 errx(int eval, const char *fmt, ...)
77 {
78  va_list ap;
79 
80  va_start(ap, fmt);
81  if (fmt != NULL)
82  (void)vfprintf(stderr, fmt, ap);
83  (void)fprintf(stderr, "\n");
84  va_end(ap);
85  exit(eval);
86 }
87 
88 void
89 warnx(const char *fmt, ...)
90 {
91  va_list ap;
92 
93  va_start(ap, fmt);
94  if (fmt != NULL)
95  (void)vfprintf(stderr, fmt, ap);
96  (void)fprintf(stderr, "\n");
97  va_end(ap);
98 }
99 
warnx
void warnx(const char *fmt,...)
Definition: err.c:89
err
void err(int eval, const char *fmt,...)
Definition: err.c:47
errx
void errx(int eval, const char *fmt,...)
Definition: err.c:76
warn
void warn(const char *fmt,...)
Definition: err.c:62