home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name wnpgrem -- Remove window from linked list of windows
- * displayed on a device & display page.
- *
- * Synopsis presult = wnpgrem(pwindow);
- *
- * WIN_NODE *presult Pointer to newly-removed BWINDOW
- * structure, or NIL if failure.
- * BWINDOW *pwindow Window to remove from list
- *
- * Description This function removes a window from the linked list
- * which governs the windows displayed on its video device
- * and display page.
- *
- * An error occurs if the window structure is invalid, if
- * the window is not attached to a location on a video
- * display device, or if the window is not attached to a
- * valid node.
- *
- * Returns presult Pointer to newly-removed BWINDOW
- * structure, or NIL if failure.
- * b_wnlist[][] Altered linked list if success.
- * pwindow->pnode NIL if success.
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_BAD_WIN *pwindow is invalid.
- * WN_BAD_NODE *pwindow not attached
- * to valid node.
- * WN_BAD_DEV Not shown.
- * WN_BAD_PAGE Internal error.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <string.h>
-
- #include <bwindow.h>
-
- #if MSC300
- #include <malloc.h>
- #else
- #include <stdlib.h>
- #endif
-
- BWINDOW *wnpgrem(pwindow)
- BWINDOW *pwindow;
- {
- int dev,page;
- WIN_NODE *pnode;
-
- if (wnvalwin(pwindow) == NIL)
- {
- wnerror(WN_BAD_WIN);
- return NIL;
- }
-
- if (wnvalnod(pnode = pwindow->pnode) == NIL)
- {
- wnerror(WN_BAD_NODE);
- return NIL;
- }
-
- dev = pwindow->where_shown.dev;
- if (dev != MONO && dev != COLOR)
- {
- wnerror(WN_BAD_DEV);
- return NIL;
- }
-
- page = pwindow->where_shown.page;
- if (page < 0 || page >= MAX_PAGES)
- {
- wnerror(WN_BAD_PAGE);
- return NIL;
- }
-
- if (b_wnlist[dev][page] == pnode) /* If this is top window, */
- /* link root of list to next */
- /* remaining window. */
- b_wnlist[dev][page] = pnode->below;
-
- if (pnode->above != NIL) /* Link next higher window */
- /* to next lower window. */
- pnode->above->below = pnode->below;
-
- /* Link next lower window */
- /* to next higher window. */
- if (pnode->below != NIL)
- pnode->below->above = pnode->above;
-
- pnode->above = /* Detach from next higher */
- /* window. */
- pnode->below = NIL; /* Detach from next lower window*/
- pnode->pwin = NIL; /* Detach node from window. */
- pwindow->pnode = NIL; /* Detach window from node. */
-
- strcpy(pnode->signature,"Closed");/* Mark the node abandoned. */
-
- free((char *) pnode); /* Free the node's memory. */
-
- return pwindow;
- }