Xively Official / mbed-libxively-5d6fdd4

Dependents:   xively-jumpstart-demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers xi_macros.h Source File

xi_macros.h

Go to the documentation of this file.
00001 // Copyright (c) 2003-2013, LogMeIn, Inc. All rights reserved.
00002 // This is part of Xively C library, it is under the BSD 3-Clause license.
00003 
00004 /**
00005  * \file    xi_macros.h
00006  * \author  Olgierd Humenczuk
00007  * \brief   General macros used by the library
00008  */
00009 
00010 #ifndef __XI_MACROS_H__
00011 #define __XI_MACROS_H__
00012 
00013 #include <string.h>
00014 
00015 #define XI_STR_EXPAND(tok) #tok
00016 #define XI_STR(tok) XI_STR_EXPAND(tok)
00017 #define XI_MIN(a,b) (a)<(b)?(a):(b)
00018 #define XI_MAX(a,b) (a)<(b)?(b):(a)
00019 #define XI_UNUSED(x) (void)(x)
00020 
00021 #define XI_GUARD_EOS(s,size) { (s)[ (size) - 1 ] = '\0'; }
00022 
00023 #define XI_CLAMP(a,b,t) XI_MIN( XI_MAX( (a), (b) ), (t) )
00024 
00025 #define XI_CHECK_CND(cnd,e) if( (cnd) ) { xi_set_err( (e) ); goto err_handling; }
00026 #define XI_CHECK_ZERO(a,e) XI_CHECK_CND((a) == 0,(e))
00027 #define XI_CHECK_NEG(a) if( (a) < 0 ) )
00028 #define XI_CHECK_PTR(a,b) if( (a) == (b) )
00029 #define XI_SAFE_FREE(a) if( (a) ) { xi_free(a); (a) = 0; }
00030 #define XI_CHECK_MEMORY(a) XI_CHECK_CND((a) == 0,XI_OUT_OF_MEMORY)
00031 #define XI_CHECK_SIZE(a,b,e) XI_CHECK_CND(((a) >= (b) || (a) < 0 ),e)
00032 #define XI_CLEAR_STATIC_BUFFER(a) memset( (a), 0, sizeof(a) )
00033 #define XI_CHECK_S(s,size,o,e) {\
00034     XI_CHECK_SIZE(s,size-o,e)\
00035     else\
00036     {\
00037         (o) += (s);\
00038     }}
00039 
00040 #endif //__XI_MACROS_H__