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 if 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.
19 * TRAP_ERROR: This is a quick way of doing a test for an error condition.
20 * if an error occurs (or more precisely, if the value supplied is
21 * true), an error message is sent back to the client. This is _not_
22 * a debugging macro. The condition is allowed to have side effects,
23 * and is only evaluated once.
25 * The second argument is the FTP error code to send back, in case
26 * of an error (the error message itself will be supplied by the
27 * system). The third argument is code to execute after the FTP error
28 * has been sent (typically `return' or `return -1').
30 * If TRAP_ERROR_DEBUG is defined, some extra debugging info is
31 * sent. Don't enable this for a normal server, it could be a
34 #undef TRAP_ERROR_DEBUG
35 /* #define TRAP_ERROR_DEBUG 1 */
37 #ifdef TRAP_ERROR_DEBUG
38 #define TRAP_ERROR(x, num, y) TRAP_ERROR_INTERNAL(x, num, y, __FILE__, __LINE__)
39 #define TRAP_ERROR_INTERNAL(x, num, y, fl, ln) \
41 numeric(c, num, "%s (%s:%d)", strerror(errno), fl, ln); \
45 #define TRAP_ERROR(x, num, y) \
47 numeric(c, num, strerror(errno)); \
52 #define CMD_PROTO(cmd) int cmd_ ## cmd ## (struct conn * const c)
54 int do_chdir(struct conn * const c, const char * const newd);
95 void cmd_cwd_internal(struct conn * const c, const char * const newd);
96 void parse_command(struct conn *c);
97 void prepare_for_transfer(struct ftran *f);
98 char decode_mode(mode_t mode);
99 char *translate_path(struct conn * const c, char * const path);
100 int do_openfile(struct conn * const c, char * const path,
101 char * const filename, const int flags
103 , const int check_permission
106 int prepare_for_listing(struct conn * const c, char ** const ptr,
107 struct list_options * const lo);
108 void do_listing(struct conn * const c, struct list_options * const lo);
109 int get_num_files(struct conn * const c, const char * const pathname,
110 struct list_options * const lo);
111 int list_core(struct conn * const c, const char * const pathname,
112 char * const disp_pathname, struct list_options * const lo
114 , const int size, int pos
117 char classify(const mode_t mode);
118 void do_store(struct conn * const c, int append);
119 char *do_pwd(struct conn * const c, char * const retbuf, const char * const dir);
123 * Even on select()-only systems, we use some poll() constants, so
124 * we'll have to make them up if we don't already have them. These
125 * are taken from my glibc 2.1 system.
128 #define POLLOUT 0x004