-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcommon.h
More file actions
81 lines (68 loc) · 2.03 KB
/
Copy pathcommon.h
File metadata and controls
81 lines (68 loc) · 2.03 KB
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
/*
* Copyright (C) 2009-2011 CompuLab, Ltd.
* Authors: Nikita Kiryanov <nikita@compulab.co.il>
* Igor Grinberg <grinberg@compulab.co.il>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _COMMON_
#define _COMMON_
#define COLOR_RED "\x1B[31m"
#define COLOR_GREEN "\x1B[32m"
#define COLOR_RESET "\033[0m"
#define MIN_I2C_BUS 0
#define MAX_I2C_BUS 255
#define MIN_I2C_ADDR 0x03
#define MAX_I2C_ADDR 0x77
#define STR_ENO_MEM "Out of memory"
// Macro for printing error messages
#define eprintf(args...) fprintf (stderr, args)
// Macro for printing input error messages
#define ie_fmt(fmt) "Input error: " fmt " - Operation Aborted!\n"
#define ieprintf(fmt, ...) eprintf(ie_fmt(fmt), ##__VA_ARGS__)
// Macro for handling debug checks
#ifndef DEBUG
#define ASSERT(args) ((void)0)
#else // ifndef DEBUG
void failed_assert(const char* func, char *file, int line);
#define ASSERT(arg) ((arg) ? ((void)0) : \
failed_assert(__func__, __FILE__, __LINE__))
#endif // ifndef DEBUG
struct field_change {
char *field;
char *value;
};
struct bytes_change {
int start;
int end;
int value;
};
struct bytes_range {
int start;
int end;
};
struct data_array {
int size;
union {
struct field_change *fields_changes;
struct bytes_change *bytes_changes;
char **fields_list;
struct bytes_range *bytes_list;
};
};
#define STRTOI_STR_CON 1
#define STRTOI_STR_END 2
int strtoi_base(char **str, int *dest, int base);
int strtoi(char **str, int *dest);
#endif