Esempio n. 1
0
int switchResp(struct text * text) {

	switch((int)text->txt_type) {
		case TXT_ERROR:
			return recvError((struct text_error *) text);
		case TXT_LIST:
			return recvList((struct text_list *) text);
		case TXT_WHO:
			return recvWho((struct text_who *) text);
		case TXT_SAY:
			return recvSay((struct text_say *) text);
		default:
			printError("Unknown response type received\n");
			return false;
	}
}
void
ProtocolDataTransfer::run()
{
        switch (m_SocketMode)
        {
        case Slave:
                if (accept() == -1)
                {
                        return;
                }
                break;
        case Active:
                if (connectTo() == -1)
                {
                        return;
                }
                break;
        default:
                return;
        }

        switch (m_Protocol)
        {
        case DoSendFile:
                sendFile();
                break;
        case DoRecvFile:
                recvFile();
                break;
        case DoSendDir:
                sendDir();
                break;
        case DoRecvDir:
                recvDir();
                break;
        case DoSendList:
                sendList();
                break;
        case DoRecvList:
                recvList();
                break;
        }
}