/*
 *
 *  AM --- AmigaMail
 *  (C) 1991, 1992 by Christian Riede
 *
 *  AM is distributed in the hope that it will be useful, but WITHOUT ANY
 *  WARRANTY.  No author or distributor accepts responsibility to anyone
 *  for the consequences of using it or for whether it serves any
 *  particular purpose or works at all, unless he says so in writing.
 *  Refer to the GNU General Public License, Version 1, for full details.
 *  
 *  Everyone is granted permission to copy, modify and redistribute AM,
 *  but only under the conditions described in the GNU General Public
 *  License, Version 1.  A copy of this license is supposed to have been 
 *  given to you along with AM so you can know your rights and responsi-
 *  bilities.  It should be in a file named COPYING.  Among other things,
 *  the copyright notice and this notice must be preserved on all copies.
 *
 *  
 *
 */


#include "am.h"

/* write entries in file denoted by s */
int WriteConfig(char *s)
{
	FILE *Config;
	int i;

	/* try up to 10 times because somone else might be looking at the file */
	for (i=0;i<10;++i)
	{
		if 	(Config = fopen(s,"w"))
			break;
		Delay(25L);
	}
	
	/* no success? */
	if (!Config)
		return(FALSE);

	if (*MailEditor)
		fprintf(Config,"MailEditor\t%s\n",MailEditor);

	if (*RFilter)
		fprintf(Config,"RFilter\t%s\n",RFilter);

	if (*Signature)
		fprintf(Config,"Signature\t%s\n",Signature);

	if (*AMPubScreen)
		fprintf(Config,"AMPubScreen\t%s\n",AMPubScreen);

	fprintf(Config,"AMCTE\t%d\n",AMCTE);

	if (*ReplyTo)
		fprintf(Config,"ReplyTo\t%s\n",ReplyTo);

	if (AMDisplayID)
		fprintf(Config,"AMDisplayID\t0x%08lx\n",AMDisplayID);

	if (*AMFont.ta_Name)
		fprintf(Config,"AMFont\t%s %d %d %d\n",
			AMFont.ta_Name,AMFont.ta_YSize,
			(int)AMFont.ta_Style,(int)AMFont.ta_Flags);

	if (AMColors[0])
	{
		fprintf(Config,"AMColors\t0x%04hx ",AMColors[1]);
		for (i=1;i<AMColors[0];++i)
			fprintf(Config,"0x%04hx ",AMColors[i+1]);
		putc('\n',Config);
	}

	fclose(Config);
	
	return(TRUE);
}
