1 /**************************************************************************\ 2 * Copyright (c) Kongsberg Oil & Gas Technologies AS 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * Neither the name of the copyright holder nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 \**************************************************************************/ 32 33 #ifndef COIN_TIDBITS_H 34 #define COIN_TIDBITS_H 35 36 #include <Inventor/C/basic.h> 37 #include <stdarg.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif /*__cplusplus */ 42 43 /* ********************************************************************** */ 44 45 enum CoinEndiannessValues { 46 COIN_HOST_IS_UNKNOWNENDIAN = -1, 47 COIN_HOST_IS_LITTLEENDIAN = 0, 48 COIN_HOST_IS_BIGENDIAN = 1 49 }; 50 51 COIN_DLL_API int coin_host_get_endianness(void); 52 53 COIN_DLL_API int coin_snprintf(char * dst, unsigned int n, const char * fmtstr, ...); 54 COIN_DLL_API int coin_vsnprintf(char * dst, unsigned int n, const char * fmtstr, va_list args); 55 56 COIN_DLL_API const char * coin_getenv(const char * name); 57 COIN_DLL_API SbBool coin_setenv(const char * name, const char * value, int overwrite); 58 COIN_DLL_API void coin_unsetenv(const char * name); 59 60 COIN_DLL_API int coin_strncasecmp(const char * str1, const char * str2, int len); 61 62 COIN_DLL_API uint16_t coin_hton_uint16(uint16_t value); 63 COIN_DLL_API uint16_t coin_ntoh_uint16(uint16_t value); 64 COIN_DLL_API uint32_t coin_hton_uint32(uint32_t value); 65 COIN_DLL_API uint32_t coin_ntoh_uint32(uint32_t value); 66 COIN_DLL_API uint64_t coin_hton_uint64(uint64_t value); 67 COIN_DLL_API uint64_t coin_ntoh_uint64(uint64_t value); 68 69 COIN_DLL_API void coin_hton_float_bytes(float value, char * result); /* expects room for 4 bytes in result*/ 70 COIN_DLL_API float coin_ntoh_float_bytes(const char * value); /* expects 4 bytes input */ 71 72 COIN_DLL_API void coin_hton_double_bytes(double value, char * result); /* expects room for 8 bytes in result */ 73 COIN_DLL_API double coin_ntoh_double_bytes(const char * value); /* expects 8 bytes input */ 74 75 COIN_DLL_API SbBool coin_isascii(const int c); 76 COIN_DLL_API SbBool coin_isspace(const char c); 77 78 COIN_DLL_API SbBool coin_is_power_of_two(uint32_t x); 79 COIN_DLL_API uint32_t coin_next_power_of_two(uint32_t x); 80 COIN_DLL_API uint32_t coin_geq_power_of_two(uint32_t x); 81 82 COIN_DLL_API void coin_viewvolume_jitter(int numpasses, int curpass, const int * vpsize, float * jitter); 83 84 typedef void coin_atexit_f(void); 85 COIN_DLL_API void cc_coin_atexit(coin_atexit_f * fp); 86 87 /* Used internally to clean up static data. Do not use in application code */ 88 COIN_DLL_API void cc_coin_atexit_static_internal(coin_atexit_f * fp); 89 90 /* ********************************************************************** */ 91 92 #ifdef __cplusplus 93 } /* extern "C" */ 94 #endif /* __cplusplus */ 95 96 #endif /* !COIN_TIDBITS_H */ 97