(patch) Turn functions static

This commit is contained in:
twinaphex 2016-02-07 01:44:54 +01:00
parent c4c4ee4eee
commit d9b3412922
3 changed files with 42 additions and 50 deletions

26
patch.c
View File

@ -96,7 +96,7 @@ static void bps_write(struct bps_data *bps, uint8_t data)
#endif #endif
} }
patch_error_t bps_apply_patch( static patch_error_t bps_apply_patch(
const uint8_t *modify_data, size_t modify_length, const uint8_t *modify_data, size_t modify_length,
const uint8_t *source_data, size_t source_length, const uint8_t *source_data, size_t source_length,
uint8_t *target_data, size_t *target_length) uint8_t *target_data, size_t *target_length)
@ -198,7 +198,8 @@ patch_error_t bps_apply_patch(
modify_modify_checksum |= bps_read(&bps) << i; modify_modify_checksum |= bps_read(&bps) << i;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
bps.source_checksum = stream_backend->stream_crc_calculate(0, bps.source_data, bps.source_length); bps.source_checksum = stream_backend->stream_crc_calculate(0,
bps.source_data, bps.source_length);
#else #else
return PATCH_PATCH_CHECKSUM_INVALID; return PATCH_PATCH_CHECKSUM_INVALID;
#endif #endif
@ -237,7 +238,8 @@ static uint8_t ups_patch_read(struct ups_data *data)
{ {
uint8_t n = data->patch_data[data->patch_offset++]; uint8_t n = data->patch_data[data->patch_offset++];
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
data->patch_checksum = ~stream_backend->stream_crc_calculate(~data->patch_checksum, &n, 1); data->patch_checksum =
~stream_backend->stream_crc_calculate(~data->patch_checksum, &n, 1);
#endif #endif
return n; return n;
} }
@ -255,7 +257,8 @@ static uint8_t ups_source_read(struct ups_data *data)
{ {
uint8_t n = data->source_data[data->source_offset++]; uint8_t n = data->source_data[data->source_offset++];
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
data->source_checksum = ~stream_backend->stream_crc_calculate(~data->source_checksum, &n, 1); data->source_checksum =
~stream_backend->stream_crc_calculate(~data->source_checksum, &n, 1);
#endif #endif
return n; return n;
} }
@ -273,7 +276,8 @@ static void ups_target_write(struct ups_data *data, uint8_t n)
{ {
data->target_data[data->target_offset] = n; data->target_data[data->target_offset] = n;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
data->target_checksum = ~stream_backend->stream_crc_calculate(~data->target_checksum, &n, 1); data->target_checksum =
~stream_backend->stream_crc_calculate(~data->target_checksum, &n, 1);
#endif #endif
} }
@ -297,7 +301,7 @@ static uint64_t ups_decode(struct ups_data *data)
return offset; return offset;
} }
patch_error_t ups_apply_patch( static patch_error_t ups_apply_patch(
const uint8_t *patchdata, size_t patchlength, const uint8_t *patchdata, size_t patchlength,
const uint8_t *sourcedata, size_t sourcelength, const uint8_t *sourcedata, size_t sourcelength,
uint8_t *targetdata, size_t *targetlength) uint8_t *targetdata, size_t *targetlength)
@ -396,7 +400,7 @@ patch_error_t ups_apply_patch(
return PATCH_SOURCE_INVALID; return PATCH_SOURCE_INVALID;
} }
patch_error_t ips_apply_patch( static patch_error_t ips_apply_patch(
const uint8_t *patchdata, size_t patchlen, const uint8_t *patchdata, size_t patchlen,
const uint8_t *sourcedata, size_t sourcelength, const uint8_t *sourcedata, size_t sourcelength,
uint8_t *targetdata, size_t *targetlength) uint8_t *targetdata, size_t *targetlength)
@ -591,13 +595,17 @@ void patch_content(uint8_t **buf, ssize_t *size)
{ {
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
if (global->patch.ips_pref + global->patch.bps_pref + global->patch.ups_pref > 1) if ( global->patch.ips_pref
+ global->patch.bps_pref
+ global->patch.ups_pref > 1)
{ {
RARCH_WARN("Several patches are explicitly defined, ignoring all ...\n"); RARCH_WARN("Several patches are explicitly defined, ignoring all ...\n");
return; return;
} }
if (!try_ips_patch(buf, size) && !try_bps_patch(buf, size) && !try_ups_patch(buf, size)) if ( !try_ips_patch(buf, size)
&& !try_bps_patch(buf, size)
&& !try_ups_patch(buf, size))
{ {
RARCH_LOG("Did not find a valid content patch.\n"); RARCH_LOG("Did not find a valid content patch.\n");
} }

18
patch.h
View File

@ -25,7 +25,7 @@
typedef enum typedef enum
{ {
PATCH_UNKNOWN, PATCH_UNKNOWN = 0,
PATCH_SUCCESS, PATCH_SUCCESS,
PATCH_PATCH_TOO_SMALL, PATCH_PATCH_TOO_SMALL,
PATCH_PATCH_INVALID_HEADER, PATCH_PATCH_INVALID_HEADER,
@ -42,22 +42,6 @@ typedef enum
typedef patch_error_t (*patch_func_t)(const uint8_t*, size_t, typedef patch_error_t (*patch_func_t)(const uint8_t*, size_t,
const uint8_t*, size_t, uint8_t*, size_t*); const uint8_t*, size_t, uint8_t*, size_t*);
patch_error_t bps_apply_patch(
const uint8_t *patch_data, size_t patch_length,
const uint8_t *source_data, size_t source_length,
uint8_t *target_data, size_t *target_length);
patch_error_t ups_apply_patch(
const uint8_t *patch_data, size_t patch_length,
const uint8_t *source_data, size_t source_length,
uint8_t *target_data, size_t *target_length);
patch_error_t ips_apply_patch(
const uint8_t *patch_data, size_t patch_length,
const uint8_t *source_data, size_t source_length,
uint8_t *target_data, size_t *target_length);
/** /**
* patch_content: * patch_content:
* @buf : buffer of the content file. * @buf : buffer of the content file.

View File

@ -24,31 +24,31 @@
extern "C" { extern "C" {
#endif #endif
#define MENU_VALUE_FILE_WEBM 0x7ca00b50U #define MENU_VALUE_FILE_WEBM 0x7ca00b50U
#define MENU_VALUE_FILE_F4F 0x0b886be5U #define MENU_VALUE_FILE_F4F 0x0b886be5U
#define MENU_VALUE_FILE_F4V 0x0b886bf5U #define MENU_VALUE_FILE_F4V 0x0b886bf5U
#define MENU_VALUE_FILE_OGM 0x0b8898c8U #define MENU_VALUE_FILE_OGM 0x0b8898c8U
#define MENU_VALUE_FILE_MKV 0x0b8890d3U #define MENU_VALUE_FILE_MKV 0x0b8890d3U
#define MENU_VALUE_FILE_AVI 0x0b885f25U #define MENU_VALUE_FILE_AVI 0x0b885f25U
#define MENU_VALUE_FILE_M4A 0x0b8889a7U #define MENU_VALUE_FILE_M4A 0x0b8889a7U
#define MENU_VALUE_FILE_3GP 0x0b87998fU #define MENU_VALUE_FILE_3GP 0x0b87998fU
#define MENU_VALUE_FILE_MP4 0x0b889136U #define MENU_VALUE_FILE_MP4 0x0b889136U
#define MENU_VALUE_FILE_MP3 0x0b889135U #define MENU_VALUE_FILE_MP3 0x0b889135U
#define MENU_VALUE_FILE_FLAC 0x7c96d67bU #define MENU_VALUE_FILE_FLAC 0x7c96d67bU
#define MENU_VALUE_FILE_OGG 0x0b8898c2U #define MENU_VALUE_FILE_OGG 0x0b8898c2U
#define MENU_VALUE_FILE_FLV 0x0b88732dU #define MENU_VALUE_FILE_FLV 0x0b88732dU
#define MENU_VALUE_FILE_WAV 0x0b88ba13U #define MENU_VALUE_FILE_WAV 0x0b88ba13U
#define MENU_VALUE_FILE_MOV 0x0b889157U #define MENU_VALUE_FILE_MOV 0x0b889157U
#define MENU_VALUE_FILE_WMV 0x0b88bb9fU #define MENU_VALUE_FILE_WMV 0x0b88bb9fU
#define MENU_VALUE_FILE_JPG 0x0b8884a6U #define MENU_VALUE_FILE_JPG 0x0b8884a6U
#define MENU_VALUE_FILE_JPEG 0x7c99198bU #define MENU_VALUE_FILE_JPEG 0x7c99198bU
#define MENU_VALUE_FILE_JPG_CAPS 0x0b87f846U #define MENU_VALUE_FILE_JPG_CAPS 0x0b87f846U
#define MENU_VALUE_FILE_JPEG_CAPS 0x7c87010bU #define MENU_VALUE_FILE_JPEG_CAPS 0x7c87010bU
#define MENU_VALUE_FILE_PNG 0x0b889deaU #define MENU_VALUE_FILE_PNG 0x0b889deaU
#define MENU_VALUE_FILE_PNG_CAPS 0x0b88118aU #define MENU_VALUE_FILE_PNG_CAPS 0x0b88118aU
#define MENU_VALUE_FILE_TGA 0x0b88ae01U #define MENU_VALUE_FILE_TGA 0x0b88ae01U
#define MENU_VALUE_FILE_BMP 0x0b886244U #define MENU_VALUE_FILE_BMP 0x0b886244U
enum rarch_ctl_state enum rarch_ctl_state
{ {