Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3plug.dmh #2

Open
wants to merge 2 commits into
base: v3plug.dmh
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/ncrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ typedef struct NCRCinfo {

/* Opaque structures */
struct NCS3INFO;
enum NCS3SVC;

#if defined(__cplusplus)
extern "C" {
Expand Down
62 changes: 45 additions & 17 deletions libdispatch/ncs3sdk_aws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,26 +548,12 @@ NC_s3sdkwriteobject(void* s3client0, const char* bucket, const char* pathkey, s
}

EXTERNL int
NC_s3sdkclose(void* s3client0, NCS3INFO* info, int deleteit, char** errmsgp)
NC_s3sdkclose(void* s3client0, char** errmsgp)
{
int stat = NC_NOERR;

NCTRACE(11,"info=%s rootkey=%s deleteit=%d",dumps3info(info),deleteit);

NCTRACE(11, "");
AWSS3CLIENT s3client = (AWSS3CLIENT)s3client0;
if(deleteit) {
/* Delete the root key; ok it if does not exist */
switch (stat = NC_s3sdkdeletekey(s3client0,info->bucket,info->rootkey,errmsgp)) {
case NC_NOERR: break;
case NC_EEMPTY: case NC_ENOTFOUND: stat = NC_NOERR; break;
default: break;
}
}
#ifdef TRANSFER
delete s3client;
#else
delete s3client;
#endif
return NCUNTRACE(stat);
}

Expand Down Expand Up @@ -654,11 +640,23 @@ Return a list of full keys of legal objects immediately below a specified key.
Not necessarily sorted.
*/
EXTERNL int
NC_s3sdkgetkeys(void* s3client0, const char* bucket, const char* prefixkey0, size_t* nkeysp, char*** keysp, char** errmsgp)
NC_s3sdklist(void* s3client0, const char* bucket, const char* prefixkey0, size_t* nkeysp, char*** keysp, char** errmsgp)
{
return getkeys(s3client0, bucket, prefixkey0, "/", nkeysp, keysp, errmsgp);
}

/*
Return a list of full keys of legal objects below a specified key.
Not necessarily sorted.
Essentially same as getkeys, but with no delimiter.
*/
EXTERNL int
NC_s3sdklistall(void* s3client0, const char* bucket, const char* prefixkey0, size_t* nkeysp, char*** keysp, char** errmsgp)
{
NCTRACE(11,"bucket=%s prefixkey0=%s",bucket,prefixkey0);
return NCUNTRACE(getkeys(s3client0, bucket, prefixkey0, NULL, nkeysp, keysp, errmsgp));
}

/*
Return a list of full keys of legal objects immediately below a specified key.
Not necessarily sorted.
Expand All @@ -669,6 +667,36 @@ NC_s3sdksearch(void* s3client0, const char* bucket, const char* prefixkey0, size
return getkeys(s3client0, bucket, prefixkey0, NULL, nkeysp, keysp, errmsgp);
}

EXTERNL int
NC_s3sdktruncate(void* s3client0, const char* bucket, const char* prefix, char** errmsgp)
{
int stat = NC_NOERR;
char* errmsg = NULL;
size_t nkeys;
char** keys = NULL;
AWSS3CLIENT* s3client = (AWSS3CLIENT*)s3client0;

NCTRACE(11,"bucket=%s prefix=%s",bucket,prefix);

if((stat = NC_s3sdklistall(s3client0,bucket,prefix,&nkeys,&keys,&errmsg))) goto done;

if(nkeys > 0 && keys != NULL) {
size_t i;
/* Sort the list -- shortest first */
NC_sortenvv(nkeys,keys);
for(i=0;i<nkeys;i++) {
if((stat = NC_s3sdkdeletekey(s3client, bucket, keys[i], NULL))) goto done;
}
}

if(errmsgp) {*errmsgp = errmsg; errmsg = NULL;}

done:
free(errmsg);
NC_freeenvv(nkeys,keys);
return NCUNTRACE(stat);
}

EXTERNL int
NC_s3sdkdeletekey(void* s3client0, const char* bucket, const char* pathkey, char** errmsgp)
{
Expand Down
4 changes: 2 additions & 2 deletions libnczarr/zmap_s3sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ zs3keyexists(NCZMAP* map, const char* key)

if((stat = maketruekey(z3map->s3.rootkey,key,&truekey))) goto done;

switch (stat = NC_s3sdkinfo(z3map->s3client,z3map->s3.bucket,truekey,lenp,&z3map->errmsg)) {
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:
if(lenp) *lenp = 0;
goto done;
default:
goto done;
Expand Down