⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ntcat.c

📁 NTFS 磁盘系统 加载源代码
💻 C
字号:
/* *  ntcat.c * *  Copyright (C) 1995 Martin von L鰓is */#include "config.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#ifdef HAVE_GETOPT_LONG#include <getopt.h>#else#define getopt_long(a,v,o,ol,x)        getopt(a,v,o)#endif#include <unistd.h>#include <string.h>#include "ntfs.h"#include "version.h"char *short_opts="f:o:l:B:1V";#ifdef HAVE_GETOPT_LONGstruct option options[]={	{"filesystem",1,0,'f'},	{"offset",1,0,'o'},	{"size",1,0,'s'},	{"bias",1,0,'b'},	{"8859-1",0,0,'1'},	{"version",0,0,'V'},	{0,0,0,0}};#endifvoid usage(void){	fprintf(stderr,"ntcat [-f device] [-o offset] [-l size] [-1] [directory/]filename\n");}/* print the file ino on stdout */void ntfs_cat_file(ntfs_inode *ino,int offset,int length){	int position,len;	char *buf;	int bufsize;	ntfs_io io;	position=offset;	if(length)		bufsize=length;	else		bufsize=8192;	buf=(char*)malloc(bufsize);	/* Very large file */	if(!buf)	{		bufsize=8192;		buf=(char*)malloc(bufsize);		if(!buf)		{			perror("ntcat");			exit(0);		}	}	io.fn_put=ntfs_put;	io.fn_get=0;	io.do_read=1;	io.param=buf;	/* read from the unnamed data attribute */	while((len=ntfs_read_attr(ino,AT_DATA,NULL,				  position,&io,bufsize))>0)	{		write(1,buf,len);		position+=len;		length-=len;		if(length==0)			break;		io.param=buf;	}	free(buf);}int main(int argc,char *argv[]){	int c;	char *device=0;	int offset=0;	int length=0;	char *name;	ntfs_inode ino;	int inum;	int bias=0;	extern int opterr,optind;	extern char* optarg;	enum ntfs_charset_type charset=nct_utf8;	opterr=1;	while((c=getopt_long(argc,argv,short_opts,options,NULL))>0)		switch(c)		{		case 'f': device=optarg;break;		case 'o': offset=strtol(optarg,NULL,0);break;		case 'l': length=strtol(optarg,NULL,0);break;		case 'B': bias=strtol(optarg,NULL,0);break;		case '1': charset=nct_iso8859_1;break;		case 'V': printf("ntcat " NTFS_VERSION "\n");exit(0);break;		}	name=argv[optind];	if(!ntfs_open_volume(device,bias,1,0))return 1;	the_vol->nct=charset;	inum=5;	/* walk the directory tree */	do{		char *next;		ntfs_init_inode(&ino,the_vol,inum);		if(!name || !*name)break;		next=strchr(name,'/');		if(next){			*next='\0';			next++;		}		inum=ntfs_find_file(&ino,name);		if(inum==-1){			fprintf(stderr,"%s not found\n",name);			return 1;		}		name=next;	}while(1);	ntfs_init_inode(&ino,the_vol,inum);	ntfs_cat_file(&ino,offset,length);	return 0;}/* * Local variables: * c-file-style: "linux" * End: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -