diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2007-12-27 19:46:36 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2007-12-27 19:46:36 +0000 |
commit | 2e0d675bf995f9f6e893bd41cb4b14304c6c88ab (patch) | |
tree | daa0cef3fc8e9c3e6d476a17f197e8a90c67cc30 /xdelta3/xdelta3.h | |
parent | b7e82b2ed8eaf661aaa4548e703083474b016f04 (diff) |
Adding more support for "merge" command.
Diffstat (limited to 'xdelta3/xdelta3.h')
-rw-r--r-- | xdelta3/xdelta3.h | 122 |
1 files changed, 84 insertions, 38 deletions
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index 8adc7ff..24032fd 100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h | |||
@@ -234,6 +234,7 @@ typedef struct _xd3_smatcher xd3_smatcher; | |||
234 | typedef struct _xd3_rinst xd3_rinst; | 234 | typedef struct _xd3_rinst xd3_rinst; |
235 | typedef struct _xd3_dinst xd3_dinst; | 235 | typedef struct _xd3_dinst xd3_dinst; |
236 | typedef struct _xd3_hinst xd3_hinst; | 236 | typedef struct _xd3_hinst xd3_hinst; |
237 | typedef struct _xd3_winst xd3_winst; | ||
237 | typedef struct _xd3_rpage xd3_rpage; | 238 | typedef struct _xd3_rpage xd3_rpage; |
238 | typedef struct _xd3_addr_cache xd3_addr_cache; | 239 | typedef struct _xd3_addr_cache xd3_addr_cache; |
239 | typedef struct _xd3_output xd3_output; | 240 | typedef struct _xd3_output xd3_output; |
@@ -549,8 +550,17 @@ struct _xd3_dinst | |||
549 | struct _xd3_hinst | 550 | struct _xd3_hinst |
550 | { | 551 | { |
551 | uint8_t type; | 552 | uint8_t type; |
552 | uint32_t size; | 553 | usize_t size; |
553 | uint32_t addr; | 554 | usize_t addr; |
555 | }; | ||
556 | |||
557 | /* the form of a whole-file instruction */ | ||
558 | struct _xd3_winst | ||
559 | { | ||
560 | uint8_t type; /* RUN, ADD, COPY */ | ||
561 | uint8_t mode; /* 0, VCD_SOURCE, VCD_TARGET */ | ||
562 | usize_t size; | ||
563 | xoff_t addr; | ||
554 | }; | 564 | }; |
555 | 565 | ||
556 | /* used by the encoder to buffer output in sections. list of blocks. */ | 566 | /* used by the encoder to buffer output in sections. list of blocks. */ |
@@ -567,7 +577,7 @@ struct _xd3_desect | |||
567 | { | 577 | { |
568 | const uint8_t *buf; | 578 | const uint8_t *buf; |
569 | const uint8_t *buf_max; | 579 | const uint8_t *buf_max; |
570 | uint32_t size; | 580 | usize_t size; |
571 | usize_t pos; | 581 | usize_t pos; |
572 | 582 | ||
573 | /* used in xdelta3-decode.h */ | 583 | /* used in xdelta3-decode.h */ |
@@ -847,11 +857,11 @@ struct _xd3_stream | |||
847 | 857 | ||
848 | usize_t dec_secondid; /* Optional secondary compressor ID. */ | 858 | usize_t dec_secondid; /* Optional secondary compressor ID. */ |
849 | 859 | ||
850 | uint32_t dec_codetblsz; /* Optional code table: length. */ | 860 | usize_t dec_codetblsz; /* Optional code table: length. */ |
851 | uint8_t *dec_codetbl; /* Optional code table: storage. */ | 861 | uint8_t *dec_codetbl; /* Optional code table: storage. */ |
852 | usize_t dec_codetblbytes; /* Optional code table: position. */ | 862 | usize_t dec_codetblbytes; /* Optional code table: position. */ |
853 | 863 | ||
854 | uint32_t dec_appheadsz; /* Optional application header: | 864 | usize_t dec_appheadsz; /* Optional application header: |
855 | size. */ | 865 | size. */ |
856 | uint8_t *dec_appheader; /* Optional application header: | 866 | uint8_t *dec_appheader; /* Optional application header: |
857 | storage */ | 867 | storage */ |
@@ -860,14 +870,14 @@ struct _xd3_stream | |||
860 | 870 | ||
861 | usize_t dec_cksumbytes; /* Optional checksum: position. */ | 871 | usize_t dec_cksumbytes; /* Optional checksum: position. */ |
862 | uint8_t dec_cksum[4]; /* Optional checksum: storage. */ | 872 | uint8_t dec_cksum[4]; /* Optional checksum: storage. */ |
863 | uint32_t dec_adler32; /* Optional checksum: value. */ | 873 | usize_t dec_adler32; /* Optional checksum: value. */ |
864 | 874 | ||
865 | uint32_t dec_cpylen; /* length of copy window | 875 | usize_t dec_cpylen; /* length of copy window |
866 | (VCD_SOURCE or VCD_TARGET) */ | 876 | (VCD_SOURCE or VCD_TARGET) */ |
867 | xoff_t dec_cpyoff; /* offset of copy window | 877 | xoff_t dec_cpyoff; /* offset of copy window |
868 | (VCD_SOURCE or VCD_TARGET) */ | 878 | (VCD_SOURCE or VCD_TARGET) */ |
869 | uint32_t dec_enclen; /* length of delta encoding */ | 879 | usize_t dec_enclen; /* length of delta encoding */ |
870 | uint32_t dec_tgtlen; /* length of target window */ | 880 | usize_t dec_tgtlen; /* length of target window */ |
871 | 881 | ||
872 | #if USE_UINT64 | 882 | #if USE_UINT64 |
873 | uint64_t dec_64part; /* part of a decoded uint64_t */ | 883 | uint64_t dec_64part; /* part of a decoded uint64_t */ |
@@ -876,26 +886,42 @@ struct _xd3_stream | |||
876 | uint32_t dec_32part; /* part of a decoded uint32_t */ | 886 | uint32_t dec_32part; /* part of a decoded uint32_t */ |
877 | #endif | 887 | #endif |
878 | 888 | ||
879 | xoff_t dec_winstart; /* offset of the start of current target window */ | 889 | xoff_t dec_winstart; /* offset of the start of |
880 | xoff_t dec_window_count; /* == current_window + 1 in DEC_FINISH */ | 890 | current target window */ |
881 | usize_t dec_winbytes; /* bytes of the three sections so far consumed */ | 891 | xoff_t dec_window_count; /* == current_window + 1 in |
892 | DEC_FINISH */ | ||
893 | usize_t dec_winbytes; /* bytes of the three sections | ||
894 | so far consumed */ | ||
882 | usize_t dec_hdrsize; /* VCDIFF + app header size */ | 895 | usize_t dec_hdrsize; /* VCDIFF + app header size */ |
883 | 896 | ||
884 | const uint8_t *dec_tgtaddrbase; /* Base of decoded target addresses (addr >= dec_cpylen). */ | 897 | const uint8_t *dec_tgtaddrbase; /* Base of decoded target |
885 | const uint8_t *dec_cpyaddrbase; /* Base of decoded copy addresses (addr < dec_cpylen). */ | 898 | addresses (addr >= |
886 | 899 | dec_cpylen). */ | |
887 | usize_t dec_position; /* current decoder position counting the cpylen offset */ | 900 | const uint8_t *dec_cpyaddrbase; /* Base of decoded copy |
888 | usize_t dec_maxpos; /* maximum decoder position counting the cpylen offset */ | 901 | addresses (addr < |
902 | dec_cpylen). */ | ||
903 | |||
904 | usize_t dec_position; /* current decoder position | ||
905 | counting the cpylen | ||
906 | offset */ | ||
907 | usize_t dec_maxpos; /* maximum decoder position | ||
908 | counting the cpylen | ||
909 | offset */ | ||
889 | xd3_hinst dec_current1; /* current instruction */ | 910 | xd3_hinst dec_current1; /* current instruction */ |
890 | xd3_hinst dec_current2; /* current instruction */ | 911 | xd3_hinst dec_current2; /* current instruction */ |
891 | 912 | ||
892 | uint8_t *dec_buffer; /* Decode buffer */ | 913 | uint8_t *dec_buffer; /* Decode buffer */ |
893 | uint8_t *dec_lastwin; /* In case of VCD_TARGET, the last target window. */ | 914 | uint8_t *dec_lastwin; /* In case of VCD_TARGET, the |
894 | usize_t dec_lastlen; /* length of the last target window */ | 915 | last target window. */ |
895 | xoff_t dec_laststart; /* offset of the start of last target window */ | 916 | usize_t dec_lastlen; /* length of the last target |
896 | usize_t dec_lastspace; /* allocated space of last target window, for reuse */ | 917 | window */ |
897 | 918 | xoff_t dec_laststart; /* offset of the start of last | |
898 | xd3_desect inst_sect; /* staging area for decoding window sections */ | 919 | target window */ |
920 | usize_t dec_lastspace; /* allocated space of last | ||
921 | target window, for reuse */ | ||
922 | |||
923 | xd3_desect inst_sect; /* staging area for decoding | ||
924 | window sections */ | ||
899 | xd3_desect addr_sect; | 925 | xd3_desect addr_sect; |
900 | xd3_desect data_sect; | 926 | xd3_desect data_sect; |
901 | 927 | ||
@@ -911,6 +937,15 @@ struct _xd3_stream | |||
911 | xd3_sec_stream *sec_stream_i; | 937 | xd3_sec_stream *sec_stream_i; |
912 | xd3_sec_stream *sec_stream_a; | 938 | xd3_sec_stream *sec_stream_a; |
913 | 939 | ||
940 | /* state for reconstructing whole files (e.g., for merge), this only | ||
941 | * supports loading USIZE_T_MAX instructions, adds, etc. */ | ||
942 | usize_t whole_target_addslen; | ||
943 | uint8_t *whole_target_adds; | ||
944 | usize_t whole_target_adds_alloc; | ||
945 | usize_t whole_target_instlen; | ||
946 | xd3_winst *whole_target_inst; | ||
947 | usize_t whole_target_inst_alloc; | ||
948 | |||
914 | /* statistics */ | 949 | /* statistics */ |
915 | xoff_t n_scpy; | 950 | xoff_t n_scpy; |
916 | xoff_t n_tcpy; | 951 | xoff_t n_tcpy; |
@@ -933,9 +968,9 @@ struct _xd3_stream | |||
933 | #endif | 968 | #endif |
934 | }; | 969 | }; |
935 | 970 | ||
936 | /****************************************************************************************** | 971 | /************************************************************************** |
937 | PUBLIC FUNCTIONS | 972 | PUBLIC FUNCTIONS |
938 | ******************************************************************************************/ | 973 | **************************************************************************/ |
939 | 974 | ||
940 | /* This function configures an xd3_stream using the provided in-memory | 975 | /* This function configures an xd3_stream using the provided in-memory |
941 | * input buffer, source buffer, output buffer, and flags. The output | 976 | * input buffer, source buffer, output buffer, and flags. The output |
@@ -1022,14 +1057,22 @@ int xd3_decode_stream (xd3_stream *stream, | |||
1022 | * | 1057 | * |
1023 | * Return values: | 1058 | * Return values: |
1024 | * | 1059 | * |
1025 | * XD3_INPUT: the process requires more input: call xd3_avail_input() then repeat | 1060 | * XD3_INPUT: the process requires more input: call |
1026 | * XD3_OUTPUT: the process has more output: read stream->next_out, stream->avail_out, | 1061 | * xd3_avail_input() then repeat |
1027 | * then call xd3_consume_output(), then repeat | 1062 | * |
1028 | * XD3_GOTHEADER: (decoder-only) notification returned following the VCDIFF header and | 1063 | * XD3_OUTPUT: the process has more output: read stream->next_out, |
1029 | * first window header. the decoder may use the header to configure itself. | 1064 | * stream->avail_out, then call xd3_consume_output(), |
1030 | * XD3_WINSTART: a general notification returned once for each window except the 0-th | 1065 | * then repeat |
1031 | * window, which is implied by XD3_GOTHEADER. It is recommended to | 1066 | * |
1032 | * use a switch-stmt such as: | 1067 | * XD3_GOTHEADER: (decoder-only) notification returned following the |
1068 | * VCDIFF header and first window header. the decoder | ||
1069 | * may use the header to configure itself. | ||
1070 | * | ||
1071 | * XD3_WINSTART: a general notification returned once for each | ||
1072 | * window except the 0-th window, which is implied by | ||
1073 | * XD3_GOTHEADER. It is recommended to use a | ||
1074 | * switch-stmt such as: | ||
1075 | * | ||
1033 | * ... | 1076 | * ... |
1034 | * again: | 1077 | * again: |
1035 | * switch ((ret = xd3_decode_input (stream))) { | 1078 | * switch ((ret = xd3_decode_input (stream))) { |
@@ -1043,11 +1086,14 @@ int xd3_decode_stream (xd3_stream *stream, | |||
1043 | * goto again; | 1086 | * goto again; |
1044 | * } | 1087 | * } |
1045 | * ... | 1088 | * ... |
1046 | * XD3_WINFINISH: a general notification, following the complete input & output of a | 1089 | * |
1047 | * window. at this point, stream->total_in and stream->total_out are | 1090 | * XD3_WINFINISH: a general notification, following the complete |
1048 | * consistent for either encoding or decoding. | 1091 | * input & output of a window. at this point, |
1049 | * XD3_GETSRCBLK: If the xd3_getblk() callback is NULL, this value is returned to | 1092 | * stream->total_in and stream->total_out are consistent |
1050 | * initiate a non-blocking source read. | 1093 | * for either encoding or decoding. |
1094 | * | ||
1095 | * XD3_GETSRCBLK: If the xd3_getblk() callback is NULL, this value | ||
1096 | * is returned to initiate a non-blocking source read. | ||
1051 | */ | 1097 | */ |
1052 | int xd3_decode_input (xd3_stream *stream); | 1098 | int xd3_decode_input (xd3_stream *stream); |
1053 | int xd3_encode_input (xd3_stream *stream); | 1099 | int xd3_encode_input (xd3_stream *stream); |