?? exchanger.cpp
字號:
#include "stdafx.h"
#include "exchanger.h"
int Exchanger::initlize(char *src, char *tag)
{
if ((m_pSourceFile = fopen(src, "r")) == NULL)
{
return 1;
}
if ((m_pTargetFile = fopen(tag, "wb")) == NULL)
{
return 2;
}
return 0;
};
int Exchanger::process()
{
char CapHeader[] = { 0xD4, 0xC3, 0xB2, 0xA1, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};
char TimeStamp[8] = {0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
int iFrameLength = 0;
char chCountBuf[2];
char buf[4096];
int i = 0, j = 0, totalLen = 0;
char chRdbuf = 0;
char hexNum;
if ((m_pSourceFile == NULL) || (m_pTargetFile == NULL))
{
return -1;
}
memset(buf, 0, 4096);
// write the header
fwrite(CapHeader, 24, 1, m_pTargetFile);
while ((chRdbuf = getc(m_pSourceFile)) != EOF)
{
switch(chRdbuf)
{
case ' ':
case '\n':
hexNum = chCountBuf[0]*16 + chCountBuf[1];
buf[j] = hexNum;
j++;
memset(chCountBuf, 0, 2);
i = 0;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
chCountBuf[i] = chRdbuf - 48;
i++;
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
chCountBuf[i] = chRdbuf - 55;
i++;
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
chCountBuf[i] = chRdbuf - 87;
i++;
break;
case '#':
totalLen = j;
// j = j - 4; // using for loop length, from 0 to
fwrite(TimeStamp, 8, 1, m_pTargetFile);
fwrite(&totalLen, 4, 1, m_pTargetFile);
fwrite(&totalLen, 4, 1, m_pTargetFile);
// memcpy(buf, &j, sizeof(j));
// memcpy(&buf[totalLen], &iTail, sizeof(int));
fwrite(buf, totalLen, 1, m_pTargetFile);
chRdbuf = getc(m_pSourceFile);
// start a new one
j = 0;
i = 0;
totalLen = 0;
memset(buf, 0, 4096);
break;
default:
break;
}
}
fclose(m_pSourceFile);
fclose(m_pTargetFile);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -