• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aremmell / libsir / 1153

25 Jul 2023 04:30AM UTC coverage: 80.118% (-14.7%) from 94.801%
1153

push

travis-ci

aremmell
fix ternary

1 of 1 new or added line in 1 file covered. (100.0%)

2571 of 3209 relevant lines covered (80.12%)

24530.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/plugins/dummy/plugin_dummy.c
1
/*
2
 * plugin_dummy.c
3
 *
4
 * Author:    Ryan M. Lederman <lederman@gmail.com>
5
 * Copyright: Copyright (c) 2018-2023
6
 * Version:   2.2.1
7
 * License:   The MIT License (MIT)
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
10
 * this software and associated documentation files (the "Software"), to deal in
11
 * the Software without restriction, including without limitation the rights to
12
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
13
 * the Software, and to permit persons to whom the Software is furnished to do so,
14
 * subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in all
17
 * copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 */
26
#include <stdio.h>
27
#include "plugin_dummy.h"
28
#include "sir/ansimacros.h"
29
#include "sir/helpers.h"
30

31
#if !defined(PLUGIN_NAME)
32
# define PLUGIN_NAME "plugin_dummy"
33
#endif
34

35
/*
36
 * Controlling misbehavior via preprocessor macros:
37
 *
38
 * When the following are defined upon compilation, this plugin will exhibit
39
 * behavior that will cause libsir to reject it during the loading/validation
40
 * process. Only one at a time need be defined, since one failed check will result
41
 * in the loader immediately rejecting and unloading the module.
42
 *
43
 * - PLUGINDUMMY_BADBEHAVIOR1: return false from 'sir_plugin_query'
44
 * - PLUGINDUMMY_BADBEHAVIOR2: set info::iface_ver != SIR_PLUGIN_VCURRENT
45
 * - PLUGINDUMMY_BADBEHAVIOR3: set invalid values in sir_plugininfo
46
 * - PLUGINDUMMY_BADBEHAVIOR4: missing an export
47
 * - PLUGINDUMMY_BADBEHAVIOR5: return false from 'sir_plugin_init'
48
 * - PLUGINDUMMY_BADBEHAVIOR6: return false from 'sir_plugin_write' and
49
 *   'sir_plugin_cleanup'
50
 */
51

52
#if defined(__WIN__)
53
BOOL APIENTRY DllMain(HMODULE module, DWORD ul_reason_for_call, LPVOID reserved) {
54
    SIR_UNUSED(module);
55
    SIR_UNUSED(ul_reason_for_call);
56
    SIR_UNUSED(reserved);
57
    return TRUE;
58
}
59
#endif
60

61
const uint8_t maj_ver   = 1;
62
const uint8_t min_ver   = 0;
63
const uint8_t bld_ver   = 0;
64
const sir_levels levels = SIRL_DEBUG | SIRL_INFO;
65
const sir_options opts  = SIRO_NOHOST | SIRO_NOTID;
66
const char* author      = "libsir contributors";
67
const char* desc        = "Logs messages and function calls to stdout.";
68
const uint64_t caps     = 0;
69

70
PLUGIN_EXPORT bool sir_plugin_query(sir_plugininfo* info) {
21✔
71
#if defined(PLUGINDUMMY_BADBEHAVIOR2)
72
    info->iface_ver = 255;
3✔
73
#else
74
    info->iface_ver = SIR_PLUGIN_VCURRENT;
18✔
75
#endif
76
    info->maj_ver   = maj_ver;
21✔
77
    info->min_ver   = min_ver;
21✔
78
    info->bld_ver   = bld_ver;
21✔
79
#if defined(PLUGINDUMMY_BADBEHAVIOR3)
80
    info->levels    = 0xfe23;
3✔
81
    info->opts      = 0x1234abcd;
3✔
82
    info->author    = NULL;
3✔
83
    info->desc      = "";
3✔
84
#else
85
    info->levels    = levels;
18✔
86
    info->opts      = opts;
18✔
87
    info->author    = author;
18✔
88
    info->desc      = desc;
18✔
89
#endif
90
    info->caps      = caps;
21✔
91

92
    /* cppcheck-suppress syntaxError */
93
    printf("\t" DGRAY("" PLUGIN_NAME " ('%s')") "\n", __func__);
×
94

95
#if defined(PLUGINDUMMY_BADBEHAVIOR1)
96
    return false;
3✔
97
#else
98
    return true;
18✔
99
#endif
100
}
101

102
#if !defined(PLUGINDUMMY_BADBEHAVIOR4)
103
PLUGIN_EXPORT bool sir_plugin_init(void) {
12✔
104
    printf("\t" DGRAY("" PLUGIN_NAME " ('%s')") "\n", __func__);
×
105
# if defined(PLUGINDUMMY_BADBEHAVIOR5)
106
    return false;
3✔
107
# else
108
    return true;
9✔
109
# endif
110
}
111
#endif
112

113
PLUGIN_EXPORT bool sir_plugin_write(sir_level level, const char* message) {
9✔
114
#if defined(PLUGINDUMMY_BADBEHAVIOR6)
115
    SIR_UNUSED(level);
116
    SIR_UNUSED(message);
117
    return false;
3✔
118
#else
119
    printf("\t" DGRAY("" PLUGIN_NAME " (%s): level: %04"PRIx32", message: %s"),
×
120
        __func__, level, message);
121
    return true;
6✔
122
#endif
123
}
124

125
PLUGIN_EXPORT bool sir_plugin_cleanup(void) { //-V524
24✔
126
    printf("\t" DGRAY("" PLUGIN_NAME " ('%s')") "\n", __func__);
×
127
#if defined(PLUGINDUMMY_BADBEHAVIOR6)
128
    return false;
3✔
129
#else
130
    return true;
21✔
131
#endif
132
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc