michaele@vice.ICO.TEK.COM (Michael Enkelis) (04/14/89)
patches should remove that littly proublem. I am willing to accept any other patches, and try them out and repost any context diff's needed to update the unzipbsd program. Now all i need to do is to try to find time to make a zip archiver for unix. *** unzipbsd.c Wed Apr 12 21:01:01 1989 --- ../unzipbsd.c Thu Apr 13 10:41:03 1989 *************** *** 56,65 **** typedef longint signature_type; ! ! #define local_file_header_signature 0x04034b50L ! ! typedef struct local_file_header { word version_needed_to_extract; word general_purpose_bit_flag; --- 56,62 ---- typedef longint signature_type; ! char local_file_header_signature[] = {0x50,0x4b,0x03,0x04}; typedef struct local_file_header { word version_needed_to_extract; word general_purpose_bit_flag; *************** *** 73,80 **** word extra_field_length; } local_file_header; - #define central_file_header_signature 0x02014b50L typedef struct central_directory_file_header { word version_made_by; word version_needed_to_extract; --- 70,77 ---- word extra_field_length; } local_file_header; + char central_file_header_signature[] = {0x50,0x4b,0x01,0x02}; typedef struct central_directory_file_header { word version_made_by; word version_needed_to_extract; *************** *** 94,101 **** longint relative_offset_local_header; } central_directory_file_header; - #define end_central_dir_signature 0x06054b50L typedef struct end_central_dir_record { word number_this_disk; word number_disk_with_start_central_directory; --- 91,98 ---- longint relative_offset_local_header; } central_directory_file_header; + char end_central_dir_signature[] = {0x50,0x4b,0x05,0x06}; typedef struct end_central_dir_record { word number_this_disk; word number_disk_with_start_central_directory; *************** *** 267,273 **** get_string(len, s) int len; ! char *s[]; { read(zipfd,s,len); s[len] = 0; --- 264,270 ---- get_string(len, s) int len; ! char *s; { read(zipfd,s,len); s[len] = 0; *************** *** 811,817 **** while ((!zipeof)) { ReadByte(&b); ! OutByte(b); } } break; --- 808,815 ---- while ((!zipeof)) { ReadByte(&b); ! if (!zipeof) /* bob@dhw68k.cts.com */ ! OutByte(b); } } break; *************** *** 862,868 **** /* UNIX support routines: Michael Enkelis */ get_byte() { ! unsigned int nibble; read(zipfd,&nibble,1); return (nibble & 0xff); } --- 860,866 ---- /* UNIX support routines: Michael Enkelis */ get_byte() { ! byte nibble; read(zipfd,&nibble,1); return (nibble & 0xff); } *************** *** 906,911 **** --- 904,910 ---- get_string(lrec.extra_field_length,extra); if (debugging) { + printf("Process LOCAL file header.\n"); printf("Version used : %d\n",lrec.version_needed_to_extract); printf("Bit flags : %d\n",lrec.general_purpose_bit_flag); printf("Compression : %d\n",lrec.compression_method); *************** *** 956,961 **** --- 955,964 ---- get_string(rec.extra_field_length,extra); get_string(rec.file_comment_length,comment); + if (debugging) { + printf("Process CENTRAL file header.\n"); + } + crccode = INITCRC; } *************** *** 976,981 **** --- 979,988 ---- rec.zipfile_comment_length = get_word(); get_string(rec.zipfile_comment_length,comment); + + if (debugging) { + printf("Process END_CENTRAL directory header.\n"); + } } *************** *** 983,1019 **** process_headers() { ! longint sig; while (1) { ! if (read(zipfd,&sig,sizeof(sig)) != sizeof(sig)) ! return; ! else ! if (sig == local_file_header_signature) ! process_local_file_header(); ! else ! if (sig == central_file_header_signature) ! process_central_file_header(); else ! ! if (sig == end_central_dir_signature) ! { ! process_end_central_dir(); ! return; } ! ! else ! { ! printf("Invalid Zipfile Header\n"); ! return; ! } ! } ! ! } ! /* ---------------------------------------------------------- */ --- 990,1029 ---- process_headers() { ! int i; ! char sig[4]; while (1) { ! for (i=0; i<4; i++) ! sig[i] = get_byte(); ! if (debugging) { ! printf("\n"); ! for (i=0; i<4; i++) { ! printf("%x=%x ",sig[i],local_file_header_signature[i]); ! } ! printf("\n"); ! } ! if (strncmp(sig,local_file_header_signature,4) == 0) ! process_local_file_header(); ! else ! if (strncmp(sig,central_file_header_signature,4) == 0) ! process_central_file_header(); ! else ! if (strncmp(sig,end_central_dir_signature,4) == 0) ! { ! process_end_central_dir(); ! return; ! } else ! { ! printf("Invalid Zipfile Header\n"); ! return; ! } } ! } /* ---------------------------------------------------------- */ -- _ _ _ __ ' ) ) ) / /) / ` / /) Michael Enkelis / / / o _. /_ __. _ // /-- __ /_ _ // o _ tektronix!vice!michaele / ' (_(_(__/ /_(_(_(<_(/_ (___, /) )_/ <_(<_(/_(_/_)_ (503) 627-4099