#include "plateau.h"
 
extern char MYADDR[50];
 
void sendmove();
void generate_file();
 
void generate_file(game)
struct gameinfo *game;
{   FILE *fptr,*gptr;
    char my_address[50];
    char filename[20];
    char command[50];
 
    strcpy(my_address,MYADDR);
    sprintf(filename,"%s.out",game->name);
    if ((fptr = fopen(filename,"w")) == NULL)
    {	scroll();
	drawline("Cannot open temporary file for mail.");
	return;
    }
    if ((gptr = fopen("comments","r")) != NULL)
    {	game->comments = 'y';
	fclose(gptr);
    }
    else
	game->comments = 'n';
 
    fprintf(fptr,"PLATEAU!%s:%d:%c:%c\n",game->name,game->moveno,
	game->status,game->comments);
 
    fprintf(fptr,"-----\n");
    write_position(fptr);
    fclose(fptr);
    if (game->comments == 'y')
    {   
	
	sprintf(command,"cat comments >> %s",filename);
	system(command);
	system("rm comments");

/*  For DOS
	sprintf(command,"type comments >> %s",filename);
	system(command);
	system("del comments");
*/

    }
}
