#include "cpuboard.h"
#include "luascript.h"
+#define cfgfile_warning write_log
+#define cfgfile_warning_obsolete write_log
+
+#if SIZEOF_TCHAR != 1
+/* FIXME: replace strcasecmp with _tcsicmp in source code instead */
+#undef strcasecmp
+#define strcasecmp _tcsicmp
+#endif
+
static int config_newfilesystem;
static struct strlist *temp_lines;
static struct strlist *error_lines;
{
cfg_dowrite (f, option, b ? _T("true") : _T("false"), 1, 0);
}
-void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, const TCHAR *optionext, bool b)
+static void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, const TCHAR *optionext, bool b)
{
cfg_dowrite (f, option, optionext, b ? _T("true") : _T("false"), 1, 0);
}
-void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, int b)
+static void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, int b)
{
cfgfile_dwrite_bool (f, option, b != 0);
}
{
cfg_dowrite (f, option, value, 0, 0);
}
-void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value)
+static void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value)
{
cfg_dowrite (f, option, optionext, value, 0, 0);
}
{
cfg_dowrite (f, option, value, 1, 0);
}
-void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value)
+static void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value)
{
cfg_dowrite (f, option, optionext, value, 1, 0);
}
cfg_dowrite (f, option, value, 1, 1);
}
-void cfgfile_write_ext (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *format,...)
+static void cfgfile_write_ext (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *format,...)
{
va_list parms;
TCHAR tmp[CONFIG_BLEN], tmp2[CONFIG_BLEN];
cfg_dowrite (f, option, tmp, 0, 0);
va_end (parms);
}
-void cfgfile_dwrite_ext (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *format,...)
+
+static void cfgfile_dwrite_ext (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *format,...)
{
va_list parms;
TCHAR tmp[CONFIG_BLEN], tmp2[CONFIG_BLEN];
for (i = 0; i < p->mountitems; i++) {
struct uaedev_config_data *uci = &p->mountconfig[i];
struct uaedev_config_info *ci = &uci->ci;
- TCHAR *str1, *str2, *str1b, *str2b;
+ TCHAR *str1, *str1b, *str2b;
+ const TCHAR *str2;
int bp = ci->bootpri;
str2 = _T("");
if (ptr) {
*ptr++ = 0;
str2 = ptr;
- ptr = _tcschr (str2, ',');
+ ptr = (TCHAR *) _tcschr (str2, ',');
if (ptr)
*ptr = 0;
}
_tcscat(tmp, _T(",CF"));
_tcscat(tmp3, _T(",CF"));
}
- TCHAR *extras = NULL;
+ const TCHAR *extras = NULL;
if (ct >= HD_CONTROLLER_TYPE_SCSI_FIRST && ct <= HD_CONTROLLER_TYPE_SCSI_LAST) {
if (ci->unit_feature_level == HD_LEVEL_SCSI_1){
extras = _T("SCSI1");
cfgfile_write_str (f, _T("slirp_redir"), tmp);
}
}
-#endif
+#endif /* WITH_SLIRP */
cfgfile_write_bool (f, _T("synchronize_clock"), p->tod_hack);
cfgfile_write (f, _T("maprom"), _T("0x%x"), p->maprom);
write_inputdevice_config (p, f);
}
-int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, bool numbercheck)
+static int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, bool numbercheck)
{
if (name != NULL && _tcscmp (option, name) != 0)
return 0;
if (strcasecmp (value, _T("yes")) == 0 || strcasecmp (value, _T("y")) == 0
- || strcasecmp (value, _T("true")) == 0 || strcasecmp (value, _T("t")) == 0)
+ || strcasecmp (value, _T("true")) == 0 || strcasecmp (value, _T("t")) == 0
+ || (numbercheck && strcasecmp (value, _T("1")) == 0))
*location = 1;
else if (strcasecmp (value, _T("no")) == 0 || strcasecmp (value, _T("n")) == 0
|| strcasecmp (value, _T("false")) == 0 || strcasecmp (value, _T("f")) == 0
|| (numbercheck && strcasecmp (value, _T("0")) == 0))
*location = 0;
else {
- write_log (_T("Option `%s' requires a value of either `yes' or `no' (was '%s').\n"), option, value);
+ cfgfile_warning(_T("Option '%s' requires a value of either 'true' or 'false' (was '%s').\n"), option, value);
return -1;
}
return 1;
}
-int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location)
+
+static int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location)
{
return cfgfile_yesno (option, value, name, location, true);
}
-int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, bool numbercheck)
+
+static int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, bool numbercheck)
{
int val;
int ret = cfgfile_yesno (option, value, name, &val, numbercheck);
*location = val != 0;
return 1;
}
+
int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location)
{
return cfgfile_yesno (option, value, name, location, true);
}
-int cfgfile_doubleval (const TCHAR *option, const TCHAR *value, const TCHAR *name, double *location)
+static int cfgfile_doubleval (const TCHAR *option, const TCHAR *value, const TCHAR *name, double *location)
{
- int base = 10;
TCHAR *endptr;
if (name != NULL && _tcscmp (option, name) != 0)
return 0;
return 1;
}
-int cfgfile_floatval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, float *location)
+static int cfgfile_floatval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, float *location)
{
- int base = 10;
TCHAR *endptr;
if (name == NULL)
return 0;
*location = (float)_tcstod (value, &endptr);
return 1;
}
-int cfgfile_floatval (const TCHAR *option, const TCHAR *value, const TCHAR *name, float *location)
+
+static int cfgfile_floatval (const TCHAR *option, const TCHAR *value, const TCHAR *name, float *location)
{
return cfgfile_floatval (option, value, name, NULL, location);
}
-int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, unsigned int *location, int scale)
+static int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, unsigned int *location, int scale)
{
int base = 10;
TCHAR *endptr;
*location = 1;
return 1;
}
- write_log (_T("Option '%s' requires a numeric argument but got '%s'\n"), nameext ? tmp : option, value);
+ cfgfile_warning(_T("Option '%s' requires a numeric argument but got '%s'\n"), nameext ? tmp : option, value);
return -1;
}
return 1;
}
-int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, unsigned int *location, int scale)
+static int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, unsigned int *location, int scale)
{
return cfgfile_intval (option, value, name, NULL, location, scale);
}
*location = (int)v;
return r;
}
-int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, int *location, int scale)
+static int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, int *location, int scale)
{
unsigned int v = 0;
int r = cfgfile_intval (option, value, name, nameext, &v, scale);
return r;
}
-int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, int *location, const TCHAR *table[], int more)
+static int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, int *location, const TCHAR *table[], int more)
{
int val;
TCHAR tmp[MAX_DPATH];
} else if (!strcasecmp (value, _T("no")) || !strcasecmp (value, _T("false"))) {
val = 0;
} else {
- write_log (_T("Unknown value ('%s') for option '%s'.\n"), value, nameext ? tmp : option);
+ cfgfile_warning(_T("Unknown value ('%s') for option '%s'.\n"), value, nameext ? tmp : option);
return -1;
}
}
return cfgfile_strval (option, value, name, NULL, location, table, more);
}
-int cfgfile_strboolval (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, const TCHAR *table[], int more)
+static int cfgfile_strboolval (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, const TCHAR *table[], int more)
{
int locationint;
if (!cfgfile_strval (option, value, name, &locationint, table, more))
location[maxsz - 1] = '\0';
return 1;
}
-int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, TCHAR *location, int maxsz)
+
+static int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, TCHAR *location, int maxsz)
{
if (nameext) {
TCHAR tmp[MAX_DPATH];
}
-int cfgfile_path (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz, struct multipath *mp)
+static int cfgfile_path (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz, struct multipath *mp)
{
if (!cfgfile_string (option, value, name, location, maxsz))
return 0;
xfree (s);
return 1;
}
-int cfgfile_path (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
+
+static int cfgfile_path (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
{
return cfgfile_path (option, value, name, location, maxsz, NULL);
}
-int cfgfile_multipath (const TCHAR *option, const TCHAR *value, const TCHAR *name, struct multipath *mp)
+static int cfgfile_multipath (const TCHAR *option, const TCHAR *value, const TCHAR *name, struct multipath *mp)
{
TCHAR tmploc[MAX_DPATH];
if (!cfgfile_string (option, value, name, tmploc, 256))
return 1;
}
-int cfgfile_rom (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
+static int cfgfile_rom (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
{
TCHAR id[MAX_DPATH];
if (!cfgfile_string (option, value, name, id, sizeof id / sizeof (TCHAR)))
TCHAR *next2 = _tcschr (next, ':');
if (next2)
*next2++ = 0;
- int tmpval = 0;
if (!_tcsicmp (next, _T("delay"))) {
p->cdslots[i].delayed = true;
next = next2;
|| (l = KBD_LANG_ES, strcasecmp (value, _T("es")) == 0))
p->keyboard_lang = l;
else
- write_log (_T("Unknown keyboard language\n"));
+ cfgfile_warning(_T("Unknown keyboard language\n"));
return 1;
}
else if (!_tcsnicmp (tmpp, _T("t="), 2))
_tcsncpy (label, equals, sizeof label / sizeof (TCHAR) - 1);
else if (equals) {
- if (_tcslen (cmd) + _tcslen (tmpp) + 2 < sizeof (cmd) / sizeof(TCHAR)) {
+ if (_tcslen (cmd) + _tcslen (tmpp) + 2 < sizeof (cmd) / sizeof (TCHAR)) {
_tcscat (cmd, tmpp);
_tcscat (cmd, _T("\n"));
}
}
#ifdef WITH_SLIRP
- if (cfgfile_string (option, value, _T("slirp_ports"), tmpbuf, sizeof (tmpbuf) / sizeof TCHAR)) {
+ if (cfgfile_string (option, value, _T("slirp_ports"), tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) {
TCHAR *tmpp2 = tmpbuf;
_tcscat (tmpbuf, _T(","));
for (;;) {
}
return 1;
}
- if (cfgfile_string (option, value, _T("slirp_redir"), tmpbuf, sizeof (tmpbuf) / sizeof TCHAR)) {
+ if (cfgfile_string (option, value, _T("slirp_redir"), tmpbuf, sizeof (tmpbuf) / sizeof(TCHAR))) {
TCHAR *tmpp2 = tmpbuf;
_tcscat (tmpbuf, _T(":"));
for (i = 0; i < MAX_SLIRP_REDIRS; i++) {
return 1;
invalid_fs:
- write_log (_T("Invalid filesystem/hardfile/cd specification.\n"));
+ cfgfile_warning(_T("Invalid filesystem/hardfile/cd specification.\n"));
return 1;
}
xfree (str);
return 1;
invalid_fs:
- write_log (_T("Invalid filesystem/hardfile specification.\n"));
+ cfgfile_warning(_T("Invalid filesystem/hardfile specification.\n"));
return 1;
}
{
int tmpval, dummyint, i;
bool tmpbool, dummybool;
- TCHAR *section = 0;
TCHAR tmpbuf[CONFIG_BLEN];
if (cfgfile_yesno (option, value, _T("cpu_cycle_exact"), &p->cpu_cycle_exact)
// cfgfile_parse_host may modify the option (convert to lowercase).
TCHAR* writable_option = my_strdup(option);
if (cfgfile_parse_host (p, writable_option, value)) {
- xfree(writable_option);
+ free(writable_option);
return 1;
}
- xfree(writable_option);
+ free(writable_option);
}
if (type > 0 && (type & (CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST)) != (CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST))
return 1;
line2 = strchr (line, '=');
if (! line2) {
TCHAR *s = au (line1);
- write_log (_T("CFGFILE: '%s', linea was incomplete with only %s\n"), filename, s);
+ cfgfile_warning(_T("CFGFILE: '%s', linea was incomplete with only %s\n"), filename, s);
xfree (s);
return 0;
}
return 0;
line2 = _tcschr (line, '=');
if (! line2) {
- write_log (_T("CFGFILE: line was incomplete with only %s\n"), line1);
+ cfgfile_warning(_T("CFGFILE: line was incomplete with only %s\n"), line1);
return 0;
}
*line2++ = '\0';
int i = 0;
while (obsolete[i]) {
if (!strcasecmp (s, obsolete[i])) {
- write_log (_T("obsolete config entry '%s'\n"), s);
+ cfgfile_warning_obsolete(_T("obsolete config entry '%s'\n"), s);
return 1;
}
i++;
if (_tcslen (s) > 2 && !_tcsncmp (s, _T("w."), 2))
return 1;
if (_tcslen (s) >= 10 && !_tcsncmp (s, _T("gfx_opengl"), 10)) {
- write_log (_T("obsolete config entry '%s\n"), s);
+ cfgfile_warning_obsolete(_T("obsolete config entry '%s\n"), s);
return 1;
}
if (_tcslen (s) >= 6 && !_tcsncmp (s, _T("gfx_3d"), 6)) {
- write_log (_T("obsolete config entry '%s\n"), s);
+ cfgfile_warning_obsolete(_T("obsolete config entry '%s\n"), s);
return 1;
}
return 0;
p->all_lines = u;
if (!ret) {
u->unknown = 1;
- write_log (_T("unknown config entry: '%s=%s'\n"), u->option, u->value);
+ cfgfile_warning(_T("unknown config entry: '%s=%s'\n"), u->option, u->value);
}
}
}
static int getconfigstoreline (const TCHAR *option, TCHAR *value)
{
TCHAR tmp[CONFIG_BLEN * 2], tmp2[CONFIG_BLEN * 2];
- int idx = 0;
if (!configstore)
return 0;
write_log (_T("load config '%s':%d\n"), filename, type ? *type : -1);
v = cfgfile_load_2 (p, filename, 1, type);
if (!v) {
- write_log (_T("load failed\n"));
+ cfgfile_warning(_T("cfgfile_load_2 failed\n"));
goto end;
}
if (userconfig)
if (!ignorelink) {
if (p->config_hardware_path[0]) {
fetch_configurationpath (tmp, sizeof (tmp) / sizeof (TCHAR));
- _tcsncat (tmp, p->config_hardware_path, sizeof (tmp) / sizeof (TCHAR));
+ _tcsncat (tmp, p->config_hardware_path, sizeof (tmp) / sizeof (TCHAR) - _tcslen(tmp) - 1);
type2 = CONFIG_TYPE_HARDWARE;
cfgfile_load (p, tmp, &type2, 1, 0);
}
if (p->config_host_path[0]) {
fetch_configurationpath (tmp, sizeof (tmp) / sizeof (TCHAR));
- _tcsncat (tmp, p->config_host_path, sizeof (tmp) / sizeof (TCHAR));
+ _tcsncat (tmp, p->config_host_path, sizeof (tmp) / sizeof (TCHAR) - _tcslen(tmp) - 1);
type2 = CONFIG_TYPE_HOST;
cfgfile_load (p, tmp, &type2, 1, 0);
}
argh:
free (x0);
- write_log (_T("Bad hardfile parameter specified - type \"uae -h\" for help.\n"));
+ cfgfile_warning(_T("Bad hardfile parameter specified\n"));
return;
}
static void parse_cpu_specs (struct uae_prefs *p, const TCHAR *spec)
{
if (*spec < '0' || *spec > '4') {
- write_log (_T("CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n"));
+ cfgfile_warning(_T("CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n"));
return;
}
switch (*spec) {
case 'a':
if (p->cpu_model < 68020)
- write_log (_T("In 68000/68010 emulation, the address space is always 24 bit.\n"));
+ cfgfile_warning(_T("In 68000/68010 emulation, the address space is always 24 bit.\n"));
else if (p->cpu_model >= 68040)
- write_log (_T("In 68040/060 emulation, the address space is always 32 bit.\n"));
+ cfgfile_warning(_T("In 68040/060 emulation, the address space is always 32 bit.\n"));
else
p->address_space_24 = 1;
break;
case 'c':
if (p->cpu_model != 68000)
- write_log (_T("The more compatible CPU emulation is only available for 68000\n")
+ cfgfile_warning(_T("The more compatible CPU emulation is only available for 68000\n")
_T("emulation, not for 68010 upwards.\n"));
else
p->cpu_compatible = 1;
break;
default:
- write_log (_T("Bad CPU parameter specified - type \"uae -h\" for help.\n"));
+ cfgfile_warning(_T("Bad CPU parameter specified.\n"));
break;
}
spec++;
TCHAR *argc[UAELIB_MAX_PARSE];
int argv, i;
uae_u32 err;
- TCHAR zero = 0;
static TCHAR *configsearch;
*out = 0;