diff options
author | Andris Zeila <andris.zeila@zabbix.com> | 2016-12-22 18:15:40 +0300 |
---|---|---|
committer | Andris Zeila <andris.zeila@zabbix.com> | 2016-12-22 18:15:40 +0300 |
commit | 07c09bcc238a0d37c74b4bd0d4d062a93dc04bdb (patch) | |
tree | a4c93384c9ab813eca26f0c02d1995c8100a2f8f /include/zbxserialize.h | |
parent | 19cba8797d840881036d9b9381b8b7d3e5aa3dd3 (diff) |
.......PS. [ZBXNEXT-3386] added IPMI manager/pollers (with stubs intead of real IPMI checks)
Diffstat (limited to 'include/zbxserialize.h')
-rw-r--r-- | include/zbxserialize.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/include/zbxserialize.h b/include/zbxserialize.h new file mode 100644 index 00000000000..13b26538711 --- /dev/null +++ b/include/zbxserialize.h @@ -0,0 +1,76 @@ +/* +** Zabbix +** Copyright (C) 2001-2016 Zabbix SIA +** +** 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, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#ifndef ZABBIX_SERIALIZE_H +#define ZABBIX_SERIALIZE_H + +#include "common.h" + +#define zbx_serialize_uint64(buffer, value) (memcpy(buffer, &value, sizeof(zbx_uint64_t)), sizeof(zbx_uint64_t)) + +#define zbx_serialize_int(buffer, value) (memcpy(buffer, (int *)&value, sizeof(int)), sizeof(int)) + +#define zbx_serialize_short(buffer, value) (memcpy(buffer, (short *)&value, sizeof(short)), sizeof(short)) + +#define zbx_serialize_char(buffer, value) (*buffer = (char)value, sizeof(char)) + +#define zbx_serialize_str(buffer, value, len) \ + (memcpy(buffer, (zbx_uint32_t *)&len, sizeof(zbx_uint32_t)), \ + memcpy(buffer + sizeof(zbx_uint32_t), value, len), \ + len + sizeof(zbx_uint32_t)) + +#define zbx_serialize_str_null(buffer) \ + ( \ + memset(buffer, 0, sizeof(zbx_uint32_t)), \ + sizeof(zbx_uint32_t) \ + ) + +#define zbx_deserialize_uint64(buffer, value) \ + (memcpy(value, buffer, sizeof(zbx_uint64_t)), sizeof(zbx_uint64_t)) + +#define zbx_deserialize_int(buffer, value) \ + (memcpy(value, buffer, sizeof(int)), sizeof(int)) + +#define zbx_deserialize_short(buffer, value) \ + (memcpy(value, buffer, sizeof(short)), sizeof(short)) + +#define zbx_deserialize_char(buffer, value) \ + (*value = *buffer, sizeof(char)) + +#define zbx_deserialize_str(buffer, value, value_len) \ + ( \ + memcpy(&value_len, buffer, sizeof(zbx_uint32_t)), \ + 0 < value_len ? ( \ + *value = malloc(value_len + 1), \ + memcpy(*(value), buffer + sizeof(zbx_uint32_t), value_len), \ + (*value)[value_len] = '\0' \ + ) : (*value = NULL, 0), \ + value_len + sizeof(zbx_uint32_t) \ + ) + +#define zbx_deserialize_str_s(buffer, value, value_len) \ + ( \ + memcpy(&value_len, buffer, sizeof(zbx_uint32_t)), \ + memcpy(value, buffer + sizeof(zbx_uint32_t), value_len), \ + value[value_len] = '\0', \ + value_len + sizeof(zbx_uint32_t) \ + ) + + +#endif /* ZABBIX_SERIALIZE_H */ |