1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It is one of the source files comprising zwgc, the Zephyr WindowGram
5 * Created by: Marc Horowitz <marc@athena.mit.edu>
9 * Copyright (c) 1989 by the Massachusetts Institute of Technology.
10 * For copying and distribution information, see the file
14 #if (!defined(lint) && !defined(SABER))
15 static char rcsid_display_c[] = "$Id$";
18 #include <zephyr/mit-copyright.h>
20 /****************************************************************************/
22 /* "Bus" module for plug in output driver modules: */
24 /****************************************************************************/
27 #include "new_memory.h"
28 #include "new_string.h"
29 #include "variables.h"
33 * driver_table - <<<>>>
36 extern void tty_driver();
37 extern void plain_driver();
38 extern void raw_driver();
40 extern int tty_driver_init();
42 #ifndef X_DISPLAY_MISSING
43 extern int X_driver_init();
44 extern void X_driver();
47 static struct driver_info {
51 void (*driver_reset)();
53 #ifndef X_DISPLAY_MISSING
54 {"X", X_driver, X_driver_init, X_driver_reset},
56 {"tty", tty_driver, tty_driver_init, NULL},
57 {"plain", plain_driver, NULL, NULL},
58 {"raw", raw_driver, NULL, NULL},
59 {NULL, NULL, NULL, NULL}
66 struct driver_info *get_driver_info(driver_name)
69 struct driver_info *d;
71 for (d=driver_table; d->driver_name; d++)
72 if (string_Eq(d->driver_name, driver_name) && d->driver)
79 * void init_display(int *pargc; char **argv)
83 void display_init(pargc, argv)
87 char **new, **current;
88 struct driver_info *d;
89 string first_working_driver = "";
90 string default_driver = "";
93 * Process argument list handling "-disable <driver>" and
94 * "-default <driver>" arguments:
96 for (new=current=argv+1; *current; current++) {
97 if (string_Eq(*current, "-disable")) {
98 current++; *pargc -= 2;
101 if (d = get_driver_info(*current))
103 } else if (string_Eq(*current, "-default")) {
104 current++; *pargc -= 2;
107 default_driver = *current;
114 * Initialize all non-disabled drivers. If a driver reports an error,
115 * disable that driver. Set default_driver if not already set
116 * by the -default argument to the first non-disabled driver.
118 for (d = driver_table; d->driver_name; d++) {
122 if (d->driver_init && d->driver_init(pargc, argv)) {
127 if (!*first_working_driver)
128 first_working_driver = d->driver_name;
131 if (!get_driver_info(default_driver))
132 default_driver = first_working_driver;
134 var_set_variable("output_driver", default_driver);
139 for (d = driver_table; d->driver_name; d++)
140 if (d->driver) d->driver_reset();