test.c
test.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h> void dump_line(const unsigned char* buf, int w, int l)
{
#define YYYGET(X) ( X >= 32 && X <= 126) ? X : '.'
unsigned int i = 0;
printf("%08x: ", l);
for (; i < w; ++i)
printf((i % 8 == 7) ? "%02x " : "%02x ", *(buf+i));
if (w < 0x10)
{
for (i = 0; i < 0x10 - w; ++i) printf(" ");
printf(" ");
}
printf ("|");
for (i = 0; i < w; ++i)
printf ("%c", YYYGET(*(buf+i)));
if (w < 0x10)
for (i = 0; i < 0x10 - w; ++i) printf(" ");
printf ("|\n");
#undef YYYGET
} void dump_buffer(const unsigned char* buf, int max)
{
int l = max / 0x10 + ((max % 0x10) ? 1 : 0);
printf ("l = %d\n",l);
int i = 0;
int w = l - i > 1 ? 0x10 : max;
const unsigned char* ptr = buf;
for (; i < l; ++i,w = l - i > 1 ? 0x10 : max - 0x10 * i)
{
dump_line(ptr, w, i);
ptr += w;
}
} int main(int argc, char *argv[])
{
if (argc < 3)
{
printf ("Usage: %s FileName, number.\n", argv[0]);
exit(1);
} int fd = open(argv[1], O_RDONLY);
if (fd != -1)
{
int s = atoi(argv[2]);
unsigned char* buf = malloc(s+1);
memset(buf, 0, s+1);
read(fd, buf, s);
dump_buffer(buf, s);
}
return 0;
}
随机推荐
- 微服务Kong(八)——代理参考
Kong侦听四个端口的请求,默认情况是: 8000:此端口是Kong用来监听来自客户端的HTTP请求的,并将此请求转发到您的上游服务.这也是本教程中最主要用到的端口. 8443:此端口是Kong监听H ...
- web项目中配置文件的加载顺序
当一个项目启动时,首先是web.xml: 这里面的配置: 为什么要在web.xml中配置struts的过滤器? 因为一个web项目运行的时需要加载的,或者默认的部分配置都会在web.xml中配置,中间 ...
- 【题解】Tree-String Problem Codeforces 291E AC自动机
Prelude 传送到Codeforces:(/ω\)--- (/ω•\) Solution 很水的一道题. 对查询的串建出来AC自动机,然后树上随便跑跑就行了. 为什么要写这篇题解呢? 我第一眼看到 ...
- [Java] 理解JVM之一:工作机制及基本结构
一.基本结构 类加载器:在 JVM 启动时或在类运行时需要将类的字节码信息加载到 JVM 内存区域中. 执行引擎:负责执行字节码信息中包含的字节码指令,相当于实际机器上的 CPU. 内存区域:也被称为 ...
- bzoj千题计划134:bzoj3124: [Sdoi2013]直径
http://www.lydsy.com/JudgeOnline/problem.php?id=3124 第一问: dfs1.dfs2 dfs2中记录dis[i]表示点i距离最长链左端点的距离 第二问 ...
- sublime text3 最常用的快捷键及插件
A:最常用的快捷键 Tab:自动补齐代码 <!--div+Tab 其它标签一样--><div></div> emmet常用的使用方法 <!--ul>li ...
- nodejs 剪切图像在上传,并保存到指定路径下(./public/img/' + req.session.token + '.jpg‘)
前jQuery端接收数据 function upAvatar(img){ console.log(img); // data:image/jpeg;base64,/9j/4AAQSkZJRgABAQA ...
- iOS设备分辨率
CHENYILONG Blog iOS设备分辨率 © chenyilong. Powered by Postach.io Blog
- 【译】第六篇 Replication:合并复制-发布
本篇文章是SQL Server Replication系列的第六篇,详细内容请参考原文. 合并复制,类似于事务复制,包括一个发布服务器,一个分发服务器和一个或多个订阅服务器.每一个发布服务器上可以定义 ...
- 42 - 数据库-orm-SQLAlchemy
目录 1 ORM 2 sqlalchemy 3 基本使用 3.1 创建连接 3.1.1 利用连接池执行sql 3.1.2 利用session来执行sql 3.2 创建基类 3.3 创建实体类 3.3. ...