/***********************************************************************
* *
* This software is part of the zlib package *
* Copyright (c) 1996-2003 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. *
* *
* Julian R Seward *
* *
***********************************************************************/
#pragma prototyped
/*
* sfio bzip discipline
*/
#include <sfio_t.h>
#include <ast.h>
#include <bzlib.h>
#include <sfdcbzip.h>
typedef struct
{
} Sfbzip_t;
/*
* bzip exception handler
* free on close
*/
static int
{
int r;
#if 1
{
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_READ:
case SF_WRITE:
case SF_SYNC:
case SFBZ_HANDLE:
case SFBZ_GETPOS:
case SFBZ_SETPOS:
}
return 0;
}
/*
* sfio bzip discipline read
*/
static ssize_t
{
}
/*
* sfio bzip discipline write
*/
static ssize_t
{
}
/*
* create and push the sfio bzip discipline
*
* (flags&SFBZ_VERIFY) return
* >0 is a bzip file
* 0 not a bzip file
* <0 error
* otherwise return
* >0 discipline pushed
* 0 discipline not needed
* <0 error
*/
int
{
char* m;
{
register unsigned char* s;
register int n;
/*
* peek the first 4 bytes to verify the magic
*
* BZh[0-9] sfdcbzip bzip
*/
if (!n)
if (!s)
return -1;
n = s[0] == 'B' && s[1] == 'Z' && s[2] == 'h' && (s[3] >= '0' && s[3] <= '9');
if (!n || (flags & SFBZ_VERIFY))
return n;
}
else if (flags & SFBZ_VERIFY)
return -1;
return -1;
else
m = mode;
*m++ = 'o';
*m++ = '0' + flags;
*m = 0;
{
return -1;
}
return 1;
}