-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool.h
More file actions
39 lines (32 loc) · 892 Bytes
/
tool.h
File metadata and controls
39 lines (32 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef TOOL_H
#define TOOL_H
#include "stdio.h"
#include "stdlib.h"
void Hex2Str( const char *sSrc, char *sDest, int nSrcLen );
void char2IP( const char *sSrc, char *sDest, int nSrcLen );
#endif // TOOL_H
void char2Mac( const char *sSrc, char *sDest, int nSrcLen )
{
int i;
char szTmp[4];
for( i = 0; i < nSrcLen; i++ )
{
sprintf( szTmp, "%02X", (unsigned char) sSrc[i] );
memcpy( &sDest[i * 3], szTmp, 2 );
sDest[3*i+2]=':';
}
sDest[nSrcLen*2+nSrcLen-1]='\0';
return ;
}
void char2IP( const char *sSrc, char *sDest, int nSrcLen ){
int i;
char szTmp[5];
for( i = 0; i < nSrcLen; i++ )
{
sprintf( szTmp, "%3d", (unsigned char) sSrc[i] );
memcpy( &sDest[i * 4], szTmp, 3);
sDest[4*i+3]='.';
}
sDest[nSrcLen*3+nSrcLen-1]='\0';
return ;
}