Solaris compilation fixes.
[uftps.git] / reply.c
blob1b01fbe7894b387490bffbb653016bb20135b024
1 /*
2 * User FTP Server, Share folders over FTP without being root.
3 * Copyright (C) 2008 Isaac Jurado
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option) any later
8 * version.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "uftps.h"
21 #ifndef __MINGW32__
22 # include <sys/socket.h>
23 #endif
27 * Send a reply to the client over the control connection. Not a complex
28 * function at all, but necessary almost everywhere else.
30 void reply (const char *str, int len)
32 int b;
34 debug("Reply : %.*s", len - 2, str);
36 do {
37 b = send(SS.control_sk, str, len, 0);
38 if (b == -1)
39 fatal("Control channel output");
41 str += b;
42 len -= b;
43 } while (len > 0);
48 * Send reply over the current data connection. It succeeds (return value 0)
49 * when all data has been transferred. It fails otherwise (return value -1),
50 * that is, either by an incomplete transfer or a system error.
52 int data_reply (const char *data, int len)
54 int b, l = 0;
56 while (l < len)
58 b = send(SS.data_sk, &data[l], len - l, 0);
59 if (b <= 0)
61 error("Sending listing data");
62 return -1;
65 l += b;
68 return 0;