-
Notifications
You must be signed in to change notification settings - Fork 3
/
FTPD_cmd.cc
85 lines (74 loc) · 1.57 KB
/
FTPD_cmd.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// Copyright 2009-2016 M. Shulhan (ms@kilabit.info). All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "FTPD_cmd.hh"
namespace vos {
const char* FTPD_cmd::__cname = "FTPD_cmd";
FTPD_cmd::FTPD_cmd() :
_code(0)
, _name()
, _parm()
, _callback(NULL)
{}
FTPD_cmd::~FTPD_cmd()
{
reset();
}
/**
* @method : FTPD_cmd::reset
* @desc : reset all attribute.
*/
void FTPD_cmd::reset()
{
_code = 0;
_name.reset();
_parm.reset();
_callback = 0;
}
/**
* @method : FTPD_cmd::set
* @param :
* > cmd : pointer to FTPD_cmd object.
* @desc : set content of this object using data from 'cmd' object.
*/
void FTPD_cmd::set(FTPD_cmd *cmd)
{
_code = cmd->_code;
_name.copy(&cmd->_name);
_parm.copy(&cmd->_parm);
_callback = cmd->_callback;
}
/**
* @method : FTPD_cmd::dump
* @desc : Dump content of FTPD_cmd object.
*/
void FTPD_cmd::dump()
{
printf( "[vos::FTPD_cmd__] dump:\n"
" command : %s\n"
" parameter : %s\n", _name.chars(), _parm.chars());
}
/**
* @method : FTPD_cmd::INIT
* @param :
* > name : name of new command.
* @return : pointer to function.
* < !NULL : success, pointer to new FTPD_cmd object.
* < NULL : fail.
* @desc : Create and initialize a new FTPD_cmd object.
*/
FTPD_cmd* FTPD_cmd::INIT(const int code, const char* name
, void (*callback)(const void*, const void*))
{
FTPD_cmd* cmd = new FTPD_cmd();
if (cmd) {
cmd->_code = code;
cmd->_callback = callback;
cmd->_name.copy_raw(name);
}
return cmd;
}
} /* namespace::vos */
// vi: ts=8 sw=8 tw=78: