remove the example code from the repository.
considering that many issues were reported with lack of robustness of the example code, I have decided to remove it. while it was meant to initially be a demonstration of the bzip3 APIs, i do not want to turn it into a demonstration of how to use the C standard library. to guard the code against all sorts of errors (I/O, allocation) we would need to essentially triple the size of the example code for no reason in particular. one needs to check all I/O operations - fopen, fflush, fread, fwrite, fseek. you need to check malloc return values, need to check file headers, need to sync files using UNIX apis. then a handler for each case to display an error message and `exit`. as such, when the size of the "example" will grow 3 times and become just useless stuff completely irrelevant to someone who's using the library, it will stop serving its purpose. the example code was not a part of the library, but to stop it from drawing so much attention, it has been removed.
diff --git a/examples/compress-file.c b/examples/compress-file.c
deleted file mode 100644
index 5fab2d4..0000000
--- a/examples/compress-file.c
+++ /dev/null
@@ -1,44 +0,0 @@
-
-/* Compress a file SEQUENTIALLY (i.e. *not* in parallel) using bzip3 high level API with block size of 6 MB. */
-/* This is just a demonstration of bzip3 library usage, it does not contain all the necessary error checks and will not
- * support cross-endian encoding/decoding. */
-
-#include <libbz3.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define MB (1024 * 1024)
-
-int main(int argc, char ** argv) {
- if (argc != 3) {
- printf("Usage: %s <input file> <output file>\n", argv[0]);
- return 1;
- }
-
- // Read the entire input file to memory:
- FILE * fp = fopen(argv[1], "rb");
- fseek(fp, 0, SEEK_END);
- size_t size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- uint8_t * buffer = malloc(size);
- fread(buffer, 1, size, fp);
- fclose(fp);
-
- // Compress the file:
- size_t out_size = bz3_bound(size);
- uint8_t * outbuf = malloc(out_size);
- int bzerr = bz3_compress(6 * MB, buffer, outbuf, size, &out_size);
- if (bzerr != BZ3_OK) {
- printf("bz3_compress() failed with error code %d", bzerr);
- return 1;
- }
-
- FILE * outfp = fopen(argv[2], "wb");
- /* XXX: Doesn't preserve endianess. We should write the `size_t` value manually with known endianess. */
- fwrite(&size, 1, sizeof(size_t), outfp);
- fwrite(outbuf, 1, out_size, outfp);
- fclose(outfp);
-
- printf("OK, %d => %d\n", size, out_size);
- return 0;
-}
diff --git a/examples/decompress-file.c b/examples/decompress-file.c
deleted file mode 100644
index 93f16d6..0000000
--- a/examples/decompress-file.c
+++ /dev/null
@@ -1,41 +0,0 @@
-
-/* Decompress a file produced by compress-file SEQUENTIALLY (i.e. *not* in parallel) using bzip3 high level API. */
-/* This is just a demonstration of bzip3 library usage, it does not contain all the necessary error checks and will not
- * support cross-endian encoding/decoding. It *WILL* segfault if the input file does not exist,
- * malloc returns a NULL pointer, etc... - you are expected to handle these corner cases in your code. */
-
-#include <libbz3.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int main(int argc, char ** argv) {
- if (argc != 3) {
- printf("Usage: %s <input file> <output file>", argv[0]);
- return 1;
- }
-
- // Read the entire input file to memory:
- FILE * fp = fopen(argv[1], "rb");
- fseek(fp, 0, SEEK_END);
- size_t size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- uint8_t * buffer = malloc(size);
- fread(buffer, 1, size, fp);
- fclose(fp);
-
- // Decompress the file:
- size_t orig_size = *(size_t *)buffer;
- uint8_t * outbuf = malloc(orig_size);
- int bzerr = bz3_decompress(buffer + sizeof(size_t), outbuf, size - sizeof(size_t), &orig_size);
- if (bzerr != BZ3_OK) {
- printf("bz3_decompress() failed with error code %d", bzerr);
- return 1;
- }
-
- FILE * outfp = fopen(argv[2], "wb");
- fwrite(outbuf, 1, orig_size, outfp);
- fclose(outfp);
-
- printf("OK, %d => %d", size, orig_size);
- return 0;
-}
