Added patch 849608 from Jonathan Gray and a patch from Dominik Vogt
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1546
This commit is contained in:
parent
eda2ee4b18
commit
9785e03197
3 changed files with 54 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2002 The DOSBox Team
|
||||
* Copyright (C) 2002-2004 The DOSBox Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,6 +16,8 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: setup.h,v 1.14 2004-01-08 11:45:24 qbix79 Exp $ */
|
||||
|
||||
#ifndef _SETUP_H_
|
||||
#define _SETUP_H_
|
||||
|
||||
|
@ -180,7 +182,7 @@ public:
|
|||
void ShutDown();
|
||||
void StartUp();
|
||||
void PrintConfig(const char* configfilename);
|
||||
void ParseConfigFile(const char* configfilename);
|
||||
bool ParseConfigFile(const char* configfilename);
|
||||
void ParseEnv(char ** envp);
|
||||
|
||||
std::list<Section*> sectionlist;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2002-2003 The DOSBox Team
|
||||
* Copyright (C) 2002-2004 The DOSBox Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: sdlmain.cpp,v 1.54 2003-11-12 13:27:39 qbix79 Exp $ */
|
||||
/* $Id: sdlmain.cpp,v 1.55 2004-01-08 11:47:26 qbix79 Exp $ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_thread.h"
|
||||
|
||||
|
@ -56,6 +57,11 @@ extern char** environ;
|
|||
#include <windows.h>
|
||||
#define STDOUT_FILE TEXT("stdout.txt")
|
||||
#define STDERR_FILE TEXT("stderr.txt")
|
||||
#define DEFAULT_CONFIG_FILE "/dosbox.conf"
|
||||
#elif defined(MACOSX)
|
||||
#define DEFAULT_CONFIG_FILE "/Library/Preferences/DOSBox Preferences"
|
||||
#else /*linux freebsd*/
|
||||
#define DEFAULT_CONFIG_FILE "/.dosboxrc"
|
||||
#endif
|
||||
|
||||
enum SCREEN_TYPES {
|
||||
|
@ -759,8 +765,19 @@ int main(int argc, char* argv[]) {
|
|||
} else {
|
||||
config_file="dosbox.conf";
|
||||
}
|
||||
/* Parse the config file */
|
||||
control->ParseConfigFile(config_file.c_str());
|
||||
/* Parse the config file
|
||||
* try open config file in $HOME if can't open dosbox.conf or specified file
|
||||
*/
|
||||
if (control->ParseConfigFile(config_file.c_str()) == false) {
|
||||
if ((getenv("HOME") != NULL)) {
|
||||
config_file = (std::string)getenv("HOME") +
|
||||
(std::string)DEFAULT_CONFIG_FILE;
|
||||
if (control->ParseConfigFile(config_file.c_str()) == false) {
|
||||
LOG_MSG("CONFIG: Using default settings. Create a configfile to change them");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#if (ENVIRON_LINKED)
|
||||
control->ParseEnv(environ);
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2002-2003 The DOSBox Team
|
||||
* Copyright (C) 2002-2004 The DOSBox Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,6 +16,8 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: setup.cpp,v 1.18 2004-01-08 11:46:40 qbix79 Exp $ */
|
||||
|
||||
#include "dosbox.h"
|
||||
#include "cross.h"
|
||||
#include "setup.h"
|
||||
|
@ -226,36 +228,48 @@ Section* Config::GetSection(const char* _sectionname){
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void Config::ParseConfigFile(const char* configfilename){
|
||||
bool Config::ParseConfigFile(const char* configfilename){
|
||||
ifstream in(configfilename);
|
||||
if (!in) {
|
||||
LOG_MSG("CONFIG:Can't find config file %s, using default settings",configfilename);
|
||||
return;
|
||||
}
|
||||
char gegevens[150];
|
||||
if (!in) return false;
|
||||
LOG_MSG("CONFIG:Loading settings from config file %s", configfilename);
|
||||
char gegevens[1024];
|
||||
Section* currentsection = NULL;
|
||||
Section* testsec = NULL;
|
||||
while (in) {
|
||||
in.getline(gegevens,150);
|
||||
in.getline(gegevens,1024);
|
||||
char* temp;
|
||||
switch(gegevens[0]){
|
||||
char* s;
|
||||
int len;
|
||||
s = gegevens;
|
||||
|
||||
/* strip trailing whitespace */
|
||||
for (len = strlen(s); len > 0 && isspace(s[len - 1]); len--) {
|
||||
/* nothing */
|
||||
}
|
||||
s[len] = 0;
|
||||
|
||||
/* strip leading whitespace */
|
||||
while (isspace(s[0])) {
|
||||
s++;
|
||||
}
|
||||
switch(s[0]){
|
||||
case '%':
|
||||
case '\0':
|
||||
case '\n':
|
||||
case '#':
|
||||
case '#':
|
||||
case ' ':
|
||||
case '\n':
|
||||
continue;
|
||||
break;
|
||||
case '[':
|
||||
temp = strrchr(gegevens,']');
|
||||
temp = strrchr(s,']');
|
||||
*temp=0;
|
||||
testsec = GetSection(&gegevens[1]);
|
||||
testsec = GetSection(&s[1]);
|
||||
if(testsec != NULL ) currentsection = testsec;
|
||||
testsec = NULL;
|
||||
break;
|
||||
default:
|
||||
try{
|
||||
currentsection->HandleInputline(gegevens);
|
||||
currentsection->HandleInputline(s);
|
||||
}catch(const char* message){
|
||||
message=0;
|
||||
//EXIT with message
|
||||
|
@ -263,6 +277,7 @@ void Config::ParseConfigFile(const char* configfilename){
|
|||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Config::ParseEnv(char ** envp) {
|
||||
|
|
Loading…
Add table
Reference in a new issue