aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/utils')
-rw-r--r--src/libstrongswan/utils/hashtable.c4
-rw-r--r--src/libstrongswan/utils/host.c40
-rw-r--r--src/libstrongswan/utils/host.h9
-rw-r--r--src/libstrongswan/utils/identification.c38
-rw-r--r--src/libstrongswan/utils/identification.h11
-rw-r--r--src/libstrongswan/utils/leak_detective.c1
-rw-r--r--src/libstrongswan/utils/linked_list.c10
7 files changed, 35 insertions, 78 deletions
diff --git a/src/libstrongswan/utils/hashtable.c b/src/libstrongswan/utils/hashtable.c
index 9c364dddf..295f28565 100644
--- a/src/libstrongswan/utils/hashtable.c
+++ b/src/libstrongswan/utils/hashtable.c
@@ -282,7 +282,7 @@ static void *get(private_hashtable_t *this, void *key)
/**
* Implementation of hashtable_t.remove
*/
-static void *remove(private_hashtable_t *this, void *key)
+static void *remove_(private_hashtable_t *this, void *key)
{
void *value = NULL;
linked_list_t *list;
@@ -414,7 +414,7 @@ hashtable_t *hashtable_create(hashtable_hash_t hash, hashtable_equals_t equals,
this->public.put = (void*(*)(hashtable_t*,void*,void*))put;
this->public.get = (void*(*)(hashtable_t*,void*))get;
- this->public.remove = (void*(*)(hashtable_t*,void*))remove;
+ this->public.remove = (void*(*)(hashtable_t*,void*))remove_;
this->public.get_count = (u_int(*)(hashtable_t*))get_count;
this->public.create_enumerator = (enumerator_t*(*)(hashtable_t*))create_enumerator;
this->public.destroy = (void(*)(hashtable_t*))destroy;
diff --git a/src/libstrongswan/utils/host.c b/src/libstrongswan/utils/host.c
index eddd6f163..cb2b6a10f 100644
--- a/src/libstrongswan/utils/host.c
+++ b/src/libstrongswan/utils/host.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2007 Tobias Brunner
+ * Copyright (C) 2006-2009 Tobias Brunner
* Copyright (C) 2006 Daniel Roethlisberger
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
@@ -21,7 +21,6 @@
#define _GNU_SOURCE
#include <netdb.h>
#include <string.h>
-#include <printf.h>
#include "host.h"
@@ -106,10 +105,10 @@ static bool is_anyaddr(private_host_t *this)
}
/**
- * output handler in printf()
+ * Described in header.
*/
-static int print(FILE *stream, const struct printf_info *info,
- const void *const *args)
+int host_printf_hook(char *dst, size_t dstlen, printf_hook_spec_t *spec,
+ const void *const *args)
{
private_host_t *this = *((private_host_t**)(args[0]));
char buffer[INET6_ADDRSTRLEN + 16];
@@ -145,7 +144,7 @@ static int print(FILE *stream, const struct printf_info *info,
snprintf(buffer, sizeof(buffer),
"(address conversion failed)");
}
- else if (info->alt)
+ else if (spec->hash)
{
len = strlen(buffer);
snprintf(buffer + len, sizeof(buffer) - len,
@@ -157,34 +156,11 @@ static int print(FILE *stream, const struct printf_info *info,
break;
}
}
- if (info->left)
+ if (spec->minus)
{
- return fprintf(stream, "%-*s", info->width, buffer);
+ return print_in_hook(dst, dstlen, "%-*s", spec->width, buffer);
}
- return fprintf(stream, "%*s", info->width, buffer);
-}
-
-
-/**
- * arginfo handler for printf() hosts
- */
-int arginfo(const struct printf_info *info, size_t n, int *argtypes)
-{
- if (n > 0)
- {
- argtypes[0] = PA_POINTER;
- }
- return 1;
-}
-
-/**
- * return printf hook functions for a host
- */
-printf_hook_functions_t host_get_printf_hooks()
-{
- printf_hook_functions_t hooks = {print, arginfo};
-
- return hooks;
+ return print_in_hook(dst, dstlen, "%*s", spec->width, buffer);
}
/**
diff --git a/src/libstrongswan/utils/host.h b/src/libstrongswan/utils/host.h
index 667cc6bcc..5f00872b8 100644
--- a/src/libstrongswan/utils/host.h
+++ b/src/libstrongswan/utils/host.h
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2005-2008 Martin Willi
- * Copyright (C) 2006-2007 Tobias Brunner
+ * Copyright (C) 2006-2009 Tobias Brunner
* Copyright (C) 2006 Daniel Roethlisberger
+ * Copyright (C) 2005-2008 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -198,12 +198,13 @@ host_t *host_create_from_sockaddr(sockaddr_t *sockaddr);
host_t *host_create_any(int family);
/**
- * Get printf hooks for a host.
+ * printf hook function for host_t.
*
* Arguments are:
* host_t *host
* Use #-modifier to include port number
*/
-printf_hook_functions_t host_get_printf_hooks();
+int host_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
+ const void *const *args);
#endif /* HOST_H_ @}*/
diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c
index fad7e6acc..44e63b626 100644
--- a/src/libstrongswan/utils/identification.c
+++ b/src/libstrongswan/utils/identification.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2009 Tobias Brunner
* Copyright (C) 2005-2008 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
@@ -23,7 +24,6 @@
#include <string.h>
#include <stdio.h>
#include <ctype.h>
-#include <printf.h>
#include "identification.h"
@@ -879,10 +879,10 @@ static id_match_t matches_dn(private_identification_t *this,
}
/**
- * output handler in printf()
+ * Described in header.
*/
-static int print(FILE *stream, const struct printf_info *info,
- const void *const *args)
+int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
+ const void *const *args)
{
private_identification_t *this = *((private_identification_t**)(args[0]));
char buf[BUF_LEN];
@@ -890,7 +890,7 @@ static int print(FILE *stream, const struct printf_info *info,
if (this == NULL)
{
- return fprintf(stream, "%*s", info->width, "(null)");
+ return print_in_hook(dst, len, "%*s", spec->width, "(null)");
}
switch (this->type)
@@ -940,33 +940,11 @@ static int print(FILE *stream, const struct printf_info *info,
snprintf(buf, sizeof(buf), "(unknown ID type: %d)", this->type);
break;
}
- if (info->left)
- {
- return fprintf(stream, "%-*s", info->width, buf);
- }
- return fprintf(stream, "%*s", info->width, buf);
-}
-
-/**
- * arginfo handler
- */
-static int arginfo(const struct printf_info *info, size_t n, int *argtypes)
-{
- if (n > 0)
+ if (spec->minus)
{
- argtypes[0] = PA_POINTER;
+ return print_in_hook(dst, len, "%-*s", spec->width, buf);
}
- return 1;
-}
-
-/**
- * Get printf hook functions
- */
-printf_hook_functions_t identification_get_printf_hooks()
-{
- printf_hook_functions_t hook = {print, arginfo};
-
- return hook;
+ return print_in_hook(dst, len, "%*s", spec->width, buf);
}
/**
diff --git a/src/libstrongswan/utils/identification.h b/src/libstrongswan/utils/identification.h
index c83db3aee..1b5427bca 100644
--- a/src/libstrongswan/utils/identification.h
+++ b/src/libstrongswan/utils/identification.h
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2009 Tobias Brunner
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
@@ -274,10 +275,12 @@ identification_t * identification_create_from_string(char *string);
identification_t * identification_create_from_encoding(id_type_t type, chunk_t encoded);
/**
- * Get the printf hook functions.
- *
- * @return printf hook functions
+ * printf hook function for identification_t.
+ *
+ * Arguments are:
+ * identification_t *identification
*/
-printf_hook_functions_t identification_get_printf_hooks();
+int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
+ const void *const *args);
#endif /* IDENTIFICATION_H_ @} */
diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c
index 63d1635f6..7983940b5 100644
--- a/src/libstrongswan/utils/leak_detective.c
+++ b/src/libstrongswan/utils/leak_detective.c
@@ -29,7 +29,6 @@
#include <syslog.h>
#include <pthread.h>
#include <netdb.h>
-#include <printf.h>
#include <locale.h>
#include "leak_detective.h"
diff --git a/src/libstrongswan/utils/linked_list.c b/src/libstrongswan/utils/linked_list.c
index 45d17c80f..ce34985bf 100644
--- a/src/libstrongswan/utils/linked_list.c
+++ b/src/libstrongswan/utils/linked_list.c
@@ -224,7 +224,7 @@ static void iterator_reset(private_iterator_t *this)
/**
* Implementation of iterator_t.remove.
*/
-static status_t remove_(private_iterator_t *this)
+static status_t iterator_remove(private_iterator_t *this)
{
element_t *new_current;
@@ -514,8 +514,8 @@ static status_t remove_last(private_linked_list_t *this, void **item)
/**
* Implementation of linked_list_t.remove.
*/
-static int remove(private_linked_list_t *this, void *item,
- bool (*compare)(void *,void*))
+static int remove_(private_linked_list_t *this, void *item,
+ bool (*compare)(void *,void*))
{
element_t *current = this->first;
int removed = 0;
@@ -727,7 +727,7 @@ static iterator_t *create_iterator(private_linked_list_t *linked_list, bool forw
this->public.insert_before = (void (*) (iterator_t*, void *item)) insert_before;
this->public.insert_after = (void (*) (iterator_t*, void *item)) insert_after;
this->public.replace = (status_t (*) (iterator_t*, void **, void *)) replace;
- this->public.remove = (status_t (*) (iterator_t*)) remove_;
+ this->public.remove = (status_t (*) (iterator_t*)) iterator_remove;
this->public.reset = (void (*) (iterator_t*)) iterator_reset;
this->public.destroy = (void (*) (iterator_t*)) iterator_destroy;
@@ -756,7 +756,7 @@ linked_list_t *linked_list_create()
this->public.insert_last = (void (*) (linked_list_t *, void *item))insert_last;
this->public.remove_first = (status_t (*) (linked_list_t *, void **item))remove_first;
this->public.remove_last = (status_t (*) (linked_list_t *, void **item))remove_last;
- this->public.remove = (int(*)(linked_list_t*, void *item, bool (*compare)(void *,void*)))remove;
+ this->public.remove = (int(*)(linked_list_t*, void *item, bool (*compare)(void *,void*)))remove_;
this->public.remove_at = (void(*)(linked_list_t*, enumerator_t *enumerator))remove_at;
this->public.invoke_offset = (void (*)(linked_list_t*,size_t,...))invoke_offset;
this->public.invoke_function = (void (*)(linked_list_t*,linked_list_invoke_t,...))invoke_function;