if (buffer[0] == ACK && buffer[1] == 0x02) { sprintf(Message, "SendData  %5d bytes transmitted", total); Write_Status(Message); outlen = read(filefd, outbuffer, readlen); outbufptr = 0;
state = STATE_SD; break; }
static int yapp_upload_data(int filefd, char *filename, int filelength, unsigned char *buffer){	char Message[80];		if (buffer[0] == CAN || buffer[0] == NAK)	{		Write_Status("RcvABORT");		return(FALSE);	}	switch (state)	{		case STATE_S:			if (buffer[0] == ACK && buffer[1] == 0x01)			{				Write_Status("SendHeader");				Send_HD(filename, filelength);				state = STATE_SH;				break;			}			if (buffer[0] == ACK && buffer[1] == 0x02)			{				sprintf(Message, "SendData  %5d bytes transmitted", total);				Write_Status(Message);				outlen = read(filefd, outbuffer, readlen);				outbufptr = 0;				if (outlen) Send_DT(outlen);				if (yappc)				{					outbuffer[outlen] = checksum(outbuffer, outlen);					outlen++;				}				state = STATE_SD;				break;			}			Send_CN("Unknown code");			Write_Status("SndABORT");			return(FALSE);							case STATE_SH:		/* Could get three replies here:		 * ACK 02 : normal acknowledge.		 * ACK ACK: yappc acknowledge.		 * NAK ...: resume request.		 */			if (buffer[0] == NAK && buffer[2] == 'R')			{				int len;				off_t rpos;				len = buffer[1];				if (buffer[len] == 'C') yappc=1;				rpos = atol((char *)buffer + 4);				lseek(filefd, rpos, SEEK_SET);				buffer[0] = ACK;				buffer[1] = yappc ? ACK : 0x02;			}			if (buffer[0] == ACK && 				(buffer[1] == 0x02 || buffer[1] == ACK))			{				if (buffer[1] == ACK) yappc = 1;				sprintf(Message, "SendData  %5d bytes transmitted", total);				Write_Status(Message);				outlen = read(filefd, outbuffer, readlen);				outbufptr = 0;				if (outlen) Send_DT(outlen);				state = STATE_SD;								if (yappc)				{					outbuffer[outlen] = checksum(outbuffer, outlen);					outlen++;				}				break;			}			Send_CN("Unknown code");			Write_Status("SndABORT");			return(FALSE);												case STATE_SD:			Send_CN("Unknown code");			Write_Status("SndABORT");			return(FALSE);							case STATE_SE:			if (buffer[0] == ACK && buffer[1] == 0x03)			{				Write_Status("SendEOT");				Send_ET();				state = STATE_ST;				break;			}			Send_CN("Unknown code");			Write_Status("SndABORT");			return(FALSE);							case STATE_ST:			if (buffer[0] == ACK && buffer[1] == 0x04)			{				return(FALSE);			}			Send_CN("Unknown code");			Write_Status("SndABORT");			return(FALSE);	}	return(TRUE);}