1 Star 0 Fork 13

云丽网络科技有限公司 / mbinlogmq

forked from Josin / mbinlogmq 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
endian.h 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
liqiongfan 提交于 2019-07-25 17:23 . 增加了double、float类型解析
/**
* Copyright @2019 Josin All Rights Reserved.
* Author: Josin
* Email : xeapplee@gmail.com
*/
#ifndef MYSQL_BINLOG_ENDIAN_H
#define MYSQL_BINLOG_ENDIAN_H
/**
* @brief NOTICE
* Some macro for generate the value from little to big endian or for another
*/
#include <fc_string.h>
#define GLOBAL_VARS
GLOBAL_VARS int IS_BIGENDIAN;
#define int32_cbit(i) ( ((i) & 0x000000ffu) << 24 | ( (i) & 0x0000ff00u ) << 8 | ( ((i) & 0x00ff0000u) >> 8) | ( (i) & 0xff000000u ) >> 24 )
#define int64_cbit(i) ( int32_cbit((i) & 0x0ffffffffu) << 32 | int32_cbit( ((i) >> 32) & 0x0ffffffffu) )
static
int big_endian() {
union {
short a:2;
char b[2];
} ua;
ua.b[0] = 0x11;
ua.b[1] = 0x22;
if ( (ua.a & 0x0ff) == 0x11 ) {
return 1; /* Big endian */
} else {
return 0; /* Little endian */
}
}
long long exchange_copy_data_from_little(char *little_memory, int num); /* Only used for MySQL DATE type */
long long copy_data_from_little(char *little_memory, int num);
/**
* @brief NOTICE
* Machine except.
*/
long copy_number_from_little_stream(char *src, int num);
long copy_number_from_big_stream(char *src, int num);
double copy_double_from_little_stream(char *src, int num);
float copy_float_from_little_stream(char *src, int num);
long copy_number_from_bit( long num, int numbit, int begin_pos, int length );
long bitsets_in_var( int num );
#endif /* MYSQL_BINLOG_ENDIAN_H */
C
1
https://gitee.com/style1987/mbinlogmq.git
git@gitee.com:style1987/mbinlogmq.git
style1987
mbinlogmq
mbinlogmq
release

搜索帮助