netcdf-c/dap4_test/dump.c
Dennis Heimbigner e7d5f24078 Add zip file support
The primary change is to support the use of a zip file as a
storage format. Simultaneously the .nz4 support is made obsolete

Use of zip requires the libzip support library, so a number of
changes to the build files (Makefile.am, CMakeLists.txt) are
necessary to locate and incorporate libzip.  The nczarr_tests
tests are also changed to add zip testing.

Other changes:
* Make sure distcheck leaves no files around.
* Add some functions to netcdf_aux to export some functions of libnetcdf.
* Add a new error NC_EFOUND as the complement of NC_EEMPTY.
* Add tracing support to nclog and use it in libnczarr.
* Modify the zmap interface to support the writeonce semantics of zip.
* Create a new s3util.c to support a variety of S3 auxilliary functions.
* EXTERNL'ize a number of functions so they can be used in s3util.
* Add support for the S3 ListObjects CommonPrefixes mechanism
  to improve search.
* Add experimental support for running nczarr X s3 tests against
  the actual Amazon S3 cloud.
2021-01-28 20:11:01 -07:00

91 lines
1.9 KiB
C

/*********************************************************************
* Copyright 2018, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
* $Header: /upc/share/CVS/netcdf-3/ncgen3/main.c,v 1.20 2010/03/31 18:18:40 dmh Exp $
*********************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef _MSC_VER
#include "XGetopt.h"
#define snprintf _snprintf
#endif
#include "netcdf.h"
#include "netcdf_aux.h"
#include "ncbytes.h"
#include "ncpathmgr.h"
extern void NCD4_dumpbytes(size_t size, const void* data0, int swap);
extern void NCD4_tagdump(size_t size, const void* data0, int swap, const char* tag);
static char* progname = NULL;
static void
usage(void)
{
fprintf(stderr,"Usage: %s [ -O ][ -f infile | file ]",progname);
exit(1);
}
int
main(int argc, char *argv[])
{
int c;
char* fname = NULL;
char* tag = NULL;
size_t offset = 0;
size_t len = 0;
char* data = NULL;
int swap = 0;
progname = strdup(argv[0]);
while ((c = getopt(argc, argv, "SO:f:t:")) != EOF) {
switch(c) {
case 'f':
fname = strdup(optarg);
break;
case 't':
tag = strdup(optarg);
break;
case 'S':
swap = 1;
break;
case 'O':
offset = atol(optarg);
break;
case '?':
usage();
}
}
argc -= optind;
argv += optind;
if(fname == NULL) {
if (argc > 1) {
fprintf(stderr,"%s: only one input file argument permitted",progname);
return(1);
}
fname = strdup(argv[0]);
}
if(tag == NULL) tag = strdup(progname);
if(ncaux_readfile(fname,&len,&((void*)data))) usage();
data += offset;
NCD4_tagdump(len,data,swap,tag);
nullfree(data);
return 0;
}