From 94529e1e04880166d33a4aa89db3e7d1d25d8be4 Mon Sep 17 00:00:00 2001 From: icex2 Date: Thu, 2 Mar 2023 19:09:18 +0100 Subject: [PATCH] Code format --- src/main/capnhook/hook/iobuf.c | 16 +++---- src/main/capnhook/hook/lib-main.h | 4 +- src/main/crypt/lib/md5.c | 40 ++++++++--------- src/main/crypt/lib/rijndael.c | 18 ++++---- src/main/hook/exc/lockchip.c | 4 +- src/main/hook/exc/options.c | 5 ++- src/main/hook/f2/options.c | 5 ++- src/main/hook/fex/options.c | 5 ++- src/main/hook/fst/options.c | 5 ++- src/main/hook/nx/options.c | 5 ++- src/main/hook/nx2/options.c | 5 ++- src/main/hook/nxa/options.c | 5 ++- src/main/hook/patch/gfx.c | 9 ++-- src/main/hook/patch/gfx.h | 10 ++--- src/main/hook/patch/net-profile.c | 17 ++------ src/main/hook/pri/options.c | 5 ++- src/main/hook/x2/options.c | 5 ++- src/main/hook/zero/options.c | 5 ++- src/main/io/util/usb.c | 9 +--- src/main/io/util/usb_.h | 6 +-- src/main/ptapi/io/piuio/lxio/lxio.c | 67 ++++++++++++++++------------- src/main/sec/hasp/lib/asn1.c | 30 ++++++------- src/main/util/options.c | 5 ++- src/main/util/patch.c | 2 +- src/main/util/sock-tcp.c | 12 +++--- src/main/util/time.c | 10 ++--- 26 files changed, 166 insertions(+), 143 deletions(-) diff --git a/src/main/capnhook/hook/iobuf.c b/src/main/capnhook/hook/iobuf.c index a67cb1c..7f146a9 100644 --- a/src/main/capnhook/hook/iobuf.c +++ b/src/main/capnhook/hook/iobuf.c @@ -202,7 +202,7 @@ enum cnh_result cnh_iobuf_write_be16(struct cnh_iobuf *dest, uint16_t value) return CNH_RESULT_ERROR_INSUFFICIENT_BUFFER; } - dest->bytes[dest->pos++] = (uint8_t)(value >> 8); + dest->bytes[dest->pos++] = (uint8_t) (value >> 8); dest->bytes[dest->pos++] = (uint8_t) value; return CNH_RESULT_SUCCESS; @@ -216,9 +216,9 @@ enum cnh_result cnh_iobuf_write_be32(struct cnh_iobuf *dest, uint32_t value) return CNH_RESULT_ERROR_INSUFFICIENT_BUFFER; } - dest->bytes[dest->pos++] = (uint8_t)(value >> 24); - dest->bytes[dest->pos++] = (uint8_t)(value >> 16); - dest->bytes[dest->pos++] = (uint8_t)(value >> 8); + dest->bytes[dest->pos++] = (uint8_t) (value >> 24); + dest->bytes[dest->pos++] = (uint8_t) (value >> 16); + dest->bytes[dest->pos++] = (uint8_t) (value >> 8); dest->bytes[dest->pos++] = (uint8_t) value; return CNH_RESULT_SUCCESS; @@ -233,7 +233,7 @@ enum cnh_result cnh_iobuf_write_le16(struct cnh_iobuf *dest, uint16_t value) } dest->bytes[dest->pos++] = (uint8_t) value; - dest->bytes[dest->pos++] = (uint8_t)(value >> 8); + dest->bytes[dest->pos++] = (uint8_t) (value >> 8); return CNH_RESULT_SUCCESS; } @@ -247,9 +247,9 @@ enum cnh_result cnh_iobuf_write_le32(struct cnh_iobuf *dest, uint32_t value) } dest->bytes[dest->pos++] = (uint8_t) value; - dest->bytes[dest->pos++] = (uint8_t)(value >> 8); - dest->bytes[dest->pos++] = (uint8_t)(value >> 16); - dest->bytes[dest->pos++] = (uint8_t)(value >> 24); + dest->bytes[dest->pos++] = (uint8_t) (value >> 8); + dest->bytes[dest->pos++] = (uint8_t) (value >> 16); + dest->bytes[dest->pos++] = (uint8_t) (value >> 24); return CNH_RESULT_SUCCESS; } diff --git a/src/main/capnhook/hook/lib-main.h b/src/main/capnhook/hook/lib-main.h index 845bfdd..3b50702 100644 --- a/src/main/capnhook/hook/lib-main.h +++ b/src/main/capnhook/hook/lib-main.h @@ -27,7 +27,7 @@ #define LIB_MAIN_TRAP_MAIN(func_before_main, func_after_main) \ typedef int (*func_libc_start_main_t)( \ - int *(main)(int, char **, char **), \ + int *(main) (int, char **, char **), \ int argc, \ char **ubp_av, \ void (*init)(void), \ @@ -58,7 +58,7 @@ } \ \ int __libc_start_main( \ - int *(main)(int, char **, char **), \ + int *(main) (int, char **, char **), \ int argc, \ char **ubp_av, \ void (*init)(void), \ diff --git a/src/main/crypt/lib/md5.c b/src/main/crypt/lib/md5.c index 2f0d6df..62ce1e4 100644 --- a/src/main/crypt/lib/md5.c +++ b/src/main/crypt/lib/md5.c @@ -67,29 +67,29 @@ static unsigned char PADDING[64] = { /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent recomputation. */ -#define FF(a, b, c, d, x, s, ac) \ - { \ - (a) += F((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT((a), (s)); \ - (a) += (b); \ +#define FF(a, b, c, d, x, s, ac) \ + { \ + (a) += F((b), (c), (d)) + (x) + (uint32_t) (ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ } -#define GG(a, b, c, d, x, s, ac) \ - { \ - (a) += G((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT((a), (s)); \ - (a) += (b); \ +#define GG(a, b, c, d, x, s, ac) \ + { \ + (a) += G((b), (c), (d)) + (x) + (uint32_t) (ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ } -#define HH(a, b, c, d, x, s, ac) \ - { \ - (a) += H((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT((a), (s)); \ - (a) += (b); \ +#define HH(a, b, c, d, x, s, ac) \ + { \ + (a) += H((b), (c), (d)) + (x) + (uint32_t) (ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ } -#define II(a, b, c, d, x, s, ac) \ - { \ - (a) += I((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT((a), (s)); \ - (a) += (b); \ +#define II(a, b, c, d, x, s, ac) \ + { \ + (a) += I((b), (c), (d)) + (x) + (uint32_t) (ac); \ + (a) = ROTATE_LEFT((a), (s)); \ + (a) += (b); \ } /* MD5 initialization. Begins an MD5 operation, writing a new context. diff --git a/src/main/crypt/lib/rijndael.c b/src/main/crypt/lib/rijndael.c index a050ede..34a3be9 100644 --- a/src/main/crypt/lib/rijndael.c +++ b/src/main/crypt/lib/rijndael.c @@ -569,16 +569,16 @@ static const u32 rcon[] = { /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; -#define GETU32(plaintext) \ - (((u32)(plaintext)[0] << 24) ^ ((u32)(plaintext)[1] << 16) ^ \ - ((u32)(plaintext)[2] << 8) ^ ((u32)(plaintext)[3])) +#define GETU32(plaintext) \ + (((u32) (plaintext)[0] << 24) ^ ((u32) (plaintext)[1] << 16) ^ \ + ((u32) (plaintext)[2] << 8) ^ ((u32) (plaintext)[3])) -#define PUTU32(ciphertext, st) \ - { \ - (ciphertext)[0] = (u8)((st) >> 24); \ - (ciphertext)[1] = (u8)((st) >> 16); \ - (ciphertext)[2] = (u8)((st) >> 8); \ - (ciphertext)[3] = (u8)(st); \ +#define PUTU32(ciphertext, st) \ + { \ + (ciphertext)[0] = (u8) ((st) >> 24); \ + (ciphertext)[1] = (u8) ((st) >> 16); \ + (ciphertext)[2] = (u8) ((st) >> 8); \ + (ciphertext)[3] = (u8) (st); \ } /** diff --git a/src/main/hook/exc/lockchip.c b/src/main/hook/exc/lockchip.c index 32fe73e..378185c 100644 --- a/src/main/hook/exc/lockchip.c +++ b/src/main/hook/exc/lockchip.c @@ -34,10 +34,10 @@ exchook_lockchip_dec_chunk(uint8_t len, const uint8_t *src, uint8_t *dest) for (size_t i = 1; i < len; i++) { uint8_t result = sec_lockchip_step(src[i] ^ 0xFF); - dest[i - 1] = (uint8_t)((last_res >> 3) ^ (result << 5)); + dest[i - 1] = (uint8_t) ((last_res >> 3) ^ (result << 5)); last_res = result; } uint8_t last_byte = sec_lockchip_step(0); - dest[len - 1] = (uint8_t)((last_res >> 3) ^ (last_byte << 5)); + dest[len - 1] = (uint8_t) ((last_res >> 3) ^ (last_byte << 5)); } \ No newline at end of file diff --git a/src/main/hook/exc/options.c b/src/main/hook/exc/options.c index a59e936..672143a 100644 --- a/src/main/hook/exc/options.c +++ b/src/main/hook/exc/options.c @@ -45,7 +45,10 @@ static const struct util_options_def exchook_options_def[] = { }, { .name = EXCHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/f2/options.c b/src/main/hook/f2/options.c index a1d80fa..6cc42c3 100644 --- a/src/main/hook/f2/options.c +++ b/src/main/hook/f2/options.c @@ -36,7 +36,10 @@ const struct util_options_def f2hook_options_def[] = { }, { .name = F2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/fex/options.c b/src/main/hook/fex/options.c index 70c5554..689b474 100644 --- a/src/main/hook/fex/options.c +++ b/src/main/hook/fex/options.c @@ -36,7 +36,10 @@ const struct util_options_def fexhook_options_def[] = { }, { .name = FEXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/fst/options.c b/src/main/hook/fst/options.c index 182c070..0640e42 100644 --- a/src/main/hook/fst/options.c +++ b/src/main/hook/fst/options.c @@ -36,7 +36,10 @@ const struct util_options_def fsthook_options_def[] = { }, { .name = FSTHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/nx/options.c b/src/main/hook/nx/options.c index 1d5fa5c..2d8ac35 100644 --- a/src/main/hook/nx/options.c +++ b/src/main/hook/nx/options.c @@ -35,7 +35,10 @@ static const struct util_options_def nxhook_options_def[] = { }, { .name = NXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/nx2/options.c b/src/main/hook/nx2/options.c index b817c73..25a1110 100644 --- a/src/main/hook/nx2/options.c +++ b/src/main/hook/nx2/options.c @@ -40,7 +40,10 @@ const struct util_options_def nx2hook_options_def[] = { }, { .name = NX2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/nxa/options.c b/src/main/hook/nxa/options.c index 64b6a80..b908daf 100644 --- a/src/main/hook/nxa/options.c +++ b/src/main/hook/nxa/options.c @@ -40,7 +40,10 @@ const struct util_options_def nxahook_options_def[] = { }, { .name = NXAHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/patch/gfx.c b/src/main/hook/patch/gfx.c index 765826d..b68ed7d 100644 --- a/src/main/hook/patch/gfx.c +++ b/src/main/hook/patch/gfx.c @@ -1,8 +1,8 @@ #define LOG_MODULE "patch-gfx" +#include #include #include -#include // OpenGL 3.x+ #include @@ -165,8 +165,11 @@ void patch_gfx_init() log_info("Initialized"); } -// Note, consider improving scaling, see http://www.david-amador.com/2013/04/opengl-2d-independent-resolution-rendering/ +// Note, consider improving scaling, see +// http://www.david-amador.com/2013/04/opengl-2d-independent-resolution-rendering/ void patch_gfx_scale(enum patch_gfx_scale_mode scale_mode) { - log_error("GFX scaling enabled but will not work. Temporarily removed due to issues with loading libGL.so"); + log_error( + "GFX scaling enabled but will not work. Temporarily removed due to " + "issues with loading libGL.so"); } diff --git a/src/main/hook/patch/gfx.h b/src/main/hook/patch/gfx.h index b2303a6..3a801aa 100644 --- a/src/main/hook/patch/gfx.h +++ b/src/main/hook/patch/gfx.h @@ -5,11 +5,11 @@ * resolutions including keeping the aspect ratio */ enum patch_gfx_scale_mode { - PATCH_GFX_SCALE_MODE_INVALID = 0, - PATCH_GFX_SCALE_MODE_SD_480_TO_PILLARBOX_HD_720 = 1, - PATCH_GFX_SCALE_MODE_SD_480_TO_PILLARBOX_HD_1080 = 2, - PATCH_GFX_SCALE_MODE_SD_480_TO_SD_960 = 3, - PATCH_GFX_SCALE_MODE_HD_720_TO_HD_1080 = 4, + PATCH_GFX_SCALE_MODE_INVALID = 0, + PATCH_GFX_SCALE_MODE_SD_480_TO_PILLARBOX_HD_720 = 1, + PATCH_GFX_SCALE_MODE_SD_480_TO_PILLARBOX_HD_1080 = 2, + PATCH_GFX_SCALE_MODE_SD_480_TO_SD_960 = 3, + PATCH_GFX_SCALE_MODE_HD_720_TO_HD_1080 = 4, }; /** diff --git a/src/main/hook/patch/net-profile.c b/src/main/hook/patch/net-profile.c index 1445a88..caced07 100644 --- a/src/main/hook/patch/net-profile.c +++ b/src/main/hook/patch/net-profile.c @@ -468,9 +468,7 @@ static bool _patch_net_profile_download_profile_file( virtual_file->buffer, virtual_file->file_info->file_size)) { log_error( - "Downloading file player %d, file_type %d, failed", - player, - file_type); + "Downloading file player %d, file_type %d, failed", player, file_type); return false; } @@ -536,16 +534,12 @@ static bool _patch_net_profile_upload_profile_file( virtual_file->buffer, virtual_file->file_info->file_size)) { log_error( - "Uploading file player %d, file_type %d, failed", - player, - file_type); + "Uploading file player %d, file_type %d, failed", player, file_type); return false; } log_info( - "Uploading file player %d, file_type %d, successful", - player, - file_type); + "Uploading file player %d, file_type %d, successful", player, file_type); return true; } @@ -641,10 +635,7 @@ void patch_net_profile_init( pthread_mutex_init(&_patch_net_profile_mutex, NULL); - log_info( - "Initialized: game %d, server %s", - game, - pumpnet_server_addr); + log_info("Initialized: game %d, server %s", game, pumpnet_server_addr); } void patch_net_profile_shutdown() diff --git a/src/main/hook/pri/options.c b/src/main/hook/pri/options.c index a34eb06..0e59bec 100644 --- a/src/main/hook/pri/options.c +++ b/src/main/hook/pri/options.c @@ -34,7 +34,10 @@ const struct util_options_def prihook_options_def[] = { }, { .name = PRIHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/x2/options.c b/src/main/hook/x2/options.c index 0057c89..0ba1372 100644 --- a/src/main/hook/x2/options.c +++ b/src/main/hook/x2/options.c @@ -43,7 +43,10 @@ static const struct util_options_def x2hook_options_def[] = { }, { .name = X2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/hook/zero/options.c b/src/main/hook/zero/options.c index 17c0ba4..039b072 100644 --- a/src/main/hook/zero/options.c +++ b/src/main/hook/zero/options.c @@ -43,7 +43,10 @@ static const struct util_options_def zerohook_options_def[] = { }, { .name = ZEROHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, - .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .description = + "Set a scaling mode for the rendered output. Available modes: 0 = " + "disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox " + "HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", .param = 'z', .type = UTIL_OPTIONS_TYPE_INT, .is_secret_data = false, diff --git a/src/main/io/util/usb.c b/src/main/io/util/usb.c index c7d3cff..1300888 100644 --- a/src/main/io/util/usb.c +++ b/src/main/io/util/usb.c @@ -182,18 +182,13 @@ int32_t io_usb_control_transfer( } int32_t io_usb_interrupt_transfer( - void *handle, - int ep, - uint8_t *data, - uint16_t len, - uint32_t timeout) + void *handle, int ep, uint8_t *data, uint16_t len, uint32_t timeout) { struct usb_io_ctx *dev = (struct usb_io_ctx *) handle; int32_t ret, transferred; ret = - libusb_interrupt_transfer( - dev->dev, ep, data, len, &transferred, timeout); + libusb_interrupt_transfer(dev->dev, ep, data, len, &transferred, timeout); if (transferred != len) { log_error( diff --git a/src/main/io/util/usb_.h b/src/main/io/util/usb_.h index f8a960f..442cb76 100644 --- a/src/main/io/util/usb_.h +++ b/src/main/io/util/usb_.h @@ -54,11 +54,7 @@ int32_t io_usb_control_transfer( * @return Number of bytes read/written or -1 on error */ int32_t io_usb_interrupt_transfer( - void *handle, - int ep, - uint8_t *data, - uint16_t len, - uint32_t timeout); + void *handle, int ep, uint8_t *data, uint16_t len, uint32_t timeout); /** * Close a opened usb device * diff --git a/src/main/ptapi/io/piuio/lxio/lxio.c b/src/main/ptapi/io/piuio/lxio/lxio.c index 9f3ba2c..9c2f3c8 100644 --- a/src/main/ptapi/io/piuio/lxio/lxio.c +++ b/src/main/ptapi/io/piuio/lxio/lxio.c @@ -1,7 +1,8 @@ /** - * Communicate with the Andamiro "lxio" or ATMEGAPUMP or PIU HID. + * Communicate with the Andamiro "lxio" or ATMEGAPUMP or PIU HID. * This device hosts all data in two address, and interrupt in and out. - * Device needs to be written then read in that order. Every read needs a preceding write. + * Device needs to be written then read in that order. Every read needs a + * preceding write. */ #define LOG_MODULE "ptapi-io-piuio-lxio" @@ -13,8 +14,8 @@ #include "util/log.h" -#include "ptapi/io/piuio.h" #include "ptapi/io/piubtn.h" +#include "ptapi/io/piuio.h" // Data going to/from lxio uint8_t lxio_btn_state_buffer[LXIO_MSG_SIZE]; @@ -95,19 +96,19 @@ void convert_output_to_lxio() /* Menu Buttons */ for (uint8_t i = 0; i < 2; i++) { - //both UR and UL are mapped to "back" + // both UR and UL are mapped to "back" if (ptapi_piubtn_out[i].back) { - lxio_light_state_buffer[i+4] |= (1 << 0); - lxio_light_state_buffer[i+4] |= (1 << 1); + lxio_light_state_buffer[i + 4] |= (1 << 0); + lxio_light_state_buffer[i + 4] |= (1 << 1); } if (ptapi_piubtn_out[i].start) { - lxio_light_state_buffer[i+4] |= (1 << 2); + lxio_light_state_buffer[i + 4] |= (1 << 2); } if (ptapi_piubtn_out[i].left) { - lxio_light_state_buffer[i+4] |= (1 << 3); + lxio_light_state_buffer[i + 4] |= (1 << 3); } if (ptapi_piubtn_out[i].right) { - lxio_light_state_buffer[i+4] |= (1 << 4); + lxio_light_state_buffer[i + 4] |= (1 << 4); } } } @@ -135,7 +136,6 @@ static void convert_input_to_piuio() ptapi_piuio_sys.clear = lxio_btn_state_buffer[8] & (1 << 7); ptapi_piuio_sys.coin = lxio_btn_state_buffer[8] & (1 << 2); ptapi_piuio_sys.coin2 = lxio_btn_state_buffer[9] & (1 << 2); - } bool ptapi_io_piuio_recv(void) @@ -208,20 +208,20 @@ void ptapi_io_piuio_set_output_cab( &ptapi_piuio_cab_out, outputs, sizeof(struct ptapi_io_piuio_cab_outputs)); } -const char* ptapi_io_piubtn_ident(void) +const char *ptapi_io_piubtn_ident(void) { return "lxio"; } bool ptapi_io_piubtn_open(void) { - //taken care of by piuio_open + // taken care of by piuio_open return true; } void ptapi_io_piubtn_close(void) { - //handled by piuio_close + // handled by piuio_close } bool ptapi_io_piubtn_recv(void) @@ -236,33 +236,38 @@ bool ptapi_io_piubtn_send(void) return true; } -void ptapi_io_piubtn_get_input(uint8_t player, struct ptapi_io_piubtn_inputs* inputs) +void ptapi_io_piubtn_get_input( + uint8_t player, struct ptapi_io_piubtn_inputs *inputs) { - // Note: There could be consistancy issues if the two IOs are threaded by seperate threads - // Decided to take the risk of potentially lost button inputs. Testing has yielded - // good results. + // Note: There could be consistancy issues if the two IOs are threaded by + // seperate threads Decided to take the risk of potentially lost button + // inputs. Testing has yielded good results. // Set all inputs to off if (player == 0) { - inputs->left = lxio_btn_state_buffer[10] & (1 << 3); - inputs->right = lxio_btn_state_buffer[10] & (1 << 4); - inputs->start = lxio_btn_state_buffer[10] & (1 << 2); + inputs->left = lxio_btn_state_buffer[10] & (1 << 3); + inputs->right = lxio_btn_state_buffer[10] & (1 << 4); + inputs->start = lxio_btn_state_buffer[10] & (1 << 2); - //map both UR and UL to "back" as this is how kpump maps it. - inputs->back = (lxio_btn_state_buffer[10] & (1 << 0)) | - (lxio_btn_state_buffer[10] & (1 << 1)); + // map both UR and UL to "back" as this is how kpump maps it. + inputs->back = (lxio_btn_state_buffer[10] & (1 << 0)) | + (lxio_btn_state_buffer[10] & (1 << 1)); } else { - inputs->left = lxio_btn_state_buffer[11] & (1 << 3); - inputs->right = lxio_btn_state_buffer[11] & (1 << 4); - inputs->start = lxio_btn_state_buffer[11] & (1 << 2); + inputs->left = lxio_btn_state_buffer[11] & (1 << 3); + inputs->right = lxio_btn_state_buffer[11] & (1 << 4); + inputs->start = lxio_btn_state_buffer[11] & (1 << 2); - //map both UR and UL to "back" as this is how kpump maps it. - inputs->back = (lxio_btn_state_buffer[11] & (1 << 0)) | - (lxio_btn_state_buffer[11] & (1 << 1)); + // map both UR and UL to "back" as this is how kpump maps it. + inputs->back = (lxio_btn_state_buffer[11] & (1 << 0)) | + (lxio_btn_state_buffer[11] & (1 << 1)); } } -void ptapi_io_piubtn_set_output(uint8_t player, const struct ptapi_io_piubtn_outputs* outputs) +void ptapi_io_piubtn_set_output( + uint8_t player, const struct ptapi_io_piubtn_outputs *outputs) { - memcpy(&ptapi_piubtn_out[player], outputs, sizeof(struct ptapi_io_piubtn_outputs)); + memcpy( + &ptapi_piubtn_out[player], + outputs, + sizeof(struct ptapi_io_piubtn_outputs)); } diff --git a/src/main/sec/hasp/lib/asn1.c b/src/main/sec/hasp/lib/asn1.c index 420b883..a72e5c3 100644 --- a/src/main/sec/hasp/lib/asn1.c +++ b/src/main/sec/hasp/lib/asn1.c @@ -472,18 +472,18 @@ sec_hasp_asn1_encode_int(uint32_t val, uint8_t *buffer, size_t *offset) tmp[tmp_pos++] = (uint8_t) val; } else if (val <= 0xFFFF) { /* Big endian */ - tmp[tmp_pos++] = (uint8_t)(val >> 8); + tmp[tmp_pos++] = (uint8_t) (val >> 8); tmp[tmp_pos++] = (uint8_t) val; } else if (val <= 0xFFFFFF) { /* Big endian */ - tmp[tmp_pos++] = (uint8_t)(val >> 16); - tmp[tmp_pos++] = (uint8_t)(val >> 8); + tmp[tmp_pos++] = (uint8_t) (val >> 16); + tmp[tmp_pos++] = (uint8_t) (val >> 8); tmp[tmp_pos++] = (uint8_t) val; } else if (val <= 0xFFFFFFFF) { /* Big endian */ - tmp[tmp_pos++] = (uint8_t)(val >> 24); - tmp[tmp_pos++] = (uint8_t)(val >> 16); - tmp[tmp_pos++] = (uint8_t)(val >> 8); + tmp[tmp_pos++] = (uint8_t) (val >> 24); + tmp[tmp_pos++] = (uint8_t) (val >> 16); + tmp[tmp_pos++] = (uint8_t) (val >> 8); tmp[tmp_pos++] = (uint8_t) val; } else if (val <= 0xFFFFFFFFFFFFFFFF) { // TODO quad words not supported in decode? @@ -528,20 +528,20 @@ sec_hasp_asn1_encode_length(uint32_t len, uint8_t *buffer, size_t *offset) } else if (len <= 0xFFFF) { buffer[(*offset)++] = 0x82; /* Big endian */ - buffer[(*offset)++] = (uint8_t)(len >> 8); + buffer[(*offset)++] = (uint8_t) (len >> 8); buffer[(*offset)++] = (uint8_t) len; } else if (len <= 0xFFFF) { buffer[(*offset)++] = 0x82; /* Big endian */ - buffer[(*offset)++] = (uint8_t)(len >> 16); - buffer[(*offset)++] = (uint8_t)(len >> 8); + buffer[(*offset)++] = (uint8_t) (len >> 16); + buffer[(*offset)++] = (uint8_t) (len >> 8); buffer[(*offset)++] = (uint8_t) len; } else if (len <= 0xFFFFFFFF) { buffer[(*offset)++] = 0x84; /* Big endian */ - buffer[(*offset)++] = (uint8_t)(len >> 24); - buffer[(*offset)++] = (uint8_t)(len >> 16); - buffer[(*offset)++] = (uint8_t)(len >> 8); + buffer[(*offset)++] = (uint8_t) (len >> 24); + buffer[(*offset)++] = (uint8_t) (len >> 16); + buffer[(*offset)++] = (uint8_t) (len >> 8); buffer[(*offset)++] = (uint8_t) len; } } @@ -551,9 +551,9 @@ sec_hasp_asn1_encode_tag(uint16_t tag, uint8_t *buffer, size_t *offset) { if (tag > 0xFF) { /* Big endian */ - buffer[(*offset)++] = (uint8_t)(tag >> 8); - buffer[(*offset)++] = (uint8_t)(tag); + buffer[(*offset)++] = (uint8_t) (tag >> 8); + buffer[(*offset)++] = (uint8_t) (tag); } else { - buffer[(*offset)++] = (uint8_t)(tag); + buffer[(*offset)++] = (uint8_t) (tag); } } \ No newline at end of file diff --git a/src/main/util/options.c b/src/main/util/options.c index c6ee6c7..8a5932c 100644 --- a/src/main/util/options.c +++ b/src/main/util/options.c @@ -648,7 +648,10 @@ static bool util_options_init_from_file( options->defs->defs[j].param, options->defs->defs[j].name, options->defs->defs[j].type, - val ? (options->defs->defs[j].is_secret_data ? "[REDACTED-SECRET]" : val) : "NULL"); + val ? + (options->defs->defs[j].is_secret_data ? "[REDACTED-SECRET]" : + val) : + "NULL"); options->values[j].avail = true; break; diff --git a/src/main/util/patch.c b/src/main/util/patch.c index 91d484b..7b1c950 100644 --- a/src/main/util/patch.c +++ b/src/main/util/patch.c @@ -36,7 +36,7 @@ void util_patch_function(uintptr_t func_addr, void *detour_func) offset += 4; } - uintptr_t call = (uintptr_t)(((uintptr_t) detour_func) - func_addr - offset); + uintptr_t call = (uintptr_t) (((uintptr_t) detour_func) - func_addr - offset); if (UNPROTECT(func_addr, 4096) != 0) { log_die("Unprotecting memory %p, len %d failed", func_addr); diff --git a/src/main/util/sock-tcp.c b/src/main/util/sock-tcp.c index 2a0369e..7272663 100644 --- a/src/main/util/sock-tcp.c +++ b/src/main/util/sock-tcp.c @@ -63,8 +63,8 @@ bool util_sock_tcp_is_connectable3( FD_ZERO(&fdset); FD_SET(handle, &fdset); - tv.tv_sec = (__time_t)(timeout_ms / 1000); - tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000); + tv.tv_sec = (__time_t) (timeout_ms / 1000); + tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000); if (select(handle + 1, NULL, &fdset, NULL, &tv) == 1) { int so_error; @@ -142,8 +142,8 @@ ssize_t util_sock_tcp_send(int handle, void *buffer, size_t size, uint32_t timeout_ms) { struct timeval tv; - tv.tv_sec = (__time_t)(timeout_ms / 1000); - tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000); + tv.tv_sec = (__time_t) (timeout_ms / 1000); + tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000); setsockopt(handle, SOL_SOCKET, SO_SNDTIMEO, (const char *) &tv, sizeof(tv)); @@ -166,8 +166,8 @@ ssize_t util_sock_tcp_recv(int handle, void *buffer, size_t size, uint32_t timeout_ms) { struct timeval tv; - tv.tv_sec = (__time_t)(timeout_ms / 1000); - tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000); + tv.tv_sec = (__time_t) (timeout_ms / 1000); + tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000); setsockopt(handle, SOL_SOCKET, SO_RCVTIMEO, (const char *) &tv, sizeof(tv)); diff --git a/src/main/util/time.c b/src/main/util/time.c index f890355..d6c604e 100644 --- a/src/main/util/time.c +++ b/src/main/util/time.c @@ -12,7 +12,7 @@ void util_time_sleep_ns(uint64_t time_ns) { struct timespec t; - t.tv_sec = (__time_t)(time_ns / (1000 * 1000 * 1000)); + t.tv_sec = (__time_t) (time_ns / (1000 * 1000 * 1000)); t.tv_nsec = (__syscall_slong_t) time_ns % (1000 * 1000 * 1000); nanosleep(&t, NULL); @@ -21,8 +21,8 @@ void util_time_sleep_ns(uint64_t time_ns) void util_time_sleep_us(uint64_t time_us) { struct timespec t; - t.tv_sec = (__time_t)(time_us / (1000 * 1000)); - t.tv_nsec = (__syscall_slong_t)(time_us % (1000 * 1000)) * 1000; + t.tv_sec = (__time_t) (time_us / (1000 * 1000)); + t.tv_nsec = (__syscall_slong_t) (time_us % (1000 * 1000)) * 1000; nanosleep(&t, NULL); } @@ -30,8 +30,8 @@ void util_time_sleep_us(uint64_t time_us) void util_time_sleep_ms(uint64_t time_ms) { struct timespec t; - t.tv_sec = (__time_t)(time_ms / 1000); - t.tv_nsec = (__syscall_slong_t)(time_ms % 1000) * 1000 * 1000; + t.tv_sec = (__time_t) (time_ms / 1000); + t.tv_nsec = (__syscall_slong_t) (time_ms % 1000) * 1000 * 1000; nanosleep(&t, NULL); }