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

📄 isodump.c

📁 将用户指定的符合iso-9660标准的文件的信息dump出来。
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  isodump.c  --  extract iso9660 image from device or file  Copyright (C) 1999-2002 Steffen Solyga <solyga@absinth.net>  This program is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or  (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*//* $Id: isodump.c,v 1.20 2008-01-30 22:27:09 solyga Exp $ */#include	"isodump.h"intdisplay_help( char* fn ) {  fprintf( HELP_CHANNEL, "%s v%s (%s): ", fn, VERSION_NUMBER, DATE_OF_LAST_MOD );  fprintf( HELP_CHANNEL, "Extract iso9660 image from device or file.\n" );  fprintf( HELP_CHANNEL, "Flowers & bug reports to %s.\n", MY_EMAIL_ADDRESS );  fprintf( HELP_CHANNEL, "Usage: %s [options] [infile [outfile]]\n", fn );  fprintf( HELP_CHANNEL, "switches:\n" );  fprintf( HELP_CHANNEL, "  -a\t extract all data available (until EOF)\n" );  fprintf( HELP_CHANNEL, "  -h\t write this info to %s and exit sucessfully\n", HELP_CHANNEL==stdout ? "stdout" : "stderr" );  fprintf( HELP_CHANNEL, "  -n\t NRG image (skip first 150 blocks)\n" );  fprintf( HELP_CHANNEL, "  -p\t don't pad image (if it's too small)\n" );  fprintf( HELP_CHANNEL, "  -v\t increase verbosity level on %s\n", VERBOSE_CHANNEL==stdout ? "stdout" : "stderr" );  fprintf( HELP_CHANNEL, "  -x\t XA image (set block offset to %d)\n", CD_XA_SYNC_HEAD );  fprintf( HELP_CHANNEL, "  -H\t print %d hash marks on %s\n", HASH_MARKS, VERBOSE_CHANNEL==stdout ? "stdout" : "stderr" );  fprintf( HELP_CHANNEL, "  -V\t write version and compilation info to %s and exit sucessfully\n", VERSION_CHANNEL==stdout ? "stdout" : "stderr" );  return( 0 );}intdisplay_version( char* pn ) {  fprintf( VERSION_CHANNEL, "%s v%s (%s)\n", pn, VERSION_NUMBER, DATE_OF_LAST_MOD );  fprintf( VERSION_CHANNEL, "compilation settings:\n" );  fprintf( VERSION_CHANNEL, "  DEFAULT_INPUT_FILE : %s\n", DEFAULT_INPUT_FILE );  fprintf( VERSION_CHANNEL, "  HASH_MARKS         : %d\n", HASH_MARKS );  return( 0 );}ssize_tmy_read( int fd, void* buf, size_t nbtr ) {/* returns number of bytes read or -1 on error *//* like read(2) but nbr<nbtr only if eof reached */  ssize_t nbr;  ssize_t tnbr= 0;  size_t rem= nbtr;  unsigned char *p= (unsigned char*)buf;  do {    if( (nbr=read(fd,p+tnbr,rem)) == -1 ) return( -1 );    tnbr+= nbr;    rem= nbtr - tnbr;  }  while( nbr>1 && rem>0 );  return( tnbr );}longiso_num_733( char* p ) {  return(   (p[0] & 0xffL)          | (p[1] & 0xffL) <<  8          | (p[2] & 0xffL) << 16          | (p[3] & 0xffL) << 24 );}intfra2min( int f ) {/* convert frames to minutes of msf */  f= f < 0 ? -f : f;  return( f/CD_FRAMES/CD_SECS );}intfra2sec( int f ) {/* convert frames to seconds of msf */  f= f < 0 ? -f : f;  return( (f - fra2min(f)*CD_SECS*CD_FRAMES)/CD_FRAMES );}intfra2fra( int f ) {/* convert frames to frames of msf */  f= f < 0 ? -f : f;  return( f - (fra2min(f)*CD_SECS+fra2sec(f))*CD_FRAMES );}unsigned char*setup_head( int blk, int uhb ) {/* set up head data (4 bytes) */  static unsigned char head[CD_HEAD_SIZE];  static int min, sec, fra;  min= fra2min( blk+CD_MSF_OFFSET );  sec= fra2sec( blk+CD_MSF_OFFSET );  fra= fra2fra( blk+CD_MSF_OFFSET );  head[0]= (unsigned char) 16*(min/10)+min%10;  head[1]= (unsigned char) 16*(sec/10)+sec%10;  head[2]= (unsigned char) 16*(fra/10)+fra%10;  head[3]= (unsigned char) uhb;  return( head );}char*basename( char* name ) {/* strip directory from name *//* basename("/usr/bin/") == "" -- basename(1) would return "bin" !! */  char* p= name;  while( *p != '\0' ) p++;  while( p > name ) {    if( *(p-1) == '/' ) break;    else p--;  }  return( p );}intmain( int argc, char** argv ) {/*SOLYGA --------------------SOLYGA main(argc, argv) isodumpSOLYGA extract iso9660 image from device or fileSOLYGA started Mon Jun 15 12:23:54 MET DST 1998 @beast*/  char* fpn= *argv;			/* full program name */  char* pn= basename( fpn );		/* base program name */  int retval= RETVAL_OK;		/* return value */  int c;				/* option char */  char stdin_fn[]= "stdin";  char stdout_fn[]= "stdout";  char default_in_fn[]= DEFAULT_INPUT_FILE;  int in_fd= -1;			/* input fd */  char* in_fn= default_in_fn;		/* input file name */  int out_fd= STDOUT_FILENO;		/* output fd */  char* out_fn= stdout_fn;		/* output file name */  int verbose= 0;			/* verbosity level */  int hash= 0;				/* hash marks ? */  int all= 0;				/* write all data available */  int xa= 0;				/* XA disk, block offset= 24 */  int nrg= 0;				/* nrg image, skip first 150 blocks */  int pad= 1;				/* pad image? */  ssize_t nbr;				/* number of bytes read */  long long tnbr= 0;			/* total number of bytes read */  ssize_t nbw;				/* number of bytes written */  long long tnbw= 0;			/* total number of bytes written */  int blk;				/* current block */  int blocks;				/* number of blocks to dump */  time_t sec0, sec1;			/* speed measurement */  unsigned char buf[CD_FRAMESIZE_RAW];	/* read buffer */  unsigned char* bp;			/* start of iso-block */  int buf_size;  int hash_marks_printed= 0;  unsigned char sync[CD_SYNC_SIZE]= {0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00};  unsigned char head[CD_HEAD_SIZE]= {0x00,0x02,0x00,0x01};  char id[]= ISO_STANDARD_ID;		/* "CD001" */  int uhb= -1;				/* unidentified head byte */  int extra_zero;			/* flag: extra data is zero */  int padded;				/* flag & number of pad blocks */  int i;/* process options */  *argv= pn;  while( (c=getopt(argc,argv,"ahHnpvVx")) != EOF )    switch( c ) {      case 'a': /* write all data available */        all= 1;        break;      case 'h': /* display help to HELP_CHANNEL and exit sucessfully */        display_help( pn );        retval= RETVAL_OK; goto DIE_NOW;      case 'H': /* print hash marks */        hash= 1;        break;      case 'n': /* nrg image, skip first 150 blocks */        nrg= 1;        break;      case 'p':	/* don't pad image */        pad= 0;        break;      case 'v': /* increase verbosity level */        verbose++;        break;      case 'V': /* display version to VERSION_CHANNEL and exit sucessfully */        display_version( pn );        retval= RETVAL_OK; goto DIE_NOW;      case 'x':	/* XA disk ==> offset=CD_XA_SYNC_HEAD */        xa= 1;        break;      case '?': /* refer to help and exit unsuccessfully */        fprintf( ERROR_CHANNEL, "%s: Try `%s -h' for more information.\n",                 pn, pn );        retval= RETVAL_ERROR; goto DIE_NOW;      default : /* program error */        fprintf( ERROR_CHANNEL, "%s: Options bug! E-mail me at %s.\n",                 pn, MY_EMAIL_ADDRESS );        retval= RETVAL_BUG; goto DIE_NOW;    }/* open input and output */  if( argc > optind ) {    if( *argv[optind] == '-' ) {      in_fn= stdin_fn;      in_fd= STDIN_FILENO;    }    else {      in_fn= argv[optind];      in_fd= -1;    }  }  if( in_fd != STDIN_FILENO ) {    if( (in_fd=open(in_fn,O_RDONLY)) == -1 ) {      fprintf( ERROR_CHANNEL, "%s: Cannot open `%s' read-only. %s.\n",               pn, in_fn, strerror(errno) );      retval= RETVAL_ERROR; goto DIE_NOW;    }  }  if( argc > optind+1 ) {    if( *argv[optind+1] == '-' ) {      out_fn= stdout_fn;      out_fd= STDOUT_FILENO;    }    else {      out_fn= argv[optind+1];      out_fd= -1;    }  }   if( out_fd != STDOUT_FILENO ) {    if( (out_fd=open(out_fn,O_WRONLY|O_CREAT|O_TRUNC,OUT_PERMS)) == -1 ) {      fprintf( ERROR_CHANNEL, "%s: Cannot open `%s' write-only. %s.\n",               pn, out_fn, strerror(errno) );      retval= RETVAL_ERROR; goto DIE_NOW;    }

⌨️ 快捷键说明

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