vsftpd 3.0.2
[tomato.git] / release / src / router / vsftpd / utility.c
blob5fd714da088e0708720a57860f6ea5009a9533fa
1 /*
2 * Part of Very Secure FTPd
3 * Licence: GPL v2
4 * Author: Chris Evans
5 * utility.c
6 */
8 #include "utility.h"
9 #include "sysutil.h"
10 #include "str.h"
11 #include "defs.h"
13 #define DIE_DEBUG
15 void
16 die(const char* p_text)
18 #ifdef DIE_DEBUG
19 bug(p_text);
20 #endif
21 vsf_sysutil_exit(2);
24 void
25 die2(const char* p_text1, const char* p_text2)
27 struct mystr die_str = INIT_MYSTR;
28 str_alloc_text(&die_str, p_text1);
29 if (p_text2)
31 str_append_text(&die_str, p_text2);
33 else
35 str_append_text(&die_str, "(null)");
37 die(str_getbuf(&die_str));
40 void
41 bug(const char* p_text)
43 /* Rats. Try and write the reason to the network for diagnostics */
44 vsf_sysutil_activate_noblock(VSFTP_COMMAND_FD);
45 (void) vsf_sysutil_write_loop(VSFTP_COMMAND_FD, "500 OOPS: ", 10);
46 (void) vsf_sysutil_write_loop(VSFTP_COMMAND_FD, p_text,
47 vsf_sysutil_strlen(p_text));
48 (void) vsf_sysutil_write_loop(VSFTP_COMMAND_FD, "\r\n", 2);
49 vsf_sysutil_exit(2);
52 void
53 vsf_exit(const char* p_text)
55 (void) vsf_sysutil_write_loop(VSFTP_COMMAND_FD, p_text,
56 vsf_sysutil_strlen(p_text));
57 vsf_sysutil_exit(0);