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).
11
#include "dirchange.h"
22
#define VSFTP_MAX_VISIT_REMEMBER 100
23
#define VSFTP_MAX_MSGFILE_SIZE 1000
26
dir_changed(struct vsf_session* p_sess, int ftpcode)
28
struct mystr dir_str = INIT_MYSTR;
29
/* Do nothing if .message support is off */
30
if (!tunable_dirmessage_enable)
34
if (p_sess->p_visited_dir_list == 0)
36
struct mystr_list the_list = INIT_STRLIST;
37
p_sess->p_visited_dir_list = vsf_sysutil_malloc(sizeof(struct mystr_list));
38
*p_sess->p_visited_dir_list = the_list;
41
/* Do nothing if we already visited this directory */
42
if (!str_list_contains_str(p_sess->p_visited_dir_list, &dir_str))
44
/* Just in case, cap the max. no of visited directories we'll remember */
45
if (str_list_get_length(p_sess->p_visited_dir_list) <
46
VSFTP_MAX_VISIT_REMEMBER)
48
str_list_add(p_sess->p_visited_dir_list, &dir_str, 0);
50
/* If we have a .message file, squirt it out prepended by the ftpcode and
51
* the continuation mark '-'
54
struct mystr msg_file_str = INIT_MYSTR;
55
struct mystr msg_line_str = INIT_MYSTR;
56
unsigned int str_pos = 0;
57
(void) str_fileread(&msg_file_str, tunable_message_file,
58
VSFTP_MAX_MSGFILE_SIZE);
59
while (str_getline(&msg_file_str, &msg_line_str, &str_pos))
61
vsf_cmdio_write_str_hyphen(p_sess, ftpcode, &msg_line_str);
63
str_free(&msg_file_str);
64
str_free(&msg_line_str);