Coverage Report

Created: 2025-07-12 06:14

/src/opensips/errinfo.c
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
/*!
22
 * \file errinfo.c
23
 * \brief OpenSIPS Error info functions
24
 */
25
26
27
#include <stdlib.h>
28
#include <string.h>
29
30
#include "dprint.h"
31
#include "errinfo.h"
32
33
/*! global error info */
34
err_info_t _oser_err_info;
35
36
/*! \brief Get global error state
37
 */
38
0
err_info_t* get_err_info(void) { return &_oser_err_info; }
39
40
/*! \brief Initialize global error state
41
 */
42
void init_err_info(void)
43
0
{
44
0
  memset(&_oser_err_info, 0, sizeof(err_info_t));
45
0
}
46
47
/*! \brief Set suggested error info message
48
 */
49
void set_err_info(int ec, int el, char *info)
50
0
{
51
0
  LM_DBG("ec: %d, el: %d, ei: '%s'\n", ec, el,
52
0
      (info)?info:"");
53
0
  _oser_err_info.eclass = ec;
54
0
  _oser_err_info.level = el;
55
0
  if(info)
56
0
  {
57
0
    _oser_err_info.info.s   = info;
58
0
    _oser_err_info.info.len = strlen(info);
59
0
  }
60
0
}
61
62
/*! \brief Set suggested error reply
63
 */
64
void set_err_reply(int rc, char *rr)
65
0
{
66
0
  _oser_err_info.rcode = rc;
67
0
  if(rr)
68
0
  {
69
0
    _oser_err_info.rreason.s   = rr;
70
0
    _oser_err_info.rreason.len = strlen(rr);
71
0
  }
72
0
}
73