Standardize License information
[openafs.git] / src / gtx / input.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 #define IGNORE_STDS_H
11 #include <afs/param.h>
12 #ifdef AFS_HPUX_ENV
13 #include <sys/types.h>
14 #endif
15 #include <lwp.h>
16
17 #include "gtxobjects.h"
18 #include "gtxwindows.h"
19 #include "gtxcurseswin.h"
20 #include "gtxinput.h"
21 #include "gtxkeymap.h"
22 #include "gtxframe.h"
23 #include <afs/stds.h>
24
25
26 /* process input */
27 gtx_InputServer(awin)
28 register struct gwin *awin; {
29     register int tc;
30     register int code;
31     register struct gtx_frame *tframe;
32
33     WOP_DISPLAY(awin);  /* start off with a clean display */
34     while (1) {
35         /* get a character from the generic window */
36         tframe = awin->w_frame;
37         code = WOP_WAIT(awin);
38         if (code) {
39             printf("***WAIT FAILURE %d****\n", code);
40             exit(1);
41         }
42         tc = WOP_GETCHAR(awin);
43         tframe->flags &= ~GTXFRAME_NEWDISPLAY;  /* OK to clear now */
44         if (tc < 0) break;      /* EOF or some such */
45         /* otherwise, process the character and go get a new one */
46         gtxframe_ClearMessageLine(tframe);
47         tframe->flags &= ~(GTXFRAME_RECURSIVEEND | GTXFRAME_RECURSIVEERR);
48         keymap_ProcessKey(tframe->keystate, tc, awin);
49         tframe = awin->w_frame; /* in case command changed it */
50         if (tframe->flags & GTXFRAME_RECURSIVEEND) {
51             tframe->flags &= ~GTXFRAME_RECURSIVEEND;
52             return 0;
53         }
54         tframe->flags &= ~GTXFRAME_RECURSIVEEND;
55         WOP_DISPLAY(awin);      /* eventually calls gtxframe_Display */
56     }
57 }
58
59 struct gwin *gtx_Init(astartInput, atype)
60 int atype;                                      /* type of window to create */
61 int astartInput; {
62     PROCESS junk;
63     struct onode_initparams oi_params;          /* object init params*/
64     struct gwin_initparams wi_params;           /* window initialization params*/
65     register struct gwin *twin;
66     register int code;
67
68     /* setup the main window structure */
69     wi_params.i_type   = GATOR_WIN_CURSES;
70     wi_params.i_x      =   0;
71     wi_params.i_y      =   0;
72     wi_params.i_width  =  80;
73     wi_params.i_height = 200;
74     wi_params.i_debug  = 0;     /* or 1 if we want debugging done */
75
76     /*
77      * Set up the basic onode initialization parameters, throwing in
78      * the graphics-specific stuff.
79      */
80     oi_params.i_debug = 0;      /* or 1 if we want debugging */
81     oi_params.i_gwparams = &wi_params;
82
83     code = gator_objects_init(&oi_params);
84     if (code) return (struct gwin *) 0;
85     
86     /* if we start input thread */
87     IOMGR_Initialize(); /* input thread uses it */
88     if (astartInput)
89         code = LWP_CreateProcess(gtx_InputServer, 8192, LWP_NORMAL_PRIORITY,
90                                  0, "gx-listener", &junk);
91     /* all done */
92     twin = &gator_basegwin;
93     return twin;
94 }