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;
}
随机推荐
- logger.debug的用处
原文:https://www.cnblogs.com/xiangkejin/p/6426761.html logger.debug的用处 简单的说,就是配合log的等级过滤输出 根据你log4j的配置 ...
- 使用 laravel 的 queue 必须知道的一些事
1. 在修改 queue 相关代码后,必须要使用 php artisan queue:restart 来重启队列服务,否则所做的修改可能不会生效(没法重现了,按理说应该和使用 queue:listen ...
- lightoj 1205 数位dp
1205 - Palindromic Numbers PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 3 ...
- K8S调度之pod亲和性
目录 Pod Affinity Pod亲和性调度 pod互斥性调度 Pod Affinity 通过<K8S调度之节点亲和性>,我们知道怎么在调度的时候让pod灵活的选择node,但有些时候 ...
- unity还原three——顶点,三角面,uv
public class Geometry { public Geometry(string name, Data data, Hashtable hash) { Debug.Log("解析 ...
- P2158 [SDOI2008]仪仗队 && 欧拉函数
P2158 [SDOI2008]仪仗队 题目描述 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线 ...
- python中super与成员属性
super的使用直接看例子: class A(): def __init__(self, a): print('init A...') self.a = a class B(A): def __ini ...
- select()函数
select(),确定一个或多个套接口的状态,本函数用于确定一个或多个套接口的状态,对每一个套接口,调用者可查询它的可读性.可写性及错误状态信息,用fd_set结构来表示一组等待检查的套接口,在调用返 ...
- bzoj千题计划149:bzoj2527: [Poi2011]Meteors
http://www.lydsy.com/JudgeOnline/problem.php?id=2527 整体二分 区间加,单点查,树状数组维护差分序列 注意 累积可能会爆long long,所以一满 ...
- [JQuery代码]超酷鼠标滑过背景高亮效果
1.效果及功能说明 鼠标滑过悬停特效,div css制作产品列表图片布局通过鼠标滑过产品图片背景高亮闪烁显示,产品标题滑动显示或隐藏 2.实现原理 首先定义好一个重复实现效果的方法,然后定义光带出现速 ...