2 * Part of Very Secure FTPd
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
23 #define VSFTP_MAX_VISIT_REMEMBER 100
24 #define VSFTP_MAX_MSGFILE_SIZE 4000
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
)
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
;
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
);
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
);