Coverage Report

Created: 2025-08-24 06:53

/src/rtpproxy/external/libre/include/re_fmt.h
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * @file re_fmt.h  Interface to formatted text functions
3
 *
4
 * Copyright (C) 2010 Creytiv.com
5
 */
6
7
8
#include <stdarg.h>
9
#include <stdio.h>
10
11
12
struct mbuf;
13
14
15
/** Defines a pointer-length string type */
16
struct pl {
17
  const char *p;  /**< Pointer to string */
18
  size_t l;       /**< Length of string  */
19
};
20
21
/** Initialise a pointer-length object from a constant string */
22
#define PL(s) {(s), sizeof((s))-1}
23
24
/** Pointer-length Initializer */
25
0
#define PL_INIT {NULL, 0}
26
27
extern const struct pl pl_null;
28
29
void     pl_set_str(struct pl *pl, const char *str);
30
void     pl_set_mbuf(struct pl *pl, const struct mbuf *mb);
31
uint32_t pl_u32(const struct pl *pl);
32
uint32_t pl_x32(const struct pl *pl);
33
uint64_t pl_u64(const struct pl *pl);
34
uint64_t pl_x64(const struct pl *pl);
35
double   pl_float(const struct pl *pl);
36
bool     pl_isset(const struct pl *pl);
37
int      pl_strcpy(const struct pl *pl, char *str, size_t size);
38
int      pl_strdup(char **dst, const struct pl *src);
39
int      pl_dup(struct pl *dst, const struct pl *src);
40
int      pl_strcmp(const struct pl *pl, const char *str);
41
int      pl_strcasecmp(const struct pl *pl, const char *str);
42
int      pl_cmp(const struct pl *pl1, const struct pl *pl2);
43
int      pl_casecmp(const struct pl *pl1, const struct pl *pl2);
44
const char *pl_strchr(const struct pl *pl, char c);
45
const char *pl_strrchr(const struct pl *pl, char c);
46
47
/** Advance pl position/length by +/- N bytes */
48
static inline void pl_advance(struct pl *pl, ssize_t n)
49
664
{
50
664
  pl->p += n;
51
664
  pl->l -= n;
52
664
}
Unexecuted instantiation: attr.c:pl_advance
Unexecuted instantiation: cand.c:pl_advance
Unexecuted instantiation: candpair.c:pl_advance
Unexecuted instantiation: comp.c:pl_advance
Unexecuted instantiation: ctrans.c:pl_advance
Unexecuted instantiation: icem.c:pl_advance
Unexecuted instantiation: icesdp.c:pl_advance
Unexecuted instantiation: icestr.c:pl_advance
Unexecuted instantiation: mbuf.c:pl_advance
Unexecuted instantiation: msg.c:pl_advance
Unexecuted instantiation: netstr.c:pl_advance
Unexecuted instantiation: ntop.c:pl_advance
Unexecuted instantiation: pl.c:pl_advance
print.c:pl_advance
Line
Count
Source
49
664
{
50
664
  pl->p += n;
51
664
  pl->l -= n;
52
664
}
Unexecuted instantiation: pton.c:pl_advance
Unexecuted instantiation: regex.c:pl_advance
Unexecuted instantiation: rtpp_re_dbg.c:pl_advance
Unexecuted instantiation: rtpp_re_icesdp.c:pl_advance
Unexecuted instantiation: sa.c:pl_advance
Unexecuted instantiation: str.c:pl_advance
Unexecuted instantiation: str_error.c:pl_advance
Unexecuted instantiation: stun.c:pl_advance
Unexecuted instantiation: stunsrv.c:pl_advance
Unexecuted instantiation: util.c:pl_advance
Unexecuted instantiation: rtpp_ice_lite.c:pl_advance
53
54
55
/* Formatted printing */
56
57
/**
58
 * Defines the re_vhprintf() print handler
59
 *
60
 * @param p    String to print
61
 * @param size Size of string to print
62
 * @param arg  Handler argument
63
 *
64
 * @return 0 for success, otherwise errorcode
65
 */
66
typedef int(re_vprintf_h)(const char *p, size_t size, void *arg);
67
68
/** Defines a print backend */
69
struct re_printf {
70
  re_vprintf_h *vph; /**< Print handler   */
71
  void *arg;         /**< Handler agument */
72
};
73
74
/**
75
 * Defines the %H print handler
76
 *
77
 * @param pf  Print backend
78
 * @param arg Handler argument
79
 *
80
 * @return 0 for success, otherwise errorcode
81
 */
82
typedef int(re_printf_h)(struct re_printf *pf, void *arg);
83
84
int re_vhprintf(const char *fmt, va_list ap, re_vprintf_h *vph, void *arg);
85
int re_vfprintf(FILE *stream, const char *fmt, va_list ap);
86
int re_vprintf(const char *fmt, va_list ap);
87
int re_vsnprintf(char *str, size_t size, const char *fmt, va_list ap);
88
int re_vsdprintf(char **strp, const char *fmt, va_list ap);
89
90
int re_hprintf(struct re_printf *pf, const char *fmt, ...);
91
int re_fprintf(FILE *stream, const char *fmt, ...);
92
int re_printf(const char *fmt, ...);
93
int re_snprintf(char *str, size_t size, const char *fmt, ...);
94
int re_sdprintf(char **strp, const char *fmt, ...);
95
96
97
/* Regular expressions */
98
int re_regex(const char *ptr, size_t len, const char *expr, ...);
99
100
101
/* Character functions */
102
uint8_t ch_hex(char ch);
103
104
105
/* String functions */
106
int  str_hex(uint8_t *hex, size_t len, const char *str);
107
void str_ncpy(char *dst, const char *src, size_t n);
108
int  str_dup(char **dst, const char *src);
109
int  str_cmp(const char *s1, const char *s2);
110
int  str_casecmp(const char *s1, const char *s2);
111
size_t str_len(const char *s);
112
const char *str_error(int errnum, char *buf, size_t sz);
113
114
115
/**
116
 * Check if string is set
117
 *
118
 * @param s Zero-terminated string
119
 *
120
 * @return true if set, false if not set
121
 */
122
static inline bool str_isset(const char *s)
123
0
{
124
0
  return s && s[0] != '\0';
125
0
}
Unexecuted instantiation: attr.c:str_isset
Unexecuted instantiation: cand.c:str_isset
Unexecuted instantiation: candpair.c:str_isset
Unexecuted instantiation: comp.c:str_isset
Unexecuted instantiation: ctrans.c:str_isset
Unexecuted instantiation: icem.c:str_isset
Unexecuted instantiation: icesdp.c:str_isset
Unexecuted instantiation: icestr.c:str_isset
Unexecuted instantiation: mbuf.c:str_isset
Unexecuted instantiation: msg.c:str_isset
Unexecuted instantiation: netstr.c:str_isset
Unexecuted instantiation: ntop.c:str_isset
Unexecuted instantiation: pl.c:str_isset
Unexecuted instantiation: print.c:str_isset
Unexecuted instantiation: pton.c:str_isset
Unexecuted instantiation: regex.c:str_isset
Unexecuted instantiation: rtpp_re_dbg.c:str_isset
Unexecuted instantiation: rtpp_re_icesdp.c:str_isset
Unexecuted instantiation: sa.c:str_isset
Unexecuted instantiation: str.c:str_isset
Unexecuted instantiation: str_error.c:str_isset
Unexecuted instantiation: stun.c:str_isset
Unexecuted instantiation: stunsrv.c:str_isset
Unexecuted instantiation: util.c:str_isset
Unexecuted instantiation: rtpp_ice_lite.c:str_isset
126
127
128
/* time */
129
int  fmt_gmtime(struct re_printf *pf, void *ts);
130
int  fmt_human_time(struct re_printf *pf, const uint32_t *seconds);
131
132
133
void hexdump(FILE *f, const void *p, size_t len);
134
135
136
/* param */
137
typedef void (fmt_param_h)(const struct pl *name, const struct pl *val,
138
         void *arg);
139
140
bool fmt_param_exists(const struct pl *pl, const char *pname);
141
bool fmt_param_get(const struct pl *pl, const char *pname, struct pl *val);
142
void fmt_param_apply(const struct pl *pl, fmt_param_h *ph, void *arg);
143
144
145
/* unicode */
146
int utf8_encode(struct re_printf *pf, const char *str);
147
int utf8_decode(struct re_printf *pf, const struct pl *pl);
148
size_t utf8_byteseq(char u[4], unsigned cp);