1 /*
2  * ProFTPD - FTP server daemon
3  * Copyright (c) 2001-2020 The ProFTPD Project team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  *
19  * As a special exemption, The ProFTPD Project team and other respective
20  * copyright holders give permission to link this program with OpenSSL, and
21  * distribute the resulting executable, without including the source code for
22  * OpenSSL in the source distribution.
23  */
24 
25 /* Command response routines */
26 
27 #ifndef PR_RESPONSE_H
28 #define PR_RESPONSE_H
29 
30 /* Response structure */
31 
32 typedef struct resp_struc {
33   struct resp_struc *next;
34   const char *num;
35   const char *msg;
36 } pr_response_t;
37 
38 /* Utilize gcc's __attribute__ pragma for signalling that it should perform
39  * printf-style checking of this function's arguments.
40  */
41 
42 void pr_response_add(const char *, const char *, ...)
43 #ifdef __GNUC__
44        __attribute__ ((format (printf, 2, 3)));
45 #else
46        ;
47 #endif
48 
49 void pr_response_add_err(const char *, const char *, ...)
50 #ifdef __GNUC__
51        __attribute__ ((format (printf, 2, 3)));
52 #else
53        ;
54 #endif
55 
56 int pr_response_block(int);
57 
58 /* Returns TRUE or FALSE, indicating whether responses have been previously
59  * blocked via pr_response_block().
60  */
61 int pr_response_blocked(void);
62 
63 void pr_response_clear(pr_response_t **);
64 void pr_response_flush(pr_response_t **);
65 
66 /* Retrieves the response code and response message from the last response
67  * sent/added for flushing to the client.  The strings for the values are
68  * allocated out of the given pool.
69  */
70 int pr_response_get_last(pool *, const char **resp_code,
71   const char **response_msg);
72 
73 void pr_response_send(const char *, const char *, ...)
74 #ifdef __GNUC__
75        __attribute__ ((format (printf, 2, 3)));
76 #else
77        ;
78 #endif
79 
80 void pr_response_send_async(const char *, const char *, ...)
81 #ifdef __GNUC__
82        __attribute__ ((format (printf, 2, 3)));
83 #else
84        ;
85 #endif
86 
87 void pr_response_send_raw(const char *, ...)
88 #ifdef __GNUC__
89        __attribute__ ((format (printf, 1, 2)));
90 #else
91        ;
92 #endif
93 
94 /* Set a callback pointer to a function that can handle/adjust a response
95  * line, before that response is sent to the client.  If no callback is
96  * configured, the line will be sent as is.
97  */
98 void pr_response_register_handler(char *(*)(pool *, const char *, ...));
99 
100 /* Get the pool currently used for response lists. */
101 pool *pr_response_get_pool(void);
102 
103 /* Set the pool used for the response lists. */
104 void pr_response_set_pool(pool *);
105 
106 #endif /* PR_RESPONSE_H */
107