/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1993-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* unpack file ...
* pcat file ...
*
* unpack files that have been Huffman encoded
*
* David Korn
* AT&T Research
*
*/
static const char usage_head[] =
"[-?@(#)$Id: unpack (AT&T Research) 2003-04-28 $\n]"
;
static const char usage_common[] =
"For each \afile\a specified, a search is made for a file named "
"\afile\a\b.z\b (or just \afile\a, if \afile\a ends in \b.z\b). If "
"this file appears to be a packed file, ";
"[+EXIT STATUS]{"
"[+0?All files unpacked successfully.]"
"[+\an\a?\an\a files failed to unpack, where \an\a is less than 125.]"
"[+125?125 or more files failed to unpack.]"
"}";
static const char usage_pcat1[] =
"[+NAME?pcat - unpack and concatenate files created by pack]"
"[+DESCRIPTION?\bpcat\b does for packed files what \bcat\b(1) does "
"for ordinary files, except that \bpcat\b cannot be used "
"as filter. ";
static const char usage_pcat2[] =
"\bpcat\b unpacks the file and writes it to standard output.]";
static const char pcat_see_also[] =
"[+SEE ALSO?pack(1), unpack(1), cat(1), zcat(1), gzcat(1)]";
static const char usage_unpack1[] =
"[+NAME?unpack - unpack files created by pack]"
"[+DESCRIPTION?\bunpack\b expands files created by \bpack\b. ";
static const char usage_unpack2[] =
"it is replaced by its original expanded version. The new file "
"has the \b.z\b suffix stripped from its name, and has the same "
"access modes, access and modification dates, and owner as those "
"of the packed file.]";
static const char unpack_see_also[] =
"[+SEE ALSO?pack(1), pcat(1), uncompress(1), gunzip(1)]";
#include "huffman.h"
#include <error.h>
#include <ls.h>
#include <times.h>
static char *inname(char*);
int
{
char *command;
char *usage;
int out;
int pcat;
int deleted;
int n;
command++;
else
if(pcat)
{
}
else
{
}
{
case ':':
break;
case '?':
break;
}
{
deleted = 0;
continue;
{
continue;
}
if(pcat)
else
{
else
{
goto ok;
}
goto skip;
}
ok:
else
{
if(!pcat)
{
deleted = 0;
}
nunpack++;
}
skip:
if(hp)
if(fpin)
if(fpout)
if(deleted)
if(infile)
}
if(argc > 125)
argc = 125;
}
{
register char *cp;
{
else
}
return(cp);
}