diff options
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r-- | xdelta3/xdelta3-main.h | 95 |
1 files changed, 86 insertions, 9 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index d0f90fe..ec0f858 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -262,7 +262,7 @@ struct _main_blklru | |||
262 | /* ... represented as a list (no cache index). */ | 262 | /* ... represented as a list (no cache index). */ |
263 | XD3_MAKELIST(main_blklru_list,main_blklru,link); | 263 | XD3_MAKELIST(main_blklru_list,main_blklru,link); |
264 | 264 | ||
265 | // Merge state: | 265 | /* Merge state: */ |
266 | 266 | ||
267 | struct _main_merge_list | 267 | struct _main_merge_list |
268 | { | 268 | { |
@@ -273,6 +273,7 @@ struct _main_merge_list | |||
273 | struct _main_merge | 273 | struct _main_merge |
274 | { | 274 | { |
275 | const char *filename; | 275 | const char *filename; |
276 | xoff_t source_size; | ||
276 | main_merge_list link; | 277 | main_merge_list link; |
277 | }; | 278 | }; |
278 | 279 | ||
@@ -384,6 +385,7 @@ main_config (void) | |||
384 | DP(RINT "REGRESSION_TEST=%d\n", REGRESSION_TEST); | 385 | DP(RINT "REGRESSION_TEST=%d\n", REGRESSION_TEST); |
385 | DP(RINT "SECONDARY_DJW=%d\n", SECONDARY_DJW); | 386 | DP(RINT "SECONDARY_DJW=%d\n", SECONDARY_DJW); |
386 | DP(RINT "SECONDARY_FGK=%d\n", SECONDARY_FGK); | 387 | DP(RINT "SECONDARY_FGK=%d\n", SECONDARY_FGK); |
388 | DP(RINT "UNALIGNED_OK=%d\n", UNALIGNED_OK); | ||
387 | DP(RINT "VCDIFF_TOOLS=%d\n", VCDIFF_TOOLS); | 389 | DP(RINT "VCDIFF_TOOLS=%d\n", VCDIFF_TOOLS); |
388 | DP(RINT "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE); | 390 | DP(RINT "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE); |
389 | DP(RINT "XD3_DEBUG=%d\n", XD3_DEBUG); | 391 | DP(RINT "XD3_DEBUG=%d\n", XD3_DEBUG); |
@@ -1581,6 +1583,77 @@ main_recode_func (xd3_stream* stream, main_file *ofile) | |||
1581 | #endif /* VCDIFF_TOOLS */ | 1583 | #endif /* VCDIFF_TOOLS */ |
1582 | 1584 | ||
1583 | /******************************************************************* | 1585 | /******************************************************************* |
1586 | VCDIFF merging | ||
1587 | ******************************************************************/ | ||
1588 | |||
1589 | #if XD3_ENCODER | ||
1590 | /* The first stream in merge order sets the source of the merged | ||
1591 | * output. This is where we initialize the static merge_state | ||
1592 | * variable w/ the initial source information. */ | ||
1593 | static int | ||
1594 | main_init_merge_state (xd3_stream *stream, main_merge *merge) | ||
1595 | { | ||
1596 | if (! xd3_decoder_needs_source (stream)) | ||
1597 | { | ||
1598 | DP(RINT "cannot merge inputs which do not have a source file\n"); | ||
1599 | return XD3_INVALID; | ||
1600 | } | ||
1601 | |||
1602 | merge->source_size = stream->src->size; | ||
1603 | |||
1604 | return 0; | ||
1605 | } | ||
1606 | |||
1607 | /* This processes the sequence of -m arguments. The final input | ||
1608 | * is processed as part of the ordinary main_input() loop. */ | ||
1609 | static int | ||
1610 | main_merge_arguments (main_merge_list* merges) | ||
1611 | { | ||
1612 | int ret; | ||
1613 | main_merge *merge = NULL; | ||
1614 | |||
1615 | if (main_merge_list_empty (merges)) | ||
1616 | { | ||
1617 | return 0; | ||
1618 | } | ||
1619 | |||
1620 | merge = main_merge_list_front (merges); | ||
1621 | |||
1622 | while (!main_merge_list_end (merges, merge)) | ||
1623 | { | ||
1624 | DP(RINT "TODO MERGE FILE: %s\n", merge->filename); | ||
1625 | |||
1626 | if ((ret = main_init_merge_state (stream, NULL))) | ||
1627 | { | ||
1628 | return ret; | ||
1629 | } | ||
1630 | |||
1631 | merge = main_merge_list_next (merge); | ||
1632 | } | ||
1633 | |||
1634 | return 0; | ||
1635 | } | ||
1636 | |||
1637 | /* This processes each window of the final merge input. This routine | ||
1638 | * does not output, it buffers the entire delta into memory. */ | ||
1639 | static int | ||
1640 | main_merge_func (xd3_stream* stream, main_file *no_write) | ||
1641 | { | ||
1642 | int ret; | ||
1643 | |||
1644 | if ((ret = main_init_merge_state (stream, NULL))) | ||
1645 | { | ||
1646 | return ret; | ||
1647 | } | ||
1648 | |||
1649 | // TODO HERE YOU ARE | ||
1650 | //if ((ret = xd3_n | ||
1651 | |||
1652 | return 0; | ||
1653 | } | ||
1654 | #endif | ||
1655 | |||
1656 | /******************************************************************* | ||
1584 | Input decompression, output recompression | 1657 | Input decompression, output recompression |
1585 | ******************************************************************/ | 1658 | ******************************************************************/ |
1586 | 1659 | ||
@@ -2788,7 +2861,8 @@ main_input (xd3_cmd cmd, | |||
2788 | break; | 2861 | break; |
2789 | 2862 | ||
2790 | case CMD_RECODE: | 2863 | case CMD_RECODE: |
2791 | // No source will be read | 2864 | case CMD_MERGE: |
2865 | /* No source will be read */ | ||
2792 | stream_flags |= XD3_ADLER32_NOVER | XD3_SKIP_EMIT; | 2866 | stream_flags |= XD3_ADLER32_NOVER | XD3_SKIP_EMIT; |
2793 | 2867 | ||
2794 | XD3_ASSERT (recode_stream == NULL); | 2868 | XD3_ASSERT (recode_stream == NULL); |
@@ -2812,14 +2886,11 @@ main_input (xd3_cmd cmd, | |||
2812 | 2886 | ||
2813 | ifile->flags |= RD_NONEXTERNAL; | 2887 | ifile->flags |= RD_NONEXTERNAL; |
2814 | input_func = xd3_decode_input; | 2888 | input_func = xd3_decode_input; |
2815 | output_func = main_recode_func; | 2889 | if (cmd == CMD_RECODE) { output_func = main_recode_func; } |
2890 | else { output_func = main_merge_func; } | ||
2816 | break; | 2891 | break; |
2892 | #endif /* VCDIFF_TOOLS */ | ||
2817 | 2893 | ||
2818 | case CMD_MERGE: | ||
2819 | XPR(NT "merge not implemented\n"); | ||
2820 | return EXIT_FAILURE; | ||
2821 | //break; | ||
2822 | #endif | ||
2823 | #if XD3_ENCODER | 2894 | #if XD3_ENCODER |
2824 | case CMD_ENCODE: | 2895 | case CMD_ENCODE: |
2825 | do_not_lru = 1; | 2896 | do_not_lru = 1; |
@@ -3618,7 +3689,6 @@ main (int argc, char **argv) | |||
3618 | } | 3689 | } |
3619 | main_merge_list_push_back (& merge_order, merge); | 3690 | main_merge_list_push_back (& merge_order, merge); |
3620 | merge->filename = my_optarg; | 3691 | merge->filename = my_optarg; |
3621 | // TODO: more cleanup | ||
3622 | break; | 3692 | break; |
3623 | 3693 | ||
3624 | case 'V': | 3694 | case 'V': |
@@ -3678,6 +3748,12 @@ main (int argc, char **argv) | |||
3678 | if (! option_stdout) { ofile.filename = argv[1]; } | 3748 | if (! option_stdout) { ofile.filename = argv[1]; } |
3679 | } | 3749 | } |
3680 | 3750 | ||
3751 | if (cmd == CMD_MERGE && | ||
3752 | (ret = main_merge_arguments (&merge_order))) | ||
3753 | { | ||
3754 | goto cleanup; | ||
3755 | } | ||
3756 | |||
3681 | switch (cmd) | 3757 | switch (cmd) |
3682 | { | 3758 | { |
3683 | case CMD_PRINTHDR: | 3759 | case CMD_PRINTHDR: |
@@ -3729,6 +3805,7 @@ main (int argc, char **argv) | |||
3729 | 3805 | ||
3730 | while (! main_merge_list_empty (& merge_order)) | 3806 | while (! main_merge_list_empty (& merge_order)) |
3731 | { | 3807 | { |
3808 | /* TODO: More merge cleanup, once implemented. */ | ||
3732 | merge = main_merge_list_pop_front (& merge_order); | 3809 | merge = main_merge_list_pop_front (& merge_order); |
3733 | main_free (merge); | 3810 | main_free (merge); |
3734 | } | 3811 | } |