Cut down on gotos
This commit is contained in:
parent
341f6d3df4
commit
327621938b
|
@ -2237,8 +2237,7 @@ bool video_shader_load_preset_into_shader(const char *path,
|
||||||
if (!root_conf)
|
if (!root_conf)
|
||||||
{
|
{
|
||||||
RARCH_WARN("[Shaders] Could not read root preset: \"%s\".\n", path);
|
RARCH_WARN("[Shaders] Could not read root preset: \"%s\".\n", path);
|
||||||
ret = false;
|
return false;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the root preset is a valid shader chain
|
/* Check if the root preset is a valid shader chain
|
||||||
|
@ -2345,7 +2344,6 @@ bool video_shader_load_preset_into_shader(const char *path,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
path_linked_list_free(override_paths_list);
|
path_linked_list_free(override_paths_list);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
config_file_free(root_conf);
|
config_file_free(root_conf);
|
||||||
|
@ -2842,7 +2840,7 @@ static bool video_shader_load_shader_preset_internal(
|
||||||
*
|
*
|
||||||
* Returns: false if there was an error or no action was performed.
|
* Returns: false if there was an error or no action was performed.
|
||||||
*/
|
*/
|
||||||
static bool video_shader_load_auto_shader_preset(
|
static size_t video_shader_load_auto_shader_preset(
|
||||||
const char *video_shader_directory,
|
const char *video_shader_directory,
|
||||||
const char *menu_config_directory,
|
const char *menu_config_directory,
|
||||||
const char *core_name,
|
const char *core_name,
|
||||||
|
@ -2897,7 +2895,7 @@ static bool video_shader_load_auto_shader_preset(
|
||||||
sizeof(shader_path),
|
sizeof(shader_path),
|
||||||
dirs[i], core_name,
|
dirs[i], core_name,
|
||||||
game_name))
|
game_name))
|
||||||
goto success;
|
return strlcpy(s, shader_path, len);
|
||||||
|
|
||||||
/* Folder-specific shader preset found? */
|
/* Folder-specific shader preset found? */
|
||||||
if (video_shader_load_shader_preset_internal(
|
if (video_shader_load_shader_preset_internal(
|
||||||
|
@ -2905,7 +2903,7 @@ static bool video_shader_load_auto_shader_preset(
|
||||||
sizeof(shader_path),
|
sizeof(shader_path),
|
||||||
dirs[i], core_name,
|
dirs[i], core_name,
|
||||||
content_dir_name))
|
content_dir_name))
|
||||||
goto success;
|
return strlcpy(s, shader_path, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Core-specific shader preset found? */
|
/* Core-specific shader preset found? */
|
||||||
|
@ -2914,7 +2912,7 @@ static bool video_shader_load_auto_shader_preset(
|
||||||
sizeof(shader_path),
|
sizeof(shader_path),
|
||||||
dirs[i], core_name,
|
dirs[i], core_name,
|
||||||
core_name))
|
core_name))
|
||||||
goto success;
|
return strlcpy(s, shader_path, len);
|
||||||
|
|
||||||
/* Global shader preset found? */
|
/* Global shader preset found? */
|
||||||
if (video_shader_load_shader_preset_internal(
|
if (video_shader_load_shader_preset_internal(
|
||||||
|
@ -2922,14 +2920,10 @@ static bool video_shader_load_auto_shader_preset(
|
||||||
sizeof(shader_path),
|
sizeof(shader_path),
|
||||||
dirs[i], NULL,
|
dirs[i], NULL,
|
||||||
"global"))
|
"global"))
|
||||||
goto success;
|
return strlcpy(s, shader_path, len);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
success:
|
return 0;
|
||||||
/* Shader preset exists, load it. */
|
|
||||||
strlcpy(s, shader_path, len);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool video_shader_combine_preset_and_apply(
|
bool video_shader_combine_preset_and_apply(
|
||||||
|
|
|
@ -1139,7 +1139,10 @@ static void thread_set_texture_frame(void *data, const void *frame,
|
||||||
void *tmp_frame = realloc(thr->texture.frame, required);
|
void *tmp_frame = realloc(thr->texture.frame, required);
|
||||||
|
|
||||||
if (!tmp_frame)
|
if (!tmp_frame)
|
||||||
goto end;
|
{
|
||||||
|
slock_unlock(thr->frame.lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
thr->texture.frame = tmp_frame;
|
thr->texture.frame = tmp_frame;
|
||||||
thr->texture.frame_cap = required;
|
thr->texture.frame_cap = required;
|
||||||
|
@ -1153,7 +1156,6 @@ static void thread_set_texture_frame(void *data, const void *frame,
|
||||||
thr->texture.alpha = alpha;
|
thr->texture.alpha = alpha;
|
||||||
thr->texture.frame_updated = true;
|
thr->texture.frame_updated = true;
|
||||||
|
|
||||||
end:
|
|
||||||
slock_unlock(thr->frame.lock);
|
slock_unlock(thr->frame.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1347,24 +1347,21 @@ static bool input_remote_init_network(input_remote_t *handle,
|
||||||
RARCH_LOG("[Network] Bringing up remote interface on port %hu.\n",
|
RARCH_LOG("[Network] Bringing up remote interface on port %hu.\n",
|
||||||
(unsigned short)port);
|
(unsigned short)port);
|
||||||
|
|
||||||
if ((fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM, AF_INET)) < 0)
|
if ((fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM, AF_INET)) >= 0)
|
||||||
goto error;
|
|
||||||
|
|
||||||
handle->net_fd[user] = fd;
|
|
||||||
|
|
||||||
if (!socket_nonblock(handle->net_fd[user]))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!socket_bind(handle->net_fd[user], res))
|
|
||||||
{
|
{
|
||||||
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_BIND_SOCKET));
|
handle->net_fd[user] = fd;
|
||||||
goto error;
|
|
||||||
|
if (socket_nonblock(handle->net_fd[user]))
|
||||||
|
{
|
||||||
|
if (socket_bind(handle->net_fd[user], res))
|
||||||
|
{
|
||||||
|
freeaddrinfo_retro(res);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_BIND_SOCKET));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
freeaddrinfo_retro(res);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
error:
|
|
||||||
if (res)
|
if (res)
|
||||||
freeaddrinfo_retro(res);
|
freeaddrinfo_retro(res);
|
||||||
return false;
|
return false;
|
||||||
|
@ -3442,11 +3439,14 @@ static void input_overlay_update_pointer_coords(
|
||||||
/* Need multi-touch coordinates for pointer only */
|
/* Need multi-touch coordinates for pointer only */
|
||||||
if ( ptr_st->count
|
if ( ptr_st->count
|
||||||
&& !(ptr_st->device_mask & (1 << RETRO_DEVICE_POINTER)))
|
&& !(ptr_st->device_mask & (1 << RETRO_DEVICE_POINTER)))
|
||||||
goto finish;
|
{
|
||||||
|
ptr_st->count++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Need viewport pointers for pointer and lightgun */
|
/* Need viewport pointers for pointer and lightgun */
|
||||||
if (ptr_st->device_mask &
|
if ( ptr_st->device_mask
|
||||||
((1 << RETRO_DEVICE_LIGHTGUN) | (1 << RETRO_DEVICE_POINTER)))
|
& ((1 << RETRO_DEVICE_LIGHTGUN) | (1 << RETRO_DEVICE_POINTER)))
|
||||||
{
|
{
|
||||||
ptr_st->ptr[ptr_st->count].x = current_input->input_state(
|
ptr_st->ptr[ptr_st->count].x = current_input->input_state(
|
||||||
input_data, NULL, NULL, NULL, NULL, true, 0,
|
input_data, NULL, NULL, NULL, NULL, true, 0,
|
||||||
|
@ -3478,7 +3478,6 @@ static void input_overlay_update_pointer_coords(
|
||||||
RETRO_DEVICE_ID_POINTER_Y);
|
RETRO_DEVICE_ID_POINTER_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
finish:
|
|
||||||
ptr_st->count++;
|
ptr_st->count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6375,8 +6374,8 @@ void bsv_movie_read_next_events(bsv_movie_t *handle)
|
||||||
else if (next_frame_type == REPLAY_TOKEN_CHECKPOINT2_FRAME)
|
else if (next_frame_type == REPLAY_TOKEN_CHECKPOINT2_FRAME)
|
||||||
{
|
{
|
||||||
uint8_t compression, encoding;
|
uint8_t compression, encoding;
|
||||||
if (intfstream_read(handle->file, &(compression), sizeof(uint8_t)) != sizeof(uint8_t) ||
|
if ( intfstream_read(handle->file, &(compression), sizeof(uint8_t)) != sizeof(uint8_t)
|
||||||
intfstream_read(handle->file, &(encoding), sizeof(uint8_t)) != sizeof(uint8_t))
|
|| intfstream_read(handle->file, &(encoding), sizeof(uint8_t)) != sizeof(uint8_t))
|
||||||
{
|
{
|
||||||
/* Unexpected EOF */
|
/* Unexpected EOF */
|
||||||
RARCH_ERR("[Replay] Replay checkpoint truncated.\n");
|
RARCH_ERR("[Replay] Replay checkpoint truncated.\n");
|
||||||
|
@ -6533,7 +6532,7 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_
|
||||||
{
|
{
|
||||||
int64_t i;
|
int64_t i;
|
||||||
/* no choice but to memcmp the whole stream against the other */
|
/* no choice but to memcmp the whole stream against the other */
|
||||||
for (i = 0; ret && i < check_limit; i+=check_cap)
|
for (i = 0; ret && i < check_limit; i += check_cap)
|
||||||
{
|
{
|
||||||
int64_t read_end = MIN(check_limit - i, check_cap);
|
int64_t read_end = MIN(check_limit - i, check_cap);
|
||||||
int64_t read1 = intfstream_read(movie->file, buf1, read_end);
|
int64_t read1 = intfstream_read(movie->file, buf1, read_end);
|
||||||
|
@ -6547,7 +6546,7 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_
|
||||||
}
|
}
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
while(intfstream_tell(movie->file) < check_limit && intfstream_tell(check_stream) < check_limit)
|
while (intfstream_tell(movie->file) < check_limit && intfstream_tell(check_stream) < check_limit)
|
||||||
{
|
{
|
||||||
if (intfstream_tell(movie->file) < 0 || intfstream_tell(check_stream) < 0)
|
if (intfstream_tell(movie->file) < 0 || intfstream_tell(check_stream) < 0)
|
||||||
{
|
{
|
||||||
|
@ -6555,25 +6554,28 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_
|
||||||
ret = false;
|
ret = false;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (intfstream_read(movie->file, &keycount1, 1) < 1 ||
|
if ( intfstream_read(movie->file, &keycount1, 1) < 1
|
||||||
intfstream_read(check_stream, &keycount2, 1) < 1 ||
|
|| intfstream_read(check_stream, &keycount2, 1) < 1
|
||||||
keycount1 != keycount2)
|
|| keycount1 != keycount2)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[Replay] Replay checkpoints disagree on key count, %d vs %d\n", keycount1, keycount2);
|
RARCH_ERR("[Replay] Replay checkpoints disagree on key count, %d vs %d\n", keycount1, keycount2);
|
||||||
ret = false;
|
ret = false;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if ((uint64_t)intfstream_read(movie->file, buf1, keycount1*sizeof(bsv_key_data_t)) < keycount1*sizeof(bsv_key_data_t) ||
|
if (
|
||||||
(uint64_t)intfstream_read(check_stream, buf2, keycount2*sizeof(bsv_key_data_t)) < keycount2*sizeof(bsv_key_data_t) ||
|
(uint64_t)intfstream_read(movie->file, buf1, keycount1*sizeof(bsv_key_data_t))
|
||||||
memcmp(buf1, buf2, keycount1*sizeof(bsv_key_data_t)) != 0)
|
< keycount1*sizeof(bsv_key_data_t)
|
||||||
|
|| (uint64_t)intfstream_read(check_stream, buf2, keycount2*sizeof(bsv_key_data_t))
|
||||||
|
< keycount2*sizeof(bsv_key_data_t)
|
||||||
|
|| memcmp(buf1, buf2, keycount1*sizeof(bsv_key_data_t)) != 0)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[Replay] Replay checkpoints disagree on key data\n");
|
RARCH_ERR("[Replay] Replay checkpoints disagree on key data\n");
|
||||||
ret = false;
|
ret = false;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (intfstream_read(movie->file, &btncount1, 2) < 2 ||
|
if ( intfstream_read(movie->file, &btncount1, 2) < 2
|
||||||
intfstream_read(check_stream, &btncount2, 2) < 2 ||
|
|| intfstream_read(check_stream, &btncount2, 2) < 2
|
||||||
btncount1 != btncount2)
|
|| btncount1 != btncount2)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[Replay] Replay checkpoints disagree on input count\n");
|
RARCH_ERR("[Replay] Replay checkpoints disagree on input count\n");
|
||||||
ret = false;
|
ret = false;
|
||||||
|
@ -6581,17 +6583,19 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_
|
||||||
}
|
}
|
||||||
btncount1 = swap_if_big16(btncount1);
|
btncount1 = swap_if_big16(btncount1);
|
||||||
btncount2 = swap_if_big16(btncount2);
|
btncount2 = swap_if_big16(btncount2);
|
||||||
if ((uint64_t)intfstream_read(movie->file, buf1, btncount1*sizeof(bsv_input_data_t)) < btncount1*sizeof(bsv_input_data_t) ||
|
if ( (uint64_t)intfstream_read(movie->file, buf1, btncount1*sizeof(bsv_input_data_t))
|
||||||
(uint64_t)intfstream_read(check_stream, buf2, btncount2*sizeof(bsv_input_data_t)) < btncount2*sizeof(bsv_input_data_t) ||
|
< btncount1*sizeof(bsv_input_data_t)
|
||||||
memcmp(buf1, buf2, btncount1*sizeof(bsv_input_data_t)) != 0)
|
|| (uint64_t)intfstream_read(check_stream, buf2, btncount2*sizeof(bsv_input_data_t))
|
||||||
|
< btncount2*sizeof(bsv_input_data_t)
|
||||||
|
|| memcmp(buf1, buf2, btncount1*sizeof(bsv_input_data_t)) != 0)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[Replay] Replay checkpoints disagree on input data\n");
|
RARCH_ERR("[Replay] Replay checkpoints disagree on input data\n");
|
||||||
ret = false;
|
ret = false;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (intfstream_read(movie->file, &frametok1, 1) < 1 ||
|
if ( intfstream_read(movie->file, &frametok1, 1) < 1
|
||||||
intfstream_read(check_stream, &frametok2, 1) < 1 ||
|
|| intfstream_read(check_stream, &frametok2, 1) < 1
|
||||||
frametok1 != frametok2)
|
|| frametok1 != frametok2)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[Replay] Replay checkpoints disagree on frame token\n");
|
RARCH_ERR("[Replay] Replay checkpoints disagree on frame token\n");
|
||||||
ret = false;
|
ret = false;
|
||||||
|
@ -6606,9 +6610,9 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_
|
||||||
case REPLAY_TOKEN_REGULAR_FRAME:
|
case REPLAY_TOKEN_REGULAR_FRAME:
|
||||||
break;
|
break;
|
||||||
case REPLAY_TOKEN_CHECKPOINT_FRAME:
|
case REPLAY_TOKEN_CHECKPOINT_FRAME:
|
||||||
if ((uint64_t)intfstream_read(movie->file, &size1, sizeof(uint64_t)) < sizeof(uint64_t) ||
|
if ( (uint64_t)intfstream_read(movie->file, &size1, sizeof(uint64_t)) < sizeof(uint64_t)
|
||||||
(uint64_t)intfstream_read(check_stream, &size2, sizeof(uint64_t)) < sizeof(uint64_t) ||
|
|| (uint64_t)intfstream_read(check_stream, &size2, sizeof(uint64_t)) < sizeof(uint64_t)
|
||||||
size1 != size2)
|
|| size1 != size2)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[Replay] Replay checkpoints disagree on size or scheme\n");
|
RARCH_ERR("[Replay] Replay checkpoints disagree on size or scheme\n");
|
||||||
ret = false;
|
ret = false;
|
||||||
|
|
|
@ -338,7 +338,6 @@ bool file_archive_extract_file(
|
||||||
char *s, size_t len)
|
char *s, size_t len)
|
||||||
{
|
{
|
||||||
struct archive_extract_userdata userdata;
|
struct archive_extract_userdata userdata;
|
||||||
bool ret = true;
|
|
||||||
struct string_list *list = string_split(valid_exts, "|");
|
struct string_list *list = string_split(valid_exts, "|");
|
||||||
|
|
||||||
userdata.archive_path[0] = '\0';
|
userdata.archive_path[0] = '\0';
|
||||||
|
@ -353,37 +352,22 @@ bool file_archive_extract_file(
|
||||||
userdata.transfer = NULL;
|
userdata.transfer = NULL;
|
||||||
userdata.dec = NULL;
|
userdata.dec = NULL;
|
||||||
|
|
||||||
if (!list)
|
if ( list
|
||||||
|
&& file_archive_walk(archive_path, valid_exts,
|
||||||
|
file_archive_extract_cb, &userdata)
|
||||||
|
&& userdata.found_file
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ret = false;
|
if (!string_is_empty(userdata.first_extracted_file_path))
|
||||||
goto end;
|
strlcpy(s, userdata.first_extracted_file_path, len);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_archive_walk(archive_path, valid_exts,
|
|
||||||
file_archive_extract_cb, &userdata))
|
|
||||||
{
|
|
||||||
/* Parsing file archive failed. */
|
|
||||||
ret = false;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!userdata.found_file)
|
|
||||||
{
|
|
||||||
/* Didn't find any file that matched valid extensions
|
|
||||||
* for libretro implementation. */
|
|
||||||
ret = false;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string_is_empty(userdata.first_extracted_file_path))
|
|
||||||
strlcpy(s, userdata.first_extracted_file_path, len);
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (userdata.first_extracted_file_path)
|
if (userdata.first_extracted_file_path)
|
||||||
free(userdata.first_extracted_file_path);
|
free(userdata.first_extracted_file_path);
|
||||||
if (list)
|
if (list)
|
||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
return ret;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Warning: 'list' must zero initialised before
|
/* Warning: 'list' must zero initialised before
|
||||||
|
@ -533,7 +517,10 @@ static struct string_list *file_archive_filename_split(const char *path)
|
||||||
{
|
{
|
||||||
/* add archive path to list first */
|
/* add archive path to list first */
|
||||||
if (!string_list_append_n(list, path, (unsigned)(delim - path), attr))
|
if (!string_list_append_n(list, path, (unsigned)(delim - path), attr))
|
||||||
goto error;
|
{
|
||||||
|
string_list_free(list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* now add the path within the archive */
|
/* now add the path within the archive */
|
||||||
delim++;
|
delim++;
|
||||||
|
@ -541,18 +528,22 @@ static struct string_list *file_archive_filename_split(const char *path)
|
||||||
if (*delim)
|
if (*delim)
|
||||||
{
|
{
|
||||||
if (!string_list_append(list, delim, attr))
|
if (!string_list_append(list, delim, attr))
|
||||||
goto error;
|
{
|
||||||
|
string_list_free(list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
if (!string_list_append(list, path, attr))
|
if (!string_list_append(list, path, attr))
|
||||||
goto error;
|
{
|
||||||
|
string_list_free(list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
error:
|
|
||||||
string_list_free(list);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generic compressed file loader.
|
/* Generic compressed file loader.
|
||||||
|
|
|
@ -99,12 +99,12 @@ static bool zlib_stream_decompress_data_to_file_init(
|
||||||
void *context, file_archive_file_handle_t *handle,
|
void *context, file_archive_file_handle_t *handle,
|
||||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size)
|
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size)
|
||||||
{
|
{
|
||||||
zip_context_t *zip_context = (zip_context_t *)context;
|
int64_t offsetData;
|
||||||
struct file_archive_transfer *state = zip_context->state;
|
|
||||||
uint8_t local_header_buf[4];
|
|
||||||
uint8_t *local_header;
|
uint8_t *local_header;
|
||||||
uint32_t offsetNL, offsetEL;
|
uint32_t offsetNL, offsetEL;
|
||||||
int64_t offsetData;
|
uint8_t local_header_buf[4];
|
||||||
|
zip_context_t *zip_context = (zip_context_t *)context;
|
||||||
|
struct file_archive_transfer *state = zip_context->state;
|
||||||
|
|
||||||
/* free previous data and stream if left unfinished */
|
/* free previous data and stream if left unfinished */
|
||||||
zip_context_free_stream(zip_context, false);
|
zip_context_free_stream(zip_context, false);
|
||||||
|
@ -118,7 +118,10 @@ static bool zlib_stream_decompress_data_to_file_init(
|
||||||
{
|
{
|
||||||
filestream_seek(state->archive_file, (int64_t)(size_t)cdata + 26, RETRO_VFS_SEEK_POSITION_START);
|
filestream_seek(state->archive_file, (int64_t)(size_t)cdata + 26, RETRO_VFS_SEEK_POSITION_START);
|
||||||
if (filestream_read(state->archive_file, local_header_buf, 4) != 4)
|
if (filestream_read(state->archive_file, local_header_buf, 4) != 4)
|
||||||
goto error;
|
{
|
||||||
|
zip_context_free_stream(zip_context, false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
local_header = local_header_buf;
|
local_header = local_header_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,34 +159,31 @@ static bool zlib_stream_decompress_data_to_file_init(
|
||||||
{
|
{
|
||||||
free(zip_context->zstream);
|
free(zip_context->zstream);
|
||||||
zip_context->zstream = NULL;
|
zip_context->zstream = NULL;
|
||||||
goto error;
|
zip_context_free_stream(zip_context, false);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
|
||||||
zip_context_free_stream(zip_context, false);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int zlib_stream_decompress_data_to_file_iterate(
|
static int zlib_stream_decompress_data_to_file_iterate(
|
||||||
void *context, file_archive_file_handle_t *handle)
|
void *context, file_archive_file_handle_t *handle)
|
||||||
{
|
{
|
||||||
|
int64_t rd;
|
||||||
zip_context_t *zip_context = (zip_context_t *)context;
|
zip_context_t *zip_context = (zip_context_t *)context;
|
||||||
struct file_archive_transfer *state = zip_context->state;
|
struct file_archive_transfer *state = zip_context->state;
|
||||||
int64_t rd;
|
|
||||||
|
|
||||||
if (zip_context->cmode == ZIP_MODE_STORED)
|
if (zip_context->cmode == ZIP_MODE_STORED)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
/* Simply copy the data to the output buffer */
|
/* Simply copy the data to the output buffer */
|
||||||
if (zip_context->state->archive_mmap_data)
|
if (zip_context->state->archive_mmap_data)
|
||||||
memcpy(zip_context->decompressed_data,
|
memcpy(zip_context->decompressed_data,
|
||||||
zip_context->state->archive_mmap_data + (size_t)zip_context->fdoffset,
|
zip_context->state->archive_mmap_data + (size_t)zip_context->fdoffset,
|
||||||
zip_context->usize);
|
zip_context->usize);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Read the entire file to memory */
|
/* Read the entire file to memory */
|
||||||
filestream_seek(state->archive_file, zip_context->fdoffset, RETRO_VFS_SEEK_POSITION_START);
|
filestream_seek(state->archive_file, zip_context->fdoffset, RETRO_VFS_SEEK_POSITION_START);
|
||||||
|
@ -204,7 +204,7 @@ static int zlib_stream_decompress_data_to_file_iterate(
|
||||||
if (!zip_context->zstream)
|
if (!zip_context->zstream)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
if (state->archive_mmap_data)
|
if (state->archive_mmap_data)
|
||||||
{
|
{
|
||||||
/* Decompress from the mapped file */
|
/* Decompress from the mapped file */
|
||||||
|
@ -212,7 +212,7 @@ static int zlib_stream_decompress_data_to_file_iterate(
|
||||||
rd = to_read;
|
rd = to_read;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Read some compressed data from file to the temp buffer */
|
/* Read some compressed data from file to the temp buffer */
|
||||||
filestream_seek(state->archive_file,
|
filestream_seek(state->archive_file,
|
||||||
|
|
|
@ -634,20 +634,21 @@ static bool config_file_parse_line(config_file_t *conf,
|
||||||
if (*line != '=')
|
if (*line != '=')
|
||||||
{
|
{
|
||||||
list->value = NULL;
|
list->value = NULL;
|
||||||
goto error;
|
list->key = NULL;
|
||||||
|
free(key);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
if (!(list->value = config_file_extract_value(line)))
|
if (!(list->value = config_file_extract_value(line)))
|
||||||
goto error;
|
{
|
||||||
|
list->key = NULL;
|
||||||
|
free(key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
|
||||||
list->key = NULL;
|
|
||||||
free(key);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_file_from_string_internal(
|
static int config_file_from_string_internal(
|
||||||
|
|
|
@ -805,7 +805,11 @@ char *path_resolve_realpath(char *s, size_t len, bool resolve_symlinks)
|
||||||
tmp[t++] = '/';
|
tmp[t++] = '/';
|
||||||
|
|
||||||
if (string_is_empty(s))
|
if (string_is_empty(s))
|
||||||
goto end;
|
{
|
||||||
|
tmp[t] = '\0';
|
||||||
|
strlcpy(s, tmp, len);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
p = s;
|
p = s;
|
||||||
}
|
}
|
||||||
|
@ -851,10 +855,8 @@ char *path_resolve_realpath(char *s, size_t len, bool resolve_symlinks)
|
||||||
while (p <= next)
|
while (p <= next)
|
||||||
tmp[t++] = *p++;
|
tmp[t++] = *p++;
|
||||||
}
|
}
|
||||||
}while(next < buf_end);
|
} while(next < buf_end);
|
||||||
|
|
||||||
|
|
||||||
end:
|
|
||||||
tmp[t] = '\0';
|
tmp[t] = '\0';
|
||||||
strlcpy(s, tmp, len);
|
strlcpy(s, tmp, len);
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -113,12 +113,15 @@ static void *nbio_stdio_open(const char * filename, unsigned mode)
|
||||||
if (!f)
|
if (!f)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
handle = (struct nbio_stdio_t*)malloc(sizeof(struct nbio_stdio_t));
|
handle = (struct nbio_stdio_t*)malloc(sizeof(struct nbio_stdio_t));
|
||||||
|
|
||||||
if (!handle)
|
if (!handle)
|
||||||
goto error;
|
{
|
||||||
|
fclose(f);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
handle->f = f;
|
handle->f = f;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
|
@ -143,7 +146,11 @@ static void *nbio_stdio_open(const char * filename, unsigned mode)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (len && !buf)
|
if (len && !buf)
|
||||||
goto error;
|
{
|
||||||
|
free(handle);
|
||||||
|
fclose(f);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
handle->data = buf;
|
handle->data = buf;
|
||||||
handle->len = len;
|
handle->len = len;
|
||||||
|
@ -151,12 +158,6 @@ static void *nbio_stdio_open(const char * filename, unsigned mode)
|
||||||
handle->op = -2;
|
handle->op = -2;
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
|
|
||||||
error:
|
|
||||||
if (handle)
|
|
||||||
free(handle);
|
|
||||||
fclose(f);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nbio_stdio_begin_read(void *data)
|
static void nbio_stdio_begin_read(void *data)
|
||||||
|
|
|
@ -199,21 +199,26 @@ static bool image_texture_load_internal(
|
||||||
unsigned g_shift, unsigned b_shift)
|
unsigned g_shift, unsigned b_shift)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
bool success = false;
|
|
||||||
void *img = image_transfer_new(type);
|
void *img = image_transfer_new(type);
|
||||||
|
|
||||||
if (!img)
|
if (!img)
|
||||||
goto end;
|
return false;
|
||||||
|
|
||||||
image_transfer_set_buffer_ptr(img, type, (uint8_t*)ptr, len);
|
image_transfer_set_buffer_ptr(img, type, (uint8_t*)ptr, len);
|
||||||
|
|
||||||
if (!image_transfer_start(img, type))
|
if (!image_transfer_start(img, type))
|
||||||
goto end;
|
{
|
||||||
|
image_transfer_free(img, type);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
while (image_transfer_iterate(img, type));
|
while (image_transfer_iterate(img, type));
|
||||||
|
|
||||||
if (!image_transfer_is_valid(img, type))
|
if (!image_transfer_is_valid(img, type))
|
||||||
goto end;
|
{
|
||||||
|
image_transfer_free(img, type);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -223,7 +228,10 @@ static bool image_texture_load_internal(
|
||||||
} while (ret == IMAGE_PROCESS_NEXT);
|
} while (ret == IMAGE_PROCESS_NEXT);
|
||||||
|
|
||||||
if (ret == IMAGE_PROCESS_ERROR || ret == IMAGE_PROCESS_ERROR_END)
|
if (ret == IMAGE_PROCESS_ERROR || ret == IMAGE_PROCESS_ERROR_END)
|
||||||
goto end;
|
{
|
||||||
|
image_transfer_free(img, type);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
image_texture_color_convert(r_shift, g_shift, b_shift,
|
image_texture_color_convert(r_shift, g_shift, b_shift,
|
||||||
a_shift, out_img);
|
a_shift, out_img);
|
||||||
|
@ -232,17 +240,13 @@ static bool image_texture_load_internal(
|
||||||
if (!image_texture_internal_gx_convert_texture32(out_img))
|
if (!image_texture_internal_gx_convert_texture32(out_img))
|
||||||
{
|
{
|
||||||
image_texture_free(out_img);
|
image_texture_free(out_img);
|
||||||
goto end;
|
image_transfer_free(img, type);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
success = true;
|
image_transfer_free(img, type);
|
||||||
|
return true;
|
||||||
end:
|
|
||||||
if (img)
|
|
||||||
image_transfer_free(img, type);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_texture_free(struct texture_image *img)
|
void image_texture_free(struct texture_image *img)
|
||||||
|
@ -269,9 +273,7 @@ bool image_texture_load_buffer(struct texture_image *out_img,
|
||||||
if (image_texture_load_internal(
|
if (image_texture_load_internal(
|
||||||
type, buffer, buffer_len, out_img,
|
type, buffer, buffer_len, out_img,
|
||||||
a_shift, r_shift, g_shift, b_shift))
|
a_shift, r_shift, g_shift, b_shift))
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out_img->supports_rgba = false;
|
out_img->supports_rgba = false;
|
||||||
|
@ -285,49 +287,44 @@ bool image_texture_load_buffer(struct texture_image *out_img,
|
||||||
bool image_texture_load(struct texture_image *out_img,
|
bool image_texture_load(struct texture_image *out_img,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
unsigned r_shift, g_shift, b_shift, a_shift;
|
|
||||||
size_t file_len = 0;
|
|
||||||
struct nbio_t *handle = NULL;
|
|
||||||
void *ptr = NULL;
|
|
||||||
enum image_type_enum type = image_texture_get_type(path);
|
enum image_type_enum type = image_texture_get_type(path);
|
||||||
|
|
||||||
image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift,
|
|
||||||
&a_shift, out_img);
|
|
||||||
|
|
||||||
if (type != IMAGE_TYPE_NONE)
|
if (type != IMAGE_TYPE_NONE)
|
||||||
{
|
{
|
||||||
handle = (struct nbio_t*)nbio_open(path, NBIO_READ);
|
struct nbio_t *handle = (struct nbio_t*)
|
||||||
if (!handle)
|
nbio_open(path, NBIO_READ);
|
||||||
goto error;
|
if (handle)
|
||||||
nbio_begin_read(handle);
|
{
|
||||||
|
void *ptr = NULL;
|
||||||
|
size_t file_len = 0;
|
||||||
|
|
||||||
while (!nbio_iterate(handle));
|
nbio_begin_read(handle);
|
||||||
|
|
||||||
ptr = nbio_get_ptr(handle, &file_len);
|
while (!nbio_iterate(handle));
|
||||||
|
|
||||||
if (!ptr)
|
if ((ptr = nbio_get_ptr(handle, &file_len)))
|
||||||
goto error;
|
{
|
||||||
|
unsigned r_shift, g_shift, b_shift, a_shift;
|
||||||
|
image_texture_set_color_shifts(&r_shift,
|
||||||
|
&g_shift, &b_shift, &a_shift, out_img);
|
||||||
|
|
||||||
if (image_texture_load_internal(
|
if (image_texture_load_internal(
|
||||||
type,
|
type,
|
||||||
ptr, file_len, out_img,
|
ptr, file_len, out_img,
|
||||||
a_shift, r_shift, g_shift, b_shift))
|
a_shift, r_shift, g_shift, b_shift))
|
||||||
goto success;
|
{
|
||||||
|
nbio_free(handle);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nbio_free(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
|
||||||
out_img->supports_rgba = false;
|
out_img->supports_rgba = false;
|
||||||
out_img->pixels = NULL;
|
out_img->pixels = NULL;
|
||||||
out_img->width = 0;
|
out_img->width = 0;
|
||||||
out_img->height = 0;
|
out_img->height = 0;
|
||||||
if (handle)
|
|
||||||
nbio_free(handle);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
success:
|
|
||||||
if (handle)
|
|
||||||
nbio_free(handle);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,13 @@ static int dir_list_read(const char *dir,
|
||||||
{
|
{
|
||||||
struct RDIR *entry = retro_opendir_include_hidden(dir, include_hidden);
|
struct RDIR *entry = retro_opendir_include_hidden(dir, include_hidden);
|
||||||
|
|
||||||
if (!entry || retro_dirent_error(entry))
|
if (!entry)
|
||||||
goto error;
|
return -1;
|
||||||
|
if (retro_dirent_error(entry))
|
||||||
|
{
|
||||||
|
retro_closedir(entry);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
while (retro_readdir(entry))
|
while (retro_readdir(entry))
|
||||||
{
|
{
|
||||||
|
@ -193,7 +198,10 @@ static int dir_list_read(const char *dir,
|
||||||
{
|
{
|
||||||
attr.i = RARCH_PLAIN_FILE;
|
attr.i = RARCH_PLAIN_FILE;
|
||||||
if (!string_list_append(list, file_path, attr))
|
if (!string_list_append(list, file_path, attr))
|
||||||
goto error;
|
{
|
||||||
|
retro_closedir(entry);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,17 +242,15 @@ static int dir_list_read(const char *dir,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string_list_append(list, file_path, attr))
|
if (!string_list_append(list, file_path, attr))
|
||||||
goto error;
|
{
|
||||||
|
retro_closedir(entry);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retro_closedir(entry);
|
retro_closedir(entry);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
if (entry)
|
|
||||||
retro_closedir(entry);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -128,28 +128,29 @@ struct hostent *gethostbyname(const char *name)
|
||||||
|
|
||||||
XNetDnsLookup(name, event, &dns);
|
XNetDnsLookup(name, event, &dns);
|
||||||
if (!dns)
|
if (!dns)
|
||||||
goto done;
|
{
|
||||||
|
WSACloseEvent(event);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
WaitForSingleObject((HANDLE)event, INFINITE);
|
WaitForSingleObject((HANDLE)event, INFINITE);
|
||||||
|
|
||||||
if (dns->iStatus)
|
if (!dns->iStatus)
|
||||||
goto done;
|
{
|
||||||
|
memcpy(&addr, dns->aina, sizeof(addr));
|
||||||
|
|
||||||
memcpy(&addr, dns->aina, sizeof(addr));
|
he.h_name = NULL;
|
||||||
|
he.h_aliases = NULL;
|
||||||
|
he.h_addrtype = AF_INET;
|
||||||
|
he.h_length = sizeof(addr);
|
||||||
|
he.h_addr_list = &he.h_addr;
|
||||||
|
he.h_addr = (char*)&addr;
|
||||||
|
|
||||||
he.h_name = NULL;
|
ret = &he;
|
||||||
he.h_aliases = NULL;
|
}
|
||||||
he.h_addrtype = AF_INET;
|
|
||||||
he.h_length = sizeof(addr);
|
|
||||||
he.h_addr_list = &he.h_addr;
|
|
||||||
he.h_addr = (char*)&addr;
|
|
||||||
|
|
||||||
ret = &he;
|
|
||||||
|
|
||||||
done:
|
|
||||||
WSACloseEvent(event);
|
WSACloseEvent(event);
|
||||||
if (dns)
|
XNetDnsRelease(dns);
|
||||||
XNetDnsRelease(dns);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,27 +373,31 @@ struct http_connection_t *net_http_connection_new(const char *url,
|
||||||
conn->contentlength = strlen(data);
|
conn->contentlength = strlen(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(conn->url = strdup(url)))
|
if ((conn->url = strdup(url)))
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!strncmp(url, "http://", STRLEN_CONST("http://")))
|
|
||||||
conn->scan = conn->url + STRLEN_CONST("http://");
|
|
||||||
else if (!strncmp(url, "https://", STRLEN_CONST("https://")))
|
|
||||||
{
|
{
|
||||||
conn->scan = conn->url + STRLEN_CONST("https://");
|
if (!strncmp(url, "http://", STRLEN_CONST("http://")))
|
||||||
conn->ssl = true;
|
{
|
||||||
|
conn->scan = conn->url + STRLEN_CONST("http://");
|
||||||
|
|
||||||
|
if (!string_is_empty(conn->scan))
|
||||||
|
{
|
||||||
|
conn->domain = conn->scan;
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!strncmp(url, "https://", STRLEN_CONST("https://")))
|
||||||
|
{
|
||||||
|
conn->scan = conn->url + STRLEN_CONST("https://");
|
||||||
|
conn->ssl = true;
|
||||||
|
|
||||||
|
if (!string_is_empty(conn->scan))
|
||||||
|
{
|
||||||
|
conn->domain = conn->scan;
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (string_is_empty(conn->scan))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
conn->domain = conn->scan;
|
|
||||||
|
|
||||||
return conn;
|
|
||||||
|
|
||||||
error:
|
|
||||||
if (conn->url)
|
if (conn->url)
|
||||||
free(conn->url);
|
free(conn->url);
|
||||||
if (conn->method)
|
if (conn->method)
|
||||||
|
|
|
@ -364,25 +364,28 @@ scond_t *scond_new(void)
|
||||||
*
|
*
|
||||||
* Note: We might could simplify this using vista+ condition variables,
|
* Note: We might could simplify this using vista+ condition variables,
|
||||||
* but we wanted an XP compatible solution. */
|
* but we wanted an XP compatible solution. */
|
||||||
if (!(cond->event = CreateEvent(NULL, FALSE, FALSE, NULL)))
|
if (!(cond->event = CreateEvent(NULL, FALSE, FALSE, NULL)))
|
||||||
goto error;
|
{
|
||||||
|
free(cond);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (!(cond->hot_potato = CreateEvent(NULL, FALSE, FALSE, NULL)))
|
if (!(cond->hot_potato = CreateEvent(NULL, FALSE, FALSE, NULL)))
|
||||||
{
|
{
|
||||||
CloseHandle(cond->event);
|
CloseHandle(cond->event);
|
||||||
goto error;
|
free(cond);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeCriticalSection(&cond->cs);
|
InitializeCriticalSection(&cond->cs);
|
||||||
#else
|
#else
|
||||||
if (pthread_cond_init(&cond->cond, NULL) != 0)
|
if (pthread_cond_init(&cond->cond, NULL) != 0)
|
||||||
goto error;
|
{
|
||||||
|
free(cond);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return cond;
|
return cond;
|
||||||
|
|
||||||
error:
|
|
||||||
free(cond);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void scond_free(scond_t *cond)
|
void scond_free(scond_t *cond)
|
||||||
|
|
|
@ -547,15 +547,13 @@ int filestream_putc(RFILE *stream, int c)
|
||||||
int filestream_vprintf(RFILE *stream, const char* format, va_list args)
|
int filestream_vprintf(RFILE *stream, const char* format, va_list args)
|
||||||
{
|
{
|
||||||
static char buffer[8 * 1024];
|
static char buffer[8 * 1024];
|
||||||
int64_t num_chars = vsnprintf(buffer, sizeof(buffer),
|
int _len = vsnprintf(buffer, sizeof(buffer),
|
||||||
format, args);
|
format, args);
|
||||||
|
if (_len < 0)
|
||||||
if (num_chars < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
else if (num_chars == 0)
|
else if (_len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
return (int)filestream_write(stream, buffer, _len);
|
||||||
return (int)filestream_write(stream, buffer, num_chars);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int filestream_printf(RFILE *stream, const char* format, ...)
|
int filestream_printf(RFILE *stream, const char* format, ...)
|
||||||
|
|
|
@ -218,12 +218,10 @@ void *intfstream_init(intfstream_info_t *info)
|
||||||
{
|
{
|
||||||
intfstream_internal_t *intf = NULL;
|
intfstream_internal_t *intf = NULL;
|
||||||
if (!info)
|
if (!info)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
intf = (intfstream_internal_t*)malloc(sizeof(*intf));
|
if (!(intf = (intfstream_internal_t*)malloc(sizeof(*intf))))
|
||||||
|
return NULL;
|
||||||
if (!intf)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
intf->type = info->type;
|
intf->type = info->type;
|
||||||
intf->file.fp = NULL;
|
intf->file.fp = NULL;
|
||||||
|
@ -246,25 +244,24 @@ void *intfstream_init(intfstream_info_t *info)
|
||||||
case INTFSTREAM_MEMORY:
|
case INTFSTREAM_MEMORY:
|
||||||
intf->memory.writable = info->memory.writable;
|
intf->memory.writable = info->memory.writable;
|
||||||
if (!intfstream_resize(intf, info))
|
if (!intfstream_resize(intf, info))
|
||||||
goto error;
|
{
|
||||||
|
free(intf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case INTFSTREAM_CHD:
|
case INTFSTREAM_CHD:
|
||||||
#ifdef HAVE_CHD
|
#ifdef HAVE_CHD
|
||||||
intf->chd.track = info->chd.track;
|
intf->chd.track = info->chd.track;
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
goto error;
|
free(intf);
|
||||||
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
case INTFSTREAM_RZIP:
|
case INTFSTREAM_RZIP:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return intf;
|
return intf;
|
||||||
|
|
||||||
error:
|
|
||||||
if (intf)
|
|
||||||
free(intf);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t intfstream_seek(
|
int64_t intfstream_seek(
|
||||||
|
@ -699,17 +696,11 @@ intfstream_t* intfstream_open_file(const char *path,
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!intfstream_open(fd, path, mode, hints))
|
if (intfstream_open(fd, path, mode, hints))
|
||||||
goto error;
|
return fd;
|
||||||
|
|
||||||
return fd;
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
error:
|
|
||||||
if (fd)
|
|
||||||
{
|
|
||||||
intfstream_close(fd);
|
|
||||||
free(fd);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,21 +715,14 @@ intfstream_t *intfstream_open_memory(void *data,
|
||||||
info.memory.buf.size = size;
|
info.memory.buf.size = size;
|
||||||
info.memory.writable = false;
|
info.memory.writable = false;
|
||||||
|
|
||||||
fd = (intfstream_t*)intfstream_init(&info);
|
if (!(fd = (intfstream_t*)intfstream_init(&info)))
|
||||||
if (!fd)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!intfstream_open(fd, NULL, mode, hints))
|
if (intfstream_open(fd, NULL, mode, hints))
|
||||||
goto error;
|
return fd;
|
||||||
|
|
||||||
return fd;
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
error:
|
|
||||||
if (fd)
|
|
||||||
{
|
|
||||||
intfstream_close(fd);
|
|
||||||
free(fd);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,21 +737,14 @@ intfstream_t *intfstream_open_writable_memory(void *data,
|
||||||
info.memory.buf.size = size;
|
info.memory.buf.size = size;
|
||||||
info.memory.writable = true;
|
info.memory.writable = true;
|
||||||
|
|
||||||
fd = (intfstream_t*)intfstream_init(&info);
|
if (!(fd = (intfstream_t*)intfstream_init(&info)))
|
||||||
if (!fd)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!intfstream_open(fd, NULL, mode, hints))
|
if (intfstream_open(fd, NULL, mode, hints))
|
||||||
goto error;
|
return fd;
|
||||||
|
|
||||||
return fd;
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
error:
|
|
||||||
if (fd)
|
|
||||||
{
|
|
||||||
intfstream_close(fd);
|
|
||||||
free(fd);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,22 +757,14 @@ intfstream_t *intfstream_open_chd_track(const char *path,
|
||||||
info.type = INTFSTREAM_CHD;
|
info.type = INTFSTREAM_CHD;
|
||||||
info.chd.track = track;
|
info.chd.track = track;
|
||||||
|
|
||||||
fd = (intfstream_t*)intfstream_init(&info);
|
if (!(fd = (intfstream_t*)intfstream_init(&info)))
|
||||||
|
|
||||||
if (!fd)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!intfstream_open(fd, path, mode, hints))
|
if (intfstream_open(fd, path, mode, hints))
|
||||||
goto error;
|
return fd;
|
||||||
|
|
||||||
return fd;
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
error:
|
|
||||||
if (fd)
|
|
||||||
{
|
|
||||||
intfstream_close(fd);
|
|
||||||
free(fd);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,16 +780,10 @@ intfstream_t* intfstream_open_rzip_file(const char *path,
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!intfstream_open(fd, path, mode, RETRO_VFS_FILE_ACCESS_HINT_NONE))
|
if (intfstream_open(fd, path, mode, RETRO_VFS_FILE_ACCESS_HINT_NONE))
|
||||||
goto error;
|
return fd;
|
||||||
|
|
||||||
return fd;
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
error:
|
|
||||||
if (fd)
|
|
||||||
{
|
|
||||||
intfstream_close(fd);
|
|
||||||
free(fd);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,8 @@ static bool rzipstream_read_file_header(rzipstream_t *stream)
|
||||||
header_bytes[i] = 0;
|
header_bytes[i] = 0;
|
||||||
|
|
||||||
/* Attempt to read header bytes */
|
/* Attempt to read header bytes */
|
||||||
if ((length = filestream_read(stream->file, header_bytes, sizeof(header_bytes))) <= 0)
|
if ((length = filestream_read(stream->file,
|
||||||
|
header_bytes, sizeof(header_bytes))) <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* If file length is less than header size
|
/* If file length is less than header size
|
||||||
|
@ -116,21 +117,23 @@ static bool rzipstream_read_file_header(rzipstream_t *stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get uncompressed chunk size - next 4 bytes */
|
/* Get uncompressed chunk size - next 4 bytes */
|
||||||
if ((stream->chunk_size = ((uint32_t)header_bytes[11] << 24) |
|
if ((stream->chunk_size = (
|
||||||
((uint32_t)header_bytes[10] << 16) |
|
(uint32_t)header_bytes[11] << 24)
|
||||||
((uint32_t)header_bytes[9] << 8) |
|
| ((uint32_t)header_bytes[10] << 16)
|
||||||
(uint32_t)header_bytes[8]) == 0)
|
| ((uint32_t)header_bytes[9] << 8)
|
||||||
|
| (uint32_t)header_bytes[8]) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Get total uncompressed data size - next 8 bytes */
|
/* Get total uncompressed data size - next 8 bytes */
|
||||||
if ((stream->size = ((uint64_t)header_bytes[19] << 56) |
|
if ((stream->size = (
|
||||||
((uint64_t)header_bytes[18] << 48) |
|
(uint64_t)header_bytes[19] << 56)
|
||||||
((uint64_t)header_bytes[17] << 40) |
|
| ((uint64_t)header_bytes[18] << 48)
|
||||||
((uint64_t)header_bytes[16] << 32) |
|
| ((uint64_t)header_bytes[17] << 40)
|
||||||
((uint64_t)header_bytes[15] << 24) |
|
| ((uint64_t)header_bytes[16] << 32)
|
||||||
((uint64_t)header_bytes[14] << 16) |
|
| ((uint64_t)header_bytes[15] << 24)
|
||||||
((uint64_t)header_bytes[13] << 8) |
|
| ((uint64_t)header_bytes[14] << 16)
|
||||||
(uint64_t)header_bytes[12]) == 0)
|
| ((uint64_t)header_bytes[13] << 8)
|
||||||
|
| (uint64_t)header_bytes[12]) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stream->is_compressed = true;
|
stream->is_compressed = true;
|
||||||
|
@ -391,8 +394,8 @@ rzipstream_t* rzipstream_open(const char *path, unsigned mode)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* If opening in read mode, ensure file exists */
|
/* If opening in read mode, ensure file exists */
|
||||||
if ((mode == RETRO_VFS_FILE_ACCESS_READ) &&
|
if ( (mode == RETRO_VFS_FILE_ACCESS_READ)
|
||||||
!path_is_valid(path))
|
&& !path_is_valid(path))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Allocate stream object */
|
/* Allocate stream object */
|
||||||
|
@ -454,10 +457,10 @@ static bool rzipstream_read_chunk(rzipstream_t *stream)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Get size of next compressed chunk */
|
/* Get size of next compressed chunk */
|
||||||
compressed_chunk_size = ((uint32_t)chunk_header_bytes[3] << 24) |
|
compressed_chunk_size = ( (uint32_t)chunk_header_bytes[3] << 24)
|
||||||
((uint32_t)chunk_header_bytes[2] << 16) |
|
| ((uint32_t)chunk_header_bytes[2] << 16)
|
||||||
((uint32_t)chunk_header_bytes[1] << 8) |
|
| ((uint32_t)chunk_header_bytes[1] << 8)
|
||||||
(uint32_t)chunk_header_bytes[0];
|
| (uint32_t)chunk_header_bytes[0];
|
||||||
if (compressed_chunk_size == 0)
|
if (compressed_chunk_size == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -523,7 +526,7 @@ static bool rzipstream_read_chunk(rzipstream_t *stream)
|
||||||
* the event of an error */
|
* the event of an error */
|
||||||
int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len)
|
int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len)
|
||||||
{
|
{
|
||||||
int64_t data_len = len;
|
int64_t _len = len;
|
||||||
uint8_t *data_ptr = (uint8_t *)data;
|
uint8_t *data_ptr = (uint8_t *)data;
|
||||||
int64_t data_read = 0;
|
int64_t data_read = 0;
|
||||||
|
|
||||||
|
@ -536,7 +539,7 @@ int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len)
|
||||||
return filestream_read(stream->file, data, len);
|
return filestream_read(stream->file, data, len);
|
||||||
|
|
||||||
/* Process input data */
|
/* Process input data */
|
||||||
while (data_len > 0)
|
while (_len > 0)
|
||||||
{
|
{
|
||||||
int64_t read_size = 0;
|
int64_t read_size = 0;
|
||||||
|
|
||||||
|
@ -556,8 +559,8 @@ int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len)
|
||||||
* > i.e. minimum of remaining output buffer
|
* > i.e. minimum of remaining output buffer
|
||||||
* occupancy and remaining 'read data' size */
|
* occupancy and remaining 'read data' size */
|
||||||
if ((read_size = stream->out_buf_occupancy - stream->out_buf_ptr) >
|
if ((read_size = stream->out_buf_occupancy - stream->out_buf_ptr) >
|
||||||
data_len)
|
_len)
|
||||||
read_size = data_len;
|
read_size = _len;
|
||||||
|
|
||||||
/* Copy as much cached data as possible into
|
/* Copy as much cached data as possible into
|
||||||
* the read buffer */
|
* the read buffer */
|
||||||
|
@ -566,7 +569,7 @@ int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len)
|
||||||
/* Increment pointers and remaining length */
|
/* Increment pointers and remaining length */
|
||||||
stream->out_buf_ptr += read_size;
|
stream->out_buf_ptr += read_size;
|
||||||
data_ptr += read_size;
|
data_ptr += read_size;
|
||||||
data_len -= read_size;
|
_len -= read_size;
|
||||||
|
|
||||||
stream->virtual_ptr += read_size;
|
stream->virtual_ptr += read_size;
|
||||||
|
|
||||||
|
@ -784,14 +787,14 @@ static bool rzipstream_write_chunk(rzipstream_t *stream)
|
||||||
* in the event of an error */
|
* in the event of an error */
|
||||||
int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len)
|
int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len)
|
||||||
{
|
{
|
||||||
int64_t data_len = len;
|
int64_t _len = len;
|
||||||
const uint8_t *data_ptr = (const uint8_t *)data;
|
const uint8_t *data_ptr = (const uint8_t *)data;
|
||||||
|
|
||||||
if (!stream || !stream->is_writing || !data)
|
if (!stream || !stream->is_writing || !data)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Process input data */
|
/* Process input data */
|
||||||
while (data_len > 0)
|
while (_len > 0)
|
||||||
{
|
{
|
||||||
int64_t cache_size = 0;
|
int64_t cache_size = 0;
|
||||||
|
|
||||||
|
@ -803,8 +806,8 @@ int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len)
|
||||||
/* Get amount of data to cache during this loop
|
/* Get amount of data to cache during this loop
|
||||||
* > i.e. minimum of space remaining in input buffer
|
* > i.e. minimum of space remaining in input buffer
|
||||||
* and remaining 'write data' size */
|
* and remaining 'write data' size */
|
||||||
if ((cache_size = stream->in_buf_size - stream->in_buf_ptr) > data_len)
|
if ((cache_size = stream->in_buf_size - stream->in_buf_ptr) > _len)
|
||||||
cache_size = data_len;
|
cache_size = _len;
|
||||||
|
|
||||||
/* Copy as much data as possible into
|
/* Copy as much data as possible into
|
||||||
* the input buffer */
|
* the input buffer */
|
||||||
|
@ -813,7 +816,7 @@ int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len)
|
||||||
/* Increment pointers and remaining length */
|
/* Increment pointers and remaining length */
|
||||||
stream->in_buf_ptr += cache_size;
|
stream->in_buf_ptr += cache_size;
|
||||||
data_ptr += cache_size;
|
data_ptr += cache_size;
|
||||||
data_len -= cache_size;
|
_len -= cache_size;
|
||||||
|
|
||||||
stream->size += cache_size;
|
stream->size += cache_size;
|
||||||
stream->virtual_ptr += cache_size;
|
stream->virtual_ptr += cache_size;
|
||||||
|
@ -831,12 +834,10 @@ int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len)
|
||||||
int rzipstream_putc(rzipstream_t *stream, int c)
|
int rzipstream_putc(rzipstream_t *stream, int c)
|
||||||
{
|
{
|
||||||
char c_char = (char)c;
|
char c_char = (char)c;
|
||||||
|
if ( stream && stream->is_writing
|
||||||
if (!stream || !stream->is_writing)
|
&& (rzipstream_write(stream, &c_char, 1) == 1))
|
||||||
return EOF;
|
return (int)(unsigned char)c;
|
||||||
|
return EOF;
|
||||||
return (rzipstream_write(stream, &c_char, 1) == 1) ?
|
|
||||||
(int)(unsigned char)c : EOF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Writes a variable argument list to an RZIP file.
|
/* Writes a variable argument list to an RZIP file.
|
||||||
|
@ -847,15 +848,13 @@ int rzipstream_putc(rzipstream_t *stream, int c)
|
||||||
int rzipstream_vprintf(rzipstream_t *stream, const char* format, va_list args)
|
int rzipstream_vprintf(rzipstream_t *stream, const char* format, va_list args)
|
||||||
{
|
{
|
||||||
static char buffer[8 * 1024] = {0};
|
static char buffer[8 * 1024] = {0};
|
||||||
int64_t num_chars = vsnprintf(buffer,
|
int _len = vsnprintf(buffer,
|
||||||
sizeof(buffer), format, args);
|
sizeof(buffer), format, args);
|
||||||
|
if (_len < 0)
|
||||||
if (num_chars < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
else if (num_chars == 0)
|
else if (_len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
return (int)rzipstream_write(stream, buffer, _len);
|
||||||
return (int)rzipstream_write(stream, buffer, num_chars);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Writes formatted output to an RZIP file.
|
/* Writes formatted output to an RZIP file.
|
||||||
|
@ -1050,20 +1049,17 @@ int rzipstream_close(rzipstream_t *stream)
|
||||||
* disk and update file header */
|
* disk and update file header */
|
||||||
if (stream->is_writing)
|
if (stream->is_writing)
|
||||||
{
|
{
|
||||||
if (stream->in_buf_ptr > 0)
|
if ( ((stream->in_buf_ptr > 0)
|
||||||
if (!rzipstream_write_chunk(stream))
|
&& !rzipstream_write_chunk(stream))
|
||||||
goto error;
|
|| !rzipstream_write_file_header(stream))
|
||||||
|
{
|
||||||
if (!rzipstream_write_file_header(stream))
|
/* Stream must be free()'d regardless */
|
||||||
goto error;
|
rzipstream_free_stream(stream);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free stream
|
/* Free stream
|
||||||
* > This also closes the file */
|
* > This also closes the file */
|
||||||
return rzipstream_free_stream(stream);
|
return rzipstream_free_stream(stream);
|
||||||
|
|
||||||
error:
|
|
||||||
/* Stream must be free()'d regardless */
|
|
||||||
rzipstream_free_stream(stream);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -681,7 +681,7 @@ static struct buffer query_parse_table(
|
||||||
buff = query_expect_char(s, len, buff, '{', error);
|
buff = query_expect_char(s, len, buff, '{', error);
|
||||||
|
|
||||||
if (*error)
|
if (*error)
|
||||||
goto clean;
|
return buff;
|
||||||
|
|
||||||
buff = query_chomp(buff);
|
buff = query_chomp(buff);
|
||||||
|
|
||||||
|
@ -798,13 +798,12 @@ static struct buffer query_parse_method_call(
|
||||||
|
|
||||||
invocation->func = NULL;
|
invocation->func = NULL;
|
||||||
|
|
||||||
buff = query_get_ident(s, len,
|
buff = query_get_ident(s, len, buff, &func_name, &_len, error);
|
||||||
buff, &func_name, &_len, error);
|
|
||||||
if (*error)
|
if (*error)
|
||||||
goto clean;
|
return buff;
|
||||||
|
|
||||||
buff = query_chomp(buff);
|
buff = query_chomp(buff);
|
||||||
buff = query_expect_char(s, len, buff, '(', error);
|
buff = query_expect_char(s, len, buff, '(', error);
|
||||||
if (*error)
|
if (*error)
|
||||||
goto clean;
|
goto clean;
|
||||||
|
|
||||||
|
|
|
@ -422,12 +422,6 @@ int rmsgpack_dom_read_into(intfstream_t *fd, ...)
|
||||||
int rv;
|
int rv;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
struct rmsgpack_dom_value map;
|
struct rmsgpack_dom_value map;
|
||||||
struct rmsgpack_dom_value key;
|
|
||||||
int64_t *int_value;
|
|
||||||
uint64_t *uint_value;
|
|
||||||
int *bool_value;
|
|
||||||
char *buff_value;
|
|
||||||
uint64_t min_len;
|
|
||||||
|
|
||||||
va_start(ap, fd);
|
va_start(ap, fd);
|
||||||
|
|
||||||
|
@ -439,13 +433,20 @@ int rmsgpack_dom_read_into(intfstream_t *fd, ...)
|
||||||
|
|
||||||
if (map.type == RDT_MAP)
|
if (map.type == RDT_MAP)
|
||||||
{
|
{
|
||||||
|
int *bool_value;
|
||||||
|
char *buff_value;
|
||||||
|
uint64_t min_len;
|
||||||
|
int64_t *int_value;
|
||||||
|
uint64_t *uint_value;
|
||||||
|
struct rmsgpack_dom_value key;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
struct rmsgpack_dom_value *value;
|
struct rmsgpack_dom_value *value;
|
||||||
const char *key_name = va_arg(ap, const char *);
|
const char *key_name = va_arg(ap, const char *);
|
||||||
|
|
||||||
if (!key_name)
|
if (!key_name)
|
||||||
goto clean;
|
break;
|
||||||
|
|
||||||
key.type = RDT_STRING;
|
key.type = RDT_STRING;
|
||||||
key.val.string.len = (uint32_t)strlen(key_name);
|
key.val.string.len = (uint32_t)strlen(key_name);
|
||||||
|
@ -486,12 +487,13 @@ int rmsgpack_dom_read_into(intfstream_t *fd, ...)
|
||||||
memcpy(buff_value, value->val.string.buff, (size_t)min_len);
|
memcpy(buff_value, value->val.string.buff, (size_t)min_len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto clean;
|
va_end(ap);
|
||||||
|
rmsgpack_dom_value_free(&map);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clean:
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
rmsgpack_dom_value_free(&map);
|
rmsgpack_dom_value_free(&map);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -519,15 +519,10 @@ enum manual_content_scan_playlist_refresh_status
|
||||||
system_name_type = MANUAL_CONTENT_SCAN_SYSTEM_NAME_CONTENT_DIR;
|
system_name_type = MANUAL_CONTENT_SCAN_SYSTEM_NAME_CONTENT_DIR;
|
||||||
enum manual_content_scan_core_type
|
enum manual_content_scan_core_type
|
||||||
core_type = MANUAL_CONTENT_SCAN_CORE_DETECT;
|
core_type = MANUAL_CONTENT_SCAN_CORE_DETECT;
|
||||||
enum manual_content_scan_playlist_refresh_status
|
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_OK;
|
|
||||||
char system_name[NAME_MAX_LENGTH];
|
char system_name[NAME_MAX_LENGTH];
|
||||||
|
|
||||||
if (!playlist_scan_refresh_enabled(playlist))
|
if (!playlist_scan_refresh_enabled(playlist))
|
||||||
{
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_MISSING_CONFIG;
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_MISSING_CONFIG;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read scan parameters from playlist */
|
/* Read scan parameters from playlist */
|
||||||
playlist_path = playlist_get_conf_path(playlist);
|
playlist_path = playlist_get_conf_path(playlist);
|
||||||
|
@ -543,31 +538,22 @@ enum manual_content_scan_playlist_refresh_status
|
||||||
|
|
||||||
/* Determine system name (playlist basename
|
/* Determine system name (playlist basename
|
||||||
* without extension) */
|
* without extension) */
|
||||||
|
/* Cannot happen, but would constitute a
|
||||||
|
* 'system name' error */
|
||||||
if (string_is_empty(playlist_path))
|
if (string_is_empty(playlist_path))
|
||||||
{
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME;
|
||||||
/* Cannot happen, but would constitute a
|
|
||||||
* 'system name' error */
|
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_pathname(system_name, path_basename(playlist_path),
|
fill_pathname(system_name, path_basename(playlist_path),
|
||||||
"", sizeof(system_name));
|
"", sizeof(system_name));
|
||||||
|
|
||||||
|
/* Cannot happen, but would constitute a
|
||||||
|
* 'system name' error */
|
||||||
if (string_is_empty(system_name))
|
if (string_is_empty(system_name))
|
||||||
{
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME;
|
||||||
/* Cannot happen, but would constitute a
|
|
||||||
* 'system name' error */
|
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set content directory */
|
/* Set content directory */
|
||||||
if (!manual_content_scan_set_menu_content_dir(content_dir))
|
if (!manual_content_scan_set_menu_content_dir(content_dir))
|
||||||
{
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CONTENT_DIR;
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CONTENT_DIR;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set system name */
|
/* Set system name */
|
||||||
#ifdef HAVE_LIBRETRODB
|
#ifdef HAVE_LIBRETRODB
|
||||||
|
@ -630,10 +616,7 @@ enum manual_content_scan_playlist_refresh_status
|
||||||
|
|
||||||
if (!manual_content_scan_set_menu_system_name(
|
if (!manual_content_scan_set_menu_system_name(
|
||||||
system_name_type, system_name))
|
system_name_type, system_name))
|
||||||
{
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME;
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set core path/name */
|
/* Set core path/name */
|
||||||
if ( !string_is_empty(core_name)
|
if ( !string_is_empty(core_name)
|
||||||
|
@ -642,10 +625,7 @@ enum manual_content_scan_playlist_refresh_status
|
||||||
|
|
||||||
if (!manual_content_scan_set_menu_core_name(
|
if (!manual_content_scan_set_menu_core_name(
|
||||||
core_type, core_name))
|
core_type, core_name))
|
||||||
{
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CORE;
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CORE;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set custom file extensions */
|
/* Set custom file extensions */
|
||||||
if (string_is_empty(file_exts))
|
if (string_is_empty(file_exts))
|
||||||
|
@ -679,11 +659,9 @@ enum manual_content_scan_playlist_refresh_status
|
||||||
switch (manual_content_scan_validate_dat_file_path())
|
switch (manual_content_scan_validate_dat_file_path())
|
||||||
{
|
{
|
||||||
case MANUAL_CONTENT_SCAN_DAT_FILE_INVALID:
|
case MANUAL_CONTENT_SCAN_DAT_FILE_INVALID:
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_DAT_FILE;
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_DAT_FILE;
|
||||||
goto end;
|
|
||||||
case MANUAL_CONTENT_SCAN_DAT_FILE_TOO_LARGE:
|
case MANUAL_CONTENT_SCAN_DAT_FILE_TOO_LARGE:
|
||||||
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_DAT_FILE_TOO_LARGE;
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_DAT_FILE_TOO_LARGE;
|
||||||
goto end;
|
|
||||||
default:
|
default:
|
||||||
/* No action required */
|
/* No action required */
|
||||||
break;
|
break;
|
||||||
|
@ -700,8 +678,7 @@ enum manual_content_scan_playlist_refresh_status
|
||||||
* existing file */
|
* existing file */
|
||||||
scan_settings.validate_entries = true;
|
scan_settings.validate_entries = true;
|
||||||
|
|
||||||
end:
|
return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_OK;
|
||||||
return playlist_status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Menu getters */
|
/* Menu getters */
|
||||||
|
@ -1096,9 +1073,9 @@ struct string_list *manual_content_scan_get_content_list(
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if (!task_config)
|
if (!task_config)
|
||||||
goto error;
|
return NULL;
|
||||||
if (string_is_empty(task_config->content_dir))
|
if (string_is_empty(task_config->content_dir))
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
/* Check whether files should be filtered by
|
/* Check whether files should be filtered by
|
||||||
* extension */
|
* extension */
|
||||||
|
@ -1187,7 +1164,7 @@ static bool manual_content_scan_get_playlist_content_path(
|
||||||
/* Get archive file contents */
|
/* Get archive file contents */
|
||||||
if (!(archive_list = file_archive_get_file_list(
|
if (!(archive_list = file_archive_get_file_list(
|
||||||
content_path, filter_exts ? task_config->file_exts : NULL)))
|
content_path, filter_exts ? task_config->file_exts : NULL)))
|
||||||
goto error;
|
return false;
|
||||||
|
|
||||||
if (archive_list->size < 1)
|
if (archive_list->size < 1)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -164,7 +164,6 @@ static void handle_discord_join_cb(retro_task_t *task, void *task_data,
|
||||||
goto done;
|
goto done;
|
||||||
if (data->status != 200)
|
if (data->status != 200)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (!(room_data = (char*)malloc(data->len + 1)))
|
if (!(room_data = (char*)malloc(data->len + 1)))
|
||||||
goto done;
|
goto done;
|
||||||
memcpy(room_data, data->data, data->len);
|
memcpy(room_data, data->data, data->len);
|
||||||
|
|
Loading…
Reference in New Issue