Remove using declarations from download-via-ssh

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2014-02-12 07:22:36 -05:00
parent c89d6b9b63
commit 2246aa77d2

View file

@ -10,16 +10,13 @@
#include <unistd.h> #include <unistd.h>
using namespace nix; using namespace nix;
using std::pair;
using std::cout;
using std::endl;
// !!! TODO: // !!! TODO:
// * Respect more than the first host // * Respect more than the first host
// * use a database // * use a database
// * show progress // * show progress
static pair<FdSink, FdSource> connect(string conn) { static std::pair<FdSink, FdSource> connect(string conn) {
Pipe to, from; Pipe to, from;
to.create(); to.create();
from.create(); from.create();
@ -51,21 +48,20 @@ static pair<FdSink, FdSource> connect(string conn) {
// If we exit unexpectedly, child will EPIPE or EOF early. // If we exit unexpectedly, child will EPIPE or EOF early.
// So no need to keep track of it. // So no need to keep track of it.
return pair<FdSink, FdSource>(to.writeSide.borrow(), from.readSide.borrow()); return std::pair<FdSink, FdSource>(to.writeSide.borrow(), from.readSide.borrow());
} }
static void substitute(pair<FdSink, FdSource> & pipes, Path storePath, Path destPath) { static void substitute(std::pair<FdSink, FdSource> & pipes, Path storePath, Path destPath) {
writeInt(cmdSubstitute, pipes.first); writeInt(cmdSubstitute, pipes.first);
writeString(storePath, pipes.first); writeString(storePath, pipes.first);
pipes.first.flush(); pipes.first.flush();
restorePath(destPath, pipes.second); restorePath(destPath, pipes.second);
cout << endl; std::cout << std::endl;
} }
static void query(pair<FdSink, FdSource> & pipes) { static void query(std::pair<FdSink, FdSource> & pipes) {
using std::cin;
writeInt(cmdQuery, pipes.first); writeInt(cmdQuery, pipes.first);
for (string line; getline(cin, line);) { for (string line; getline(std::cin, line);) {
Strings tokenized = tokenizeString<Strings>(line); Strings tokenized = tokenizeString<Strings>(line);
string cmd = tokenized.front(); string cmd = tokenized.front();
tokenized.pop_front(); tokenized.pop_front();
@ -76,25 +72,25 @@ static void query(pair<FdSink, FdSource> & pipes) {
pipes.first.flush(); pipes.first.flush();
PathSet paths = readStrings<PathSet>(pipes.second); PathSet paths = readStrings<PathSet>(pipes.second);
foreach (PathSet::iterator, i, paths) foreach (PathSet::iterator, i, paths)
cout << *i << endl; std::cout << *i << std::endl;
} else if (cmd == "info") { } else if (cmd == "info") {
writeInt(qCmdInfo, pipes.first); writeInt(qCmdInfo, pipes.first);
foreach (Strings::iterator, i, tokenized) foreach (Strings::iterator, i, tokenized)
writeStrings(tokenized, pipes.first); writeStrings(tokenized, pipes.first);
pipes.first.flush(); pipes.first.flush();
for (Path path = readString(pipes.second); !path.empty(); path = readString(pipes.second)) { for (Path path = readString(pipes.second); !path.empty(); path = readString(pipes.second)) {
cout << path << endl; std::cout << path << std::endl;
cout << readString(pipes.second) << endl; std::cout << readString(pipes.second) << std::endl;
PathSet references = readStrings<PathSet>(pipes.second); PathSet references = readStrings<PathSet>(pipes.second);
cout << references.size() << endl; std::cout << references.size() << std::endl;
foreach (PathSet::iterator, i, references) foreach (PathSet::iterator, i, references)
cout << *i << endl; std::cout << *i << std::endl;
cout << readLongLong(pipes.second) << endl; std::cout << readLongLong(pipes.second) << std::endl;
cout << readLongLong(pipes.second) << endl; std::cout << readLongLong(pipes.second) << std::endl;
} }
} else } else
throw Error(format("Unknown substituter query `%1%'") % cmd); throw Error(format("Unknown substituter query `%1%'") % cmd);
cout << endl; std::cout << std::endl;
} }
} }
@ -106,9 +102,9 @@ void run(Strings args)
if (settings.sshSubstituterHosts.empty()) if (settings.sshSubstituterHosts.empty())
return; return;
cout << endl; std::cout << std::endl;
pair<FdSink, FdSource> pipes = connect(settings.sshSubstituterHosts.front()); std::pair<FdSink, FdSource> pipes = connect(settings.sshSubstituterHosts.front());
/* Exchange the greeting */ /* Exchange the greeting */
writeInt(SERVE_MAGIC_1, pipes.first); writeInt(SERVE_MAGIC_1, pipes.first);