#include <vaccinator.h>
#include <string.h>
int32_t headerCb(
void* usrCtx,
dvSetHeaderFn setHeader,
void* headerCtx) {
return setHeader(headerCtx, "Cache-Control", "max-age=60");
}
int32_t postCb(
void* usrCtx,
dvSetPostFn setPostField,
void* postCtx) {
const char* user = "testuser";
int32_t ret = setPostField(postCtx, "username", (void*)user, strlen(user));
if (ret) return ret;
char* passwd = (char*) usrCtx;
return setPostField(postCtx, "password", (void*)passwd, strlen(passwd));
}
int main ( int argc, char **argv ) {
int ret;
const char *name = "John Doe", *address = "Mystreet 42";
const char *passwd = "mysecret", *logfile = CACHE_DIR "/debug.log";
char *namevid = NULL, *addrvid = NULL, *a1 = NULL;
ruList vids = NULL, indexTerms = NULL, searchTerms = NULL, foundVids = NULL;
do {
ret =
ruMkdir(CACHE_DIR, 0755,
false);
printf("failed to create folder '%s' ec [%d]\n", CACHE_DIR, ret);
break;
}
}
if (ret) break;
if (argc > 1) {
a1 = argv[1];
} else {
a1 = NULL;
}
}
ret =
dvNew(&dc, PROVIDER_URL, APPID, kvs);
if (ret) break;
if (ret) break;
}
if (ret) break;
}
if (ret) break;
if (ret) break;
if (ret) break;
ret =
dvAdd(dc, name, NULL, &namevid);
if (ret) break;
printf("namevid: %s\n", namevid);
if (ret) break;
ret =
dvAdd(dc, address, indexTerms, &addrvid);
if (ret) break;
printf("addrvid: %s\n", addrvid);
if (ret) break;
if (ret) break;
ret =
dvGet(dc, vids, &data);
if (ret) break;
printf("pid for vid: '%s' is: '%s'\n", vd, out);
}
}
data = NULL;
if (ret) break;
ret =
dvSearch(dc, searchTerms, &foundVids);
if (ret) break;
printf("found vid: '%s'\n", vd);
}
if (ret) break;
if (ret) break;
if (ret) break;
} while (false);
if (namevid) free(namevid);
if (addrvid) free(addrvid);
if (a1) {
printf("You will find debug logging in '%s'\n", logfile);
}
return ret;
}
RUAPI int32_t ruCleanAdd(ruCleaner rc, trans_chars instr, trans_chars substitute)
int32_t(* dvSetPostFn)(void *ctx, const char *name, void *buf, size_t len)
Definition: vaccinator.h:532
int32_t(* dvSetHeaderFn)(void *ctx, const char *name, const char *value)
Definition: vaccinator.h:482
DVAPI int32_t dvSetHeaderCb(dvCtx dc, dvHeaderCb callback, void *cbCtx)
DVAPI int dvSetProp(dvCtx dc, enum dvCtxOpt opt, const char *value)
Sets a DataVaccinator Client context dvCtxOpt option.
DVAPI void dvFree(dvCtx dc)
DVAPI int32_t dvNew(dvCtx *dc, const char *serviceUrl, const char *appId, KvStore *cache)
DVAPI int32_t dvSetPostCb(dvCtx dc, dvPostCb callback, void *cbCtx)
void * dvCtx
Definition: vaccinator.h:167
@ DV_CURL_LOGGING
Definition: vaccinator.h:628
@ DV_SKIP_CERT_CHECK
Definition: vaccinator.h:623
DVAPI int32_t dvGet(dvCtx dc, ruList vids, ruMap *vidMap)
DVAPI int32_t dvAdd(dvCtx dc, const char *data, ruList indexWords, char **vid)
DVAPI int32_t dvAddSearchWord(ruList *searchWords, const char *appId, const char *word)
DVAPI int32_t dvGetVid(ruMap vidMap, const char *vid, char **pid)
DVAPI int32_t dvAddIndexWord(ruList *indexWords, const char *appId, const char *word)
DVAPI int32_t dvDelete(dvCtx dc, ruList vids)
DVAPI int32_t dvSearch(dvCtx dc, ruList searchWords, ruList *vids)
DVAPI int32_t dvWipe(dvCtx dc, ruList vids)
RUAPI ruMap ruMapFree(ruMap rm)
RUAPI bool ruIsDir(trans_chars filename)
RUAPI int32_t ruMkdir(trans_chars pathname, int mode, bool deep)
RUAPI KvStore * ruNewFileStore(const char *folderPath, int32_t *code)
RUAPI void ruFreeStore(void *obj)
#define ruListAppend(rl, data)
RUAPI ruList ruListFree(ruList rl)
RUAPI ruList ruListNew(ruType valueType)
#define ruIterNext(re, type)
RUAPI void ruFileLogSink(perm_ptr rsc, uint32_t logLevel, trans_chars msg)
RUAPI ruSinkCtx ruSinkCtxFree(ruSinkCtx rsc)
RUAPI void ruSetLogger(ruLogFunc logger, uint32_t logLevel, perm_ptr userData, bool cleaned, bool threaded)
RUAPI ruSinkCtx ruSinkCtxNew(trans_chars filePath, ruCloseFunc closeCb, perm_ptr closeCtx)
RUAPI ruCleaner ruGetCleaner(void)
RUAPI trans_chars ruGetenv(trans_chars variable)
#define RUE_PARAMETER_NOT_SET
RUAPI bool ruStrEquals(trans_chars str1, trans_chars str2)