/*
 *	Copyright (C) 1986  SRI International
 *	Copyright (C) 1989  TGV, Incorporated
 *
 *	Ask the user various questions and set up the MM INIT file
 *
 */
#include "vax-mm.h"

static int Yes();
/*
 *	Ask the questions and create MM init file
 */
CMD_Profile()
{

	/*
	 *	Confirm
	 */
	Confirm();
	/*
	 *	Do the dialog
	 */
	Reply_Include_Me =
	  Yes("Do you want to receive copies of your replies to messages? ") ?
		1 : 0;
	printf(
"Normally, when you REPLY to or ANSWER a message, the reply will\n\
default to only sending to the person you got the message from.\n\
You can have MM default instead to replying to everybody listed in\n\
the message header.\n");
	Reply_Sender_Only_Default =
	  Yes("Do you want REPLY to default to everybody? ") ?
		0 : -1;
	Do_Blank_Screen =
	  Yes("Do you want to erase the screen at startup and between messages? ") ?
		-1 : 0;
	printf(
"Normally the abort command control-N asks for confirmation before\n\
aborting.\n");
	Control_N_Abort =
	  Yes("Do you want control-N to abort without asking? ") ?
		1 : 0;
	printf(
"Other profile options may be set by using the SET command to set the\n\
option, and CREATE-INIT to update your MM.INIT profile file.  You may\n\
also edit MM.INIT with an editor.  Use the \"HELP SET variable-name\"\n\
command for a desriptions of individual MM.INIT options, and the SHOW\n\
command to list the complete environment.\n");
	/*
	 *	Create the new init file
	 */
	Setup_String_Parse(""); /* So CREATE-INIT will see confirmation */
	CMD_Create_Init();
}


static int Yes(Prompt)
char *Prompt;
{
	static struct {
		int current_entries;
		int maximum_entries;
		struct tbluk_keyword keywords[2];
		} Table = {
			2,
			2,
			{{0,	"no",	0},
			 {0,	"yes",	1}}};
	static struct comnd_function Responses =
		{COMND_KEYWORD,
		 COMND_HELP_VALID|COMND_SUPPRESS_DEFAULT_HELP,
		 0,
		 (int)&Table,
		 "YES or NO"};
	struct tbluk_keyword *t;

	/*
	 *	Set the prompt
	 */
	Command_State.prompt = Prompt;
	/*
	 *	Get the response
	 */
	while(1) {
		COMND_INIT(&Command_State);
		if (COMND(&Command_State,&Responses,&t,0) >= 0) {
			/*
			 *	Confirm the YES or NO
			 */
			Confirm();
			/*
			 *	Return the data field (YES = 1, NO = 0)
			 */
			return(t->user_data);
		}
	}
}

