/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\

File: oct_ws_macro.c

Copyright (c) 2014 Octasic Inc. All rights reserved.

Description:	Wireshark macro

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation; either version 3 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 Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Release: Octasic Application Development Framework OCTADF-01.00.01-B497 (2014/01/09)

$Octasic_Revision: 4 $


\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#ifndef __OCT_WS_MACRO_H__
#define __OCT_WS_MACRO_H__

/*****************************  INCLUDE FILES  *******************************/
#include <color.h>
#include <color_filters.h>

/*****************************  DEFINES **************************************/
#ifndef UNUSED
#ifdef __GNUC__
#  define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#else
#  define UNUSED(x) UNUSED_ ## x
#endif
#endif

#ifndef UNUSED_FUNCTION
#ifdef __GNUC__
#  define UNUSED_FUNCTION(x) __attribute__((__unused__)) UNUSED_ ## x
#else
#  define UNUSED_FUNCTION(x) UNUSED_ ## x
#endif
#endif

#define mWS_RED_COMPONENT(x)   (guint16) (((((x) >> 16) & 0xff) * 65535 / 255))
#define mWS_GREEN_COMPONENT(x) (guint16) (((((x) >>  8) & 0xff) * 65535 / 255))
#define mWS_BLUE_COMPONENT(x)  (guint16) ( (((x)        & 0xff) * 65535 / 255))

#define mWS_FIELDSIZE( type, field)		(sizeof(((type *)0)->field))
#define mWS_FIELDOFFSET(type, field)    ((guint32)&(((type *)0)->field))
#define mWS_COUNTOF(array) (sizeof(array)/sizeof(array[0]))

#if defined(VERSION_MAJOR) && (VERSION_MAJOR > 1 || (VERSION_MAJOR == 1 && VERSION_MINOR > 8))
#define OCT_MATCH_STRVAL_IDX(a,b,c) try_val_to_str_idx(a,b,c)
#else
#define OCT_MATCH_STRVAL_IDX(a,b,c) match_strval_idx(a,b,c)
#define dissector_add_uint(a,b,c)	dissector_add(a,b,c)
#endif

#endif /* __OCT_WS_MACRO_H__ */
