mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
changed credentials API
This commit is contained in:
@@ -111,28 +111,9 @@ void wfp_impl_client_config_set_onread(
|
||||
config->provider.read = handler;
|
||||
}
|
||||
|
||||
|
||||
void wfp_impl_client_config_set_username_credentials(
|
||||
void wfp_impl_client_config_enable_authentication(
|
||||
struct wfp_client_config * config,
|
||||
char const * username,
|
||||
char const * password)
|
||||
wfp_get_credentials_fn * get_credentials)
|
||||
{
|
||||
(void) config;
|
||||
(void) username;
|
||||
(void) password;
|
||||
|
||||
// ToDo: implement me
|
||||
}
|
||||
|
||||
void wfp_impl_client_config_set_generic_credentials(
|
||||
struct wfp_client_config * config,
|
||||
char const * credentials_type,
|
||||
char const * contents[])
|
||||
{
|
||||
(void) config;
|
||||
(void) credentials_type;
|
||||
(void) contents;
|
||||
|
||||
// ToDo: implement me
|
||||
|
||||
config->provider.get_credentials = get_credentials;
|
||||
}
|
||||
|
||||
@@ -70,15 +70,9 @@ extern void wfp_impl_client_config_set_onread(
|
||||
struct wfp_client_config * config,
|
||||
wfp_read_fn * handler);
|
||||
|
||||
extern void wfp_impl_client_config_set_username_credentials(
|
||||
extern void wfp_impl_client_config_enable_authentication(
|
||||
struct wfp_client_config * config,
|
||||
char const * username,
|
||||
char const * password);
|
||||
|
||||
extern void wfp_impl_client_config_set_generic_credentials(
|
||||
struct wfp_client_config * config,
|
||||
char const * credentials_type,
|
||||
char const * contents[]);
|
||||
wfp_get_credentials_fn * get_credentials);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
34
lib/webfuse/provider/impl/credentials.c
Normal file
34
lib/webfuse/provider/impl/credentials.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "webfuse/provider/impl/credentials.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void wfp_impl_credentials_init(
|
||||
struct wfp_credentials * credentials)
|
||||
{
|
||||
credentials->type = NULL;
|
||||
credentials->contents = json_object();
|
||||
}
|
||||
|
||||
void wfp_impl_credentials_cleanup(
|
||||
struct wfp_credentials * credentials)
|
||||
{
|
||||
free(credentials->type);
|
||||
json_decref(credentials->contents);
|
||||
}
|
||||
|
||||
void wfp_impl_credentials_set_type(
|
||||
struct wfp_credentials * credentials,
|
||||
char const * type)
|
||||
{
|
||||
free(credentials->type);
|
||||
credentials->type = strdup(type);
|
||||
}
|
||||
|
||||
void wfp_impl_credentials_add(
|
||||
struct wfp_credentials * credentials,
|
||||
char const * key,
|
||||
char const * value)
|
||||
{
|
||||
json_object_set_new(credentials->contents, key, json_string(value));
|
||||
}
|
||||
38
lib/webfuse/provider/impl/credentials.h
Normal file
38
lib/webfuse/provider/impl/credentials.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef WF_PROVIDER_IMPL_CREDENTIALS_H
|
||||
#define WF_PROVIDER_IMPL_CREDENTIALS_H
|
||||
|
||||
#include "webfuse/provider/credentials.h"
|
||||
#include <jansson.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wfp_credentials
|
||||
{
|
||||
char * type;
|
||||
json_t * contents;
|
||||
};
|
||||
|
||||
extern void wfp_impl_credentials_init(
|
||||
struct wfp_credentials * credentials);
|
||||
|
||||
extern void wfp_impl_credentials_cleanup(
|
||||
struct wfp_credentials * credentials);
|
||||
|
||||
extern void wfp_impl_credentials_set_type(
|
||||
struct wfp_credentials * credentials,
|
||||
char const * type);
|
||||
|
||||
extern void wfp_impl_credentials_add(
|
||||
struct wfp_credentials * credentials,
|
||||
char const * key,
|
||||
char const * value);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -67,6 +67,7 @@ void wfp_impl_provider_init(
|
||||
provider->connected = &wfp_impl_connected_default;
|
||||
provider->disconnected = &wfp_impl_disconnected_default;
|
||||
provider->ontimer = &wfp_impl_ontimer_default;
|
||||
provider->get_credentials = NULL;
|
||||
}
|
||||
|
||||
void wfp_impl_provider_init_from_prototype(
|
||||
@@ -82,6 +83,7 @@ void wfp_impl_provider_init_from_prototype(
|
||||
provider->connected = prototype->connected;
|
||||
provider->disconnected = prototype->disconnected;
|
||||
provider->ontimer = prototype->ontimer;
|
||||
provider->get_credentials = prototype->get_credentials;
|
||||
}
|
||||
|
||||
void wfp_impl_provider_invoke(
|
||||
|
||||
@@ -20,6 +20,7 @@ struct wfp_provider
|
||||
wfp_open_fn * open;
|
||||
wfp_close_fn * close;
|
||||
wfp_read_fn * read;
|
||||
wfp_get_credentials_fn * get_credentials;
|
||||
};
|
||||
|
||||
struct wfp_impl_invokation_context
|
||||
|
||||
Reference in New Issue
Block a user