show data
来源:互联网 发布:服务器防ddos攻击软件 编辑:程序博客网 时间:2024/05/04 13:18
#include <stdio.h>
#include <stdlib.h>
#define SHOW_DATA(_buf, _len) func(#_buf, _buf, _len)
void func(const char *name, const char *buffer, const int len)
{
char tmpbuf[8] = {0};
char bufout[40] = {0};
int lenremaining = len;
const char *bufidx = buffer;
printf("\"name\"'s %d bytes are shown below:\n", len);
while (lenremaining)
{
int lentocopy = (lenremaining > 8) ? 8 : lenremaining;
memset(tmpbuf, 0, 8);
memset(bufout, 0, 40);
memcpy(tmpbuf, bufidx, lentocopy);
lenremaining -= lentocopy;
sprintf(bufout, "%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c",
(unsigned char)tmpbuf[0],(tmpbuf[0]>32&&tmpbuf[0]<127)?tmpbuf[0]:(' '),
(unsigned char)tmpbuf[1],(tmpbuf[1]>32&&tmpbuf[1]<127)?tmpbuf[1]:(' '),
(unsigned char)tmpbuf[2],(tmpbuf[2]>32&&tmpbuf[2]<127)?tmpbuf[2]:(' '),
(unsigned char)tmpbuf[3],(tmpbuf[3]>32&&tmpbuf[3]<127)?tmpbuf[3]:(' '),
(unsigned char)tmpbuf[4],(tmpbuf[4]>32&&tmpbuf[4]<127)?tmpbuf[4]:(' '),
(unsigned char)tmpbuf[5],(tmpbuf[5]>32&&tmpbuf[5]<127)?tmpbuf[5]:(' '),
(unsigned char)tmpbuf[6],(tmpbuf[6]>32&&tmpbuf[6]<127)?tmpbuf[6]:(' '),
(unsigned char)tmpbuf[7],(tmpbuf[7]>32&&tmpbuf[7]<127)?tmpbuf[7]:(' ')
);
bufidx += 8;
printf("%s\n", bufout);
}
}
int main(int argc, char *argv[])
{
char buf[] = {67, -3, 23, 198, 245, 56, 22, -98, 23, 1, -45, 67, 136};
SHOW_DATA(buf, sizeof(buf));
system("PAUSE");
return 0;
}
#include <stdlib.h>
#define SHOW_DATA(_buf, _len) func(#_buf, _buf, _len)
void func(const char *name, const char *buffer, const int len)
{
char tmpbuf[8] = {0};
char bufout[40] = {0};
int lenremaining = len;
const char *bufidx = buffer;
printf("\"name\"'s %d bytes are shown below:\n", len);
while (lenremaining)
{
int lentocopy = (lenremaining > 8) ? 8 : lenremaining;
memset(tmpbuf, 0, 8);
memset(bufout, 0, 40);
memcpy(tmpbuf, bufidx, lentocopy);
lenremaining -= lentocopy;
sprintf(bufout, "%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c\t%02X-%c",
(unsigned char)tmpbuf[0],(tmpbuf[0]>32&&tmpbuf[0]<127)?tmpbuf[0]:(' '),
(unsigned char)tmpbuf[1],(tmpbuf[1]>32&&tmpbuf[1]<127)?tmpbuf[1]:(' '),
(unsigned char)tmpbuf[2],(tmpbuf[2]>32&&tmpbuf[2]<127)?tmpbuf[2]:(' '),
(unsigned char)tmpbuf[3],(tmpbuf[3]>32&&tmpbuf[3]<127)?tmpbuf[3]:(' '),
(unsigned char)tmpbuf[4],(tmpbuf[4]>32&&tmpbuf[4]<127)?tmpbuf[4]:(' '),
(unsigned char)tmpbuf[5],(tmpbuf[5]>32&&tmpbuf[5]<127)?tmpbuf[5]:(' '),
(unsigned char)tmpbuf[6],(tmpbuf[6]>32&&tmpbuf[6]<127)?tmpbuf[6]:(' '),
(unsigned char)tmpbuf[7],(tmpbuf[7]>32&&tmpbuf[7]<127)?tmpbuf[7]:(' ')
);
bufidx += 8;
printf("%s\n", bufout);
}
}
int main(int argc, char *argv[])
{
char buf[] = {67, -3, 23, 198, 245, 56, 22, -98, 23, 1, -45, 67, 136};
SHOW_DATA(buf, sizeof(buf));
system("PAUSE");
return 0;
}
- show data
- Use Django to show data
- debug : show value as binary data
- Using Python to show the test data
- angular js data-ng-show, data-ng-disabled
- Linux下show “error attaching device data”的原因分析
- On data dictionary synchronization errors:show which table is error
- Retrieve data from xml and show in listField
- Show of Gridview Header with Empty Data Source
- Asp.net Data list control show Image example
- show
- show
- Extjs store load json data,store fields mapping can't show data
- An example to show how to make Tree structure data table in SQL server
- 掷双骰结果统计(Show statistical data of Craps (Rolling of two dice))
- Use LCD Keyboard Shieid to show color sensor's data which received [1.2]
- Use LCD Keyboard Shieid to show color sensor's data which received [2.1]
- 【O'Reilly Data Show】机器学习将如何加速数据管理系统
- iPhone:创建、连接和使用静态库
- 手把手教你玩转ARP包(完)【数据包的游戏系列之一】
- anscii 表
- monkeyrunner其他测试例子收集,便于理解python一些基本用法
- Doclist压缩方法简介 [转者注:搜索引擎设计的倒排索引设计中文档列表的存储压缩]
- show data
- 手把手教你玩转网络编程模型之完成例程(Completion Routine)篇(上)
- 手把手教你玩转网络编程模型之完成例程(Completion Routine)篇(下)
- Java Classloader
- 完成端口详解 - 手把手教你玩转网络编程系列之三
- 给工厂分配采购组织
- PB中文本框设置成透明效果
- android开发学习笔记(2)android的基本介绍
- svn文件冲突,树冲突详解