mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-31 17:50:26 +08:00
fix a missing files problem
This commit is contained in:
parent
7eccec950f
commit
1ec800e07b
4
cf
4
cf
@ -11,11 +11,11 @@ DAP=1
|
||||
|
||||
#NB=1
|
||||
|
||||
cmds=""
|
||||
#cmds=""
|
||||
#cmds="all"
|
||||
#cmds="all check"
|
||||
#cmds="all dist"
|
||||
#cmds="all distcheck"
|
||||
cmds="all distcheck"
|
||||
|
||||
PREFIX="/tmp/install/${HOST}"
|
||||
stddir="/share/ed/local/${HOST}"
|
||||
|
@ -39,7 +39,8 @@ rpcutil.c
|
||||
|
||||
if BUILD_RPC
|
||||
|
||||
noinst_LTLIBRARIES = librpcclient.la librcpserver.la
|
||||
noinst_LTLIBRARIES = librpcclient.la
|
||||
#librcpserver.la
|
||||
|
||||
# Build convenience library
|
||||
librpcclient_la_SOURCES = $(SRC) $(HDRS)
|
||||
|
96
librpc/cceparselex.h
Normal file
96
librpc/cceparselex.h
Normal file
@ -0,0 +1,96 @@
|
||||
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
|
||||
See the COPYRIGHT file for more information. */
|
||||
|
||||
#ifndef CCEPARSELEX_H
|
||||
#define CCEPARSELEX_H
|
||||
|
||||
#include "config.h"
|
||||
#include "ccetab.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define strcasecmp stricmp
|
||||
#define snprintf _snprintf
|
||||
#define strtoll (long long)_strtoi64
|
||||
#define strtoull (unsigned long long)_strtou64
|
||||
/* Override config.h */
|
||||
#undef HAVE_STRTOLL
|
||||
#define HAVE_STRTOLL
|
||||
#undef HAVE_STRTOULL
|
||||
#define HAVE_STRTOULL
|
||||
#endif
|
||||
|
||||
/* For consistency with Java parser */
|
||||
#ifndef null
|
||||
#define null NULL
|
||||
#endif
|
||||
|
||||
typedef void* Object;
|
||||
|
||||
#define YYSTYPE Object
|
||||
|
||||
#define MAX_TOKEN_LENGTH 1024
|
||||
|
||||
/*! Specifies CCElexstate. */
|
||||
typedef struct CCElexstate {
|
||||
char* input;
|
||||
char* next; /* next char in uri.query */
|
||||
NCbytes* yytext;
|
||||
/*! Specifies the Lasttoken. */
|
||||
int lasttoken;
|
||||
char lasttokentext[MAX_TOKEN_LENGTH+1]; /* leave room for trailing null */
|
||||
NClist* reclaim; /* reclaim SCAN_WORD instances */
|
||||
} CCElexstate;
|
||||
|
||||
/*! Specifies CCEparsestate. */
|
||||
typedef struct CCEparsestate {
|
||||
CCEconstraint* constraint;
|
||||
char errorbuf[1024];
|
||||
int errorcode;
|
||||
CCElexstate* lexstate;
|
||||
} CCEparsestate;
|
||||
|
||||
/* Define a generic object carrier; this serves
|
||||
essentially the same role as the typical bison %union
|
||||
declaration
|
||||
*/
|
||||
|
||||
/* bison parse entry point */
|
||||
extern int cceparse(CCEparsestate*);
|
||||
|
||||
extern int cceerror(CCEparsestate*,char*);
|
||||
|
||||
#ifdef IGNORE
|
||||
extern void ce_parse_error(CCEparsestate*,const char *fmt, ...);
|
||||
|
||||
extern int yyerror(CCEparsestate* state, char* msg);
|
||||
extern void projections(CCEparsestate* state, Object list0);
|
||||
extern Object projectionlist(CCEparsestate* state, Object list0, Object decl);
|
||||
extern Object projection(CCEparsestate* state, Object segmentlist);
|
||||
extern Object segmentlist(CCEparsestate* state, Object list0, Object decl);
|
||||
extern Object segment(CCEparsestate* state, Object name, Object slices0);
|
||||
extern Object range(CCEparsestate* state, Object, Object, Object);
|
||||
extern Object indexer(CCEparsestate* state, Object name, Object indices);
|
||||
extern Object indexpath(CCEparsestate* state, Object list0, Object index);
|
||||
extern Object var(CCEparsestate* state, Object indexpath);
|
||||
extern Object range1(CCEparsestate* state, Object rangenumber);
|
||||
extern Object rangelist(CCEparsestate* state, Object list0, Object decl);
|
||||
|
||||
/* lexer interface */
|
||||
extern int ccelex(YYSTYPE*, CCEparsestate*);
|
||||
extern void ccelexinit(char* input, CCElexstate** lexstatep);
|
||||
extern void ccelexcleanup(CCElexstate** lexstatep);
|
||||
#endif
|
||||
|
||||
extern int cdmceparse(char* input, CCEconstraint*, char**);
|
||||
|
||||
#ifdef PARSEDEBUG
|
||||
extern int ccedebug;
|
||||
extern Object debugobject(Object);
|
||||
#define checkobject(x) debugobject(x)
|
||||
#else
|
||||
#define checkobject(x) (x)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*CCEPARSELEX_H*/
|
||||
|
451
librpc/curlwrap.c
Normal file
451
librpc/curlwrap.c
Normal file
@ -0,0 +1,451 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/* "$Id$" */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "curlwrap.h"
|
||||
|
||||
#include "nclist.h"
|
||||
#include "nclog.h"
|
||||
|
||||
#include "netcdf.h"
|
||||
#include "nc.h"
|
||||
#include "nc4internal.h"
|
||||
#include "nccr.h"
|
||||
#include "ast.h"
|
||||
#include "crutil.h"
|
||||
|
||||
static char* combinecredentials(const char* user, const char* pwd);
|
||||
static size_t WriteMemoryCallback(void*, size_t, size_t, void*);
|
||||
|
||||
/* Condition on libcurl version */
|
||||
#ifndef HAVE_CURLOPT_KEYPASSWD
|
||||
/* Set up an alias */
|
||||
#define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD
|
||||
#endif
|
||||
|
||||
struct NCCR_CALLBACK_DATA {
|
||||
size_t alloc;
|
||||
size_t pos;
|
||||
unsigned char* data;
|
||||
};
|
||||
|
||||
static size_t WriteMemoryCallback(void*, size_t, size_t, void*);
|
||||
|
||||
int
|
||||
nccr_curlopen(CURL** curlp)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat;
|
||||
CURL* curl;
|
||||
/* initialize curl*/
|
||||
curl = curl_easy_init();
|
||||
if(curl == NULL)
|
||||
stat = NC_ECURL;
|
||||
else {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||
if(cstat != CURLE_OK)
|
||||
stat = NC_ECURL;
|
||||
/*some servers don't like requests that are made without a user-agent*/
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
|
||||
if(cstat != CURLE_OK)
|
||||
stat = NC_ECURL;
|
||||
}
|
||||
if(curlp)
|
||||
*curlp = curl;
|
||||
return stat;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_curlclose(CURL* curl)
|
||||
{
|
||||
if(curl != NULL)
|
||||
curl_easy_cleanup(curl);
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_fetchurl(NCCDMR* cdmr, CURL* curl, char* url, bytes_t* buf, long* filetime)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
struct NCCR_CALLBACK_DATA callback_data;
|
||||
int index, first;
|
||||
|
||||
/* If required, report the url */
|
||||
if(cdmr->controls & SHOWFETCH) {
|
||||
nclog(NCLOGNOTE,"fetch url: %s",url);
|
||||
}
|
||||
|
||||
callback_data.alloc = 0;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if(cstat != CURLE_OK)
|
||||
goto fail;
|
||||
|
||||
/* send all data to this function */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||
if(cstat != CURLE_OK)
|
||||
goto fail;
|
||||
|
||||
/* we pass our file to the callback function */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&callback_data);
|
||||
if(cstat != CURLE_OK)
|
||||
goto fail;
|
||||
|
||||
/* One last thing; always try to get the last modified time */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FILETIME, (long)1);
|
||||
|
||||
/* fetch */
|
||||
cstat = curl_easy_perform(curl);
|
||||
if(cstat == CURLE_PARTIAL_FILE) {
|
||||
/* Log it but otherwise ignore */
|
||||
nclog(NCLOGERR,"curl error: %s; ignored",
|
||||
curl_easy_strerror(cstat));
|
||||
cstat = CURLE_OK;
|
||||
}
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* pull the data */
|
||||
if(buf) {
|
||||
buf->nbytes = callback_data.pos;
|
||||
buf->bytes = callback_data.data;
|
||||
callback_data.data = NULL;
|
||||
}
|
||||
|
||||
/* Get the last modified time */
|
||||
if(filetime != NULL)
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_FILETIME,filetime);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* Check for potential html return */
|
||||
/* skip leading whitespace */
|
||||
for(first=0;first<buf->nbytes;first++) {
|
||||
char* p = strchr(" \t\r\n",buf->bytes[first]);
|
||||
if(p == NULL)
|
||||
break;
|
||||
}
|
||||
index = crstrindex((char*)buf->bytes,"<html");
|
||||
if(index >= 0) {
|
||||
int endex;
|
||||
/* Search for </html> */
|
||||
endex = crstrindex((char*)buf->bytes,"</html>");
|
||||
if(endex >= 0) endex += 7; else endex = buf->nbytes-1;
|
||||
nclog(NCLOGWARN,"Probable Server error");
|
||||
nclogtextn(NCLOGWARN,(char*)buf->bytes+first,endex-first);
|
||||
nclogtext(NCLOGWARN,"\n");
|
||||
}
|
||||
return stat;
|
||||
|
||||
fail:
|
||||
nclog(NCLOGERR,"curl error: %s", curl_easy_strerror(cstat));
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
static size_t
|
||||
WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *cdata)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
struct NCCR_CALLBACK_DATA* callback_data = (struct NCCR_CALLBACK_DATA*)cdata;
|
||||
|
||||
if(realsize == 0)
|
||||
nclog(NCLOGERR,"WriteMemoryCallback: zero sized chunk");
|
||||
|
||||
if(callback_data->alloc == 0) {
|
||||
callback_data->data = (unsigned char*)malloc(realsize);
|
||||
callback_data->alloc = realsize;
|
||||
callback_data->pos = 0;
|
||||
}
|
||||
|
||||
if(callback_data->alloc - callback_data->pos < realsize) {
|
||||
callback_data->data = (unsigned char*)realloc(callback_data->data,
|
||||
callback_data->alloc+realsize);
|
||||
callback_data->alloc += realsize;
|
||||
}
|
||||
memcpy(callback_data->data+callback_data->pos,ptr,realsize);
|
||||
callback_data->pos += realsize;
|
||||
return realsize;
|
||||
}
|
||||
|
||||
long
|
||||
nccr_fetchhttpcode(CURL* curl)
|
||||
{
|
||||
long httpcode;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
/* Extract the http code */
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&httpcode);
|
||||
if(cstat != CURLE_OK) httpcode = 0;
|
||||
return httpcode;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_fetchlastmodified(CURL* curl, char* url, long* filetime)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if(cstat != CURLE_OK)
|
||||
goto fail;
|
||||
|
||||
/* Ask for head */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30); /* 30sec timeout*/
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FILETIME, (long)1);
|
||||
|
||||
cstat = curl_easy_perform(curl);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
if(filetime != NULL)
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_FILETIME,filetime);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
return stat;
|
||||
|
||||
fail:
|
||||
nclog(NCLOGERR,"curl error: %s\n", curl_easy_strerror(cstat));
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
|
||||
/* Set various general curl flags */
|
||||
int
|
||||
nccr_set_curl_flags(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat = CURLE_OK;
|
||||
NCCURLSTATE* state = &nccr->curl;
|
||||
|
||||
#ifdef CURLOPT_ENCODING
|
||||
if (state->compress) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_ENCODING, 'deflate, gzip');
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_ENCODING=deflat, gzip"));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (state->cookiejar || state->cookiefile) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_COOKIESESSION=1"));
|
||||
#endif
|
||||
}
|
||||
if (state->cookiejar) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIEJAR, state->cookiejar);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_COOKIEJAR=%s",state->cookiejar);
|
||||
#endif
|
||||
}
|
||||
if (state->cookiefile) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIEFILE, state->cookiefile);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_COOKIEFILE=%s",state->cookiefile);
|
||||
#endif
|
||||
}
|
||||
if (state->verbose) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_VERBOSE=%ld",1L);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Following are always set */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_FOLLOWLOCATION=%ld",1L);
|
||||
#endif
|
||||
return NC_NOERR;
|
||||
|
||||
fail:
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_set_proxy(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat;
|
||||
struct NCCURLSTATE* state = &nccr->curl;
|
||||
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXY, state->host);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXY=%s",state->host);
|
||||
#endif
|
||||
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, state->port);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYPORT=%d",state->port);
|
||||
#endif
|
||||
|
||||
if (state->username) {
|
||||
char *combined = combinecredentials(state->username,state->password);
|
||||
if (!combined) return NC_ENOMEM;
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, combined);
|
||||
free(combined);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYUSERPWD=%s",combined);
|
||||
#endif
|
||||
#ifdef CURLOPT_PROXYAUTH
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYAUTH=%ld",(long)CURLAUTH_ANY);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_set_ssl(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat = CURLE_OK;
|
||||
struct NCCURLSTATE* state = &nccr->curl;
|
||||
long verify = (state->validate?1L:0L);
|
||||
cstat=curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, verify);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSL_VERIFYPEER=%ld",verify);
|
||||
#endif
|
||||
cstat=curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (verify?2L:0L));
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSL_VERIFYHOST=%ld",(verify?2L:0L));
|
||||
#endif
|
||||
{
|
||||
if(state->certificate) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_SSLCERT, state->certificate);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLCERT=%s",state->certificate);
|
||||
#endif
|
||||
}
|
||||
if(state->key) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_SSLKEY, state->key);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLKEY=%s",state->key);
|
||||
#endif
|
||||
}
|
||||
if(state->keypasswd) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_KEYPASSWD, state->keypasswd);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLKEY=%s",state->key);
|
||||
#endif
|
||||
}
|
||||
if(state->cainfo) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CAINFO, state->cainfo);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_CAINFO=%s",state->cainfo);
|
||||
#endif
|
||||
}
|
||||
if(state->capath) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CAPATH, state->capath);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_CAPATH=%s",state->capath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return NC_NOERR;
|
||||
|
||||
fail:
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
/* This is called with arguments while the other functions in this file are
|
||||
* used with global values read from the.dodsrc file. The reason is that
|
||||
* we may have multiple password sources.
|
||||
*/
|
||||
int
|
||||
nccr_set_user_password(CURL* curl, const char *userC, const char *passwordC)
|
||||
{
|
||||
CURLcode cstat;
|
||||
char* combined = NULL;
|
||||
|
||||
if(userC == NULL && passwordC == NULL) return NC_NOERR;
|
||||
if(userC == NULL) userC = "";
|
||||
if(passwordC == NULL) passwordC = "";
|
||||
|
||||
combined = combinecredentials(userC,passwordC);
|
||||
if (!combined) return NC_ENOMEM;
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_USERPWD, combined);
|
||||
if (cstat != CURLE_OK) goto done;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_USERPWD=%s",combined);
|
||||
#endif
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long) CURLAUTH_ANY);
|
||||
if (cstat != CURLE_OK) goto done;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_HTTPAUTH=%ld",(long)CURLAUTH_ANY);
|
||||
#endif
|
||||
|
||||
done:
|
||||
if(combined != NULL) free(combined);
|
||||
return (cstat == CURLE_OK?NC_NOERR:NC_ECURL);
|
||||
}
|
||||
|
||||
static char*
|
||||
combinecredentials(const char* user, const char* pwd)
|
||||
{
|
||||
int userPassSize = strlen(user) + strlen(pwd) + 2;
|
||||
char *userPassword = malloc(sizeof(char) * userPassSize);
|
||||
if (!userPassword) {
|
||||
nclog(NCLOGERR,"Out of Memory");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(userPassword, user);
|
||||
strcat(userPassword, ":");
|
||||
strcat(userPassword, pwd);
|
||||
return userPassword;
|
||||
}
|
55
librpc/curlwrap.h
Normal file
55
librpc/curlwrap.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/* "$Id$" */
|
||||
|
||||
#ifndef CURLWRAP_H
|
||||
#define CURLWRAP_H
|
||||
|
||||
/*Forward*/
|
||||
struct NCCDMR;
|
||||
struct bytes_t;
|
||||
|
||||
extern int nccr_curlopen(CURL**);
|
||||
extern int nccr_curlclose(CURL*);
|
||||
|
||||
extern int nccr_fetchurl(struct NCCDMR*, CURL*, char* url, struct bytes_t* buf, long* filetime);
|
||||
extern long nccr_fetchhttpcode(CURL* curl);
|
||||
extern int nccr_fetchlastmodified(CURL* curl, char* url, long* filetime);
|
||||
|
||||
extern int nccr_set_curl_flags(CURL*, struct NCCDMR*);
|
||||
extern int nccr_set_proxy(CURL*, struct NCCDMR*);
|
||||
extern int nccr_set_ssl(CURL*, struct NCCDMR*);
|
||||
extern int nccr_set_user_password(CURL*, const char *userC, const char *passwordC);
|
||||
|
||||
|
||||
#endif /*CURLWRAP_H*/
|
38
librpc/fix
Normal file
38
librpc/fix
Normal file
@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
RPCF="\
|
||||
rpcdebug.c \
|
||||
rpcdebug.h \
|
||||
rpcpath.h \
|
||||
rpcutil.c \
|
||||
rpcutil.h"
|
||||
|
||||
NCF="\
|
||||
ncrpc.c \
|
||||
ncrpc.h \
|
||||
ncrpccvt.c \
|
||||
ncrpccvt.h \
|
||||
ncrpcdispatch.c \
|
||||
ncrpcdispatch.h \
|
||||
ncrpcdump.c \
|
||||
ncrpcdump.h \
|
||||
ncrpcmeta.c \
|
||||
ncrpcmeta.h \
|
||||
ncrpcnode.h \
|
||||
ncrpcproto.c \
|
||||
ncrpcproto.h"
|
||||
|
||||
for f in ${RPCF} ; do
|
||||
rm -f ./$f
|
||||
cat ckp1/$f \
|
||||
| sed -e 's/[#]include[ \t]*["]cr\([a-zA-Z0-9_]*\)[.]h/#include "rpc\1.h"/' \
|
||||
| sed -e 's/[#]include[ \t]*["]nccr\([a-zA-Z0-9_]*\)[.]h/#include "ncrpc\1.h"/' \
|
||||
| sed -e 's/^cr/rpc/' \
|
||||
| sed -e 's/ CR/ RPC/' \
|
||||
| sed -e 's/nccr/ncrpc/' \
|
||||
| sed -e 's/ NCCR/ NCRPC/' \
|
||||
| cat >./$f
|
||||
done
|
||||
|
||||
exit
|
||||
|
3
librpc/junk
Normal file
3
librpc/junk
Normal file
@ -0,0 +1,3 @@
|
||||
ncrpc.h
|
||||
ncrpcdispatch.c
|
||||
ncrpcdispatch.h
|
6
librpc/librpcserver.c
Normal file
6
librpc/librpcserver.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
310
librpc/nc_meta.c
Normal file
310
librpc/nc_meta.c
Normal file
@ -0,0 +1,310 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "nc_meta.h"
|
||||
|
||||
MetaNode*
|
||||
NC_meta_alloc(nc_meta nodeclass)
|
||||
{
|
||||
MetaNode* node = (MetaNode*)calloc(1,sizeof(MetaNode));
|
||||
if(node != null) {
|
||||
node->nodeclass = nodeclass;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
MetaNode**
|
||||
NC_meta_allocn(nc_meta nodeclass, int count)
|
||||
{
|
||||
int i,j;
|
||||
MetaNode** nodelist = (MetaNode**)calloc(count,sizeof(MetaNode*));
|
||||
if(nodelist != null) { /* cleanup */
|
||||
for(i=0;i<count;i++) {
|
||||
nodelist[i] = nc_meta_alloc(nodeclass);
|
||||
if(nodelist[i] == NULL) {
|
||||
for(j=0;j<i;j++) nc_meta_free(nodelist[j]);
|
||||
}
|
||||
free(nodelist);
|
||||
nodelist = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nodelist;
|
||||
}
|
||||
|
||||
void
|
||||
NC_meta_free(MetaNode* node)
|
||||
{
|
||||
int i;
|
||||
if(node == NULL) return;
|
||||
switch(node->nodeclass) {
|
||||
case NC_ENUM:
|
||||
for(i=0;i<node->nelems;i++) {
|
||||
if(node->econsts[i].name != NULL)
|
||||
free(node->econsts[i].name);
|
||||
}
|
||||
if(node->consts != null) free(node->econsts);
|
||||
break;
|
||||
case NC_COMPOUND:
|
||||
if(node->compound.fields != null) {
|
||||
for(i=0;i<node->nelems;i++) {
|
||||
NC_meta_free(node->compound.fields[i]);
|
||||
}
|
||||
free(node->compound.fields);
|
||||
}
|
||||
break;
|
||||
case NC_FIELD:
|
||||
break;
|
||||
default:
|
||||
free((void*)node; break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Invoke nc_inq functions to fill in a type node
|
||||
*/
|
||||
|
||||
int
|
||||
NC_meta_create_type(int ncid, nc_type xtype,
|
||||
MetaNode* root, MetaNode** typenodep)
|
||||
{
|
||||
/* Walk the node set to ensure that the type does not already exist */
|
||||
int ncstat = NC_NOERR;
|
||||
MetaNode* node = locatemetatype(xtype,root);
|
||||
if(node == NULL) {
|
||||
ncstat = NC_meta_create_type1(ncid,xtype,root,typenodep);
|
||||
} else if(typenodep != NULL)
|
||||
*typenodep = node;
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
static int
|
||||
NC_meta_create_type1(int ncid, nc_type xtype,
|
||||
MetaNode* root, MetaNode** typenodep)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
int i;
|
||||
MetaNode* node;
|
||||
nc_meta metatype = NC_NAT;
|
||||
|
||||
/* Determine the top-level type for xtype */
|
||||
ncstat = mapnctype(ncid,xtype,&metatype);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
node = NC_meta_alloc(metatype);
|
||||
node->ncid = ncid;
|
||||
node->xtype = xtype;
|
||||
|
||||
switch (node->nodeclass) {
|
||||
|
||||
case NC_ATOMIC:
|
||||
ncstat = nc_inq_type(ncid,xtype,node->name,&node->size);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
break;
|
||||
|
||||
case NC_OPAQUE:
|
||||
ncstat = nc_inq_opaque(ncid,xtype,node->name,&node->size);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
break;
|
||||
|
||||
case NC_ENUM:
|
||||
ncstat = nc_inq_enum(ncid,xtype,node->name,&node->basetype,
|
||||
&node->size,&node->nelems);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
/* Now, create and fill in the enum constants */
|
||||
node->econsts = (struct MetaEconst*)calloc(node->nelems,
|
||||
sizeof(struct MetaEconst));
|
||||
if(node->econsts == NULL) {ncstat = NC_ENOMEM;goto fail;}
|
||||
for(i=0;i<node->nelems;i++) {
|
||||
struct MetaEconst* econst = node->consts+i;
|
||||
ncstat = nc_inq_enum_member(ncid,xtype,i,
|
||||
econst->name,
|
||||
(void*)econst->value);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
case NC_COMPOUND:
|
||||
ncstat = nc_inq_compound(ncid,xtype,node->name,&node->size,
|
||||
&node->nelems);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
/* Now, create and fill in the fields */
|
||||
node->compound.fields = nc_meta_allocn(NC_FIELD,node->nelems);
|
||||
if(node->compound.fields == NULL) {ncstat = NC_ENOMEM;goto fail;}
|
||||
for(i=0;i<node->nelems;i++) {
|
||||
MetaNode* field = node->compound.fields+i;
|
||||
nc_type basetype;
|
||||
ncstat = nc_inq_compound_field(ncid,xtype,i,
|
||||
field->name,
|
||||
&field->offset,
|
||||
&basetype,
|
||||
&field->ndims,
|
||||
field->dims);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
/* create basetype */
|
||||
ncstat = NC_meta_create_type(ncid,basetype,root,&field->basetype);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
case NC_VLEN: {
|
||||
nc_type basetype;
|
||||
ncstat = nc_inq_vlen(ncid,xtype,node->name,&node->size,&basetype);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
/* create basetype */
|
||||
ncstat = NC_meta_create_type(ncid,basetype,root,&node->basetype);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
} break;
|
||||
|
||||
case NC_GROUP: {
|
||||
nc_type* typeids;
|
||||
ncstat = nc_inq_typeids(ncid,&node->nelems,NULL);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
typeids = (nc_type*)calloc(node->nelems,sizeof(nc_type));
|
||||
if(typeids == NULL) {ncstat = NC_ENOMEM; goto fail;}
|
||||
ncstat = nc_inq_typeids(ncid,&node->nelems,typeids);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
break;
|
||||
|
||||
default: abort();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
mapnctype(int ncid, nc_type xtype, nc_meta* metatypep)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
if(metatypep == NULL) goto done;
|
||||
if(xtype <= NC_MAX_ATOMIC_TYPE) goto done;
|
||||
ncstat = nc_inq_user_type(ncid,xtype,NULL,NULL,NULL,NULL,metatypep);
|
||||
done:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
static MetaNode*
|
||||
locatemetatype(nc_type typeid, MetaNode* root)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<nclistlength(root->root.typeset);i++) {
|
||||
MetaNode* node = (MetaNode*)nclistget(root->root.typeset,i);
|
||||
if(node->typeid == xtype) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given
|
||||
*/
|
||||
|
||||
int
|
||||
NC_meta_computesize(MetaNode* typenode, void* data)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
int i;
|
||||
|
||||
switch (node->nodeclass) {
|
||||
|
||||
case NC_ATOMIC:
|
||||
ncstat = nc_inq_type(ncid,xtype,node->name,&node->size);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
break;
|
||||
|
||||
case NC_OPAQUE:
|
||||
ncstat = nc_inq_opaque(ncid,xtype,node->name,&node->size);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
break;
|
||||
|
||||
case NC_ENUM:
|
||||
ncstat = nc_inq_enum(ncid,xtype,node->name,&node->basetype,
|
||||
&node->size,&node->nelems);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
/* Now, create and fill in the enum constants */
|
||||
node->econsts = (struct MetaEconst*)calloc(node->nelems,
|
||||
sizeof(struct MetaEconst));
|
||||
if(node->econsts == NULL) {ncstat = NC_ENOMEM;goto fail;}
|
||||
for(i=0;i<node->nelems;i++) {
|
||||
struct MetaEconst* econst = node->consts+i;
|
||||
ncstat = nc_inq_enum_member(ncid,xtype,i,
|
||||
econst->name,
|
||||
(void*)econst->value);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
case NC_COMPOUND:
|
||||
ncstat = nc_inq_compound(ncid,xtype,node->name,&node->size,
|
||||
&node->nelems);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
/* Now, create and fill in the fields */
|
||||
node->compound.fields = nc_meta_allocn(NC_FIELD,node->nelems);
|
||||
if(node->compound.fields == NULL) {ncstat = NC_ENOMEM;goto fail;}
|
||||
for(i=0;i<node->nelems;i++) {
|
||||
MetaNode* field = node->compound.fields+i;
|
||||
nc_type basetype;
|
||||
ncstat = nc_inq_compound_field(ncid,xtype,i,
|
||||
field->name,
|
||||
&field->offset,
|
||||
&basetype,
|
||||
&field->ndims,
|
||||
field->dims);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
/* create basetype */
|
||||
ncstat = NC_meta_create_type(ncid,basetype,root,&field->basetype);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
case NC_VLEN: {
|
||||
nc_type basetype;
|
||||
ncstat = nc_inq_vlen(ncid,xtype,node->name,&node->size,&basetype);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
/* create basetype */
|
||||
ncstat = NC_meta_create_type(ncid,basetype,root,&node->basetype);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
} break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
return ncstat;
|
||||
}
|
116
librpc/nc_meta.h
Normal file
116
librpc/nc_meta.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef NC_META_H
|
||||
#define NC_META_H 1
|
||||
|
||||
/**
|
||||
Provide an in-memory representation
|
||||
of a type system associated with a netcdf
|
||||
file. This is required for e.g. rpc so
|
||||
that it can serialize data arguments to
|
||||
e.g. nc_put_vara
|
||||
*/
|
||||
|
||||
/**
|
||||
Use a single node type to represent
|
||||
meta-data definition tree.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define the primary node types
|
||||
* by extending the existing entries in
|
||||
* netcdf.h
|
||||
*/
|
||||
|
||||
/* Start defs at a good offset from NC_COMPOUND;
|
||||
ok if it overlaps with NC_FIRSTUSERTYPEID.
|
||||
*/
|
||||
#define NC_META_TYPE_OFFSET 32
|
||||
|
||||
/* Start with a root node to hold various things */
|
||||
#define NC_ATOMIC (NC_META_TYPE_OFFSET+0)
|
||||
#define NC_FIELD (NC_META_TYPE_OFFSET+1)
|
||||
#define NC_ROOT (NC_META_TYPE_OFFSET+2)
|
||||
#define NC_GROUP (NC_META_TYPE_OFFSET+3)
|
||||
#define NC_VAR (NC_META_TYPE_OFFSET+4)
|
||||
#define NC_DIM (NC_META_TYPE_OFFSET+5) /* does not include field dims */
|
||||
|
||||
typedef int nc_meta;
|
||||
|
||||
typedef struct MetaNode {
|
||||
nc_meta nodeclass;
|
||||
nc_meta subclass;
|
||||
int ncid;
|
||||
nc_type typeid;
|
||||
char name[NC_MAX_NAME];
|
||||
size_t size; /* for opaque, dims, etc */
|
||||
MetaNode* basetype; /* vlen or enum or basetype */
|
||||
int nelems; /* # fields ,econsts, dims, etc. */
|
||||
struct {
|
||||
MetaNode** nodeset;
|
||||
MetaNode* rootgroup;
|
||||
} root;
|
||||
struct {
|
||||
MetaNode** typeset; /* types in group */
|
||||
MetaNode** varset; /* vars in group */
|
||||
MetaNode** dimrset; /* dims in group */
|
||||
MetaNode** groups; /* (sub)groups in group */
|
||||
} group;
|
||||
struct { /* compound node specific info */
|
||||
MetaNode** fields;
|
||||
} compound;
|
||||
struct { /* var node specific info */
|
||||
MetaNode* dims[NC_MAX_VAR_DIMS];
|
||||
} var;
|
||||
struct {
|
||||
size_t actualsize; /* actual size for unlimited */
|
||||
} dim;
|
||||
struct { /* field node specific info */
|
||||
size_t dims[NC_MAX_VAR_DIMS];
|
||||
size_t offset;
|
||||
size_t alignment;
|
||||
} field; /* compound fields */
|
||||
/* Don't bother with separate econst nodes */
|
||||
struct MetaEconst { /* enum constants */
|
||||
char name[NC_MAX_NAME];
|
||||
char value[16]; /* actual value size is unknown */
|
||||
} *econsts;
|
||||
} MetaNode;
|
||||
|
||||
/* Meta Methods */
|
||||
extern MetaNode* NC_meta_alloc(nc_meta nodeclass);
|
||||
extern MetaNode** NC_meta_allocn(nc_meta nodeclass, int count);
|
||||
extern void NC_meta_free(MetaNode*);
|
||||
|
||||
#endif /*NC_META_H*/
|
87
librpc/nc_path.c
Normal file
87
librpc/nc_path.c
Normal file
@ -0,0 +1,87 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap3/common34.c,v 1.29 2010/05/25 13:53:02 ed Exp $
|
||||
*********************************************************************/
|
||||
|
||||
#include "rpc_includes.h"
|
||||
|
||||
NCPath*
|
||||
ncpath_append(NCPath* path, char* name)
|
||||
{
|
||||
NCPath* newsegment = NULL;
|
||||
newsegment = (NCPath*)malloc(sizeof(NCPath));
|
||||
if(newsegment == NULL) return NULL;
|
||||
newsegment->name = strdup(name);
|
||||
newsegment->next = NULL;
|
||||
|
||||
if(path == NULL) {
|
||||
path = newsegment;
|
||||
} else {
|
||||
/* Find last node */
|
||||
NCPath* last = path;
|
||||
while(last->next != NULL) last = last->next;
|
||||
last->next = newsegment;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ncpath_free(NCPath* path)
|
||||
{
|
||||
while(path != NULL) {
|
||||
NCPath* curr = path;
|
||||
if(curr->name) free(curr->name);
|
||||
path = curr->next;
|
||||
free(curr);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ncpath_match(NCPath* path1, NCPath* path2)
|
||||
{
|
||||
while(path1 != NULL && path2 != NULL) {
|
||||
if(strcmp(path1->name,path2->name)!=0) return 0;
|
||||
path1 = path1->next;
|
||||
path2 = path2->next;
|
||||
}
|
||||
if(path1 == NULL && path2 == NULL) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
NCPath*
|
||||
ncpath_dup(NCPath* path)
|
||||
{
|
||||
NCPath* newpath = NULL;
|
||||
while(path != NULL) {
|
||||
ncpath_append(newpath,path->name);
|
||||
path = path->next;
|
||||
}
|
||||
return newpath;
|
||||
}
|
||||
|
||||
char*
|
||||
ncpath_tostring(NCPath* path, char* sep, char*(encode)(char*,NCBytes*))
|
||||
{
|
||||
NCBytes* buf;
|
||||
char* result;
|
||||
|
||||
if(path == NULL) return NULL;
|
||||
if(sep == NULL) sep = ".";
|
||||
buf = ncbytesnew();
|
||||
int first = 1;
|
||||
while(path != NULL) {
|
||||
if(!first) ncbytescat(buf,path);
|
||||
first = 0;
|
||||
if(encode != NULL)
|
||||
encode(path->name,buf);
|
||||
else
|
||||
ncbytescat(buf,path->name);
|
||||
path = path->next;
|
||||
}
|
||||
result = ncbytesdup(buf);
|
||||
ncbytesfree(buf);
|
||||
return result;
|
||||
}
|
||||
|
30
librpc/nc_path.h
Normal file
30
librpc/nc_path.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef NC_PATH_H
|
||||
#define NC_PATH_H
|
||||
|
||||
/* In order to allow greater lattitude in
|
||||
what characters are allowed in names,
|
||||
we avoid stringifying the pathname; instead
|
||||
we use a linked list of names.
|
||||
*/
|
||||
|
||||
typedef struct NCPath {
|
||||
char* name; /* this segment of the full path */
|
||||
struct NCPath* next;
|
||||
} NCPath;
|
||||
|
||||
extern NCPath* ncpath_append(NCPath*,char*);
|
||||
extern void ncpath_free(NCPath*);
|
||||
extern int ncpath_match(NCPath*,NCPath*);
|
||||
extern NCPath* ncpath_dup(NCPath*);
|
||||
|
||||
/* Caller free's return value */
|
||||
extern char* ncpath_tostring(NCPath* path, char* sep, char*(encode(char*)));
|
||||
|
||||
#endif /*NC_PATH_H*/
|
35
librpc/rpc_includes.h
Normal file
35
librpc/rpc_includes.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef RPC_INCLUDES_H
|
||||
#define RPC_INCLUDES_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "ncbytes.h"
|
||||
#include "nclist.h"
|
||||
#include "nclog.h"
|
||||
|
||||
#include "netcdf.h"
|
||||
#include "nc.h"
|
||||
#include "ncdispatch.h"
|
||||
|
||||
#include "ast.h"
|
||||
#include "protorpc.h"
|
||||
|
||||
#include "rpc.h"
|
||||
#include "rpcdispatch.h"
|
||||
#include "rpccurl.h"
|
||||
#include "rpcdebug.h"
|
||||
#include "rpcpath.h"
|
||||
#include "rpcutil.h"
|
||||
|
||||
#endif /*RPC_INCLUDES_H*/
|
42
librpc/rpcdebug.c
Normal file
42
librpc/rpcdebug.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap3/dapdebug.c,v 1.9 2009/09/23 22:26:00 dmh Exp $
|
||||
*********************************************************************/
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rpcdebug.h""
|
||||
|
||||
#ifdef CATCHERROR
|
||||
|
||||
/* Place breakpoint here to catch errors close to where they occur*/
|
||||
int
|
||||
ncrpcbreakpoint(int err) {return err;}
|
||||
|
||||
int
|
||||
ncrpcthrow(int err)
|
||||
{
|
||||
if(err == 0) return err;
|
||||
return ncrpcbreakpoint(err);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
ncrpcpanic(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
if(fmt != NULL) {
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n" );
|
||||
va_end( args );
|
||||
} else {
|
||||
fprintf(stderr, "panic" );
|
||||
}
|
||||
fprintf(stderr, "\n" );
|
||||
fflush(stderr);
|
||||
return 0;
|
||||
}
|
||||
|
44
librpc/rpcdebug.h
Normal file
44
librpc/rpcdebug.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap3/dapdebug.h,v 1.33 2009/12/03 18:53:16 dmh Exp $
|
||||
*********************************************************************/
|
||||
#ifndef RPCDEBUG_H
|
||||
#define RPCDEBUG_H
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* Warning: setting CATCHERROR has significant performance impact */
|
||||
#undef CATCHERROR
|
||||
#ifdef DEBUG
|
||||
#undef CATCHERROR
|
||||
#define CATCHERROR
|
||||
#endif
|
||||
|
||||
#define PANIC(msg) assert(ncrpcpanic(msg));
|
||||
#define PANIC1(msg,arg) assert(ncrpcpanic(msg,arg));
|
||||
#define PANIC2(msg,arg1,arg2) assert(ncrpcpanic(msg,arg1,arg2));
|
||||
|
||||
#define ASSERT(expr) if(!(expr)) {PANIC(#expr);} else {}
|
||||
|
||||
extern int ncrpcpanic(const char* fmt, ...);
|
||||
|
||||
#define MEMCHECK(var,throw) {if((var)==NULL) return (throw);}
|
||||
|
||||
#ifdef CATCHERROR
|
||||
/* Place breakpoint on ncrpcbreakpoint to catch errors close to where they occur*/
|
||||
#define THROW(e) ncrpcthrow(e)
|
||||
#define THROWCHK(e) (void)ncrpcthrow(e)
|
||||
|
||||
extern int ncrpcbreakpoint(int err);
|
||||
extern int ncrpcthrow(int err);
|
||||
#else
|
||||
#define THROW(e) (e)
|
||||
#define THROWCHK(e)
|
||||
#endif
|
||||
|
||||
#endif /*CRDEBUG_H*/
|
||||
|
29
librpc/rpcserialize.c
Normal file
29
librpc/rpcserialize.c
Normal file
@ -0,0 +1,29 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap3/common34.c,v 1.29 2010/05/25 13:53:02 ed Exp $
|
||||
*********************************************************************/
|
||||
|
||||
#include "rpc_includes.h"
|
||||
|
||||
|
||||
int
|
||||
rpc_serialize(MetaNode* node, NCBytes* buf)
|
||||
{
|
||||
switch(node->nodeclass) {
|
||||
case NC_VAR:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case NC_FIELD:
|
||||
case NC_GROUP:
|
||||
case NC_ECONST:
|
||||
case NC_VLEN:
|
||||
case NC_OPAQUE:
|
||||
case NC_ENUM:
|
||||
case NC_COMPOUND:
|
||||
default: return 0;
|
||||
}
|
||||
}
|
42
librpc/rpcutil.c
Normal file
42
librpc/rpcutil.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap3/common34.c,v 1.29 2010/05/25 13:53:02 ed Exp $
|
||||
*********************************************************************/
|
||||
|
||||
#include "rpc_includes.h"
|
||||
|
||||
/* Define a local version of strindex */
|
||||
int
|
||||
rpcstrindex(char* s, char* match)
|
||||
{
|
||||
size_t mlen = strlen(match);
|
||||
size_t slen = strlen(s);
|
||||
int i,j;
|
||||
if(slen < mlen) return -1;
|
||||
slen -= mlen;
|
||||
for(i=0;i<slen;i++) {
|
||||
int found = 1;
|
||||
for(j=0;j<mlen;j++) {
|
||||
if(s[i+j] != match[j]) {found=0; break;}
|
||||
}
|
||||
if(found)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Collect the set of parent group nodes of node */
|
||||
void
|
||||
rpccollectnodepath(CRnode* node, NClist* path)
|
||||
{
|
||||
Group* group;
|
||||
if(node == NULL) return;
|
||||
nclistpush(path,(ncelem)node);
|
||||
group = node->group;
|
||||
while(group != NULL) {
|
||||
nclistinsert(path,0,(ncelem)group);
|
||||
group = ((CRnode*)group)->group;
|
||||
}
|
||||
}
|
18
librpc/rpcutil.h
Normal file
18
librpc/rpcutil.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef RPCUTIL_H
|
||||
#define RPCUTIL_H
|
||||
|
||||
/*Forward*/
|
||||
struct RPCnode;
|
||||
|
||||
extern int rpcstrindex(char* s, char* match);
|
||||
|
||||
extern void rpccollectnodepath(struct RPCnode*, NClist* path);
|
||||
|
||||
#endif /*RPCUTIL_H*/
|
19
librpc/t_cdmr.c
Normal file
19
librpc/t_cdmr.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* This example program is part of Unidata's netCDF library for
|
||||
scientific data access.
|
||||
|
||||
How about a short, but meaningful, netCDF program?
|
||||
|
||||
Ed Hartnett, 6/19/4
|
||||
$Id: simple.c,v 1.1 2004/07/26 14:04:42 ed Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <netcdf.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
352
librpc/testaux.c
Normal file
352
librpc/testaux.c
Normal file
@ -0,0 +1,352 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/ncgen/offsets.c,v 1.1 2009/09/25 18:22:40 dmh Exp $
|
||||
*********************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <netcdf.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ncaux.h"
|
||||
#include "ncaux.c"
|
||||
|
||||
static int debug = 0;
|
||||
|
||||
#define COMP_ALIGNMENT1(DST,TYPE1,TYPE) {\
|
||||
struct {TYPE1 f1; TYPE x;} tmp; \
|
||||
DST.typename = #TYPE ; \
|
||||
DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
|
||||
|
||||
#define COMP_ALIGNMENT2(DST,TYPE1,TYPE2,TYPE) {\
|
||||
struct {TYPE1 f1, TYPE2 f2; TYPE x;} tmp; \
|
||||
DST.typename = #TYPE ; \
|
||||
DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
|
||||
|
||||
#define COMP_SIZE0(DST,TYPE1,TYPE2) {\
|
||||
struct {TYPE1 c; TYPE2 x;} tmp; \
|
||||
DST = sizeof(tmp); }
|
||||
|
||||
/**************************************************/
|
||||
|
||||
int baseline_alignment[] = {
|
||||
0, 1, 1, 2, 2,
|
||||
4, 4, 4, 4, 8,
|
||||
8, 4, 8, 4, 4,
|
||||
};
|
||||
|
||||
struct Baseline {
|
||||
int size;
|
||||
int alignment;
|
||||
} baseline8[] = {
|
||||
{0,0}, {2,1}, {2,1}, {4,2}, {4,2},
|
||||
{8,4}, {8,4}, {8,4}, {8,4}, {16,8},
|
||||
{16,8}, {8,4}, {16,8}, {8,4}, {12,4},
|
||||
};
|
||||
|
||||
struct Baseline baseline16[] = {
|
||||
{0,0}, {16,2}, {4,2}, {4,2}, {4,2},
|
||||
{8,4}, {8,4}, {8,4}, {8,4}, {16,8},
|
||||
{16,8}, {8,4}, {16,8}, {8,4}, {8,4},
|
||||
};
|
||||
|
||||
struct Baseline baseline32[] = {
|
||||
{0,0}, {8,4}, {8,4}, {8,4}, {8,4},
|
||||
{8,4}, {8,4}, {8,4}, {8,4}, {16,8},
|
||||
{16,8}, {8,4}, {16,8}, {8,4}, {8,4},
|
||||
};
|
||||
|
||||
struct Baseline baseline64[] = {
|
||||
{0,0}, {16,8}, {16,8}, {16,8}, {16,8},
|
||||
{16,8}, {16,8}, {16,8}, {16,8}, {16,8},
|
||||
{16,8}, {16,8}, {16,8}, {16,8}, {16,8},
|
||||
};
|
||||
|
||||
static Typealignvec* vec8;
|
||||
static Typealignvec* vec16;
|
||||
static Typealignvec* vec32;
|
||||
static Typealignvec* vec64;
|
||||
static int* sizes8;
|
||||
static int* sizes16;
|
||||
static int* sizes32;
|
||||
static int* sizes64;
|
||||
|
||||
/**************************************************/
|
||||
|
||||
static char*
|
||||
padname(char* name)
|
||||
{
|
||||
#define MAX 20
|
||||
if(name == NULL) name = "null";
|
||||
int len = strlen(name);
|
||||
if(len > MAX) len = MAX;
|
||||
char* s = (char*)calloc(1,MAX+1);
|
||||
s[MAX+1] = '\0';
|
||||
strncpy(s,name,len);
|
||||
return s;
|
||||
}
|
||||
|
||||
static void
|
||||
setup(void)
|
||||
{
|
||||
vec8 = (Typealignvec*)malloc(sizeof(Typealignvec)*NCTYPES);
|
||||
vec16 = (Typealignvec*)malloc(sizeof(Typealignvec)*NCTYPES);
|
||||
vec32 = (Typealignvec*)malloc(sizeof(Typealignvec)*NCTYPES);
|
||||
vec64 = (Typealignvec*)malloc(sizeof(Typealignvec)*NCTYPES);
|
||||
sizes8 = (int*)malloc(sizeof(int)*NCTYPES);
|
||||
sizes16 = (int*)malloc(sizeof(int)*NCTYPES);
|
||||
sizes32 = (int*)malloc(sizeof(int)*NCTYPES);
|
||||
sizes64 = (int*)malloc(sizeof(int)*NCTYPES);
|
||||
|
||||
COMP_ALIGNMENT1(vec8[1],char,char)
|
||||
COMP_ALIGNMENT1(vec8[2],unsigned char,char)
|
||||
COMP_ALIGNMENT1(vec8[3],short,char)
|
||||
COMP_ALIGNMENT1(vec8[4],unsigned short,char)
|
||||
COMP_ALIGNMENT1(vec8[5],int,char)
|
||||
COMP_ALIGNMENT1(vec8[6],unsigned int,char)
|
||||
COMP_ALIGNMENT1(vec8[7],long,char)
|
||||
COMP_ALIGNMENT1(vec8[8],unsigned long,char)
|
||||
COMP_ALIGNMENT1(vec8[9],int64_t,char)
|
||||
COMP_ALIGNMENT1(vec8[10],uint64_t,char)
|
||||
COMP_ALIGNMENT1(vec8[11],float,char)
|
||||
COMP_ALIGNMENT1(vec8[12],double,char)
|
||||
COMP_ALIGNMENT1(vec8[13],void*,char)
|
||||
COMP_ALIGNMENT1(vec8[14],nc_vlen_t*,char)
|
||||
|
||||
COMP_ALIGNMENT1(vec16[1],char,short);
|
||||
COMP_ALIGNMENT1(vec16[2],unsigned char,short);
|
||||
COMP_ALIGNMENT1(vec16[3],short,short);
|
||||
COMP_ALIGNMENT1(vec16[4],unsigned short,short);
|
||||
COMP_ALIGNMENT1(vec16[5],int,short);
|
||||
COMP_ALIGNMENT1(vec16[6],unsigned int,short);
|
||||
COMP_ALIGNMENT1(vec16[7],long,short);
|
||||
COMP_ALIGNMENT1(vec16[8],unsigned long,short);
|
||||
COMP_ALIGNMENT1(vec16[9],int64_t,short);
|
||||
COMP_ALIGNMENT1(vec16[10],uint64_t,short);
|
||||
COMP_ALIGNMENT1(vec16[11],float,short);
|
||||
COMP_ALIGNMENT1(vec16[12],double,short);
|
||||
COMP_ALIGNMENT1(vec16[13],void*,short);
|
||||
COMP_ALIGNMENT1(vec16[14],nc_vlen_t*,short);
|
||||
|
||||
COMP_ALIGNMENT1(vec32[1],char,int);
|
||||
COMP_ALIGNMENT1(vec32[2],unsigned char,int);
|
||||
COMP_ALIGNMENT1(vec32[3],char,int);
|
||||
COMP_ALIGNMENT1(vec32[4],unsigned short,int);
|
||||
COMP_ALIGNMENT1(vec32[5],int,int);
|
||||
COMP_ALIGNMENT1(vec32[6],unsigned int,int);
|
||||
COMP_ALIGNMENT1(vec32[7],long,int);
|
||||
COMP_ALIGNMENT1(vec32[8],unsigned long,int);
|
||||
COMP_ALIGNMENT1(vec32[9],int64_t,int);
|
||||
COMP_ALIGNMENT1(vec32[10],uint64_t,int);
|
||||
COMP_ALIGNMENT1(vec32[11],float,int);
|
||||
COMP_ALIGNMENT1(vec32[12],double,int);
|
||||
COMP_ALIGNMENT1(vec32[13],void*,int);
|
||||
COMP_ALIGNMENT1(vec32[14],nc_vlen_t*,int);
|
||||
|
||||
COMP_ALIGNMENT1(vec64[1],char,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[2],unsigned char,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[3],char,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[4],unsigned short,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[5],int,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[6],unsigned int,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[7],long,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[8],unsigned long,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[9],uint64_t,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[10],uint64_t,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[11],float,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[12],double,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[13],void*,uint64_t);
|
||||
COMP_ALIGNMENT1(vec64[14],nc_vlen_t*,uint64_t);
|
||||
|
||||
COMP_SIZE0(sizes8[1],char,char);
|
||||
COMP_SIZE0(sizes8[2],unsigned char,char);
|
||||
COMP_SIZE0(sizes8[3],short,char);
|
||||
COMP_SIZE0(sizes8[4],unsigned short,char);
|
||||
COMP_SIZE0(sizes8[5],int,char);
|
||||
COMP_SIZE0(sizes8[6],unsigned int,char);
|
||||
COMP_SIZE0(sizes8[7],long,char);
|
||||
COMP_SIZE0(sizes8[8],unsigned long,char);
|
||||
COMP_SIZE0(sizes8[9],uint64_t,char);
|
||||
COMP_SIZE0(sizes8[10],uint64_t,char);
|
||||
COMP_SIZE0(sizes8[11],float,char);
|
||||
COMP_SIZE0(sizes8[12],double,char) ;
|
||||
COMP_SIZE0(sizes8[13],void*,char);
|
||||
COMP_SIZE0(sizes8[14],nc_vlen_t,char);
|
||||
|
||||
COMP_SIZE0(sizes16[1],char,uint64_t);
|
||||
COMP_SIZE0(sizes16[2],unsigned char,short);
|
||||
COMP_SIZE0(sizes16[3],short,short);
|
||||
COMP_SIZE0(sizes16[4],unsigned short,short);
|
||||
COMP_SIZE0(sizes16[5],int,short);
|
||||
COMP_SIZE0(sizes16[6],unsigned int,short);
|
||||
COMP_SIZE0(sizes16[7],long,short);
|
||||
COMP_SIZE0(sizes16[8],unsigned long,short);
|
||||
COMP_SIZE0(sizes16[9],uint64_t,short);
|
||||
COMP_SIZE0(sizes16[10],uint64_t,short);
|
||||
COMP_SIZE0(sizes16[11],float,short);
|
||||
COMP_SIZE0(sizes16[12],double,short) ;
|
||||
COMP_SIZE0(sizes16[13],void*,short);
|
||||
COMP_SIZE0(sizes16[14],nc_vlen_t*,short);
|
||||
|
||||
COMP_SIZE0(sizes32[1],char,int);
|
||||
COMP_SIZE0(sizes32[2],unsigned char,int);
|
||||
COMP_SIZE0(sizes32[3],short,int);
|
||||
COMP_SIZE0(sizes32[4],unsigned short,int);
|
||||
COMP_SIZE0(sizes32[5],int,int);
|
||||
COMP_SIZE0(sizes32[6],unsigned int,int);
|
||||
COMP_SIZE0(sizes32[7],long,int);
|
||||
COMP_SIZE0(sizes32[8],unsigned long,int);
|
||||
COMP_SIZE0(sizes32[9],uint64_t,int);
|
||||
COMP_SIZE0(sizes32[10],uint64_t,int);
|
||||
COMP_SIZE0(sizes32[11],float,int);
|
||||
COMP_SIZE0(sizes32[12],double,int) ;
|
||||
COMP_SIZE0(sizes32[13],void*,int);
|
||||
COMP_SIZE0(sizes32[14],nc_vlen_t*,int);
|
||||
|
||||
COMP_SIZE0(sizes64[1],char,uint64_t);
|
||||
COMP_SIZE0(sizes64[2],unsigned char,uint64_t);
|
||||
COMP_SIZE0(sizes64[3],short,uint64_t);
|
||||
COMP_SIZE0(sizes64[4],unsigned short,uint64_t);
|
||||
COMP_SIZE0(sizes64[5],int,uint64_t);
|
||||
COMP_SIZE0(sizes64[6],unsigned int,uint64_t);
|
||||
COMP_SIZE0(sizes64[7],long,uint64_t);
|
||||
COMP_SIZE0(sizes64[8],unsigned long,uint64_t);
|
||||
COMP_SIZE0(sizes64[9],uint64_t,uint64_t);
|
||||
COMP_SIZE0(sizes64[10],uint64_t,uint64_t);
|
||||
COMP_SIZE0(sizes64[11],float,uint64_t);
|
||||
COMP_SIZE0(sizes64[12],double,uint64_t) ;
|
||||
COMP_SIZE0(sizes64[13],void*,uint64_t);
|
||||
COMP_SIZE0(sizes64[14],nc_vlen_t*,uint64_t);
|
||||
}
|
||||
|
||||
static void
|
||||
report(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("Type alignments:\n");
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
printf("%s: alignment=%2d\n",
|
||||
padname(vec[i].typename),vec[i].alignment);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf("Paired struct sizes and alignment:\n");
|
||||
|
||||
printf("\n");
|
||||
printf("int8 vs other types\n");
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
printf("char vs %s: size=%2d alignment=%2d\n",
|
||||
padname(vec[i].typename),sizes8[i],vec8[i].alignment);
|
||||
}
|
||||
printf("\n");
|
||||
printf("int16 vs other types\n");
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
printf("short vs %s: size=%2d alignment=%2d\n",
|
||||
padname(vec[i].typename),sizes16[i],vec16[i].alignment);
|
||||
}
|
||||
printf("\n");
|
||||
printf("int32 vs other types\n");
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
printf("int vs %s: size=%2d alignment=%2d\n",
|
||||
padname(vec[i].typename),sizes32[i],vec32[i].alignment);
|
||||
}
|
||||
printf("\n");
|
||||
printf("int64 vs other types\n");
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
printf("long long vs %s: size=%2d alignment=%2d\n",
|
||||
padname(vec[i].typename),sizes64[i],vec64[i].alignment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
verify(void)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
if(vec[i].alignment != baseline_alignment[i]) {
|
||||
fprintf(stderr,"*** FAIL: verify alignment: %s\n",vec[i].typename);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
if(sizes8[i] != baseline8[i].size) {
|
||||
fprintf(stderr,"*** FAIL: verify size: uint8 vs %s\n",vec8[i].typename);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
if(sizes16[i] != baseline16[i].size) {
|
||||
fprintf(stderr,"*** FAIL: verify size: uint16 vs %s\n",vec16[i].typename);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
if(sizes32[i] != baseline32[i].size) {
|
||||
fprintf(stderr,"*** FAIL: verify size: uint32 vs %s\n",vec32[i].typename);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<NCTYPES;i++) {
|
||||
if(sizes64[i] != baseline64[i].size) {
|
||||
fprintf(stderr,"*** FAIL: verify size: uint64 vs %s\n",vec64[i].typename);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* Create a struct using the ncaux functions and check the alignment */
|
||||
static int
|
||||
test1(void)
|
||||
{
|
||||
int status = NC_NOERR;
|
||||
void* tag;
|
||||
int tid, ncid;
|
||||
|
||||
status = nc_create("./tmp.nc",NC_CLOBBER|NC_NETCDF4,&ncid);
|
||||
if(status) goto fail;
|
||||
status = ncaux_begin_compound(ncid,"test",NCAUX_ALIGN_C,&tag);
|
||||
if(status) goto fail;
|
||||
status = ncaux_add_field(tag,"f1", NC_INT,0,NULL);
|
||||
if(status) goto fail;
|
||||
status = ncaux_end_compound(tag,&tid);
|
||||
if(status) goto fail;
|
||||
|
||||
return status;
|
||||
|
||||
fail:
|
||||
fprintf(stderr,"***FAIL: test1: (%d) %s\n",status,nc_strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
compute_alignments();
|
||||
|
||||
setup();
|
||||
if(debug) report();
|
||||
if(!verify()) goto fail;
|
||||
|
||||
fprintf(stderr,"***PASS: testaux\n");
|
||||
|
||||
exit(0);
|
||||
|
||||
fail:
|
||||
exit(1);
|
||||
}
|
80
librpc/unknown/Make0
Normal file
80
librpc/unknown/Make0
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
PREFIX=/tmp
|
||||
|
||||
NCLIB=../liblib/.libs/libnetcdf.a
|
||||
NCINCL=-I../include -I${HDF5DIR}/include
|
||||
|
||||
#HDF5DIR=/local
|
||||
HDF5DIR=/share/ed/local/${HOST}
|
||||
CURLDIR=/usr/local
|
||||
CURLDIR=${HDF5DIR}
|
||||
|
||||
HDFLIBS=-L${HDF5DIR}/lib -lhdf5_hl -lhdf5
|
||||
CURLLIB=-L${CURLDIR}/lib -lcurl -lz
|
||||
CURLINCL=-I${CURLDIR}/include
|
||||
#RPCLIB=-lnsl
|
||||
ZLIB=-L${HDF5DIR}/lib -lz
|
||||
TESTURL=file:///upc/share/dmh/nc/netcdf-3/ncdap_test/testdata3
|
||||
VALGRIND=valgrind --leak-check=full
|
||||
|
||||
OCLIB=../libncdap3/oc/.libs/liboc.a
|
||||
OCINCL=-I../libncdap3/oc
|
||||
|
||||
OTHERLIBS=-lm
|
||||
|
||||
RPATH=-Wl,-rpath,${HDF5DIR}/lib -Wl,-rpath,${CURLDIR}/lib
|
||||
|
||||
# Might want to specify a particular C compiler with flags
|
||||
#CC=cc
|
||||
CFLAGS=-g -O0 -Wall -DHAVE_CONFIG_H
|
||||
#CFLAGS=-DHAVE_CONFIG_H
|
||||
|
||||
GFLAGS=-g
|
||||
#############################################
|
||||
|
||||
LIBS=${NCLIB} ${CURLLIB} ${HDFLIBS} ${ZLIB} ${OTHERLIBS} ${RPCLIB}
|
||||
INCL=-I. -I.. -I../include -I../ncdump ${OCINCL} ${NCINCL} ${CURLINCL}
|
||||
|
||||
##################################################
|
||||
|
||||
all:: ncd
|
||||
|
||||
##################################################
|
||||
clean::
|
||||
rm -f *.o *.exe ncdump.exe ncd.exe
|
||||
rm -f *.stackdump
|
||||
|
||||
##################################################
|
||||
# ncd
|
||||
S=chunkspec.c dimmap.c dumplib.c indent.c ncdump.c nciter.c nctime.c utils.c vardata.c
|
||||
|
||||
SRC=${S:%.c=../ncdump/%.c}
|
||||
OBJ=${S:%.c=%.o}
|
||||
|
||||
ncd::
|
||||
cd .. ; make
|
||||
${CC} ${CFLAGS} ${GFLAGS} -c ${INCL} ${SRC}
|
||||
${CC} -g -O0 -o ncd ${GFLAGS} ${OBJ} ${LIBS} ${RPATH}
|
||||
|
||||
ncdonly::
|
||||
${CC} ${CFLAGS} ${GFLAGS} -c ${INCL} ${SRC}
|
||||
${CC} -o ncd ${GFLAGS} ${OBJ} ${LIBS} ${RPATH}
|
||||
|
||||
URL=[cdmremote]http://motherlode.ucar.edu/thredds/cdmremote/nws/upperair/ncdecoded/files/Upperair_20110517_0000.nc
|
||||
#?wmoStaNum
|
||||
|
||||
q0::
|
||||
./ncd "${URL}"
|
||||
qq::
|
||||
gdb --args ./ncd "${URL}"
|
||||
qv::
|
||||
${VALGRIND} ./ncd "${URL}"
|
||||
|
||||
qh::
|
||||
./ncd -h "${URL}"
|
||||
qqh::
|
||||
gdb --args ./ncd -h "${URL}"
|
||||
qvh::
|
||||
${VALGRIND} ./ncd -h "${URL}"
|
||||
|
||||
|
79
librpc/unknown/Makefile.am
Normal file
79
librpc/unknown/Makefile.am
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
## This is a automake file, part of Unidata's netCDF package.
|
||||
# Copyright 2010, see the COPYRIGHT file for more information.
|
||||
|
||||
# This builds the netcdf-4 version of the opendap client.
|
||||
|
||||
# $Id: Makefile.am,v 1.18 2010/05/29 18:45:47 dmh Exp $
|
||||
|
||||
# Put together AM_CPPFLAGS and AM_LDFLAGS.
|
||||
include $(top_srcdir)/lib_flags.am
|
||||
|
||||
DISTCLEANFILES =
|
||||
CLEANFILES =
|
||||
EXTRA_DIST =
|
||||
LDADD=
|
||||
|
||||
ASTJAR=ast.jar
|
||||
|
||||
# RPC Sources
|
||||
|
||||
HDRS=\
|
||||
protorpc.h \
|
||||
nc_path.h \
|
||||
rpc_includes.h \
|
||||
rpc.h \
|
||||
rpccurl.h \
|
||||
rpcdebug.h \
|
||||
rpcdispatch.h \
|
||||
rpcutil.h
|
||||
|
||||
SRC=\
|
||||
protorpc.c \
|
||||
nc_path.c \
|
||||
rpccurl.c \
|
||||
rpcdebug.c \
|
||||
rpcdispatch.c \
|
||||
rpcserialize.c \
|
||||
rpcutil.c
|
||||
|
||||
if BUILD_RPC
|
||||
|
||||
noinst_LTLIBRARIES = librpcclient.la librcpserver.la
|
||||
|
||||
# Build convenience library
|
||||
librpcclient_la_SOURCES = $(SRC) $(HDRS)
|
||||
#librpcserver_la_SOURCES = $(SRC) $(HDRS)
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libdispatch \
|
||||
-I$(top_srcdir)/libsrc
|
||||
|
||||
# Define the load libraries
|
||||
LDADD += \
|
||||
${top_builddir}/libsrc/libnetcdf3.la \
|
||||
${top_builddir}/libdispatch/libdispatch.la
|
||||
|
||||
if USE_NETCDF4
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/libsrc4
|
||||
|
||||
# Define the load libraries
|
||||
LDADD += ${top_builddir}/libsrc4/libnetcdf4.la
|
||||
|
||||
endif #USE_NETCDF4
|
||||
|
||||
if BUILD_V2
|
||||
LDADD += ${top_builddir}/libdispatch/libnetcdf2.la
|
||||
endif # BUILD_V2
|
||||
|
||||
##################################################
|
||||
# Generate the augmented ncstream structures
|
||||
|
||||
EXTRA_DIST += ast.jar protorpc.proto
|
||||
|
||||
protorpc.c protorpc.h: protorpc.proto ast.jar
|
||||
java -jar ast.jar -WdT -I. protorpc.proto
|
||||
|
||||
##################################################
|
||||
|
||||
endif # BUILD_RPC
|
BIN
librpc/unknown/ast.jar
Normal file
BIN
librpc/unknown/ast.jar
Normal file
Binary file not shown.
16185
librpc/unknown/protorpc.c
Normal file
16185
librpc/unknown/protorpc.c
Normal file
File diff suppressed because it is too large
Load Diff
2013
librpc/unknown/protorpc.h
Normal file
2013
librpc/unknown/protorpc.h
Normal file
File diff suppressed because it is too large
Load Diff
1012
librpc/unknown/protorpc.proto
Normal file
1012
librpc/unknown/protorpc.proto
Normal file
File diff suppressed because it is too large
Load Diff
18
librpc/unknown/rpc.h
Normal file
18
librpc/unknown/rpc.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef NCRPC_H
|
||||
#define NCRPC_H
|
||||
|
||||
/**************************************************/
|
||||
/*Forwards*/
|
||||
struct NC;
|
||||
struct NC_URI;
|
||||
struct NClist;
|
||||
|
||||
|
||||
#endif /*NCRPC_H*/
|
457
librpc/unknown/rpccurl.c
Normal file
457
librpc/unknown/rpccurl.c
Normal file
@ -0,0 +1,457 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/* "$Id$" */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "curlwrap.h"
|
||||
|
||||
#include "nclist.h"
|
||||
#include "nclog.h"
|
||||
|
||||
#include "netcdf.h"
|
||||
#include "nc.h"
|
||||
#include "nc4internal.h"
|
||||
#include "nccr.h"
|
||||
#include "ast.h"
|
||||
#include "crutil.h"
|
||||
|
||||
static char* combinecredentials(const char* user, const char* pwd);
|
||||
static size_t WriteMemoryCallback(void*, size_t, size_t, void*);
|
||||
|
||||
/* Condition on libcurl version */
|
||||
#ifndef HAVE_CURLOPT_KEYPASSWD
|
||||
/* Set up an alias */
|
||||
#define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD
|
||||
#endif
|
||||
|
||||
struct NCCR_CALLBACK_DATA {
|
||||
size_t alloc;
|
||||
size_t pos;
|
||||
unsigned char* data;
|
||||
};
|
||||
|
||||
static size_t WriteMemoryCallback(void*, size_t, size_t, void*);
|
||||
|
||||
int
|
||||
nccr_curlopen(CURL** curlp)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat;
|
||||
CURL* curl;
|
||||
/* initialize curl*/
|
||||
curl = curl_easy_init();
|
||||
if(curl == NULL)
|
||||
stat = NC_ECURL;
|
||||
else {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||
if(cstat != CURLE_OK)
|
||||
stat = NC_ECURL;
|
||||
/*some servers don't like requests that are made without a user-agent*/
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
|
||||
if(cstat != CURLE_OK)
|
||||
stat = NC_ECURL;
|
||||
}
|
||||
if(curlp)
|
||||
*curlp = curl;
|
||||
return stat;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_curlclose(CURL* curl)
|
||||
{
|
||||
if(curl != NULL)
|
||||
curl_easy_cleanup(curl);
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_fetchurl(NCCDMR* cdmr, CURL* curl, char* url, bytes_t* buf, long* filetime)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
struct NCCR_CALLBACK_DATA callback_data;
|
||||
int index, first;
|
||||
|
||||
/* If required, report the url */
|
||||
if(cdmr->controls & SHOWFETCH) {
|
||||
nclog(NCLOGNOTE,"fetch url: %s",url);
|
||||
}
|
||||
|
||||
callback_data.alloc = 0;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if(cstat != CURLE_OK)
|
||||
goto fail;
|
||||
|
||||
/* send all data to this function */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||
if(cstat != CURLE_OK)
|
||||
goto fail;
|
||||
|
||||
/* we pass our file to the callback function */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&callback_data);
|
||||
if(cstat != CURLE_OK)
|
||||
goto fail;
|
||||
|
||||
/* One last thing; always try to get the last modified time */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FILETIME, (long)1);
|
||||
|
||||
/* fetch */
|
||||
cstat = curl_easy_perform(curl);
|
||||
if(cstat == CURLE_PARTIAL_FILE) {
|
||||
/* Log it but otherwise ignore */
|
||||
nclog(NCLOGERR,"curl error: %s; ignored",
|
||||
curl_easy_strerror(cstat));
|
||||
cstat = CURLE_OK;
|
||||
}
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* pull the data */
|
||||
if(buf) {
|
||||
buf->nbytes = callback_data.pos;
|
||||
buf->bytes = callback_data.data;
|
||||
callback_data.data = NULL;
|
||||
}
|
||||
|
||||
/* Get the last modified time */
|
||||
if(filetime != NULL)
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_FILETIME,filetime);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* Check for potential html return */
|
||||
/* skip leading whitespace */
|
||||
for(first=0;first<buf->nbytes;first++) {
|
||||
char* p = strchr(" \t\r\n",buf->bytes[first]);
|
||||
if(p == NULL)
|
||||
break;
|
||||
}
|
||||
index = crstrindex((char*)buf->bytes,"<html");
|
||||
if(index >= 0) {
|
||||
int endex;
|
||||
/* Search for </html> */
|
||||
endex = crstrindex((char*)buf->bytes,"</html>");
|
||||
if(endex >= 0) endex += 7; else endex = buf->nbytes-1;
|
||||
nclog(NCLOGWARN,"Probable Server error");
|
||||
nclogtextn(NCLOGWARN,(char*)buf->bytes+first,endex-first);
|
||||
nclogtext(NCLOGWARN,"\n");
|
||||
}
|
||||
return stat;
|
||||
|
||||
fail:
|
||||
nclog(NCLOGERR,"curl error: %s", curl_easy_strerror(cstat));
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
static size_t
|
||||
WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *cdata)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
struct NCCR_CALLBACK_DATA* callback_data = (struct NCCR_CALLBACK_DATA*)cdata;
|
||||
|
||||
if(realsize == 0)
|
||||
nclog(NCLOGERR,"WriteMemoryCallback: zero sized chunk");
|
||||
|
||||
if(callback_data->alloc == 0) {
|
||||
callback_data->data = (unsigned char*)malloc(realsize);
|
||||
callback_data->alloc = realsize;
|
||||
callback_data->pos = 0;
|
||||
}
|
||||
|
||||
if(callback_data->alloc - callback_data->pos < realsize) {
|
||||
callback_data->data = (unsigned char*)realloc(callback_data->data,
|
||||
callback_data->alloc+realsize);
|
||||
callback_data->alloc += realsize;
|
||||
}
|
||||
memcpy(callback_data->data+callback_data->pos,ptr,realsize);
|
||||
callback_data->pos += realsize;
|
||||
return realsize;
|
||||
}
|
||||
|
||||
long
|
||||
nccr_fetchhttpcode(CURL* curl)
|
||||
{
|
||||
long httpcode;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
/* Extract the http code */
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&httpcode);
|
||||
if(cstat != CURLE_OK) httpcode = 0;
|
||||
return httpcode;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_fetchlastmodified(CURL* curl, char* url, long* filetime)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if(cstat != CURLE_OK)
|
||||
goto fail;
|
||||
|
||||
/* Ask for head */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30); /* 30sec timeout*/
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FILETIME, (long)1);
|
||||
|
||||
cstat = curl_easy_perform(curl);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
if(filetime != NULL)
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_FILETIME,filetime);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
return stat;
|
||||
|
||||
fail:
|
||||
nclog(NCLOGERR,"curl error: %s\n", curl_easy_strerror(cstat));
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
|
||||
/* Set various general curl flags */
|
||||
int
|
||||
nccr_set_curl_flags(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat = CURLE_OK;
|
||||
NCCURLSTATE* state = &nccr->curl;
|
||||
|
||||
#ifdef CURLOPT_ENCODING
|
||||
if (state->compress) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_ENCODING, 'deflate, gzip');
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_ENCODING=deflat, gzip"));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (state->cookiejar || state->cookiefile) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_COOKIESESSION=1"));
|
||||
#endif
|
||||
}
|
||||
if (state->cookiejar) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIEJAR, state->cookiejar);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_COOKIEJAR=%s",state->cookiejar);
|
||||
#endif
|
||||
}
|
||||
if (state->cookiefile) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIEFILE, state->cookiefile);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_COOKIEFILE=%s",state->cookiefile);
|
||||
#endif
|
||||
}
|
||||
if (state->verbose) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_VERBOSE=%ld",1L);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Following are always set */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_FOLLOWLOCATION=%ld",1L);
|
||||
#endif
|
||||
return NC_NOERR;
|
||||
|
||||
fail:
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_set_proxy(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat;
|
||||
struct NCCURLSTATE* state = &nccr->curl;
|
||||
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXY, state->host);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXY=%s",state->host);
|
||||
#endif
|
||||
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, state->port);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYPORT=%d",state->port);
|
||||
#endif
|
||||
|
||||
if (state->username) {
|
||||
char *combined = combinecredentials(state->username,state->password);
|
||||
if (!combined) return NC_ENOMEM;
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, combined);
|
||||
free(combined);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYUSERPWD=%s",combined);
|
||||
#endif
|
||||
#ifdef CURLOPT_PROXYAUTH
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYAUTH=%ld",(long)CURLAUTH_ANY);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
int
|
||||
nccr_set_ssl(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat = CURLE_OK;
|
||||
struct NCCURLSTATE* state = &nccr->curl;
|
||||
long verify = (state->validate?1L:0L);
|
||||
cstat=curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, verify);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSL_VERIFYPEER=%ld",verify);
|
||||
#endif
|
||||
cstat=curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (verify?2L:0L));
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSL_VERIFYHOST=%ld",(verify?2L:0L));
|
||||
#endif
|
||||
{
|
||||
if(state->certificate) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_SSLCERT, state->certificate);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLCERT=%s",state->certificate);
|
||||
#endif
|
||||
}
|
||||
if(state->key) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_SSLKEY, state->key);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLKEY=%s",state->key);
|
||||
#endif
|
||||
}
|
||||
if(state->keypasswd) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_KEYPASSWD, state->keypasswd);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLKEY=%s",state->key);
|
||||
#endif
|
||||
}
|
||||
if(state->cainfo) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CAINFO, state->cainfo);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_CAINFO=%s",state->cainfo);
|
||||
#endif
|
||||
}
|
||||
if(state->capath) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CAPATH, state->capath);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_CAPATH=%s",state->capath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return NC_NOERR;
|
||||
|
||||
fail:
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
/* This is called with arguments while the other functions in this file are
|
||||
* used with global values read from the.dodsrc file. The reason is that
|
||||
* we may have multiple password sources.
|
||||
*/
|
||||
int
|
||||
nccr_set_user_password(CURL* curl, const char *userC, const char *passwordC)
|
||||
{
|
||||
CURLcode cstat;
|
||||
char* combined = NULL;
|
||||
|
||||
if(userC == NULL && passwordC == NULL) return NC_NOERR;
|
||||
if(userC == NULL) userC = "";
|
||||
if(passwordC == NULL) passwordC = "";
|
||||
|
||||
combined = combinecredentials(userC,passwordC);
|
||||
if (!combined) return NC_ENOMEM;
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_USERPWD, combined);
|
||||
if (cstat != CURLE_OK) goto done;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_USERPWD=%s",combined);
|
||||
#endif
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long) CURLAUTH_ANY);
|
||||
if (cstat != CURLE_OK) goto done;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_HTTPAUTH=%ld",(long)CURLAUTH_ANY);
|
||||
#endif
|
||||
|
||||
done:
|
||||
if(combined != NULL) free(combined);
|
||||
return (cstat == CURLE_OK?NC_NOERR:NC_ECURL);
|
||||
}
|
||||
|
||||
static char*
|
||||
combinecredentials(const char* user, const char* pwd)
|
||||
{
|
||||
int userPassSize = strlen(user) + strlen(pwd) + 2;
|
||||
char *userPassword = malloc(sizeof(char) * userPassSize);
|
||||
if (!userPassword) {
|
||||
nclog(NCLOGERR,"Out of Memory");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(userPassword, user);
|
||||
strcat(userPassword, ":");
|
||||
strcat(userPassword, pwd);
|
||||
return userPassword;
|
||||
}
|
54
librpc/unknown/rpccurl.h
Normal file
54
librpc/unknown/rpccurl.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/* "$Id$" */
|
||||
|
||||
#ifndef RPCCURL_H
|
||||
#define RPCCURL_H
|
||||
|
||||
/*Forward*/
|
||||
struct NCRPC;
|
||||
struct bytes_t;
|
||||
|
||||
extern int rpc_curlopen(CURL**);
|
||||
extern int rpc_curlclose(CURL*);
|
||||
|
||||
extern int rpc_fetchurl(struct NCRPC*, CURL*, char* url, struct bytes_t* buf, long* filetime);
|
||||
extern long rpc_fetchhttpcode(CURL* curl);
|
||||
extern int rpc_fetchlastmodified(CURL* curl, char* url, long* filetime);
|
||||
|
||||
extern int rpc_set_curl_flags(CURL*, struct NCRPC*);
|
||||
extern int rpc_set_proxy(CURL*, struct NCRPC*);
|
||||
extern int rpc_set_ssl(CURL*, struct NCRPC*);
|
||||
extern int rpc_set_user_password(CURL*, const char *userC, const char *passwordC);
|
||||
|
||||
#endif /*RPCCURL_H*/
|
821
librpc/unknown/rpcdispatch.c
Normal file
821
librpc/unknown/rpcdispatch.c
Normal file
@ -0,0 +1,821 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap4/ncd4dispatch.c,v 1.8 2010/05/27 21:34:10 dmh Exp $
|
||||
*********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "nclog.h"
|
||||
|
||||
#include "netcdf.h"
|
||||
#include "nc.h"
|
||||
#include "ncdispatch.h"
|
||||
#include "nc4internal.h"
|
||||
|
||||
#include "ncrpc.h"
|
||||
#include "ncrpcdispatch.h"
|
||||
|
||||
int
|
||||
NCRPC_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
int useparallel, void* parameters,
|
||||
NC_Dispatch* dispatcher, NC** ncidp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Create* request = (Create*)calloc(1,sizeof(Create));
|
||||
Create_Return* response = NULL;
|
||||
request->path = nulldup(path);
|
||||
request->cmode = cmode;
|
||||
request->initialsz = initialsz;
|
||||
request->basepe = basepe;
|
||||
request->use_parallel = useparallel;
|
||||
/* currently, chunksizehint is ignored */
|
||||
/* currently, parameters must always be null */
|
||||
if(parameters != NULL) {
|
||||
ncstat = NC_ENOPAR; /* not supported */
|
||||
goto fail;
|
||||
}
|
||||
ncstat = rpc_send(NCRPC_CREATE,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_CREATE,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(ncidp != NULL) *ncidp = response->ncid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_open(const char *path, int cmode,
|
||||
int basepe, size_t *chunksizehintp,
|
||||
int use_parallel, void* parameters,
|
||||
NC_Dispatch*, NC**)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Open* request = (Open*)calloc(1,sizeof(Open));
|
||||
Open_Return* response = NULL;
|
||||
request->path = nulldup(path);
|
||||
request->cmode = cmode;
|
||||
request->initialsz = initialsz;
|
||||
request->basepe = basepe;
|
||||
request->use_parallel = useparallel;
|
||||
/* currently, parameters must always be null */
|
||||
if(parameters != NULL) {
|
||||
ncstat = NC_ENOPAR; /* not supported */
|
||||
goto fail;
|
||||
}
|
||||
ncstat = rpc_send(NCRPC_OPEN,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_OPEN,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(ncidp != NULL) *ncidp = response->ncid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_redef(int ncid)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Redef* request = (Redef*)calloc(1,sizeof(Redef));
|
||||
Redef_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
ncstat = rpc_send(NCRPC_REDEF,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_REDEF,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC__enddef(int ncid, size_t h_minfree, size_t v_align,
|
||||
size_t v_minfree, size_t r_align)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Enddef* request = (Enddef*)calloc(1,sizeof(Enddef));
|
||||
Enddef_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->h_minfree = h_minfree;
|
||||
request->v_align = v_align;
|
||||
request->v_minfree = v_minfree
|
||||
request->r_align = r_align;
|
||||
ncstat = rpc_send(NCRPC_ENDDEF,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_ENDDEF,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_sync(int ncid)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Sync* request = (Sync*)calloc(1,sizeof(Sync));
|
||||
Sync_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
ncstat = rpc_send(NCRPC_SYNC,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_SYNC,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_abort(int ncid)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Abort* request = (Abort*)calloc(1,sizeof(Abort));
|
||||
Abort_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
ncstat = rpc_send(NCRPC_ABORT,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_ABORT,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_close(int ncid)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Close* request = (Close*)calloc(1,sizeof(Close));
|
||||
Close_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
ncstat = rpc_send(NCRPC_CLOSE,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_CLOSE,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_set_fill(int ncid, int fillmode, int *old_modep)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Set_Fill* request = (Set_Fill*)calloc(1,sizeof(Set_Fill));
|
||||
Set_Fill_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->fillmode = fillmode;
|
||||
ncstat = rpc_send(NCRPC_SET_FILL,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_SET_FILL,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(old_modep) *old_modep = response->oldmode;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_base_pe(int ncid, int *pe)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Inq_Base_PE* request = (Inq_Base_PE*)calloc(1,sizeof(Inq_Base_PE));
|
||||
Inq_Base_PE_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
ncstat = rpc_send(NCRPC_INQ_BASE_PE,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_INQ_BASE_PE,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(pe != NULL) *pe = response->pe;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_set_base_pe(int ncid, int pe)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Set_Base_PE* request = (Set_Base_PE*)calloc(1,sizeof(Set_Base_PE));
|
||||
Set_Base_PE_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->pe = pe;
|
||||
ncstat = rpc_send(NCRPC_SET_BASE_PE,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_SET_BASE_PE,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_format(int ncid, int *formatp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Inq_Format* request = (Inq_Format*)calloc(1,sizeof(Inq_Format));
|
||||
Inq_Format_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
ncstat = rpc_send(NCRPC_INQ_FORMAT,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_INQ_FORMAT,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(formatp != NULL) *formatp = response->format;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Inq* request = (Inq*)calloc(1,sizeof(Inq));
|
||||
Inq_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
ncstat = rpc_send(NCRPC_INQ,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_INQ,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(ndimsp != NULL) *ndimsp = response->ndims;
|
||||
if(nvarsp != NULL) *nvarsp = response->nvars;
|
||||
if(nattsp != NULL) *nattsp = response->natts;
|
||||
if(unlimidimidp != NULL) *unlimidimidp = response->unlimidimid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_type(int ncid, nc_type xtype, char* name, size_t* sizep)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Inq_Type* request = (Inq_Type*)calloc(1,sizeof(Inq_Type));
|
||||
Inq_Type_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->xtype = xtype;
|
||||
ncstat = rpc_send(NCRPC_INQ_TYPE,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_INQ_TYPE,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(name != NULL) strcpy(name,response->name);
|
||||
if(sizep != NULL) *size = response->size;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
/* Begin _dim */
|
||||
|
||||
int
|
||||
NCRPC_def_dim(int ncid, const char *name, size_t len, int *idp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Dim* request = (Def_Dim*)calloc(1,sizeof(Def_Dim));
|
||||
Def_Dim_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->name = nulldup(name);
|
||||
request->len = len;
|
||||
ncstat = rpc_send(NCRPC_DEF_DIM,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_DIM,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(idp != NULL) *idp = response->dimid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_typedimid(int ncid, const char *name, int *idp)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_unlimdim(int ncid, int *unlimdimidp)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_rename_dim(int ncid, int dimid, const char *name)
|
||||
{
|
||||
}
|
||||
|
||||
/* End _dim */
|
||||
/* Begin _att */
|
||||
|
||||
int
|
||||
NCRPC_inq_att(int ncid, int varid, const char *name,
|
||||
nc_type *xtypep, size_t *lenp)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_attid(int ncid, int varid, const char *name, int *idp)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_attname(int ncid, int varid, int attnum, char *name)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_rename_att(int ncid, int varid, const char *name, const char *newname)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_del_att(int ncid, int varid, const char*)
|
||||
{
|
||||
}
|
||||
|
||||
/* End _att */
|
||||
/* Begin {put,get}_att */
|
||||
|
||||
int
|
||||
NCRPC_get_att(int ncid, int varid, const char *name, void *value, nc_type)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_put_att(int ncid, int varid, const char *name, nc_type datatype,
|
||||
size_t len, const void *value, nc_type)
|
||||
{
|
||||
}
|
||||
|
||||
/* End {put,get}_att */
|
||||
/* Begin _var */
|
||||
|
||||
int
|
||||
NCRPC_def_var(int ncid, const char *name,
|
||||
nc_type xtype, int ndims, const int *dimidsp, int *varidp)
|
||||
{
|
||||
int i;
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Var* request = (Def_Var*)calloc(1,sizeof(Def_Var));
|
||||
Def_Var_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->name = nulldup(name);
|
||||
request->xtype = xtype;
|
||||
request->ndims = ndims;
|
||||
request->dimids.count = ndims;
|
||||
request->dimids.values = (int32_t*)calloc(ndims,sizeof(int32_t));
|
||||
for(i=0;i<ndims;i++)
|
||||
request->dimids.values[i] = dimidsp[i];
|
||||
ncstat = rpc_send(NCRPC_DEF_VAR,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_VAR,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(varidp != NULL) *varidp = response->varid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *ndimsp, int *dimidsp, int *nattsp,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_varid(int ncid, const char *name, int *varidp)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_rename_var(int ncid, int varid, const char *name)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_put_vara(int ncid, int varid,
|
||||
const size_t *start, const size_t *count,
|
||||
const void *value, nc_type)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_get_vara(int ncid, int varid,
|
||||
const size_t *start, const size_t *count,
|
||||
void *value, nc_type)
|
||||
{
|
||||
}
|
||||
|
||||
/* End _var */
|
||||
|
||||
/* netCDF4 API only */
|
||||
int
|
||||
NCRPC_var_par_access(int, int, int)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_ncid(int, const char *, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_grps(int, int *, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_grpname(int, char *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_grpname_full(int, size_t *, char *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_grp_parent(int, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_grp_full_ncid(int, const char *, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_varids(int, int * nvars, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_dimids(int, int * ndims, int *, int)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_typeids(int, int * ntypes, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_type_equal(int, nc_type, int, nc_type, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_grp(int ncid, const char* name, int* grpidp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Grp* request = (Def_Grp*)calloc(1,sizeof(Def_Grp));
|
||||
Def_Grp_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->name = nulldup(name);
|
||||
ncstat = rpc_send(NCRPC_DEF_GRP,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_GRP,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(grpidp != NULL) *grpidp = response->grpncid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_user_type(int, nc_type, char *, size_t *, nc_type *,
|
||||
size_t *, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_compound(int ncid, size_t size, const char* name, nc_type* typeidp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Compound* request = (Def_Compound*)calloc(1,sizeof(Def_Compound));
|
||||
Def_Compound_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->size = size;
|
||||
request->name = nulldup(name);
|
||||
ncstat = rpc_send(NCRPC_DEF_COMPOUND,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_COMPOUND,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(typeidp != NULL) *typeidp = response->typeid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_insert_compound(int, nc_type, const char *, size_t, nc_type)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_insert_array_compound(int, nc_type, const char *, size_t,
|
||||
nc_type, int, const int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_typeid(int, const char *, nc_type *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_compound_field(int, nc_type, int, char *, size_t *,
|
||||
nc_type *, int *, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_compound_fieldindex(int, nc_type, const char *, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_vlen(int ncid, const char* name, nc_type base_typeid, nc_type* idp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Vlen* request = (Def_Vlen*)calloc(1,sizeof(Def_Vlen));
|
||||
Def_Vlen_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->name = nulldup(name);
|
||||
request->base_typeid = base_typeid;
|
||||
ncstat = rpc_send(NCRPC_DEF_VLEN,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_VLEN,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(idp != NULL) *idp = response->typeid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_put_vlen_element(int, int, void *, size_t, const void *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_get_vlen_element(int, int, const void *, size_t *, void *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_enum(int ncid, nc_type basetypeid, const char* name, nc_type* idp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Enum* request = (Def_Enum*)calloc(1,sizeof(Def_Enum));
|
||||
Def_Enum_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->name = nulldup(name);
|
||||
request->basetypeid = basetypeid;
|
||||
ncstat = rpc_send(NCRPC_DEF_ENUM,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_ENUM,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(idp != NULL) *idp = response->typeid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_insert_enum(int, nc_type, const char *, const void *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_enum_member(int, nc_type, int, char *, void *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_enum_ident(int, nc_type, long long, char *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_opaque(int ncid, size_t size , const char* name, nc_type* idp)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Opaque* request = (Def_Opaque*)calloc(1,sizeof(Def_Opaque));
|
||||
Def_Opaque_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->name = nulldup(name);
|
||||
request->size = size;
|
||||
ncstat = rpc_send(NCRPC_DEF_OPAQUE,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_OPAQUE,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
if(idp != NULL) *idp = response->typeid;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_var_deflate(int ncid, int varid, int shuffle, int deflate, int deflatelevel)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Var_Deflate* request = (Def_Var_Deflate*)calloc(1,sizeof(Def_Var_Deflate));
|
||||
Def_Var_Deflate_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->varid varid;
|
||||
request->size = size;
|
||||
request->shuffle = (shuffle == NC_SHUFFLE?1:0);
|
||||
request->deflate = (deflate?1:0);
|
||||
request->deflatelevel = deflatelevel;
|
||||
ncstat = rpc_send(NCRPC_DEF_VAR_DEFLATE,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_VAR_DEFLATE,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_var_fletcher32(int ncid, int varid, int fletcher32)
|
||||
{
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Var_Fletcher32* request = (Def_Var_Fletcher32*)calloc(1,sizeof(Def_Var_Fletcher32));
|
||||
Def_Var_Fletcher32_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->varid varid;
|
||||
request->fletcher32 = (fletcher32 == NC_FLETCHER32?1:0);
|
||||
ncstat = rpc_send(NCRPC_DEF_VAR_FLETCHER32,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_VAR_FLETCHER32,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_var_chunking(int ncid, int varid, int contiguous, const size_t* chunksizes)
|
||||
{
|
||||
int i, ndims;
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Var_Chunking* request = (Def_Var_Chunking*)calloc(1,sizeof(Def_Var_Chunking));
|
||||
Def_Var_Chunking_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->varid varid;
|
||||
request->contiguous = (contiguous == NC_CONTIGUOUS?1:0);
|
||||
/* Get the number of dimensions */
|
||||
ncstat = nc_inq_ndims(ncid,&ndims);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
request->chunksizes.count = ndims;
|
||||
for(i=0;i<ndims;i++)
|
||||
request->chunksizes.values[i] = chunksizes[i];
|
||||
ncstat = rpc_send(NCRPC_DEF_VAR_CHUNKING,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_VAR_CHUNKING,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_var_fill(int ncid, int varid, int nofill, const void* fill_value)
|
||||
{
|
||||
int i, ndims;
|
||||
int ncstat = NC_NOERR;
|
||||
Def_Var_Fill* request = (Def_Var_Fill*)calloc(1,sizeof(Def_Var_Fill));
|
||||
Def_Var_Fill_Return* response = NULL;
|
||||
request->ncid = ncid;
|
||||
request->varid varid;
|
||||
request->nofill = (nofill == 1?1:0);
|
||||
/* Get the size of an instance */
|
||||
ncstat = nc_inq_ndims(ncid,&ndims);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
request->chunksizes.count = ndims;
|
||||
for(i=0;i<ndims;i++)
|
||||
request->chunksizes.values[i] = chunksizes[i];
|
||||
ncstat = rpc_send(NCRPC_DEF_VAR_FILL,(void*)request);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = rpc_receive(NCRPC_DEF_VAR_FILL,(void*)response);
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
ncstat = response->ncstatus;
|
||||
if(ncstat != NC_NOERR) goto fail;
|
||||
return ncstat;
|
||||
|
||||
fail:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_def_var_endian(int, int, int)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_set_var_chunk_cache(int, int, size_t, size_t, float)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_get_var_chunk_cache(int, int, size_t *, size_t *, float *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_inq_unlimdims(int, int *, int *)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_show_metadata(int)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NCRPC_initialize(void)
|
||||
{
|
||||
}
|
300
librpc/unknown/rpcdispatch.h
Normal file
300
librpc/unknown/rpcdispatch.h
Normal file
@ -0,0 +1,300 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata. See netcdf/COPYRIGHT file for copying
|
||||
* and redistribution conditions.
|
||||
*
|
||||
* This header file contains the prototypes for the netCDF-4 versions
|
||||
* of all the netCDF functions.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef _NCRPCDISPATCH_H
|
||||
#define _NCRPCDISPATCH_H
|
||||
|
||||
#include <stddef.h> /* size_t, ptrdiff_t */
|
||||
#include <errno.h> /* netcdf functions sometimes return system errors */
|
||||
#include "ncdispatch.h"
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int
|
||||
NCRPC_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
int useparallel, void* parameters,
|
||||
NC_Dispatch*, NC**);
|
||||
|
||||
extern int
|
||||
NCRPC_open(const char *path, int mode,
|
||||
int basepe, size_t *chunksizehintp,
|
||||
int use_parallel, void* parameters,
|
||||
NC_Dispatch*, NC**);
|
||||
|
||||
extern int
|
||||
NCRPC_redef(int ncid);
|
||||
|
||||
extern int
|
||||
NCRPC__enddef(int ncid, size_t h_minfree, size_t v_align,
|
||||
size_t v_minfree, size_t r_align);
|
||||
|
||||
extern int
|
||||
NCRPC_sync(int ncid);
|
||||
|
||||
extern int
|
||||
NCRPC_abort(int ncid);
|
||||
|
||||
extern int
|
||||
NCRPC_close(int ncid);
|
||||
|
||||
extern int
|
||||
NCRPC_set_fill(int ncid, int fillmode, int *old_modep);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_base_pe(int ncid, int *pe);
|
||||
|
||||
extern int
|
||||
NCRPC_set_base_pe(int ncid, int pe);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_format(int ncid, int *formatp);
|
||||
|
||||
extern int
|
||||
NCRPC_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_type(int, nc_type, char *, size_t *);
|
||||
|
||||
/* Begin _dim */
|
||||
|
||||
extern int
|
||||
NCRPC_def_dim(int ncid, const char *name, size_t len, int *idp);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_dimid(int ncid, const char *name, int *idp);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_dim(int ncid, int dimid, char *name, size_t *lenp);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_unlimdim(int ncid, int *unlimdimidp);
|
||||
|
||||
extern int
|
||||
NCRPC_rename_dim(int ncid, int dimid, const char *name);
|
||||
|
||||
/* End _dim */
|
||||
/* Begin _att */
|
||||
|
||||
extern int
|
||||
NCRPC_inq_att(int ncid, int varid, const char *name,
|
||||
nc_type *xtypep, size_t *lenp);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_attid(int ncid, int varid, const char *name, int *idp);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_attname(int ncid, int varid, int attnum, char *name);
|
||||
|
||||
extern int
|
||||
NCRPC_rename_att(int ncid, int varid, const char *name, const char *newname);
|
||||
|
||||
extern int
|
||||
NCRPC_del_att(int ncid, int varid, const char*);
|
||||
|
||||
/* End _att */
|
||||
/* Begin {put,get}_att */
|
||||
|
||||
extern int
|
||||
NCRPC_get_att(int ncid, int varid, const char *name, void *value, nc_type);
|
||||
|
||||
extern int
|
||||
NCRPC_put_att(int ncid, int varid, const char *name, nc_type datatype,
|
||||
size_t len, const void *value, nc_type);
|
||||
|
||||
/* End {put,get}_att */
|
||||
/* Begin _var */
|
||||
|
||||
extern int
|
||||
NCRPC_def_var(int ncid, const char *name,
|
||||
nc_type xtype, int ndims, const int *dimidsp, int *varidp);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_varid(int ncid, const char *name, int *varidp);
|
||||
|
||||
extern int
|
||||
NCRPC_rename_var(int ncid, int varid, const char *name);
|
||||
|
||||
|
||||
extern int
|
||||
NCRPC_get_vara(int ncid, int varid,
|
||||
const size_t *start, const size_t *count,
|
||||
void *value, nc_type);
|
||||
|
||||
extern int
|
||||
NCRPC_put_vara(int ncid, int varid,
|
||||
const size_t *start, const size_t *count,
|
||||
const void *value, nc_type);
|
||||
|
||||
extern int
|
||||
NCRPC_get_vars(int ncid, int varid,
|
||||
const size_t *start, const size_t *count, const ptrdiff_t*,
|
||||
void *value, nc_type);
|
||||
|
||||
extern int
|
||||
NCRPC_put_vars(int ncid, int varid,
|
||||
const size_t *start, const size_t *count, const ptrdiff_t*,
|
||||
const void *value, nc_type);
|
||||
|
||||
extern int
|
||||
NCRPC_get_varm(int, int, const size_t*, const size_t*, const ptrdiff_t*, const ptrdiff_t*, void*, nc_type);
|
||||
|
||||
extern int
|
||||
NCRPC_put_varm(int, int, const size_t*, const size_t*, const ptrdiff_t*, const ptrdiff_t*, const void*, nc_type);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *ndimsp, int *dimidsp, int *nattsp,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp);
|
||||
/* End _var */
|
||||
|
||||
/*#ifdef USE_NETCDF4*/
|
||||
|
||||
extern int
|
||||
NCRPC_show_metadata(int);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_unlimdims(int, int *, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_var_par_access(int, int, int);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_ncid(int, const char *, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_grps(int, int *, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_grpname(int, char *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_grpname_full(int, size_t *, char *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_grp_parent(int, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_grp_full_ncid(int, const char *, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_varids(int, int * nvars, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_dimids(int, int * ndims, int *, int);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_typeids(int, int * ntypes, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_type_equal(int, nc_type, int, nc_type, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_def_grp(int, const char *, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_user_type(int, nc_type, char *, size_t *, nc_type *,
|
||||
size_t *, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_typeid(int, const char *, nc_type *);
|
||||
|
||||
extern int
|
||||
NCRPC_def_compound(int, size_t, const char *, nc_type *);
|
||||
|
||||
extern int
|
||||
NCRPC_insert_compound(int, nc_type, const char *, size_t, nc_type);
|
||||
|
||||
extern int
|
||||
NCRPC_insert_array_compound(int, nc_type, const char *, size_t,
|
||||
nc_type, int, const int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_compound_field(int, nc_type, int, char *, size_t *,
|
||||
nc_type *, int *, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_compound_fieldindex(int, nc_type, const char *, int *);
|
||||
|
||||
extern int
|
||||
NCRPC_def_vlen(int, const char *, nc_type base_typeid, nc_type *);
|
||||
|
||||
extern int
|
||||
NCRPC_put_vlen_element(int, int, void *, size_t, const void *);
|
||||
|
||||
extern int
|
||||
NCRPC_get_vlen_element(int, int, const void *, size_t *, void *);
|
||||
|
||||
extern int
|
||||
NCRPC_def_enum(int, nc_type, const char *, nc_type *);
|
||||
|
||||
extern int
|
||||
NCRPC_insert_enum(int, nc_type, const char *, const void *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_enum_member(int, nc_type, int, char *, void *);
|
||||
|
||||
extern int
|
||||
NCRPC_inq_enum_ident(int, nc_type, long long, char *);
|
||||
|
||||
extern int
|
||||
NCRPC_def_opaque(int, size_t, const char *, nc_type *);
|
||||
|
||||
extern int
|
||||
NCRPC_def_var_deflate(int, int, int, int, int);
|
||||
|
||||
extern int
|
||||
NCRPC_def_var_fletcher32(int, int, int);
|
||||
|
||||
extern int
|
||||
NCRPC_def_var_chunking(int, int, int, const size_t *);
|
||||
|
||||
extern int
|
||||
NCRPC_def_var_fill(int, int, int, const void *);
|
||||
|
||||
extern int
|
||||
NCRPC_def_var_endian(int, int, int);
|
||||
|
||||
extern int
|
||||
NCRPC_set_var_chunk_cache(int, int, size_t, size_t, float);
|
||||
|
||||
extern int
|
||||
NCRPC_get_var_chunk_cache(int, int, size_t *, size_t *, float *);
|
||||
|
||||
/*#endif USE_NETCDF4*/
|
||||
|
||||
/* Non-dispatch operations *.
|
||||
extern void
|
||||
NCRPC_nc_advise(const char*cdf_routine_name,interr,const char*fmt,...);
|
||||
|
||||
extern void
|
||||
NCRPC_nc_set_log_level(int);
|
||||
|
||||
extern const char*
|
||||
NCRPC_nc_inq_libvers(void);
|
||||
|
||||
extern const char*
|
||||
NCRPC_nc_strerror(int);
|
||||
|
||||
extern int
|
||||
NCRPC_nc_delete(const char*path);
|
||||
|
||||
extern int
|
||||
NCRPC_nc_delete_mp(const char*path,intbasepe);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_NCRPCDISPATCH_H */
|
Loading…
x
Reference in New Issue
Block a user