better split up of library files "types.h" & "definitions.h"
centralized all printf specifier character definitions reuse of arginfo handlers more cleanups fixed more AMD64 issues added DEBUG_LEVEL compile flag to exclude DBGn() statements
This commit is contained in:
@@ -154,24 +154,12 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* arginfo handler in printf()
|
||||
*/
|
||||
static int print_arginfo(const struct printf_info *info, size_t n, int *argtypes)
|
||||
{
|
||||
if (n > 0)
|
||||
{
|
||||
argtypes[0] = PA_POINTER;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* register printf() handlers
|
||||
*/
|
||||
static void __attribute__ ((constructor))print_register()
|
||||
{
|
||||
register_printf_function(HOST_PRINTF_SPEC, print, print_arginfo);
|
||||
register_printf_function(PRINTF_HOST, print, arginfo_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +167,7 @@ static void __attribute__ ((constructor))print_register()
|
||||
*/
|
||||
static chunk_t get_address(private_host_t *this)
|
||||
{
|
||||
chunk_t address = CHUNK_INITIALIZER;
|
||||
chunk_t address = chunk_empty;
|
||||
|
||||
switch (this->address.sa_family)
|
||||
{
|
||||
|
||||
@@ -36,14 +36,7 @@ typedef struct host_t host_t;
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/xfrm.h>
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/**
|
||||
* printf() specifier to print a host.
|
||||
* The specifier option '#' does include the port number, e.g.:
|
||||
* printf("my host is %#H\n", my_host);
|
||||
*/
|
||||
#define HOST_PRINTF_SPEC 'H'
|
||||
#include <library.h>
|
||||
|
||||
/**
|
||||
* Differences between two hosts. They differ in
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <ctype.h>
|
||||
#include <printf.h>
|
||||
|
||||
#include "definitions.h"
|
||||
#include "identification.h"
|
||||
|
||||
#include <asn1/asn1.h>
|
||||
@@ -251,8 +250,8 @@ static chunk_t sanitize_chunk(chunk_t chunk)
|
||||
*/
|
||||
static status_t init_rdn(chunk_t dn, chunk_t *rdn, chunk_t *attribute, bool *next)
|
||||
{
|
||||
*rdn = CHUNK_INITIALIZER;
|
||||
*attribute = CHUNK_INITIALIZER;
|
||||
*rdn = chunk_empty;
|
||||
*attribute = chunk_empty;
|
||||
|
||||
/* a DN is a SEQUENCE OF RDNs */
|
||||
if (*dn.ptr != ASN1_SEQUENCE)
|
||||
@@ -285,8 +284,8 @@ static status_t get_next_rdn(chunk_t *rdn, chunk_t * attribute, chunk_t *oid, ch
|
||||
chunk_t body;
|
||||
|
||||
/* initialize return values */
|
||||
*oid = CHUNK_INITIALIZER;
|
||||
*value = CHUNK_INITIALIZER;
|
||||
*oid = chunk_empty;
|
||||
*value = chunk_empty;
|
||||
|
||||
/* if all attributes have been parsed, get next rdn */
|
||||
if (attribute->len <= 0)
|
||||
@@ -569,8 +568,8 @@ static status_t atodn(char *src, chunk_t *dn)
|
||||
UNKNOWN_OID = 4
|
||||
} state_t;
|
||||
|
||||
chunk_t oid = CHUNK_INITIALIZER;
|
||||
chunk_t name = CHUNK_INITIALIZER;
|
||||
chunk_t oid = chunk_empty;
|
||||
chunk_t name = chunk_empty;
|
||||
chunk_t rdns[RDN_MAX];
|
||||
int rdn_count = 0;
|
||||
int dn_len = 0;
|
||||
@@ -614,7 +613,7 @@ static status_t atodn(char *src, chunk_t *dn)
|
||||
break;
|
||||
}
|
||||
/* reset oid and change state */
|
||||
oid = CHUNK_INITIALIZER;
|
||||
oid = chunk_empty;
|
||||
state = SEARCH_NAME;
|
||||
}
|
||||
break;
|
||||
@@ -658,7 +657,7 @@ static status_t atodn(char *src, chunk_t *dn)
|
||||
status = OUT_OF_RES;
|
||||
}
|
||||
/* reset name and change state */
|
||||
name = CHUNK_INITIALIZER;
|
||||
name = chunk_empty;
|
||||
state = SEARCH_OID;
|
||||
}
|
||||
break;
|
||||
@@ -683,7 +682,7 @@ static status_t atodn(char *src, chunk_t *dn)
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
free(dn->ptr);
|
||||
*dn = CHUNK_INITIALIZER;
|
||||
*dn = chunk_empty;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -911,24 +910,12 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* arginfo handler in printf()
|
||||
*/
|
||||
static int print_arginfo(const struct printf_info *info, size_t n, int *argtypes)
|
||||
{
|
||||
if (n > 0)
|
||||
{
|
||||
argtypes[0] = PA_POINTER;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* register printf() handlers
|
||||
*/
|
||||
static void __attribute__ ((constructor))print_register()
|
||||
{
|
||||
register_printf_function(IDENTIFICATION_PRINTF_SPEC, print, print_arginfo);
|
||||
register_printf_function(PRINTF_IDENTIFICATION, print, arginfo_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -971,7 +958,7 @@ static private_identification_t *identification_create(void)
|
||||
this->public.equals = (bool (*) (identification_t*,identification_t*))equals_binary;
|
||||
this->public.matches = (bool (*) (identification_t*,identification_t*,int*))matches_binary;
|
||||
|
||||
this->encoded = CHUNK_INITIALIZER;
|
||||
this->encoded = chunk_empty;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -28,13 +28,9 @@
|
||||
typedef enum id_type_t id_type_t;
|
||||
typedef struct identification_t identification_t;
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
|
||||
#define MAX_WILDCARDS 14
|
||||
/**
|
||||
* printf() specifier to print a identification.
|
||||
*/
|
||||
#define IDENTIFICATION_PRINTF_SPEC 'D'
|
||||
|
||||
/**
|
||||
* @brief ID Types in a ID payload.
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
|
||||
#include "leak_detective.h"
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
#include <debug.h>
|
||||
|
||||
#ifdef LEAK_DETECTIVE
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ bool extract_token(chunk_t *token, const char termination, chunk_t *src)
|
||||
u_char *eot = memchr(src->ptr, termination, src->len);
|
||||
|
||||
/* initialize empty token */
|
||||
*token = CHUNK_INITIALIZER;
|
||||
*token = chunk_empty;
|
||||
|
||||
if (eot == NULL) /* termination symbol not found */
|
||||
{
|
||||
@@ -98,7 +98,7 @@ err_t extract_value(chunk_t *value, chunk_t *line)
|
||||
|
||||
if (!eat_whitespace(line))
|
||||
{
|
||||
*value = CHUNK_INITIALIZER;
|
||||
*value = chunk_empty;
|
||||
return NULL;
|
||||
}
|
||||
if (*line->ptr == '\'' || *line->ptr == '"')
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
|
||||
/**
|
||||
* @brief Eats whitespace
|
||||
|
||||
@@ -669,15 +669,15 @@ static iterator_t *create_iterator(private_linked_list_t *linked_list, bool forw
|
||||
{
|
||||
private_iterator_t *this = malloc_thing(private_iterator_t);
|
||||
|
||||
this->public.get_count = (bool (*) (iterator_t *this)) get_list_count;
|
||||
this->public.iterate = (bool (*) (iterator_t *this, void **value)) iterate;
|
||||
this->public.set_iterator_hook = (void(*)(iterator_t *this, void*(*)(void*)))set_iterator_hook;
|
||||
this->public.insert_before = (void (*) (iterator_t *this, void *item)) insert_before;
|
||||
this->public.insert_after = (void (*) (iterator_t *this, void *item)) insert_after;
|
||||
this->public.replace = (status_t (*) (iterator_t *, void **, void *)) replace;
|
||||
this->public.remove = (status_t (*) (iterator_t *this)) remove_;
|
||||
this->public.reset = (void (*) (iterator_t *this)) iterator_reset;
|
||||
this->public.destroy = (void (*) (iterator_t *this)) iterator_destroy;
|
||||
this->public.get_count = (int (*) (iterator_t*)) get_list_count;
|
||||
this->public.iterate = (bool (*) (iterator_t*, void **value)) iterate;
|
||||
this->public.set_iterator_hook = (void(*)(iterator_t*, void*(*)(void*)))set_iterator_hook;
|
||||
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.reset = (void (*) (iterator_t*)) iterator_reset;
|
||||
this->public.destroy = (void (*) (iterator_t*)) iterator_destroy;
|
||||
|
||||
this->forward = forward;
|
||||
this->current = NULL;
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef struct linked_list_t linked_list_t;
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
#include <utils/iterator.h>
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
typedef struct randomizer_t randomizer_t;
|
||||
|
||||
#include <types.h>
|
||||
#include <library.h>
|
||||
|
||||
#ifndef DEV_RANDOM
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user