diff options
-rwxr-xr-x | xdelta3/xdelta3-main.h | 186 |
1 files changed, 112 insertions, 74 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index e2fe460..6225cb3 100755 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -67,9 +67,6 @@ const char* xd3_mainerror(int err_num); | |||
67 | #define XPR fprintf | 67 | #define XPR fprintf |
68 | #define NT stderr, "xdelta3: " | 68 | #define NT stderr, "xdelta3: " |
69 | 69 | ||
70 | #define VC fprintf | ||
71 | #define UT stdout, | ||
72 | |||
73 | /* If none are set, default to posix. */ | 70 | /* If none are set, default to posix. */ |
74 | #if (XD3_POSIX + XD3_STDIO + XD3_WIN32) == 0 | 71 | #if (XD3_POSIX + XD3_STDIO + XD3_WIN32) == 0 |
75 | #undef XD3_POSIX | 72 | #undef XD3_POSIX |
@@ -189,17 +186,18 @@ struct _main_file | |||
189 | #elif XD3_POSIX | 186 | #elif XD3_POSIX |
190 | int file; | 187 | int file; |
191 | #elif XD3_WIN32 | 188 | #elif XD3_WIN32 |
192 | HANDLE file; | 189 | HANDLE file; |
193 | #endif | 190 | #endif |
194 | 191 | ||
195 | int mode; /* XO_READ and XO_WRITE */ | 192 | int mode; /* XO_READ and XO_WRITE */ |
196 | const char *filename; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */ | 193 | const char *filename; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */ |
197 | char *filename_copy; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */ | 194 | char *filename_copy; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */ |
198 | const char *realname; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */ | 195 | const char *realname; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */ |
199 | const main_extcomp *compressor; /* External compression struct. */ | 196 | const main_extcomp *compressor; /* External compression struct. */ |
200 | int flags; /* RD_FIRST, RD_NONEXTERNAL, ... */ | 197 | int flags; /* RD_FIRST, RD_NONEXTERNAL, ... */ |
201 | xoff_t nread; /* for input position */ | 198 | xoff_t nread; /* for input position */ |
202 | xoff_t nwrite; /* for output position */ | 199 | xoff_t nwrite; /* for output position */ |
200 | uint8_t *snprintf_buf; /* internal snprintf() use */ | ||
203 | }; | 201 | }; |
204 | 202 | ||
205 | /* Various strings and magic values used to detect and call external compression. See | 203 | /* Various strings and magic values used to detect and call external compression. See |
@@ -465,7 +463,7 @@ get_errno (void) | |||
465 | #endif | 463 | #endif |
466 | } | 464 | } |
467 | 465 | ||
468 | const char* | 466 | const char* |
469 | xd3_mainerror(int err_num) { | 467 | xd3_mainerror(int err_num) { |
470 | #ifndef _WIN32 | 468 | #ifndef _WIN32 |
471 | const char* x = xd3_strerror (err_num); | 469 | const char* x = xd3_strerror (err_num); |
@@ -481,7 +479,7 @@ xd3_mainerror(int err_num) { | |||
481 | } | 479 | } |
482 | memset (err_buf, 0, 256); | 480 | memset (err_buf, 0, 256); |
483 | FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | 481 | FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
484 | NULL, err_num, | 482 | NULL, err_num, |
485 | MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), | 483 | MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), |
486 | err_buf, 256, NULL); | 484 | err_buf, 256, NULL); |
487 | return err_buf; | 485 | return err_buf; |
@@ -555,8 +553,8 @@ static char* | |||
555 | main_format_millis (long millis, char *buf) | 553 | main_format_millis (long millis, char *buf) |
556 | { | 554 | { |
557 | if (millis < 1000) { sprintf (buf, "%lu ms", millis); } | 555 | if (millis < 1000) { sprintf (buf, "%lu ms", millis); } |
558 | else if (millis < 10000) { sprintf (buf, "%.1f sec", millis / 1000.0); } | 556 | else if (millis < 10000) { sprintf (buf, "%.1f sec", millis / 1000.0); } |
559 | else { sprintf (buf, "%lu sec", millis / 1000L); } | 557 | else { sprintf (buf, "%lu sec", millis / 1000L); } |
560 | return buf; | 558 | return buf; |
561 | } | 559 | } |
562 | 560 | ||
@@ -715,10 +713,16 @@ main_file_close (main_file *xfile) | |||
715 | static void | 713 | static void |
716 | main_file_cleanup (main_file *xfile) | 714 | main_file_cleanup (main_file *xfile) |
717 | { | 715 | { |
716 | /* TODO: inconsistent code style here */ | ||
718 | if (main_file_isopen (xfile)) { | 717 | if (main_file_isopen (xfile)) { |
719 | main_file_close (xfile); | 718 | main_file_close (xfile); |
720 | } | 719 | } |
721 | 720 | ||
721 | if (xfile->snprintf_buf != NULL) { | ||
722 | main_free(xfile->snprintf_buf); | ||
723 | xfile->snprintf_buf = NULL; | ||
724 | } | ||
725 | |||
722 | if (xfile->filename_copy != NULL) { | 726 | if (xfile->filename_copy != NULL) { |
723 | main_free(xfile->filename_copy); | 727 | main_free(xfile->filename_copy); |
724 | xfile->filename_copy = NULL; | 728 | xfile->filename_copy = NULL; |
@@ -751,7 +755,7 @@ main_file_open (main_file *xfile, const char* name, int mode) | |||
751 | } | 755 | } |
752 | 756 | ||
753 | #elif XD3_WIN32 | 757 | #elif XD3_WIN32 |
754 | xfile->file = CreateFile(name, | 758 | xfile->file = CreateFile(name, |
755 | (mode == XO_READ) ? GENERIC_READ : GENERIC_WRITE, | 759 | (mode == XO_READ) ? GENERIC_READ : GENERIC_WRITE, |
756 | 0, | 760 | 0, |
757 | NULL, | 761 | NULL, |
@@ -821,7 +825,7 @@ xd3_posix_io (int fd, uint8_t *buf, usize_t size, xd3_posix_func *func, usize_t | |||
821 | while (nproc < size) | 825 | while (nproc < size) |
822 | { | 826 | { |
823 | int result = (*func) (fd, buf + nproc, size - nproc); | 827 | int result = (*func) (fd, buf + nproc, size - nproc); |
824 | 828 | ||
825 | if (result < 0) | 829 | if (result < 0) |
826 | { | 830 | { |
827 | ret = get_errno (); | 831 | ret = get_errno (); |
@@ -963,14 +967,30 @@ main_file_seek (main_file *xfile, xoff_t pos) | |||
963 | ******************************************************************************************/ | 967 | ******************************************************************************************/ |
964 | 968 | ||
965 | #if VCDIFF_TOOLS | 969 | #if VCDIFF_TOOLS |
966 | /* This function prints a single VCDIFF window, mainly for debugging purposes. */ | 970 | #define SNPRINTF_BUFSIZE XD3_ALLOCSIZE |
971 | #define VC do { if (((ret = snprintf | ||
972 | #define UT xfile->snprintf_buf, SNPRINTF_BUFSIZE, | ||
973 | #define VE ) >= SNPRINTF_BUFSIZE \ | ||
974 | && (ret = main_print_overflow(ret)) != 0) \ | ||
975 | || (ret = main_file_write(xfile, xfile->snprintf_buf, \ | ||
976 | ret, "print")) != 0) \ | ||
977 | { return ret; } } while (0) | ||
978 | |||
979 | static int | ||
980 | main_print_overflow (int x) | ||
981 | { | ||
982 | XPR(NT "internal print buffer overflow: %d bytes\n", x); | ||
983 | return XD3_INTERNAL; | ||
984 | } | ||
985 | |||
986 | /* This function prints a single VCDIFF window. */ | ||
967 | static int | 987 | static int |
968 | main_print_window (xd3_stream* stream) | 988 | main_print_window (xd3_stream* stream, main_file *xfile) |
969 | { | 989 | { |
970 | int ret; | 990 | int ret; |
971 | usize_t size = 0; | 991 | usize_t size = 0; |
972 | 992 | ||
973 | VC(UT " Offset Code Type1 Size1 @Addr1 + Type2 Size2 @Addr2\n"); | 993 | VC(UT " Offset Code Type1 Size1 @Addr1 + Type2 Size2 @Addr2\n")VE; |
974 | 994 | ||
975 | while (stream->inst_sect.buf < stream->inst_sect.buf_max) | 995 | while (stream->inst_sect.buf < stream->inst_sect.buf_max) |
976 | { | 996 | { |
@@ -980,18 +1000,18 @@ main_print_window (xd3_stream* stream) | |||
980 | 1000 | ||
981 | VC(UT " %06"Q"u %03u %s %3u", stream->dec_winstart + size, code, | 1001 | VC(UT " %06"Q"u %03u %s %3u", stream->dec_winstart + size, code, |
982 | xd3_rtype_to_string (stream->dec_current1.type, option_print_cpymode), | 1002 | xd3_rtype_to_string (stream->dec_current1.type, option_print_cpymode), |
983 | (usize_t) stream->dec_current1.size); | 1003 | (usize_t) stream->dec_current1.size)VE; |
984 | 1004 | ||
985 | if (stream->dec_current1.type != XD3_NOOP) | 1005 | if (stream->dec_current1.type != XD3_NOOP) |
986 | { | 1006 | { |
987 | size += stream->dec_current1.size; | 1007 | size += stream->dec_current1.size; |
988 | if (stream->dec_current1.type >= XD3_CPY) | 1008 | if (stream->dec_current1.type >= XD3_CPY) |
989 | { | 1009 | { |
990 | VC(UT " @%-6u", (usize_t)stream->dec_current1.addr); | 1010 | VC(UT " @%-6u", (usize_t)stream->dec_current1.addr)VE; |
991 | } | 1011 | } |
992 | else | 1012 | else |
993 | { | 1013 | { |
994 | VC(UT " "); | 1014 | VC(UT " ")VE; |
995 | } | 1015 | } |
996 | } | 1016 | } |
997 | 1017 | ||
@@ -1000,15 +1020,15 @@ main_print_window (xd3_stream* stream) | |||
1000 | size += stream->dec_current2.size; | 1020 | size += stream->dec_current2.size; |
1001 | VC(UT " %s %3u", | 1021 | VC(UT " %s %3u", |
1002 | xd3_rtype_to_string (stream->dec_current2.type, option_print_cpymode), | 1022 | xd3_rtype_to_string (stream->dec_current2.type, option_print_cpymode), |
1003 | (usize_t)stream->dec_current2.size); | 1023 | (usize_t)stream->dec_current2.size)VE; |
1004 | 1024 | ||
1005 | if (stream->dec_current2.type >= XD3_CPY) | 1025 | if (stream->dec_current2.type >= XD3_CPY) |
1006 | { | 1026 | { |
1007 | VC(UT " @%-6u", (usize_t)stream->dec_current2.addr); | 1027 | VC(UT " @%-6u", (usize_t)stream->dec_current2.addr)VE; |
1008 | } | 1028 | } |
1009 | } | 1029 | } |
1010 | 1030 | ||
1011 | VC(UT "\n"); | 1031 | VC(UT "\n")VE; |
1012 | } | 1032 | } |
1013 | 1033 | ||
1014 | if (stream->dec_tgtlen != size && (stream->flags & XD3_SKIP_WINDOW) == 0) | 1034 | if (stream->dec_tgtlen != size && (stream->flags & XD3_SKIP_WINDOW) == 0) |
@@ -1032,11 +1052,19 @@ main_print_window (xd3_stream* stream) | |||
1032 | return 0; | 1052 | return 0; |
1033 | } | 1053 | } |
1034 | 1054 | ||
1035 | static void | 1055 | static int |
1036 | main_print_vcdiff_file (main_file *file, const char *type) | 1056 | main_print_vcdiff_file (main_file *xfile, main_file *file, const char *type) |
1037 | { | 1057 | { |
1038 | if (file->filename) { VC(UT "XDELTA filename (%s): %s\n", type, file->filename); } | 1058 | int ret; /* Used by VC macro */ |
1039 | if (file->compressor) { VC(UT "XDELTA ext comp (%s): %s\n", type, file->compressor->recomp_cmdname); } | 1059 | if (file->filename) |
1060 | { | ||
1061 | VC(UT "XDELTA filename (%s): %s\n", type, file->filename)VE; | ||
1062 | } | ||
1063 | if (file->compressor) | ||
1064 | { | ||
1065 | VC(UT "XDELTA ext comp (%s): %s\n", type, file->compressor->recomp_cmdname)VE; | ||
1066 | } | ||
1067 | return 0; | ||
1040 | } | 1068 | } |
1041 | 1069 | ||
1042 | /* This function prints a VCDIFF input, mainly for debugging purposes. */ | 1070 | /* This function prints a VCDIFF input, mainly for debugging purposes. */ |
@@ -1044,20 +1072,30 @@ static int | |||
1044 | main_print_func (xd3_stream* stream, main_file *xfile) | 1072 | main_print_func (xd3_stream* stream, main_file *xfile) |
1045 | { | 1073 | { |
1046 | int ret; | 1074 | int ret; |
1075 | |||
1076 | if (xfile->snprintf_buf == NULL) | ||
1077 | { | ||
1078 | if ((xfile->snprintf_buf = main_malloc(SNPRINTF_BUFSIZE)) == NULL) | ||
1079 | { | ||
1080 | return ENOMEM; | ||
1081 | } | ||
1082 | } | ||
1083 | |||
1047 | if (stream->dec_winstart == 0) | 1084 | if (stream->dec_winstart == 0) |
1048 | { | 1085 | { |
1049 | VC(UT "VCDIFF version: 0\n"); | 1086 | VC(UT "VCDIFF version: 0\n")VE; |
1050 | 1087 | ||
1051 | VC(UT "VCDIFF header size: %d\n", stream->dec_hdrsize); | 1088 | VC(UT "VCDIFF header size: %d\n", stream->dec_hdrsize)VE; |
1052 | VC(UT "VCDIFF header indicator: "); | 1089 | VC(UT "VCDIFF header indicator: ")VE; |
1053 | if ((stream->dec_hdr_ind & VCD_SECONDARY) != 0) VC(UT "VCD_SECONDARY "); | 1090 | if ((stream->dec_hdr_ind & VCD_SECONDARY) != 0) VC(UT "VCD_SECONDARY ")VE; |
1054 | if ((stream->dec_hdr_ind & VCD_CODETABLE) != 0) VC(UT "VCD_CODETABLE "); | 1091 | if ((stream->dec_hdr_ind & VCD_CODETABLE) != 0) VC(UT "VCD_CODETABLE ")VE; |
1055 | if ((stream->dec_hdr_ind & VCD_APPHEADER) != 0) VC(UT "VCD_APPHEADER "); | 1092 | if ((stream->dec_hdr_ind & VCD_APPHEADER) != 0) VC(UT "VCD_APPHEADER ")VE; |
1056 | if (stream->dec_hdr_ind == 0) VC(UT "none"); | 1093 | if (stream->dec_hdr_ind == 0) VC(UT "none")VE; |
1057 | VC(UT "\n"); | 1094 | VC(UT "\n")VE; |
1058 | 1095 | ||
1059 | IF_SEC(VC(UT "VCDIFF secondary compressor: %s\n", stream->sec_type ? stream->sec_type->name : "none")); | 1096 | IF_SEC(VC(UT "VCDIFF secondary compressor: %s\n", |
1060 | IF_NSEC(VC(UT "VCDIFF secondary compressor: unsupported\n")); | 1097 | stream->sec_type ? stream->sec_type->name : "none")VE); |
1098 | IF_NSEC(VC(UT "VCDIFF secondary compressor: unsupported\n")VE); | ||
1061 | 1099 | ||
1062 | if (stream->dec_hdr_ind & VCD_APPHEADER) | 1100 | if (stream->dec_hdr_ind & VCD_APPHEADER) |
1063 | { | 1101 | { |
@@ -1070,9 +1108,9 @@ main_print_func (xd3_stream* stream, main_file *xfile) | |||
1070 | int sq = option_quiet; | 1108 | int sq = option_quiet; |
1071 | main_file i, o, s; | 1109 | main_file i, o, s; |
1072 | XD3_ASSERT (apphead != NULL); | 1110 | XD3_ASSERT (apphead != NULL); |
1073 | VC(UT "VCDIFF application header: "); | 1111 | VC(UT "VCDIFF application header: ")VE; |
1074 | fwrite (apphead, 1, appheadsz, stdout); | 1112 | if ((ret = main_file_write (xfile, apphead, appheadsz, "print")) != 0) { return ret; } |
1075 | VC(UT "\n"); | 1113 | VC(UT "\n")VE; |
1076 | 1114 | ||
1077 | main_file_init (& i); | 1115 | main_file_init (& i); |
1078 | main_file_init (& o); | 1116 | main_file_init (& o); |
@@ -1080,8 +1118,8 @@ main_print_func (xd3_stream* stream, main_file *xfile) | |||
1080 | option_quiet = 1; | 1118 | option_quiet = 1; |
1081 | main_get_appheader (stream, &i, & o, & s); | 1119 | main_get_appheader (stream, &i, & o, & s); |
1082 | option_quiet = sq; | 1120 | option_quiet = sq; |
1083 | main_print_vcdiff_file (& o, "output"); | 1121 | if ((ret = main_print_vcdiff_file (xfile, & o, "output"))) { return ret; } |
1084 | main_print_vcdiff_file (& s, "source"); | 1122 | if ((ret = main_print_vcdiff_file (xfile, & s, "source"))) { return ret; } |
1085 | main_file_cleanup (& i); | 1123 | main_file_cleanup (& i); |
1086 | main_file_cleanup (& o); | 1124 | main_file_cleanup (& o); |
1087 | main_file_cleanup (& s); | 1125 | main_file_cleanup (& s); |
@@ -1090,51 +1128,51 @@ main_print_func (xd3_stream* stream, main_file *xfile) | |||
1090 | } | 1128 | } |
1091 | else | 1129 | else |
1092 | { | 1130 | { |
1093 | VC(UT "\n"); | 1131 | VC(UT "\n")VE; |
1094 | } | 1132 | } |
1095 | 1133 | ||
1096 | VC(UT "VCDIFF window number: %"Q"u\n", stream->current_window); | 1134 | VC(UT "VCDIFF window number: %"Q"u\n", stream->current_window)VE; |
1097 | VC(UT "VCDIFF window indicator: "); | 1135 | VC(UT "VCDIFF window indicator: ")VE; |
1098 | if ((stream->dec_win_ind & VCD_SOURCE) != 0) VC(UT "VCD_SOURCE "); | 1136 | if ((stream->dec_win_ind & VCD_SOURCE) != 0) VC(UT "VCD_SOURCE ")VE; |
1099 | if ((stream->dec_win_ind & VCD_TARGET) != 0) VC(UT "VCD_TARGET "); | 1137 | if ((stream->dec_win_ind & VCD_TARGET) != 0) VC(UT "VCD_TARGET ")VE; |
1100 | if ((stream->dec_win_ind & VCD_ADLER32) != 0) VC(UT "VCD_ADLER32 "); | 1138 | if ((stream->dec_win_ind & VCD_ADLER32) != 0) VC(UT "VCD_ADLER32 ")VE; |
1101 | if (stream->dec_win_ind == 0) VC(UT "none"); | 1139 | if (stream->dec_win_ind == 0) VC(UT "none")VE; |
1102 | VC(UT "\n"); | 1140 | VC(UT "\n")VE; |
1103 | 1141 | ||
1104 | if ((stream->dec_win_ind & VCD_ADLER32) != 0) | 1142 | if ((stream->dec_win_ind & VCD_ADLER32) != 0) |
1105 | { | 1143 | { |
1106 | VC(UT "VCDIFF adler32 checksum: %08X\n", (usize_t)stream->dec_adler32); | 1144 | VC(UT "VCDIFF adler32 checksum: %08X\n", (usize_t)stream->dec_adler32)VE; |
1107 | } | 1145 | } |
1108 | 1146 | ||
1109 | if (stream->dec_del_ind != 0) | 1147 | if (stream->dec_del_ind != 0) |
1110 | { | 1148 | { |
1111 | VC(UT "VCDIFF delta indicator: "); | 1149 | VC(UT "VCDIFF delta indicator: ")VE; |
1112 | if ((stream->dec_del_ind & VCD_DATACOMP) != 0) VC(UT "VCD_DATACOMP "); | 1150 | if ((stream->dec_del_ind & VCD_DATACOMP) != 0) VC(UT "VCD_DATACOMP ")VE; |
1113 | if ((stream->dec_del_ind & VCD_INSTCOMP) != 0) VC(UT "VCD_INSTCOMP "); | 1151 | if ((stream->dec_del_ind & VCD_INSTCOMP) != 0) VC(UT "VCD_INSTCOMP ")VE; |
1114 | if ((stream->dec_del_ind & VCD_ADDRCOMP) != 0) VC(UT "VCD_ADDRCOMP "); | 1152 | if ((stream->dec_del_ind & VCD_ADDRCOMP) != 0) VC(UT "VCD_ADDRCOMP ")VE; |
1115 | if (stream->dec_del_ind == 0) VC(UT "none"); | 1153 | if (stream->dec_del_ind == 0) VC(UT "none")VE; |
1116 | VC(UT "\n"); | 1154 | VC(UT "\n")VE; |
1117 | } | 1155 | } |
1118 | 1156 | ||
1119 | if (stream->dec_winstart != 0) | 1157 | if (stream->dec_winstart != 0) |
1120 | { | 1158 | { |
1121 | VC(UT "VCDIFF window at offset: %"Q"u\n", stream->dec_winstart); | 1159 | VC(UT "VCDIFF window at offset: %"Q"u\n", stream->dec_winstart)VE; |
1122 | } | 1160 | } |
1123 | 1161 | ||
1124 | if (SRCORTGT (stream->dec_win_ind)) | 1162 | if (SRCORTGT (stream->dec_win_ind)) |
1125 | { | 1163 | { |
1126 | VC(UT "VCDIFF copy window length: %u\n", (usize_t)stream->dec_cpylen); | 1164 | VC(UT "VCDIFF copy window length: %u\n", (usize_t)stream->dec_cpylen)VE; |
1127 | VC(UT "VCDIFF copy window offset: %"Q"u\n", stream->dec_cpyoff); | 1165 | VC(UT "VCDIFF copy window offset: %"Q"u\n", stream->dec_cpyoff)VE; |
1128 | } | 1166 | } |
1129 | 1167 | ||
1130 | VC(UT "VCDIFF delta encoding length: %u\n", (usize_t)stream->dec_enclen); | 1168 | VC(UT "VCDIFF delta encoding length: %u\n", (usize_t)stream->dec_enclen)VE; |
1131 | VC(UT "VCDIFF target window length: %u\n", (usize_t)stream->dec_tgtlen); | 1169 | VC(UT "VCDIFF target window length: %u\n", (usize_t)stream->dec_tgtlen)VE; |
1132 | 1170 | ||
1133 | VC(UT "VCDIFF data section length: %u\n", (usize_t)stream->data_sect.size); | 1171 | VC(UT "VCDIFF data section length: %u\n", (usize_t)stream->data_sect.size)VE; |
1134 | VC(UT "VCDIFF inst section length: %u\n", (usize_t)stream->inst_sect.size); | 1172 | VC(UT "VCDIFF inst section length: %u\n", (usize_t)stream->inst_sect.size)VE; |
1135 | VC(UT "VCDIFF addr section length: %u\n", (usize_t)stream->addr_sect.size); | 1173 | VC(UT "VCDIFF addr section length: %u\n", (usize_t)stream->addr_sect.size)VE; |
1136 | 1174 | ||
1137 | ret = 0; | 1175 | ret = 0; |
1138 | if ((stream->flags & XD3_JUST_HDR) != 0) | 1176 | if ((stream->flags & XD3_JUST_HDR) != 0) |
1139 | { | 1177 | { |
1140 | /* Print a header -- finished! */ | 1178 | /* Print a header -- finished! */ |
@@ -1142,7 +1180,7 @@ main_print_func (xd3_stream* stream, main_file *xfile) | |||
1142 | } | 1180 | } |
1143 | else if ((stream->flags & XD3_SKIP_WINDOW) == 0) | 1181 | else if ((stream->flags & XD3_SKIP_WINDOW) == 0) |
1144 | { | 1182 | { |
1145 | ret = main_print_window (stream); | 1183 | ret = main_print_window (stream, xfile); |
1146 | } | 1184 | } |
1147 | 1185 | ||
1148 | return ret; | 1186 | return ret; |
@@ -2516,7 +2554,7 @@ main_input (xd3_cmd cmd, | |||
2516 | { | 2554 | { |
2517 | if (xd3_decoder_needs_source (& stream) && sfile->filename == NULL) | 2555 | if (xd3_decoder_needs_source (& stream) && sfile->filename == NULL) |
2518 | { | 2556 | { |
2519 | allow_fake_source = 1; | 2557 | allow_fake_source = 1; |
2520 | sfile->filename = "<placeholder>"; | 2558 | sfile->filename = "<placeholder>"; |
2521 | main_set_source (& stream, cmd, sfile, & source); | 2559 | main_set_source (& stream, cmd, sfile, & source); |
2522 | } | 2560 | } |
@@ -2538,7 +2576,7 @@ main_input (xd3_cmd cmd, | |||
2538 | * output for both encoder and decoder, this way we delay long enough for | 2576 | * output for both encoder and decoder, this way we delay long enough for |
2539 | * the decoder to receive the application header. (Or longer if there are | 2577 | * the decoder to receive the application header. (Or longer if there are |
2540 | * skipped windows, but I can't think of any reason not to delay open.) */ | 2578 | * skipped windows, but I can't think of any reason not to delay open.) */ |
2541 | 2579 | ||
2542 | if (! main_file_isopen (ofile) && (ret = main_open_output (& stream, ofile)) != 0) | 2580 | if (! main_file_isopen (ofile) && (ret = main_open_output (& stream, ofile)) != 0) |
2543 | { | 2581 | { |
2544 | return EXIT_FAILURE; | 2582 | return EXIT_FAILURE; |
@@ -2702,7 +2740,7 @@ static void | |||
2702 | main_cleanup (void) | 2740 | main_cleanup (void) |
2703 | { | 2741 | { |
2704 | int i; | 2742 | int i; |
2705 | 2743 | ||
2706 | if (appheader_used != NULL && | 2744 | if (appheader_used != NULL && |
2707 | appheader_used != option_appheader) | 2745 | appheader_used != option_appheader) |
2708 | { | 2746 | { |
@@ -2911,7 +2949,7 @@ main (int argc, char **argv) | |||
2911 | #else | 2949 | #else |
2912 | XPR(NT "encoder support not compiled\n"); | 2950 | XPR(NT "encoder support not compiled\n"); |
2913 | return EXIT_FAILURE; | 2951 | return EXIT_FAILURE; |
2914 | #endif | 2952 | #endif |
2915 | case 'P': | 2953 | case 'P': |
2916 | /* only set profile count once, since... */ | 2954 | /* only set profile count once, since... */ |
2917 | if (option_profile_cnt == 0) | 2955 | if (option_profile_cnt == 0) |
@@ -3031,7 +3069,7 @@ main (int argc, char **argv) | |||
3031 | strcat (buf, " "); | 3069 | strcat (buf, " "); |
3032 | } | 3070 | } |
3033 | XPR(NT "command line: %s\n", buf); | 3071 | XPR(NT "command line: %s\n", buf); |
3034 | } | 3072 | } |
3035 | 3073 | ||
3036 | ifile.flags = RD_FIRST; | 3074 | ifile.flags = RD_FIRST; |
3037 | sfile.flags = RD_FIRST; | 3075 | sfile.flags = RD_FIRST; |
@@ -3045,7 +3083,7 @@ main (int argc, char **argv) | |||
3045 | 3083 | ||
3046 | if ((ret = main_file_open (& ifile, ifile.filename, XO_READ))) | 3084 | if ((ret = main_file_open (& ifile, ifile.filename, XO_READ))) |
3047 | { | 3085 | { |
3048 | goto cleanup; | 3086 | goto cleanup; |
3049 | } | 3087 | } |
3050 | } | 3088 | } |
3051 | else | 3089 | else |
@@ -3124,7 +3162,7 @@ main (int argc, char **argv) | |||
3124 | static int | 3162 | static int |
3125 | main_help (void) | 3163 | main_help (void) |
3126 | { | 3164 | { |
3127 | /* TODO: update www/xdelta3-cmdline.html */ | 3165 | /* TODO: update www/xdelta3-cmdline.html */ |
3128 | main_version (); | 3166 | main_version (); |
3129 | P(RINT "usage: xdelta3 [command/options] [input [output]]\n"); | 3167 | P(RINT "usage: xdelta3 [command/options] [input [output]]\n"); |
3130 | P(RINT "special command names:\n"); | 3168 | P(RINT "special command names:\n"); |