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