/***********************************************************************
* *
* This software is part of the zlib package *
* Copyright (c) 1995-2009 Jean-loup Gailly and Mark Adler *
* *
* This software is provided 'as-is', without any express or implied *
* warranty. In no event will the authors be held liable for any *
* damages arising from the use of this software. *
* *
* Permission is granted to anyone to use this software for any *
* purpose, including commercial applications, and to alter it and *
* redistribute it freely, subject to the following restrictions: *
* *
* 1. The origin of this software must not be misrepresented; *
* you must not claim that you wrote the original software. If *
* you use this software in a product, an acknowledgment in the *
* product documentation would be appreciated but is not *
* required. *
* *
* 2. Altered source versions must be plainly marked as such, *
* and must not be misrepresented as being the original *
* software. *
* *
* 3. This notice may not be removed or altered from any source *
* distribution. *
* *
* This software is provided "as-is", without any express or implied *
* warranty. In no event will the authors be held liable for any damages*
* arising from the use of this software. *
* *
* Permission is granted to anyone to use this software for any purpose,*
* including commercial applications, and to alter it and redistribute i*
* freely, subject to the following restrictions: *
* *
* 1. The origin of this software must not be misrepresented; you must n*
* claim that you wrote the original software. If you use this softwa*
* in a product, an acknowledgment in the product documentation would*
* be appreciated but is not required. *
* *
* 2. Altered source versions must be plainly marked as such, and must n*
* be misrepresented as being the original software. *
* *
* 3. This notice may not be removed or altered from any source *
* distribution. *
* *
* Jean-loup Gailly *
* Mark Adler *
* *
***********************************************************************/
#pragma prototyped
/*
* sfio gzip discipline
*
* handles { gzip compress vczip } on input
* handles { gzip compress } on output
*/
#include <sfio_t.h>
#include <ast.h>
#include <zlib.h>
#include <sfdcgzip.h>
#ifdef z_off64_t
#endif
typedef struct
{
} Sfgzip_t;
/*
* gzip exception handler
* free on close
*/
static int
{
int f;
int r;
#if 0
{
static char aha[] = "AHA sfdcgzip event 0\n";
static int init;
if (!init)
if (init > 0)
{
}
}
#endif
switch (op)
{
case SF_ATEXIT:
return 0;
case SF_CLOSING:
case SF_DPOP:
case SF_FINAL:
{
}
else
r = 0;
{
}
if (op != SF_CLOSING)
return r;
case SF_DBUFFER:
return 1;
case SF_SYNC:
return 0;
case SFGZ_HANDLE:
case SFGZ_GETPOS:
case SFGZ_SETPOS:
}
return 0;
}
/*
* sfio gzip discipline seek
*/
static Sfoff_t
{
}
/*
* sfio gzip discipline read
*/
static ssize_t
{
}
/*
* sfio gzip discipline write
*/
static ssize_t
{
}
/*
* create and push the sfio gzip discipline
*
* (flags&SFGZ_VERIFY) return
* >0 is a { g:gzip c:compress v:vczip } file
* 0 not a { gzip compress vczip } file
* <0 error
* otherwise return
* >0 discipline pushed { g:gzip c:compress v:vczip }
* 0 discipline not needed
* <0 error
*/
#define PRIVATE 0
int
{
char* m;
int fd;
int rd;
size_t z;
if (rd)
{
register unsigned char* s;
register int n;
register int r;
/*
* peek the first 4 bytes to verify the magic
*
* 0x1f8b.... sfdcgzip gzip
* 0x1f9d.... sfdclzw compress
* 0xd6c3c4d8 sfpopen vcunzip
*/
#if PRIVATE
#endif
#if PRIVATE
if (!n)
#endif
if (!s)
return -1;
n = 0;
if (s[0] == 0x1f)
{
if (s[1] == 0x8b)
n = 'g';
else if (s[1] == 0x9d)
n = 'c';
}
else if (s[0] == 0xd6 && s[1] == 0xc3 && s[2] == 0xc4 && s[3] == 0xd8)
n = 'v';
if (!n)
return 0;
if (flags & SFGZ_VERIFY)
return n != 0;
switch (n)
{
case 'c':
case 'v':
r = 0;
n = dup(0);
close(0);
r = -1;
close(0);
if (n > 0 && dup(n))
r = -1;
close(n);
return r > 0 ? 'v' : r;
}
}
else if (flags & SFGZ_VERIFY)
return -1;
return -1;
if (rd)
else
m = mode;
*m++ = 'b';
if (flags & SFGZ_NOCRC)
*m++ = 'n';
*m++ = 'o';
*m++ = '0' + flags;
*m = 0;
#if PRIVATE
#endif
if (!rd)
{
m = 0;
z = 0;
}
m = 0;
else
z = 0;
{
return -1;
}
#if PRIVATE
#if 0
{
char* v;
long n;
{
}
else
}
#else
#endif
#endif
if (!rd)
return 'g';
}
#if __OBSOLETE__ < 19990717
#if defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern int
{
}
#undef extern
#endif