use computed values in src/gtx/curseswindows.c
[openafs.git] / src / gtx / curseswindows.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_curseswindows.c
12  *
13  * Description:
14  *      Implementation of the gator curses window facility.
15  *
16  *------------------------------------------------------------------------*/
17
18 #include <afsconfig.h>
19 #include <afs/param.h>
20
21
22
23 #if defined(AFS_HPUX110_ENV) && !defined(__HP_CURSES)
24 #define __HP_CURSES
25 #endif
26
27 #ifndef AFS_SUN5_ENV
28 #include <curses.h>             /*Curses library */
29 #endif
30 #include <sys/types.h>
31 #include <sys/file.h>
32 #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD80_ENV)
33 #include <sgtty.h>
34 #endif
35 #include <stdio.h>
36 #include <sys/time.h>
37 #include <errno.h>
38 #include <string.h>
39 #include <stdlib.h>
40
41 #include <lwp.h>
42
43 #include "gtxcurseswin.h"       /*Interface definition */
44 #include "gtxobjects.h"
45 #include "gtxframe.h"
46
47
48
49 int curses_debug;               /*Is debugging turned on? */
50 static char mn[] = "gator_curseswindows";       /*Module name */
51
52 /*
53  * Version of standard operations for a curses window.
54  */
55 struct gwinops curses_gwinops = {
56     gator_cursesgwin_box,
57     gator_cursesgwin_clear,
58     gator_cursesgwin_destroy,
59     gator_cursesgwin_display,
60     gator_cursesgwin_drawline,
61     gator_cursesgwin_drawrectangle,
62     gator_cursesgwin_drawchar,
63     gator_cursesgwin_drawstring,
64     gator_cursesgwin_invert,
65     gator_cursesgwin_getchar,
66     gator_cursesgwin_getdimensions,
67     gator_cursesgwin_wait,
68 };
69
70 struct gwinbaseops gator_curses_gwinbops = {
71     gator_cursesgwin_create,
72     gator_cursesgwin_cleanup,
73 };
74
75
76 /*
77  * Macros to map pixel positions to row & column positions.
78  * (Note: for now, they are the identity function!!)
79  */
80 #define GATOR_MAP_X_TO_COL(w, x)    (x)
81 #define GATOR_MAP_Y_TO_LINE(w, y)   (y)
82
83 /*------------------------------------------------------------------------
84  * gator_cursesgwin_init
85  *
86  * Description:
87  *      Initialize the curses window package.
88  *
89  * Arguments:
90  *      int adebug: Is debugging turned on?
91  *
92  * Returns:
93  *      0 on success,
94  *      Error value otherwise.
95  *
96  * Environment:
97  *      Nothing interesting.
98  *
99  * Side Effects:
100  *      As advertised.
101  *------------------------------------------------------------------------*/
102
103 int
104 gator_cursesgwin_init(int adebug)
105 {                               /*gator_cursesgwin_init */
106
107     static char rn[] = "gator_cursesgwin_init"; /*Routine name */
108     struct gator_cursesgwin *c_data;    /*Ptr to curses-specific data */
109
110     /*
111      * Remember if we'll be doing debugging, then init the curses package.
112      */
113     curses_debug = adebug;
114
115     if (curses_debug)
116         fprintf(stderr, "[%s:%s] Calling initscr()\n", mn, rn);
117     initscr();
118
119     /*
120      * Fill out the base window structure for curses.
121      */
122     if (curses_debug)
123         fprintf(stderr,
124                 "[%s:%s] Allocating %" AFS_SIZET_FMT " bytes for curses window private space in base window\n",
125                 mn, rn, sizeof(struct gator_cursesgwin));
126     c_data =
127         (struct gator_cursesgwin *)malloc(sizeof(struct gator_cursesgwin));
128     if (c_data == (struct gator_cursesgwin *)0) {
129         fprintf(stderr,
130                 "[%s:%s] Can't allocate %" AFS_SIZET_FMT " bytes for curses window private space in base window\n",
131                 mn, rn, sizeof(struct gator_cursesgwin));
132         return (-1);
133     }
134
135     /*
136      * Fill in the curses-specific base window info.  We assume that chars are 8x13.
137      */
138     c_data->wp = stdscr;
139     c_data->charwidth = 8;
140     c_data->charheight = 13;
141     c_data->box_vertchar = '|';
142     c_data->box_horizchar = '-';
143
144     /*
145      * Fill in the generic base window info.
146      */
147     gator_basegwin.w_type = GATOR_WIN_CURSES;
148     gator_basegwin.w_x = 0;
149     gator_basegwin.w_y = 0;
150     gator_basegwin.w_width = c_data->charwidth * COLS;
151     gator_basegwin.w_height = c_data->charheight * LINES;
152     gator_basegwin.w_changed = 0;
153     gator_basegwin.w_op = &curses_gwinops;
154     gator_basegwin.w_parent = NULL;
155
156     /*
157      * Plug the private data into the generic part of the base window.
158      */
159     gator_basegwin.w_data = (int *)c_data;
160
161     /*
162      * Now, set the terminal into the right mode for handling input
163      */
164     raw();                      /* curses raw mode */
165
166     /* init the frame */
167     gator_basegwin.w_frame = gtxframe_Create();
168
169     /*
170      * Clear out the screen and return the good news.
171      */
172     wclear(((struct gator_cursesgwin *)(gator_basegwin.w_data))->wp);
173     return (0);
174
175 }                               /*gator_cursesgwin_init */
176
177 /*------------------------------------------------------------------------
178  * gator_cursesgwin_create
179  *
180  * Description:
181  *      Create a curses window (incorrectly).
182  *
183  * Arguments:
184  *      struct gator_cursesgwin_params *params : Ptr to creation parameters.
185  *
186  * Returns:
187  *      Ptr to the created curses window if successful,
188  *      Null ptr otherwise.
189  *
190  * Environment:
191  *      Nothing interesting.
192  *
193  * Side Effects:
194  *      As advertised.
195  *------------------------------------------------------------------------*/
196
197 struct gwin *
198 gator_cursesgwin_create(void * rock)
199 {
200     static char rn[] = "gator_cursesgwin_create";       /*Routine name */
201     struct gator_cursesgwin_params *params = (struct gator_cursesgwin_params *)rock;
202     struct gwin *newgwin;       /*Ptr to new curses window */
203     struct gator_cursesgwin *c_data;    /*Ptr to curses-specific data */
204     WINDOW *newcursgwin;        /*Ptr to new curses window */
205
206     if (curses_debug)
207         fprintf(stderr,
208                 "[%s:%s] Allocating %" AFS_SIZET_FMT " bytes for new gwin structure\n", mn,
209                 rn, sizeof(struct gwin));
210     newgwin = (struct gwin *)malloc(sizeof(struct gwin));
211     if (newgwin == NULL) {
212         fprintf(stderr,
213                 "[%s:%s] Can't malloc() %" AFS_SIZET_FMT " bytes for new gwin structure: Errno is %d\n",
214                 mn, rn, sizeof(struct gwin), errno);
215         return (NULL);
216     }
217
218     newgwin->w_type = GATOR_WIN_CURSES;
219     newgwin->w_x = params->gwin_params.cr_x;
220     newgwin->w_y = params->gwin_params.cr_y;
221     newgwin->w_width = params->gwin_params.cr_width;
222     newgwin->w_height = params->gwin_params.cr_height;
223     newgwin->w_changed = 1;
224     newgwin->w_op = &curses_gwinops;
225     newgwin->w_parent = params->gwin_params.cr_parentwin;
226
227     if (curses_debug)
228         fprintf(stderr,
229                 "[%s:%s] Allocating %" AFS_SIZET_FMT " bytes for curses window private space\n",
230                 mn, rn, sizeof(struct gator_cursesgwin));
231     c_data =
232         (struct gator_cursesgwin *)malloc(sizeof(struct gator_cursesgwin));
233     if (c_data == (struct gator_cursesgwin *)0) {
234         fprintf(stderr,
235                 "[%s:%s] Can't allocate %" AFS_SIZET_FMT " bytes for curses window private space\n",
236                 mn, rn, sizeof(struct gator_cursesgwin));
237         free(newgwin);
238         return (NULL);
239     }
240
241     newcursgwin = newwin(newgwin->w_height,     /*Number of lines */
242                          newgwin->w_width,      /*Number of columns */
243                          newgwin->w_y,  /*Beginning y value */
244                          newgwin->w_x); /*Beginning x value */
245     if (newcursgwin == (WINDOW *) 0) {
246         fprintf(stderr,
247                 "[%s:%s] Failed to create curses window via newwin()\n", mn,
248                 rn);
249         free(newgwin);
250         free(c_data);
251         return (NULL);
252     }
253
254     /*
255      * Now, fill in the curses-specific window info.
256      */
257     c_data->wp = newcursgwin;
258     c_data->charwidth = params->charwidth;
259     c_data->charheight = params->charheight;
260     c_data->box_vertchar = params->box_vertchar;
261     c_data->box_horizchar = params->box_horizchar;
262
263     /*
264      * Plug in a frame at the top-level.
265      */
266     newgwin->w_frame = gtxframe_Create();
267
268     /*
269      * Plug the curses private data into the generic window object, then
270      * return the new window's info.
271      */
272     newgwin->w_data = (int *)c_data;
273     return (newgwin);
274
275 }                               /*gator_cursesgwin_create */
276
277 /*------------------------------------------------------------------------
278  * gator_cursesgwin_cleanup
279  *
280  * Description:
281  *      Clean up, probably right before the caller exits.
282  *
283  * Arguments:
284  *      struct gwin *gwp : Ptr to base window.
285  *
286  * Returns:
287  *      0 on success,
288  *      Error value otherwise.
289  *
290  * Environment:
291  *      Nothing interesting.
292  *
293  * Side Effects:
294  *      As advertised.
295  *------------------------------------------------------------------------*/
296
297 int
298 gator_cursesgwin_cleanup(struct gwin *gwp)
299 {                               /*gator_cursesgwin_cleanup */
300
301     static char rn[] = "gator_cursesgwin_cleanup";      /*Routine name */
302     struct gator_cursesgwin *cwp;       /*Curses private area ptr */
303
304     cwp = (struct gator_cursesgwin *)(gwp->w_data);
305
306     /*
307      * Cleaning up in curses is extremely easy - one simple call.  We also
308      * want to clear the screen before we go.
309      */
310     if (curses_debug)
311         fprintf(stderr, "[%s:%s] Calling wclear() on window at %p\n", mn,
312                 rn, cwp->wp);
313     wclear(cwp->wp);
314     wrefresh(cwp->wp);
315
316     /*
317      * Now, set the terminal back into normal mode.
318      */
319     noraw();
320
321     if (curses_debug)
322         fprintf(stderr, "[%s:%s] Calling endwin()\n", mn, rn);
323     endwin();
324
325     return (0);
326
327 }                               /*gator_cursesgwin_cleanup */
328
329 /*------------------------------------------------------------------------
330  * gator_cursesgwin_box
331  *
332  * Description:
333  *      Draw a box around the given curses window.
334  *
335  * Arguments:
336  *      struct gwin *gwp : Ptr to the curses window to draw
337  *                         a box around.
338  *
339  * Returns:
340  *      0 on success,
341  *      Error value otherwise.
342  *
343  * Environment:
344  *      Nothing interesting.
345  *
346  * Side Effects:
347  *      As advertised.
348  *------------------------------------------------------------------------*/
349
350 int
351 gator_cursesgwin_box(struct gwin *gwp)
352 {                               /*gator_cursesgwin_box */
353
354     static char rn[] = "gator_cursesgwin_box";  /*Routine name */
355     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
356
357     cwp = (struct gator_cursesgwin *)(gwp->w_data);
358     if (curses_debug)
359         fprintf(stderr, "[%s:%s] Calling box() on window at %p\n", mn, rn,
360                 cwp->wp);
361     box(cwp->wp, cwp->box_vertchar, cwp->box_horizchar);
362
363     return (0);
364
365 }                               /*gator_cursesgwin_box */
366
367 /*------------------------------------------------------------------------
368  * gator_cursesgwin_clear
369  *
370  * Description:
371  *      Clear out the given curses window.
372  *
373  * Arguments:
374  *      struct gwin *gwp : Ptr to the curses window to clear out.
375  *
376  * Returns:
377  *      0 on success,
378  *      Error value otherwise.
379  *
380  * Environment:
381  *      Nothing interesting.
382  *
383  * Side Effects:
384  *      As advertised.
385  *------------------------------------------------------------------------*/
386
387 int
388 gator_cursesgwin_clear(struct gwin *gwp)
389 {                               /*gator_cursesgwin_clear */
390
391     static char rn[] = "gator_cursesgwin_clear";        /*Routine name */
392     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
393
394     /*
395      * Clearing windows is very easy in curses; just one call will do it.
396      */
397     cwp = (struct gator_cursesgwin *)(gwp->w_data);
398     if (curses_debug)
399         fprintf(stderr, "[%s:%s] Calling wclear() on window at %p\n", mn,
400                 rn, cwp->wp);
401     wclear(cwp->wp);
402
403     return (0);
404
405 }                               /*gator_cursesgwin_clear */
406
407 /*------------------------------------------------------------------------
408  * gator_cursesgwin_destroy
409  *
410  * Description:
411  *      Destroy the given curses window.
412  *
413  * Arguments:
414  *      struct gwin *gwp : Ptr to the curses window to destroy.
415  *
416  * Returns:
417  *      0 on success,
418  *      Error value otherwise.
419  *
420  * Environment:
421  *      Nothing interesting.
422  *
423  * Side Effects:
424  *      As advertised.
425  *------------------------------------------------------------------------*/
426
427 int
428 gator_cursesgwin_destroy(struct gwin *gwp)
429 {                               /*gator_cursesgwin_destroy */
430
431     static char rn[] = "gator_cursesgwin_destroy";      /*Routine name */
432     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
433
434     cwp = (struct gator_cursesgwin *)(gwp->w_data);
435     if (curses_debug)
436         fprintf(stderr, "[%s:%s] Calling delwin() on window at %p\n", mn,
437                 rn, cwp->wp);
438     delwin(cwp->wp);
439
440     return (0);
441
442 }                               /*gator_cursesgwin_destroy */
443
444 /*------------------------------------------------------------------------
445  * gator_cursesgwin_display
446  *
447  * Description:
448  *      Display/redraw the given curses window.
449  *
450  * Arguments:
451  *      struct gwin *gwp : Ptr to the curses window to draw.
452  *
453  * Returns:
454  *      0 on success,
455  *      Error value otherwise.
456  *
457  * Environment:
458  *      Nothing interesting.
459  *
460  * Side Effects:
461  *      As advertised.
462  *------------------------------------------------------------------------*/
463
464 int
465 gator_cursesgwin_display(struct gwin *gwp)
466 {                               /*gator_cursesgwin_display */
467
468     struct gator_cursesgwin *cwp;       /*Curses private area ptr */
469
470     cwp = (struct gator_cursesgwin *)(gwp->w_data);
471
472     wclear(cwp->wp);            /* clear screen */
473     gtxframe_Display(gwp->w_frame, gwp);        /* display the frame */
474     wrefresh(cwp->wp);          /* redraw the guy */
475     return (0);
476
477 }                               /*gator_cursesgwin_display */
478
479 /*------------------------------------------------------------------------
480  * gator_cursesgwin_drawline
481  *
482  * Description:
483  *      Draw a line between two points in the given curses
484  *      window.
485  *
486  * Arguments:
487  *      struct gwin *gwp : Ptr to the curses window in which
488  *                                 the line is to be drawn.
489  *      struct gwin_lineparams *params : Ptr to other params.
490  *
491  * Returns:
492  *      0 on success,
493  *      Error value otherwise.
494  *
495  * Environment:
496  *      Nothing interesting.
497  *
498  * Side Effects:
499  *      As advertised.
500  *------------------------------------------------------------------------*/
501
502 int
503 gator_cursesgwin_drawline(struct gwin *gwp, struct gwin_lineparams *params)
504 {                               /*gator_cursesgwin_drawline */
505
506     static char rn[] = "gator_cursesgwin_drawline";     /*Routine name */
507
508     if (curses_debug)
509         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
510                 rn);
511
512     return (0);
513
514 }                               /*gator_cursesgwin_drawline */
515
516 /*------------------------------------------------------------------------
517  * gator_cursesgwin_drawrectangle
518  *
519  * Description:
520  *      Draw a rectangle in the given curses window.
521  *
522  * Arguments:
523  *      struct gwin *gwp : Ptr to the curses window in which
524  *                                 the rectangle is to be drawn.
525  *      struct gwin_rectparams *params : Ptr to other params.
526  *
527  * Returns:
528  *      0 on success,
529  *      Error value otherwise.
530  *
531  * Environment:
532  *      Nothing interesting.
533  *
534  * Side Effects:
535  *      As advertised.
536  *------------------------------------------------------------------------*/
537
538 int
539 gator_cursesgwin_drawrectangle(struct gwin *gwp, struct gwin_rectparams *params)
540 {                               /*gator_cursesgwin_drawrectangle */
541
542     static char rn[] = "gator_cursesgwin_drawrectangle";        /*Routine name */
543
544     if (curses_debug)
545         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
546                 rn);
547
548     return (0);
549
550 }                               /*gator_cursesgwin_drawrectangle */
551
552 /*------------------------------------------------------------------------
553  * gator_cursesgwin_drawchar
554  *
555  * Description:
556  *      Draw a character in the given curses window.
557  *
558  * Arguments:
559  *      struct gwin *gwp : Ptr to the curses window in which
560  *                                 the character is to be drawn.
561  *      struct gwin_charparams *params : Ptr to other params.
562  *
563  * Returns:
564  *      0 on success,
565  *      Error value otherwise.
566  *
567  * Environment:
568  *      Nothing interesting.
569  *
570  * Side Effects:
571  *      As advertised.
572  *------------------------------------------------------------------------*/
573
574 int
575 gator_cursesgwin_drawchar(struct gwin *gwp, struct gwin_charparams *params)
576 {                               /*gator_cursesgwin_drawchar */
577
578     static char rn[] = "gator_cursesgwin_drawchar";     /*Routine name */
579     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
580     int curses_x, curses_y;     /*Mapped x,y positions */
581     int code=0;
582
583     cwp = (struct gator_cursesgwin *)(gwp->w_data);
584     curses_x = GATOR_MAP_X_TO_COL(cwp, params->x);
585     curses_y = GATOR_MAP_Y_TO_LINE(cwp, params->y);
586     if (curses_debug)
587         fprintf(stderr,
588                 "[%s:%s] Drawing char '%c' on window at %p at (%d, %d) [line %d, column %d]%s\n",
589                 mn, rn, params->c, cwp->wp, params->x, params->y, curses_y,
590                 curses_x, (params->highlight ? ", using standout mode" : ""));
591     wmove(cwp->wp, curses_y, curses_x);
592     if (params->highlight)
593         code=wstandout(cwp->wp);
594         if (code)
595             return (code);
596     waddch(cwp->wp, params->c);
597     if (params->highlight)
598         code=wstandend(cwp->wp);
599         if (code)
600             return (code);
601
602     return (0);
603
604 }                               /*gator_cursesgwin_drawchar */
605
606 /*------------------------------------------------------------------------
607  * gator_cursesgwin_drawstring
608  *
609  * Description:
610  *      Draw a string in the given curses window.
611  *
612  * Arguments:
613  *      struct gwin *gwp : Ptr to the curses window in which
614  *                                 the string is to be drawn.
615  *      struct gwin_strparams *params : Ptr to other params.
616  *
617  * Returns:
618  *      0 on success,
619  *      Error value otherwise.
620  *
621  * Environment:
622  *      Nothing interesting.
623  *
624  * Side Effects:
625  *      As advertised.
626  *------------------------------------------------------------------------*/
627
628 int
629 gator_cursesgwin_drawstring(struct gwin *gwp, struct gwin_strparams *params)
630 {                               /*gator_cursesgwin_drawstring */
631
632     static char rn[] = "gator_cursesgwin_drawstring";   /*Routine name */
633     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
634     int curses_x, curses_y;     /*Mapped x,y positions */
635     int code=0;
636
637     cwp = (struct gator_cursesgwin *)(gwp->w_data);
638     curses_x = GATOR_MAP_X_TO_COL(cwp, params->x);
639     curses_y = GATOR_MAP_Y_TO_LINE(cwp, params->y);
640     if (curses_debug)
641         fprintf(stderr,
642                 "[%s:%s] Drawing string '%s' on window at %p at (%d, %d) [line %d, column %d]%s\n",
643                 mn, rn, params->s, cwp->wp, params->x, params->y, curses_y,
644                 curses_x, (params->highlight ? ", using standout mode" : ""));
645     wmove(cwp->wp, curses_y, curses_x);
646     if (params->highlight)
647         code=wstandout(cwp->wp);
648         if (code)
649             return (code);
650     waddstr(cwp->wp, params->s);
651     if (params->highlight)
652         code=wstandend(cwp->wp);
653         if (code)
654             return (code);
655
656     return (code);
657
658 }                               /*gator_cursesgwin_drawstring */
659
660 /*------------------------------------------------------------------------
661  * gator_cursesgwin_invert
662  *
663  * Description:
664  *      Invert a region in the given curses window.
665  *
666  * Arguments:
667  *      struct gwin *gwp : Ptr to the curses window in which
668  *                                 the inverted region lies.
669  *      struct gwin_invparams *params : Ptr to other params.
670  *
671  * Returns:
672  *      0 on success,
673  *      Error value otherwise.
674  *
675  * Environment:
676  *      Nothing interesting.
677  *
678  * Side Effects:
679  *      As advertised.
680  *------------------------------------------------------------------------*/
681
682 int
683 gator_cursesgwin_invert(struct gwin *gwp, struct gwin_invparams *params)
684 {                               /*gator_cursesgwin_invert */
685
686     static char rn[] = "gator_cursesgwin_invert";       /*Routine name */
687
688     if (curses_debug)
689         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
690                 rn);
691
692     return (0);
693
694 }                               /*gator_cursesgwin_invert */
695
696 /*------------------------------------------------------------------------
697  * gator_cursesgwin_getchar
698  *
699  * Description:
700  *      Pick up a character from the given window.
701  *
702  * Arguments:
703  *      struct gwin *gwp : Ptr to the curses window to listen to.
704  *
705  * Returns:
706  *      Value of the character read,
707  *      -1 otherwise.
708  *
709  * Environment:
710  *      Nothing interesting.
711  *
712  * Side Effects:
713  *      As advertised.
714  *------------------------------------------------------------------------*/
715
716 int
717 gator_cursesgwin_getchar(struct gwin *gwp)
718 {                               /*gator_cursesgwin_getchar */
719
720     return (getc(stdin));
721
722 }                               /*gator_cursesgwin_getchar */
723
724 /*------------------------------------------------------------------------
725  * gator_cursesgwin_wait
726  *
727  * Description:
728  *      Wait until input is available.
729  *
730  * Arguments:
731  *      struct gwin *gwp : Ptr to the curses window to wait on.
732  *
733  * Returns:
734  *      0 on success,
735  *      Error value otherwise.
736  *
737  * Environment:
738  *      Nothing interesting.
739  *
740  * Side Effects:
741  *      As advertised.
742  *------------------------------------------------------------------------*/
743
744 int
745 gator_cursesgwin_wait(struct gwin *gwp)
746 {                               /*gator_cursesgwin_wait */
747
748     while (!LWP_WaitForKeystroke(-1));
749
750     return (0);
751
752 }                               /*gator_cursesgwin_wait */
753
754 /*------------------------------------------------------------------------
755  * gator_cursesgwin_getdimensions
756  *
757  * Description:
758  *      Get the window's X,Y dimensions.
759  *
760  * Arguments:
761  *      struct gwin *gwp               : Ptr to the curses window to examine.
762  *      struct gwin_sizeparams *params : Ptr to the size params to set.
763  *
764  * Returns:
765  *      0 on success,
766  *      Error value otherwise.
767  *
768  * Environment:
769  *      Nothing interesting.
770  *
771  * Side Effects:
772  *      As advertised.
773  *------------------------------------------------------------------------*/
774
775 int
776 gator_cursesgwin_getdimensions(struct gwin *gwp, struct gwin_sizeparams *aparms)
777 {                               /*gator_cursesgwin_getdimensions */
778
779     struct gator_cursesgwin *cwp;       /*Curses-specific data */
780
781     cwp = (struct gator_cursesgwin *)(gwp->w_data);
782 #if defined(AFS_NBSD_ENV) || defined(AFS_DARWIN100_ENV)
783     aparms->maxx = getmaxx(cwp->wp);
784     aparms->maxy = getmaxy(cwp->wp);
785 #else
786     aparms->maxx = cwp->wp->_maxx;
787     aparms->maxy = cwp->wp->_maxy;
788 #endif
789
790     return (0);
791
792 }                               /*gator_cursesgwin_getdimensions */