]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/zwgc/display.c
fix zwgc man page on linux and note
[1ts-debian.git] / zephyr / zwgc / display.c
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
3  * client.
4  *
5  *      Created by:     Marc Horowitz <marc@athena.mit.edu>
6  *
7  *      $Id: display.c,v 1.4 1999/01/22 23:20:15 ghudson Exp $
8  *
9  *      Copyright (c) 1989 by the Massachusetts Institute of Technology.
10  *      For copying and distribution information, see the file
11  *      "mit-copyright.h".
12  */
13
14 #if (!defined(lint) && !defined(SABER))
15 static char rcsid_display_c[] = "$Id: display.c,v 1.4 1999/01/22 23:20:15 ghudson Exp $";
16 #endif
17
18 #include <zephyr/mit-copyright.h>
19
20 /****************************************************************************/
21 /*                                                                          */
22 /*             "Bus" module for plug in output driver modules:              */
23 /*                                                                          */
24 /****************************************************************************/
25
26 #include <sysdep.h>
27 #include "new_memory.h"
28 #include "new_string.h"
29 #include "variables.h"
30 #include "display.h"
31
32 /*
33  * driver_table - <<<>>>
34  */
35
36 extern void tty_driver();
37 extern void plain_driver();
38 extern void raw_driver();
39
40 extern int tty_driver_init();
41
42 #ifndef X_DISPLAY_MISSING
43 extern int X_driver_init();
44 extern void X_driver();
45 #endif
46
47 static struct driver_info {
48     string driver_name;
49     void   (*driver)();
50     int    (*driver_init)();
51     void   (*driver_reset)();
52 } driver_table[] = {
53 #ifndef X_DISPLAY_MISSING
54     {"X",     X_driver,     X_driver_init,   X_driver_reset},
55 #endif
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}
60 };
61
62 /*
63  * <<<>>>
64  */
65
66 struct driver_info *get_driver_info(driver_name)
67      string driver_name;
68 {
69     struct driver_info *d;
70
71     for (d=driver_table; d->driver_name; d++)
72       if (string_Eq(d->driver_name, driver_name) && d->driver)
73         return(d);
74
75     return(NULL);
76 }
77
78 /*
79  *    void init_display(int *pargc; char **argv)
80  *        Effects: <<<>>>
81  */
82
83 void display_init(pargc, argv)
84      int *pargc;
85      char **argv;
86 {
87     char **new, **current;
88     struct driver_info *d;
89     string first_working_driver = "";
90     string default_driver = "";
91
92     /*
93      * Process argument list handling "-disable <driver>" and
94      * "-default <driver>" arguments:
95      */
96     for (new=current=argv+1; *current; current++) {
97         if (string_Eq(*current, "-disable")) {
98             current++; *pargc -= 2;
99             if (!*current)
100               usage();
101             if (d = get_driver_info(*current))
102               d->driver = NULL;
103         } else if (string_Eq(*current, "-default")) {
104             current++; *pargc -= 2;
105             if (!*current)
106               usage();
107             default_driver = *current;
108         } else
109           *(new++) = *current;
110     }
111     *new = *current;
112
113     /*
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.
117      */    
118     for (d = driver_table; d->driver_name; d++) {
119         if (!d->driver)
120           continue;
121         
122         if (d->driver_init && d->driver_init(pargc, argv)) {
123             d->driver = NULL;
124             continue;
125         }
126
127         if (!*first_working_driver)
128           first_working_driver = d->driver_name;
129     }
130
131     if (!get_driver_info(default_driver))
132       default_driver = first_working_driver;
133
134     var_set_variable("output_driver", default_driver);
135 }
136
137 void display_reset()
138 {
139    for (d = driver_table; d->driver_name; d++)
140       if (d->driver) d->driver_reset();
141 }