print_buf_lines - moved
This commit is contained in:
parent
7abf68a5b3
commit
adb0add226
|
@ -90,143 +90,6 @@ static enum msg_hash_enums new_type = MSG_UNKNOWN;
|
||||||
/* HACK - we have to find some way to pass state inbetween
|
/* HACK - we have to find some way to pass state inbetween
|
||||||
* function pointer callback functions that don't necessarily
|
* function pointer callback functions that don't necessarily
|
||||||
* call each other. */
|
* call each other. */
|
||||||
static void print_buf_lines(file_list_t *list, char *buf,
|
|
||||||
const char *label, int buf_size,
|
|
||||||
enum msg_file_type type, bool append, bool extended)
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
int i, j = 0;
|
|
||||||
char *line_start = buf;
|
|
||||||
|
|
||||||
if (!buf || !buf_size)
|
|
||||||
{
|
|
||||||
menu_entries_append_enum(list,
|
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
|
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),
|
|
||||||
MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY,
|
|
||||||
FILE_TYPE_NONE, 0, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < buf_size; i++)
|
|
||||||
{
|
|
||||||
size_t ln;
|
|
||||||
const char *core_date = NULL;
|
|
||||||
const char *core_crc = NULL;
|
|
||||||
const char *core_pathname = NULL;
|
|
||||||
struct string_list *str_list = NULL;
|
|
||||||
|
|
||||||
/* The end of the buffer, print the last bit */
|
|
||||||
if (*(buf + i) == '\0')
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (*(buf + i) != '\n')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Found a line ending, print the line and compute new line_start */
|
|
||||||
|
|
||||||
/* Save the next char */
|
|
||||||
c = *(buf + i + 1);
|
|
||||||
/* replace with \0 */
|
|
||||||
*(buf + i + 1) = '\0';
|
|
||||||
|
|
||||||
/* We need to strip the newline. */
|
|
||||||
ln = strlen(line_start) - 1;
|
|
||||||
if (line_start[ln] == '\n')
|
|
||||||
line_start[ln] = '\0';
|
|
||||||
|
|
||||||
str_list = string_split(line_start, " ");
|
|
||||||
|
|
||||||
if (str_list->elems[0].data)
|
|
||||||
core_date = str_list->elems[0].data;
|
|
||||||
if (str_list->elems[1].data)
|
|
||||||
core_crc = str_list->elems[1].data;
|
|
||||||
if (str_list->elems[2].data)
|
|
||||||
core_pathname = str_list->elems[2].data;
|
|
||||||
|
|
||||||
(void)core_date;
|
|
||||||
(void)core_crc;
|
|
||||||
|
|
||||||
if (extended)
|
|
||||||
{
|
|
||||||
if (append)
|
|
||||||
menu_entries_append_enum(list, core_pathname, "",
|
|
||||||
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
|
|
||||||
else
|
|
||||||
menu_entries_prepend(list, core_pathname, "",
|
|
||||||
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (append)
|
|
||||||
menu_entries_append_enum(list, line_start, label,
|
|
||||||
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
|
|
||||||
else
|
|
||||||
menu_entries_prepend(list, line_start, label,
|
|
||||||
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case FILE_TYPE_DOWNLOAD_CORE:
|
|
||||||
{
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
if (settings)
|
|
||||||
{
|
|
||||||
char display_name[255];
|
|
||||||
char core_path[PATH_MAX_LENGTH];
|
|
||||||
char *last = NULL;
|
|
||||||
|
|
||||||
display_name[0] = core_path[0] = '\0';
|
|
||||||
|
|
||||||
fill_pathname_join_noext(
|
|
||||||
core_path,
|
|
||||||
settings->paths.path_libretro_info,
|
|
||||||
(extended && !string_is_empty(core_pathname))
|
|
||||||
? core_pathname : line_start,
|
|
||||||
sizeof(core_path));
|
|
||||||
path_remove_extension(core_path);
|
|
||||||
|
|
||||||
last = (char*)strrchr(core_path, '_');
|
|
||||||
|
|
||||||
if (!string_is_empty(last))
|
|
||||||
{
|
|
||||||
if (string_is_not_equal_fast(last, "_libretro", 9))
|
|
||||||
*last = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
strlcat(core_path,
|
|
||||||
file_path_str(FILE_PATH_CORE_INFO_EXTENSION),
|
|
||||||
sizeof(core_path));
|
|
||||||
|
|
||||||
if (
|
|
||||||
path_file_exists(core_path)
|
|
||||||
&& core_info_get_display_name(
|
|
||||||
core_path, display_name, sizeof(display_name)))
|
|
||||||
file_list_set_alt_at_offset(list, j, display_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case FILE_TYPE_NONE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
j++;
|
|
||||||
|
|
||||||
string_list_free(str_list);
|
|
||||||
|
|
||||||
/* Restore the saved char */
|
|
||||||
*(buf + i + 1) = c;
|
|
||||||
line_start = buf + i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (append)
|
|
||||||
file_list_sort_on_alt(list);
|
|
||||||
/* If the buffer was completely full, and didn't end
|
|
||||||
* with a newline, just ignore the partial last line. */
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU)
|
#if !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU)
|
||||||
#include <net/net_ifinfo.h>
|
#include <net/net_ifinfo.h>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <lists/file_list.h>
|
#include <lists/file_list.h>
|
||||||
|
#include <lists/string_list.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
@ -32,6 +33,8 @@
|
||||||
#include "menu_entries.h"
|
#include "menu_entries.h"
|
||||||
#include "widgets/menu_list.h"
|
#include "widgets/menu_list.h"
|
||||||
|
|
||||||
|
#include "../core_info.h"
|
||||||
|
#include "../configuration.h"
|
||||||
#include "../file_path_special.h"
|
#include "../file_path_special.h"
|
||||||
#include "../msg_hash.h"
|
#include "../msg_hash.h"
|
||||||
#include "../tasks/tasks_internal.h"
|
#include "../tasks/tasks_internal.h"
|
||||||
|
@ -39,6 +42,144 @@
|
||||||
char *core_buf = NULL;
|
char *core_buf = NULL;
|
||||||
size_t core_len = 0;
|
size_t core_len = 0;
|
||||||
|
|
||||||
|
void print_buf_lines(file_list_t *list, char *buf,
|
||||||
|
const char *label, int buf_size,
|
||||||
|
enum msg_file_type type, bool append, bool extended)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
int i, j = 0;
|
||||||
|
char *line_start = buf;
|
||||||
|
|
||||||
|
if (!buf || !buf_size)
|
||||||
|
{
|
||||||
|
menu_entries_append_enum(list,
|
||||||
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
|
||||||
|
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),
|
||||||
|
MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY,
|
||||||
|
FILE_TYPE_NONE, 0, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < buf_size; i++)
|
||||||
|
{
|
||||||
|
size_t ln;
|
||||||
|
const char *core_date = NULL;
|
||||||
|
const char *core_crc = NULL;
|
||||||
|
const char *core_pathname = NULL;
|
||||||
|
struct string_list *str_list = NULL;
|
||||||
|
|
||||||
|
/* The end of the buffer, print the last bit */
|
||||||
|
if (*(buf + i) == '\0')
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (*(buf + i) != '\n')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Found a line ending, print the line and compute new line_start */
|
||||||
|
|
||||||
|
/* Save the next char */
|
||||||
|
c = *(buf + i + 1);
|
||||||
|
/* replace with \0 */
|
||||||
|
*(buf + i + 1) = '\0';
|
||||||
|
|
||||||
|
/* We need to strip the newline. */
|
||||||
|
ln = strlen(line_start) - 1;
|
||||||
|
if (line_start[ln] == '\n')
|
||||||
|
line_start[ln] = '\0';
|
||||||
|
|
||||||
|
str_list = string_split(line_start, " ");
|
||||||
|
|
||||||
|
if (str_list->elems[0].data)
|
||||||
|
core_date = str_list->elems[0].data;
|
||||||
|
if (str_list->elems[1].data)
|
||||||
|
core_crc = str_list->elems[1].data;
|
||||||
|
if (str_list->elems[2].data)
|
||||||
|
core_pathname = str_list->elems[2].data;
|
||||||
|
|
||||||
|
(void)core_date;
|
||||||
|
(void)core_crc;
|
||||||
|
|
||||||
|
if (extended)
|
||||||
|
{
|
||||||
|
if (append)
|
||||||
|
menu_entries_append_enum(list, core_pathname, "",
|
||||||
|
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
|
||||||
|
else
|
||||||
|
menu_entries_prepend(list, core_pathname, "",
|
||||||
|
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (append)
|
||||||
|
menu_entries_append_enum(list, line_start, label,
|
||||||
|
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
|
||||||
|
else
|
||||||
|
menu_entries_prepend(list, line_start, label,
|
||||||
|
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case FILE_TYPE_DOWNLOAD_CORE:
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (settings)
|
||||||
|
{
|
||||||
|
char display_name[255];
|
||||||
|
char core_path[PATH_MAX_LENGTH];
|
||||||
|
char *last = NULL;
|
||||||
|
|
||||||
|
display_name[0] = core_path[0] = '\0';
|
||||||
|
|
||||||
|
fill_pathname_join_noext(
|
||||||
|
core_path,
|
||||||
|
settings->paths.path_libretro_info,
|
||||||
|
(extended && !string_is_empty(core_pathname))
|
||||||
|
? core_pathname : line_start,
|
||||||
|
sizeof(core_path));
|
||||||
|
path_remove_extension(core_path);
|
||||||
|
|
||||||
|
last = (char*)strrchr(core_path, '_');
|
||||||
|
|
||||||
|
if (!string_is_empty(last))
|
||||||
|
{
|
||||||
|
if (string_is_not_equal_fast(last, "_libretro", 9))
|
||||||
|
*last = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
strlcat(core_path,
|
||||||
|
file_path_str(FILE_PATH_CORE_INFO_EXTENSION),
|
||||||
|
sizeof(core_path));
|
||||||
|
|
||||||
|
if (
|
||||||
|
path_file_exists(core_path)
|
||||||
|
&& core_info_get_display_name(
|
||||||
|
core_path, display_name, sizeof(display_name)))
|
||||||
|
file_list_set_alt_at_offset(list, j, display_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case FILE_TYPE_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
j++;
|
||||||
|
|
||||||
|
string_list_free(str_list);
|
||||||
|
|
||||||
|
/* Restore the saved char */
|
||||||
|
*(buf + i + 1) = c;
|
||||||
|
line_start = buf + i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (append)
|
||||||
|
file_list_sort_on_alt(list);
|
||||||
|
/* If the buffer was completely full, and didn't end
|
||||||
|
* with a newline, just ignore the partial last line. */
|
||||||
|
}
|
||||||
|
|
||||||
void cb_net_generic_subdir(void *task_data, void *user_data, const char *err)
|
void cb_net_generic_subdir(void *task_data, void *user_data, const char *err)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
|
|
|
@ -21,11 +21,17 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
|
#include <lists/file_list.h>
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
extern char *core_buf;
|
extern char *core_buf;
|
||||||
extern size_t core_len;
|
extern size_t core_len;
|
||||||
|
|
||||||
|
void print_buf_lines(file_list_t *list, char *buf,
|
||||||
|
const char *label, int buf_size,
|
||||||
|
enum msg_file_type type, bool append, bool extended);
|
||||||
|
|
||||||
void cb_net_generic_subdir(void *task_data, void *user_data,
|
void cb_net_generic_subdir(void *task_data, void *user_data,
|
||||||
const char *err);
|
const char *err);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue