printf("501 5.5.4 Syntax error in parameters\r\n"); continue; } printf("250 2.5.0 ok\r\n");
mailerr("501 5.5.4", "Syntax error in parameters"); continue; } printf("250 2.5.0 Ok\r\n");
dolmtp(bouncequota)	bool bouncequota;{	char *return_path = NULL;	char **rcpt_addr = NULL;	int rcpt_num = 0;	int rcpt_alloc = 0;	bool gotlhlo = FALSE;	char *err;	int msgfd;	char *p;	int i;	char myhostname[1024];	char buf[4096];	(void) gethostname(myhostname, sizeof myhostname - 1);	printf("220 %s LMTP ready\r\n", myhostname);	for (;;)	{		(void) fflush(stdout);		if (fgets(buf, sizeof(buf) - 1, stdin) == NULL)			exit(EX_OK);		p = buf + strlen(buf) - 1;		if (p >= buf && *p == '\n')			*p-- = '\0';		if (p >= buf && *p == '\r')			*p-- = '\0';		switch (buf[0])		{		  case 'd':		  case 'D':			if (strcasecmp(buf, "data") == 0)			{				if (rcpt_num == 0)				{					printf("503 5.5.1 No recipients\r\n");					continue;				}				msgfd = store(return_path, rcpt_num);				if (msgfd == -1)					continue;				for (i = 0; i < rcpt_num; i++)				{					p = strchr(rcpt_addr[i], '+');					if (p != NULL)						*p++ = '\0';					deliver(msgfd, rcpt_addr[i],						bouncequota);				}				(void) close(msgfd);				goto rset;			}			goto syntaxerr;			/* NOTREACHED */			break;		  case 'l':		  case 'L':			if (strncasecmp(buf, "lhlo ", 5) == 0)			{				/* check for duplicate per RFC 1651 4.2 */				if (gotlhlo)				{					printf("503 %s Duplicate LHLO\r\n",					       myhostname);					continue;				}				gotlhlo = TRUE;				printf("250-%s\r\n", myhostname);				if (EightBitMime)					printf("250-8BITMIME\r\n");				printf("250-ENHANCEDSTATUSCODES\r\n");				printf("250 PIPELINING\r\n");				continue;			}			goto syntaxerr;			/* NOTREACHED */			break;		  case 'm':		  case 'M':			if (strncasecmp(buf, "mail ", 5) == 0)			{				if (return_path != NULL)				{					printf("503 5.5.1 Nested MAIL command\r\n");					continue;				}				if (strncasecmp(buf+5, "from:", 5) != 0 ||				    ((return_path = parseaddr(buf + 10,							      FALSE)) == NULL))				{					printf("501 5.5.4 Syntax error in parameters\r\n");					continue;				}				printf("250 2.5.0 ok\r\n");				continue;			}			goto syntaxerr;			/* NOTREACHED */			break;		  case 'n':		  case 'N':			if (strcasecmp(buf, "noop") == 0)			{				printf("250 2.0.0 ok\r\n");				continue;			}			goto syntaxerr;			/* NOTREACHED */			break;		  case 'q':		  case 'Q':			if (strcasecmp(buf, "quit") == 0)			{				printf("221 2.0.0 bye\r\n");				exit(EX_OK);			}			goto syntaxerr;			/* NOTREACHED */			break;		  case 'r':		  case 'R':			if (strncasecmp(buf, "rcpt ", 5) == 0)			{				if (return_path == NULL)				{					printf("503 5.5.1 Need MAIL command\r\n");					continue;				}				if (rcpt_num >= rcpt_alloc)				{					rcpt_alloc += RCPT_GROW;					rcpt_addr = (char **)						REALLOC((char *) rcpt_addr,							rcpt_alloc *							sizeof(char **));					if (rcpt_addr == NULL)					{						printf("421 4.3.0 memory exhausted\r\n");						exit(EX_TEMPFAIL);					}				}				if (strncasecmp(buf + 5, "to:", 3) != 0 ||				    ((rcpt_addr[rcpt_num] = parseaddr(buf + 8,								      TRUE)) == NULL))				{					printf("501 5.5.4 Syntax error in parameters\r\n");					continue;				}				if ((err = process_recipient(rcpt_addr[rcpt_num])) != NULL)				{					printf("%s\r\n", err);					continue;				}				rcpt_num++;				printf("250 2.1.5 ok\r\n");				continue;			}			else if (strcasecmp(buf, "rset") == 0)			{				printf("250 2.0.0 ok\r\n");rset:				while (rcpt_num > 0)					free(rcpt_addr[--rcpt_num]);				if (return_path != NULL)					free(return_path);				return_path = NULL;				continue;			}			goto syntaxerr;			/* NOTREACHED */			break;		  case 'v':		  case 'V':			if (strncasecmp(buf, "vrfy ", 5) == 0)			{				printf("252 2.3.3 try RCPT to attempt delivery\r\n");				continue;			}			goto syntaxerr;			/* NOTREACHED */			break;		  default:  syntaxerr:			printf("500 5.5.2 Syntax error\r\n");			continue;			/* NOTREACHED */			break;		}	}}