check curses-libs by configure
[openafs.git] / src / gtx / curseswindows.c
index 7dc59b8..1d28040 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 
 
 
-#if defined(AFS_HPUX110_ENV) && !defined(__HP_CURSES)
-#define __HP_CURSES
-#endif
-
-#ifndef        AFS_SUN5_ENV
-#include <curses.h>            /*Curses library */
-#endif
 #include <sys/types.h>
 #include <sys/file.h>
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD80_ENV)
 #include <sgtty.h>
 #endif
 #include <stdio.h>
@@ -121,13 +114,13 @@ gator_cursesgwin_init(int adebug)
      */
     if (curses_debug)
        fprintf(stderr,
-               "[%s:%s] Allocating %lu bytes for curses window private space in base window\n",
+               "[%s:%s] Allocating %" AFS_SIZET_FMT " bytes for curses window private space in base window\n",
                mn, rn, sizeof(struct gator_cursesgwin));
     c_data =
        (struct gator_cursesgwin *)malloc(sizeof(struct gator_cursesgwin));
     if (c_data == (struct gator_cursesgwin *)0) {
        fprintf(stderr,
-               "[%s:%s] Can't allocate %lu bytes for curses window private space in base window\n",
+               "[%s:%s] Can't allocate %" AFS_SIZET_FMT " bytes for curses window private space in base window\n",
                mn, rn, sizeof(struct gator_cursesgwin));
        return (-1);
     }
@@ -195,22 +188,22 @@ gator_cursesgwin_init(int adebug)
  *------------------------------------------------------------------------*/
 
 struct gwin *
-gator_cursesgwin_create(struct gator_cursesgwin_params *params)
-{                              /*gator_cursesgwin_create */
-
+gator_cursesgwin_create(void * rock)
+{
     static char rn[] = "gator_cursesgwin_create";      /*Routine name */
+    struct gator_cursesgwin_params *params = (struct gator_cursesgwin_params *)rock;
     struct gwin *newgwin;      /*Ptr to new curses window */
     struct gator_cursesgwin *c_data;   /*Ptr to curses-specific data */
     WINDOW *newcursgwin;       /*Ptr to new curses window */
 
     if (curses_debug)
        fprintf(stderr,
-               "[%s:%s] Allocating %lu bytes for new gwin structure\n", mn,
+               "[%s:%s] Allocating %" AFS_SIZET_FMT " bytes for new gwin structure\n", mn,
                rn, sizeof(struct gwin));
     newgwin = (struct gwin *)malloc(sizeof(struct gwin));
     if (newgwin == NULL) {
        fprintf(stderr,
-               "[%s:%s] Can't malloc() %lu bytes for new gwin structure: Errno is %d\n",
+               "[%s:%s] Can't malloc() %" AFS_SIZET_FMT " bytes for new gwin structure: Errno is %d\n",
                mn, rn, sizeof(struct gwin), errno);
        return (NULL);
     }
@@ -226,13 +219,13 @@ gator_cursesgwin_create(struct gator_cursesgwin_params *params)
 
     if (curses_debug)
        fprintf(stderr,
-               "[%s:%s] Allocating %lu bytes for curses window private space\n",
+               "[%s:%s] Allocating %" AFS_SIZET_FMT " bytes for curses window private space\n",
                mn, rn, sizeof(struct gator_cursesgwin));
     c_data =
        (struct gator_cursesgwin *)malloc(sizeof(struct gator_cursesgwin));
     if (c_data == (struct gator_cursesgwin *)0) {
        fprintf(stderr,
-               "[%s:%s] Can't allocate %lu bytes for curses window private space\n",
+               "[%s:%s] Can't allocate %" AFS_SIZET_FMT " bytes for curses window private space\n",
                mn, rn, sizeof(struct gator_cursesgwin));
        free(newgwin);
        return (NULL);
@@ -578,6 +571,7 @@ gator_cursesgwin_drawchar(struct gwin *gwp, struct gwin_charparams *params)
     static char rn[] = "gator_cursesgwin_drawchar";    /*Routine name */
     struct gator_cursesgwin *cwp;      /*Ptr to curses private area */
     int curses_x, curses_y;    /*Mapped x,y positions */
+    int code=0;
 
     cwp = (struct gator_cursesgwin *)(gwp->w_data);
     curses_x = GATOR_MAP_X_TO_COL(cwp, params->x);
@@ -589,10 +583,14 @@ gator_cursesgwin_drawchar(struct gwin *gwp, struct gwin_charparams *params)
                curses_x, (params->highlight ? ", using standout mode" : ""));
     wmove(cwp->wp, curses_y, curses_x);
     if (params->highlight)
-       wstandout(cwp->wp);
+       code=wstandout(cwp->wp);
+        if (code)
+           return (code);
     waddch(cwp->wp, params->c);
     if (params->highlight)
-       wstandend(cwp->wp);
+       code=wstandend(cwp->wp);
+        if (code)
+            return (code);
 
     return (0);
 
@@ -627,6 +625,7 @@ gator_cursesgwin_drawstring(struct gwin *gwp, struct gwin_strparams *params)
     static char rn[] = "gator_cursesgwin_drawstring";  /*Routine name */
     struct gator_cursesgwin *cwp;      /*Ptr to curses private area */
     int curses_x, curses_y;    /*Mapped x,y positions */
+    int code=0;
 
     cwp = (struct gator_cursesgwin *)(gwp->w_data);
     curses_x = GATOR_MAP_X_TO_COL(cwp, params->x);
@@ -638,12 +637,16 @@ gator_cursesgwin_drawstring(struct gwin *gwp, struct gwin_strparams *params)
                curses_x, (params->highlight ? ", using standout mode" : ""));
     wmove(cwp->wp, curses_y, curses_x);
     if (params->highlight)
-       wstandout(cwp->wp);
+       code=wstandout(cwp->wp);
+       if (code)
+           return (code);
     waddstr(cwp->wp, params->s);
     if (params->highlight)
-       wstandend(cwp->wp);
+       code=wstandend(cwp->wp);
+       if (code)
+           return (code);
 
-    return (0);
+    return (code);
 
 }                              /*gator_cursesgwin_drawstring */
 
@@ -769,10 +772,7 @@ gator_cursesgwin_getdimensions(struct gwin *gwp, struct gwin_sizeparams *aparms)
     struct gator_cursesgwin *cwp;      /*Curses-specific data */
 
     cwp = (struct gator_cursesgwin *)(gwp->w_data);
-#if defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN60_ENV)
-    aparms->maxx = cwp->wp->maxx;
-    aparms->maxy = cwp->wp->maxy;
-#elif defined(AFS_NBSD_ENV) || defined(AFS_DARWIN100_ENV)
+#if defined(AFS_NBSD_ENV) || defined(AFS_DARWIN100_ENV)
     aparms->maxx = getmaxx(cwp->wp);
     aparms->maxy = getmaxy(cwp->wp);
 #else