一个UNIX工具的源代码
发表于:2007-06-08来源:作者:点击数:
标签:
//程序名称:debg //程序功能:使用16进制和ASCII码显示文件内容 //程序格式:debgfile[f] // 开发 日期:2000年09月10日 //开发作者:耿祯荣 //运行状况: UNIX 5.0.55.0.7调试运行通过 #include"stdio.h" #include"stdlib.h" main(intac,char*av[]) { longx,y,x1
// 程序名称: debg
// 程序功能: 使用16进制和ASCII码显示文件内容
// 程序格式: debg file [f]
//
开发日期: 2000年09月10日
// 开发作者: 耿祯荣
// 运行状况:
UNIX5.0.5 5.0.7 调试运行通过
#include "stdio.h"
#include "stdlib.h"
main(int ac,char *av[])
{
long x,y,x1,y1;
long byte_num,wz;
unsigned int ch;
FILE *p;
int i;
char buf[50];
int sq,sq1;
if(ac<2){
printf("格式不正确!!\n");
printf("程序功能: 使用16进制和ASCII码显示文件内容");
printf("格式:debg filename [f]\n\a");
printf("\n欢迎您使用本软件 作者:耿祯荣\n");
exit(0);
}
p=fopen(av[1],"r");
if(p==0){
printf("\nFile Not found!!\n");
exit(0);
}
x=1;
y=x1=0;
y1=58;
x=1;
byte_num=0;
wz=0;
printf("[2J");
i=0;
sq1=0;
do{
ch=getc(p);
if(feof(p))
break;
if(i==0)
printf( "[%dH%05x",x,byte_num);
if(i==7)
printf( "[%dH[%dC%02x-[%dH[%dC%c",
x,y*3+6,ch,x,y1,(isprint(ch)?ch:'.'));
else
printf( "[%dH[%dC%02x [%dH[%dC%c",
x,y*3+6,ch,x,y1,(isprint(ch)?ch:'.'));
i++;
byte_num++;
y1++;
y++;
if(i==16){
sq=byte_num%512;
if(sq==0){
printf("[%dH===================== ",++x);
printf("扇区: %04d 字节: %10ld ",sq1++,byte_num);
printf("======================");
}
x++;
y=0;
y1=58;
i=0;
}
if(x==25){
x=1;
if(av[2][0]!='f')
if(getchar()=='q')
break;
printf("[2J");
}
}while(1);
fclose(p);
printf("\n欢迎您使用本软件 作者:耿祯荣\n");
}
编译方法
cc -o debg debg.c
本人网站有已经编译好的目标文件
http://hsgzr.www48.cnidc.cn
| 绣林 回复于:2004-05-16 15:08:12
|
好帖,支持原创。
|
| sdccf 回复于:2004-05-16 23:11:26
|
好,请继续帖其它小工具的代码。
|
| hsgzr 回复于:2004-05-17 21:25:46
|
看来本论坛对此不感兴趣
|
| htldm 回复于:2004-05-18 09:20:21
|
大家都很支持你呀
|
| starter 回复于:2004-05-18 18:06:32
|
不错
|
| hsgzr 回复于:2004-05-18 18:54:28
|
看来这个贴子该发到C论坛区 除了三位外 其它人没有感兴趣的
|
| cain 回复于:2004-05-18 22:57:44
|
俺很有兴趣,已经下载了,继续!!
|
| zyun_work 回复于:2004-05-19 00:02:57
|
支持,好东西,有关于可以查找进程,杀死终端的小程序吗?谢谢!
|
| jysww 回复于:2004-05-19 09:23:24
|
好贴,继续!
|
| corand 回复于:2004-05-19 14:14:39
|
在linux运行有问题问题,待会儿看看是哪里的问题
|
| li2002 回复于:2004-05-19 15:09:40
|
系统不是有hd和od命令吗
|
| hsgzr 回复于:2004-05-19 16:49:48
|
是的 UNIX系统是有hd和od 这个工具是我在分析一个数据文件的存储情况时临时做的 贴上来是为了给初学C语言的人参考
|
| loveu_cn 回复于:2004-05-20 16:35:59
|
写一个可以修改源文件的工具啊,这个可以用hd的。
|
原文转自:http://www.ltesting.net