/*
 * W-NEWS       A simple NEWS processing package.
 *		packers.c - routines to handle the different packers.
 *
 * Version:     @(#)packers.c     4.50    19-Nov-1993
 *
 * Author:	Miquel van Smoorenburg, <miquels@drinkel.ow.org>
 *              Copyright 1993 MicroWalt Corporation
 *		Copyright 1994,1995 Cistron Software C.V.
 *
 *              This program is free software; you can redistribute it and/or
 *              modify it under the terms of the GNU General Public License
 *              as published by the Free Software Foundation; either version
 *              2 of the License, or (at your option) any later version.
 */
#include "libwnews.h"


static struct packer {				/* Packers we know about. */
  char	*nickname;
  char	*header;
  char	*prog;
  char	*unprog;
  int	ratio;
} packers[] = {
  { "compress",	"#! cunbatch\n",   "compress",		"uncompress",	2 },
  { "comp12",	"#! cunbatch\n",   "compress -b12",	"uncompress",	2 },
  { "comp13",	"#! cunbatch\n",   "compress -b13",	"uncompress",	2 },
  { "compgzip",	"#! cunbatch\n",   "gzip",		"uncompress",	3 },
  { "gzip",	"#! gzunbatch\n",  "gzip",		"gzip -d",	3 },
  { "gzip",	"#! gunbatch\n",   "gzip",		"gzip -d",	3 },
  { "freeze",	"#! funbatch\n",   "freeze",		"freeze -d",	3 },
  { NULL,	NULL,		   NULL,		NULL,		0 }
};


/* Get the uncompress program. */
char *
p_uncomp(p)
char *p;
{
  int f;

  for(f = 0; packers[f].nickname; f++)
	if (strcmp(packers[f].header, p) == 0) return(packers[f].unprog);
  return((char *)NULL);
}


/* Get the compress program. */
char *
p_comp(p)
char *p;
{
  int f;

  for(f = 0; packers[f].nickname; f++)
	if (strcmp(packers[f].nickname, p) == 0) return(packers[f].prog);
  return((char *)NULL);
}


/* Get the compress ratio. */
int
p_ratio(p)
char *p;
{
  int f;

  for(f = 0; packers[f].nickname; f++)
	if (strcmp(packers[f].nickname, p) == 0) return(packers[f].ratio);
  return(1);
}


/* Get the compress header. */
char *
p_header(p)
char *p;
{
  int f;

  for(f = 0; packers[f].nickname; f++)
	if (strcmp(packers[f].nickname, p) == 0) return(packers[f].header);
  return((char *)NULL);
}
