/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred."
 *
 */
/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

/*
 * Copyright  (c) 1985 AT&T
 *	All Rights Reserved
 */
#ident	"$Header: oeupkg.c 1.2 89/10/10 $@(#)vm:xx/oeupkg.c	1.1"
#include <stdio.h>
#include <string.h>
#include "tsys.h"
#include "terror.h"
#include "retcds.h"
#include "parse.h"

main(argc, argv)
int argc;
char **argv;
{
	FILE *fp;
	struct oeh header, *oeuparse();
	extern char *optarg;
	int unpack = FALSE;
	int c;
	char *objtype, *type, *src, *dst, *enc, *appl, *form, *prid;
	char *file;
	char *getepenv();
	char *parsehead();

	wish_init(argc, argv);
	objtype = type = src = dst = enc = appl = form = prid = NULL;
	while ((c = getopt(argc, argv, "ut:s:d:o:e:a:f:p:")) != EOF)
		switch (c) {
		case 'u':
			unpack = TRUE;
			break;
		case 't':
			type = optarg;
			break;
		case 's':
			src = optarg;
			break;
		case 'd':
			dst = optarg;
			break;
		case 'o':
			objtype = optarg;
			break;
		case 'e':
			enc = optarg;
			break;
		case 'a':
			appl = optarg;
			break;
		case 'f':
			form = optarg;
			break;
		case 'p':
			prid = optarg;
			break;
		default:
			break;
		}
	if (unpack) {
		if (!src || !dst)
			fatal(BADARGS, "");
		header.file = dst;
		if (oeuparse(src, &header, UNPACK))
			exit(R_ERR);
		if (header.encrytest)
			puts(header.encrytest);
	}
	else {
		FILE *fp;

		if ((fp = fopen(dst, "w")) == NULL)
			fatal(NOPEN, "");
		if (!oeupack(fp, src, objtype, enc, type, appl, form, prid))
			exit(R_ERR);
	}
	exit(R_OK);
}
