diff options
author | Finn Behrens <me@kloenk.de> | 2021-02-26 23:43:13 +0100 |
---|---|---|
committer | Finn Behrens <me@kloenk.de> | 2021-02-26 23:43:13 +0100 |
commit | 03a59a6b035c26456784916793fa674b4b36b4c5 (patch) | |
tree | 7741a6e7fb795bf087193c14f81c425c6a1bb095 /protocol.h | |
parent | eb00d6a4f192392225941a57293dba8ba8670a70 (diff) | |
download | mcc-03a59a6b035c26456784916793fa674b4b36b4c5.tar.gz mcc-03a59a6b035c26456784916793fa674b4b36b4c5.tar.xz mcc-03a59a6b035c26456784916793fa674b4b36b4c5.zip |
refactor
Diffstat (limited to 'protocol.h')
-rw-r--r-- | protocol.h | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -14,6 +14,8 @@ #include <stdio.h> #include <errno.h> +#define PROTOCOL_VERSION 0 + // MARK: - Helpers #if defined(__APPLE__) #include <libkern/OSByteOrder.h> @@ -40,14 +42,20 @@ #define pos_bufferx(x, y) ((x + y)) #define pos_buffer(x) pos_bufferx(x, counter) -#define check_addx(func, x) \ -{ \ +/*#define check_addx(func, x) \ if (func < 0) \ return func; \ - x += func; \ -} + x += func;*/ #define check_add(func) check_addx(func, counter) +int inline check_addx(int func, int *x) +{ + if (func < 0) + return func; + *x += func; + return 0; +} + // MARK: - READ // MARK: VAR @@ -83,7 +91,7 @@ typedef struct { int read_position(position_t *dest, uint8_t *src); // string -int read_string_malloc(char *str, uint8_t *src); +int read_string_malloc(char *dest, uint8_t *src); // MARK: - WRITE // MARK: VAR @@ -93,6 +101,6 @@ int write_var_long(long value, uint8_t *dest); // MARK: primitives // string -int write_string(char *str, uint8_t *dest, int size); +int write_string(const char *str, uint8_t *dest, int size); #endif /* protocol_h */ |