removed trailing spaces ([[:space:]]+$)
This commit is contained in:
+38
-38
@@ -57,22 +57,22 @@ struct private_bus_t {
|
||||
* Public part of a bus_t object.
|
||||
*/
|
||||
bus_t public;
|
||||
|
||||
|
||||
/**
|
||||
* List of registered listeners as entry_t's
|
||||
*/
|
||||
linked_list_t *listeners;
|
||||
|
||||
|
||||
/**
|
||||
* mutex to synchronize active listeners, recursively
|
||||
*/
|
||||
mutex_t *mutex;
|
||||
|
||||
|
||||
/**
|
||||
* Thread local storage for a unique, simple thread ID
|
||||
*/
|
||||
pthread_key_t thread_id;
|
||||
|
||||
|
||||
/**
|
||||
* Thread local storage the threads IKE_SA
|
||||
*/
|
||||
@@ -90,17 +90,17 @@ struct entry_t {
|
||||
* registered listener interface
|
||||
*/
|
||||
listener_t *listener;
|
||||
|
||||
|
||||
/**
|
||||
* is this a active listen() call with a blocking thread
|
||||
*/
|
||||
bool blocker;
|
||||
|
||||
|
||||
/**
|
||||
* are we currently calling this listener
|
||||
*/
|
||||
int calling;
|
||||
|
||||
|
||||
/**
|
||||
* condvar where active listeners wait
|
||||
*/
|
||||
@@ -113,12 +113,12 @@ struct entry_t {
|
||||
static entry_t *entry_create(listener_t *listener, bool blocker)
|
||||
{
|
||||
entry_t *this = malloc_thing(entry_t);
|
||||
|
||||
|
||||
this->listener = listener;
|
||||
this->blocker = blocker;
|
||||
this->calling = 0;
|
||||
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ static u_int get_thread_number(private_bus_t *this)
|
||||
{
|
||||
static uintptr_t current_num = 0;
|
||||
uintptr_t stored_num;
|
||||
|
||||
|
||||
stored_num = (uintptr_t)pthread_getspecific(this->thread_id);
|
||||
if (stored_num == 0)
|
||||
{ /* first call of current thread */
|
||||
@@ -214,7 +214,7 @@ static void listen_(private_bus_t *this, listener_t *listener, job_t *job)
|
||||
{
|
||||
int old;
|
||||
cleanup_data_t data;
|
||||
|
||||
|
||||
data.this = this;
|
||||
data.entry = entry_create(listener, TRUE);
|
||||
|
||||
@@ -302,20 +302,20 @@ static void vlog(private_bus_t *this, debug_t group, level_t level,
|
||||
char* format, va_list args)
|
||||
{
|
||||
log_data_t data;
|
||||
|
||||
|
||||
data.ike_sa = pthread_getspecific(this->thread_sa);
|
||||
data.thread = get_thread_number(this);
|
||||
data.group = group;
|
||||
data.level = level;
|
||||
data.format = format;
|
||||
va_copy(data.args, args);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
/* We use the remove() method to invoke all listeners. This is cheap and
|
||||
* does not require an allocation for this performance critical function. */
|
||||
this->listeners->remove(this->listeners, &data, (void*)log_cb);
|
||||
this->mutex->unlock(this->mutex);
|
||||
|
||||
|
||||
va_end(data.args);
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ static void log_(private_bus_t *this, debug_t group, level_t level,
|
||||
char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, format);
|
||||
vlog(this, group, level, format, args);
|
||||
va_end(args);
|
||||
@@ -360,9 +360,9 @@ static void alert(private_bus_t *this, alert_t alert, ...)
|
||||
entry_t *entry;
|
||||
va_list args;
|
||||
bool keep;
|
||||
|
||||
|
||||
ike_sa = pthread_getspecific(this->thread_sa);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -394,7 +394,7 @@ static void ike_state_change(private_bus_t *this, ike_sa_t *ike_sa,
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -425,9 +425,9 @@ static void child_state_change(private_bus_t *this, child_sa_t *child_sa,
|
||||
ike_sa_t *ike_sa;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
ike_sa = pthread_getspecific(this->thread_sa);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -458,9 +458,9 @@ static void message(private_bus_t *this, message_t *message, bool incoming)
|
||||
ike_sa_t *ike_sa;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
ike_sa = pthread_getspecific(this->thread_sa);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -492,7 +492,7 @@ static void ike_keys(private_bus_t *this, ike_sa_t *ike_sa,
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -524,9 +524,9 @@ static void child_keys(private_bus_t *this, child_sa_t *child_sa,
|
||||
ike_sa_t *ike_sa;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
ike_sa = pthread_getspecific(this->thread_sa);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -557,9 +557,9 @@ static void child_updown(private_bus_t *this, child_sa_t *child_sa, bool up)
|
||||
ike_sa_t *ike_sa;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
ike_sa = pthread_getspecific(this->thread_sa);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -590,9 +590,9 @@ static void child_rekey(private_bus_t *this, child_sa_t *old, child_sa_t *new)
|
||||
ike_sa_t *ike_sa;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
ike_sa = pthread_getspecific(this->thread_sa);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -621,7 +621,7 @@ static void ike_updown(private_bus_t *this, ike_sa_t *ike_sa, bool up)
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -640,13 +640,13 @@ static void ike_updown(private_bus_t *this, ike_sa_t *ike_sa, bool up)
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->mutex->unlock(this->mutex);
|
||||
|
||||
|
||||
/* a down event for IKE_SA implicitly downs all CHILD_SAs */
|
||||
if (!up)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
child_sa_t *child_sa;
|
||||
|
||||
|
||||
iterator = ike_sa->create_child_sa_iterator(ike_sa);
|
||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
||||
{
|
||||
@@ -664,7 +664,7 @@ static void ike_rekey(private_bus_t *this, ike_sa_t *old, ike_sa_t *new)
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -694,9 +694,9 @@ static bool authorize(private_bus_t *this, linked_list_t *auth, bool final)
|
||||
ike_sa_t *ike_sa;
|
||||
entry_t *entry;
|
||||
bool keep, success = TRUE;
|
||||
|
||||
|
||||
ike_sa = pthread_getspecific(this->thread_sa);
|
||||
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -739,7 +739,7 @@ static void destroy(private_bus_t *this)
|
||||
bus_t *bus_create()
|
||||
{
|
||||
private_bus_t *this = malloc_thing(private_bus_t);
|
||||
|
||||
|
||||
this->public.add_listener = (void(*)(bus_t*,listener_t*))add_listener;
|
||||
this->public.remove_listener = (void(*)(bus_t*,listener_t*))remove_listener;
|
||||
this->public.listen = (void(*)(bus_t*, listener_t *listener, job_t *job))listen_;
|
||||
@@ -758,12 +758,12 @@ bus_t *bus_create()
|
||||
this->public.child_rekey = (void(*)(bus_t*, child_sa_t *old, child_sa_t *new))child_rekey;
|
||||
this->public.authorize = (bool(*)(bus_t*, linked_list_t *auth, bool final))authorize;
|
||||
this->public.destroy = (void(*)(bus_t*)) destroy;
|
||||
|
||||
|
||||
this->listeners = linked_list_create();
|
||||
this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
|
||||
pthread_key_create(&this->thread_id, NULL);
|
||||
pthread_key_create(&this->thread_sa, NULL);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
+17
-17
@@ -142,7 +142,7 @@ enum alert_t {
|
||||
* may wait actively to events using the blocking listen() call.
|
||||
*/
|
||||
struct bus_t {
|
||||
|
||||
|
||||
/**
|
||||
* Register a listener to the bus.
|
||||
*
|
||||
@@ -153,14 +153,14 @@ struct bus_t {
|
||||
* @param listener listener to register.
|
||||
*/
|
||||
void (*add_listener) (bus_t *this, listener_t *listener);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a listener from the bus.
|
||||
*
|
||||
* @param listener listener to unregister.
|
||||
*/
|
||||
void (*remove_listener) (bus_t *this, listener_t *listener);
|
||||
|
||||
|
||||
/**
|
||||
* Register a listener and block the calling thread.
|
||||
*
|
||||
@@ -174,20 +174,20 @@ struct bus_t {
|
||||
* @param job job to execute asynchronously when registered, or NULL
|
||||
*/
|
||||
void (*listen)(bus_t *this, listener_t *listener, job_t *job);
|
||||
|
||||
|
||||
/**
|
||||
* Set the IKE_SA the calling thread is using.
|
||||
*
|
||||
* To associate an received log message to an IKE_SA without passing it as
|
||||
* parameter each time, the thread registers the currenlty used IKE_SA
|
||||
* during check-out. Before check-in, the thread unregisters the IKE_SA.
|
||||
* during check-out. Before check-in, the thread unregisters the IKE_SA.
|
||||
* This IKE_SA is stored per-thread, so each thread has its own IKE_SA
|
||||
* registered.
|
||||
*
|
||||
*
|
||||
* @param ike_sa ike_sa to register, or NULL to unregister
|
||||
*/
|
||||
void (*set_sa) (bus_t *this, ike_sa_t *ike_sa);
|
||||
|
||||
|
||||
/**
|
||||
* Send a log message to the bus.
|
||||
*
|
||||
@@ -202,7 +202,7 @@ struct bus_t {
|
||||
* @param ... printf() style argument list
|
||||
*/
|
||||
void (*log)(bus_t *this, debug_t group, level_t level, char* format, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Send a log message to the bus using va_list arguments.
|
||||
*
|
||||
@@ -215,7 +215,7 @@ struct bus_t {
|
||||
*/
|
||||
void (*vlog)(bus_t *this, debug_t group, level_t level,
|
||||
char* format, va_list args);
|
||||
|
||||
|
||||
/**
|
||||
* Raise an alert over the bus.
|
||||
*
|
||||
@@ -223,7 +223,7 @@ struct bus_t {
|
||||
* @param ... alert specific attributes
|
||||
*/
|
||||
void (*alert)(bus_t *this, alert_t alert, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Send a IKE_SA state change event to the bus.
|
||||
*
|
||||
@@ -247,7 +247,7 @@ struct bus_t {
|
||||
* @param incoming TRUE for incoming messages, FALSE for outgoing
|
||||
*/
|
||||
void (*message)(bus_t *this, message_t *message, bool incoming);
|
||||
|
||||
|
||||
/**
|
||||
* IKE_SA authorization hook.
|
||||
*
|
||||
@@ -256,7 +256,7 @@ struct bus_t {
|
||||
* @return TRUE to establish IKE_SA, FALSE to send AUTH_FAILED
|
||||
*/
|
||||
bool (*authorize)(bus_t *this, linked_list_t *auth, bool final);
|
||||
|
||||
|
||||
/**
|
||||
* IKE_SA keymat hook.
|
||||
*
|
||||
@@ -278,7 +278,7 @@ struct bus_t {
|
||||
*/
|
||||
void (*child_keys)(bus_t *this, child_sa_t *child_sa, diffie_hellman_t *dh,
|
||||
chunk_t nonce_i, chunk_t nonce_r);
|
||||
|
||||
|
||||
/**
|
||||
* IKE_SA up/down hook.
|
||||
*
|
||||
@@ -286,7 +286,7 @@ struct bus_t {
|
||||
* @param up TRUE for an up event, FALSE for a down event
|
||||
*/
|
||||
void (*ike_updown)(bus_t *this, ike_sa_t *ike_sa, bool up);
|
||||
|
||||
|
||||
/**
|
||||
* IKE_SA rekeying hook.
|
||||
*
|
||||
@@ -294,7 +294,7 @@ struct bus_t {
|
||||
* @param new new IKE_SA replacing old
|
||||
*/
|
||||
void (*ike_rekey)(bus_t *this, ike_sa_t *old, ike_sa_t *new);
|
||||
|
||||
|
||||
/**
|
||||
* CHILD_SA up/down hook.
|
||||
*
|
||||
@@ -302,7 +302,7 @@ struct bus_t {
|
||||
* @param up TRUE for an up event, FALSE for a down event
|
||||
*/
|
||||
void (*child_updown)(bus_t *this, child_sa_t *child_sa, bool up);
|
||||
|
||||
|
||||
/**
|
||||
* CHILD_SA rekeying hook.
|
||||
*
|
||||
@@ -310,7 +310,7 @@ struct bus_t {
|
||||
* @param new new CHILD_SA replacing old
|
||||
*/
|
||||
void (*child_rekey)(bus_t *this, child_sa_t *old, child_sa_t *new);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy the event bus.
|
||||
*/
|
||||
|
||||
@@ -25,17 +25,17 @@ typedef struct private_file_logger_t private_file_logger_t;
|
||||
* Private data of a file_logger_t object
|
||||
*/
|
||||
struct private_file_logger_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public data.
|
||||
*/
|
||||
file_logger_t public;
|
||||
|
||||
|
||||
/**
|
||||
* output file
|
||||
*/
|
||||
FILE *out;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum level to log, for each group
|
||||
*/
|
||||
@@ -52,10 +52,10 @@ static bool log_(private_file_logger_t *this, debug_t group, level_t level,
|
||||
{
|
||||
char buffer[8192];
|
||||
char *current = buffer, *next;
|
||||
|
||||
|
||||
/* write in memory buffer first */
|
||||
vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
|
||||
|
||||
/* prepend a prefix in front of every line */
|
||||
while (current)
|
||||
{
|
||||
@@ -109,17 +109,17 @@ static void destroy(private_file_logger_t *this)
|
||||
file_logger_t *file_logger_create(FILE *out)
|
||||
{
|
||||
private_file_logger_t *this = malloc_thing(private_file_logger_t);
|
||||
|
||||
|
||||
/* public functions */
|
||||
memset(&this->public.listener, 0, sizeof(listener_t));
|
||||
this->public.listener.log = (bool(*)(listener_t*,debug_t,level_t,int,ike_sa_t*,char*,va_list))log_;
|
||||
this->public.set_level = (void(*)(file_logger_t*,debug_t,level_t))set_level;
|
||||
this->public.destroy = (void(*)(file_logger_t*))destroy;
|
||||
|
||||
|
||||
/* private variables */
|
||||
this->out = out;
|
||||
set_level(this, DBG_ANY, LEVEL_SILENT);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ typedef struct file_logger_t file_logger_t;
|
||||
* Logger to files which implements listener_t.
|
||||
*/
|
||||
struct file_logger_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements the listener_t interface.
|
||||
*/
|
||||
listener_t listener;
|
||||
|
||||
|
||||
/**
|
||||
* Set the loglevel for a debug group.
|
||||
*
|
||||
@@ -42,7 +42,7 @@ struct file_logger_t {
|
||||
* @param level max level to log (0..4)
|
||||
*/
|
||||
void (*set_level) (file_logger_t *this, debug_t group, level_t level);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a file_logger_t object.
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct listener_t listener_t;
|
||||
* Listener interface, listens to events if registered to the bus.
|
||||
*/
|
||||
struct listener_t {
|
||||
|
||||
|
||||
/**
|
||||
* Log a debugging message.
|
||||
*
|
||||
@@ -48,7 +48,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*log)(listener_t *this, debug_t group, level_t level, int thread,
|
||||
ike_sa_t *ike_sa, char* format, va_list args);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called if a critical alert is risen.
|
||||
*
|
||||
@@ -59,7 +59,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*alert)(listener_t *this, ike_sa_t *ike_sa,
|
||||
alert_t alert, va_list args);
|
||||
|
||||
|
||||
/**
|
||||
* Handle state changes in an IKE_SA.
|
||||
*
|
||||
@@ -69,7 +69,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*ike_state_change)(listener_t *this, ike_sa_t *ike_sa,
|
||||
ike_sa_state_t state);
|
||||
|
||||
|
||||
/**
|
||||
* Handle state changes in a CHILD_SA.
|
||||
*
|
||||
@@ -80,7 +80,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*child_state_change)(listener_t *this, ike_sa_t *ike_sa,
|
||||
child_sa_t *child_sa, child_sa_state_t state);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called for received/sent messages of an IKE_SA.
|
||||
*
|
||||
@@ -91,7 +91,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*message)(listener_t *this, ike_sa_t *ike_sa, message_t *message,
|
||||
bool incoming);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called with IKE_SA key material.
|
||||
*
|
||||
@@ -104,7 +104,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*ike_keys)(listener_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
|
||||
chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called with CHILD_SA key material.
|
||||
*
|
||||
@@ -117,7 +117,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*child_keys)(listener_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
|
||||
diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called if an IKE_SA gets up or down.
|
||||
*
|
||||
@@ -126,7 +126,7 @@ struct listener_t {
|
||||
* @return TRUE to stay registered, FALSE to unregister
|
||||
*/
|
||||
bool (*ike_updown)(listener_t *this, ike_sa_t *ike_sa, bool up);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called when an IKE_SA gets rekeyed.
|
||||
*
|
||||
@@ -135,7 +135,7 @@ struct listener_t {
|
||||
* @return TRUE to stay registered, FALSE to unregister
|
||||
*/
|
||||
bool (*ike_rekey)(listener_t *this, ike_sa_t *old, ike_sa_t *new);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called when a CHILD_SA gets up or down.
|
||||
*
|
||||
@@ -146,7 +146,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*child_updown)(listener_t *this, ike_sa_t *ike_sa,
|
||||
child_sa_t *child_sa, bool up);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called when an CHILD_SA gets rekeyed.
|
||||
*
|
||||
@@ -157,7 +157,7 @@ struct listener_t {
|
||||
*/
|
||||
bool (*child_rekey)(listener_t *this, ike_sa_t *ike_sa,
|
||||
child_sa_t *old, child_sa_t *new);
|
||||
|
||||
|
||||
/**
|
||||
* Hook called to invoke additional authorization rules.
|
||||
*
|
||||
|
||||
@@ -25,17 +25,17 @@ typedef struct private_sys_logger_t private_sys_logger_t;
|
||||
* Private data of a sys_logger_t object
|
||||
*/
|
||||
struct private_sys_logger_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public data.
|
||||
*/
|
||||
sys_logger_t public;
|
||||
|
||||
|
||||
/**
|
||||
* syslog facility to use
|
||||
*/
|
||||
int facility;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum level to log, for each group
|
||||
*/
|
||||
@@ -52,10 +52,10 @@ static bool log_(private_sys_logger_t *this, debug_t group, level_t level,
|
||||
{
|
||||
char buffer[8192];
|
||||
char *current = buffer, *next;
|
||||
|
||||
|
||||
/* write in memory buffer first */
|
||||
vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
|
||||
|
||||
/* do a syslog with every line */
|
||||
while (current)
|
||||
{
|
||||
@@ -106,16 +106,16 @@ static void destroy(private_sys_logger_t *this)
|
||||
sys_logger_t *sys_logger_create(int facility)
|
||||
{
|
||||
private_sys_logger_t *this = malloc_thing(private_sys_logger_t);
|
||||
|
||||
|
||||
/* public functions */
|
||||
memset(&this->public.listener, 0, sizeof(listener_t));
|
||||
this->public.listener.log = (bool(*)(listener_t*,debug_t,level_t,int,ike_sa_t*,char*,va_list))log_;
|
||||
this->public.set_level = (void(*)(sys_logger_t*,debug_t,level_t))set_level;
|
||||
this->public.destroy = (void(*)(sys_logger_t*))destroy;
|
||||
|
||||
|
||||
/* private variables */
|
||||
this->facility = facility;
|
||||
set_level(this, DBG_ANY, LEVEL_SILENT);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ typedef struct sys_logger_t sys_logger_t;
|
||||
* Logger for syslog which implements listener_t.
|
||||
*/
|
||||
struct sys_logger_t {
|
||||
|
||||
|
||||
/**
|
||||
* Implements the listener_t interface.
|
||||
*/
|
||||
listener_t listener;
|
||||
|
||||
|
||||
/**
|
||||
* Set the loglevel for a debug group.
|
||||
*
|
||||
@@ -44,7 +44,7 @@ struct sys_logger_t {
|
||||
* @param level max level to log (0..4)
|
||||
*/
|
||||
void (*set_level) (sys_logger_t *this, debug_t group, level_t level);
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a sys_logger_t object.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user