|
@@ -32,6 +32,7 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
|
execmap["putdata"] = &CmdMan::cmdPutdata;
|
|
|
execmap["getdata"] = &CmdMan::cmdGetdata;
|
|
|
execmap["listdata"] = &CmdMan::cmdListdata;
|
|
|
+ execmap["head"] = &CmdMan::cmdHead;
|
|
|
|
|
|
/* initialize description map */
|
|
|
helpmap["help"] = descHelp;
|
|
@@ -40,6 +41,9 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
|
helpmap["put"] = descPut;
|
|
|
helpmap["get"] = descGet;
|
|
|
helpmap["list"] = descList;
|
|
|
+ helpmap["head"] = descHead;
|
|
|
+ helpmap["login"] = descLogin;
|
|
|
+ helpmap["signup"] = descSignup;
|
|
|
|
|
|
/* initialize handle command map */
|
|
|
handlemap["status"] = &CmdMan::handleStatus;
|
|
@@ -53,6 +57,7 @@ CmdMan::CmdMan(FileMan &fm, void (*dpf)(string)) : fileman(fm) {
|
|
|
handlemap["login"] = &CmdMan::handleLogin;
|
|
|
handlemap["signup"] = &CmdMan::handleSignup;
|
|
|
handlemap["listdata"] = &CmdMan::handleListdata;
|
|
|
+ handlemap["head"] = &CmdMan::handleHead;
|
|
|
|
|
|
debugprintfunc = dpf;
|
|
|
}
|
|
@@ -213,6 +218,18 @@ CmdMan::CmdRet CmdMan::cmdListdata(vector<string> args) {
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
+CmdMan::CmdRet CmdMan::cmdHead(vector<string> args) {
|
|
|
+ CmdRet retval;
|
|
|
+ DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
+ Json::Value root;
|
|
|
+ root["command"] = "head";
|
|
|
+ root["file"] = args[0];
|
|
|
+ retval.type = send;
|
|
|
+ retval.msg = root;
|
|
|
+
|
|
|
+ return retval;
|
|
|
+}
|
|
|
+
|
|
|
CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " using command \"" + cmd +
|
|
@@ -649,3 +666,25 @@ CmdMan::CmdRet CmdMan::handleSignup(Json::Value root) {
|
|
|
|
|
|
return retval;
|
|
|
}
|
|
|
+
|
|
|
+CmdMan::CmdRet CmdMan::handleHead(Json::Value root) {
|
|
|
+ CmdRet retval;
|
|
|
+ Json::Value output;
|
|
|
+ output["command"] = "head";
|
|
|
+ output["file"] = root["file"];
|
|
|
+ output["accept"] = false;
|
|
|
+ DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
+
|
|
|
+ if (!root["accept"].asBool()) {
|
|
|
+ retval.type = error;
|
|
|
+ output["error"] = "Server reports: " + root["error"].asString();
|
|
|
+ } else {
|
|
|
+ fileman.setGetChunks(root["chunks"].asInt());
|
|
|
+ output["accept"] = true;
|
|
|
+ output["data"] = root["data"];
|
|
|
+ retval.type = print;
|
|
|
+ }
|
|
|
+ retval.msg = output;
|
|
|
+
|
|
|
+ return retval;
|
|
|
+}
|