2019-03-26 22:04:53 +00:00
|
|
|
#include "webfuse/adapter/impl/credentials.h"
|
2019-03-23 21:53:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
void wf_impl_credentials_init(
|
|
|
|
struct wf_credentials * credentials,
|
2019-03-23 21:53:14 +00:00
|
|
|
char const * type,
|
|
|
|
json_t * data)
|
|
|
|
{
|
|
|
|
credentials->type = strdup(type);
|
|
|
|
credentials->data = data;
|
|
|
|
json_incref(credentials->data);
|
|
|
|
}
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
void wf_impl_credentials_cleanup(
|
|
|
|
struct wf_credentials * credentials)
|
2019-03-23 21:53:14 +00:00
|
|
|
{
|
|
|
|
free(credentials->type);
|
|
|
|
json_decref(credentials->data);
|
|
|
|
}
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
char const * wf_impl_credentials_type(
|
|
|
|
struct wf_credentials const * credentials)
|
2019-03-23 21:53:14 +00:00
|
|
|
{
|
|
|
|
return credentials->type;
|
|
|
|
}
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
char const * wf_impl_credentials_get(
|
|
|
|
struct wf_credentials const * credentials,
|
2019-03-23 21:53:14 +00:00
|
|
|
char const * key)
|
|
|
|
{
|
|
|
|
char const * result = NULL;
|
|
|
|
|
|
|
|
json_t * value_holder = json_object_get(credentials->data, key);
|
|
|
|
if (json_is_string(value_holder))
|
|
|
|
{
|
|
|
|
result = json_string_value(value_holder);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|