| Newsgroups: rec.arts.int-fiction | |
| From: svm@kozmix.xs4all.nl (Sander van Malssen) | |
| Subject: Re: ZIP under Linux? | |
| These are my patches to Zip. (They also include some small general | |
| improvements to the unix interface). I sent them to the author a while | |
| ago, & they'll probably be part of the official package whenever a new | |
| release comes out. | |
| Cheers, | |
| Sander | |
| diff -ur orig/fileio.c new/fileio.c | |
| --- orig/fileio.c Thu Jun 2 17:08:02 1994 | |
| +++ new/fileio.c Mon Jul 11 00:11:32 1994 | |
| const char *storyname; | |
| #endif | |
| { | |
| + char *path, *p; | |
| + char tmp[PATHNAME_MAX + 1]; | |
| + | |
| + if ((gfp = fopen (storyname, "rb"))) | |
| + return; | |
| - gfp = fopen (storyname, "rb"); | |
| - if (gfp == NULL) | |
| - fatal ("Game file not found"); | |
| + if ((path = getenv("INFOCOM_PATH")) == NULL) | |
| + fatal ("Can't open game file"); | |
| + | |
| + p = strtok(path, ":"); | |
| + while (p) | |
| + { | |
| + sprintf (tmp, "%s/%s", p, storyname); | |
| + if ((gfp = fopen (tmp, "rb"))) | |
| + return; | |
| + p = strtok(NULL, ":"); | |
| + } | |
| + | |
| + fatal ("Can't open game file"); | |
| }/* open_story */ | |
| diff -ur orig/interpre.c new/interpre.c | |
| --- orig/interpre.c Thu Jun 2 17:08:06 1994 | |
| +++ new/interpre.c Mon Jul 11 00:11:32 1994 | |
| case 0x24: read_line (count, operand); break; | |
| case 0x25: print_character (operand[0]); break; | |
| case 0x26: print_number (operand[0]); break; | |
| - case 0x27: random (operand[0]); break; | |
| + case 0x27: zip_random (operand[0]); break; | |
| case 0x28: push_var (operand[0]); break; | |
| case 0x29: pop_var (operand[0]); break; | |
| case 0x2a: set_status_size (operand[0]); break; | |
| diff -ur orig/math.c new/math.c | |
| --- orig/math.c Thu Jun 2 17:08:07 1994 | |
| +++ new/math.c Mon Jul 11 00:11:32 1994 | |
| }/* and */ | |
| /* | |
| - * random | |
| + * zip_random | |
| * | |
| * Return random number between 1 and operand | |
| * | |
| */ | |
| #ifdef __STDC__ | |
| -void random (zword_t a) | |
| +void zip_random (zword_t a) | |
| #else | |
| -void random (a) | |
| +void zip_random (a) | |
| zword_t a; | |
| #endif | |
| { | |
| } else /* (a > 0) */ | |
| store_operand (((zword_t) rand () % a) + 1); | |
| -}/* random */ | |
| +}/* zip_random */ | |
| /* | |
| * test | |
| diff -ur orig/osdepend.c new/osdepend.c | |
| --- orig/osdepend.c Thu Jun 2 17:08:16 1994 | |
| +++ new/osdepend.c Mon Jul 11 01:13:24 1994 | |
| #include "ztypes.h" | |
| +char *storybasename; | |
| + | |
| /* File names will be O/S dependent */ | |
| #if defined(AMIGA) | |
| exit (EXIT_FAILURE); | |
| } | |
| - /* Open the story file */ | |
| + /* Strip leading directories */ | |
| + if ((storybasename = strrchr(argv[optind], '/'))) | |
| + storybasename++; | |
| + else | |
| + storybasename = argv[optind]; | |
| + /* Open the story file */ | |
| open_story (argv[optind]); | |
| }/* process_arguments */ | |
| else if (flag == GAME_RECORD || flag == GAME_PLAYBACK) | |
| strcpy (default_name, RECORD_NAME); | |
| else /* (flag == GAME_SAVE || flag == GAME_RESTORE) */ | |
| +#if 0 | |
| strcpy (default_name, SAVE_NAME); | |
| +#else | |
| + strcpy (default_name, storybasename); | |
| + strcat (default_name, ".sav"); | |
| +#endif | |
| } | |
| /* Prompt for the file name */ | |
| { | |
| reset_screen (); | |
| - printf ("\nFatal error: %s (PC = %lx)\n", s, pc); | |
| + printf ("\nFatal error: %s", s); | |
| + if (pc) | |
| + printf (" (PC = %lx)", pc); | |
| + putchar ('\n'); | |
| exit (1); | |
| }/* fatal */ | |
| diff -ur orig/unixio.c new/unixio.c | |
| --- orig/unixio.c Thu Jun 2 17:08:25 1994 | |
| +++ new/unixio.c Mon Jul 11 00:54:03 1994 | |
| #include "ztypes.h" | |
| -#if !defined(BSD) || !defined(SYSTEM_FIVE) || !defined(POSIX) | |
| -#define BSD | |
| -#endif /* !defined(BSD) || !defined(SYSTEM_FIVE) || !defined(POSIX) */ | |
| +#if !defined(BSD) && !defined(SYSTEM_FIVE) && !defined(POSIX) | |
| +#error "define one of BSD, SYSTEM_FIVE or POSIX" | |
| +#endif /* !defined(BSD) && !defined(SYSTEM_FIVE) && !defined(POSIX) */ | |
| #if defined(BSD) | |
| #include <sgtty.h> | |
| #endif /* defined(BSD) */ | |
| #if defined(SYSTEM_FIVE) | |
| #include <termio.h> | |
| -#endif /* defined(SYSTEM_FIVE) | |
| +#endif /* defined(SYSTEM_FIVE) */ | |
| #if defined(POSIX) | |
| #include <termios.h> | |
| #endif /* defined(POSIX) */ | |
| static int read_key (); | |
| static void set_cbreak_mode (); | |
| static void rundown (); | |
| +static void tstp_zip (); | |
| +static void cont_zip (); | |
| extern int tgetent (); | |
| extern int tgetnum (); | |
| US = SO; | |
| } | |
| - tputs (TI, 1, outc); | |
| + if (TI && *TI) | |
| + tputs (TI, 1, outc); | |
| clear_screen (); | |
| row = screen_rows / 2; | |
| col = (screen_cols - (sizeof ("The story is loading...") - 1)) / 2; | |
| move_cursor (row, col); | |
| - display_string ("The story is loading..."); | |
| + display_string ("The story is loading..."); fflush (stdout); | |
| h_interpreter = INTERP_MSDOS; | |
| set_cbreak_mode (0); | |
| - tputs (TE, 1, outc); | |
| + if (TE && *TE) | |
| + tputs (TE, 1, outc); | |
| }/* reset_screen */ | |
| { | |
| int row, col; | |
| - if (*CS) { | |
| + if (CS && *CS) { | |
| get_cursor_position (&row, &col); | |
| tputs (tgoto (CS, screen_rows - 1, status_size), 1, outc); | |
| { | |
| int row, col; | |
| - if (*CS) { | |
| + if (CS && *CS) { | |
| get_cursor_position (&row, &col); | |
| tputs (tgoto (CS, screen_rows - 1, 0), 1, outc); | |
| get_cursor_position (&row, &col); | |
| - if (*CS || row < screen_rows) { | |
| + if ((CS && *CS) || row < screen_rows) { | |
| display_char ('\n'); | |
| } else { | |
| move_cursor (status_size + 1, 1); | |
| /* Scroll line if return key pressed */ | |
| - if (c == '\n') { | |
| + if (c == '\r') { | |
| scroll_line (); | |
| return (c); | |
| } else { | |
| if (c == 127) | |
| c = '\b'; | |
| - else if (c == '\r') | |
| - c = '\n'; | |
| + else if (c == '\n') | |
| + c = '\r'; | |
| return (c); | |
| if (mode) { | |
| signal (SIGINT, rundown); | |
| signal (SIGTERM, rundown); | |
| + signal (SIGTSTP, tstp_zip); | |
| } | |
| if (mode) { | |
| if (mode == 0) { | |
| signal (SIGINT, SIG_DFL); | |
| signal (SIGTERM, SIG_DFL); | |
| + signal (SIGTSTP, SIG_DFL); | |
| } | |
| }/* set_cbreak_mode */ | |
| reset_screen (); | |
| }/* rundown */ | |
| + | |
| +static void tstp_zip () | |
| +{ | |
| + reset_screen (); | |
| + signal (SIGTSTP, SIG_DFL); | |
| + signal (SIGCONT, cont_zip); | |
| + raise (SIGTSTP); | |
| + | |
| +}/* tstp_zip */ | |
| + | |
| +static void cont_zip () | |
| +{ | |
| + signal (SIGINT, rundown); | |
| + signal (SIGTERM, rundown); | |
| + signal (SIGTSTP, tstp_zip); | |
| + clear_screen (); | |
| + restart_screen (); | |
| + set_cbreak_mode (); | |
| + | |
| +}/* cont_zip */ | |
| diff -ur orig/ztypes.h new/ztypes.h | |
| --- orig/ztypes.h Thu Jun 2 17:08:28 1994 | |
| +++ new/ztypes.h Mon Jul 11 00:11:33 1994 | |
| #define FILENAME_MAX 255 | |
| #endif | |
| +#ifndef PATHNAME_MAX | |
| +#define PATHNAME_MAX 1024 | |
| +#endif | |
| + | |
| #ifndef EXIT_SUCCESS | |
| #define EXIT_SUCCESS 0 | |
| #endif | |
| void multiply (zword_t, zword_t); | |
| void not (zword_t); | |
| void or (zword_t, zword_t); | |
| -void random (zword_t); | |
| +void zip_random (zword_t); | |
| void remainder (zword_t, zword_t); | |
| void shift (zword_t, zword_t); | |
| void subtract (zword_t, zword_t); | |
| void multiply (); | |
| void not (); | |
| void or (); | |
| -void random (); | |
| +void zip_random (); | |
| void remainder (); | |
| void shift (); | |
| void subtract (); | |
| --- unixio.c.~1~ Mon Jul 11 17:12:36 1994 | |
| +++ unixio.c Thu Jul 14 04:10:03 1994 | |
| int mode; | |
| { | |
| int status; | |
| + static int initialized = 0; | |
| #if defined(BSD) | |
| struct sgttyb new_tty; | |
| static struct sgttyb old_tty; | |
| struct termios new_termios; | |
| static struct termios old_termios; | |
| #endif /* defined(POSIX) */ | |
| + | |
| + /* Don't try to restore terminal settings if they weren't saved first */ | |
| + if (mode == 0 && initialized == 0) | |
| + return; | |
| + initialized = mode; | |
| #if defined(BSD) | |
| status = ioctl (fileno (stdin), (mode) ? TIOCGETP : TIOCSETP, &old_tty); | |
| -- | |
| Sander van Malssen | |
| svm@kozmix.xs4all.nl | |
Xet Storage Details
- Size:
- 8.35 kB
- Xet hash:
- 3f9686e8311b795d0a10d96d0d990dedd3fe93549c285e60286b3f2d5a6a88aa
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.