]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Modules/zlib/minigzip.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Modules / zlib / minigzip.c
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Modules/zlib/minigzip.c b/AppPkg/Applications/Python/Python-2.7.2/Modules/zlib/minigzip.c
deleted file mode 100644 (file)
index 41996db..0000000
+++ /dev/null
@@ -1,322 +0,0 @@
-/* minigzip.c -- simulate gzip using the zlib compression library\r
- * Copyright (C) 1995-2005 Jean-loup Gailly.\r
- * For conditions of distribution and use, see copyright notice in zlib.h\r
- */\r
-\r
-/*\r
- * minigzip is a minimal implementation of the gzip utility. This is\r
- * only an example of using zlib and isn't meant to replace the\r
- * full-featured gzip. No attempt is made to deal with file systems\r
- * limiting names to 14 or 8+3 characters, etc... Error checking is\r
- * very limited. So use minigzip only for testing; use gzip for the\r
- * real thing. On MSDOS, use only on file names without extension\r
- * or in pipe mode.\r
- */\r
-\r
-/* @(#) $Id$ */\r
-\r
-#include <stdio.h>\r
-#include "zlib.h"\r
-\r
-#ifdef STDC\r
-#  include <string.h>\r
-#  include <stdlib.h>\r
-#endif\r
-\r
-#ifdef USE_MMAP\r
-#  include <sys/types.h>\r
-#  include <sys/mman.h>\r
-#  include <sys/stat.h>\r
-#endif\r
-\r
-#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)\r
-#  include <fcntl.h>\r
-#  include <io.h>\r
-#  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)\r
-#else\r
-#  define SET_BINARY_MODE(file)\r
-#endif\r
-\r
-#ifdef VMS\r
-#  define unlink delete\r
-#  define GZ_SUFFIX "-gz"\r
-#endif\r
-#ifdef RISCOS\r
-#  define unlink remove\r
-#  define GZ_SUFFIX "-gz"\r
-#  define fileno(file) file->__file\r
-#endif\r
-#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os\r
-#  include <unix.h> /* for fileno */\r
-#endif\r
-\r
-#ifndef WIN32 /* unlink already in stdio.h for WIN32 */\r
-  extern int unlink OF((const char *));\r
-#endif\r
-\r
-#ifndef GZ_SUFFIX\r
-#  define GZ_SUFFIX ".gz"\r
-#endif\r
-#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)\r
-\r
-#define BUFLEN      16384\r
-#define MAX_NAME_LEN 1024\r
-\r
-#ifdef MAXSEG_64K\r
-#  define local static\r
-   /* Needed for systems with limitation on stack size. */\r
-#else\r
-#  define local\r
-#endif\r
-\r
-char *prog;\r
-\r
-void error            OF((const char *msg));\r
-void gz_compress      OF((FILE   *in, gzFile out));\r
-#ifdef USE_MMAP\r
-int  gz_compress_mmap OF((FILE   *in, gzFile out));\r
-#endif\r
-void gz_uncompress    OF((gzFile in, FILE   *out));\r
-void file_compress    OF((char  *file, char *mode));\r
-void file_uncompress  OF((char  *file));\r
-int  main             OF((int argc, char *argv[]));\r
-\r
-/* ===========================================================================\r
- * Display error message and exit\r
- */\r
-void error(msg)\r
-    const char *msg;\r
-{\r
-    fprintf(stderr, "%s: %s\n", prog, msg);\r
-    exit(1);\r
-}\r
-\r
-/* ===========================================================================\r
- * Compress input to output then close both files.\r
- */\r
-\r
-void gz_compress(in, out)\r
-    FILE   *in;\r
-    gzFile out;\r
-{\r
-    local char buf[BUFLEN];\r
-    int len;\r
-    int err;\r
-\r
-#ifdef USE_MMAP\r
-    /* Try first compressing with mmap. If mmap fails (minigzip used in a\r
-     * pipe), use the normal fread loop.\r
-     */\r
-    if (gz_compress_mmap(in, out) == Z_OK) return;\r
-#endif\r
-    for (;;) {\r
-        len = (int)fread(buf, 1, sizeof(buf), in);\r
-        if (ferror(in)) {\r
-            perror("fread");\r
-            exit(1);\r
-        }\r
-        if (len == 0) break;\r
-\r
-        if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));\r
-    }\r
-    fclose(in);\r
-    if (gzclose(out) != Z_OK) error("failed gzclose");\r
-}\r
-\r
-#ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */\r
-\r
-/* Try compressing the input file at once using mmap. Return Z_OK if\r
- * if success, Z_ERRNO otherwise.\r
- */\r
-int gz_compress_mmap(in, out)\r
-    FILE   *in;\r
-    gzFile out;\r
-{\r
-    int len;\r
-    int err;\r
-    int ifd = fileno(in);\r
-    caddr_t buf;    /* mmap'ed buffer for the entire input file */\r
-    off_t buf_len;  /* length of the input file */\r
-    struct stat sb;\r
-\r
-    /* Determine the size of the file, needed for mmap: */\r
-    if (fstat(ifd, &sb) < 0) return Z_ERRNO;\r
-    buf_len = sb.st_size;\r
-    if (buf_len <= 0) return Z_ERRNO;\r
-\r
-    /* Now do the actual mmap: */\r
-    buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);\r
-    if (buf == (caddr_t)(-1)) return Z_ERRNO;\r
-\r
-    /* Compress the whole file at once: */\r
-    len = gzwrite(out, (char *)buf, (unsigned)buf_len);\r
-\r
-    if (len != (int)buf_len) error(gzerror(out, &err));\r
-\r
-    munmap(buf, buf_len);\r
-    fclose(in);\r
-    if (gzclose(out) != Z_OK) error("failed gzclose");\r
-    return Z_OK;\r
-}\r
-#endif /* USE_MMAP */\r
-\r
-/* ===========================================================================\r
- * Uncompress input to output then close both files.\r
- */\r
-void gz_uncompress(in, out)\r
-    gzFile in;\r
-    FILE   *out;\r
-{\r
-    local char buf[BUFLEN];\r
-    int len;\r
-    int err;\r
-\r
-    for (;;) {\r
-        len = gzread(in, buf, sizeof(buf));\r
-        if (len < 0) error (gzerror(in, &err));\r
-        if (len == 0) break;\r
-\r
-        if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {\r
-            error("failed fwrite");\r
-        }\r
-    }\r
-    if (fclose(out)) error("failed fclose");\r
-\r
-    if (gzclose(in) != Z_OK) error("failed gzclose");\r
-}\r
-\r
-\r
-/* ===========================================================================\r
- * Compress the given file: create a corresponding .gz file and remove the\r
- * original.\r
- */\r
-void file_compress(file, mode)\r
-    char  *file;\r
-    char  *mode;\r
-{\r
-    local char outfile[MAX_NAME_LEN];\r
-    FILE  *in;\r
-    gzFile out;\r
-\r
-    strcpy(outfile, file);\r
-    strcat(outfile, GZ_SUFFIX);\r
-\r
-    in = fopen(file, "rb");\r
-    if (in == NULL) {\r
-        perror(file);\r
-        exit(1);\r
-    }\r
-    out = gzopen(outfile, mode);\r
-    if (out == NULL) {\r
-        fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);\r
-        exit(1);\r
-    }\r
-    gz_compress(in, out);\r
-\r
-    unlink(file);\r
-}\r
-\r
-\r
-/* ===========================================================================\r
- * Uncompress the given file and remove the original.\r
- */\r
-void file_uncompress(file)\r
-    char  *file;\r
-{\r
-    local char buf[MAX_NAME_LEN];\r
-    char *infile, *outfile;\r
-    FILE  *out;\r
-    gzFile in;\r
-    uInt len = (uInt)strlen(file);\r
-\r
-    strcpy(buf, file);\r
-\r
-    if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {\r
-        infile = file;\r
-        outfile = buf;\r
-        outfile[len-3] = '\0';\r
-    } else {\r
-        outfile = file;\r
-        infile = buf;\r
-        strcat(infile, GZ_SUFFIX);\r
-    }\r
-    in = gzopen(infile, "rb");\r
-    if (in == NULL) {\r
-        fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);\r
-        exit(1);\r
-    }\r
-    out = fopen(outfile, "wb");\r
-    if (out == NULL) {\r
-        perror(file);\r
-        exit(1);\r
-    }\r
-\r
-    gz_uncompress(in, out);\r
-\r
-    unlink(infile);\r
-}\r
-\r
-\r
-/* ===========================================================================\r
- * Usage:  minigzip [-d] [-f] [-h] [-r] [-1 to -9] [files...]\r
- *   -d : decompress\r
- *   -f : compress with Z_FILTERED\r
- *   -h : compress with Z_HUFFMAN_ONLY\r
- *   -r : compress with Z_RLE\r
- *   -1 to -9 : compression level\r
- */\r
-\r
-int main(argc, argv)\r
-    int argc;\r
-    char *argv[];\r
-{\r
-    int uncompr = 0;\r
-    gzFile file;\r
-    char outmode[20];\r
-\r
-    strcpy(outmode, "wb6 ");\r
-\r
-    prog = argv[0];\r
-    argc--, argv++;\r
-\r
-    while (argc > 0) {\r
-      if (strcmp(*argv, "-d") == 0)\r
-        uncompr = 1;\r
-      else if (strcmp(*argv, "-f") == 0)\r
-        outmode[3] = 'f';\r
-      else if (strcmp(*argv, "-h") == 0)\r
-        outmode[3] = 'h';\r
-      else if (strcmp(*argv, "-r") == 0)\r
-        outmode[3] = 'R';\r
-      else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&\r
-               (*argv)[2] == 0)\r
-        outmode[2] = (*argv)[1];\r
-      else\r
-        break;\r
-      argc--, argv++;\r
-    }\r
-    if (outmode[3] == ' ')\r
-        outmode[3] = 0;\r
-    if (argc == 0) {\r
-        SET_BINARY_MODE(stdin);\r
-        SET_BINARY_MODE(stdout);\r
-        if (uncompr) {\r
-            file = gzdopen(fileno(stdin), "rb");\r
-            if (file == NULL) error("can't gzdopen stdin");\r
-            gz_uncompress(file, stdout);\r
-        } else {\r
-            file = gzdopen(fileno(stdout), outmode);\r
-            if (file == NULL) error("can't gzdopen stdout");\r
-            gz_compress(stdin, file);\r
-        }\r
-    } else {\r
-        do {\r
-            if (uncompr) {\r
-                file_uncompress(*argv);\r
-            } else {\r
-                file_compress(*argv, outmode);\r
-            }\r
-        } while (argv++, --argc);\r
-    }\r
-    return 0;\r
-}\r