mirror of
https://github.com/libretro/RetroArch
synced 2024-12-26 21:29:08 +00:00
Create new char_list_new_special
This commit is contained in:
parent
9e83bdf656
commit
db5d8d248b
@ -225,7 +225,7 @@ const char *audio_driver_find_ident(int idx)
|
||||
**/
|
||||
const char *config_get_audio_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_AUDIO_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_AUDIO_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void find_audio_driver(void)
|
||||
|
@ -99,7 +99,7 @@ const char *audio_resampler_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_audio_resampler_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_AUDIO_RESAMPLER_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_AUDIO_RESAMPLER_DRIVERS, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -80,7 +80,7 @@ const char *camera_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_camera_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_CAMERA_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_CAMERA_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void find_camera_driver(void)
|
||||
|
@ -151,7 +151,7 @@ const char *video_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_video_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_VIDEO_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_VIDEO_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void find_video_driver(void)
|
||||
|
@ -108,7 +108,7 @@ const char *input_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_input_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_INPUT_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_INPUT_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void find_input_driver(void)
|
||||
|
@ -81,7 +81,7 @@ const char *hid_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_hid_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_INPUT_HID_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_INPUT_HID_DRIVERS, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -109,7 +109,7 @@ const char *joypad_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_joypad_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_INPUT_JOYPAD_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_INPUT_JOYPAD_DRIVERS, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -73,7 +73,7 @@ const char *location_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_location_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_LOCATION_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_LOCATION_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void find_location_driver(void)
|
||||
|
@ -87,7 +87,7 @@ const char *menu_driver_find_ident(int idx)
|
||||
**/
|
||||
const char *config_get_menu_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_MENU_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_MENU_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void find_menu_driver(void)
|
||||
|
@ -76,7 +76,7 @@ const void *record_driver_find_handle(int idx)
|
||||
**/
|
||||
const char* config_get_record_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_RECORD_DRIVERS, NULL);
|
||||
return char_list_new_special(STRING_LIST_RECORD_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void find_record_driver(void)
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <string/string_list.h>
|
||||
|
||||
#include "string_list_special.h"
|
||||
|
||||
@ -39,14 +38,13 @@
|
||||
#include "audio/audio_resampler_driver.h"
|
||||
#include "record/record_driver.h"
|
||||
|
||||
const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
struct string_list *string_list_new_special(enum string_list_type type,
|
||||
void *data, unsigned *len)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
unsigned i;
|
||||
size_t list_size;
|
||||
char *options = NULL;
|
||||
const core_info_t *core_info = NULL;
|
||||
int len = 0;
|
||||
global_t *global = global_get_ptr();
|
||||
struct string_list *s = string_list_new();
|
||||
|
||||
@ -54,6 +52,11 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
|
||||
(void)data;
|
||||
|
||||
if (!len)
|
||||
return NULL;
|
||||
|
||||
*len = 0;
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
@ -64,7 +67,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; menu_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = menu_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -75,7 +78,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; camera_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = camera_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -86,7 +89,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; location_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = location_driver_find_ident(i);
|
||||
options_len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
string_list_append(options_l, opt, attr);
|
||||
}
|
||||
break;
|
||||
@ -95,7 +98,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; audio_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = audio_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -104,7 +107,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; audio_resampler_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = audio_resampler_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -113,7 +116,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; video_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = video_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -122,7 +125,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; input_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = input_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -131,7 +134,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; hid_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = hid_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -140,7 +143,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; joypad_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = joypad_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -149,7 +152,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
for (i = 0; record_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = record_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
@ -159,7 +162,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
(const char*)data, &core_info, &list_size);
|
||||
|
||||
if (list_size == 0)
|
||||
goto end;
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < list_size; i++)
|
||||
{
|
||||
@ -168,9 +171,9 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
opt = info ? info->path : NULL;
|
||||
|
||||
if (!opt)
|
||||
goto end;
|
||||
goto error;
|
||||
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
@ -182,9 +185,9 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
opt = core_info ? core_info->path : NULL;
|
||||
|
||||
if (!opt)
|
||||
goto end;
|
||||
goto error;
|
||||
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
@ -193,7 +196,7 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
(const char*)data, &core_info, &list_size);
|
||||
|
||||
if (list_size == 0)
|
||||
goto end;
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < list_size; i++)
|
||||
{
|
||||
@ -202,9 +205,9 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
opt = info ? info->display_name : NULL;
|
||||
|
||||
if (!opt)
|
||||
goto end;
|
||||
goto error;
|
||||
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
@ -217,23 +220,32 @@ const char *string_list_special_new(enum string_list_type type, void *data)
|
||||
opt = core_info ? core_info->display_name : NULL;
|
||||
|
||||
if (!opt)
|
||||
goto end;
|
||||
goto error;
|
||||
|
||||
len += strlen(opt) + 1;
|
||||
*len += strlen(opt) + 1;
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
case STRING_LIST_NONE:
|
||||
default:
|
||||
goto end;
|
||||
goto error;
|
||||
}
|
||||
|
||||
options = (char*)calloc(len, sizeof(char));
|
||||
return s;
|
||||
|
||||
if (options)
|
||||
error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *char_list_new_special(enum string_list_type type, void *data)
|
||||
{
|
||||
unsigned len;
|
||||
struct string_list *s = string_list_new_special(type, data, &len);
|
||||
char *options = (len > 0) ? (char*)calloc(len, sizeof(char)): NULL;
|
||||
|
||||
if (options && s)
|
||||
string_list_join_concat(options, len, s, "|");
|
||||
|
||||
end:
|
||||
string_list_free(s);
|
||||
s = NULL;
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
#ifndef _STRING_LIST_SPECIAL_H
|
||||
#define _STRING_LIST_SPECIAL_H
|
||||
|
||||
#include <string/string_list.h>
|
||||
|
||||
enum string_list_type
|
||||
{
|
||||
STRING_LIST_NONE = 0,
|
||||
@ -35,6 +37,9 @@ enum string_list_type
|
||||
STRING_LIST_CORES_NAMES
|
||||
};
|
||||
|
||||
const char *string_list_special_new(enum string_list_type type, void *data);
|
||||
struct string_list *string_list_new_special(enum string_list_type type,
|
||||
void *data, unsigned *len);
|
||||
|
||||
const char *char_list_new_special(enum string_list_type type, void *data);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user