Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / vsftpd / banner.c
blobbc662d0a48a3a7064855e4e837a005feb1064467
1 /*
2 * Part of Very Secure FTPd
3 * Licence: GPL v2
4 * Author: Chris Evans
5 * banner.c
7 * Calls exposed to handle the junk a typical FTP server has to do upon
8 * entering a new directory (messages, etc), as well as general banner
9 * writing support.
12 #include "banner.h"
13 #include "strlist.h"
14 #include "str.h"
15 #include "sysstr.h"
16 #include "tunables.h"
17 #include "ftpcmdio.h"
18 #include "filestr.h"
19 #include "session.h"
20 #include "sysutil.h"
22 /* Definitions */
23 #define VSFTP_MAX_VISIT_REMEMBER 100
24 #define VSFTP_MAX_MSGFILE_SIZE 4000
26 void
27 vsf_banner_dir_changed(struct vsf_session* p_sess, int ftpcode)
29 struct mystr dir_str = INIT_MYSTR;
30 /* Do nothing if .message support is off */
31 if (!tunable_dirmessage_enable)
33 return;
35 if (p_sess->p_visited_dir_list == 0)
37 struct mystr_list the_list = INIT_STRLIST;
38 p_sess->p_visited_dir_list = vsf_sysutil_malloc(sizeof(struct mystr_list));
39 *p_sess->p_visited_dir_list = the_list;
41 str_getcwd(&dir_str);
42 /* Do nothing if we already visited this directory */
43 if (!str_list_contains_str(p_sess->p_visited_dir_list, &dir_str))
45 /* Just in case, cap the max. no of visited directories we'll remember */
46 if (str_list_get_length(p_sess->p_visited_dir_list) <
47 VSFTP_MAX_VISIT_REMEMBER)
49 str_list_add(p_sess->p_visited_dir_list, &dir_str, 0);
51 /* If we have a .message file, squirt it out prepended by the ftpcode and
52 * the continuation mark '-'
55 struct mystr msg_file_str = INIT_MYSTR;
56 (void) str_fileread(&msg_file_str, tunable_message_file,
57 VSFTP_MAX_MSGFILE_SIZE);
58 vsf_banner_write(p_sess, &msg_file_str, ftpcode);
59 str_free(&msg_file_str);
62 str_free(&dir_str);
65 void
66 vsf_banner_write(struct vsf_session* p_sess, struct mystr* p_str, int ftpcode)
68 struct mystr msg_line_str = INIT_MYSTR;
69 unsigned int str_pos = 0;
70 while (str_getline(p_str, &msg_line_str, &str_pos))
72 vsf_cmdio_write_str_hyphen(p_sess, ftpcode, &msg_line_str);
74 str_free(&msg_line_str);