mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-27 08:49:16 +08:00
65414eeaa4
re: Partly addresses issue https://github.com/Unidata/netcdf-c/issues/1712. 1. Turn on Hyrax Hack to accept Hyrax style attribute containers. 2. Support Url type as alias for String. 3. Accept the special attribute, "__DAP4_Checksum_CRC32", to control per-variable checksums. 4. Make _DAP4_xxx attributes be reserved and only accessible by name (ala _SuperBlock attribute). 5. Fix handling of checksums. There is a hack in the code that uses an extra flag in the chunk header to indicate that all variables have checksums. This violates the spec and will be removed once it is possible to regenerate the test cases. Note that checksumming with the Hyrax test server has not been tested. This, along with some other probable inconsistencies, needs fixing when OPeNDAP and Unidata can agree on the proper specification. Testing will be included.
94 lines
2.0 KiB
C
94 lines
2.0 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 "ncbytes.h"
|
|
#include "ncwinpath.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);
|
|
extern int NC_readfile(const char* filename, NCbytes* content);
|
|
|
|
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;
|
|
NCbytes* contents = ncbytesnew();
|
|
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(NC_readfile(fname,contents)) usage();
|
|
len = ncbyteslength(contents) - offset;
|
|
data = (char*)ncbytescontents(contents);
|
|
data += offset;
|
|
NCD4_tagdump(len,data,swap,tag);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|