summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-main.h
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r--xdelta3/xdelta3-main.h51
1 files changed, 25 insertions, 26 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 6882e03..0babbf1 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -2761,6 +2761,8 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
2761 main_blklru_list_init (& lru_list); 2761 main_blklru_list_init (& lru_list);
2762 main_blklru_list_init (& lru_free); 2762 main_blklru_list_init (& lru_free);
2763 2763
2764 IF_DEBUG1 (DP(RINT "[main_set_source] %s\n", sfile->filename));
2765
2764 /* Open it, check for seekability, set required xd3_source fields. */ 2766 /* Open it, check for seekability, set required xd3_source fields. */
2765 if (allow_fake_source) 2767 if (allow_fake_source)
2766 { 2768 {
@@ -2795,9 +2797,9 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
2795 seekable = 0; 2797 seekable = 0;
2796 source_size_known = 0; 2798 source_size_known = 0;
2797 2799
2798 if (option_verbose) 2800 if (option_verbose > 1)
2799 { 2801 {
2800 XPR(NT "source not seekable\n"); 2802 XPR(NT "source not seekable: %s\n", xd3_mainerror (stat_val));
2801 } 2803 }
2802 } 2804 }
2803 } 2805 }
@@ -2827,6 +2829,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
2827 XPR(NT XD3_LIB_ERRMSG (stream, ret)); 2829 XPR(NT XD3_LIB_ERRMSG (stream, ret));
2828 goto error; 2830 goto error;
2829 } 2831 }
2832 XD3_ASSERT (stream->src == source);
2830 2833
2831 lru_size = (option_srcwinsz + source->blksize - 1) / source->blksize; 2834 lru_size = (option_srcwinsz + source->blksize - 1) / source->blksize;
2832 option_srcwinsz = lru_size * source->blksize; 2835 option_srcwinsz = lru_size * source->blksize;
@@ -2835,7 +2838,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
2835 { 2838 {
2836 static char buf[32]; 2839 static char buf[32];
2837 2840
2838 XPR(NT "source %s winsize %s\n", 2841 XPR(NT "source %s: winsize %s\n",
2839 sfile->filename, main_format_bcnt(option_srcwinsz, buf)); 2842 sfile->filename, main_format_bcnt(option_srcwinsz, buf));
2840 } 2843 }
2841 2844
@@ -2864,7 +2867,10 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
2864 main_blklru_list_push_back (& lru_free, & lru[i]); 2867 main_blklru_list_push_back (& lru_free, & lru[i]);
2865 } 2868 }
2866 2869
2870 return 0;
2871
2867 error: 2872 error:
2873 IF_DEBUG1 (DP(RINT "[main_set_source] error %s\n", xd3_strerror (ret)));
2868 if (tmp_buf != NULL) 2874 if (tmp_buf != NULL)
2869 { 2875 {
2870 main_free (tmp_buf); 2876 main_free (tmp_buf);
@@ -3224,17 +3230,6 @@ main_input (xd3_cmd cmd,
3224 return EXIT_FAILURE; 3230 return EXIT_FAILURE;
3225 } 3231 }
3226 3232
3227 if (IS_ENCODE (cmd))
3228 {
3229 /* When encoding, open the source file, possibly decompress it.
3230 * The decoder delays this step until XD3_GOTHEADER. */
3231 if (sfile->filename != NULL &&
3232 (ret = main_set_source (& stream, cmd, sfile, & source)))
3233 {
3234 return EXIT_FAILURE;
3235 }
3236 }
3237
3238 config.winsize = winsize; 3233 config.winsize = winsize;
3239 config.srcwin_maxsz = option_srcwinsz; 3234 config.srcwin_maxsz = option_srcwinsz;
3240 config.getblk = main_getblk_func; 3235 config.getblk = main_getblk_func;
@@ -3256,6 +3251,21 @@ main_input (xd3_cmd cmd,
3256 } 3251 }
3257#endif 3252#endif
3258 3253
3254 if (cmd != CMD_DECODE)
3255 {
3256 /* When not decoding, set source now. The decoder delays this
3257 * step until XD3_GOTHEADER. */
3258 if (sfile->filename != NULL)
3259 {
3260 if ((ret = main_set_source (& stream, cmd, sfile, & source)))
3261 {
3262 return EXIT_FAILURE;
3263 }
3264
3265 XD3_ASSERT(stream.src != NULL);
3266 }
3267 }
3268
3259 /* This times each window. */ 3269 /* This times each window. */
3260 get_millisecs_since (); 3270 get_millisecs_since ();
3261 3271
@@ -3329,18 +3339,6 @@ main_input (xd3_cmd cmd,
3329 return EXIT_FAILURE; 3339 return EXIT_FAILURE;
3330 } 3340 }
3331 } 3341 }
3332 else if (cmd == CMD_PRINTHDR ||
3333 cmd == CMD_PRINTHDRS ||
3334 cmd == CMD_PRINTDELTA ||
3335 cmd == CMD_RECODE)
3336 {
3337 if (sfile->filename == NULL)
3338 {
3339 allow_fake_source = 1;
3340 sfile->filename = "<placeholder>";
3341 main_set_source (& stream, cmd, sfile, & source);
3342 }
3343 }
3344 } 3342 }
3345 /* FALLTHROUGH */ 3343 /* FALLTHROUGH */
3346 case XD3_WINSTART: 3344 case XD3_WINSTART:
@@ -3397,6 +3395,7 @@ main_input (xd3_cmd cmd,
3397 "no source copies\n", 3395 "no source copies\n",
3398 stream.current_window * winsize, 3396 stream.current_window * winsize,
3399 (stream.current_window+1) * winsize); 3397 (stream.current_window+1) * winsize);
3398 XD3_ASSERT (stream.src != NULL);
3400 } 3399 }
3401 3400
3402 /* Limited i-buffer size affects source copies */ 3401 /* Limited i-buffer size affects source copies */