{"id":21651660,"url":"https://github.com/hoytech/vcdiff-xdelta3","last_synced_at":"2025-03-20T03:59:52.333Z","repository":{"id":8708945,"uuid":"10376541","full_name":"hoytech/Vcdiff-Xdelta3","owner":"hoytech","description":"Xdelta3 backend for Vcdiff","archived":false,"fork":false,"pushed_at":"2014-05-27T02:55:43.000Z","size":368,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T05:42:46.457Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoytech.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-30T06:01:21.000Z","updated_at":"2014-05-27T02:55:43.000Z","dependencies_parsed_at":"2022-07-09T21:31:02.515Z","dependency_job_id":null,"html_url":"https://github.com/hoytech/Vcdiff-Xdelta3","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2FVcdiff-Xdelta3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2FVcdiff-Xdelta3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2FVcdiff-Xdelta3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2FVcdiff-Xdelta3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoytech","download_url":"https://codeload.github.com/hoytech/Vcdiff-Xdelta3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244547602,"owners_count":20470103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T07:49:08.793Z","updated_at":"2025-03-20T03:59:52.314Z","avatar_url":"https://github.com/hoytech.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"package Vcdiff::Xdelta3;\n\nuse strict;\n\nuse Carp;\n\nuse Vcdiff;\n\nour $VERSION = '0.104';\n\nrequire XSLoader;\nXSLoader::load('Vcdiff::Xdelta3', $VERSION);\n\n\n\nsub diff {\n  my ($source, $input, $output) = @_;\n\n  my ($source_fileno, $source_str, $input_fileno, $input_str, $output_fileno, $output_str);\n\n  $source_fileno = $input_fileno = $output_fileno = -1;\n\n  if (!defined $source) {\n    croak \"diff needs source argument\";\n  } elsif (ref $source eq 'GLOB') {\n    $source_fileno = fileno($source);\n    croak \"source file handle is closed or invalid\" if !defined $source_fileno || $source_fileno == -1;\n  } else {\n    $source_str = $source;\n  }\n\n  if (!defined $input) {\n    croak \"diff needs target argument\";\n  } elsif (ref $input eq 'GLOB') {\n    $input_fileno = fileno($input);\n    croak \"target file handle is closed or invalid\" if !defined $input_fileno || $input_fileno == -1;\n  } else {\n    $input_str = $input;\n  }\n\n  if (defined $output) {\n    croak \"output argument to diff should be a file handle or undef\"\n      if ref $output ne 'GLOB';\n\n    $output_fileno = fileno($output);\n    croak \"output file handle is closed or invalid\" if !defined $output_fileno || $output_fileno == -1;\n  } else {\n    $output_str = '';\n  }\n\n  my $ret = _encode($source_fileno, $source_str, $input_fileno, $input_str, $output_fileno, $output_str);\n\n  _check_ret($ret, 'diff');\n\n  return $output_str if !defined $output;\n}\n\n\nsub patch {\n  my ($source, $input, $output) = @_;\n\n  my ($source_fileno, $source_str, $input_fileno, $input_str, $output_fileno, $output_str);\n\n  $source_fileno = $input_fileno = $output_fileno = -1;\n\n  if (!defined $source) {\n    croak \"patch needs source argument\";\n  } elsif (ref $source eq 'GLOB') {\n    $source_fileno = fileno($source);\n    croak \"source file handle is closed or invalid\" if !defined $source_fileno || $source_fileno == -1;\n  } else {\n    $source_str = $source;\n  }\n\n  if (!defined $input) {\n    croak \"patch needs delta argument\";\n  } elsif (ref $input eq 'GLOB') {\n    $input_fileno = fileno($input);\n    croak \"delta file handle is closed or invalid\" if !defined $input_fileno || $input_fileno == -1;\n  } else {\n    $input_str = $input;\n  }\n\n  if (defined $output) {\n    croak \"output argument to patch should be a file handle or undef\"\n      if ref $output ne 'GLOB';\n\n    $output_fileno = fileno($output);\n    croak \"output file handle is closed or invalid\" if !defined $output_fileno || $output_fileno == -1;\n  } else {\n    $output_str = '';\n  }\n\n  my $ret = _decode($source_fileno, $source_str, $input_fileno, $input_str, $output_fileno, $output_str);\n\n  _check_ret($ret, 'patch');\n\n  return $output_str if !defined $output;\n}\n\n\n\nmy $exception_map = {\n  1 =\u003e 'xd3_config_stream',\n  2 =\u003e 'unable to allocate memory for source.blksize',\n  3 =\u003e 'source is not lseek()able (must be a regular file, not a pipe/socket)',\n  4 =\u003e 'error reading from source',\n  5 =\u003e 'unable to allocate memory for ibuf',\n  6 =\u003e 'error reading from target/delta',\n  7 =\u003e 'error writing to output',\n  8 =\u003e 'xd3_close_stream',\n};\n\nsub _check_ret {\n  my ($ret, $func) = @_;\n\n  return unless $ret;\n\n  my $exception = $exception_map-\u003e{$ret};\n\n  croak \"error in Vcdiff::Xdelta3::$func: $exception\" if $exception;\n\n  croak \"unknown error in Vcdiff::Xdelta3::$func ($ret)\";\n}\n\n\n1;\n\n\n\n\n=head1 NAME\n\nVcdiff::Xdelta3 - Xdelta3 backend for Vcdiff\n\n=head1 SYNOPSIS\n\n    use Vcdiff::Xdelta3;\n\n    my $delta = Vcdiff::Xdelta3::diff($source, $target);\n\n    my $target2 = Vcdiff::Xdelta3::patch($source, $delta);\n\n    ## $target2 eq $target\n\nThis module is a backend to the L\u003cVcdiff\u003e module and isn't usually used directly.\n\n\n=head1 DESCRIPTION\n\nXdelta3 is a delta encoding library by Joshua MacDonald. The Xdelta3 source code is embedded into this module and built as a shared object. The C\u003cxdelta3\u003e command-line binary is not built.\n\n\n=head1 PROS\n\n=over\n\n=item *\n\nDoesn't have arbitrary size limitations on source, target, or delta files.\n\n=item *\n\nHas a really neat feature that lets you merge VCDIFF deltas into a single delta. Unfortunately this module doesn't expose that yet.\n\n=back\n\n\n=head1 CONS\n\n=over\n\n=item *\n\nGPL licensed\n\n=item *\n\nBuild system is really weird. I didn't bother figuring out how to run Xdelta3's test-suite when installing the CPAN module which is unfortunate. Note that installing this module does still run the shared test-suite in L\u003cVcdiff\u003e.\n\n=back\n\n\n=head1 SEE ALSO\n\nL\u003cVcdiff-Xdelta3 github repo|https://github.com/hoytech/Vcdiff-Xdelta3\u003e\n\nL\u003cVcdiff\u003e\n\nL\u003cOfficial Xdelta3 website|http://xdelta.org/\u003e\n\n\n=head1 AUTHOR\n\nDoug Hoyte, C\u003c\u003c \u003cdoug@hcsw.org\u003e \u003e\u003e\n\n\n=head1 COPYRIGHT \u0026 LICENSE\n\nCopyright 2013 Doug Hoyte.\n\nThis module includes xdelta3 which is copyright Joshua P. MacDonald. xdelta3 is licensed under the GNU GPL 2 which can be found in the inc/COPYING file of this distribution.\n\nBecause of xdelta3's license, this module is licensed under the GNU GPL 2.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoytech%2Fvcdiff-xdelta3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoytech%2Fvcdiff-xdelta3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoytech%2Fvcdiff-xdelta3/lists"}