X-Git-Url: https://git.strongswan.org/?p=strongswan.git;a=blobdiff_plain;f=src%2Flibstrongswan%2Flibrary.c;h=3a76a5a05440799dce4678ba83d5e0a7579b87f3;hp=cd40b647788320a450cf773c235267cbb9b9a4b8;hb=aa3af83a80c45f77584f776dc0832bc04c2631da;hpb=db7ef62494fb6859df150e2b06b3ca91881d95af diff --git a/src/libstrongswan/library.c b/src/libstrongswan/library.c index cd40b64..3a76a5a 100644 --- a/src/libstrongswan/library.c +++ b/src/libstrongswan/library.c @@ -43,6 +43,7 @@ ENUM(status_names, SUCCESS, DESTROY_ME, "VERIFY_ERROR", "INVALID_STATE", "DESTROY_ME", + "NEED_MORE", ); /** @@ -59,6 +60,18 @@ void *clalloc(void * pointer, size_t size) } /** + * Described in header. + */ +void memxor(u_int8_t dest[], u_int8_t src[], size_t n) +{ + size_t i; + for (i = 0; i < n; i++) + { + dest[i] ^= src[i]; + } +} + +/** * We use a single mutex for all refcount variables. This * is not optimal for performance, but the critical section * is not that long... @@ -105,7 +118,7 @@ static int print_time(FILE *stream, const struct printf_info *info, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - time_t time = *((time_t*)(args[0])); + time_t *time = *((time_t**)(args[0])); bool utc = TRUE; struct tm t; @@ -120,11 +133,11 @@ static int print_time(FILE *stream, const struct printf_info *info, } if (utc) { - gmtime_r(&time, &t); + gmtime_r(time, &t); } else { - localtime_r(&time, &t); + localtime_r(time, &t); } return fprintf(stream, "%s %02d %02d:%02d:%02d%s%04d", months[t.tm_mon], t.tm_mday, t.tm_hour, t.tm_min, @@ -137,11 +150,12 @@ static int print_time(FILE *stream, const struct printf_info *info, static int print_time_delta(FILE *stream, const struct printf_info *info, const void *const *args) { - time_t start = *((time_t*)(args[0])); - time_t end = *((time_t*)(args[1])); - u_int delta = abs(end - start); + time_t *start = *((time_t**)(args[0])); + time_t *end = *((time_t**)(args[1])); + u_int delta = abs(*end - *start); + char* unit = "second"; - + if (delta > 2 * 60 * 60 * 24) { delta /= 60 * 60 * 24; @@ -165,6 +179,6 @@ static int print_time_delta(FILE *stream, const struct printf_info *info, */ static void __attribute__ ((constructor))print_register() { - register_printf_function(PRINTF_TIME, print_time, arginfo_int_alt_int_int); - register_printf_function(PRINTF_TIME_DELTA, print_time_delta, arginfo_int_int); + register_printf_function(PRINTF_TIME, print_time, arginfo_ptr_alt_ptr_int); + register_printf_function(PRINTF_TIME_DELTA, print_time_delta, arginfo_ptr_ptr); }