summaryrefslogtreecommitdiff
path: root/toxrtp/toxrtp_error.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxrtp/toxrtp_error.c')
-rw-r--r--toxrtp/toxrtp_error.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/toxrtp/toxrtp_error.c b/toxrtp/toxrtp_error.c
deleted file mode 100644
index 3a7ff9a5..00000000
--- a/toxrtp/toxrtp_error.c
+++ /dev/null
@@ -1,68 +0,0 @@
1
2#ifdef HAVE_CONFIG_H
3#include "config.h"
4#endif /* HAVE_CONFIG_H */
5
6#include "toxrtp_error.h"
7#include "toxrtp_helper.h"
8
9#include <stdio.h>
10#include <stdarg.h>
11#include <string.h>
12#include <stdlib.h>
13#include <assert.h>
14
15typedef struct rtp_error_s {
16 char* _message;
17 int _id;
18
19} rtp_error_t;
20
21static rtp_error_t* _register = NULL;
22static size_t _it = 0;
23
24void t_rtperr_register ( int _id, const char* _info )
25{
26 size_t _info_size = strlen ( _info );
27
28 if ( !_register ) {
29 _register = calloc ( sizeof ( rtp_error_t ), 1 );
30 } else {
31 _register = realloc ( _register, sizeof ( rtp_error_t ) * ( _it + 1 ) );
32 }
33 assert(_register);
34
35
36 rtp_error_t* _current = & _register[_it];
37
38 _current->_id = _id;
39 _current->_message = calloc ( sizeof(char), _info_size );
40 assert(_current->_message);
41
42 t_memcpy ( (uint8_t*)_current->_message, (const uint8_t*)_info, _info_size );
43 _it ++;
44}
45
46const char* t_rtperr ( int _errno )
47{
48 if ( !_register )
49 return "Unregistered";
50
51 uint32_t _i;
52
53 for ( _i = _it; _i--; ) {
54 if ( _register[_i]._id == _errno ) {
55 return _register[_i]._message;
56 }
57 }
58
59 return "Invalid error id!";
60}
61
62void t_rtperr_print ( const char* _val, ... )
63{
64 va_list _args;
65 va_start ( _args, _val );
66 vfprintf ( stderr, _val, _args );
67 va_end ( _args );
68}