-static void send_packet(SilcBuffer packet, void *context)
-{
- Client client = (Client)context;
- SilcSocketConnection sock = client->sock;
- SilcPacketContext packetdata;
- const SilcBufferStruct p;
- int ret;
-
- memset(&packetdata, 0, sizeof(packetdata));
- packetdata.type = SILC_PACKET_FTP;
- packetdata.truelen = packet->len + SILC_PACKET_HEADER_LEN;
- SILC_PACKET_PADLEN(packetdata.truelen, 0, packetdata.padlen);
- silc_packet_assemble(&packetdata, NULL, NULL, NULL, sock,
- packet->data, packet->len, (const SilcBuffer)&p);
- ret = silc_packet_send(sock, TRUE);
- if (ret != -2)
- return;
-
- silc_schedule_set_listen_fd(client->schedule, sock->sock,
- (SILC_TASK_READ | SILC_TASK_WRITE), FALSE);
- SILC_SET_OUTBUF_PENDING(sock);
-}
-
-static bool packet_parse(SilcPacketParserContext *parser, void *context)
-{
- Client client = (Client)parser->context;
- SilcSocketConnection sock = parser->sock;
- SilcPacketContext *packet = parser->packet;
- int ret;
-
- ret = silc_packet_parse(packet, NULL);
- assert(packet->type == SILC_PACKET_FTP);
-
- silc_sftp_client_receive_process(client->sftp, sock, packet);
-
- return TRUE;
-}
-
-SILC_TASK_CALLBACK(packet_process)
-{
- Client client = (Client)context;
- SilcSocketConnection sock = client->sock;
- int ret;
-
- if (type == SILC_TASK_WRITE) {
- if (sock->outbuf->data - sock->outbuf->head)
- silc_buffer_push(sock->outbuf, sock->outbuf->data - sock->outbuf->head);
-
- ret = silc_packet_send(sock, TRUE);
- if (ret < 0)
- return;
-
- silc_schedule_set_listen_fd(client->schedule, fd, SILC_TASK_READ, FALSE);
- SILC_UNSET_OUTBUF_PENDING(sock);
- silc_buffer_clear(sock->outbuf);
- return;
-
- }
-
- if (type == SILC_TASK_READ) {
- ret = silc_packet_receive(sock);
- if (ret < 0)
- return;
-
- if (ret == 0) {
- silc_net_close_connection(sock->sock);
- silc_socket_free(sock);
- exit(0);
- }
-
- silc_packet_receive_process(sock, FALSE, NULL, NULL, 0,
- packet_parse, client);
- }
-}
-