Appl new code style on whole code base

Use a similar code style to bemanitools though reduce indentation
to 2 spaces. Also some other tweaks to be more similar to google
style.
This commit is contained in:
icex2
2021-03-19 15:52:34 +01:00
parent b493b4983a
commit eafb2909d1
322 changed files with 30291 additions and 25084 deletions
+49 -48
View File
@@ -10,72 +10,73 @@
#include "util/log.h"
#include "util/str.h"
static FILE* _hook_x2_unlock_settings_file = NULL;
static FILE *_hook_x2_unlock_settings_file = NULL;
static enum cnh_result _hook_x2_unlock_filehook(struct cnh_filehook_irp *irp);
void hook_x2_unlock_init(void)
{
cnh_filehook_push_handler(_hook_x2_unlock_filehook);
cnh_filehook_push_handler(_hook_x2_unlock_filehook);
log_info("Initialized");
log_info("Initialized");
}
static enum cnh_result _hook_x2_unlock_filehook(struct cnh_filehook_irp *irp)
{
enum cnh_result result;
enum cnh_result result;
assert(irp);
assert(irp);
if (irp->op != CNH_FILEHOOK_IRP_OP_OPEN && irp->file != _hook_x2_unlock_settings_file) {
return cnh_filehook_invoke_next(irp);
if (irp->op != CNH_FILEHOOK_IRP_OP_OPEN &&
irp->file != _hook_x2_unlock_settings_file) {
return cnh_filehook_invoke_next(irp);
}
switch (irp->op) {
case CNH_FILEHOOK_IRP_OP_OPEN: {
/* Let it open the real file */
result = cnh_filehook_invoke_next(irp);
if (util_str_ends_with(irp->open_filename, ASSET_X2_SETTINGS_FILE_NAME)) {
if (result == CNH_RESULT_SUCCESS) {
log_debug("Intercepting settings file open");
_hook_x2_unlock_settings_file = irp->file;
}
}
break;
}
switch (irp->op) {
case CNH_FILEHOOK_IRP_OP_OPEN:
{
/* Let it open the real file */
result = cnh_filehook_invoke_next(irp);
case CNH_FILEHOOK_IRP_OP_READ: {
/* Let it read the real file */
result = cnh_filehook_invoke_next(irp);
if (util_str_ends_with(irp->open_filename, ASSET_X2_SETTINGS_FILE_NAME)) {
if (result == CNH_RESULT_SUCCESS) {
log_debug("Intercepting settings file open");
_hook_x2_unlock_settings_file = irp->file;
}
}
if (result == CNH_RESULT_SUCCESS) {
struct asset_x2_settings *settings =
(struct asset_x2_settings *) irp->read.bytes;
break;
}
asset_x2_settings_unlock_all(settings);
case CNH_FILEHOOK_IRP_OP_READ:
{
/* Let it read the real file */
result = cnh_filehook_invoke_next(irp);
log_debug(
"Applied unlock patch to loaded settings (buffer size %d)",
irp->read.pos);
}
if (result == CNH_RESULT_SUCCESS) {
struct asset_x2_settings* settings = (struct asset_x2_settings*) irp->read.bytes;
asset_x2_settings_unlock_all(settings);
log_debug("Applied unlock patch to loaded settings (buffer size %d)", irp->read.pos);
}
break;
}
case CNH_FILEHOOK_IRP_OP_CLOSE:
{
_hook_x2_unlock_settings_file = NULL;
result = cnh_filehook_invoke_next(irp);
break;
}
default:
result = cnh_filehook_invoke_next(irp);
break;
break;
}
return result;
case CNH_FILEHOOK_IRP_OP_CLOSE: {
_hook_x2_unlock_settings_file = NULL;
result = cnh_filehook_invoke_next(irp);
break;
}
default:
result = cnh_filehook_invoke_next(irp);
break;
}
return result;
}