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