/* uusplt.c - Split concatenated uuencoded files into separate uue files */
/* $Id: uusplt.c,v 1.3 1995/02/06 23:22:43 tundra Exp $ */
/* $Log: uusplt.c,v $
/* Revision 1.3 1995/02/06 23:22:43 tundra
/* Changed to directly invoke uudecode via popen()
/* */
#include <stdio.h>
#include <strings.h>
void begun();
static int cnt;
main()
{
char buf[1001];
cnt = 0;
while(fgets(buf, 1000, stdin) != NULL)
{
if (strncmp("begin",buf, 5) == 0)
{
begun(buf);
cnt++;
}
}
printf("%d UUencoded Files Found.\n", cnt);
}
void begun(buf)
char *buf;
{
FILE *fd;
char nm[101];
int l;
l = strlen(buf) - 2;
while(buf[l] != ' ')
l--;
strcpy(nm, buf+l+1);
l = strlen(nm);
nm[l-1] = '\0';
if ((fd = popen("uudecode", "w")) == NULL)
{
printf("Hosed Pipe Open For %s!", nm);
exit();
}
printf("%s\n", nm);
while(strncmp("end", buf, 3) != 0)
{
fputs(buf, fd);
fgets(buf, 1000, stdin);
}
fputs(buf,fd);
fclose(fd);
}