diff -r 000000000000 -r 2b3e5ec03512 apps/dtnrecv/dtnrecv.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apps/dtnrecv/dtnrecv.c Thu Apr 21 14:57:45 2011 +0100 @@ -0,0 +1,583 @@ +/* + * Copyright 2004-2006 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dtn_api.h" + +#define BUFSIZE 16 +#define BLOCKSIZE 8192 +#define COUNTER_MAX_DIGITS 9 + +// Find the maximum commandline length +#ifdef __FreeBSD__ +/* Needed for PATH_MAX, Linux doesn't need it */ +#include +#endif + +#ifndef PATH_MAX +/* A conservative fallback */ +#define PATH_MAX 1024 +#endif + +const char *progname; + +int verbose = 0; // verbose output +int quiet = 0; // quiet output +char* endpoint = NULL; // endpoint for registration +dtn_reg_id_t regid = DTN_REGID_NONE;// registration id +int expiration = 30; // registration expiration time +int count = 0; // exit after count bundles received +int failure_action = DTN_REG_DEFER;// registration delivery failure action +char* failure_script = ""; // script to exec +int register_only = 0; // register and quit +int change = 0; // change existing registration +int unregister = 0; // remove existing registration +int recv_timeout = -1; // timeout to dtn_recv call +int no_find_reg = 0; // omit call to dtn_find_registration +char filename[PATH_MAX]; // Destination filename for file xfers +dtn_bundle_payload_location_t bundletype = DTN_PAYLOAD_MEM; + +void +usage() +{ + fprintf(stderr, "usage: %s [opts] \n", progname); + fprintf(stderr, "options:\n"); + fprintf(stderr, " -v verbose\n"); + fprintf(stderr, " -q quiet\n"); + fprintf(stderr, " -h help\n"); + fprintf(stderr, " -d endpoint id\n"); + fprintf(stderr, " -r use existing registration regid\n"); + fprintf(stderr, " -n exit after count bundles received\n"); + fprintf(stderr, " -e