Adapt everything in BT5 to new capnhook API

This includes:
- Renaming of functions (iohook_invoke_next)
- Slight interface changes (com_proxy_wrap, iohook_push_handler)
- De-duplicate stuff from utils (iobuf, hr)
This commit is contained in:
icex2
2020-09-02 19:35:15 +00:00
parent b777396efd
commit 5de9fdee43
52 changed files with 265 additions and 333 deletions
-1
View File
@@ -7,7 +7,6 @@ src_util := \
crypto.c \
fs.c \
hex.c \
hr.c \
iobuf.c \
list.c \
log.c \
-61
View File
@@ -1,61 +0,0 @@
#include <windows.h>
#include <stdint.h>
#include "util/hr.h"
HRESULT
hr_from_win32(void)
{
return HRESULT_FROM_WIN32(GetLastError());
}
void hr_propagate_win32_(HRESULT hr)
{
uint32_t result;
if (SUCCEEDED(hr)) {
result = ERROR_SUCCESS;
} else if (HRESULT_FACILITY(hr) == FACILITY_WIN32) {
result = HRESULT_CODE(hr);
} else {
// https://docs.microsoft.com/en-us/windows/desktop/seccrypto/common-hresult-values
switch (hr) {
case E_ABORT:
result = ERROR_OPERATION_ABORTED;
break;
case E_ACCESSDENIED:
result = ERROR_ACCESS_DENIED;
break;
case E_FAIL:
result = ERROR_GEN_FAILURE;
break;
case E_HANDLE:
result = ERROR_INVALID_HANDLE;
break;
case E_INVALIDARG:
result = ERROR_INVALID_PARAMETER;
break;
case E_NOINTERFACE:
result = ERROR_NOT_SUPPORTED;
break;
case E_NOTIMPL:
result = ERROR_NOT_SUPPORTED;
break;
case E_OUTOFMEMORY:
result = ERROR_OUTOFMEMORY;
break;
case E_POINTER:
result = ERROR_INVALID_ADDRESS;
break;
case E_UNEXPECTED:
result = ERROR_INTERNAL_ERROR;
break;
default:
result = ERROR_INTERNAL_ERROR;
break;
}
}
SetLastError(result);
}
-11
View File
@@ -1,11 +0,0 @@
#ifndef UTIL_HR_H
#define UTIL_HR_H
#include <windows.h>
#define hr_propagate_win32(hr, r) (hr_propagate_win32_(hr), r)
HRESULT hr_from_win32(void);
void hr_propagate_win32_(HRESULT hr);
#endif
+1 -31
View File
@@ -1,40 +1,10 @@
#define LOG_MODULE "iobuf"
#include <string.h>
#define LOG_MODULE "util-iobuf"
#include "util/hex.h"
#include "util/iobuf.h"
#include "util/log.h"
#include "util/mem.h"
size_t iobuf_move(struct iobuf *dest, struct const_iobuf *src)
{
size_t dest_avail;
size_t src_avail;
size_t chunksz;
dest_avail = dest->nbytes - dest->pos;
src_avail = src->nbytes - src->pos;
chunksz = dest_avail < src_avail ? dest_avail : src_avail;
memcpy(&dest->bytes[dest->pos], &src->bytes[src->pos], chunksz);
dest->pos += chunksz;
src->pos += chunksz;
return chunksz;
}
void iobuf_flip(struct const_iobuf *dest, const struct iobuf *src)
{
log_assert(dest != NULL);
log_assert(src != NULL);
dest->bytes = src->bytes;
dest->pos = 0;
dest->nbytes = src->pos;
}
void iobuf_log(struct iobuf *buffer, const char *tag)
{
char *str;
+1 -15
View File
@@ -4,21 +4,7 @@
#include <stddef.h>
#include <stdint.h>
struct iobuf {
uint8_t *bytes;
size_t nbytes;
size_t pos;
};
struct const_iobuf {
const uint8_t *bytes;
size_t nbytes;
size_t pos;
};
size_t iobuf_move(struct iobuf *dest, struct const_iobuf *src);
void iobuf_flip(struct const_iobuf *dest, const struct iobuf *src);
#include "hook/iobuf.h"
void iobuf_log(struct iobuf *buffer, const char *tag);