00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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