/*
       B R O C C O L I  --  The Bro Client Communications Library

Copyright (C) 2004-2008 Christian Kreibich <christian (at) icir.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies of the Software and its documentation and acknowledgment shall be
given in the documentation and software packages that this Software was
used.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/
#ifndef broccoli_util_h
#define broccoli_util_h

#include <broccoli.h>

#if HAVE_CONFIG_H
# include <config.h>
#endif

#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#ifndef MAX
#define	MAX(a,b) (((a)>(b))?(a):(b))
#endif

int      __bro_util_snprintf(char *str, size_t size, const char *format, ...);

void     __bro_util_fill_v4_addr(BroAddr *a, uint32 addr);

void     __bro_util_fill_subnet(BroSubnet *sn, uint32 net, uint32 width);

double   __bro_util_get_time(void);

double   __bro_util_timeval_to_double(const struct timeval *tv);

int      __bro_util_is_v4_addr(const BroAddr* a);

#ifdef WORDS_BIGENDIAN
#define  __bro_util_ntohd(x) x
#define  __bro_util_htond(x) x
#define  __bro_util_ntohll(x) x
#define  __bro_util_htonll(x) x
#else
double   __bro_util_htond(double d);
double   __bro_util_ntohd(double d);
uint64   __bro_util_htonll(uint64 i);
uint64   __bro_util_ntohll(uint64 i);
#endif

#endif
