summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authorfaith <faith>2002-04-30 02:37:50 +0000
committerfaith <faith>2002-04-30 02:37:50 +0000
commitbfb50bff496bc740b836e66eadc26c9638466c5c (patch)
tree008205983b4e4175a906d542309d3aa69230265d /xc
parent884dd97912e22b7fbbd8d339013e64262a138621 (diff)
Rename dmxconfigfile.* dmxconfig.*
Diffstat (limited to 'xc')
-rw-r--r--xc/programs/Xserver/hw/dmx/config/dmxconfig.c182
-rw-r--r--xc/programs/Xserver/hw/dmx/config/dmxconfig.h10
-rw-r--r--xc/programs/Xserver/hw/dmx/config/dmxconfigfile.c220
-rw-r--r--xc/programs/Xserver/hw/dmx/dmxconfigfile.h42
4 files changed, 184 insertions, 270 deletions
diff --git a/xc/programs/Xserver/hw/dmx/config/dmxconfig.c b/xc/programs/Xserver/hw/dmx/config/dmxconfig.c
index a7c711dc8..520accdd3 100644
--- a/xc/programs/Xserver/hw/dmx/config/dmxconfig.c
+++ b/xc/programs/Xserver/hw/dmx/config/dmxconfig.c
@@ -30,19 +30,191 @@
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
+ * This is the interface to the upper-level dmx code.
+ *
*/
+#include "dmx.h"
+#include "dmxconfigfile.h"
#include "dmxconfig.h"
#include "dmxparse.h"
-#include "dmxprint.h"
+#include "dmxlog.h"
+#include "dmxcb.h"
DMXConfigEntryPtr dmxConfigEntry;
+static const char *dmxConfigName;
+static const char *dmxConfigFileName;
-int main(int argc, char **argv)
+int dmxConfigReadFile(const char *filename, int debug)
{
-
- yydebug = 0;
+ FILE *str;
+
+ if (!(str = fopen(filename, "r"))) return -1;
+ yyin = str;
+ yydebug = debug;
yyparse();
- dmxConfigPrint(dmxConfigEntry);
+ fclose(str);
+ dmxLog(dmxInfo, "Read configuration file %s\n", filename);
return 0;
}
+
+void dmxConfigSelect(const char *name)
+{
+ dmxConfigName = name;
+}
+
+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 && !dmxConfigName) return v->name ? v->name : "<noname>";
+ if (!name) return NULL;
+ if (!strcmp(name, target)) return name;
+ return NULL;
+}
+
+static void dmxConfigCopyFromDisplay(DMXConfigDisplayPtr d)
+{
+ DMXScreenInfo *dmxScreen;
+
+ if (!(dmxScreens = realloc(dmxScreens,
+ (dmxNumScreens+1) * sizeof(*dmxScreens))))
+ dmxLog(dmxFatal,
+ "dmxConfigCopyFromDisplay: realloc failed for screen %d (%s)\n",
+ dmxNumScreens, d->name);
+
+ dmxScreen = &dmxScreens[dmxNumScreens];
+ memset(dmxScreen, 0, sizeof(*dmxScreen));
+ dmxScreen->name = d->name;
+ dmxScreen->index = dmxNumScreens;
+ dmxScreen->width = d->width;
+ dmxScreen->height = d->height;
+ dmxScreen->where = PosAbsolute;
+ dmxScreen->whereX = d->xoff;
+ dmxScreen->whereY = d->yoff;
+ ++dmxNumScreens;
+}
+
+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) {
+ if (!(dmxScreens = realloc(dmxScreens,
+ (dmxNumScreens+1) * sizeof(*dmxScreens))))
+ dmxLog(dmxFatal,
+ "dmxConfigCopyFromWall:"
+ " realloc failed for screen %d (%s)\n",
+ dmxNumScreens, pt->string);
+
+ dmxScreen = &dmxScreens[dmxNumScreens];
+ memset(dmxScreen, 0, sizeof(*dmxScreen));
+ dmxScreen->name = pt->string;
+ dmxScreen->index = dmxNumScreens;
+ dmxScreen->width = w->width;
+ dmxScreen->height = w->height;
+ 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 % w->xwall)) {
+ dmxScreen->where = PosBelow;
+ dmxScreen->whereRefScreen = edge;
+ edge = dmxNumScreens;
+ } else {
+ dmxScreen->where = PosRightOf;
+ dmxScreen->whereRefScreen = last;
+ }
+ } else { /* Tile top to bottom, then left to right */
+ if (!(dmxNumScreens % w->ywall)) {
+ dmxScreen->where = PosRightOf;
+ dmxScreen->whereRefScreen = edge;
+ edge = dmxNumScreens;
+ } else {
+ dmxScreen->where = Below;
+ dmxScreen->whereRefScreen = last;
+ }
+
+ }
+ last = dmxNumScreens++;
+ dmxLog(dmxDebug, "Added %s\n", pt->string);
+ }
+}
+
+static void dmxConfigCopyData(DMXConfigVirtualPtr v)
+{
+ DMXConfigSubPtr sub;
+
+ if (v->dim) dmxSetWidthHeight(v->dim->x, v->dim->y);
+ for (sub = v->subentry; sub; sub = sub->next) {
+ switch (sub->type) {
+ case dmxConfigDisplay: dmxConfigCopyFromDisplay(sub->display); break;
+ case dmxConfigWall: dmxConfigCopyFromWall(sub->wall); break;
+ default:
+ dmxLog(dmxFatal,
+ "dmxConfigCopyData: neither a display nor a wall\n");
+ }
+ }
+}
+
+static void dmxConfigFromCommandLine(void)
+{
+ int i;
+
+ /* Position the screen origins. Assume for now that they are in a
+ * single row with the lowest number screen at the left.
+ */
+ dmxScreens[0].where = PosAbsolute;
+ dmxScreens[0].whereX = 0;
+ dmxScreens[0].whereY = 0;
+ for (i = 1; i < dmxNumScreens; i++) {
+ dmxScreens[i].where = PosRightOf;
+ dmxScreens[i].whereRefScreen = i - 1;
+ }
+}
+
+void dmxConfigConfigure(void)
+{
+ DMXConfigEntryPtr pt;
+ const char *name;
+ static int fromConfigFile = 0;
+
+ if (!fromConfigFile && dmxNumScreens) {
+ if (dmxConfigEntry || dmxConfigName) {
+ dmxLog(dmxWarning,
+ "Configuration file ignored when -display used\n");
+ }
+ dmxConfigFromCommandLine();
+ return;
+ }
+ if (!dmxConfigEntry) {
+ if (dmxConfigName)
+ dmxLog(dmxWarning,
+ "Configuration name without configuration file\n");
+ return;
+ }
+ for (pt = dmxConfigEntry; pt; pt = pt->next) {
+ if (pt->type != dmxConfigVirtual) continue;
+ if ((name = dmxConfigMatch(dmxConfigName, pt))) {
+ dmxLog(dmxInfo, "Using configuration \"%s\"\n", name);
+ dmxConfigCopyData(pt->virtual);
+ ++fromConfigFile;
+ return;
+ }
+ }
+ dmxLog(dmxFatal, "Could not find configuration \"%s\" in \"%s\"\n",
+ dmxConfigName, dmxConfigFileName);
+}
diff --git a/xc/programs/Xserver/hw/dmx/config/dmxconfig.h b/xc/programs/Xserver/hw/dmx/config/dmxconfig.h
index 471a787c0..5e1882ab1 100644
--- a/xc/programs/Xserver/hw/dmx/config/dmxconfig.h
+++ b/xc/programs/Xserver/hw/dmx/config/dmxconfig.h
@@ -30,9 +30,13 @@
* Authors:
* Rickard E. (Rik) Faith <faith@redhat.com>
*
+ * See config/dmxconfigfile.c for the code to this API.
+ *
*/
-#ifndef _DMXCONFIG_H_
-#define _DMXCONFIG_H_
-
+#ifndef _DMXCONFIGFILE_H_
+#define _DMXCONFIGFILE_H_
+extern int dmxConfigReadFile(const char *filename, int debug);
+extern void dmxConfigSelect(const char *name);
+extern void dmxConfigConfigure(void);
#endif
diff --git a/xc/programs/Xserver/hw/dmx/config/dmxconfigfile.c b/xc/programs/Xserver/hw/dmx/config/dmxconfigfile.c
deleted file mode 100644
index 520accdd3..000000000
--- a/xc/programs/Xserver/hw/dmx/config/dmxconfigfile.c
+++ /dev/null
@@ -1,220 +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>
- *
- * This is the interface to the upper-level dmx code.
- *
- */
-
-#include "dmx.h"
-#include "dmxconfigfile.h"
-#include "dmxconfig.h"
-#include "dmxparse.h"
-#include "dmxlog.h"
-#include "dmxcb.h"
-
-DMXConfigEntryPtr dmxConfigEntry;
-static const char *dmxConfigName;
-static const char *dmxConfigFileName;
-
-int dmxConfigReadFile(const char *filename, int debug)
-{
- FILE *str;
-
- if (!(str = fopen(filename, "r"))) return -1;
- yyin = str;
- yydebug = debug;
- yyparse();
- fclose(str);
- dmxLog(dmxInfo, "Read configuration file %s\n", filename);
- return 0;
-}
-
-void dmxConfigSelect(const char *name)
-{
- dmxConfigName = name;
-}
-
-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 && !dmxConfigName) return v->name ? v->name : "<noname>";
- if (!name) return NULL;
- if (!strcmp(name, target)) return name;
- return NULL;
-}
-
-static void dmxConfigCopyFromDisplay(DMXConfigDisplayPtr d)
-{
- DMXScreenInfo *dmxScreen;
-
- if (!(dmxScreens = realloc(dmxScreens,
- (dmxNumScreens+1) * sizeof(*dmxScreens))))
- dmxLog(dmxFatal,
- "dmxConfigCopyFromDisplay: realloc failed for screen %d (%s)\n",
- dmxNumScreens, d->name);
-
- dmxScreen = &dmxScreens[dmxNumScreens];
- memset(dmxScreen, 0, sizeof(*dmxScreen));
- dmxScreen->name = d->name;
- dmxScreen->index = dmxNumScreens;
- dmxScreen->width = d->width;
- dmxScreen->height = d->height;
- dmxScreen->where = PosAbsolute;
- dmxScreen->whereX = d->xoff;
- dmxScreen->whereY = d->yoff;
- ++dmxNumScreens;
-}
-
-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) {
- if (!(dmxScreens = realloc(dmxScreens,
- (dmxNumScreens+1) * sizeof(*dmxScreens))))
- dmxLog(dmxFatal,
- "dmxConfigCopyFromWall:"
- " realloc failed for screen %d (%s)\n",
- dmxNumScreens, pt->string);
-
- dmxScreen = &dmxScreens[dmxNumScreens];
- memset(dmxScreen, 0, sizeof(*dmxScreen));
- dmxScreen->name = pt->string;
- dmxScreen->index = dmxNumScreens;
- dmxScreen->width = w->width;
- dmxScreen->height = w->height;
- 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 % w->xwall)) {
- dmxScreen->where = PosBelow;
- dmxScreen->whereRefScreen = edge;
- edge = dmxNumScreens;
- } else {
- dmxScreen->where = PosRightOf;
- dmxScreen->whereRefScreen = last;
- }
- } else { /* Tile top to bottom, then left to right */
- if (!(dmxNumScreens % w->ywall)) {
- dmxScreen->where = PosRightOf;
- dmxScreen->whereRefScreen = edge;
- edge = dmxNumScreens;
- } else {
- dmxScreen->where = Below;
- dmxScreen->whereRefScreen = last;
- }
-
- }
- last = dmxNumScreens++;
- dmxLog(dmxDebug, "Added %s\n", pt->string);
- }
-}
-
-static void dmxConfigCopyData(DMXConfigVirtualPtr v)
-{
- DMXConfigSubPtr sub;
-
- if (v->dim) dmxSetWidthHeight(v->dim->x, v->dim->y);
- for (sub = v->subentry; sub; sub = sub->next) {
- switch (sub->type) {
- case dmxConfigDisplay: dmxConfigCopyFromDisplay(sub->display); break;
- case dmxConfigWall: dmxConfigCopyFromWall(sub->wall); break;
- default:
- dmxLog(dmxFatal,
- "dmxConfigCopyData: neither a display nor a wall\n");
- }
- }
-}
-
-static void dmxConfigFromCommandLine(void)
-{
- int i;
-
- /* Position the screen origins. Assume for now that they are in a
- * single row with the lowest number screen at the left.
- */
- dmxScreens[0].where = PosAbsolute;
- dmxScreens[0].whereX = 0;
- dmxScreens[0].whereY = 0;
- for (i = 1; i < dmxNumScreens; i++) {
- dmxScreens[i].where = PosRightOf;
- dmxScreens[i].whereRefScreen = i - 1;
- }
-}
-
-void dmxConfigConfigure(void)
-{
- DMXConfigEntryPtr pt;
- const char *name;
- static int fromConfigFile = 0;
-
- if (!fromConfigFile && dmxNumScreens) {
- if (dmxConfigEntry || dmxConfigName) {
- dmxLog(dmxWarning,
- "Configuration file ignored when -display used\n");
- }
- dmxConfigFromCommandLine();
- return;
- }
- if (!dmxConfigEntry) {
- if (dmxConfigName)
- dmxLog(dmxWarning,
- "Configuration name without configuration file\n");
- return;
- }
- for (pt = dmxConfigEntry; pt; pt = pt->next) {
- if (pt->type != dmxConfigVirtual) continue;
- if ((name = dmxConfigMatch(dmxConfigName, pt))) {
- dmxLog(dmxInfo, "Using configuration \"%s\"\n", name);
- dmxConfigCopyData(pt->virtual);
- ++fromConfigFile;
- return;
- }
- }
- dmxLog(dmxFatal, "Could not find configuration \"%s\" in \"%s\"\n",
- dmxConfigName, dmxConfigFileName);
-}
diff --git a/xc/programs/Xserver/hw/dmx/dmxconfigfile.h b/xc/programs/Xserver/hw/dmx/dmxconfigfile.h
deleted file mode 100644
index 5e1882ab1..000000000
--- a/xc/programs/Xserver/hw/dmx/dmxconfigfile.h
+++ /dev/null
@@ -1,42 +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>
- *
- * See config/dmxconfigfile.c for the code to this API.
- *
- */
-
-#ifndef _DMXCONFIGFILE_H_
-#define _DMXCONFIGFILE_H_
-extern int dmxConfigReadFile(const char *filename, int debug);
-extern void dmxConfigSelect(const char *name);
-extern void dmxConfigConfigure(void);
-#endif