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