util.h (r4203/r3509)

Go to the documentation of this file.
00001         /*
00002  * $Id: util.h 3509 2006-10-19 19:19:58Z scholl $
00003  *
00004  * Copyright (c) 2004
00005  * Telecooperation Office (TecO), Universitaet Karlsruhe (TH), Germany.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above
00014  *    copyright notice, this list of conditions and the following
00015  *    disclaimer in the documentation and/or other materials provided
00016  *    with the distribution.
00017  * 3. Neither the name of the Universitaet Karlsruhe (TH) nor the names
00018  *    of its contributors may be used to endorse or promote products
00019  *    derived from this software without specific prior written
00020  *    permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00026  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * Author(s): Max Laier <mlaier@freebsd.org>
00035  *                        Thomas Morper <morper@teco.edu>
00036  */
00037 
00043 #ifndef _UTIL_H_
00044 #define _UTIL_H_
00045 
00046 #ifndef MIN
00047 
00048 #define MIN(a, b)       (((a)<(b))?(a):(b))
00049 #endif
00050 
00056 
00066 LIBPARTICLE_API int p_util_escape(unsigned char * out_data, const unsigned char * in_data, size_t len, size_t maxlen);
00067 
00077 LIBPARTICLE_API int p_util_unescape(unsigned char * out_data, const unsigned char * in_data, size_t len, size_t maxlen);
00078 
00086 LIBPARTICLE_API int p_util_decode_dot(uint8_t * out, const char * dotted_str, size_t len);
00087 
00096 LIBPARTICLE_API char *p_util_acl2str(const uint8_t * acl_type, char * out);
00097 
00106 LIBPARTICLE_API uint8_t  *p_util_str2acl(const char * in, uint8_t * acl_type);
00107 
00132 LIBPARTICLE_API void    p_util_location2raw(uint8_t root[16] , const char * node1, const char * node2, 
00133         const char * node3, const char * node4, int x, int y, int z, uint8_t deviation, unsigned char location[44]);
00134 
00151 LIBPARTICLE_API void    p_util_raw2location(uint8_t root[16] , char node1[10], char node2[10], char node3[10],
00152             char node4[10], int * x, int * y, int * z, uint8_t * deviation, const unsigned char location[44]);
00153 
00162 LIBPARTICLE_API int p_util_3to2(uint8_t * out, const char * in, size_t len);
00163 
00172 LIBPARTICLE_API int p_util_2to3(char * out, const uint8_t * in, size_t len);
00173 
00183 LIBPARTICLE_API int     p_util_crc16(const char * data, size_t length, uint8_t * phb, uint8_t * plb);
00184 
00193 LIBPARTICLE_API int     p_util_crc16_append(char * data, size_t length);
00194 
00201 LIBPARTICLE_API int     p_util_crc16_check(const char * data, size_t length);
00202 
00210 LIBPARTICLE_API int p_util_get_local_interfaces(uint32_t ip[], uint32_t broadcast[], size_t max);
00211 
00221 LIBPARTICLE_API int p_util_get_local_addresses(uint32_t * ip, uint32_t * broadcast);
00222 
00227 LIBPARTICLE_API uint32_t p_util_getmstime();
00228 
00233 LIBPARTICLE_API void p_util_sleepms(unsigned long milliseconds);
00234 
00239 LIBPARTICLE_API char* p_util_strerr(int error);
00240 
00245 LIBPARTICLE_API void p_util_perror(const char* str);
00246 
00254 LIBPARTICLE_API char* p_util_location2WKT(const unsigned char location[44], char* wkt, size_t n);
00255 
00258 #endif /* _UTIL_H_ */

Generated on Tue Apr 10 15:22:26 2007 for libparticle by  doxygen 1.5.1