2019-03-26 14:35:33 +00:00
|
|
|
#include "wsfs/adapter/impl/credentials.h"
|
2019-03-23 21:53:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2019-03-26 14:35:33 +00:00
|
|
|
void wsfs_impl_credentials_init(
|
2019-03-23 21:53:14 +00:00
|
|
|
struct wsfs_credentials * credentials,
|
|
|
|
char const * type,
|
|
|
|
json_t * data)
|
|
|
|
{
|
|
|
|
credentials->type = strdup(type);
|
|
|
|
credentials->data = data;
|
|
|
|
json_incref(credentials->data);
|
|
|
|
}
|
|
|
|
|
2019-03-26 14:35:33 +00:00
|
|
|
void wsfs_impl_credentials_cleanup(
|
2019-03-23 21:53:14 +00:00
|
|
|
struct wsfs_credentials * credentials)
|
|
|
|
{
|
|
|
|
free(credentials->type);
|
|
|
|
json_decref(credentials->data);
|
|
|
|
}
|
|
|
|
|
2019-03-26 14:35:33 +00:00
|
|
|
char const * wsfs_impl_credentials_type(
|
2019-03-23 21:53:14 +00:00
|
|
|
struct wsfs_credentials const * credentials)
|
|
|
|
{
|
|
|
|
return credentials->type;
|
|
|
|
}
|
|
|
|
|
2019-03-26 14:35:33 +00:00
|
|
|
char const * wsfs_impl_credentials_get(
|
2019-03-23 21:53:14 +00:00
|
|
|
struct wsfs_credentials const * credentials,
|
|
|
|
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;
|
|
|
|
}
|