38 #include <sys/types.h>
41 using namespace ibrcommon;
45 cout <<
"-- dtninbox (IBR-DTN) --" << endl;
46 cout <<
"Syntax: dtninbox [options] <name> <inbox>" << endl;
47 cout <<
" <name> the application name" << endl;
48 cout <<
" <inbox> directory where incoming files should be placed" << 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 - 2];
62 ret[
"inbox"] = argv[argc - 1];
64 for (
int i = 0; i < (argc - 2); ++i)
69 if (arg ==
"-h" || arg ==
"--help")
75 if ((arg ==
"-w" || arg ==
"--workdir") && (argc > i))
77 ret[
"workdir"] = argv[i + 1];
102 int main(
int argc,
char** argv)
105 signal(SIGINT,
term);
106 signal(SIGTERM,
term);
112 if (conf.find(
"workdir") != conf.end())
123 unsigned int backoff = 2;
126 File outbox(conf[
"outbox"]);
159 stringstream cmdstream; cmdstream <<
"tar -x -C " << conf[
"inbox"];
163 ostream stream(&extractor);
186 cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << endl;
193 backoff = backoff * 2;
202 cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << endl;
209 backoff = backoff * 2;
212 }
catch (
const std::exception&) {
218 return (EXIT_SUCCESS);