From 9a0b88bf7777c153dc46ace22db74ef24d51583a Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 29 Apr 2008 12:55:25 +0000 Subject: update release date to actual date git-svn-id: svn+q:///qpdf/trunk@599 71b93d88-0707-0410-a8cf-f5a4172ac649 --- zlib-flate/Makefile | 1 + zlib-flate/build.mk | 22 ++++++++++ zlib-flate/qtest/1.compressed | Bin 0 -> 193 bytes zlib-flate/qtest/1.uncompressed | 5 +++ zlib-flate/qtest/zf.test | 26 ++++++++++++ zlib-flate/zlib-flate.cc | 92 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 zlib-flate/Makefile create mode 100644 zlib-flate/build.mk create mode 100644 zlib-flate/qtest/1.compressed create mode 100644 zlib-flate/qtest/1.uncompressed create mode 100644 zlib-flate/qtest/zf.test create mode 100644 zlib-flate/zlib-flate.cc (limited to 'zlib-flate') diff --git a/zlib-flate/Makefile b/zlib-flate/Makefile new file mode 100644 index 00000000..90899055 --- /dev/null +++ b/zlib-flate/Makefile @@ -0,0 +1 @@ +include ../make/proxy.mk diff --git a/zlib-flate/build.mk b/zlib-flate/build.mk new file mode 100644 index 00000000..57d2c98c --- /dev/null +++ b/zlib-flate/build.mk @@ -0,0 +1,22 @@ +TARGETS_zlib-flate = \ + zlib-flate/$(OUTPUT_DIR)/zlib-flate + +$(TARGETS_zlib-flate): $(TARGETS_libqpdf) + +INCLUDES_zlib-flate = include + +SRCS_zlib-flate = zlib-flate/zlib-flate.cc + +# ----- + +OBJS_zlib-flate = $(call src_to_obj,$(SRCS_zlib-flate)) + +ifeq ($(GENDEPS),1) +-include $(call obj_to_dep,$(OBJS_zlib-flate)) +endif + +$(OBJS_zlib-flate): zlib-flate/$(OUTPUT_DIR)/%.o: zlib-flate/%.cc + $(call compile,$<,$(INCLUDES_zlib-flate)) + +zlib-flate/$(OUTPUT_DIR)/zlib-flate: $(OBJS_zlib-flate) + $(call makebin,$(OBJS_zlib-flate),$@) diff --git a/zlib-flate/qtest/1.compressed b/zlib-flate/qtest/1.compressed new file mode 100644 index 00000000..3d05ab1c Binary files /dev/null and b/zlib-flate/qtest/1.compressed differ diff --git a/zlib-flate/qtest/1.uncompressed b/zlib-flate/qtest/1.uncompressed new file mode 100644 index 00000000..0446561f --- /dev/null +++ b/zlib-flate/qtest/1.uncompressed @@ -0,0 +1,5 @@ +Once upon a time there lived three qowws. They didn't like poridge +much, so they had salad for breakfast. Goldilocks, upon breaking and +entering, found this to be distasteful and so she just went away +without eating any. This somewhat short-circuited the story. The +End. diff --git a/zlib-flate/qtest/zf.test b/zlib-flate/qtest/zf.test new file mode 100644 index 00000000..39271e16 --- /dev/null +++ b/zlib-flate/qtest/zf.test @@ -0,0 +1,26 @@ +#!/usr/bin/env perl +require 5.008; +BEGIN { $^W = 1; } +use strict; + +require TestDriver; + +my $td = new TestDriver('zlib-flate'); + +$td->runtest("compress", + {$td->COMMAND => "zlib-flate -compress < 1.uncompressed"}, + {$td->FILE => "1.compressed", + $td->EXIT_STATUS => 0}); + +$td->runtest("uncompress", + {$td->COMMAND => "zlib-flate -uncompress < 1.compressed"}, + {$td->FILE => "1.uncompressed", + $td->EXIT_STATUS => 0}); + +$td->runtest("error", + {$td->COMMAND => "zlib-flate -uncompress < 1.uncompressed"}, + {$td->REGEXP => "flate: inflate: data: .*\n", + $td->EXIT_STATUS => 2}, + $td->NORMALIZE_NEWLINES); + +$td->report(3); diff --git a/zlib-flate/zlib-flate.cc b/zlib-flate/zlib-flate.cc new file mode 100644 index 00000000..33a3cdd9 --- /dev/null +++ b/zlib-flate/zlib-flate.cc @@ -0,0 +1,92 @@ + +#include +#include + +#include +#include +#include +#include +#include + +static char const* whoami = 0; + +void usage() +{ + std::cerr << "Usage: " << whoami << " { -uncompress | -compress }" + << std::endl; + exit(2); +} + +int main(int argc, char* argv[]) +{ + if ((whoami = strrchr(argv[0], '/')) == NULL) + { + whoami = argv[0]; + } + else + { + ++whoami; + } + // For libtool's sake.... + if (strncmp(whoami, "lt-", 3) == 0) + { + whoami += 3; + } + + if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) + { + std::cout << whoami << " version 1.0" << std::endl; + exit(0); + } + + if (argc != 2) + { + usage(); + } + + Pl_Flate::action_e action = Pl_Flate::a_inflate; + + if ((strcmp(argv[1], "-uncompress") == 0)) + { + // okay + } + else if ((strcmp(argv[1], "-compress") == 0)) + { + action = Pl_Flate::a_deflate; + } + else + { + usage(); + } + + Pl_StdioFile* out = new Pl_StdioFile("stdout", stdout); + Pl_Flate* flate = new Pl_Flate("flate", out, action); + + try + { + unsigned char buf[10000]; + bool done = false; + while (! done) + { + int len = read(0, buf, sizeof(buf)); + if (len <= 0) + { + done = true; + } + else + { + flate->write(buf, len); + } + } + flate->finish(); + delete flate; + delete out; + } + catch (std::exception& e) + { + std::cerr << e.what() << std::endl; + exit(2); + } + + return 0; +} -- cgit v1.2.3-70-g09d2