| 1 | /* |
| 2 | * This library is free software; you can redistribute it and/or |
| 3 | * modify it under the terms of the GNU Lesser General Public |
| 4 | * License as published by the Free Software Foundation; either |
| 5 | * version 2.1 of the License, or (at your option) any later version. |
| 6 | * |
| 7 | * This library is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 10 | * Lesser General Public License for more details. |
| 11 | * |
| 12 | * You should have received a copy of the GNU Lesser General Public |
| 13 | * License along with this library; if not, write to the Free Software |
| 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 15 | * |
| 16 | * misc.h |
| 17 | * Header file for misc.c |
| 18 | * Copyright (C) 2004-2005 Simon Newton |
| 19 | */ |
| 20 | |
| 21 | #ifndef ARTNET_MISC_H |
| 22 | #define ARTNET_MISC_H |
| 23 | |
| 24 | #include <errno.h> |
| 25 | #include <string.h> |
| 26 | |
| 27 | extern char artnet_errstr[256]; |
| 28 | void artnet_error(const char *fmt, ...); |
| 29 | int32_t artnet_misc_nbytes_to_32(uint8_t bytes[4]); |
| 30 | void artnet_misc_int_to_bytes(int data, uint8_t *bytes); |
| 31 | |
| 32 | // check if the node is null and return an error |
| 33 | #define check_nullnode(node) if (node == NULL) { \ |
| 34 | artnet_error("%s : argument 1 (artnet_node) was null" , __FUNCTION__ ); \ |
| 35 | return ARTNET_EARG; \ |
| 36 | } |
| 37 | |
| 38 | #define artnet_error_malloc() artnet_error("%s : malloc error %s" , __FUNCTION__, strerror(errno) ) |
| 39 | #define artnet_error_realloc() artnet_error("%s : realloc error %s" , __FUNCTION__, strerror(errno) ) |
| 40 | #define artnet_error_nullnode() artnet_error("%s : argument 1 (artnet_node) was null" , __FUNCTION__ ) |
| 41 | |
| 42 | #endif |