kmscon: add helpers to access kmscon_conf

We are about to introduce per-seat-configuration so we need some helper
macros that will later select the right configuration that we read from.

These helpers simply hook into the kmscon-config and return the correct
value.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-10-18 15:10:42 +02:00
parent 613abadb4b
commit c1536ad6b1
2 changed files with 24 additions and 8 deletions

View File

@ -32,6 +32,7 @@
#define KMSCON_MAIN_H
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "conf.h"
@ -132,4 +133,19 @@ extern struct kmscon_conf_t kmscon_conf;
int kmscon_load_config(int argc, char **argv);
void kmscon_free_config(void);
#define KMSCON_CONF_OFFSET(_name) \
offsetof(struct kmscon_conf_t, _name)
#define KMSCON_CONF(_name, _type) \
(*((_type*)(((char*)&kmscon_conf) + KMSCON_CONF_OFFSET(_name))))
#define KMSCON_CONF_BOOL(_name) \
KMSCON_CONF(_name, bool)
#define KMSCON_CONF_UINT(_name) \
KMSCON_CONF(_name, unsigned int)
#define KMSCON_CONF_STRING(_name) \
KMSCON_CONF(_name, char*)
#define KMSCON_CONF_GRAB(_name) \
KMSCON_CONF(_name, struct conf_grab*)
#define KMSCON_CONF_STRINGLIST(_name) \
KMSCON_CONF(_name, char**)
#endif /* KMSCON_MAIN_H */

View File

@ -113,11 +113,11 @@ static int app_seat_new(struct kmscon_app *app, struct app_seat **out,
bool found;
found = false;
if (kmscon_conf.all_seats) {
if (KMSCON_CONF_BOOL(all_seats)) {
found = true;
} else {
for (i = 0; kmscon_conf.seats[i]; ++i) {
if (!strcmp(kmscon_conf.seats[i], sname)) {
for (i = 0; KMSCON_CONF_STRINGLIST(seats)[i]; ++i) {
if (!strcmp(KMSCON_CONF_STRINGLIST(seats)[i], sname)) {
found = true;
break;
}
@ -202,7 +202,7 @@ static int app_seat_add_video(struct app_seat *seat,
unsigned int mode;
struct app_video *vid;
if (kmscon_conf.fbdev) {
if (KMSCON_CONF_BOOL(fbdev)) {
if (type != UTERM_MONITOR_FBDEV &&
type != UTERM_MONITOR_FBDEV_DRM) {
log_info("ignoring video device %s on seat %s as it is not an fbdev device",
@ -237,7 +237,7 @@ static int app_seat_add_video(struct app_seat *seat,
}
if (type == UTERM_MONITOR_DRM) {
if (kmscon_conf.dumb)
if (KMSCON_CONF_BOOL(dumb))
mode = UTERM_VIDEO_DUMB;
else
mode = UTERM_VIDEO_DRM;
@ -463,7 +463,7 @@ int main(int argc, char **argv)
goto err_out;
}
if (kmscon_conf.exit) {
if (KMSCON_CONF_BOOL(exit)) {
kmscon_free_config();
return 0;
}
@ -476,14 +476,14 @@ int main(int argc, char **argv)
if (ret)
goto err_unload;
if (kmscon_conf.switchvt) {
if (KMSCON_CONF_BOOL(switchvt)) {
log_debug("activating VTs during startup");
uterm_vt_master_activate_all(app.vtm);
}
ev_eloop_run(app.eloop, -1);
if (kmscon_conf.switchvt) {
if (KMSCON_CONF_BOOL(switchvt)) {
/* The VT subsystem needs to acknowledge the VT-leave so if it
* returns -EINPROGRESS we need to wait for the VT-leave SIGUSR2
* signal to arrive. Therefore, we use a separate eloop object