forked from Unidata/netcdf-c
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzmap_s3sdk.c
More file actions
755 lines (647 loc) · 19.3 KB
/
zmap_s3sdk.c
File metadata and controls
755 lines (647 loc) · 19.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
/*
* Copyright 2018, University Corporation for Atmospheric Research
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*/
#include "zincludes.h"
#include "zmap.h"
#include "ncs3sdk.h"
#undef S3DEBUG
/*
Map our simplified map model to an S3 bucket + objects.
For the API, the mapping is as follows:
1. A bucket contains multiple datasets.
2. A key to the root of a dataset is assumed to be with respect to
the bucket name from the original open/create url.
2. Containment is simulated using the S3 key conventions.
3. Every object (e.g. group or array) is mapped to an S3 object
4. Meta data objects (e.g. .zgroup, .zarray, etc) are kept as an S3 object.
5. Actual variable data (for e.g. chunks) is stored as
using an S3 object per chunk.
Given a key, one of three things is true.
1. The key points to a content-bearing object
2. The key has no associated object
This basically means that there is no notion of not-found:
all keys are assumed to exist, but may have no content.
Notes:
1. Our canonical URLs use path style rather than virtual-host, although
virtual-host URLs will be accepted anc converted to path-style.
*/
#undef DEBUG
#define DEBUGERRORS
#define NCZM_S3SDK_V1 1
#define ZS3_PROPERTIES (0)
/* Define the "subclass" of NCZMAP */
typedef struct ZS3MAP {
NCZMAP map;
NCS3INFO s3;
void* s3client;
char* errmsg;
} ZS3MAP;
/* Forward */
static NCZMAP_API nczs3sdkapi; // c++ will not allow static forward variables
static int zs3len(NCZMAP* map, const char* key, size64_t* lenp);
static void freevector(size_t nkeys, char** list);
static void zs3initialize(void);
static int s3clear(void* s3client, const char* bucket, const char* key);
static int maketruekey(const char* rootpath, const char* key, char** truekeyp);
static void
errclear(ZS3MAP* z3map)
{
if(z3map) {
if(z3map->errmsg)
free(z3map->errmsg);
z3map->errmsg = NULL;
}
}
#ifdef DEBUGERRORS
static void
reporterr(ZS3MAP* z3map)
{
if(z3map) {
if(z3map->errmsg) {
nclog(NCLOGERR,z3map->errmsg);
}
errclear(z3map);
}
}
#else
#define reporterr(map)
#endif
/* Define the Dataset level API */
static int zs3initialized = 0;
static void
zs3initialize(void)
{
if(!zs3initialized) {
ZTRACE(7,NULL);
zs3initialized = 1;
(void)ZUNTRACE(NC_NOERR);
}
}
void
NCZ_s3finalize(void)
{
zs3initialized = 0;
}
static int
zs3create(const char *path, mode_t mode, size64_t flags, void* parameters, NCZMAP** mapp)
{
int stat = NC_NOERR;
ZS3MAP* z3map = NULL;
NCURI* url = NULL;
char* prefix = NULL;
char* truekey = NULL;
NC_UNUSED(parameters);
ZTRACE(6,"path=%s mode=%d flag=%llu",path,mode,flags);
if(!zs3initialized) zs3initialize();
#ifdef NETCDF_ENABLE_ZOH
if(flags & FLAG_ZOH) {stat = NC_EZARR; goto done;}
#endif
/* Parse the URL */
ncuriparse(path,&url);
if(url == NULL)
{stat = NC_EURL; goto done;}
/* Build the z3 state */
if((z3map = (ZS3MAP*)calloc(1,sizeof(ZS3MAP))) == NULL)
{stat = NC_ENOMEM; goto done;}
z3map->map.format = NCZM_S3; /* Even if NCZM_GS3 or NCZM_ZOH */
z3map->map.url = strdup(path);
z3map->map.mode = mode;
z3map->map.flags = flags;
z3map->map.api = (NCZMAP_API*)&nczs3sdkapi;
/* Convert to canonical path-style */
if((stat = NC_s3urlprocess(url,&z3map->s3,NULL))) goto done;
/* Verify the root path */
if(z3map->s3.rootkey == NULL)
{stat = NC_EURL; goto done;}
z3map->s3client = NC_s3sdkcreateclient(&z3map->s3);
{
int exists = 0;
/* Does bucket already exist */
if((stat = NC_s3sdkbucketexists(z3map->s3client,z3map->s3.bucket,&exists, &z3map->errmsg))) goto done;
if(!exists) {
/* create it */
if((stat = NC_s3sdkbucketcreate(z3map->s3client,z3map->s3.region,z3map->s3.bucket,&z3map->errmsg)))
goto done;
}
/* The root object may or may not already exist */
switch (stat = NC_s3sdkinfo(z3map->s3client,z3map->s3.bucket,z3map->s3.rootkey,NULL,&z3map->errmsg)) {
case NC_EEMPTY: /* fall thru */
case NC_ENOOBJECT: /* no such object */
stat = NC_NOERR; /* which is what we want */
errclear(z3map);
break;
case NC_NOERR:
stat = NC_EOBJECT;
errclear(z3map);
/* Delete objects inside root object tree */
s3clear(z3map->s3client,z3map->s3.bucket,z3map->s3.rootkey);
goto done; /* already exists */
default: reporterr(z3map); goto done;
}
}
if(mapp) *mapp = (NCZMAP*)z3map;
done:
reporterr(z3map);
ncurifree(url);
nullfree(prefix);
nullfree(truekey);
if(stat) nczmap_close((NCZMAP*)z3map,1);
return ZUNTRACE(stat);
}
/* The problem with open is that there
no obvious way to test for existence.
So, we assume that the dataset must have
some content. We look for that
@param path Dataset URL
@param mode Mode flags from nc_open
@param flags Other flags (currently unused)
@param parameters (currently unused)
@param mapp Return the created map
@result NC_NOERR|NC_EXXX
*/
static int
zs3open(const char *path, mode_t mode, size64_t flags, void* parameters, NCZMAP** mapp)
{
int stat = NC_NOERR;
ZS3MAP* z3map = NULL;
NCURI* url = NULL;
NClist* content = NULL;
size_t nkeys = 0;
NC_UNUSED(parameters);
ZTRACE(6,"path=%s mode=%d flags=%llu",path,mode,flags);
if(!zs3initialized) zs3initialize();
/* Parse the URL */
if((stat = ncuriparse(path,&url))) goto done;
if(url == NULL)
{stat = NC_EURL; goto done;}
/* Build the z3 state */
if((z3map = (ZS3MAP*)calloc(1,sizeof(ZS3MAP))) == NULL)
{stat = NC_ENOMEM; goto done;}
#ifdef NETCDF_ENABLE_ZOH
z3map->map.format = ((flags & FLAG_ZOH)?NCZM_ZOH:NCZM_S3);
#else
z3map->map.format = NCZM_S3;
#endif
z3map->map.url = strdup(path);
z3map->map.mode = mode;
z3map->map.flags = flags;
z3map->map.api = (NCZMAP_API*)&nczs3sdkapi;
/* Convert to canonical path-style */
if((stat = NC_s3urlprocess(url,&z3map->s3,NULL))) goto done;
/* Verify root path */
if(z3map->s3.rootkey == NULL)
{stat = NC_EURL; goto done;}
z3map->s3client = NC_s3sdkcreateclient(&z3map->s3);
#ifdef NETCDF_ENABLE_ZOH
if(!flags & FLAG_ZOH)
#endif
{
content = nclistnew();
if((stat = NC_s3sdklist(z3map->s3client,z3map->s3.bucket,z3map->s3.rootkey,&nkeys,NULL,&z3map->errmsg)))
goto done;
if(nkeys == 0) {
/* dataset does not actually exist; we choose to return ENOOBJECT instead of EEMPTY */
stat = NC_ENOOBJECT;
goto done;
}
}
if(mapp) *mapp = (NCZMAP*)z3map;
done:
reporterr(z3map);
nclistfreeall(content);
ncurifree(url);
if(stat) nczmap_close((NCZMAP*)z3map,0);
return ZUNTRACE(stat);
}
/* This uses url so we can get bucket */
static int
zs3truncate(const char *s3url)
{
int stat = NC_NOERR;
void* s3client = NULL;
NCURI* url = NULL;
NCURI* purl = NULL;
NCS3INFO info;
ZTRACE(6,"url=%s",s3url);
ncuriparse(s3url,&url);
if(url == NULL) {stat = NC_EURL; goto done;}
if((stat=NC_s3urlprocess(url,&info,&purl))) goto done;
if((s3client = NC_s3sdkcreateclient(&info))==NULL) {stat = NC_ES3; goto done;}
if((stat = s3clear(s3client,info.bucket,info.rootkey))) goto done;
done:
if(s3client) {stat=NC_s3sdkclose(s3client,NULL);}
ncurifree(url);
ncurifree(purl);
(void)NC_s3clear(&info);
return ZUNTRACE(stat);
}
/**************************************************/
/* Object API */
/*
@return NC_NOERR if key points to a content-bearing object.
@return NC_ENOOBJECT if object at key does not exist
@return NC_EXXX return true error
*/
static int
zs3exists(NCZMAP* map, const char* key)
{
int stat = NC_NOERR;
ZTRACE(6,"map=%s key=%s",map->url,key);
stat = zs3len(map,key,NULL);
return ZUNTRACE(stat);
}
/*
@return NC_NOERR if key points to a content-bearing object.
@return NC_ENOOBJECT if object at key does not exist
@return NC_EXXX return true error
*/
static int
zs3len(NCZMAP* map, const char* key, size64_t* lenp)
{
int stat = NC_NOERR;
ZS3MAP* z3map = (ZS3MAP*)map;
char* truekey = NULL;
ZTRACE(6,"map=%s key=%s",map->url,key);
if((stat = maketruekey(z3map->s3.rootkey,key,&truekey))) goto done;
switch (stat = NC_s3sdkinfo(z3map->s3client,z3map->s3.bucket,truekey,lenp,&z3map->errmsg)) {
case NC_NOERR: break;
case NC_EEMPTY: stat = NC_ENOOBJECT; /* fall thru */
case NC_ENOOBJECT:
if(lenp) *lenp = 0;
goto done;
default:
goto done;
}
done:
nullfree(truekey);
reporterr(z3map);
return ZUNTRACE(stat);
}
/*
@return NC_NOERR if key is a prefix for some existing object.
@return NC_EEMPTY if key is not such a prefix.
@return NC_EXXX return true error
*/
static int
zs3keyexists(NCZMAP* map, const char* key)
{
int stat = NC_NOERR;
ZS3MAP* z3map = (ZS3MAP*)map;
char* truekey = NULL;
ZTRACE(6,"map=%s key=%s",map->url,key);
if((stat = maketruekey(z3map->s3.rootkey,key,&truekey))) goto done;
switch (stat = NC_s3sdkinfo(z3map->s3client,z3map->s3.bucket,truekey,NULL,&z3map->errmsg)) {
case NC_NOERR: break;
case NC_EEMPTY: stat = NC_ENOOBJECT; /* fall thru */
case NC_ENOOBJECT:
goto done;
default:
goto done;
}
done:
nullfree(truekey);
reporterr(z3map);
return ZUNTRACE(stat);
}
/*
@return NC_NOERR if object at key was read
@return NC_ENOOBJECT if object at key does not exist
@return NC_EXXX return true error
*/
static int
zs3read(NCZMAP* map, const char* key, size64_t start, size64_t count, void* content)
{
int stat = NC_NOERR;
ZS3MAP* z3map = (ZS3MAP*)map; /* cast to true type */
size64_t size = 0;
char* truekey = NULL;
ZTRACE(6,"map=%s key=%s start=%llu count=%llu",map->url,key,start,count);
if((stat = maketruekey(z3map->s3.rootkey,key,&truekey))) goto done;
switch (stat=NC_s3sdkinfo(z3map->s3client, z3map->s3.bucket, truekey, &size, &z3map->errmsg)) {
case NC_NOERR: break;
case NC_EEMPTY: stat = NC_ENOOBJECT;
case NC_ENOOBJECT: goto done;
default: goto done;
}
/* Sanity checks */
if(start >= size || start+count > size)
{stat = NC_EEDGE; goto done;}
if(count > 0) {
if((stat = NC_s3sdkread(z3map->s3client, z3map->s3.bucket, truekey, start, count, content, &z3map->errmsg)))
goto done;
}
done:
nullfree(truekey);
reporterr(z3map);
return ZUNTRACE(stat);
}
/*
@return NC_NOERR if key content was written
@return NC_ENOOBJECT if object at key does not exist
@return NC_EXXX return true error
*/
static int
zs3write(NCZMAP* map, const char* key, size64_t count, const void* content)
{
int stat = NC_NOERR;
ZS3MAP* z3map = (ZS3MAP*)map; /* cast to true type */
char* chunk = NULL; /* use char* so we can do arithmetic with it */
char* truekey = NULL;
size64_t objsize;
ZTRACE(6,"map=%s key=%s count=%llu",map->url,key,count);
if((stat = maketruekey(z3map->s3.rootkey,key,&truekey))) goto done;
/* Apparently S3 has no write byterange operation, so we need to read the whole object,
copy data, and then rewrite */
switch (stat=NC_s3sdkinfo(z3map->s3client, z3map->s3.bucket, truekey, &objsize, &z3map->errmsg)) {
case NC_NOERR: /* Figure out the new size of the object */
break;
case NC_EEMPTY: case NC_ENOOBJECT:
stat = NC_NOERR; /* reset */
break;
default: reporterr(z3map); goto done;
}
chunk = (char*)calloc(1,count); /* initialize it */
if(chunk == NULL)
{stat = NC_ENOMEM; goto done;}
/* overwrite the relevant part of the memory with the contents */
if(count > 0)
memcpy((char*)chunk,content,count);
/* (re-)write */
if((stat = NC_s3sdkwriteobject(z3map->s3client, z3map->s3.bucket, truekey, count, (void*)chunk, &z3map->errmsg)))
goto done;
done:
nullfree(truekey);
reporterr(z3map);
nullfree(chunk);
return ZUNTRACE(stat);
}
static int
zs3close(NCZMAP* map, int deleteit)
{
int stat = NC_NOERR;
ZS3MAP* z3map = (ZS3MAP*)map;
ZTRACE(6,"map=%s deleteit=%d",map->url, deleteit);
if(deleteit)
s3clear(z3map->s3client,z3map->s3.bucket,z3map->s3.rootkey);
if(z3map->s3client && z3map->s3.bucket && z3map->s3.rootkey)
NC_s3sdkclose(z3map->s3client, &z3map->errmsg);
reporterr(z3map);
z3map->s3client = NULL;
NC_s3clear(&z3map->s3);
nullfree(z3map->errmsg);
nczm_clear(map);
nullfree(map);
return ZUNTRACE(stat);
}
/*
Return a list of all key segments immediately "below" a specified prefix,
but not including the prefix.
In theory, the returned list should be sorted in lexical order,
but it possible that it is not.
@return NC_NOERR if success, even if no keys returned.
@return NC_EXXX return true error
*/
static int
zs3list(NCZMAP* map, const char* prefix, NClist* matches)
{
int stat = NC_NOERR;
size_t i;
ZS3MAP* z3map = (ZS3MAP*)map;
char** list = NULL;
size_t nkeys;
NClist* tmp = NULL;
char* trueprefix = NULL;
char* newkey = NULL;
const char* p;
ZTRACE(6,"map=%s prefix0=%s",map->url,prefix);
if((stat = maketruekey(z3map->s3.rootkey,prefix,&trueprefix))) goto done;
if(trueprefix[0] != '/') return NC_EINTERNAL;
if((stat = NC_s3sdklist(z3map->s3client,z3map->s3.bucket,trueprefix,&nkeys,&list,&z3map->errmsg)))
goto done;
if(nkeys > 0) {
size_t tplen = strlen(trueprefix);
tmp = nclistnew();
/* Remove the trueprefix from the front of all the returned keys */
for(i=0;i<nkeys;i++) {
const char* l = list[i];
if(memcmp(trueprefix,l,tplen)==0) {
p = l+tplen; /* Point to start of suffix */
/* If the key is same as trueprefix, ignore it */
if(*p == '\0') continue;
/* Also check for trailing '/' */
if(strcmp(p,"/")==0) continue;
if(nczm_segment1(p,&newkey)) goto done;
assert(newkey[0] != '/');
nclistpush(tmp,newkey); newkey = NULL;
}
}
/* Now remove duplicates */
for(i=0;i<nclistlength(tmp);i++) {
size_t j;
int duplicate = 0;
const char* is = (char*)nclistget(tmp,i);
for(j=0;j<nclistlength(matches);j++) {
const char* js = (char*)nclistget(matches,j);
if(strcmp(js,is)==0) {duplicate = 1; break;} /* duplicate */
}
if(!duplicate)
nclistpush(matches,strdup(is));
}
nclistfreeall(tmp); tmp = NULL;
}
#ifdef DEBUG
for(i=0;i<nclistlength(matches);i++) {
const char* is = nclistget(matches,i);
fprintf(stderr,"search: %s\n",is);
}
#endif
done:
nullfree(newkey);
nullfree(trueprefix);
reporterr(z3map);
nclistfreeall(tmp);
freevector(nkeys,list);
return ZUNTRACEX(stat,"|matches|=%d",(int)nclistlength(matches));
}
/*
Return a list of full keys "below" a specified prefix,
but not including the prefix.
In theory, the returned list should be sorted in lexical order,
but it possible that it is not.
@return NC_NOERR if success, even if no keys returned.
@return NC_EXXX return true error
*/
static int
zs3listall(NCZMAP* map, const char* prefix, NClist* matches)
{
int stat = NC_NOERR;
ZS3MAP* z3map = (ZS3MAP*)map;
char** list = NULL;
size_t i,nkeys;
char* trueprefix = NULL;
char* newkey = NULL;
ZTRACE(6,"map=%s prefix0=%s",map->url,prefix);
if((stat = maketruekey(z3map->s3.rootkey,prefix,&trueprefix))) goto done;
if(*trueprefix != '/') return NC_EINTERNAL;
if((stat = NC_s3sdklistall(z3map->s3client,z3map->s3.bucket,trueprefix,&nkeys,&list,&z3map->errmsg)))
goto done;
if(nkeys > 0) {
/* remove duplicates and prefix */
for(i=0;i<nkeys;i++) {
size_t j;
int duplicate = 0;
char* is = list[i];
if(strcmp(is,prefix)==0) {list[i] = NULL; nullfree(is); continue;}
for(j=0;j<nclistlength(matches);j++) {
char* js = (char*)nclistget(matches,j);
if(strcmp(js,is)==0) {duplicate = 1; break;} /* duplicate */
}
if(!duplicate) {
nclistpush(matches,strdup(is));
}
}
}
/* Remove prefix from all entries in matches */
if((stat = nczm_removeprefix(trueprefix,nclistlength(matches),(char**)nclistcontents(matches)))) goto done;
/* Lexical sort the results */
NCZ_sortstringlist(nclistcontents(matches),nclistlength(matches));
#ifdef DEBUG
for(i=0;i<nclistlength(matches);i++) {
const char* is = nclistget(matches,i);
fprintf(stderr,"search: %s\n",is);
}
#endif
done:
nullfree(newkey);
nullfree(trueprefix);
reporterr(z3map);
freevector(nkeys,list);
return ZUNTRACEX(stat,"|matches|=%d",(int)nclistlength(matches));
}
/**************************************************/
/* S3 Utilities */
/*
Remove all objects in bucket with keys which have
rootkey as prefix; rootkey is a truekey
*/
static int
s3clear(void* s3client, const char* bucket, const char* rootkey)
{
int stat = NC_NOERR;
if(s3client && bucket && rootkey) {
if((stat = NC_s3sdktruncate(s3client, bucket, rootkey, NULL))) goto done;
}
done:
return THROW(stat);
}
/* Prefix key with path to root to make true key */
static int
maketruekey(const char* rootpath, const char* key, char** truekeyp)
{
int stat = NC_NOERR;
NCbytes* truekey = NULL;
size_t rootlen,keylen;
if(truekeyp == NULL) goto done;
truekey = ncbytesnew();
if(truekey == NULL) {stat = NC_ENOMEM; goto done;}
if(rootpath[0] != '/')
ncbytescat(truekey,"/"); /* force leading '/' */
rootlen = strlen(rootpath);
/* Force no trailing '/' */
if(rootpath[rootlen-1] == '/') rootlen--;
ncbytesappendn(truekey,rootpath,rootlen);
ncbytesnull(truekey);
keylen = nulllen(key);
if(keylen > 0) {
if(key[0] != '/') /* force '/' separator */
ncbytescat(truekey,"/");
ncbytescat(truekey,key);
ncbytesnull(truekey);
}
/* Ensure no trailing '/' */
if(ncbytesget(truekey,ncbyteslength(truekey)-1) == '/')
ncbytessetlength(truekey,ncbyteslength(truekey)-1);
ncbytesnull(truekey);
if(truekeyp) *truekeyp = ncbytesextract(truekey);
done:
ncbytesfree(truekey);
return stat;
}
static void
freevector(size_t nkeys, char** list)
{
size_t i;
if(list) {
for(i=0;i<nkeys;i++) nullfree(list[i]);
nullfree(list);
}
}
/**************************************************/
/* no-op functions for ZOH
#ifdef NETCDF_ENABLE_ZOH
static int
zs3create(const char *path, mode_t mode, size64_t flags, void* parameters, NCZMAP** mapp)
{
return NC_EZARR;
}
static int
zohtruncate(const char *s3url)
{
return NC_EZARR;
}
static int
zohlist(NCZMAP* map, const char* prefix, NClist* matches)
{
return NC_EZARR;
}
static int
zohlistall(NCZMAP* map, const char* prefix, NClist* matches)
{
return NC_EZARR;
}
#endif
/**************************************************/
/* External API objects */
/* Dispatcher for S3/GS3 */
NCZMAP_DS_API zmap_s3sdk;
NCZMAP_DS_API zmap_s3sdk = {
NCZM_S3SDK_V1,
ZS3_PROPERTIES,
zs3create,
zs3open,
zs3truncate,
};
static NCZMAP_API
nczs3sdkapi = {
NCZM_S3SDK_V1,
zs3close,
zs3exists,
zs3len,
zs3read,
zs3write,
zs3list,
zs3listall
};
#ifdef NETCDF_ENABLE_ZOH
/* Dispatcher for ZOH */
NCZMAP_DS_API zmap_zoh;
NCZMAP_DS_API zmap_zoh = {
NCZM_ZOH_V1,
ZOH_PROPERTIES,
zohcreate,
zs3open,
zohtruncate,
};
static NCZMAP_API
nczzohapi = {
NCZM_ZOH_V1,
zs3close,
zs3exists,
zs3len,
zs3read,
zohwrite,
zohlist,
zohlistall,
};
#endif