]> git.sesse.net Git - betaftpd/blob - cmds.h
process_all_clients(): Fixed a bug (reporting and much tracing by Sean MacLennan...
[betaftpd] / cmds.h
1 /*  cmds.c: BetaFTPD command handler prototypes
2     Copyright (C) 1999-2000 Steinar H. Gunderson
3
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.
7
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.
12
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.
16 */
17
18 /*
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.
24  *
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').
29  *
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
32  *              security risk.
33  */
34 #undef TRAP_ERROR_DEBUG
35 /* #define TRAP_ERROR_DEBUG 1 */
36
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) \
40         if (x) { \
41                 numeric(c, num, "%s (%s:%d)", strerror(errno), fl, ln); \
42                 y; \
43         }
44 #else
45 #define TRAP_ERROR(x, num, y) \
46         if (x) { \
47                 numeric(c, num, strerror(errno)); \
48                 y; \
49         }
50 #endif
51
52 #define CMD_PROTO(cmd) int cmd_ ## cmd ## (struct conn * const c)
53
54 int do_chdir(struct conn * const c, const char * const newd);
55 CMD_PROTO(user);
56 CMD_PROTO(pass);
57 CMD_PROTO(acct);
58 CMD_PROTO(port);
59 CMD_PROTO(pasv);
60 CMD_PROTO(pwd);
61 CMD_PROTO(cwd);
62 CMD_PROTO(cdup);
63 CMD_PROTO(rest);
64 CMD_PROTO(retr);
65 CMD_PROTO(size);
66 CMD_PROTO(mdtm);
67 CMD_PROTO(abor);
68 CMD_PROTO(dele);
69 CMD_PROTO(rnfr);
70 CMD_PROTO(rnto);
71 CMD_PROTO(mkd);
72 CMD_PROTO(rmd);
73 CMD_PROTO(allo);
74 CMD_PROTO(stat);
75 CMD_PROTO(list);
76 CMD_PROTO(nlst);
77 CMD_PROTO(syst);
78 CMD_PROTO(noop);
79 CMD_PROTO(type);
80 CMD_PROTO(mode);
81 CMD_PROTO(stru);
82 CMD_PROTO(help);
83 CMD_PROTO(quit);
84 CMD_PROTO(rein);
85
86 #if WANT_UPLOAD
87 CMD_PROTO(stor);
88 CMD_PROTO(appe);
89 #endif
90
91 #if DOING_PROFILING
92 CMD_PROTO(exit);        
93 #endif
94
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
102 #if WANT_NONROOT
103                 , const int check_permission
104 #endif
105 );
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 void list_core(struct conn * const c, const char * const pathname,
112                struct list_options * const lo
113 #if HAVE_MMAP
114                 , const int size
115 #endif
116 );
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);
120