Skip to content

Commit

Permalink
Style cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 7, 2014
1 parent f2429a9 commit 9d783b6
Show file tree
Hide file tree
Showing 15 changed files with 261 additions and 152 deletions.
3 changes: 3 additions & 0 deletions cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
typedef struct cheat_manager cheat_manager_t;

cheat_manager_t* cheat_manager_new(const char *path);

void cheat_manager_free(cheat_manager_t *handle);

void cheat_manager_index_next(cheat_manager_t *handle);

void cheat_manager_index_prev(cheat_manager_t *handle);

void cheat_manager_toggle(cheat_manager_t *handle);

#endif
4 changes: 4 additions & 0 deletions core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ core_option_manager_t *core_option_new(const char *conf_path,
const struct retro_variable *vars);

bool core_option_updated(core_option_manager_t *opt);

void core_option_flush(core_option_manager_t *opt);

void core_option_free(core_option_manager_t *opt);

void core_option_get(core_option_manager_t *opt, struct retro_variable *var);
Expand All @@ -40,6 +42,7 @@ size_t core_option_size(core_option_manager_t *opt);

/* Gets description and current value for an option. */
const char *core_option_get_desc(core_option_manager_t *opt, size_t index);

const char *core_option_get_val(core_option_manager_t *opt, size_t index);

/* Helpers to present a list of options */
Expand All @@ -51,6 +54,7 @@ void core_option_set_val(core_option_manager_t *opt,

/* Cycles through options for an option. Options wrap around. */
void core_option_next(core_option_manager_t *opt, size_t index);

void core_option_prev(core_option_manager_t *opt, size_t index);

/* Sets default value for an option. */
Expand Down
25 changes: 13 additions & 12 deletions driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,16 +439,18 @@ typedef struct driver
/* Set to true by driver if context caching succeeded. */
bool video_cache_context_ack;

/* Set this to true if the platform in question needs to 'own' the respective
* handle and therefore skip regular RetroArch driver teardown/reiniting procedure.
/* Set this to true if the platform in question needs to 'own'
* the respective handle and therefore skip regular RetroArch
* driver teardown/reiniting procedure.
*
* If set to true, the 'free' function will get skipped. It is then up to the
* driver implementation to properly handle 'reiniting' inside the 'init' function
* and make sure it returns the existing handle instead of allocating and returning
* a pointer to a new handle.
* If set to true, the 'free' function will get skipped. It is
* then up to the driver implementation to properly handle
* 'reiniting' inside the 'init' function and make sure it
* returns the existing handle instead of allocating and
* returning a pointer to a new handle.
*
* Typically, if a driver intends to make use of this, it should set this to true
* at the end of its 'init' function. */
* Typically, if a driver intends to make use of this, it should
* set this to true at the end of its 'init' function. */
bool video_data_own;
bool audio_data_own;
bool input_data_own;
Expand Down Expand Up @@ -553,12 +555,12 @@ unsigned dspfilter_get_last_idx(void);

const char *rarch_dspfilter_get_name(void *data);

// Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE
/* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. */
bool driver_camera_start(void);
void driver_camera_stop(void);
void driver_camera_poll(void);

// Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE
/* Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. */
bool driver_location_start(void);
void driver_location_stop(void);
bool driver_location_get_position(double *lat, double *lon,
Expand All @@ -570,10 +572,9 @@ void driver_location_set_interval(unsigned interval_msecs,
void find_menu_driver(void);
#endif

// Used by RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO
/* Used by RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO. */
bool driver_update_system_av_info(const struct retro_system_av_info *info);


extern driver_t driver;

/* Backends */
Expand Down
9 changes: 6 additions & 3 deletions dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ function_t dylib_proc(dylib_t lib, const char *proc);
*
* For statically linked cores, pass retro_set_environment as argument.
*/
void libretro_get_environment_info(void (*)(retro_environment_t), bool *load_no_content);
void libretro_get_environment_info(void (*)(retro_environment_t),
bool *load_no_content);

#ifdef HAVE_DYNAMIC
/* Gets system info from an arbitrary lib.
* The struct returned must be freed as strings are allocated dynamically. */
bool libretro_get_system_info(const char *path, struct retro_system_info *info, bool *load_no_content);
bool libretro_get_system_info(const char *path,
struct retro_system_info *info, bool *load_no_content);

void libretro_free_system_info(struct retro_system_info *info);
#endif
Expand Down Expand Up @@ -121,7 +123,8 @@ extern void (*pretro_cheat_set)(unsigned, bool, const char*);

extern bool (*pretro_load_game)(const struct retro_game_info*);

extern bool (*pretro_load_game_special)(unsigned, const struct retro_game_info*, size_t);
extern bool (*pretro_load_game_special)(unsigned,
const struct retro_game_info*, size_t);

extern void (*pretro_unload_game)(void);

Expand Down
6 changes: 4 additions & 2 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ static ssize_t read_content_file(const char *path, void **buf)
return -1;
}
ret = read_compressed_file(g_extern.carchive_path,
archive_found + strlen(g_extern.carchive_path) + 1, (void**)&ret_buf);
archive_found + strlen(g_extern.carchive_path) + 1,
(void**)&ret_buf);
}
else
{
/* If we didn't actually find the archivename in the filename
* the given path is not inside the archive. Then we proceed to just load the file.
* the given path is not inside the archive. Then we proceed to
* just load the file.
*/
ret = read_file(path, (void**)&ret_buf);
}
Expand Down
37 changes: 22 additions & 15 deletions file_extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@

#include "hash.h"

// File backends. Can be fleshed out later, but keep it simple for now.
// The file is mapped to memory directly (via mmap() or just plain read_file()).
/* File backends. Can be fleshed out later, but keep it simple for now.
* The file is mapped to memory directly (via mmap() or just
* plain read_file()).
*/
struct zlib_file_backend
{
void *(*open)(const char *path);
const uint8_t *(*data)(void *handle);
size_t (*size)(void *handle);
void (*free)(void *handle); // Closes, unmaps and frees.
void (*free)(void *handle); /* Closes, unmaps and frees. */
};

#ifdef HAVE_MMAP
Expand Down Expand Up @@ -168,7 +170,7 @@ const struct zlib_file_backend *zlib_get_default_file_backend(void)
}


// Modified from nall::unzip (higan).
/* Modified from nall::unzip (higan). */

#undef GOTO_END_ERROR
#define GOTO_END_ERROR() do { \
Expand Down Expand Up @@ -292,7 +294,10 @@ bool zlib_parse_file(const char *file, zlib_file_cb file_cb, void *userdata)

const uint8_t *cdata = data + offset + 30 + offsetNL + offsetEL;

//RARCH_LOG("OFFSET: %u, CSIZE: %u, SIZE: %u.\n", offset + 30 + offsetNL + offsetEL, csize, size);
#if 0
RARCH_LOG("OFFSET: %u, CSIZE: %u, SIZE: %u.\n", offset + 30 +
offsetNL + offsetEL, csize, size);
#endif

if (!file_cb(filename, cdata, cmode, csize, size, crc32, userdata))
break;
Expand All @@ -315,12 +320,13 @@ struct zip_extract_userdata
bool found_content;
};

static bool zip_extract_cb(const char *name, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
static bool zip_extract_cb(const char *name, const uint8_t *cdata,
unsigned cmode, uint32_t csize, uint32_t size,
uint32_t crc32, void *userdata)
{
struct zip_extract_userdata *data = (struct zip_extract_userdata*)userdata;

// Extract first content that matches our list.
/* Extract first content that matches our list. */
const char *ext = path_get_extension(name);
if (ext && string_list_find_elem(data->ext, ext))
{
Expand All @@ -335,11 +341,12 @@ static bool zip_extract_cb(const char *name, const uint8_t *cdata, unsigned cmod

switch (cmode)
{
case 0: // Uncompressed
/* Uncompressed. */
case 0:
data->found_content = write_file(new_path, cdata, size);
return false;

case 8: // Deflate
/* Deflate. */
case 8:
if (zlib_inflate_data_to_file(new_path, cdata, csize, size, crc32))
{
strlcpy(data->zip_path, new_path, data->zip_path_size);
Expand All @@ -356,8 +363,8 @@ static bool zip_extract_cb(const char *name, const uint8_t *cdata, unsigned cmod
return true;
}

bool zlib_extract_first_content_file(char *zip_path, size_t zip_path_size, const char *valid_exts,
const char *extraction_directory)
bool zlib_extract_first_content_file(char *zip_path, size_t zip_path_size,
const char *valid_exts, const char *extraction_directory)
{
bool ret;
struct zip_extract_userdata userdata = {0};
Expand Down Expand Up @@ -397,9 +404,9 @@ bool zlib_extract_first_content_file(char *zip_path, size_t zip_path_size, const
return ret;
}

static bool zlib_get_file_list_cb(const char *path, const uint8_t *cdata, unsigned cmode,
uint32_t csize, uint32_t size,
uint32_t crc32, void *userdata)
static bool zlib_get_file_list_cb(const char *path, const uint8_t *cdata,
unsigned cmode, uint32_t csize, uint32_t size, uint32_t crc32,
void *userdata)
{
(void)cdata;
(void)cmode;
Expand Down
11 changes: 7 additions & 4 deletions file_extract.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@
#include <stddef.h>
#include <stdint.h>

// Returns true when parsing should continue. False to stop.
/* Returns true when parsing should continue. False to stop. */
typedef bool (*zlib_file_cb)(const char *name,
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
uint32_t crc32, void *userdata);

// Low-level file parsing. Enumerates over all files and calls file_cb with userdata.
/* Low-level file parsing. Enumerates over all files and calls
* file_cb with userdata. */
bool zlib_parse_file(const char *file, zlib_file_cb file_cb, void *userdata);

// Built with zlib_parse_file.
bool zlib_extract_first_content_file(char *zip_path, size_t zip_path_size, const char *valid_exts, const char *extraction_dir);
/* Built with zlib_parse_file. */
bool zlib_extract_first_content_file(char *zip_path, size_t zip_path_size,
const char *valid_exts, const char *extraction_dir);

struct string_list *zlib_get_file_list(const char *path);

bool zlib_inflate_data_to_file(const char *path, const uint8_t *data,
Expand Down
Loading

0 comments on commit 9d783b6

Please sign in to comment.