Jabber WindowGram Client (JWGC)

Introduction Screenshots Installation Downloads
Documentation Browse Source Resources Project Site

Stable Version
-none-

Latest Version
beta5



Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

display.c

Go to the documentation of this file.
00001 /****************************************************************************/
00002 /* */
00003 /* "Bus" module for plug in output driver modules:              */
00004 /* */
00005 /****************************************************************************/
00006 
00007 #include <sysdep.h>
00008 #include "new_memory.h"
00009 #include "new_string.h"
00010 #include "variables.h"
00011 #include "display.h"
00012 
00013 /*
00014  * driver_table - <<<>>>
00015  */
00016 
00017 extern void tty_driver();
00018 extern void plain_driver();
00019 extern void raw_driver();
00020 
00021 extern int tty_driver_init();
00022 
00023 #ifndef X_DISPLAY_MISSING
00024 extern int X_driver_init();
00025 extern void X_driver();
00026 #endif
00027 
00028 static struct driver_info {
00029         string driver_name;
00030         void (*driver) ();
00031         int (*driver_init) ();
00032         void (*driver_reset) ();
00033 } driver_table[] = {
00034 #ifndef X_DISPLAY_MISSING
00035         {
00036                 "X", X_driver, X_driver_init, X_driver_reset
00037         },
00038 #endif
00039         {
00040                 "tty", tty_driver, tty_driver_init, NULL
00041         },
00042         {
00043                 "plain", plain_driver, NULL, NULL
00044         },
00045         {
00046                 "raw", raw_driver, NULL, NULL
00047         },
00048         {
00049                 NULL, NULL, NULL, NULL
00050         }
00051 };
00052 
00053 /*
00054  * <<<>>>
00055  */
00056 
00057 struct driver_info *
00058 get_driver_info(driver_name)
00059         string driver_name;
00060 {
00061         struct driver_info *d;
00062 
00063         for (d = driver_table; d->driver_name; d++)
00064                 if (string_Eq(d->driver_name, driver_name) && d->driver)
00065                         return (d);
00066 
00067         return (NULL);
00068 }
00069 
00070 /*
00071  *    void init_display(int *pargc; char **argv)
00072  *        Effects: <<<>>>
00073  */
00074 
00075 void 
00076 display_init(pargc, argv)
00077         int *pargc;
00078         char **argv;
00079 {
00080         char **new, **current;
00081         struct driver_info *d;
00082         string first_working_driver = "";
00083         string default_driver = "";
00084 
00085         /*
00086          * Process argument list handling "-disable <driver>" and
00087          * "-default <driver>" arguments:
00088          */
00089         for (new = current = argv + 1; *current; current++) {
00090                 if (string_Eq(*current, "-disable")) {
00091                         current++;
00092                         *pargc -= 2;
00093                         if (!*current)
00094                                 usage();
00095                         if (d = get_driver_info(*current))
00096                                 d->driver = NULL;
00097                 }
00098                 else if (string_Eq(*current, "-default")) {
00099                         current++;
00100                         *pargc -= 2;
00101                         if (!*current)
00102                                 usage();
00103                         default_driver = *current;
00104                 }
00105                 else
00106                         *(new++) = *current;
00107         }
00108         *new = *current;
00109 
00110         /*
00111          * Initialize all non-disabled drivers.  If a driver reports an error,
00112          * disable that driver.  Set default_driver if not already set
00113          * by the -default argument to the first non-disabled driver.
00114          */
00115         for (d = driver_table; d->driver_name; d++) {
00116                 if (!d->driver)
00117                         continue;
00118 
00119                 if (d->driver_init && d->driver_init(pargc, argv)) {
00120                         d->driver = NULL;
00121                         continue;
00122                 }
00123 
00124                 if (!*first_working_driver)
00125                         first_working_driver = d->driver_name;
00126         }
00127 
00128         if (!get_driver_info(default_driver))
00129                 default_driver = first_working_driver;
00130 
00131         var_set_variable("output_driver", default_driver);
00132 }
00133 
00134 void 
00135 display_reset()
00136 {
00137         for (d = driver_table; d->driver_name; d++)
00138                 if (d->driver)
00139                         d->driver_reset();
00140 }


Last updated at Tue Dec 18 21:07:42 PST 2007. This site and project hosted by...SourceForge.net Logo
Source Perspective by Fisheye