Renamed session structure.
[uftps.git] / next_command.c
blobe412dc46cbc5e295209bb98edb93940c1687ae5c
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
19 #include "uftps.h"
22 * Return the next command (as an integer) available in the control channel.
24 * Most of this implementation has been inspired by str_netfd_alloc() from
25 * netstr.c of VsFTPd.
28 #include "command_parser.h"
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <unistd.h>
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <ctype.h>
37 enum command next_command (void)
39 const struct Cmd *cmd;
40 int i;
42 read_request();
44 i = 0;
45 while (SS.input[i] != ' ' && SS.input[i] != '\0')
47 SS.input[i] = toupper(SS.input[i] & 0x07F);
48 i++;
51 SS.arg = (SS.input[i] == ' ' ? SS.input + i + 1 : NULL);
52 SS.input[i] = '\0';
54 cmd = parse_command(SS.input, i);
55 if (cmd == NULL)
56 return FTP_NONE;
57 return cmd->value;