-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathosc_error.h
123 lines (102 loc) · 3.89 KB
/
osc_error.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Written by John MacCallum, The Center for New Music and Audio Technologies,
University of California, Berkeley. Copyright (c) 2009-ll, The Regents of
the University of California (Regents).
Permission to use, copy, modify, distribute, and distribute modified versions
of this software and its documentation without fee and without a signed
licensing agreement, is hereby granted, provided that the above copyright
notice, this paragraph and the following two paragraphs appear in all copies,
modifications, and distributions.
IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
#ifndef __OSC_ERROR_H__
#define __OSC_ERROR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <libgen.h>
typedef uint64_t t_osc_err;
typedef int (*t_osc_error_handler)(void *context, const char * const errorstr);
#define OSC_ERROR_VERBOSE(context, errorcode, moreinfo_fmt, ...) \
osc_error_handler(context, __FILE__, __func__, __LINE__, errorcode, moreinfo_fmt, ##__VA_ARGS__);
//osc_error_handler(context, basename(__FILE__), __func__, __LINE__, errorcode, moreinfo_fmt, ##args);
#define OSC_ERROR_SIMPLE(context, errorcode, moreinfo_fmt, ...) \
osc_error_handler(context, NULL, NULL, -1, errorcode, moreinfo_fmt, ##__VA_ARGS__);
//#define OSC_ERROR_VERBOSE_REPORTING
#ifdef OSC_ERROR_VERBOSE_REPORTING
#define osc_error OSC_ERROR_VERBOSE
#else
#define osc_error OSC_ERROR_SIMPLE
#endif
#define MAX_ERR_STRING_LEN 4096
#define OSC_ERR_NONE 0
#define OSC_ERR_BUNDLETOOSMALL 0x1
#define OSC_ERR_NOBUNDLEID 0x2
#define OSC_ERR_MSGTOOSMALL 0x4
#define OSC_ERR_MALFORMEDADDRESS 0x8
#define OSC_ERR_NOBUNDLE 0x10
#define OSC_ERR_OUTOFMEM 0x11
#define OSC_ERR_NULLPTR 0x12
#define OSC_ERR_BADTYPETAG 0x14
#define OSC_ERR_MALFORMEDMSG 0x18
#define OSC_ERR_INVAL 0x20
#define OSC_ERR_EXPPARSE 0x21
#define OSC_ERR_MSGTOOLARGE 0x22
#define OSC_ERR_INVALIDCHARINADDRESS 0x24
#define OSC_ERR_PARSER_FUNCTIONNOTFOUND 0x100
#define OSC_ERR_EXPR_FUNCTIONNOTFOUND 0x101
#define OSC_ERR_EXPR_ADDRESSUNBOUND 0x102
#define OSC_ERR_EXPR_ARGCHK 0x104
#define OSC_ERR_EXPR_EVAL 0x108
#define OSC_ERR_PARSER 0x1000
int osc_error_handler(void *context,
const char * const filename,
const char * const functionname,
int linenum,
t_osc_err errorcode,
const char * const moreinfo_fmt,
...);
void osc_error_setHandler(t_osc_error_handler eh);
/**
* Get a description of an error code.
*
* @param err The error code
* @return A string that describes the error.
*/
char *osc_error_string(t_osc_err err);
/**
* Verify that a bundle is constructed properly.
*
* @param len The length of the bundle in bytes.
* @param bundle The bundle to be verified.
* @return An error code or #OSC_ERR_NONE
*/
t_osc_err osc_error_bundleSanityCheck(int len, char *bundle);
/**
* Verify that a message is constructed properly. The lengthe should be encoded in network
* order in the first 4 bytes which is why it is not passed as a parameter to the function.
*
* @param msg The message to be verified.
* @return An error code or #OSC_ERR_NONE
*/
t_osc_err osc_error_msgSanityCheck(char *msg);
/**
* Verify that an address is a properly formated OSC address.
*
* @param address The message to be verified.
* @return An error code or #OSC_ERR_NONE
*/
t_osc_err osc_error_validateAddress(char *address);
#ifdef __cplusplus
}
#endif
#endif // __OSC_ERROR_H__