Remove old DMX config system.

This commit is contained in:
David Reveman 2008-09-12 16:11:55 +02:00
parent 0bdf55838d
commit e2cb7ac2a1
57 changed files with 151 additions and 4988 deletions

View file

@ -1601,9 +1601,6 @@ dnl Linux sources in DMX require <linux/keyboard.h>
if test "x$GLX" = xyes; then
PKG_CHECK_MODULES([GL], [glproto])
fi
PKG_CHECK_MODULES([XDMXCONFIG_DEP], [xaw7 xmu xt xpm x11])
AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
AC_SUBST(XDMXCONFIG_DEP_LIBS)
PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [dmx xext x11])
AC_SUBST(DMXEXAMPLES_DEP_LIBS)
PKG_CHECK_MODULES([DMXXMUEXAMPLES_DEP], [dmx xmu xext x11])
@ -1869,7 +1866,6 @@ hw/xfree86/xf8_16bpp/Makefile
hw/xfree86/utils/Makefile
hw/xfree86/utils/cvt/Makefile
hw/xfree86/utils/gtf/Makefile
hw/dmx/config/Makefile
hw/dmx/doc/Makefile
hw/dmx/examples/Makefile
hw/dmx/input/Makefile

View file

@ -1,6 +1,6 @@
DIST_SUBDIRS = input config glxProxy examples doc
DIST_SUBDIRS = input glxProxy examples doc
SUBDIRS = input config examples
SUBDIRS = input examples
bin_PROGRAMS = Xdmx
if XINERAMA
@ -121,7 +121,6 @@ XDMX_LIBS = \
$(top_srcdir)/xfixes/libxfixes.la \
$(top_srcdir)/damageext/libdamageext.la \
input/libdmxinput.a \
config/libdmxconfig.a \
$(XSERVER_LIBS)
Xdmx_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)

View file

@ -1,159 +0,0 @@
/*
* Copyright 1987, 1998 The Open Group
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of The Open Group shall not be
* used in advertising or otherwise to promote the sale, use or other dealings
* in this Software without prior written authorization from The Open Group.
*/
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
* This file was originally taken from xc/lib/Xaw/Template.c
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include "CanvasP.h"
static void CanvasInitialize(Widget request, Widget w,
ArgList args, Cardinal *num_args)
{
}
static void CanvasExpose(Widget w, XEvent *event, Region region)
{
CanvasExposeDataRec data;
data.w = w;
data.event = event;
data.region = region;
if (!XtIsRealized(w)) return;
XtCallCallbacks(w, XtNcanvasExposeCallback, (XtPointer)&data);
}
static void CanvasResize(Widget w)
{
if (!XtIsRealized(w)) return;
XtCallCallbacks(w, XtNcanvasResizeCallback, (XtPointer)w);
}
static void CanvasAction(Widget w, XEvent *event,
String *params, Cardinal *num_params)
{
XtCallCallbacks(w, XtNcallback, (XtPointer)event);
}
#define offset(field) XtOffsetOf(CanvasRec, canvas.field)
static XtResource resources[] = {
{ XtNcallback, XtCCallback, XtRCallback,
sizeof(XtCallbackList), offset(input_callback), XtRCallback, NULL },
{ XtNcanvasExposeCallback, XtCcanvasExposeCallback, XtRCallback,
sizeof(XtCallbackList), offset(expose_callback), XtRCallback, NULL },
{ XtNcanvasResizeCallback, XtCcanvasResizeCallback, XtRCallback,
sizeof(XtCallbackList), offset(resize_callback), XtRCallback, NULL },
};
#undef offset
static XtActionsRec actions[] =
{
{"canvas", CanvasAction},
};
static char translations[] =
"<Key>: canvas()\n\
<Motion>: canvas()\n\
<BtnDown>: canvas()\n\
<BtnUp>: canvas()\n\
"
;
#define Superclass (&widgetClassRec)
CanvasClassRec canvasClassRec = {
/* core */
{
(WidgetClass)Superclass, /* superclass */
"Canvas", /* class_name */
sizeof(CanvasRec), /* widget_size */
NULL, /* class_initialize */
NULL, /* class_part_initialize */
False, /* class_inited */
CanvasInitialize, /* initialize */
NULL, /* initialize_hook */
XtInheritRealize, /* realize */
actions, /* actions */
XtNumber(actions), /* num_actions */
resources, /* resources */
XtNumber(resources), /* num_resources */
NULLQUARK, /* xrm_class */
True, /* compress_motion */
True, /* compress_exposure */
True, /* compress_enterleave */
False, /* visible_interest */
NULL, /* destroy */
CanvasResize, /* resize */
CanvasExpose, /* expose */
NULL, /* set_values */
NULL, /* set_values_hook */
XtInheritSetValuesAlmost, /* set_values_almost */
NULL, /* get_values_hook */
NULL, /* accept_focus */
XtVersion, /* version */
NULL, /* callback_private */
translations, /* tm_table */
XtInheritQueryGeometry, /* query_geometry */
XtInheritDisplayAccelerator, /* display_accelerator */
NULL, /* extension */
},
/* canvas */
{
NULL, /* extension */
}
};
WidgetClass canvasWidgetClass = (WidgetClass)&canvasClassRec;

View file

@ -1,55 +0,0 @@
/*
Copyright 1987, 1998 The Open Group
Copyright 2002 Red Hat Inc., Durham, North Carolina.
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
* This file was originally taken from xc/lib/Xaw/Template.h
*/
#ifndef _Canvas_h
#define _Canvas_h
#include <X11/Intrinsic.h>
#define XtNcanvasExposeCallback "canvasExposeCallback"
#define XtCcanvasExposeCallback "CanvasExposeCallback"
#define XtNcanvasResizeCallback "canvasResizeCallback"
#define XtCcanvasResizeCallback "CanvasResizeCallback"
typedef struct _CanvasClassRec *CanvasWidgetClass;
typedef struct _CanvasRec *CanvasWidget;
extern WidgetClass canvasWidgetClass;
typedef struct _CanvasExposeDataRec {
Widget w;
XEvent *event;
Region region;
} CanvasExposeDataRec, *CanvasExposeDataPtr;
#endif /* _Canvas_h */

View file

@ -1,65 +0,0 @@
/*
Copyright 1987, 1998 The Open Group
Copyright 2002 Red Hat Inc., Durham, North Carolina.
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
* This file was originally taken from xc/lib/Xaw/TemplateP.h
*/
#ifndef _CanvasP_h
#define _CanvasP_h
#include "Canvas.h"
/* include superclass private header file */
#include <X11/CoreP.h>
typedef struct {
XtPointer extension;
} CanvasClassPart;
typedef struct _CanvasClassRec {
CoreClassPart core_class;
CanvasClassPart canvas_class;
} CanvasClassRec;
extern CanvasClassRec canvasClassRec;
typedef struct {
XtCallbackList input_callback;
XtCallbackList expose_callback;
XtCallbackList resize_callback;
} CanvasPart;
typedef struct _CanvasRec {
CorePart core;
CanvasPart canvas;
} CanvasRec;
#endif /* _CanvasP_h */

View file

@ -1,89 +0,0 @@
noinst_LIBRARIES = libdmxconfig.a
LIBSRCS = parser.y \
scanner.l \
dmxparse.c \
dmxparse.h \
dmxprint.c \
dmxprint.h \
dmxcompat.c \
dmxcompat.h \
dmxconfig.c \
dmxconfig.h
parser.h: parser.c
scanner.c: scanner.l parser.h
BUILT_SOURCES = parser.c parser.h scanner.c
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
libdmxconfig_a_SOURCES = $(LIBSRCS)
if GLX
GLX_DEFS = @GL_CFLAGS@
GLX_INCS = -I@MESA_SOURCE@/include
endif
AM_YFLAGS = -d
AM_CFLAGS = \
$(DIX_CFLAGS) \
-I$(top_srcdir)/hw/dmx \
$(GLX_INCS) \
-DHAVE_DMX_CONFIG_H \
-DDMX_LOG_STANDALONE \
$(GLX_DEFS) \
@DMXMODULES_CFLAGS@
bin_PROGRAMS = xdmxconfig vdltodmx dmxtodmx
xdmxconfig_DEPENDENCIES = libdmxconfig.a
xdmxconfig_SOURCES = \
xdmxconfig.c \
$(top_srcdir)/hw/dmx/dmxlog.c \
Canvas.c \
Canvas.h \
CanvasP.h
xdmxconfig_LDADD = -L. -ldmxconfig @XDMXCONFIG_DEP_LIBS@
xdmxconfig_CFLAGS = $(AM_CFLAGS) @XDMXCONFIG_DEP_CFLAGS@
vdltodmx_DEPENDENCIES = libdmxconfig.a
vdltodmx_SOURCES = vdltodmx.c
vdltodmx_LDADD = -L. -ldmxconfig
dmxtodmx_DEPENDENCIES = libdmxconfig.a
dmxtodmx_SOURCES = dmxtodmx.c
dmxtodmx_LDADD = -L. -ldmxconfig
appmandir = $(APP_MAN_DIR)
appman_PRE = xdmxconfig.man vdltodmx.man dmxtodmx.man
appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@)
CLEANFILES = $(appman_DATA)
SUFFIXES = .$(APP_MAN_SUFFIX) .man
# Strings to replace in man pages
XORGRELSTRING = @PACKAGE_STRING@
XORGMANNAME = X Version 11
MAN_SUBSTS = -e 's|__vendorversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|'
.man.$(APP_MAN_SUFFIX):
sed $(MAN_SUBSTS) < $< > $@
EXTRA_DIST = \
$(appman_PRE) \
test-a.in test-a.out \
test-b.in test-b.out \
test-c.in test-c.out \
test-d.in test-d.out \
test-e.in test-e.out \
test-f.in test-f.out \
test-g.in test-g.out \
test-h.in test-h.out \
test-i.in test-i.out \
test-j.in test-j.out \
test-k.in test-k.out \
test-l.in test-l.out

View file

@ -1,7 +0,0 @@
Fri May 31 13:20:17 2002
1) Sanitize values from input boxes.
2) Add canvas colors to cavas widget resources or to command-line options.
3) Add ability to edit option line(s) and wall.

View file

@ -1,236 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*/
/** \file
* This file provides some compatibility support for reading VDL files
* that are used by xmovie
* (http://www.llnl.gov/icc/sdd/img/xmovie/xmovie.shtml).
*
* This file is not used by the DMX server.
*/
#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include "dmxconfig.h"
#include "dmxparse.h"
#include "dmxcompat.h"
#include "parser.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
static int dmxVDLReadLine(FILE *str, char *buf, int len)
{
if (fgets(buf, len, str)) return strlen(buf);
return 0;
}
static int dmxVDLCount(const char *buf)
{
return strtol(buf, NULL, 10);
}
static void dmxVDLVirtualEntry(const char *buf,
char *name, int *len,
int *x, int *y)
{
char *end;
const char *s;
char *d;
int start;
*x = strtol(buf, &end, 10);
*y = strtol(end, &end, 10);
for (s = end, d = name, start = 1; *s && *s != '['; ++s) {
if (start && isspace(*s)) continue;
*d++ = *s;
start = 0;
}
*d = '\0';
while (d > name && isspace(d[-1])) *--d = '\0'; /* remove trailing space */
*len = strlen(name);
}
static void dmxVDLDisplayEntry(const char *buf,
char *name, int *len,
int *x, int *y,
int *xoff, int *yoff,
int *xorig, int *yorig)
{
const char *pt;
char *end;
pt = strchr(buf, ' ');
strncpy(name, buf, pt-buf);
name[pt-buf] = '\0';
*len = strlen(name);
*x = strtol(pt, &end, 10);
*y = strtol(end, &end, 10);
*xorig = strtol(end, &end, 10);
*yorig = strtol(end, &end, 10);
*xoff = strtol(end, &end, 10);
*yoff = strtol(end, NULL, 10);
}
/** Read from the VDL format \a filename and return a newly allocated \a
* DMXConfigEntryPtr */
DMXConfigEntryPtr dmxVDLRead(const char *filename)
{
FILE *str;
char buf[2048]; /* RATS: Use ok */
char *pt;
int lineno = 0;
DMXConfigEntryPtr entry = NULL;
DMXConfigVirtualPtr virtual = NULL;
DMXConfigSubPtr sub = NULL;
DMXConfigDisplayPtr display = NULL;
DMXConfigFullDimPtr fdim = NULL;
int vcount = 0;
int dcount = 0;
int icount = 0;
int x, y, xoff, yoff, xorig, yorig;
char name[2048]; /* RATS: Use ok */
const char *tmp;
int len;
enum {
simulateFlag,
virtualCount,
virtualEntry,
displayCount,
displayEntry,
ignoreCount,
ignoreEntry
} state = simulateFlag;
if (!filename) str = stdin;
else str = fopen(filename, "r");
if (!str) return NULL;
while (dmxVDLReadLine(str, buf, sizeof(buf))) {
DMXConfigCommentPtr comment = NULL;
++lineno;
for (pt = buf; *pt; pt++)
if (*pt == '\r' || *pt == '\n') {
*pt = '\0';
break;
}
if (buf[0] == '#') {
tmp = dmxConfigCopyString(buf + 1, strlen(buf + 1));
comment = dmxConfigCreateComment(T_COMMENT, lineno, tmp);
entry = dmxConfigAddEntry(entry, dmxConfigComment, comment, NULL);
continue;
}
switch (state) {
case simulateFlag:
state = virtualCount;
break;
case virtualCount:
vcount = dmxVDLCount(buf);
state = virtualEntry;
break;
case virtualEntry:
len = sizeof(name);
dmxVDLVirtualEntry(buf, name, &len, &x, &y);
tmp = dmxConfigCopyString(name, len);
virtual = dmxConfigCreateVirtual(NULL,
dmxConfigCreateString(T_STRING,
lineno,
NULL,
tmp),
dmxConfigCreatePair(T_DIMENSION,
lineno,
NULL,
x, y, 0, 0),
NULL, NULL, NULL);
state = displayCount;
break;
case displayCount:
dcount = dmxVDLCount(buf);
state = displayEntry;
break;
case displayEntry:
dmxVDLDisplayEntry(buf, name, &len, &x, &y, &xoff, &yoff,
&xorig, &yorig);
tmp = dmxConfigCopyString(name, len);
fdim = dmxConfigCreateFullDim(
dmxConfigCreatePartDim(
dmxConfigCreatePair(T_DIMENSION,
lineno,
NULL,
x, y, 0, 0),
dmxConfigCreatePair(T_OFFSET,
lineno,
NULL,
xoff, yoff,
xoff, yoff)),
NULL);
display = dmxConfigCreateDisplay(NULL,
dmxConfigCreateString(T_STRING,
lineno,
NULL,
tmp),
fdim,
dmxConfigCreatePair(T_ORIGIN,
lineno,
NULL,
xorig, yorig,
0, 0),
NULL);
sub = dmxConfigAddSub(sub, dmxConfigSubDisplay(display));
if (!--dcount) {
state = ignoreCount;
virtual->subentry = sub;
entry = dmxConfigAddEntry(entry,
dmxConfigVirtual,
NULL,
virtual);
virtual = NULL;
sub = NULL;
}
break;
case ignoreCount:
icount = dmxVDLCount(buf);
state = ignoreEntry;
break;
case ignoreEntry:
if (!--icount) state = virtualEntry;
break;
}
}
return entry;
}

View file

@ -1,44 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
/** \file
* Interface to VDL compatibility support. \see dmxcompat.c
*
* This file is not used by the DMX server.
*/
#ifndef _DMXCOMPAT_H_
#define _DMXCOMPAT_H_
extern DMXConfigEntryPtr dmxVDLRead(const char *filename);
#endif

View file

@ -1,552 +0,0 @@
/*
* Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
/** \file
* Provides interface for reading DMX configuration files and for
* combining that information with command-line configuration parameters. */
#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include "dmx.h"
#include "dmxinput.h"
#include "dmxconfig.h"
#include "dmxparse.h"
#include "dmxlog.h"
#include "dmxcb.h"
#include "dmxstat.h"
#include "parser.h"
extern int yyparse(void);
extern FILE *yyin;
static char *dmxXkbRules;
static char *dmxXkbModel;
static char *dmxXkbLayout;
static char *dmxXkbVariant;
static char *dmxXkbOptions;
/** Stores lists of configuration information. */
typedef struct DMXConfigListStruct {
const char *name;
DevUnion value[8];
struct DMXConfigListStruct *next;
} DMXConfigList, *DMXConfigListPtr;
/** This stucture stores the parsed configuration information. */
typedef struct DMXConfigCmdStruct {
const char *filename;
const char *config;
DMXConfigList *displays;
DMXConfigList *inputs;
DMXConfigList *xinputs;
} DMXConfigCmd, *DMXConfigCmdPtr;
DMXConfigEntryPtr dmxConfigEntry;
static DMXConfigCmd dmxConfigCmd;
static int dmxDisplaysFromCommandLine = 0;
static int dmxNumDetached = 4;
/** Make a note that \a display is the name of an X11 display that
* should be initialized as a backend (output) display. Called from
* #ddxProcessArgument. */
void dmxConfigStoreDisplay(const char *name,
const char *display,
const char *authType,
int authTypeLen,
const char *authData,
int authDataLen,
int virtualFb)
{
DMXConfigListPtr entry = malloc(sizeof(*entry));
entry->name = strdup (name);
entry->value[0].ptr = strdup (display);
entry->value[1].ptr = dmxMemDup (authType, authTypeLen);
entry->value[2].val = authTypeLen;
entry->value[3].ptr = dmxMemDup (authData, authDataLen);
entry->value[4].val = authDataLen;
entry->value[5].val = virtualFb;
entry->next = NULL;
if (!dmxConfigCmd.displays) dmxConfigCmd.displays = entry;
else {
DMXConfigList *pt;
for (pt = dmxConfigCmd.displays; pt->next; pt = pt->next);
if (!pt)
dmxLog(dmxFatal, "dmxConfigStoreDisplay: end of list non-NULL\n");
pt->next = entry;
}
++dmxDisplaysFromCommandLine;
}
void dmxConfigStoreNumDetached(const char *num)
{
int n = strtol (num, NULL, 0);
if (n >= 0)
dmxNumDetached = n;
}
/** Make a note that \a input is the name of an X11 display that should
* be used for input (either a backend or a console input device). */
void dmxConfigStoreInput(const char *input)
{
DMXConfigListPtr entry = malloc(sizeof(*entry));
entry->name = strdup(input);
entry->next = NULL;
if (!dmxConfigCmd.inputs) dmxConfigCmd.inputs = entry;
else {
DMXConfigList *pt;
for (pt = dmxConfigCmd.inputs; pt->next; pt = pt->next);
if (!pt)
dmxLog(dmxFatal, "dmxConfigStoreInput: end of list non-NULL\n");
pt->next = entry;
}
}
/** Make a note that \a input is the name of an X11 display that should
* be used for input from XInput extension devices. */
void dmxConfigStoreXInput(const char *input)
{
DMXConfigListPtr entry = malloc(sizeof(*entry));
entry->name = strdup(input);
entry->next = NULL;
if (!dmxConfigCmd.xinputs) dmxConfigCmd.xinputs = entry;
else {
DMXConfigList *pt;
for (pt = dmxConfigCmd.xinputs; pt->next; pt = pt->next);
if (!pt)
dmxLog(dmxFatal, "dmxConfigStoreXInput: end of list non-NULL\n");
pt->next = entry;
}
}
/** Make a note that \a file is the configuration file. */
void dmxConfigStoreFile(const char *file)
{
if (dmxConfigCmd.filename)
dmxLog(dmxFatal, "Only one -configfile allowed\n");
dmxConfigCmd.filename = strdup(file);
}
/** Make a note that \a config should be used as the configuration for
* current instantiation of the DMX server. */
void dmxConfigStoreConfig(const char *config)
{
if (dmxConfigCmd.config) dmxLog(dmxFatal, "Only one -config allowed\n");
dmxConfigCmd.config = strdup(config);
}
static int dmxConfigReadFile(const char *filename, int debug)
{
FILE *str;
if (!(str = fopen(filename, "r"))) return -1;
dmxLog(dmxInfo, "Reading configuration file \"%s\"\n", filename);
yyin = str;
yydebug = debug;
yyparse();
fclose(str);
return 0;
}
static const char *dmxConfigMatch(const char *target, DMXConfigEntryPtr entry)
{
DMXConfigVirtualPtr v = entry->virtual;
const char *name = NULL;
if (v && v->name) name = v->name;
if (v && !dmxConfigCmd.config) return v->name ? v->name : "<noname>";
if (!name) return NULL;
if (!strcmp(name, target)) return name;
return NULL;
}
static DMXScreenInfo *dmxConfigAddDisplay(const char *name,
const char *display,
const char *authType,
int authTypeLen,
const char *authData,
int authDataLen,
int virtualFb)
{
DMXScreenInfo *dmxScreen;
if (!(dmxScreens = realloc(dmxScreens,
(dmxNumScreens+1) * sizeof(*dmxScreens))))
dmxLog(dmxFatal,
"dmxConfigAddDisplay: realloc failed for screen %d (%s)\n",
dmxNumScreens, name);
dmxScreen = &dmxScreens[dmxNumScreens];
memset(dmxScreen, 0, sizeof(*dmxScreen));
dmxScreen->name = strdup (name);
dmxScreen->display = strdup (display);
dmxScreen->index = dmxNumScreens;
dmxScreen->scrnWidth = 0;
dmxScreen->scrnHeight = 0;
dmxScreen->rootX = 0;
dmxScreen->rootY = 0;
dmxScreen->stat = dmxStatAlloc();
dmxScreen->authType = dmxMemDup (authType, authTypeLen);
dmxScreen->authTypeLen = authTypeLen;
dmxScreen->authData = dmxMemDup (authData, authDataLen);
dmxScreen->authDataLen = authDataLen;
dmxScreen->virtualFb = virtualFb;
++dmxNumScreens;
return dmxScreen;
}
DMXInputInfo *dmxConfigAddInput(const char *name, int core)
{
DMXInputInfo *dmxInput;
if (!(dmxInputs = realloc(dmxInputs,
(dmxNumInputs+1) * sizeof(*dmxInputs))))
dmxLog(dmxFatal,
"dmxConfigAddInput: realloc failed for input %d (%s)\n",
dmxNumInputs, name);
dmxInput = &dmxInputs[dmxNumInputs];
memset(dmxInput, 0, sizeof(*dmxInput));
dmxInput->name = name;
dmxInput->inputIdx = dmxNumInputs;
dmxInput->scrnIdx = -1;
dmxInput->core = core;
++dmxNumInputs;
return dmxInput;
}
static void dmxConfigCopyFromDisplay(DMXConfigDisplayPtr d)
{
DMXScreenInfo *dmxScreen;
dmxScreen = dmxConfigAddDisplay(d->name, d->name,
NULL, 0, NULL, 0, 0);
dmxScreen->where = PosAbsolute;
dmxScreen->whereX = d->rootXOrigin;
dmxScreen->whereY = d->rootYOrigin;
}
static void dmxConfigCopyFromWall(DMXConfigWallPtr w)
{
DMXConfigStringPtr pt;
DMXScreenInfo *dmxScreen;
int edge = dmxNumScreens;
int last = dmxNumScreens;
if (!w->xwall && !w->ywall) { /* Try to make it square */
int count;
for (pt = w->nameList, count = 0; pt; pt = pt->next) ++count;
w->xwall = sqrt(count) + .5;
}
for (pt = w->nameList; pt; pt = pt->next) {
dmxScreen = dmxConfigAddDisplay(pt->string, pt->string,
NULL, 0, NULL, 0, 0);
if (pt == w->nameList) { /* Upper left */
dmxScreen->where = PosAbsolute;
dmxScreen->whereX = 0;
dmxScreen->whereY = 0;
} else if (w->xwall) { /* Tile left to right, then top to bottom */
if (!((dmxNumScreens-1) % w->xwall)) {
dmxScreen->where = PosBelow;
dmxScreen->whereRefScreen = edge;
edge = dmxNumScreens-1;
} else {
dmxScreen->where = PosRightOf;
dmxScreen->whereRefScreen = last;
}
} else { /* Tile top to bottom, then left to right */
if (!((dmxNumScreens-1) % w->ywall)) {
dmxScreen->where = PosRightOf;
dmxScreen->whereRefScreen = edge;
edge = dmxNumScreens-1;
} else {
dmxScreen->where = PosBelow;
dmxScreen->whereRefScreen = last;
}
}
last = dmxNumScreens-1;
if (dmxScreen->where == PosAbsolute)
dmxLog(dmxInfo, "Added %s at %d %d\n",
pt->string, dmxScreen->whereX, dmxScreen->whereY);
else
dmxLog(dmxInfo, "Added %s %s %s\n",
pt->string,
dmxScreen->where == PosBelow ? "below" : "right of",
dmxScreens[dmxScreen->whereRefScreen].name);
}
}
static void dmxConfigCopyFromOption(DMXConfigOptionPtr o)
{
DMXConfigStringPtr pt;
int argc = 0;
char **argv = NULL;
if (serverGeneration != 1) return; /* FIXME: only do once, for now */
if (!o || !o->string) return;
for (pt = o->option; pt; pt = pt->next) {
if (pt->string) {
++argc;
argv = realloc(argv, (argc+1) * sizeof(*argv));
argv[argc] = (char *)pt->string;
}
}
argv[0] = NULL;
ProcessCommandLine(argc+1, argv);
free(argv);
}
static void dmxConfigCopyFromParam(DMXConfigParamPtr p)
{
const char **argv;
int argc;
if ((argv = dmxConfigLookupParam(p, "xkbrules", &argc)) && argc == 2) {
dmxConfigSetXkbRules(argv[1]);
} else if ((argv = dmxConfigLookupParam(p, "xkbmodel", &argc))
&& argc == 2) {
dmxConfigSetXkbModel(argv[1]);
} else if ((argv = dmxConfigLookupParam(p, "xkblayout", &argc))
&& argc == 2) {
dmxConfigSetXkbLayout(argv[1]);
} else if ((argv = dmxConfigLookupParam(p, "xkbvariant", &argc))
&& argc == 2) {
dmxConfigSetXkbVariant(argv[1]);
} else if ((argv = dmxConfigLookupParam(p, "xkboptions", &argc))
&& argc == 2) {
dmxConfigSetXkbOptions(argv[1]);
}
}
static void dmxConfigCopyData(DMXConfigVirtualPtr v)
{
DMXConfigSubPtr sub;
if (v->dim) dmxSetWidthHeight(v->dim->x, v->dim->y);
else dmxSetWidthHeight(0, 0);
for (sub = v->subentry; sub; sub = sub->next) {
switch (sub->type) {
case dmxConfigDisplay: dmxConfigCopyFromDisplay(sub->display); break;
case dmxConfigWall: dmxConfigCopyFromWall(sub->wall); break;
case dmxConfigOption: dmxConfigCopyFromOption(sub->option); break;
case dmxConfigParam: dmxConfigCopyFromParam(sub->param); break;
default:
dmxLog(dmxFatal,
"dmxConfigCopyData: not a display, wall, or value\n");
}
}
}
static void dmxConfigFromCommandLine(void)
{
DMXConfigListPtr pt;
int nDetached;
dmxLog(dmxInfo, "Using configuration from command line\n");
for (pt = dmxConfigCmd.displays; pt; pt = pt->next) {
DMXScreenInfo *dmxScreen = dmxConfigAddDisplay(pt->name,
pt->value[0].ptr,
pt->value[1].ptr,
pt->value[2].val,
pt->value[3].ptr,
pt->value[4].val,
pt->value[5].val);
if (dmxNumScreens == 1) {
dmxScreen->where = PosAbsolute;
dmxScreen->whereX = 0;
dmxScreen->whereY = 0;
dmxLog(dmxInfo, "Added %s at %d %d\n",
dmxScreen->name, dmxScreen->whereX, dmxScreen->whereY);
} else {
dmxScreen->where = PosRightOf;
dmxScreen->whereRefScreen = dmxNumScreens - 2;
if (dmxScreen->whereRefScreen < 0) dmxScreen->whereRefScreen = 0;
dmxLog(dmxInfo, "Added %s %s %s\n",
dmxScreen->name,
dmxScreen->where == PosBelow ? "below" : "right of",
dmxScreens[dmxScreen->whereRefScreen].name);
}
}
nDetached = dmxNumDetached;
if (dmxNumScreens + nDetached > MAXSCREENS)
nDetached = MAXSCREENS - dmxNumScreens;
if (nDetached > 0)
{
dmxLog (dmxInfo, "Adding %d detached displays\n", nDetached);
while (nDetached--)
{
DMXScreenInfo *dmxScreen = dmxConfigAddDisplay ("", "",
NULL, 0, NULL, 0,
0);
dmxScreen->where = PosAbsolute;
dmxScreen->whereX = 0;
dmxScreen->whereY = 0;
}
}
}
static void dmxConfigFromConfigFile(void)
{
DMXConfigEntryPtr pt;
const char *name;
for (pt = dmxConfigEntry; pt; pt = pt->next) {
/* FIXME -- if an input is specified, use it */
if (pt->type != dmxConfigVirtual) continue;
if ((name = dmxConfigMatch(dmxConfigCmd.config, pt))) {
dmxLog(dmxInfo, "Using configuration \"%s\"\n", name);
dmxConfigCopyData(pt->virtual);
return;
}
}
dmxLog(dmxFatal, "Could not find configuration \"%s\" in \"%s\"\n",
dmxConfigCmd.config, dmxConfigCmd.filename);
}
static void dmxConfigConfigInputs(void)
{
DMXConfigListPtr pt;
if (dmxNumInputs) return;
if (dmxConfigCmd.inputs) { /* Use command line */
for (pt = dmxConfigCmd.inputs; pt; pt = pt->next)
dmxConfigAddInput(pt->name, TRUE);
} else if (dmxNumScreens) { /* Use first display */
DMXInputInfo *dmxInput;
if (!dmxScreens[0].virtualFb)
{
dmxInput = dmxConfigAddInput(xstrdup (dmxScreens[0].name), TRUE);
dmxInput->freename = TRUE;
dmxInput->scrnIdx = 0;
}
} else { /* Use dummy */
dmxConfigAddInput("dummy", TRUE);
}
if (dmxConfigCmd.xinputs) { /* Non-core devices from command line */
for (pt = dmxConfigCmd.xinputs; pt; pt = pt->next)
dmxConfigAddInput(pt->name, FALSE);
}
}
/** Set up the appropriate global variables so that the DMX server will
* be initialized using the configuration specified in the config file
* and on the command line. */
void dmxConfigConfigure(void)
{
if (dmxConfigEntry) {
dmxConfigFreeEntry(dmxConfigEntry);
dmxConfigEntry = NULL;
}
if (dmxConfigCmd.filename) {
if (dmxConfigCmd.displays)
dmxLog(dmxWarning,
"Using configuration file \"%s\" instead of command line\n",
dmxConfigCmd.filename);
dmxConfigReadFile(dmxConfigCmd.filename, 0);
dmxConfigFromConfigFile();
} else {
if (dmxConfigCmd.config)
dmxLog(dmxWarning,
"Configuration name (%s) without configuration file\n",
dmxConfigCmd.config);
dmxConfigFromCommandLine();
}
dmxConfigConfigInputs();
}
int dmxConfigDisplaysFromCommandLine(void)
{
return dmxDisplaysFromCommandLine;
}
/** This function determines the number of displays we WILL have and
* sets MAXSCREENS to that value. This is difficult since the number
* depends on the command line (which is easy to count) or on the config
* file, which has to be parsed. */
void dmxConfigSetMaxScreens(void)
{
static int processing = 0;
if (processing) return; /* Prevent reentry via ProcessCommandLine */
processing = 1;
if (dmxConfigCmd.filename) {
if (!dmxNumScreens)
dmxConfigConfigure();
#ifndef MAXSCREENS
SetMaxScreens(dmxNumScreens);
#endif
} else
#ifndef MAXSCREENS
SetMaxScreens(dmxDisplaysFromCommandLine);
#endif
processing = 0;
}
/** This macro is used to generate the following access methods:
* - dmxConfig{Set,Get}rules
* - dmxConfig{Set,Get}model
* - dmxConfig{Set,Get}layout
* - dmxConfig{Set,Get}variant
* - dmxConfig{Set,Get}options
* These methods are used to read and write information about the keyboard. */
#define GEN(param,glob,def) \
void dmxConfigSet##glob(const char *param) { \
if (dmx##glob) free((void *)dmx##glob); \
dmx##glob = strdup(param); \
} \
char *dmxConfigGet##glob(void) { \
return (char *)(dmx##glob ? dmx##glob : def); \
}
GEN(rules, XkbRules, DMX_DEFAULT_XKB_RULES)
GEN(model, XkbModel, DMX_DEFAULT_XKB_MODEL)
GEN(layout, XkbLayout, DMX_DEFAULT_XKB_LAYOUT)
GEN(variant, XkbVariant, DMX_DEFAULT_XKB_VARIANT)
GEN(options, XkbOptions, DMX_DEFAULT_XKB_OPTIONS)

View file

@ -1,72 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
/** \file
* Interface for DMX configuration file support. \see dmxconfig.c */
#ifndef _DMXCONFIG_H_
#define _DMXCONFIG_H_
#define DMX_DEFAULT_XKB_RULES "xfree86"
#define DMX_DEFAULT_XKB_MODEL "pc101"
#define DMX_DEFAULT_XKB_LAYOUT "us"
#define DMX_DEFAULT_XKB_VARIANT NULL
#define DMX_DEFAULT_XKB_OPTIONS NULL
extern void dmxConfigStoreDisplay(const char *name,
const char *display,
const char *authType,
int authTypeLen,
const char *authData,
int authDataLen,
int virtualFb);
extern void dmxConfigStoreNumDetached(const char *num);
extern void dmxConfigStoreInput(const char *input); /* Core devices */
extern void dmxConfigStoreXInput(const char *input); /* Non-core devices */
extern void dmxConfigStoreFile(const char *file);
extern void dmxConfigStoreConfig(const char *config);
extern void dmxConfigConfigure(void);
extern int dmxConfigDisplaysFromCommandLine(void);
extern void dmxConfigSetMaxScreens(void);
extern void dmxConfigSetXkbRules(const char *rules);
extern void dmxConfigSetXkbModel(const char *model);
extern void dmxConfigSetXkbLayout(const char *layout);
extern void dmxConfigSetXkbVariant(const char *variant);
extern void dmxConfigSetXkbOptions(const char *options);
extern char *dmxConfigGetXkbRules(void);
extern char *dmxConfigGetXkbModel(void);
extern char *dmxConfigGetXkbLayout(void);
extern char *dmxConfigGetXkbVariant(void);
extern char *dmxConfigGetXkbOptions(void);
#endif

View file

@ -1,607 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
/** \file
*
* This file provides support routines and helper functions to be used
* by the DMX configuration file parser.
*
* Because the DMX configuration file parsing should be capable of being
* used in a stand-alone fashion (i.e., independent from the DMX server
* source tree), no dependencies on other DMX routines are made. */
#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "dmxparse.h"
/** A general error logging routine that does not depend on the dmxLog
* functions. */
void dmxConfigLog(const char *format, ...)
{
va_list args;
va_start(args, format);
vprintf(format, args); /* RATS: All calls to dmxConfigLog from
* dmxparse.c and dmxprint.c use a
* trusted format. */
va_end(args);
}
void *dmxConfigAlloc(unsigned long bytes)
{
void *area = calloc(1, bytes);
if (!area) {
dmxConfigLog("dmxConfigAlloc: out of memory\n");
return NULL;
}
return area;
}
void *dmxConfigRealloc(void *orig, unsigned long orig_bytes,
unsigned long bytes)
{
unsigned char *area = realloc(orig, bytes);
if (!area) {
dmxConfigLog("dmxConfigRealloc: out of memory\n");
return NULL;
}
memset(area + orig_bytes, 0, bytes - orig_bytes);
return area;
}
const char *dmxConfigCopyString(const char *string, int length)
{
char *copy;
if (!length) length = strlen(string);
copy = dmxConfigAlloc(length + 1);
if (length) strncpy(copy, string, length);
copy[length] = '\0';
return copy;
}
void dmxConfigFree(void *area)
{
if (area) free(area);
}
DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
const char *comment)
{
DMXConfigTokenPtr pToken = dmxConfigAlloc(sizeof(*pToken));
pToken->token = token;
pToken->line = line;
pToken->comment = comment;
return pToken;
}
void dmxConfigFreeToken(DMXConfigTokenPtr p)
{
if (!p) return;
dmxConfigFree((void *)p->comment);
dmxConfigFree(p);
}
DMXConfigStringPtr dmxConfigCreateString(int token, int line,
const char *comment,
const char *string)
{
DMXConfigStringPtr pString = dmxConfigAlloc(sizeof(*pString));
pString->token = token;
pString->line = line;
pString->comment = comment;
pString->string = string;
return pString;
}
void dmxConfigFreeString(DMXConfigStringPtr p)
{
DMXConfigStringPtr next;
if (!p) return;
do {
next = p->next;
dmxConfigFree((void *)p->comment);
dmxConfigFree((void *)p->string);
dmxConfigFree(p);
} while ((p = next));
}
DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line,
const char *comment,
int number)
{
DMXConfigNumberPtr pNumber = dmxConfigAlloc(sizeof(*pNumber));
pNumber->token = token;
pNumber->line = line;
pNumber->comment = comment;
pNumber->number = number;
return pNumber;
}
void dmxConfigFreeNumber(DMXConfigNumberPtr p)
{
if (!p) return;
dmxConfigFree((void *)p->comment);
dmxConfigFree(p);
}
DMXConfigPairPtr dmxConfigCreatePair(int token, int line,
const char *comment,
int x, int y,
int xsign, int ysign)
{
DMXConfigPairPtr pPair = dmxConfigAlloc(sizeof(*pPair));
pPair->token = token;
pPair->line = line;
pPair->comment = comment;
pPair->x = x;
pPair->y = y;
pPair->xsign = (xsign < 0) ? -1 : 1;
pPair->ysign = (ysign < 0) ? -1 : 1;
return pPair;
}
void dmxConfigFreePair(DMXConfigPairPtr p)
{
if (!p) return;
dmxConfigFree((void *)p->comment);
dmxConfigFree(p);
}
DMXConfigCommentPtr dmxConfigCreateComment(int token, int line,
const char *comment)
{
DMXConfigCommentPtr pComment = dmxConfigAlloc(sizeof(*pComment));
pComment->token = token;
pComment->line = line;
pComment->comment = comment;
return pComment;
}
void dmxConfigFreeComment(DMXConfigCommentPtr p)
{
if (!p) return;
dmxConfigFree((void *)p->comment);
dmxConfigFree(p);
}
DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
DMXConfigPairPtr pOffset)
{
DMXConfigPartDimPtr pPart = dmxConfigAlloc(sizeof(*pPart));
pPart->dim = pDim;
pPart->offset = pOffset;
return pPart;
}
void dmxConfigFreePartDim(DMXConfigPartDimPtr p)
{
if (!p) return;
dmxConfigFreePair(p->dim);
dmxConfigFreePair(p->offset);
dmxConfigFree(p);
}
DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
DMXConfigPartDimPtr pRoot)
{
DMXConfigFullDimPtr pFull = dmxConfigAlloc(sizeof(*pFull));
pFull->scrn = pScrn;
pFull->root = pRoot;
return pFull;
}
void dmxConfigFreeFullDim(DMXConfigFullDimPtr p)
{
if (!p) return;
dmxConfigFreePartDim(p->scrn);
dmxConfigFreePartDim(p->root);
dmxConfigFree(p);
}
DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
DMXConfigStringPtr pName,
DMXConfigFullDimPtr pDim,
DMXConfigPairPtr pOrigin,
DMXConfigTokenPtr pEnd)
{
DMXConfigDisplayPtr pDisplay = dmxConfigAlloc(sizeof(*pDisplay));
pDisplay->start = pStart;
pDisplay->dname = pName;
pDisplay->dim = pDim;
pDisplay->origin = pOrigin;
pDisplay->end = pEnd;
pDisplay->name = pName ? pName->string : NULL;
pDisplay->rootXOrigin = pOrigin ? pOrigin->x : 0;
pDisplay->rootYOrigin = pOrigin ? pOrigin->y : 0;
if (pDim && pDim->scrn && pDim->scrn->dim) {
pDisplay->scrnWidth = pDim->scrn->dim->x;
pDisplay->scrnHeight = pDim->scrn->dim->y;
}
if (pDim && pDim->scrn && pDim->scrn->offset) {
pDisplay->scrnX = pDim->scrn->offset->x;
pDisplay->scrnY = pDim->scrn->offset->y;
pDisplay->scrnXSign = pDim->scrn->offset->xsign;
pDisplay->scrnYSign = pDim->scrn->offset->ysign;
}
if (pDim && pDim->root) {
if (pDim->root->dim) {
pDisplay->rootWidth = pDim->root->dim->x;
pDisplay->rootHeight = pDim->root->dim->y;
}
if (pDim->root->offset) {
pDisplay->rootX = pDim->root->offset->x;
pDisplay->rootY = pDim->root->offset->y;
pDisplay->rootXSign = pDim->root->offset->xsign;
pDisplay->rootYSign = pDim->root->offset->ysign;
}
} else { /* If no root specification, copy width
* and height from scrn -- leave offset
* as zero, since it is relative to
* scrn. */
pDisplay->rootWidth = pDisplay->scrnWidth;
pDisplay->rootHeight = pDisplay->scrnHeight;
}
return pDisplay;
}
void dmxConfigFreeDisplay(DMXConfigDisplayPtr p)
{
if (!p) return;
dmxConfigFreeToken(p->start);
dmxConfigFreeString(p->dname);
dmxConfigFreeFullDim(p->dim);
dmxConfigFreeToken(p->end);
dmxConfigFree(p);
}
DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart,
DMXConfigPairPtr pWallDim,
DMXConfigPairPtr pDisplayDim,
DMXConfigStringPtr pNameList,
DMXConfigTokenPtr pEnd)
{
DMXConfigWallPtr pWall = dmxConfigAlloc(sizeof(*pWall));
pWall->start = pStart;
pWall->wallDim = pWallDim;
pWall->displayDim = pDisplayDim;
pWall->nameList = pNameList;
pWall->end = pEnd;
pWall->width = pDisplayDim ? pDisplayDim->x : 0;
pWall->height = pDisplayDim ? pDisplayDim->y : 0;
pWall->xwall = pWallDim ? pWallDim->x : 0;
pWall->ywall = pWallDim ? pWallDim->y : 0;
return pWall;
}
void dmxConfigFreeWall(DMXConfigWallPtr p)
{
if (!p) return;
dmxConfigFreeToken(p->start);
dmxConfigFreePair(p->wallDim);
dmxConfigFreePair(p->displayDim);
dmxConfigFreeString(p->nameList);
dmxConfigFreeToken(p->end);
dmxConfigFree(p);
}
DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
DMXConfigStringPtr pOption,
DMXConfigTokenPtr pEnd)
{
int length = 0;
int offset = 0;
DMXConfigStringPtr p;
DMXConfigOptionPtr option = dmxConfigAlloc(sizeof(*option));
for (p = pOption; p; p = p->next) {
if (p->string) length += strlen(p->string) + 1;
}
option->string = dmxConfigAlloc(length + 1);
for (p = pOption; p; p = p->next) {
if (p->string) {
int len = strlen(p->string);
strncpy(option->string + offset, p->string, len);
offset += len;
if (p->next) option->string[offset++] = ' ';
}
}
option->string[offset] = '\0';
option->start = pStart;
option->option = pOption;
option->end = pEnd;
return option;
}
void dmxConfigFreeOption(DMXConfigOptionPtr p)
{
if (!p) return;
if (p->string) free(p->string);
dmxConfigFreeToken(p->start);
dmxConfigFreeString(p->option);
dmxConfigFreeToken(p->end);
dmxConfigFree(p);
}
const char **dmxConfigLookupParam(DMXConfigParamPtr p, const char *key,
int *argc)
{
DMXConfigParamPtr pt;
for (pt = p; pt; pt = pt->next) {
if (pt->argv && !strcasecmp(pt->argv[0], key)) {
*argc = pt->argc;
return pt->argv;
}
}
*argc = 0;
return NULL;
}
DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart,
DMXConfigTokenPtr pOpen,
DMXConfigStringPtr pParam,
DMXConfigTokenPtr pClose,
DMXConfigTokenPtr pEnd)
{
DMXConfigParamPtr param = dmxConfigAlloc(sizeof(*param));
DMXConfigStringPtr pt;
param->argc = 0;
param->argv = NULL;
for (pt = pParam; pt; pt = pt->next) {
if (pt->string) {
param->argv = realloc(param->argv,
(param->argc+2) * sizeof(*param->argv));
param->argv[param->argc] = pt->string;
++param->argc;
}
}
if (param->argv) param->argv[param->argc] = NULL;
param->start = pStart;
param->open = pOpen;
param->param = pParam;
param->close = pClose;
param->end = pEnd;
return param;
}
void dmxConfigFreeParam(DMXConfigParamPtr p)
{
DMXConfigParamPtr next;
if (!p) return;
do {
next = p->next;
dmxConfigFreeToken(p->start);
dmxConfigFreeToken(p->open);
dmxConfigFreeString(p->param);
dmxConfigFreeToken(p->close);
dmxConfigFreeToken(p->end);
dmxConfigFree(p->argv);
dmxConfigFree(p);
} while ((p = next));
}
DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type,
DMXConfigCommentPtr comment,
DMXConfigDisplayPtr display,
DMXConfigWallPtr wall,
DMXConfigOptionPtr option,
DMXConfigParamPtr param)
{
DMXConfigSubPtr pSub = dmxConfigAlloc(sizeof(*pSub));
pSub->type = type;
switch (type) {
case dmxConfigComment: pSub->comment = comment; break;
case dmxConfigDisplay: pSub->display = display; break;
case dmxConfigWall: pSub->wall = wall; break;
case dmxConfigOption: pSub->option = option; break;
case dmxConfigParam: pSub->param = param; break;
default: dmxConfigLog("Type %d not supported in subentry\n", type); break;
}
return pSub;
}
void dmxConfigFreeSub(DMXConfigSubPtr sub)
{
DMXConfigSubPtr pt;
for (pt = sub; pt; pt = pt->next) {
switch (pt->type) {
case dmxConfigComment: dmxConfigFreeComment(pt->comment); break;
case dmxConfigDisplay: dmxConfigFreeDisplay(pt->display); break;
case dmxConfigWall: dmxConfigFreeWall(pt->wall); break;
case dmxConfigOption: dmxConfigFreeOption(pt->option); break;
case dmxConfigParam: dmxConfigFreeParam(pt->param); break;
default:
dmxConfigLog("Type %d not supported in subentry\n", pt->type);
break;
}
}
dmxConfigFree(sub);
}
DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment)
{
return dmxConfigCreateSub(dmxConfigComment, comment, NULL, NULL, NULL,
NULL);
}
DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display)
{
return dmxConfigCreateSub(dmxConfigDisplay, NULL, display, NULL, NULL,
NULL);
}
DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall)
{
return dmxConfigCreateSub(dmxConfigWall, NULL, NULL, wall, NULL, NULL);
}
DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option)
{
return dmxConfigCreateSub(dmxConfigOption, NULL, NULL, NULL, option, NULL);
}
DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param)
{
return dmxConfigCreateSub(dmxConfigParam, NULL, NULL, NULL, NULL, param);
}
extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head,
DMXConfigSubPtr sub)
{
DMXConfigSubPtr pt;
if (!head) return sub;
for (pt = head; pt->next; pt = pt->next);
pt->next = sub;
return head;
}
DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
DMXConfigStringPtr pName,
DMXConfigPairPtr pDim,
DMXConfigTokenPtr pOpen,
DMXConfigSubPtr pSubentry,
DMXConfigTokenPtr pClose)
{
DMXConfigVirtualPtr pVirtual = dmxConfigAlloc(sizeof(*pVirtual));
pVirtual->start = pStart;
pVirtual->vname = pName;
pVirtual->dim = pDim;
pVirtual->open = pOpen;
pVirtual->subentry = pSubentry;
pVirtual->close = pClose;
pVirtual->name = pName ? pName->string : NULL;
pVirtual->width = pDim ? pDim->x : 0;
pVirtual->height = pDim ? pDim->y : 0;
return pVirtual;
}
void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual)
{
dmxConfigFreeToken(virtual->start);
dmxConfigFreeString(virtual->vname);
dmxConfigFreePair(virtual->dim);
dmxConfigFreeToken(virtual->open);
dmxConfigFreeSub(virtual->subentry);
dmxConfigFreeToken(virtual->close);
dmxConfigFree(virtual);
}
DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type,
DMXConfigCommentPtr comment,
DMXConfigVirtualPtr virtual)
{
DMXConfigEntryPtr pEntry = dmxConfigAlloc(sizeof(*pEntry));
pEntry->type = type;
switch (type) {
case dmxConfigComment: pEntry->comment = comment; break;
case dmxConfigVirtual: pEntry->virtual = virtual; break;
default: dmxConfigLog("Type %d not supported in entry\n", type); break;
}
return pEntry;
}
void dmxConfigFreeEntry(DMXConfigEntryPtr entry)
{
DMXConfigEntryPtr pt;
for (pt = entry; pt; pt = pt->next) {
switch (pt->type) {
case dmxConfigComment: dmxConfigFreeComment(pt->comment); break;
case dmxConfigVirtual: dmxConfigFreeVirtual(pt->virtual); break;
default:
dmxConfigLog("Type %d not supported in entry\n", pt->type);
break;
}
}
dmxConfigFree(entry);
}
DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head,
DMXConfigType type,
DMXConfigCommentPtr comment,
DMXConfigVirtualPtr virtual)
{
DMXConfigEntryPtr child = dmxConfigCreateEntry(type, comment, virtual);
DMXConfigEntryPtr pt;
if (!head) return child;
for (pt = head; pt->next; pt = pt->next);
pt->next = child;
return head;
}
DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment)
{
return dmxConfigCreateEntry(dmxConfigComment, comment, NULL);
}
DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual)
{
return dmxConfigCreateEntry(dmxConfigVirtual, NULL, virtual);
}

View file

@ -1,297 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
/** \file
* Interface to DMX configuration file parser. \see dmxparse.c */
#ifndef _DMXPARSE_H_
#define _DMXPARSE_H_
#include <stdio.h> /* For FILE */
/** Stores tokens not stored in other structures (e.g., keywords and ;) */
typedef struct _DMXConfigToken {
int token;
int line;
const char *comment;
} DMXConfigToken, *DMXConfigTokenPtr;
/** Stores parsed strings. */
typedef struct _DMXConfigString {
int token;
int line;
const char *comment;
const char *string;
struct _DMXConfigString *next;
} DMXConfigString, *DMXConfigStringPtr;
/** Stores parsed numbers. */
typedef struct _DMXConfigNumber {
int token;
int line;
const char *comment;
int number;
} DMXConfigNumber, *DMXConfigNumberPtr;
/** Stores parsed pairs (e.g., x y) */
typedef struct _DMXConfigPair {
int token;
int line;
const char *comment;
int x;
int y;
int xsign;
int ysign;
} DMXConfigPair, *DMXConfigPairPtr;
/** Stores parsed comments not stored with a token. */
typedef struct _DMXConfigComment {
int token;
int line;
const char *comment;
} DMXConfigComment, *DMXConfigCommentPtr;
typedef enum {
dmxConfigComment,
dmxConfigVirtual,
dmxConfigDisplay,
dmxConfigWall,
dmxConfigOption,
dmxConfigParam
} DMXConfigType;
/** Stores a geometry specification. */
typedef struct _DMXConfigPartDim {
DMXConfigPairPtr dim;
DMXConfigPairPtr offset;
} DMXConfigPartDim, *DMXConfigPartDimPtr;
/** Stores a pair of geometry specifications. */
typedef struct _DMXConfigFullDim {
DMXConfigPartDimPtr scrn;
DMXConfigPartDimPtr root;
} DMXConfigFullDim, *DMXConfigFullDimPtr;
/** Stores parsed display information. */
typedef struct _DMXConfigDisplay {
/* Summary information */
const char *name;
/* Screen Window Geometry */
int scrnWidth, scrnHeight;
int scrnX, scrnY;
int scrnXSign, scrnYSign;
/* Root Window Geometry */
int rootWidth, rootHeight;
int rootX, rootY;
int rootXSign, rootYSign;
/* Origin in global space */
int rootXOrigin, rootYOrigin;
/* Raw configuration information */
DMXConfigTokenPtr start;
DMXConfigStringPtr dname;
DMXConfigFullDimPtr dim;
DMXConfigPairPtr origin;
DMXConfigTokenPtr end;
} DMXConfigDisplay, *DMXConfigDisplayPtr;
/** Stores parsed wall information. */
typedef struct _DMXConfigWall {
/* Summary information */
int width, height; /* dimensions of displays */
int xwall, ywall; /* dimensions of wall, in tiles */
/* Raw configuration informaiton */
DMXConfigTokenPtr start;
DMXConfigPairPtr wallDim;
DMXConfigPairPtr displayDim;
DMXConfigStringPtr nameList;
DMXConfigTokenPtr end;
} DMXConfigWall, *DMXConfigWallPtr;
/** Stores parsed option information. */
typedef struct _DMXConfigOption {
/* Summary information */
char *string;
/* Raw configuration informaiton */
DMXConfigTokenPtr start;
DMXConfigStringPtr option;
DMXConfigTokenPtr end;
} DMXConfigOption, *DMXConfigOptionPtr;
/** Stores parsed param information. */
typedef struct _DMXConfigParam {
int argc;
const char **argv;
DMXConfigTokenPtr start;
DMXConfigTokenPtr open;
DMXConfigStringPtr param;
DMXConfigTokenPtr close;
DMXConfigTokenPtr end; /* Either open/close OR end */
struct _DMXConfigParam *next;
} DMXConfigParam, *DMXConfigParamPtr;
/** Stores options under an entry (subentry). */
typedef struct _DMXConfigSub {
DMXConfigType type;
DMXConfigCommentPtr comment;
DMXConfigDisplayPtr display;
DMXConfigWallPtr wall;
DMXConfigOptionPtr option;
DMXConfigParamPtr param;
struct _DMXConfigSub *next;
} DMXConfigSub, *DMXConfigSubPtr;
/** Stores parsed virtual information. */
typedef struct _DMXConfigVirtual {
/* Summary information */
const char *name;
int width, height;
/* Raw configuration information */
DMXConfigTokenPtr start;
DMXConfigStringPtr vname;
DMXConfigPairPtr dim;
DMXConfigTokenPtr open;
DMXConfigSubPtr subentry;
DMXConfigTokenPtr close;
} DMXConfigVirtual, *DMXConfigVirtualPtr;
/** Heads entry storage. */
typedef struct _DMXConfigEntry {
DMXConfigType type;
DMXConfigCommentPtr comment;
DMXConfigVirtualPtr virtual;
struct _DMXConfigEntry *next;
} DMXConfigEntry, *DMXConfigEntryPtr;
extern DMXConfigEntryPtr dmxConfigEntry;
extern int yylex(void);
extern int yydebug;
extern void yyerror(const char *message);
extern void dmxConfigLog(const char *format, ...);
extern void *dmxConfigAlloc(unsigned long bytes);
extern void *dmxConfigRealloc(void *orig,
unsigned long orig_bytes,
unsigned long bytes);
extern const char *dmxConfigCopyString(const char *string,
int length);
extern void dmxConfigFree(void *area);
extern DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
const char *comment);
extern void dmxConfigFreeToken(DMXConfigTokenPtr p);
extern DMXConfigStringPtr dmxConfigCreateString(int token, int line,
const char *comment,
const char *string);
extern void dmxConfigFreeString(DMXConfigStringPtr p);
extern DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line,
const char *comment,
int number);
extern void dmxConfigFreeNumber(DMXConfigNumberPtr p);
extern DMXConfigPairPtr dmxConfigCreatePair(int token, int line,
const char *comment,
int x, int y,
int xsign, int ysign);
extern void dmxConfigFreePair(DMXConfigPairPtr p);
extern DMXConfigCommentPtr dmxConfigCreateComment(int token, int line,
const char *comment);
extern void dmxConfigFreeComment(DMXConfigCommentPtr p);
extern DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
DMXConfigPairPtr pOffset);
extern void dmxConfigFreePartDim(DMXConfigPartDimPtr p);
extern DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
DMXConfigPartDimPtr pRoot);
extern void dmxConfigFreeFullDim(DMXConfigFullDimPtr p);
extern DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
DMXConfigStringPtr pName,
DMXConfigFullDimPtr pDim,
DMXConfigPairPtr pOrigin,
DMXConfigTokenPtr pEnd);
extern void dmxConfigFreeDisplay(DMXConfigDisplayPtr p);
extern DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart,
DMXConfigPairPtr pWallDim,
DMXConfigPairPtr pDisplayDim,
DMXConfigStringPtr pNameList,
DMXConfigTokenPtr pEnd);
extern void dmxConfigFreeWall(DMXConfigWallPtr p);
extern DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
DMXConfigStringPtr pOption,
DMXConfigTokenPtr pEnd);
extern void dmxConfigFreeOption(DMXConfigOptionPtr p);
extern DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart,
DMXConfigTokenPtr pOpen,
DMXConfigStringPtr pParam,
DMXConfigTokenPtr pClose,
DMXConfigTokenPtr pEnd);
extern void dmxConfigFreeParam(DMXConfigParamPtr p);
extern const char **dmxConfigLookupParam(DMXConfigParamPtr p,
const char *key,
int *argc);
extern DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type,
DMXConfigCommentPtr comment,
DMXConfigDisplayPtr display,
DMXConfigWallPtr wall,
DMXConfigOptionPtr option,
DMXConfigParamPtr param);
extern void dmxConfigFreeSub(DMXConfigSubPtr sub);
extern DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment);
extern DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display);
extern DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall);
extern DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option);
extern DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param);
extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head,
DMXConfigSubPtr sub);
extern DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
DMXConfigStringPtr pName,
DMXConfigPairPtr pDim,
DMXConfigTokenPtr pOpen,
DMXConfigSubPtr pSubentry,
DMXConfigTokenPtr pClose);
extern void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual);
extern DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type,
DMXConfigCommentPtr comment,
DMXConfigVirtualPtr virtual);
extern void dmxConfigFreeEntry(DMXConfigEntryPtr entry);
extern DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head,
DMXConfigType type,
DMXConfigCommentPtr comment,
DMXConfigVirtualPtr virtual);
extern DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment);
extern DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual);
#endif

View file

@ -1,455 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
/** \file
*
* This file provides support routines and helper functions to be used
* to pretty-print DMX configurations.
*
* Because the DMX configuration file parsing should be capable of being
* used in a stand-alone fashion (i.e., independent from the DMX server
* source tree), no dependencies on other DMX routines are made. */
#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include "dmxconfig.h"
#include "dmxparse.h"
#include "dmxprint.h"
#include "parser.h"
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
static FILE *str = NULL;
static int indent = 0;
static int pos = 0;
/** Stack of indentation information used for pretty-printing
* configuration information. */
static struct stack {
int base;
int comment;
int step;
struct stack *next;
} *stack, initialStack = { 0, 0, 4, NULL };
static void dmxConfigIndent(void)
{
int i;
if (indent < 0) indent = 0;
if (indent > 40) indent = 40;
for (i = 0; i < indent; i++) fprintf(str, " ");
}
static void dmxConfigNewline(void)
{
if (pos) fprintf(str, "\n");
pos = 0;
}
static void dmxConfigPushState(int base, int comment, int step)
{
struct stack *new = dmxConfigAlloc(sizeof(*new));
new->base = base;
new->comment = comment;
new->step = step;
new->next = stack;
stack = new;
indent = base;
dmxConfigNewline();
}
static void dmxConfigPushComment(void)
{
if (stack) indent = stack->comment;
}
static void dmxConfigPushStep(void)
{
if (stack) indent = stack->step;
}
static void dmxConfigPopState(void)
{
struct stack *old = stack;
if (!stack) return;
indent = old->base;
stack = old->next;
if (!stack) dmxConfigLog("Stack underflow\n");
dmxConfigFree(old);
dmxConfigNewline();
}
static void dmxConfigOutput(int addSpace, int doNewline, const char *comment,
const char *format, ...)
{
va_list args;
if (!pos) dmxConfigIndent();
else if (addSpace) fprintf(str, " ");
if (format) {
va_start(args, format);
/* RATS: This hasn't been audited -- it
* could probably result in a buffer
* overflow. */
pos += vfprintf(str, format, args); /* assumes no newlines! */
va_end(args);
}
if (comment) {
if (pos) fprintf(str, " ");
pos += fprintf(str, "#%s", comment);
dmxConfigNewline();
dmxConfigPushComment();
} else if (doNewline) dmxConfigNewline();
}
static void dmxConfigPrintComment(DMXConfigCommentPtr p)
{
dmxConfigOutput(1, 1, p->comment, NULL);
}
static void dmxConfigPrintTokenFlag(DMXConfigTokenPtr p, int flag)
{
if (!p) return;
switch (p->token) {
case T_VIRTUAL:
dmxConfigPushState(0, 4, 4);
dmxConfigOutput(0, 0, p->comment, "virtual");
break;
case T_DISPLAY:
dmxConfigPushState(4, 12, 16);
dmxConfigOutput(0, 0, p->comment, "display");
break;
case T_WALL:
dmxConfigPushState(4, 12, 16);
dmxConfigOutput(0, 0, p->comment, "wall");
break;
case T_OPTION:
dmxConfigPushState(4, 12, 16);
dmxConfigOutput(0, 0, p->comment, "option");
break;
case T_PARAM:
dmxConfigPushState(4, 8, 12);
dmxConfigOutput(0, 0, p->comment, "param");
break;
case ';':
dmxConfigOutput(0, 1, p->comment, ";");
if (flag) dmxConfigPopState();
break;
case '{':
dmxConfigOutput(1, 1, p->comment, "{");
dmxConfigPushStep();
break;
case '}':
if (flag) dmxConfigPopState();
dmxConfigOutput(0, 1, p->comment, "}");
break;
case '/':
dmxConfigOutput(1, 0, NULL, "/");
break;
default:
dmxConfigLog("unknown token %d on line %d\n", p->token, p->line);
}
}
static void dmxConfigPrintToken(DMXConfigTokenPtr p)
{
dmxConfigPrintTokenFlag(p, 1);
}
static void dmxConfigPrintTokenNopop(DMXConfigTokenPtr p)
{
dmxConfigPrintTokenFlag(p, 0);
}
static int dmxConfigPrintQuotedString(const char *s)
{
const char *pt;
if (!s || !s[0]) return 1; /* Quote empty string */
for (pt = s; *pt; ++pt) if (isspace(*pt)) return 1;
return 0;
}
static void dmxConfigPrintString(DMXConfigStringPtr p, int quote)
{
DMXConfigStringPtr pt;
if (!p) return;
for (pt = p; pt; pt = pt->next) {
if (quote && dmxConfigPrintQuotedString(pt->string)) {
dmxConfigOutput(1, 0, pt->comment, "\"%s\"",
pt->string ? pt->string : "");
} else
dmxConfigOutput(1, 0, pt->comment, "%s",
pt->string ? pt->string : "");
}
}
static int dmxConfigPrintPair(DMXConfigPairPtr p, int addSpace)
{
const char *format = NULL;
if (!p) return 0;
switch (p->token) {
case T_ORIGIN: format = "@%dx%d"; break;
case T_DIMENSION: format = "%dx%d"; break;
case T_OFFSET: format = "%c%d%c%d"; break;
}
if (p->token == T_OFFSET) {
if (!p->comment && !p->x && !p->y && p->xsign >= 0 && p->ysign >= 0)
return 0;
dmxConfigOutput(addSpace, 0, p->comment, format,
p->xsign < 0 ? '-' : '+', p->x,
p->ysign < 0 ? '-' : '+', p->y);
} else {
if (!p->comment && !p->x && !p->y) return 0;
dmxConfigOutput(addSpace, 0, p->comment, format, p->x, p->y);
}
return 1;
}
static void dmxConfigPrintDisplay(DMXConfigDisplayPtr p)
{
DMXConfigToken dummyStart = { T_DISPLAY, 0, NULL };
DMXConfigToken dummyEnd = { ';', 0, NULL };
DMXConfigToken dummySep = { '/', 0, NULL };
DMXConfigString dummyName = { T_STRING, 0, NULL, NULL, NULL };
DMXConfigPair dummySDim = { T_DIMENSION, 0, NULL, 0, 0, 0, 0 };
DMXConfigPair dummySOffset = { T_OFFSET, 0, NULL, 0, 0, 0, 0 };
DMXConfigPair dummyRDim = { T_DIMENSION, 0, NULL, 0, 0, 0, 0 };
DMXConfigPair dummyROffset = { T_OFFSET, 0, NULL, 0, 0, 0, 0 };
DMXConfigPair dummyOrigin = { T_ORIGIN, 0, NULL, 0, 0, 0, 0 };
int output;
if (p->dname) p->dname->string = p->name;
else dummyName.string = p->name;
if (p->dim && p->dim->scrn && p->dim->scrn->dim) {
p->dim->scrn->dim->x = p->scrnWidth;
p->dim->scrn->dim->y = p->scrnHeight;
} else {
dummySDim.x = p->scrnWidth;
dummySDim.y = p->scrnHeight;
}
if (p->dim && p->dim->scrn && p->dim->scrn->offset) {
p->dim->scrn->offset->x = p->scrnX;
p->dim->scrn->offset->y = p->scrnY;
} else {
dummySOffset.x = p->scrnX;
dummySOffset.y = p->scrnY;
}
if (p->dim && p->dim->root && p->dim->root->dim) {
p->dim->root->dim->x = p->rootWidth;
p->dim->root->dim->y = p->rootHeight;
} else {
dummyRDim.x = p->rootWidth;
dummyRDim.y = p->rootHeight;
}
if (p->dim && p->dim->root && p->dim->root->offset) {
p->dim->root->offset->x = p->rootX;
p->dim->root->offset->y = p->rootY;
} else {
dummyROffset.x = p->rootX;
dummyROffset.y = p->rootY;
}
if (p->origin) {
p->origin->x = p->rootXOrigin, p->origin->y = p->rootYOrigin;
p->origin->xsign = p->rootXSign, p->origin->ysign = p->rootYSign;
} else {
dummyOrigin.x = p->rootXOrigin, dummyOrigin.y = p->rootYOrigin;
dummyOrigin.xsign = p->rootXSign, dummyOrigin.ysign = p->rootYSign;
}
dmxConfigPrintToken(p->start ? p->start : &dummyStart);
dmxConfigPrintString(p->dname ? p->dname : &dummyName, 1);
if (p->dim && p->dim->scrn && p->dim->scrn->dim)
output = dmxConfigPrintPair(p->dim->scrn->dim, 1);
else
output = dmxConfigPrintPair(&dummySDim, 1);
if (p->dim && p->dim->scrn && p->dim->scrn->offset)
dmxConfigPrintPair(p->dim->scrn->offset, !output);
else
dmxConfigPrintPair(&dummySOffset, !output);
if (p->scrnWidth != p->rootWidth
|| p->scrnHeight != p->rootHeight
|| p->rootX
|| p->rootY) {
dmxConfigPrintToken(&dummySep);
if (p->dim && p->dim->root && p->dim->root->dim)
output = dmxConfigPrintPair(p->dim->root->dim, 1);
else
output = dmxConfigPrintPair(&dummyRDim, 1);
if (p->dim && p->dim->root && p->dim->root->offset)
dmxConfigPrintPair(p->dim->root->offset, !output);
else
dmxConfigPrintPair(&dummyROffset, !output);
}
dmxConfigPrintPair(p->origin ? p->origin : &dummyOrigin, 1);
dmxConfigPrintToken(p->end ? p->end : &dummyEnd);
}
static void dmxConfigPrintWall(DMXConfigWallPtr p)
{
dmxConfigPrintToken(p->start);
dmxConfigPrintPair(p->wallDim, 1);
dmxConfigPrintPair(p->displayDim, 1);
dmxConfigPrintString(p->nameList, 1);
dmxConfigPrintToken(p->end);
}
static void dmxConfigPrintOption(DMXConfigOptionPtr p)
{
DMXConfigToken dummyStart = { T_OPTION, 0, NULL };
DMXConfigString dummyOption = { T_STRING, 0, NULL, NULL, NULL };
DMXConfigToken dummyEnd = { ';', 0, NULL };
dummyOption.string = p->string;
dmxConfigPrintToken(p->start ? p->start : &dummyStart);
dmxConfigPrintString(&dummyOption, 0);
dmxConfigPrintToken(p->end ? p->end : &dummyEnd);
}
static void dmxConfigPrintParam(DMXConfigParamPtr p)
{
if (!p) return;
if (p->start) {
if (p->open && p->close) {
dmxConfigPrintToken(p->start);
dmxConfigPrintToken(p->open);
dmxConfigPrintParam(p->next);
dmxConfigPrintToken(p->close);
} else if (p->end && p->param) {
dmxConfigPrintToken(p->start);
dmxConfigPrintString(p->param, 1);
dmxConfigPrintToken(p->end);
} else
dmxConfigLog("dmxConfigPrintParam: cannot handle format (a)\n");
} else if (p->end && p->param) {
dmxConfigPrintString(p->param, 1);
dmxConfigPrintTokenNopop(p->end);
dmxConfigPrintParam(p->next);
} else
dmxConfigLog("dmxConfigPrintParam: cannot handle format (b)\n");
}
static void dmxConfigPrintSub(DMXConfigSubPtr p)
{
DMXConfigSubPtr pt;
if (!p) return;
for (pt = p; pt; pt = pt->next) {
switch (pt->type) {
case dmxConfigComment: dmxConfigPrintComment(pt->comment); break;
case dmxConfigDisplay: dmxConfigPrintDisplay(pt->display); break;
case dmxConfigWall: dmxConfigPrintWall(pt->wall); break;
case dmxConfigOption: dmxConfigPrintOption(pt->option); break;
case dmxConfigParam: dmxConfigPrintParam(pt->param); break;
default:
dmxConfigLog("dmxConfigPrintSub:"
" cannot handle type %d in subentry\n", pt->type);
}
}
}
static void dmxConfigPrintVirtual(DMXConfigVirtualPtr p)
{
DMXConfigToken dummyStart = { T_VIRTUAL, 0, NULL };
DMXConfigToken dummyOpen = { '{', 0, NULL };
DMXConfigToken dummyClose = { '}', 0, NULL };
DMXConfigString dummyName = { T_STRING, 0, NULL, NULL, NULL };
DMXConfigPair dummyDim = { T_DIMENSION, 0, NULL, 0, 0 };
if (p->vname) p->vname->string = p->name;
else dummyName.string = p->name;
if (p->dim) p->dim->x = p->width, p->dim->y = p->height;
else dummyDim.x = p->width, dummyDim.y = p->height;
dmxConfigPrintToken(p->start ? p->start : &dummyStart);
dmxConfigPrintString(p->vname ? p->vname : &dummyName, 1);
dmxConfigPrintPair(p->dim ? p->dim : &dummyDim, 1);
dmxConfigPrintToken(p->open ? p->open : &dummyOpen);
dmxConfigPrintSub(p->subentry);
dmxConfigPrintToken(p->close ? p->close : &dummyClose);
}
/** The configuration information in \a entry will be pretty-printed to
* the \a stream. If \a stream is NULL, then stdout will be used. */
void dmxConfigPrint(FILE *stream, DMXConfigEntryPtr entry)
{
DMXConfigEntryPtr pt;
if (!stream) str = stdout;
else str = stream;
stack = &initialStack;
for (pt = entry; pt; pt = pt->next) {
switch (pt->type) {
case dmxConfigComment: dmxConfigPrintComment(pt->comment); break;
case dmxConfigVirtual: dmxConfigPrintVirtual(pt->virtual); break;
default:
dmxConfigLog("dmxConfigPrint: cannot handle type %d in entry\n",
pt->type);
}
}
if (pos) dmxConfigNewline();
}
/** The configuration information in \a p will be pretty-printed to the
* \a stream. If \a stream is NULL, then stdout will be used. */
void dmxConfigVirtualPrint(FILE *stream, DMXConfigVirtualPtr p)
{
if (!stream) str = stdout;
else str = stream;
stack = &initialStack;
dmxConfigPrintVirtual(p);
if (pos) dmxConfigNewline();
}

View file

@ -1,43 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
/** \file
* Interface to DMX configuration file pretty-printer. \see dmxprint.c */
#ifndef _DMXPRINT_H_
#define _DMXPRINT_H_
void dmxConfigPrint(FILE *str, DMXConfigEntryPtr entry);
void dmxConfigVirtualPrint(FILE *str, DMXConfigVirtualPtr p);
#endif

View file

@ -1,49 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
* This is a simple filter for testing.
*/
#include "dmxconfig.h"
#include "dmxparse.h"
#include "dmxprint.h"
#include "dmxcompat.h"
extern int yyparse(void);
extern FILE *yyin;
int main(int argc, char **argv)
{
yydebug = 0;
yyparse();
dmxConfigPrint(stdout, dmxConfigEntry);
return 0;
}

View file

@ -1,41 +0,0 @@
.\" $XFree86$
.\" Copyright 2002 Red Hat Inc., Durham, North Carolina.
.\" All Rights Reserved.
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
.\" a copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation on the rights to use, copy, modify, merge,
.\" publish, distribute, sublicense, and/or sell copies of the Software,
.\" and to permit persons to whom the Software is furnished to do so,
.\" subject to the following conditions:
.\"
.\" The above copyright notice and this permission notice (including the
.\" next paragraph) shall be included in all copies or substantial
.\" portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
.\" NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
.\" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
.\" ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
.\" SOFTWARE.
.\"
.\" Authors:
.\" Rickard E. (Rik) Faith <faith@redhat.com>
.\"
.TH dmxtodmx 1 __vendorversion__
.SH NAME
dmxtodmx - dmx configuration file parser and printer
.SH SYNOPSIS
.B dmxtodmx
.SH DESCRIPTION
.I dmxtodmx
reads the standard input, parsing a configuration file for the
.I Xdmx
distributed multi-head X server. After a successful parse, the file is
pretty-printed to standard output.
.SH "SEE ALSO"
Xdmx(1), vdltodmx(1), xdmxconfig(1)

View file

@ -1,226 +0,0 @@
/* $XFree86$ */
/*
* Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
%{
#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include "dmxparse.h"
#include <string.h>
#include <stdlib.h>
#define YYDEBUG 1
#define YYERROR_VERBOSE
#define YY_USE_PROTOS
DMXConfigEntryPtr dmxConfigEntry = NULL;
#define APPEND(type, h, t) \
{ \
type pt; \
for (pt = h; pt->next; pt = pt->next); \
pt->next = t; \
}
%}
%union {
DMXConfigTokenPtr token;
DMXConfigStringPtr string;
DMXConfigNumberPtr number;
DMXConfigPairPtr pair;
DMXConfigFullDimPtr fdim;
DMXConfigPartDimPtr pdim;
DMXConfigDisplayPtr display;
DMXConfigWallPtr wall;
DMXConfigOptionPtr option;
DMXConfigParamPtr param;
DMXConfigCommentPtr comment;
DMXConfigSubPtr subentry;
DMXConfigVirtualPtr virtual;
DMXConfigEntryPtr entry;
}
/* Terminals */
%token <token> '{' '}' ';' '/' T_VIRTUAL T_DISPLAY T_WALL T_OPTION T_PARAM
%token <string> T_STRING
%token <pair> T_DIMENSION T_OFFSET T_ORIGIN
%token <comment> T_COMMENT T_LINE_COMMENT
/* Non-termials */
%type <token> Display Wall Terminal Open Close
%type <string> NameList Name
%type <pair> Dimension Offset Origin
%type <pdim> PartialDim
%type <fdim> FullDim
%type <display> DisplayEntry
%type <option> OptionEntry
%type <param> ParamEntry ParamList Param
%type <subentry> SubList Sub
%type <wall> WallEntry
%type <virtual> Virtual
%type <entry> Program EntryList Entry
%%
Program : EntryList { dmxConfigEntry = $1; }
;
EntryList : Entry
| EntryList Entry { APPEND(DMXConfigEntryPtr,$1,$2); $$ = $1; }
;
Entry : Virtual { $$ = dmxConfigEntryVirtual($1); }
| T_LINE_COMMENT { $$ = dmxConfigEntryComment($1); }
;
Virtual : T_VIRTUAL Open SubList Close
{ $$ = dmxConfigCreateVirtual($1, NULL, NULL, $2, $3, $4); }
| T_VIRTUAL Dimension Open SubList Close
{ $$ = dmxConfigCreateVirtual($1, NULL, $2, $3, $4, $5); }
| T_VIRTUAL Name Open SubList Close
{ $$ = dmxConfigCreateVirtual($1, $2, NULL, $3, $4, $5); }
| T_VIRTUAL Name Dimension Open SubList Close
{ $$ = dmxConfigCreateVirtual($1, $2, $3, $4, $5, $6 ); }
;
SubList : Sub
| SubList Sub { APPEND(DMXConfigSubPtr,$1,$2); $$ = $1; }
;
Sub : T_LINE_COMMENT { $$ = dmxConfigSubComment($1); }
| DisplayEntry { $$ = dmxConfigSubDisplay($1); }
| WallEntry { $$ = dmxConfigSubWall($1); }
| OptionEntry { $$ = dmxConfigSubOption($1); }
| ParamEntry { $$ = dmxConfigSubParam($1); }
;
OptionEntry : T_OPTION NameList Terminal
{ $$ = dmxConfigCreateOption($1, $2, $3); }
;
ParamEntry : T_PARAM NameList Terminal
{ $$ = dmxConfigCreateParam($1, NULL, $2, NULL, $3); }
| T_PARAM Open ParamList Close
{ $$ = dmxConfigCreateParam($1, $2, NULL, $4, NULL);
$$->next = $3;
}
;
ParamList : Param
| ParamList Param { APPEND(DMXConfigParamPtr,$1,$2); $$ = $1; }
;
Param : NameList Terminal
{ $$ = dmxConfigCreateParam(NULL, NULL, $1, NULL, $2); }
;
PartialDim : Dimension Offset
{ $$ = dmxConfigCreatePartDim($1, $2); }
| Dimension
{ $$ = dmxConfigCreatePartDim($1, NULL); }
| Offset
{ $$ = dmxConfigCreatePartDim(NULL, $1); }
;
FullDim : PartialDim '/' PartialDim
{ $$ = dmxConfigCreateFullDim($1, $3); }
| '/' PartialDim
{ $$ = dmxConfigCreateFullDim(NULL, $2); }
| PartialDim
{ $$ = dmxConfigCreateFullDim($1, NULL); }
;
DisplayEntry : Display Name FullDim Origin Terminal
{ $$ = dmxConfigCreateDisplay($1, $2, $3, $4, $5); }
| Display FullDim Origin Terminal
{ $$ = dmxConfigCreateDisplay($1, NULL, $2, $3, $4); }
| Display Name Origin Terminal
{ $$ = dmxConfigCreateDisplay($1, $2, NULL, $3, $4); }
| Display Name FullDim Terminal
{ $$ = dmxConfigCreateDisplay($1, $2, $3, NULL, $4); }
| Display FullDim Terminal
{ $$ = dmxConfigCreateDisplay($1, NULL, $2, NULL, $3); }
| Display Name Terminal
{ $$ = dmxConfigCreateDisplay($1, $2, NULL, NULL, $3); }
| Display Terminal
{ $$ = dmxConfigCreateDisplay($1, NULL, NULL, NULL, $2); }
;
WallEntry : Wall Dimension Dimension NameList Terminal
{ $$ = dmxConfigCreateWall($1, $2, $3, $4, $5); }
| Wall Dimension NameList Terminal
{ $$ = dmxConfigCreateWall($1, $2, NULL, $3, $4); }
| Wall NameList Terminal
{ $$ = dmxConfigCreateWall($1, NULL, NULL, $2, $3); }
;
Display : T_DISPLAY
| T_DISPLAY T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
Name : T_STRING
| T_STRING T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
Dimension : T_DIMENSION
| T_DIMENSION T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
Offset : T_OFFSET
| T_OFFSET T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
Origin : T_ORIGIN
| T_ORIGIN T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
Terminal : ';'
| ';' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
Open : '{'
| '{' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
Close : '}'
| '}' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
Wall : T_WALL
| T_WALL T_COMMENT { $$ = $1; $$->comment = $2->comment; }
;
NameList : Name
| NameList Name { APPEND(DMXConfigStringPtr, $1, $2); $$ = $1; }
;

View file

@ -1,184 +0,0 @@
/* $XFree86$ */
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
%{
#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include "dmxparse.h"
#include "parser.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
static int getdimension(int token, const char *text, int leng);
static int getstring(int token, const char *text, int leng);
static int gettoken(int token, const char *text, int leng);
static int getcomment(int token, const char *text, int leng);
static int lineno = 1;
%}
%s OTHER
comment #.*
word ([[:alpha:]_/:\-\+\.\*][[:alnum:]_/:\-\+\.\*]+)
string \"(([^\"\n])|\"\")*\"
badstring \"(([^\"\n])|\"\")*
number [[:digit:]x]+
dimension [[:digit:]]+[[:blank:]]*x[[:blank:]]*[[:digit:]]+
offset [+-][[:digit:]]+[[:blank:]]*[+-][[:blank:]]*[[:digit:]]+
origin @[[:blank:]]*[[:digit:]]+[[:blank:]]*[[:blank:]]*x[[:digit:]]+
NL \n
WS [[:blank:]]+
%%
virtual return gettoken(T_VIRTUAL, yytext, yyleng);
display return gettoken(T_DISPLAY, yytext, yyleng);
wall return gettoken(T_WALL, yytext, yyleng);
option return gettoken(T_OPTION, yytext, yyleng);
param return gettoken(T_PARAM, yytext, yyleng);
{dimension} return getdimension(T_DIMENSION, yytext, yyleng);
{offset} return getdimension(T_OFFSET, yytext+1, yyleng-1);
{origin} return getdimension(T_ORIGIN, yytext+1, yyleng-1);
{word} return getstring(T_STRING, yytext, yyleng);
{string} return getstring(T_STRING, yytext+1, yyleng-2);
{NL} ++lineno;
{WS}
\{ return gettoken(yytext[0], yytext, yyleng);
\} return gettoken(yytext[0], yytext, yyleng);
\; return gettoken(yytext[0], yytext, yyleng);
\/ return gettoken(yytext[0], yytext, yyleng);
^{comment} return getcomment(T_LINE_COMMENT, yytext, yyleng);
{comment} return getcomment(T_COMMENT, yytext, yyleng);
. return getstring(T_STRING, yytext, yyleng);
<<EOF>> return 0;
%%
int yywrap(void)
{
return 1;
}
void yyerror(const char *message)
{
const char *pt, *end;
struct _entry {
const char *from;
const char *to;
} *entry, list[] = {
{ "T_VIRTUAL", "\"virtual\"" },
{ "T_DISPLAY", "\"display\"" },
{ "T_WALL", "\"wall\"" },
{ "T_OPTION", "\"option\"" },
{ "T_PARAM", "\"param\"" },
{ "T_DIMENSION", "dimension (e.g., 2x2 or 1024x768)" },
{ "T_OFFSET", "display offset (e.g., +10-10)" },
{ "T_ORIGIN", "tile origin (e.g., @1280x1024)" },
{ "T_STRING", "string" },
{ "T_COMMENT", "comment (e.g., #...)" },
{ "T_LINE_COMMENT", "comment (e.g., #...)" },
{ NULL, NULL }
};
fprintf(stderr, "parse error on line %d at token \"%*.*s\"\n",
lineno, yyleng, yyleng, yytext);
end = message + strlen(message);
for (pt = message; *pt; pt++) {
if (pt[0] == 'T' && pt[1] == '_') {
const char *next = strchr(pt, ' ');
if (!next || !*next) next = strchr(pt, '\0');
if (!next) goto bail;
--next;
if (next-pt == 1 && next[1]
&& next[2] == '\'' && next[3] == '\'') {
fprintf(stderr, "\"%c\"", next[1]);
pt += 4;
goto cnt;
}
for (entry = list; entry->from; ++entry) {
if (!strncmp(entry->from, pt, strlen(entry->from))) {
fprintf(stderr, "%s", entry->to);
pt = next;
goto cnt;
}
}
} else if (end-pt >= 5 && pt[0] == '\'' && pt[1] == '\'' && pt[3]
&& pt[4] == '\'' && pt[5] == '\'') {
fprintf(stderr, "\"%c\"", pt[3]);
pt += 5;
} else if (end-pt >= 3 && pt[0] == '\'' && pt[1] && pt[2] == '\'') {
fprintf(stderr, "\"%c\"", pt[1]);
pt += 3;
}
bail:
putc(*pt, stderr);
cnt:
;
}
fprintf(stderr, "\n");
exit( 1 );
}
static int getdimension(int token, const char *text, int leng)
{
char *endptr;
char *tmp = dmxConfigAlloc(leng+1);
int x, y;
strncpy(tmp, text, leng);
x = strtol(tmp, &endptr, 10);
while (*endptr && !isdigit(*endptr)) ++endptr;
y = strtol(endptr, NULL, 10);
dmxConfigFree(tmp);
yylval.pair = dmxConfigCreatePair(token, lineno, NULL, x, y, 1, 1);
return token;
}
static int getstring(int token, const char *text, int leng)
{
yylval.string = dmxConfigCreateString(token, lineno, NULL,
dmxConfigCopyString(leng ? text : "",
leng));
return token;
}
static int gettoken(int token, const char *text, int leng)
{
yylval.token = dmxConfigCreateToken(token, lineno, NULL);
return token;
}
static int getcomment(int token, const char *text, int leng)
{
yylval.comment = dmxConfigCreateComment(token, lineno,
dmxConfigCopyString(text + 1,
leng - 1));
return token;
}

View file

@ -1 +0,0 @@
error

View file

@ -1,2 +0,0 @@
parse error on line 1 at token "error"
syntax error, unexpected string expecting "virtual" or comment (e.g., #...)

View file

@ -1 +0,0 @@
# comment

View file

@ -1 +0,0 @@
# comment

View file

@ -1 +0,0 @@
virtual

View file

@ -1,2 +0,0 @@
parse error on line 2 at token " "
syntax error, unexpected $end, expecting "{" or string or dimension (e.g., 2x2 or 1024x768)

View file

@ -1 +0,0 @@
display

View file

@ -1,2 +0,0 @@
parse error on line 1 at token "display"
syntax error, unexpected "display" expecting "virtual" or comment (e.g., #...)

View file

@ -1 +0,0 @@
display;

View file

@ -1,2 +0,0 @@
parse error on line 1 at token "display"
syntax error, unexpected "display" expecting "virtual" or comment (e.g., #...)

View file

@ -1,2 +0,0 @@
virtual {
}

Binary file not shown.

View file

@ -1,4 +0,0 @@
virtual a {
display d0:0 1280x1024;
display d1:0 1280x1024;
}

View file

@ -1,4 +0,0 @@
virtual a {
display d0:0 1280x1024;
display d1:0 1280x1024;
}

View file

@ -1,7 +0,0 @@
# comment a
# comment b
## comment c
# <-- tab
# Next comment is empty
#
# Non empty

View file

@ -1,7 +0,0 @@
# comment a
# comment b
## comment c
# <-- tab
# Next comment is empty
#
# Non empty

View file

@ -1,3 +0,0 @@
virtual a {
param a b; # comment
}

View file

@ -1,3 +0,0 @@
virtual a {
param a b; # comment
}

View file

@ -1,13 +0,0 @@
virtual a {
option aaa # bbb
aa cc;
param { # comment 1
a b;
c d;
x y z; # comment 2
}
param e f g h; # comment 3
param e f g hlskdjflskdfjsd #comment 4
flksdjf sldkfjsldkfjsdlf
"lsdkfjsldkfjlsdkjflskdjflsdkjfl" "lkjsdlfjsdlfkjsdlfj";
}

View file

@ -1,11 +0,0 @@
virtual a {
option "aaa aa cc";
param { # comment 1
a b;
c d;
x y z; # comment 2
}
param e f g h; # comment 3
param e f g hlskdjflskdfjsd #comment 4
flksdjf sldkfjsldkfjsdlf lsdkfjsldkfjlsdkjflskdjflsdkjfl lkjsdlfjsdlfkjsdlfj;
}

View file

@ -1,3 +0,0 @@
virtual a {
option +xinerama -syncbatch 0;
}

View file

@ -1,3 +0,0 @@
virtual a {
option "+xinerama -syncbatch 0";
}

View file

@ -1,12 +0,0 @@
virtual a {
display d0:0 1x2;
display d1:0 +3+4;
display d2:0 100x200 @1x1;
display d3:0 +3+4 @2x2;
display d4:0 100x200+3+4 @3x3;
display d5:0 / 1x2+3+4;
display d6:0 / 1x2;
display d7:0 / +3+4;
display d8:0 / 1x2+3+4 @4x4;
display d9:0 11x22+33+44 / 111x222+333+444 @1000x1100;
}

View file

@ -1,12 +0,0 @@
virtual a {
display d0:0 1x2;
display d1:0 +3+4;
display d2:0 100x200 @1x1;
display d3:0 +3+4 @2x2;
display d4:0 100x200+3+4 @3x3;
display d5:0 / 1x2+3+4;
display d6:0 / 1x2;
display d7:0 / +3+4;
display d8:0 / 1x2+3+4 @4x4;
display d9:0 11x22+33+44 / 111x222+333+444 @1000x1100;
}

View file

@ -1,57 +0,0 @@
/*
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
#include "dmxconfig.h"
#include "dmxparse.h"
#include "dmxprint.h"
#include "dmxcompat.h"
int main(int argc, char **argv)
{
DMXConfigEntryPtr entry;
FILE *str;
if (argc != 2 && argc !=3) {
fprintf(stderr, "Usage: vdltodmx inFile [outFile]\n");
return 1;
}
if (argc == 2) {
str = stdout;
} else if (!(str = fopen(argv[2], "w"))) {
fprintf(stderr, "Cannot open %s for write\n", argv[2]);
return 2;
}
entry = dmxVDLRead(argv[1]);
dmxConfigPrint(str, entry);
return 0;
}

View file

@ -1,95 +0,0 @@
.\" $XFree86$
.\" Copyright 2002 Red Hat Inc., Durham, North Carolina.
.\" All Rights Reserved.
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
.\" a copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation on the rights to use, copy, modify, merge,
.\" publish, distribute, sublicense, and/or sell copies of the Software,
.\" and to permit persons to whom the Software is furnished to do so,
.\" subject to the following conditions:
.\"
.\" The above copyright notice and this permission notice (including the
.\" next paragraph) shall be included in all copies or substantial
.\" portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
.\" NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
.\" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
.\" ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
.\" SOFTWARE.
.\"
.\" Authors:
.\" Rickard E. (Rik) Faith <faith@redhat.com>
.\"
.TH vdltodmx 1 __vendorversion__
.SH NAME
vdltodmx - dmx configuration file parser and printer
.SH SYNOPSIS
.B vdltodmx
.I infile
.I outfile
.SH DESCRIPTION
.I vdltodmx
reads the input file, which should be in VDL configuration file format.
After a successful parse, a file in Xdmx configuration file format is
written to the output file.
.P
The VDL file format is used with
.IR xmovie ,
which is available from
http://www.llnl.gov/icc/lc/img/xmovie/xmovie.html
.SH EXAMPLE
Given the following VDL-format file:
.RS
.nf
0
2
#
#
2560 2048 Left two-thirds [restrict=*:2]
2
:2.1 1280 2048 0 0 0 0
:2.2 1280 2048 1280 0 0 0
4
1280 1024 0 0
1280 1024 0 1024
1280 1024 1280 0
1280 1024 1280 1024
#
2560 2048 Right two-thirds [restrict=*:2]
2
:2.2 1280 2048 0 0 0 0
:2.3 1280 2048 1280 0 0 0
4
1280 1024 1280 0
1280 1024 1280 1024
1280 1024 2560 0
1280 1024 2560 1024
.fi
.RE
the following DMX-format file will be produced:
.RS
.nf
#
#
virtual "Left two-thirds" 2560x2048 {
display :2.1 1280x2048;
display :2.2 1280x2048 @1280x0;
}
#
virtual "Right two-thirds" 2560x2048 {
display :2.2 1280x2048;
display :2.3 1280x2048 @1280x0;
}
.fi
.RE
.SH BUGS
If the VDL file is not in the expected format, the program will probably
dump core.
.SH "SEE ALSO"
Xdmx(1), xdmxconfig(1), vdl(3), xmovie(1)

File diff suppressed because it is too large Load diff

View file

@ -1,63 +0,0 @@
.\" $XFree86$
.\" Copyright 2002 Red Hat Inc., Durham, North Carolina.
.\" All Rights Reserved.
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
.\" a copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation on the rights to use, copy, modify, merge,
.\" publish, distribute, sublicense, and/or sell copies of the Software,
.\" and to permit persons to whom the Software is furnished to do so,
.\" subject to the following conditions:
.\"
.\" The above copyright notice and this permission notice (including the
.\" next paragraph) shall be included in all copies or substantial
.\" portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
.\" NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
.\" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
.\" ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
.\" SOFTWARE.
.\"
.\" Authors:
.\" Rickard E. (Rik) Faith <faith@redhat.com>
.\"
.TH xdmxconfig 1 __vendorversion__
.SH NAME
xdmxconfig - a graphical configuration tool for Xdmx configuration files
.SH SYNOPSIS
.B xdmxconfig
[filename]
.SH DESCRIPTION
.I xdmxconfig
reads, edits, and writes configuration files for the Xdmx server. The
grammar for the configuration file is specified in the Xdmx(1) manual
page.
.PP
To start from scratch, create a "New Global" and specify the name and
overall dimensions for the configuration. Then use "New Display" to
enter more displays.
.PP
If there is more than one configuration, the configuration name button
will bring up a selection menu.
.PP
In the right-hand pannel, the left mouse button will move the
highlighted display at "tool resolution"; the middle mouse button will
move the highlighted display by a single pixel (at "wall resolution");
and the right mouse button will bring up a menu allowing the highlighted
display to be edited or deleted. The arrow keys will also move the
highlighted display by a single pixel.
.SH BUGS
Currently, entries with the
.B wall
keyword are not editable, but will be preserved in the new output file.
The tool will quit when requested by the user, even if a configuration
file has not been written out (i.e., without warning). The menu
interaction should be improved (menu entries that don't currently work
should be greyed-out, for example). The Help button does not work.
.SH "SEE ALSO"
Xdmx(1), vdltodmx(1)

View file

@ -302,14 +302,14 @@ int dmxGetInputAttributes(int deviceId, DMXInputAttributesPtr attr)
break;
case DMX_LOCAL_TYPE_CONSOLE:
attr->inputType = 1;
attr->name = dmxInput->name;
attr->name = dmxScreens[dmxInput->scrnIdx].name;
attr->physicalId = dmxLocal->deviceId;
break;
case DMX_LOCAL_TYPE_BACKEND:
case DMX_LOCAL_TYPE_COMMON:
attr->inputType = 2;
attr->physicalScreen = dmxInput->scrnIdx;
attr->name = dmxInput->name;
attr->name = dmxScreens[dmxInput->scrnIdx].name;
attr->physicalId = dmxLocal->deviceId;
break;
}

View file

@ -49,7 +49,6 @@
#include "dmxscrinit.h"
#include "dmxcursor.h"
#include "dmxfont.h"
#include "config/dmxconfig.h"
#include "dmxcb.h"
#include "dmxprop.h"
#include "dmxstat.h"
@ -129,6 +128,8 @@ Bool dmxAddRemoveScreens = TRUE;
int dmxLaunchIndex = 0;
char *dmxLaunchVT = NULL;
int dmxNumDetached = 4;
#ifdef RANDR
int xRROutputsPerScreen = 2;
int xRRCrtcsPerScreen = 2;
@ -276,6 +277,66 @@ dmxMemDup (const char *data,
return d;
}
static DMXInputInfo *dmxAddScreenInput(DMXScreenInfo *dmxScreen)
{
DMXInputInfo *dmxInput;
if (!(dmxInputs = realloc(dmxInputs,
(dmxNumInputs+1) * sizeof(*dmxInputs))))
dmxLog(dmxFatal,
"dmxAddInput: realloc failed for input %d (%s)\n",
dmxNumInputs, dmxScreen->name);
dmxInput = &dmxInputs[dmxNumInputs];
memset(dmxInput, 0, sizeof(*dmxInput));
dmxInput->inputIdx = dmxNumInputs;
dmxInput->scrnIdx = dmxScreen->index;
dmxInput->core = TRUE;
++dmxNumInputs;
return dmxInput;
}
DMXScreenInfo *
dmxAddScreen(const char *name,
const char *display,
const char *authType,
int authTypeLen,
const char *authData,
int authDataLen,
int virtualFb)
{
DMXScreenInfo *dmxScreen;
if (!(dmxScreens = realloc(dmxScreens,
(dmxNumScreens+1) * sizeof(*dmxScreens))))
dmxLog(dmxFatal,
"dmxAddScreen: realloc failed for screen %d (%s)\n",
dmxNumScreens, name);
dmxScreen = &dmxScreens[dmxNumScreens];
memset(dmxScreen, 0, sizeof(*dmxScreen));
dmxScreen->name = strdup (name);
dmxScreen->display = strdup (display);
dmxScreen->index = dmxNumScreens;
dmxScreen->scrnWidth = 0;
dmxScreen->scrnHeight = 0;
dmxScreen->rootX = 0;
dmxScreen->rootY = 0;
dmxScreen->stat = dmxStatAlloc();
dmxScreen->authType = dmxMemDup (authType, authTypeLen);
dmxScreen->authTypeLen = authTypeLen;
dmxScreen->authData = dmxMemDup (authData, authDataLen);
dmxScreen->authDataLen = authDataLen;
dmxScreen->virtualFb = virtualFb;
++dmxNumScreens;
if (!virtualFb)
dmxAddScreenInput (dmxScreen);
return dmxScreen;
}
Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen)
{
dmxScreen->beDisplay = NULL;
@ -683,7 +744,7 @@ static const char *dmxExecHost(void)
/** This routine is called in Xserver/dix/main.c from \a main(). */
void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
{
int i;
int i, nDetached;
static unsigned long dmxGeneration = 0;
#ifdef GLXEXT
Bool glxSupported = TRUE;
@ -763,15 +824,24 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
strlen (dmxPropTrans[i].name),
TRUE);
if (!dmxConfigDisplaysFromCommandLine ())
dmxLaunchDisplay (argc, argv, dmxLaunchIndex, dmxLaunchVT);
/* ddxProcessArgument has been called at this point, but any data
* from the configuration file has not been applied. Do so, and be
* sure we have at least one back-end display. */
dmxConfigConfigure();
if (!dmxNumScreens)
dmxLog(dmxFatal, "InitOutput: no back-end displays found\n");
{
dmxLaunchDisplay (argc, argv, dmxLaunchIndex, dmxLaunchVT);
if (!dmxNumScreens)
dmxLog(dmxFatal, "InitOutput: no back-end displays found\n");
}
nDetached = dmxNumDetached;
if (dmxNumScreens + nDetached > MAXSCREENS)
nDetached = MAXSCREENS - dmxNumScreens;
if (nDetached > 0)
{
dmxLog (dmxInfo, "Adding %d detached displays\n", nDetached);
while (nDetached--)
dmxAddScreen ("", "", NULL, 0, NULL, 0, 0);
}
/* Disable lazy window creation optimization if offscreen
* optimization is disabled */
@ -1044,17 +1114,10 @@ int ddxProcessArgument(int argc, char *argv[], int i)
int retval = 0;
if (!strcmp(argv[i], "-display")) {
if (++i < argc) dmxConfigStoreDisplay(argv[i], argv[i],
NULL, 0, NULL, 0, 0);
if (++i < argc) dmxAddScreen(argv[i], argv[i], NULL, 0, NULL, 0, 0);
retval = 2;
} else if (!strcmp(argv[i], "-numDetached")) {
if (++i < argc) dmxConfigStoreNumDetached(argv[i]);
retval = 2;
} else if (!strcmp(argv[i], "-inputfrom") || !strcmp(argv[i], "-input")) {
if (++i < argc) dmxConfigStoreInput(argv[i]);
retval = 2;
} else if (!strcmp(argv[i], "-xinputfrom") || !strcmp(argv[i],"-xinput")) {
if (++i < argc) dmxConfigStoreXInput(argv[i]);
if (++i < argc) dmxNumDetached = atoi (argv[i]);
retval = 2;
} else if (!strcmp(argv[i], "-noshadowfb")) {
dmxLog(dmxWarning,
@ -1065,12 +1128,6 @@ int ddxProcessArgument(int argc, char *argv[], int i)
} else if (!strcmp(argv[i], "-shadowfb")) {
dmxShadowFB = TRUE;
retval = 1;
} else if (!strcmp(argv[i], "-configfile")) {
if (++i < argc) dmxConfigStoreFile(argv[i]);
retval = 2;
} else if (!strcmp(argv[i], "-config")) {
if (++i < argc) dmxConfigStoreConfig(argv[i]);
retval = 2;
} else if (!strcmp(argv[i], "-fontpath")) {
if (++i < argc) dmxSetDefaultFontPath(argv[i]);
retval = 2;
@ -1130,26 +1187,8 @@ int ddxProcessArgument(int argc, char *argv[], int i)
} else if (!strcmp(argv[i], "-crtcs")) {
if (++i < argc) xRRCrtcsPerScreen = atoi(argv[i]);
retval = 2;
#endif
} else if (!strcmp(argv[i], "-param")) {
if ((i += 2) < argc) {
if (!strcasecmp(argv[i-1], "xkbrules"))
dmxConfigSetXkbRules(argv[i]);
else if (!strcasecmp(argv[i-1], "xkbmodel"))
dmxConfigSetXkbModel(argv[i]);
else if (!strcasecmp(argv[i-1], "xkblayout"))
dmxConfigSetXkbLayout(argv[i]);
else if (!strcasecmp(argv[i-1], "xkbvariant"))
dmxConfigSetXkbVariant(argv[i]);
else if (!strcasecmp(argv[i-1], "xkboptions"))
dmxConfigSetXkbOptions(argv[i]);
else
dmxLog(dmxWarning,
"-param requires: XkbRules, XkbModel, XkbLayout,"
" XkbVariant, or XkbOptions\n");
}
retval = 3;
}
#endif
else if (!strcmp (argv[i], "-prop"))
{
if ((i + 2) < argc)
@ -1201,7 +1240,6 @@ int ddxProcessArgument(int argc, char *argv[], int i)
retval = argc - i;
}
if (!serverGeneration) dmxConfigSetMaxScreens();
return retval;
}
@ -1211,11 +1249,7 @@ void ddxUseMsg(void)
ErrorF("\n\nDevice Dependent Usage:\n");
ErrorF("-display string Specify the back-end display(s)\n");
ErrorF("-numDetached num Specify detached back-end display(s)\n");
ErrorF("-input string Specify input source for core device\n");
ErrorF("-xinput string Specify input source for XInput device\n");
ErrorF("-shadowfb Enable shadow frame buffer\n");
ErrorF("-configfile file Read from a configuration file\n");
ErrorF("-config config Select a specific configuration\n");
ErrorF("-fontpath Sets the default font path\n");
ErrorF("-stat inter scrns Print out performance statistics\n");
ErrorF("-syncbatch inter Set interval for XSync batching\n");
@ -1240,41 +1274,9 @@ void ddxUseMsg(void)
ErrorF("-outputs num RANDR outputs for each back-end display\n");
ErrorF("-crtcs num RANDR crtcs for each back-end display\n");
#endif
ErrorF("-param ... Specify configuration parameters (e.g.,\n");
ErrorF(" XkbRules, XkbModel, XkbLayout, etc.)\n");
ErrorF("-prop name format Specify property translation\n");
#ifdef XV
ErrorF("-xvimage fourcc Enable XVideo image format\n");
#endif
ErrorF("\n");
ErrorF(" If the -input string matches a -display string, then input\n"
" is taken from that backend display. (XInput cannot be taken\n"
" from a backend display.) Placing \",console\" after the\n"
" display name will force a console window to be opened on\n"
" that display in addition to the backend input. This is\n"
" useful if the backend window does not cover the whole\n"
" physical display.\n\n");
ErrorF(" Otherwise, if the -input or -xinput string specifies another\n"
" X display, then a console window will be created on that\n"
" display. Placing \",windows\" or \",nowindows\" after the\n"
" display name will control the display of window outlines in\n"
" the console.\n\n");
ErrorF(" -input or -xinput dummy specifies no input.\n");
ErrorF(" -input or -xinput local specifies the use of a raw keyboard,\n"
" mouse, or other (extension) device:\n"
" -input local,kbd,ps2 will use a ps2 mouse\n"
" -input local,kbd,ms will use a serial mouse\n"
" -input local,usb-kbd,usb-mou will use USB devices \n"
" -xinput local,usb-oth will use a non-mouse and\n"
" non-keyboard USB device with XInput\n\n");
ErrorF(" Special Keys:\n");
ErrorF(" Ctrl-Alt-g Server grab/ungrab (console only)\n");
ErrorF(" Ctrl-Alt-f Fine (1-pixel) mouse mode (console only)\n");
ErrorF(" Ctrl-Alt-q Quit (core devices only)\n");
ErrorF(" Ctrl-Alt-F* Switch to VC (local only)\n\n");
ErrorF("-- [ server ] [ display ] [ options ]\n");
}

View file

@ -38,7 +38,13 @@
#define DMXINIT_H
#include "scrnintstr.h"
extern DMXScreenInfo *dmxAddScreen(const char *name,
const char *display,
const char *authType,
int authTypeLen,
const char *authData,
int authDataLen,
int virtualFb);
extern Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen);
extern void dmxCloseDisplay(DMXScreenInfo *dmxScreen);
extern void dmxSetErrorHandler(DMXScreenInfo *dmxScreen);

View file

@ -121,10 +121,6 @@ typedef enum {
* access to the global pointers. However, the elements are only
* available to input-related routines. */
struct _DMXInputInfo {
const char *name; /**< Name of input display or device
* (from command line or config
* file) */
Bool freename; /**< If true, free name on destroy */
Bool detached; /**< If true, input screen is detached */
int inputIdx; /**< Index into #dmxInputs global */
int scrnIdx; /**< Index into #dmxScreens global */
@ -210,7 +206,4 @@ extern DMXScreenInfo *dmxFindFirstScreen(int x, int y);
extern void dmxCoreMotion(DevicePtr pDev, int x, int y, int delta,
DMXBlockType block);
/* Support for dynamic addition of inputs. This functions is defined in
* config/dmxconfig.c */
extern DMXInputInfo *dmxConfigAddInput(const char *name, int core);
#endif /* DMXINPUT_H */

View file

@ -26,7 +26,7 @@
#include "dmx.h"
#include "dmxlaunch.h"
#include "config/dmxconfig.h"
#include "dmxinit.h"
#include "opaque.h"
#include <X11/Xauth.h>
@ -261,13 +261,13 @@ dmxSetupAuth (char *name, int authFd)
strcmp (basename (realProg), "Xfake") == 0)
virtualFb = TRUE;
dmxConfigStoreDisplay (basename (realProg),
xbeDisplay,
auth.name,
auth.name_length,
auth.data,
auth.data_length,
virtualFb);
dmxAddScreen (basename (realProg),
xbeDisplay,
auth.name,
auth.name_length,
auth.data,
auth.data_length,
virtualFb);
return TRUE;
}

View file

@ -126,19 +126,14 @@ static void dmxHeader(dmxLogLevel logLevel, DMXInputInfo *dmxInput,
if (dmxInput && dmxScreen) {
ErrorF("(%s) dmx[i%d/%s;o%d/%s/%s]: ", type,
dmxInput->inputIdx, dmxInput->name,
dmxInput->inputIdx, dmxScreens[dmxInput->scrnIdx].name,
dmxScreen->index, dmxScreen->display, dmxScreen->name);
} else if (dmxScreen) {
ErrorF("(%s) dmx[o%d/%s/%s]: ", type,
dmxScreen->index, dmxScreen->display, dmxScreen->name);
} else if (dmxInput) {
const char *pt = strchr(dmxInput->name, ',');
int len = (pt
? (size_t)(pt-dmxInput->name)
: strlen(dmxInput->name));
ErrorF("(%s) dmx[i%d/%*.*s]: ", type,
dmxInput->inputIdx, len, len, dmxInput->name);
ErrorF("(%s) dmx[i%d/%s]: ", type,
dmxInput->inputIdx, dmxScreens[dmxInput->scrnIdx].name);
} else {
ErrorF("(%s) dmx: ", type);
}

View file

@ -894,11 +894,6 @@ static DMXScreenInfo *dmxBackendInitPrivate(DevicePtr pDev)
}
}
if (i >= dmxNumScreens)
dmxLog(dmxFatal,
"%s is not an existing backend display - cannot initialize\n",
dmxInput->name);
return dmxScreen;
}

View file

@ -311,7 +311,7 @@ int dmxCommonKbdOn(DevicePtr pDev)
dmxLocal->deviceId))) {
dmxLog(dmxWarning, "Cannot open %s device (id=%d) on %s\n",
dmxLocal->deviceName ? dmxLocal->deviceName : "(unknown)",
dmxLocal->deviceId, dmxInput->name);
dmxLocal->deviceId, dmxScreens[dmxInput->scrnIdx].name);
return -1;
}
@ -385,13 +385,14 @@ int dmxCommonOthOn(DevicePtr pDev)
} \
} else { \
dmxLog(dmxWarning, "More than %d event types for %s\n", \
DMX_MAX_XINPUT_EVENT_TYPES, dmxInput->name); \
DMX_MAX_XINPUT_EVENT_TYPES, \
dmxScreens[dmxInput->scrnIdx].name); \
}
if (!(priv->xi = XOpenDevice(priv->display, dmxLocal->deviceId))) {
dmxLog(dmxWarning, "Cannot open %s device (id=%d) on %s\n",
dmxLocal->deviceName ? dmxLocal->deviceName : "(unknown)",
dmxLocal->deviceId, dmxInput->name);
dmxLocal->deviceId, dmxScreens[dmxInput->scrnIdx].name);
return -1;
}
ADD(DeviceKeyPress);
@ -434,7 +435,7 @@ void dmxCommonOthGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
int i, j, k;
int (*handler)(Display *, char *, char *);
if (!display && !(display = XOpenDisplay(dmxInput->name)))
if (!display)
return;
/* Print out information about the XInput Extension. */
@ -535,7 +536,7 @@ int dmxCommonMouOn(DevicePtr pDev)
dmxLocal->deviceId))) {
dmxLog(dmxWarning, "Cannot open %s device (id=%d) on %s\n",
dmxLocal->deviceName ? dmxLocal->deviceName : "(unknown)",
dmxLocal->deviceId, dmxInput->name);
dmxLocal->deviceId, dmxScreens[dmxInput->scrnIdx].name);
return -1;
}

View file

@ -733,10 +733,7 @@ void dmxConsoleInit(DevicePtr pDev)
if (dmxLocal->type == DMX_LOCAL_KEYBOARD) priv->kbd = pDev;
if (priv->initialized++) return; /* Only do once for mouse/keyboard pair */
if (!(dpy = priv->display = XOpenDisplay(dmxInput->name)))
dmxLog(dmxFatal,
"dmxOpenConsole: cannot open console display %s\n",
dmxInput->name);
dmxLog(dmxFatal, "dmxOpenConsole: cannot open console display\n");
/* Set up defaults */
dmxConsoleComputeWidthHeight(priv,

View file

@ -53,7 +53,6 @@
#include "dmxmotion.h"
#include "dmxeq.h"
#include "dmxprop.h"
#include "config/dmxconfig.h"
#include "dmxcursor.h"
#include "lnx-keyboard.h"
@ -395,11 +394,7 @@ static void dmxKeyboardFreeNames(XkbComponentNamesPtr names)
static int dmxKeyboardOn(DeviceIntPtr pDevice, DMXLocalInitInfo *info)
{
#ifdef XKB
GETDMXINPUTFROMPDEVICE;
#else
DevicePtr pDev = &pDevice->public;
#endif
#ifdef XKB
if (noXkbExtension) {
@ -410,47 +405,6 @@ static int dmxKeyboardOn(DeviceIntPtr pDevice, DMXLocalInitInfo *info)
return BadImplementation;
#ifdef XKB
} else {
XkbSetRulesDflts(dmxConfigGetXkbRules(),
dmxConfigGetXkbModel(),
dmxConfigGetXkbLayout(),
dmxConfigGetXkbVariant(),
dmxConfigGetXkbOptions());
if (!info->force && (dmxInput->keycodes
|| dmxInput->symbols
|| dmxInput->geometry)) {
if (info->freenames) dmxKeyboardFreeNames(&info->names);
info->freenames = 0;
info->names.keycodes = dmxInput->keycodes;
info->names.types = NULL;
info->names.compat = NULL;
info->names.symbols = dmxInput->symbols;
info->names.geometry = dmxInput->geometry;
dmxLogInput(dmxInput, "XKEYBOARD: From command line: %s",
info->names.keycodes);
if (info->names.symbols && *info->names.symbols)
dmxLogInputCont(dmxInput, " %s", info->names.symbols);
if (info->names.geometry && *info->names.geometry)
dmxLogInputCont(dmxInput, " %s", info->names.geometry);
dmxLogInputCont(dmxInput, "\n");
} else if (info->names.keycodes) {
dmxLogInput(dmxInput, "XKEYBOARD: From device: %s",
info->names.keycodes);
if (info->names.symbols && *info->names.symbols)
dmxLogInputCont(dmxInput, " %s", info->names.symbols);
if (info->names.geometry && *info->names.geometry)
dmxLogInputCont(dmxInput, " %s", info->names.geometry);
dmxLogInputCont(dmxInput, "\n");
} else {
dmxLogInput(dmxInput, "XKEYBOARD: Defaults: %s %s %s %s %s\n",
dmxConfigGetXkbRules(),
dmxConfigGetXkbLayout(),
dmxConfigGetXkbModel(),
dmxConfigGetXkbVariant()
? dmxConfigGetXkbVariant() : "",
dmxConfigGetXkbOptions()
? dmxConfigGetXkbOptions() : "");
}
XkbInitKeyboardDeviceStruct(pDevice,
&info->names,
&info->keySyms,
@ -805,40 +759,47 @@ static char *dmxMakeUniqueDeviceName(DMXLocalInputInfoPtr dmxLocal)
if (dmxLocal->deviceName)
{
buf = xalloc (strlen (dmxInput->name) +
buf = xalloc (strlen (dmxScreens[dmxInput->scrnIdx].name) +
strlen (dmxLocal->deviceName) + 4);
if (buf)
{
sprintf (buf, "%s's %s", dmxInput->name, dmxLocal->deviceName);
sprintf (buf, "%s's %s", dmxScreens[dmxInput->scrnIdx].name,
dmxLocal->deviceName);
return buf;
}
}
#define LEN 32
buf = xalloc (strlen (dmxInput->name) + LEN);
buf = xalloc (strlen (dmxScreens[dmxInput->scrnIdx].name) + LEN);
if (buf)
{
switch (dmxLocal->type) {
case DMX_LOCAL_KEYBOARD:
if (dmxInput->k)
sprintf (buf, "%s's keyboard%d", dmxInput->name, dmxInput->k);
sprintf (buf, "%s's keyboard%d",
dmxScreens[dmxInput->scrnIdx].name, dmxInput->k);
else
sprintf (buf, "%s's keyboard", dmxInput->name);
sprintf (buf, "%s's keyboard",
dmxScreens[dmxInput->scrnIdx].name);
dmxInput->k++;
break;
case DMX_LOCAL_MOUSE:
if (dmxInput->m)
sprintf (buf, "%s's pointer%d", dmxInput->name, dmxInput->m);
sprintf (buf, "%s's pointer%d",
dmxScreens[dmxInput->scrnIdx].name, dmxInput->m);
else
sprintf (buf, "%s's pointer", dmxInput->name);
sprintf (buf, "%s's pointer",
dmxScreens[dmxInput->scrnIdx].name);
dmxInput->m++;
break;
default:
if (dmxInput->o)
sprintf (buf, "%s's input device%d", dmxInput->name, dmxInput->o);
sprintf (buf, "%s's input device%d",
dmxScreens[dmxInput->scrnIdx].name, dmxInput->o);
else
sprintf (buf, "%s's input device", dmxInput->name);
sprintf (buf, "%s's input device",
dmxScreens[dmxInput->scrnIdx].name);
dmxInput->o++;
break;
}
@ -1008,7 +969,7 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI)
XQueryExtension (display, INAME, &i, &dmxInput->eventBase, &i);
dmxLogInput(dmxInput, "Locating devices on %s (%s version %d.%d)\n",
dmxInput->name, INAME,
dmxScreens[dmxInput->scrnIdx].name, INAME,
ext->major_version, ext->minor_version);
devices = XListInputDevices(display, &num);
@ -1121,91 +1082,25 @@ void dmxInputLateReInit(DMXInputInfo *dmxInput)
/** Initialize all of the devices described in \a dmxInput. */
void dmxInputInit(DMXInputInfo *dmxInput)
{
dmxArg a;
const char *name;
int i;
int doXI = 1; /* Include by default */
int forceConsole = 0;
int doWindows = 1; /* On by default */
int hasXkb = 0;
int i;
int doXI = 1; /* Include by default */
int found;
dmxInput->k = dmxInput->m = dmxInput->o = 0;
a = dmxArgParse(dmxInput->name);
for (i = 1; i < dmxArgC(a); i++) {
switch (hasXkb) {
case 1:
dmxInput->keycodes = xstrdup(dmxArgV(a, i));
++hasXkb;
break;
case 2:
dmxInput->symbols = xstrdup(dmxArgV(a, i));
++hasXkb;
break;
case 3:
dmxInput->geometry = xstrdup(dmxArgV(a, i));
hasXkb = 0;
break;
case 0:
if (!strcmp(dmxArgV(a, i), "noxi")) doXI = 0;
else if (!strcmp(dmxArgV(a, i), "xi")) doXI = 1;
else if (!strcmp(dmxArgV(a, i), "console")) forceConsole = 1;
else if (!strcmp(dmxArgV(a, i), "noconsole")) forceConsole = 0;
else if (!strcmp(dmxArgV(a, i), "windows")) doWindows = 1;
else if (!strcmp(dmxArgV(a, i), "nowindows")) doWindows = 0;
else if (!strcmp(dmxArgV(a, i), "xkb")) hasXkb = 1;
else {
dmxLog(dmxFatal,
"Unknown input argument: %s\n", dmxArgV(a, i));
}
}
for (found = 0, i = 0; i < dmxNumScreens; i++) {
if (dmxInput->scrnIdx == i) {
dmxInputCopyLocal(dmxInput, &DMXBackendMou);
dmxInputCopyLocal(dmxInput, &DMXBackendKbd);
dmxLogInput(dmxInput,
"Using backend input from %s at %d\n",
dmxScreens[i].name, i);
++found;
break;
}
}
name = dmxArgV(a, 0);
if (!strcmp(name, "local")) {
dmxPopulateLocal(dmxInput, a);
} else if (!strcmp(name, "dummy")) {
dmxInputCopyLocal(dmxInput, &DMXDummyMou);
dmxInputCopyLocal(dmxInput, &DMXDummyKbd);
dmxLogInput(dmxInput, "Using dummy input\n");
} else {
int found;
for (found = 0, i = 0; i < dmxNumScreens; i++) {
if (dmxInput->scrnIdx == i) {
char *pt;
for (pt = (char *)dmxInput->name; pt && *pt; pt++)
if (*pt == ',') *pt = '\0';
dmxInputCopyLocal(dmxInput, &DMXBackendMou);
dmxInputCopyLocal(dmxInput, &DMXBackendKbd);
dmxLogInput(dmxInput,
"Using backend input from %s at %d\n", name, i);
++found;
break;
}
}
if (!found || forceConsole) {
char *pt;
if (found) dmxInput->console = TRUE;
for (pt = (char *)dmxInput->name; pt && *pt; pt++)
if (*pt == ',') *pt = '\0';
dmxInputCopyLocal(dmxInput, &DMXConsoleMou);
dmxInputCopyLocal(dmxInput, &DMXConsoleKbd);
if (doWindows) {
dmxInput->windows = TRUE;
dmxInput->updateWindowInfo = dmxUpdateWindowInformation;
}
dmxLogInput(dmxInput,
"Using console input from %s (%s windows)\n",
name, doWindows ? "with" : "without");
}
}
dmxArgFree(a);
/* Locate extensions we may be interested in */
/* Locate extensions we may be interested in */
dmxInputScanForExtensions(dmxInput, doXI);
for (i = 0; i < dmxInput->numDevs; i++) {
@ -1265,9 +1160,6 @@ void dmxInputFree(DMXInputInfo *dmxInput)
if (!dmxInput) return;
dmxInputFini (dmxInput);
if (dmxInput->freename) xfree(dmxInput->name);
dmxInput->name = NULL;
}
/** Log information about all of the known devices using #dmxLog(). */
@ -1279,12 +1171,8 @@ void dmxInputLogDevices(void)
dmxLog(dmxInfo, " Id Name Classes\n");
for (j = 0; j < dmxNumInputs; j++) {
DMXInputInfo *dmxInput = &dmxInputs[j];
const char *pt = strchr(dmxInput->name, ',');
int len = (pt
? (size_t)(pt-dmxInput->name)
: strlen(dmxInput->name));
for (i = 0; i < dmxInput->numDevs; i++) {
for (i = 0; i < dmxInput->numDevs; i++) {
DeviceIntPtr pDevice = dmxInput->devs[i]->pDevice;
if (pDevice) {
dmxLog(dmxInfo, " %2d%c %-20.20s",
@ -1307,8 +1195,9 @@ void dmxInputLogDevices(void)
&& !pDevice->stringfeed && !pDevice->bell
&& !pDevice->leds) dmxLogCont(dmxInfo, " (none)");
dmxLogCont(dmxInfo, "\t[i%d/%*.*s",
dmxInput->inputIdx, len, len, dmxInput->name);
dmxLogCont(dmxInfo, "\t[i%d/%s",
dmxInput->inputIdx,
dmxScreens[dmxInput->scrnIdx].name);
if (dmxInput->devs[i]->deviceId >= 0)
dmxLogCont(dmxInfo, "/id%d", dmxInput->devs[i]->deviceId);
if (dmxInput->devs[i]->attached >= 0)
@ -1417,25 +1306,7 @@ static int dmxInputAttach(DMXInputInfo *dmxInput, int *id)
int dmxInputAttachConsole(const char *name, int isCore, int *id)
{
DMXInputInfo *dmxInput;
int i;
for (i = 0; i < dmxNumInputs; i++) {
dmxInput = &dmxInputs[i];
if (dmxInput->scrnIdx == -1
&& dmxInput->detached
&& !strcmp(dmxInput->name, name)) {
/* Found match */
dmxLogInput(dmxInput, "Reattaching detached console input\n");
return dmxInputAttach(dmxInput, id);
}
}
/* No match found */
dmxInput = dmxConfigAddInput(xstrdup(name), isCore);
dmxInput->freename = TRUE;
dmxLogInput(dmxInput, "Attaching new console input\n");
return dmxInputAttach(dmxInput, id);
return BadImplementation;
}
int dmxInputAttachBackend(int physicalScreen, int isCore, int *id)
@ -1447,8 +1318,8 @@ int dmxInputAttachBackend(int physicalScreen, int isCore, int *id)
if (physicalScreen < 0 || physicalScreen >= dmxNumScreens) return BadValue;
for (i = 0; i < dmxNumInputs; i++) {
dmxInput = &dmxInputs[i];
if (dmxInput->scrnIdx != -1 && dmxInput->scrnIdx == physicalScreen) {
/* Found match */
if (dmxInput->scrnIdx == physicalScreen) {
/* Found match */
if (!dmxInput->detached) return BadAccess; /* Already attached */
dmxScreen = &dmxScreens[physicalScreen];
if (!dmxScreen->beDisplay) return BadAccess; /* Screen detached */
@ -1456,12 +1327,5 @@ int dmxInputAttachBackend(int physicalScreen, int isCore, int *id)
return dmxInputAttach(dmxInput, id);
}
}
/* No match found */
dmxScreen = &dmxScreens[physicalScreen];
if (!dmxScreen->beDisplay) return BadAccess; /* Screen detached */
dmxInput = dmxConfigAddInput(xstrdup (dmxScreen->name), isCore);
dmxInput->freename = TRUE;
dmxInput->scrnIdx = physicalScreen;
dmxLogInput(dmxInput, "Attaching new backend input\n");
return dmxInputAttach(dmxInput, id);
return BadImplementation;
}