summaryrefslogtreecommitdiff
path: root/src/libstrongswan/fetcher
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/fetcher')
-rw-r--r--src/libstrongswan/fetcher/fetcher.h22
-rw-r--r--src/libstrongswan/fetcher/fetcher_manager.c22
-rw-r--r--src/libstrongswan/fetcher/fetcher_manager.h12
3 files changed, 28 insertions, 28 deletions
diff --git a/src/libstrongswan/fetcher/fetcher.h b/src/libstrongswan/fetcher/fetcher.h
index 70d14bf97..f312206bb 100644
--- a/src/libstrongswan/fetcher/fetcher.h
+++ b/src/libstrongswan/fetcher/fetcher.h
@@ -33,36 +33,36 @@ typedef enum fetcher_option_t fetcher_option_t;
*/
enum fetcher_option_t {
- /**
+ /**
* Data to include in fetch request, e.g. on a HTTP post.
* Additional argument is a chunk_t
*/
FETCH_REQUEST_DATA,
-
- /**
+
+ /**
* Mime-Type of data included in FETCH_REQUEST_DATA.
* Additional argument is a char*.
*/
FETCH_REQUEST_TYPE,
-
- /**
+
+ /**
* HTTP header to be sent with with the fetch request.
* Additional argument is a char*.
*/
FETCH_REQUEST_HEADER,
- /**
+ /**
* Use HTTP Version 1.0 instead of 1.1.
* No additional argument is needed.
*/
FETCH_HTTP_VERSION_1_0,
- /**
+ /**
* Timeout to use for fetch, in seconds.
* Additional argument is u_int
*/
FETCH_TIMEOUT,
-
+
/**
* end of fetching options
*/
@@ -96,7 +96,7 @@ struct fetcher_t {
* - FAILED, NOT_FOUND, PARSE_ERROR on failure
*/
status_t (*fetch)(fetcher_t *this, char *uri, chunk_t *result);
-
+
/**
* Set a fetcher option, as defined in fetcher_option_t.
*
@@ -107,11 +107,11 @@ struct fetcher_t {
* @return TRUE if option supported, FALSE otherwise
*/
bool (*set_option)(fetcher_t *this, fetcher_option_t option, ...);
-
+
/**
* Destroy the fetcher instance.
*/
- void (*destroy)(fetcher_t *this);
+ void (*destroy)(fetcher_t *this);
};
#endif /** FETCHER_H_ @}*/
diff --git a/src/libstrongswan/fetcher/fetcher_manager.c b/src/libstrongswan/fetcher/fetcher_manager.c
index 1f87412c8..b73bfacf6 100644
--- a/src/libstrongswan/fetcher/fetcher_manager.c
+++ b/src/libstrongswan/fetcher/fetcher_manager.c
@@ -16,7 +16,7 @@
#include "fetcher_manager.h"
#include <debug.h>
-#include <utils/mutex.h>
+#include <threading/rwlock.h>
#include <utils/linked_list.h>
typedef struct private_fetcher_manager_t private_fetcher_manager_t;
@@ -30,12 +30,12 @@ struct private_fetcher_manager_t {
* public functions
*/
fetcher_manager_t public;
-
+
/**
* list of registered fetchers, as entry_t
*/
linked_list_t *fetchers;
-
+
/**
* read write lock to list
*/
@@ -68,7 +68,7 @@ static status_t fetch(private_fetcher_manager_t *this,
status_t status = NOT_SUPPORTED;
entry_t *entry;
bool capable = FALSE;
-
+
this->lock->read_lock(this->lock);
enumerator = this->fetchers->create_enumerator(this->fetchers);
while (enumerator->enumerate(enumerator, &entry))
@@ -119,7 +119,7 @@ static status_t fetch(private_fetcher_manager_t *this,
fetcher->destroy(fetcher);
continue;
}
-
+
status = fetcher->fetch(fetcher, url, response);
fetcher->destroy(fetcher);
/* try another fetcher only if this one does not support that URL */
@@ -142,11 +142,11 @@ static status_t fetch(private_fetcher_manager_t *this,
/**
* Implementation of fetcher_manager_t.add_fetcher.
*/
-static void add_fetcher(private_fetcher_manager_t *this,
+static void add_fetcher(private_fetcher_manager_t *this,
fetcher_constructor_t create, char *url)
{
entry_t *entry = malloc_thing(entry_t);
-
+
entry->url = strdup(url);
entry->create = create;
@@ -163,7 +163,7 @@ static void remove_fetcher(private_fetcher_manager_t *this,
{
enumerator_t *enumerator;
entry_t *entry;
-
+
this->lock->write_lock(this->lock);
enumerator = this->fetchers->create_enumerator(this->fetchers);
while (enumerator->enumerate(enumerator, &entry))
@@ -194,15 +194,15 @@ static void destroy(private_fetcher_manager_t *this)
fetcher_manager_t *fetcher_manager_create()
{
private_fetcher_manager_t *this = malloc_thing(private_fetcher_manager_t);
-
+
this->public.fetch = (status_t(*)(fetcher_manager_t*, char *url, chunk_t *response, ...))fetch;
this->public.add_fetcher = (void(*)(fetcher_manager_t*, fetcher_constructor_t,char*))add_fetcher;
this->public.remove_fetcher = (void(*)(fetcher_manager_t*, fetcher_constructor_t))remove_fetcher;
this->public.destroy = (void(*)(fetcher_manager_t*))destroy;
-
+
this->fetchers = linked_list_create();
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-
+
return &this->public;
}
diff --git a/src/libstrongswan/fetcher/fetcher_manager.h b/src/libstrongswan/fetcher/fetcher_manager.h
index 183964d6c..a7ac6611e 100644
--- a/src/libstrongswan/fetcher/fetcher_manager.h
+++ b/src/libstrongswan/fetcher/fetcher_manager.h
@@ -51,19 +51,19 @@ struct fetcher_manager_t {
*/
void (*add_fetcher)(fetcher_manager_t *this,
fetcher_constructor_t constructor, char *url);
-
+
/**
* Unregister a previously registered fetcher implementation.
*
* @param constructor fetcher constructor function to unregister
*/
- void (*remove_fetcher)(fetcher_manager_t *this,
+ void (*remove_fetcher)(fetcher_manager_t *this,
fetcher_constructor_t constructor);
-
+
/**
- * Destroy a fetcher_manager instance.
- */
- void (*destroy)(fetcher_manager_t *this);
+ * Destroy a fetcher_manager instance.
+ */
+ void (*destroy)(fetcher_manager_t *this);
};
/**