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

	/* buffer size for incoming mail */

#define RMAIL_BUF_SIZE	16000

main(int argc, char **argv)
{
char c,*buf;
FILE
	*out;


	/* check args */

if (argc != 2)
	{
	printf("usage: rmail user\n\n");
	return 0;
	}

	/* allocate buffer */

buf = malloc( RMAIL_BUF_SIZE );

	/* generate filename */

sprintf(buf,"uumail:%s", argv[1]);

	/* open file */

out = fopen(buf,"a");

	/* wipe out the buffer */

memset(buf, '\0', RMAIL_BUF_SIZE );

	/* set file buffering mode */

setbuf(out, buf);

	/* append stdin to mailbox file */

while ((c=getchar()) != EOF)
	fputc(c,out);

	/* free memory */

free(buf);

	/* close file */

fclose(out);

return 0;
}
