/*
	Dummy rnews program to create rnews.bag files when run directly
	by a uucp connection.  Then use the dnews.conf parameter to 
	read the .bag files into dnews.

	You might want to put a full path in the fopen line below so the
	bag files are created in a standard directory.
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	FILE *f;
	int chunk,r,len,rout;
	int bf[11000];

	if (argc!=2) {printf("Usage: rnews length\n"); return 0;}
	len = atoi(argv[1]);
	f = fopen("rnews.bag","a");
	if (f==NULL) {perror("rnews.bag"); return 0;}
	fprintf(f,"#! rnews %d\n",len);
	for (;len>0;) {
		chunk = 10000;
		if (chunk>len) chunk = len;
 		r = fread(bf,1,chunk,stdin);
		if (r<=0) {perror("Read error"); break;}
 		len -= r;
 		rout = fwrite(bf,1,r,f);
		if (rout!=r) {perror("Write error"); break;}
	}
	fclose(f);
}
