1 /* cmds.c: BetaFTPD command handler prototypes
2 Copyright (C) 1999-2000 Steinar H. Gunderson
4 This program is is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2 of the
6 License as published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * TRAP_ERROR: This is a quick way of doing a test for an error condition.
25 * if an error occurs (or more precisely, if the value supplied is
26 * true), an error message is sent back to the client. This is _not_
27 * a debugging macro. The condition is allowed to have side effects,
28 * and is only evaluated once.
30 * The second argument is the FTP error code to send back, in case
31 * of an error (the error message itself will be supplied by the
32 * system). The third argument is code to execute after the FTP error
33 * has been sent (typically `return' or `return -1').
35 * If TRAP_ERROR_DEBUG is defined, some extra debugging info is
36 * sent. Don't enable this for a normal server, it could be a
39 #undef TRAP_ERROR_DEBUG
40 /* #define TRAP_ERROR_DEBUG 1 */
42 #ifdef TRAP_ERROR_DEBUG
43 #define TRAP_ERROR(x, num, y) TRAP_ERROR_INTERNAL(x, num, y, __FILE__, __LINE__)
44 #define TRAP_ERROR_INTERNAL(x, num, y, fl, ln) \
46 numeric(c, num, "%s (%s:%d)", strerror(errno), fl, ln); \
50 #define TRAP_ERROR(x, num, y) \
52 numeric(c, num, strerror(errno)); \
57 #define CMD_PROTO(cmd) int cmd_ ## cmd ## (struct conn * const c)
59 int do_chdir(struct conn * const c, const char * const newd);
100 void cmd_cwd_internal(struct conn * const c, const char * const newd);
101 void parse_command(struct conn *c);
102 void prepare_for_transfer(struct ftran *f);
103 char decode_mode(mode_t mode);
104 char *translate_path(struct conn * const c, char * const path);
105 int do_openfile(struct conn * const c, char * const path,
106 char * const filename, const int flags
108 , const int check_permission
111 int prepare_for_listing(struct conn * const c, char ** const ptr,
112 struct list_options * const lo);
113 void do_listing(struct conn * const c, struct list_options * const lo);
114 int get_num_files(struct conn * const c, const char * const pathname,
115 struct list_options * const lo);
116 int list_core(struct conn * const c, const char * const pathname,
117 char * const disp_pathname, struct list_options * const lo
119 , const int size, int pos
122 char classify(const mode_t mode);
123 void do_store(struct conn * const c, int append);
124 char *do_pwd(struct conn * const c, char * const retbuf, const char * const dir);
128 * Even on select()-only systems, we use some poll() constants, so
129 * we'll have to make them up if we don't already have them. These
130 * are taken from my glibc 2.1 system.
133 #define POLLOUT 0x004