dump.c
上传用户:xiejiait
上传日期:2007-01-06
资源大小:881k
文件大小:6k
- /*
- * File dump.c - dump a file/device both in hex and in ASCII.
- 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: dump.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[256];
- unsigned char search[64];
- #define PAGE 256
- #ifdef HAVE_TERMIOS_H
- struct termios savetty;
- struct termios newtty;
- #else
- struct termio savetty;
- struct termio newtty;
- #endif
- void reset_tty __PR((void));
- void set_tty __PR((void));
- void onsusp __PR((int sig));
- void crsr2 __PR((int row, int col));
- void showblock __PR((int flag));
- int getbyte __PR((void));
- void usage __PR((int excode));
- int main __PR((int argc, char *argv[]));
- 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(sig)
- int sig;
- {
- #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("