Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / gtx / windows.c
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
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 */
9
10 /*
11 * gator_windows.c
12 *
13 * Description:
14 * Implementation of the gator windows interface.
15 *
16 *--------------------------------------------------------------------------------*/
17
18 #include <afsconfig.h>
19 #include <afs/param.h>
20
21 #include <roken.h>
22
23 /* On DUX "IN" is a variable in curses.h, so this can be a bit of a problem */
24 #ifdef IN
25 #undef IN
26 #endif
27
28 #include "gtxwindows.h" /*Interface for this module */
29 #include "gtxcurseswin.h" /*Interface for the curses module */
30 #include "gtxdumbwin.h" /*Interface for the dumb terminal module */
31 #include "gtxX11win.h" /*Interface for the X11 module */
32
33 static char mn[] = "gator_windows"; /*Module name */
34 struct gwinbaseops gwinbops; /*Base window operation fn array */
35 struct gwin gator_basegwin; /*Base gator window */
36
37 /*--------------------------------------------------------------------------------
38 * gw_init
39 *
40 * Description:
41 * Initialize the gator window package.
42 *
43 * Arguments:
44 * struct gwin_initparams *params : Ptr to initialization params.
45 *
46 * Returns:
47 * 0 on success,
48 * Error value otherwise.
49 *
50 * Environment:
51 * *** MUST BE THE FIRST ROUTINE CALLED FROM
52 * THIS PACKAGE ***
53 *
54 * Side Effects:
55 * Sets up the chosen lower-level graphics package, as well
56 * as the base operation array (gwinbops). Also sets up the
57 * base window.
58 *--------------------------------------------------------------------------------*/
59
60 int
61 gw_init(struct gwin_initparams *params)
62 { /*gw_init */
63
64 static char rn[] = "gw_init"; /*Routine name */
65 int code; /*Return code */
66 int gwin_debug; /*Is debugging turned on? */
67
68 /*
69 * Remember our debugging level.
70 */
71 gwin_debug = params->i_debug;
72 if (gwin_debug)
73 fprintf(stderr, "[%s:%s] Window debugging turned on\n", mn, rn);
74
75 /*
76 * What we do/call depends on the type of lower-level graphics
77 * package we'll be using.
78 */
79 switch (params->i_type) {
80 case GATOR_WIN_DUMB: /*Dumb terminal */
81 if (gwin_debug)
82 fprintf(stderr,
83 "[%s:%s] Initializing for the dumb terminal package\n",
84 mn, rn);
85 gwinbops = gator_dumb_gwinbops;
86 code = gator_dumbgwin_init(gwin_debug);
87 if (code) {
88 fprintf(stderr,
89 "[%s:%s] Error in dumb terminal initialization routine, gator_dumbgwin_init(): %d\n",
90 mn, rn, code);
91 return (code);
92 }
93 break;
94
95 case GATOR_WIN_CURSES: /*Curses */
96 if (gwin_debug)
97 fprintf(stderr, "[%s:%s] Initializing for the curses package\n",
98 mn, rn);
99 gwinbops = gator_curses_gwinbops;
100 code = gator_cursesgwin_init(gwin_debug);
101 if (code) {
102 fprintf(stderr,
103 "[%s:%s] Error in curses initialization routine, gator_cursesgwin_init(): %d\n",
104 mn, rn, code);
105 return (code);
106 }
107 break;
108
109 case GATOR_WIN_X11: /*X11 */
110 if (gwin_debug)
111 fprintf(stderr, "[%s:%s] Initializing for the X11 package\n", mn,
112 rn);
113 gwinbops = gator_X11_gwinbops;
114 code = gator_X11gwin_init(gwin_debug);
115 if (code) {
116 fprintf(stderr,
117 "[%s:%s] Error in X11 initialization routine, gator_X11gwin_init(): %d\n",
118 mn, rn, code);
119 return (code);
120 }
121 break;
122
123 default:
124 fprintf(stderr, "[%s:%s] Illegal choice of graphics system: %d\n", mn,
125 rn, params->i_type);
126 fprintf(stderr, "\tLegal choices are:\n");
127 fprintf(stderr, "\t\t%d: Dumb terminal\n", GATOR_WIN_DUMB);
128 fprintf(stderr, "\t\t%d: Curses\n", GATOR_WIN_CURSES);
129 fprintf(stderr, "\t\t%d: X11\n", GATOR_WIN_X11);
130 return (-1);
131 } /*end switch (params->i_type) */
132
133 /*
134 * Finally, return the good news.
135 */
136 return (0);
137
138 } /*gw_init */