isodump.c
上传用户:xiejiait
上传日期:2007-01-06
资源大小:881k
文件大小:14k
- /*
- * File isodump.c - dump iso9660 directory information.
- *
- Written by Eric Youngdale (1993).
- Copyright 1993 Yggdrasil Computing, Incorporated
- 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, 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. */
- static char rcsid[] ="$Id: isodump.c,v 1.3 1999/03/02 03:41:36 eric Exp $";
- #include "../config.h"
- #include <stdxlib.h>
- #include <unixstd.h>
- #include <strdefs.h>
- #include <stdio.h>
- #include <standard.h>
- #ifdef HAVE_TERMIOS_H
- #include <termios.h>
- #include <sys/ioctl.h>
- #else
- #include <termio.h>
- #endif
- #include <signal.h>
- FILE * infile;
- int file_addr;
- unsigned char buffer[2048];
- unsigned char search[64];
- int blocksize;
- #define PAGE sizeof(buffer)
- #define ISODCL(from, to) (to - from + 1)
- struct iso_primary_descriptor {
- unsigned char type [ISODCL ( 1, 1)]; /* 711 */
- unsigned char id [ISODCL ( 2, 6)];
- unsigned char version [ISODCL ( 7, 7)]; /* 711 */
- unsigned char unused1 [ISODCL ( 8, 8)];
- unsigned char system_id [ISODCL ( 9, 40)]; /* aunsigned chars */
- unsigned char volume_id [ISODCL ( 41, 72)]; /* dunsigned chars */
- unsigned char unused2 [ISODCL ( 73, 80)];
- unsigned char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
- unsigned char unused3 [ISODCL ( 89, 120)];
- unsigned char volume_set_size [ISODCL (121, 124)]; /* 723 */
- unsigned char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
- unsigned char logical_block_size [ISODCL (129, 132)]; /* 723 */
- unsigned char path_table_size [ISODCL (133, 140)]; /* 733 */
- unsigned char type_l_path_table [ISODCL (141, 144)]; /* 731 */
- unsigned char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
- unsigned char type_m_path_table [ISODCL (149, 152)]; /* 732 */
- unsigned char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
- unsigned char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
- unsigned char volume_set_id [ISODCL (191, 318)]; /* dunsigned chars */
- unsigned char publisher_id [ISODCL (319, 446)]; /* achars */
- unsigned char preparer_id [ISODCL (447, 574)]; /* achars */
- unsigned char application_id [ISODCL (575, 702)]; /* achars */
- unsigned char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
- unsigned char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
- unsigned char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
- unsigned char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
- unsigned char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
- unsigned char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
- unsigned char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
- unsigned char file_structure_version [ISODCL (882, 882)]; /* 711 */
- unsigned char unused4 [ISODCL (883, 883)];
- unsigned char application_data [ISODCL (884, 1395)];
- unsigned char unused5 [ISODCL (1396, 2048)];
- };
- struct iso_directory_record {
- unsigned char length [ISODCL (1, 1)]; /* 711 */
- unsigned char ext_attr_length [ISODCL (2, 2)]; /* 711 */
- unsigned char extent [ISODCL (3, 10)]; /* 733 */
- unsigned char size [ISODCL (11, 18)]; /* 733 */
- unsigned char date [ISODCL (19, 25)]; /* 7 by 711 */
- unsigned char flags [ISODCL (26, 26)];
- unsigned char file_unit_size [ISODCL (27, 27)]; /* 711 */
- unsigned char interleave [ISODCL (28, 28)]; /* 711 */
- unsigned char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
- unsigned char name_len [ISODCL (33, 33)]; /* 711 */
- unsigned char name [1];
- };
- int isonum_731 __PR((char * p));
- int isonum_721 __PR((char * p));
- int isonum_723 __PR((char * p));
- int isonum_733 __PR((unsigned char * p));
- void reset_tty __PR((void));
- void set_tty __PR((void));
- void onsusp __PR((int signo));
- void crsr2 __PR((int row, int col));
- int parse_rr __PR((unsigned char * pnt, int len, int cont_flag));
- void dump_rr __PR((struct iso_directory_record * idr));
- void showblock __PR((int flag));
- int getbyte __PR((void));
- void usage __PR((int excode));
- int main __PR((int argc, char *argv[]));
- int
- isonum_731 (p)
- char *p;
- {
- return ((p[0] & 0xff)
- | ((p[1] & 0xff) << 8)
- | ((p[2] & 0xff) << 16)
- | ((p[3] & 0xff) << 24));
- }
- int
- isonum_721 (p)
- char *p;
- {
- return ((p[0] & 0xff) | ((p[1] & 0xff) << 8));
- }
- int
- isonum_723 (p)
- char *p;
- {
- #if 0
- if (p[0] != p[3] || p[1] != p[2]) {
- #ifdef USE_LIBSCHILY
- comerrno(EX_BAD, "invalid format 7.2.3 numbern");
- #else
- fprintf (stderr, "invalid format 7.2.3 numbern");
- exit (1);
- #endif
- }
- #endif
- return (isonum_721 (p));
- }
- int
- isonum_733 (p)
- unsigned char *p;
- {
- return (isonum_731 ((char *)p));
- }
- #ifdef HAVE_TERMIOS_H
- struct termios savetty;
- struct termios newtty;
- #else
- struct termio savetty;
- struct termio newtty;
- #endif
- void
- reset_tty()
- {
- #ifdef HAVE_TERMIOS_H
- if(tcsetattr(0, TCSANOW, &savetty) == -1)
- #else
- if(ioctl(0, TCSETAF, &savetty)==-1)
- #endif
- {
- #ifdef USE_LIBSCHILY
- comerr("Cannot put tty into normal moden");
- #else
- printf("Cannot put tty into normal moden");
- exit(1);
- #endif
- }
- }
- void
- set_tty()
- {
- #ifdef HAVE_TERMIOS_H
- if(tcsetattr(0, TCSANOW, &newtty) == -1)
- #else
- if(ioctl(0, TCSETAF, &newtty)==-1)
- #endif
- {
- #ifdef USE_LIBSCHILY
- comerr("Cannot put tty into raw moden");
- #else
- printf("Cannot put tty into raw moden");
- exit(1);
- #endif
- }
- }
- /* Come here when we get a suspend signal from the terminal */
- void
- onsusp (signo)
- int signo;
- {
- #ifdef SIGTTOU
- /* ignore SIGTTOU so we don't get stopped if csh grabs the tty */
- signal(SIGTTOU, SIG_IGN);
- #endif
- reset_tty ();
- fflush (stdout);
- #ifdef SIGTTOU
- signal(SIGTTOU, SIG_DFL);
- /* Send the TSTP signal to suspend our process group */
- signal(SIGTSTP, SIG_DFL);
- /* sigsetmask(0);*/
- kill (0, SIGTSTP);
- /* Pause for station break */
- /* We're back */
- signal (SIGTSTP, onsusp);
- #endif
- set_tty ();
- }
- void
- crsr2(row, col)
- int row;
- int col;
- {
- printf("