44 if (parm == NULL)
return NULL;
47 for (; *parm != NULL; parm++) {
48 const char *p = *parm;
50 if (strncmp(p, name, len) == 0) {
51 if (p[len] ==
'=')
return p + len + 1;
52 if (p[len] ==
'\0')
return p + len;
79 return p != NULL ? atoi(p) : def;
116 if (d->
type != type)
continue;
123 const char *err = newd->
Start(NULL);
139 const char *parms[32];
143 parm = strchr(buffer,
':');
150 if (np <
lengthof(parms) - 1) parms[np++] = parm;
151 while (*parm !=
'\0' && *parm !=
',') parm++;
152 }
while (*parm ==
',');
162 if (d->
type != type)
continue;
165 if (strcasecmp(buffer, d->
name) != 0)
continue;
170 const char *err = newd->
Start(parms);
173 usererror(
"Unable to load driver '%s'. The error was: %s", d->
name, err);
220 type(type), priority(priority), name(name), description(description)
227 const char *longname =
stredup(buf);
229 std::pair<Drivers::iterator, bool> P =
GetDrivers().insert(Drivers::value_type(longname,
this));
243 Drivers::iterator it =
GetDrivers().find(buf);
246 const char *longname = (*it).first;
const char * GetDriverParam(const char *const *parm, const char *name)
Get a string parameter the list of parameters.
char * _ini_videodriver
The video driver a stored in the configuration file.
virtual ~DriverFactoryBase()
Frees memory used for this->name.
Base of all video drivers.
static Drivers & GetDrivers()
Get the map with drivers.
static Driver ** GetActiveDriver(Driver::Type type)
Get the active driver for the given type.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
char * _ini_blitter
The blitter as stored in the configuration file.
Functions related to debugging.
bool GetDriverParamBool(const char *const *parm, const char *name)
Get a boolean parameter the list of parameters.
static const char * GetDriverTypeName(Driver::Type type)
Get the driver type name.
Base for all sound drivers.
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description)
Construct a new DriverFactory.
Dimension _cur_resolution
The current resolution.
int _num_resolutions
The number of resolutions.
static bool SelectDriverImpl(const char *name, Driver::Type type)
Find the requested driver and return its class.
#define lastof(x)
Get the last element of an fixed size array.
static char * GetDriversInfo(char *p, const char *last)
Build a human readable list of available drivers, grouped by type.
int priority
The priority of this factory.
virtual Driver * CreateInstance() const =0
Create an instance of this driver-class.
Functions related to low-level strings.
const char * description
The description of this driver.
char * _ini_sounddriver
The sound driver a stored in the configuration file.
virtual const char * Start(const char *const *parm)=0
Start this driver.
Driver::Type type
The type of driver.
Base for all music playback.
Definition of base types and functions in a cross-platform compatible way.
void CDECL usererror(const char *s,...)
Error handling for fatal user errors.
A number of safeguards to prevent using unsafe methods.
Base for all driver factories.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
#define lengthof(x)
Return the length of an fixed size array.
A driver for communicating with the user.
#define DEBUG(name, level,...)
Output a line of debugging information.
Dimension _resolutions[32]
List of resolutions.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
static void SelectDriver(const char *name, Driver::Type type)
Find the requested driver and return its class.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
bool _blitter_autodetected
Was the blitter autodetected or specified by the user?
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
int GetDriverParamInt(const char *const *parm, const char *name, int def)
Get an integer parameter the list of parameters.
bool _rightclick_emulate
Whether right clicking is emulated.
char * _ini_musicdriver
The music driver a stored in the configuration file.
const char * GetDescription() const
Get a nice description of the driver-class.
Dimensions (a width and height) of a rectangle in 2D.
const char * name
The name of the drivers of this factory.