Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / gtx / windows.c
blob45c391eda25d172af4a40287865951386aa79ccf
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
11 * gator_windows.c
13 * Description:
14 * Implementation of the gator windows interface.
16 *--------------------------------------------------------------------------------*/
18 #include <afsconfig.h>
19 #include <afs/param.h>
22 /* On DUX "IN" is a variable in curses.h, so this can be a bit of a problem */
23 #ifdef IN
24 #undef IN
25 #endif
27 #include "gtxwindows.h" /*Interface for this module */
28 #include "gtxcurseswin.h" /*Interface for the curses module */
29 #include "gtxdumbwin.h" /*Interface for the dumb terminal module */
30 #include "gtxX11win.h" /*Interface for the X11 module */
32 static char mn[] = "gator_windows"; /*Module name */
33 struct gwinbaseops gwinbops; /*Base window operation fn array */
34 struct gwin gator_basegwin; /*Base gator window */
36 /*--------------------------------------------------------------------------------
37 * gw_init
39 * Description:
40 * Initialize the gator window package.
42 * Arguments:
43 * struct gwin_initparams *params : Ptr to initialization params.
45 * Returns:
46 * 0 on success,
47 * Error value otherwise.
49 * Environment:
50 * *** MUST BE THE FIRST ROUTINE CALLED FROM
51 * THIS PACKAGE ***
53 * Side Effects:
54 * Sets up the chosen lower-level graphics package, as well
55 * as the base operation array (gwinbops). Also sets up the
56 * base window.
57 *--------------------------------------------------------------------------------*/
59 int
60 gw_init(struct gwin_initparams *params)
61 { /*gw_init */
63 static char rn[] = "gw_init"; /*Routine name */
64 int code; /*Return code */
65 int gwin_debug; /*Is debugging turned on? */
68 * Remember our debugging level.
70 gwin_debug = params->i_debug;
71 if (gwin_debug)
72 fprintf(stderr, "[%s:%s] Window debugging turned on\n", mn, rn);
75 * What we do/call depends on the type of lower-level graphics
76 * package we'll be using.
78 switch (params->i_type) {
79 case GATOR_WIN_DUMB: /*Dumb terminal */
80 if (gwin_debug)
81 fprintf(stderr,
82 "[%s:%s] Initializing for the dumb terminal package\n",
83 mn, rn);
84 gwinbops = gator_dumb_gwinbops;
85 code = gator_dumbgwin_init(gwin_debug);
86 if (code) {
87 fprintf(stderr,
88 "[%s:%s] Error in dumb terminal initialization routine, gator_dumbgwin_init(): %d\n",
89 mn, rn, code);
90 return (code);
92 break;
94 case GATOR_WIN_CURSES: /*Curses */
95 if (gwin_debug)
96 fprintf(stderr, "[%s:%s] Initializing for the curses package\n",
97 mn, rn);
98 gwinbops = gator_curses_gwinbops;
99 code = gator_cursesgwin_init(gwin_debug);
100 if (code) {
101 fprintf(stderr,
102 "[%s:%s] Error in curses initialization routine, gator_cursesgwin_init(): %d\n",
103 mn, rn, code);
104 return (code);
106 break;
108 case GATOR_WIN_X11: /*X11 */
109 if (gwin_debug)
110 fprintf(stderr, "[%s:%s] Initializing for the X11 package\n", mn,
111 rn);
112 gwinbops = gator_X11_gwinbops;
113 code = gator_X11gwin_init(gwin_debug);
114 if (code) {
115 fprintf(stderr,
116 "[%s:%s] Error in X11 initialization routine, gator_X11gwin_init(): %d\n",
117 mn, rn, code);
118 return (code);
120 break;
122 default:
123 fprintf(stderr, "[%s:%s] Illegal choice of graphics system: %d\n", mn,
124 rn, params->i_type);
125 fprintf(stderr, "\tLegal choices are:\n");
126 fprintf(stderr, "\t\t%d: Dumb terminal\n", GATOR_WIN_DUMB);
127 fprintf(stderr, "\t\t%d: Curses\n", GATOR_WIN_CURSES);
128 fprintf(stderr, "\t\t%d: X11\n", GATOR_WIN_X11);
129 return (-1);
130 } /*end switch (params->i_type) */
133 * Finally, return the good news.
135 return (0);
137 } /*gw_init */