add function short2buff and buff2short
parent
0dd3d17c92
commit
090c6f819d
3
HISTORY
3
HISTORY
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
Version 1.06 2014-05-28
|
Version 1.06 2014-05-30
|
||||||
* update source code from FastDFS V5.02
|
* update source code from FastDFS V5.02
|
||||||
|
* add function short2buff and buff2short
|
||||||
|
|
||||||
Version 1.05 2012-07-08
|
Version 1.05 2012-07-08
|
||||||
* update source code from FastDFS V3.09
|
* update source code from FastDFS V3.09
|
||||||
|
|
|
||||||
|
|
@ -1140,6 +1140,20 @@ int safeWriteToFile(const char *filename, const char *buff, \
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void short2buff(const short n, char *buff)
|
||||||
|
{
|
||||||
|
unsigned char *p;
|
||||||
|
p = (unsigned char *)buff;
|
||||||
|
*p++ = (n >> 8) & 0xFF;
|
||||||
|
*p++ = n & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
short buff2short(const char *buff)
|
||||||
|
{
|
||||||
|
return (short)((((unsigned char)(*(buff))) << 8) | \
|
||||||
|
((unsigned char)(*(buff+1))));
|
||||||
|
}
|
||||||
|
|
||||||
void int2buff(const int n, char *buff)
|
void int2buff(const int n, char *buff)
|
||||||
{
|
{
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,21 @@ char *hex2bin(const char *s, char *szBinBuff, int *nDestLen);
|
||||||
*/
|
*/
|
||||||
void printBuffHex(const char *s, const int len);
|
void printBuffHex(const char *s, const int len);
|
||||||
|
|
||||||
|
/** 16 bits int convert to buffer (big-endian)
|
||||||
|
* parameters:
|
||||||
|
* n: 16 bits int value
|
||||||
|
* buff: the buffer, at least 2 bytes space, no tail \0
|
||||||
|
* return: none
|
||||||
|
*/
|
||||||
|
void short2buff(const short n, char *buff);
|
||||||
|
|
||||||
|
/** buffer convert to 16 bits int
|
||||||
|
* parameters:
|
||||||
|
* buff: big-endian 2 bytes buffer
|
||||||
|
* return: 16 bits int value
|
||||||
|
*/
|
||||||
|
short buff2short(const char *buff);
|
||||||
|
|
||||||
/** 32 bits int convert to buffer (big-endian)
|
/** 32 bits int convert to buffer (big-endian)
|
||||||
* parameters:
|
* parameters:
|
||||||
* n: 32 bits int value
|
* n: 32 bits int value
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue