Coverage Report

Created: 2025-07-12 06:05

/src/libzmq/src/compat.hpp
Line
Count
Source (jump to first uncovered line)
1
/* SPDX-License-Identifier: MPL-2.0 */
2
3
#ifndef __ZMQ_COMPAT_HPP_INCLUDED__
4
#define __ZMQ_COMPAT_HPP_INCLUDED__
5
6
#include "precompiled.hpp"
7
#include <string.h>
8
9
#ifdef ZMQ_HAVE_WINDOWS
10
#define strcasecmp _stricmp
11
#define strtok_r strtok_s
12
#else
13
#ifndef ZMQ_HAVE_STRLCPY
14
#ifdef ZMQ_HAVE_LIBBSD
15
#include <bsd/string.h>
16
#else
17
static inline size_t
18
strlcpy (char *dest_, const char *src_, const size_t dest_size_)
19
0
{
20
0
    size_t remain = dest_size_;
21
0
    for (; remain && *src_; --remain, ++src_, ++dest_) {
22
0
        *dest_ = *src_;
23
0
    }
24
0
    return dest_size_ - remain;
25
0
}
Unexecuted instantiation: msg.cpp:strlcpy(char*, char const*, unsigned long)
Unexecuted instantiation: ipc_address.cpp:strlcpy(char*, char const*, unsigned long)
Unexecuted instantiation: ws_engine.cpp:strlcpy(char*, char const*, unsigned long)
26
#endif
27
#endif
28
template <size_t size>
29
static inline int strcpy_s (char (&dest_)[size], const char *const src_)
30
0
{
31
0
    const size_t res = strlcpy (dest_, src_, size);
32
0
    return res >= size ? ERANGE : 0;
33
0
}
Unexecuted instantiation: ws_engine.cpp:int strcpy_s<2049ul>(char (&) [2049ul], char const*)
Unexecuted instantiation: ws_engine.cpp:int strcpy_s<256ul>(char (&) [256ul], char const*)
34
#endif
35
36
#ifndef HAVE_STRNLEN
37
static inline size_t strnlen (const char *s, size_t len)
38
{
39
    for (size_t i = 0; i < len; i++) {
40
        if (s[i] == '\0')
41
            return i + 1;
42
    }
43
44
    return len;
45
}
46
#endif
47
48
#endif