Coverage Report

Created: 2025-02-15 06:25

/src/wireshark/wsutil/cmdarg_err.c
Line
Count
Source (jump to first uncovered line)
1
/* cmdarg_err.c
2
 * Routines to report command-line argument errors.
3
 *
4
 * Wireshark - Network traffic analyzer
5
 * By Gerald Combs <gerald@wireshark.org>
6
 * Copyright 1998 Gerald Combs
7
 *
8
 * SPDX-License-Identifier: GPL-2.0-or-later
9
 */
10
11
#include "config.h"
12
13
#include "cmdarg_err.h"
14
15
static void (*print_err)(const char *, va_list ap);
16
static void (*print_err_cont)(const char *, va_list ap);
17
18
/*
19
 * Set the reporting functions for error messages.
20
 */
21
void
22
cmdarg_err_init(void (*err)(const char *, va_list),
23
                void (*err_cont)(const char *, va_list))
24
14
{
25
14
    print_err = err;
26
14
    print_err_cont = err_cont;
27
14
}
28
29
/*
30
 * Report an error in command-line arguments.
31
 */
32
void
33
vcmdarg_err(const char *fmt, va_list ap)
34
0
{
35
0
    print_err(fmt, ap);
36
0
}
37
38
void
39
cmdarg_err(const char *fmt, ...)
40
0
{
41
0
    va_list ap;
42
43
0
    va_start(ap, fmt);
44
0
    print_err(fmt, ap);
45
0
    va_end(ap);
46
0
}
47
48
/*
49
 * Report additional information for an error in command-line arguments.
50
 */
51
void
52
cmdarg_err_cont(const char *fmt, ...)
53
0
{
54
0
    va_list ap;
55
56
0
    va_start(ap, fmt);
57
0
    print_err_cont(fmt, ap);
58
0
    va_end(ap);
59
0
}
60
61
/*
62
 * Error printing routines that report to the standard error.
63
 */
64
void
65
stderr_cmdarg_err(const char *msg_format, va_list ap)
66
0
{
67
0
    fprintf(stderr, "%s: ", g_get_prgname());
68
0
    vfprintf(stderr, msg_format, ap);
69
0
    fprintf(stderr, "\n");
70
0
}
71
72
void
73
stderr_cmdarg_err_cont(const char *msg_format, va_list ap)
74
0
{
75
0
    vfprintf(stderr, msg_format, ap);
76
0
    fprintf(stderr, "\n");
77
0
}