GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/cu/error.c Lines: 0 16 0.0 %
Date: 2016-12-06 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: error.c,v 1.1 2012/07/10 10:28:05 nicm Exp $ */
2
3
/*
4
 * Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15
 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 */
18
19
#include <sys/types.h>
20
21
#include <err.h>
22
#include <errno.h>
23
#include <stdio.h>
24
#include <stdarg.h>
25
#include <stdlib.h>
26
#include <string.h>
27
28
#include "cu.h"
29
30
/*
31
 * Once we've configured termios, we need to use \r\n to end lines, so use our
32
 * own versions of warn/warnx/err/errx.
33
 */
34
35
extern char	*__progname;
36
37
void
38
cu_err(int eval, const char *fmt, ...)
39
{
40
	va_list ap;
41
42
	restore_termios();
43
44
	va_start(ap, fmt);
45
	verr(eval, fmt, ap);
46
}
47
48
void
49
cu_errx(int eval, const char *fmt, ...)
50
{
51
	va_list ap;
52
53
	restore_termios();
54
55
	va_start(ap, fmt);
56
	verrx(eval, fmt, ap);
57
}
58
59
void
60
cu_warn(const char *fmt, ...)
61
{
62
	va_list ap;
63
64
	fprintf(stderr, "%s: ", __progname);
65
66
	va_start(ap, fmt);
67
	vfprintf(stderr, fmt, ap);
68
	va_end(ap);
69
70
	fprintf(stderr, ": %s\r\n", strerror(errno));
71
}
72
73
void
74
cu_warnx(const char *fmt, ...)
75
{
76
	va_list ap;
77
78
	fprintf(stderr, "%s: ", __progname);
79
80
	va_start(ap, fmt);
81
	vfprintf(stderr, fmt, ap);
82
	va_end(ap);
83
84
	fprintf(stderr, "\r\n");
85
}