/* iffar - IFF CAT archiver quick append functions

   By Karl Lehenbauer, version 1.2, release date 5/9/88.
   This code is released to the public domain.
   See the README file for more information.

*/

#include <stdio.h>
#include "assert.h"

extern int verbose;

/* append a list of files specified by an array of pointers to
 * names, the number of entries in the array, and a file decscriptor
 * to write them to
 */
quickappend_entries(archive_fd,entryname_pointers,entrycount)
int archive_fd;
char *entryname_pointers[];
int entrycount;
{
	int files;
	char *nameptr;

	/* for all names specified on the command line */
	for (files = 0; files < entrycount; files++)
	{
		/* scdir will return nonnull values as long as the pattern
		 * matches files (it will return patternless names the first
		 * time and NULL the second
		 */
		while (nameptr = scdir(entryname_pointers[files]))
		{
			/* append the file */
			if (append_file_to_archive(nameptr,archive_fd))
			{
				if (verbose)
					fprintf(stderr,"appended %s\n",nameptr);
			}
		}
	}
	if (!rewrite_archive_header(archive_fd))
	{
		fprintf(stderr,"rewrite of archive header failed... archive is presumed blown\n");
	}
	close(archive_fd);
}

/* end of quickappend.c */
