
#include "k.h"

/*
 * VAX/VMS Kermit.  Modified from the UNIX C Kermit files CK* on MARKET
 * by Todd Little on 24-APR-83.  Added server mode and removed connect
 * command.
*/

main()
{
	int i;
	char command[50], *rtty = "/dev/ttyx";

/* length of file name string */
	file_name.dsc$w_length = strlen(filnam);
/* address of file name string */
	file_name.dsc$a_pointer = filnam;
	result_name.dsc$a_pointer = 0;
/* set up class and type */
	file_name.dsc$b_class = DSC$K_CLASS_S;
	file_name.dsc$b_dtype = DSC$K_DTYPE_T;
	result_name.dsc$b_class = DSC$K_CLASS_D;
	result_name.dsc$b_dtype = DSC$K_DTYPE_T;
/* indicate no fab allocated yet */
	fabp = 0;

	printf("Kermit VAX/VMS\n\n");
	remfd = open("SYS$OUTPUT:",2);
/*	printf("remfd = %d\n",remfd);	*/

	while (!feof(stdin))
	{
		printf("Kermit VMS>");
		scanf("%s",command);

		noecho(1);
		switch(toupper(command[0]))
		{
/*			case 'C':	connect();		*/	        /* connect */
/*						break;		*/

			case 'A':
#if debug
					fprintf(stderr,"Entering server mode\n");
#endif
						n=0;
						server();
						break;

			case 'S':	scanf("%s",filnam);
						i=0;
						while (filnam[i] != '\0') {
							filnam[i] = toupper(filnam[i]);
							i = i+1; }
						printf("Kermit will send file %s\n",filnam);
						n = 0;
						if (sendsw() == FALSE)
							printf("Sending failed.\n");
						else
							printf("Sending succeeded.\n");
						break;
			
			case 'R':	n = 0;
						if (recsw('R') == FALSE)
							printf("Receive failed.\n");
						else
							printf("Receive succeeded.\n");
						break;
			
			case 'E':	exit();

			case '?':
			case 'H':	printf("\nCommands available for VAX/VMS Kermit\n");
					printf("\nA - place kermit into server mode");
					printf("\nS - sends the specified file");
					printf("\nR - receive whatever file is sent");
					printf("\nE - exit kermit\n\n");
					break;

			default:	if (!feof(stdin)) printf("Unrecognized command, try ? for help\n");
		}
		noecho(0);
	}
	noecho(0);
}
