Coverage Report

Created: 2025-07-11 06:28

/src/opensips/mi/fmt.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) 2006 Voice Sistem SRL
3
 *
4
 * This file is part of opensips, a free SIP server.
5
 *
6
 * opensips is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * opensips is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 *
21
 * History:
22
 * ---------
23
 *  2006-09-08  first version (bogdan)
24
 */
25
26
/*!
27
 * \file
28
 * \brief MI :: Format handling
29
 * \ingroup mi
30
 */
31
32
33
34
#ifndef _MI_FMT_H_
35
#define _MI_FMT_H_
36
37
#include <stdarg.h>
38
#include <errno.h>
39
40
/*! \brief size of the buffer used for printing the FMT */
41
0
#define DEFAULT_MI_FMT_BUF_SIZE 2048
42
43
extern char *mi_fmt_buf;
44
extern int  mi_fmt_buf_len;
45
46
int mi_fmt_init( unsigned int size );
47
48
static inline char* mi_print_fmt(char *fmt, va_list ap, int *len)
49
0
{
50
0
  int n;
51
52
0
  if (mi_fmt_buf==NULL) {
53
0
    if (mi_fmt_init(DEFAULT_MI_FMT_BUF_SIZE)!=0) {
54
0
      LM_ERR("failed to init\n");
55
0
      return 0;
56
0
    }
57
0
  }
58
59
0
  n = vsnprintf( mi_fmt_buf, mi_fmt_buf_len, fmt, ap);
60
0
  if (n<0 || n>=mi_fmt_buf_len) {
61
0
    LM_ERR("formatting failed with n=%d, %s\n",n,strerror(errno));
62
0
    return 0;
63
0
  }
64
65
0
  *len = n;
66
0
  return mi_fmt_buf;
67
0
}
Unexecuted instantiation: item.c:mi_print_fmt
Unexecuted instantiation: status_report.c:mi_print_fmt
68
69
#endif