37 #include <sys/types.h>
40 using namespace ibrcommon;
44 cout <<
"-- dtnoutbox (IBR-DTN) --" << endl;
45 cout <<
"Syntax: dtnoutbox [options] <name> <outbox> <destination>" << endl;
46 cout <<
" <name> the application name" << endl;
47 cout <<
" <outbox> directory with outgoing files" << endl;
48 cout <<
" <destination> the destination EID for all outgoing files" << endl;
49 cout <<
"* optional parameters *" << endl;
50 cout <<
" -h|--help display this text" << endl;
51 cout <<
" -w|--workdir temporary work directory" << endl;
59 map<string,string> ret;
61 ret[
"name"] = argv[argc - 3];
62 ret[
"outbox"] = argv[argc - 2];
63 ret[
"destination"] = argv[argc - 1];
65 for (
int i = 0; i < (argc - 3); ++i)
70 if (arg ==
"-h" || arg ==
"--help")
76 if ((arg ==
"-w" || arg ==
"--workdir") && (argc > i))
78 ret[
"workdir"] = argv[i + 1];
103 int main(
int argc,
char** argv)
106 signal(SIGINT,
term);
107 signal(SIGTERM,
term);
113 if (conf.find(
"workdir") != conf.end())
124 unsigned int backoff = 2;
127 File outbox(conf[
"outbox"]);
157 if (files.size() <= 2)
165 stringstream file_list;
167 for (list<File>::iterator iter = files.begin(); iter != files.end(); ++iter)
179 cout <<
"files: " << file_list.str() << endl;
182 stringstream cmd; cmd <<
"tar --remove-files -cO -C " << outbox.
getPath() <<
" " << file_list.str();
186 istream stream(&app);
192 (*blob.
iostream()) << stream.rdbuf();
207 client << b; client.flush();
230 cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << endl;
237 backoff = backoff * 2;
246 cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << endl;
253 backoff = backoff * 2;
256 }
catch (
const std::exception&) {
262 return (EXIT_SUCCESS);