home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name wnpgadd -- Add window to linked list of windows
- * displayed on a device & display page.
- *
- * Synopsis presult = wnpgadd(pwindow,dev,page);
- *
- * WIN_NODE *presult Pointer to newly-created WIN_NODE
- * structure, or NIL if failure.
- * BWINDOW *pwindow Window to add to list
- * int dev Video display device (COLOR or MONO)
- * int page Video display page
- *
- * Description This function adds a window to the linked list which
- * governs the windows displayed on a given device and
- * video page. The window is stored as the topmost (i.e.,
- * most recently displayed).
- *
- * An error occurs if the window structure is invalid, if
- * the device or page are illegal, or if insufficient
- * memory is available for the window node.
- *
- * Returns presult Pointer to newly-created WIN_NODE
- * structure, or NIL if failure.
- * b_wnlist[][] Altered linked list if success.
- * pwindow->pnode Pointer to newly-created WIN_NODE
- * structure, or NIL if failure.
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_BAD_WIN *pwin is invalid.
- * WN_BAD_DEV Unknown device.
- * WN_NO_MEMORY Insufficient memory.
- * 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
-
- /* List of windows displayed on */
- /* each page (NIL if none). */
- WIN_NODE *(b_wnlist[MAX_DEVICES][MAX_PAGES]) = {0};
-
- WIN_NODE *wnpgadd(pwindow,dev,page)
- BWINDOW *pwindow;
- int dev,page;
- {
- WIN_NODE *pnew_node;
-
- if (wnvalwin(pwindow) == NIL) /* Validate window structure. */
- {
- wnerror(WN_BAD_WIN);
- return NIL;
- }
-
- if (dev != MONO && dev != COLOR) /* Make sure dev & page are */
- { /* within range of array */
- wnerror(WN_BAD_DEV); /* subscripts. */
- return NIL;
- }
- if (page < 0 || page >= MAX_PAGES)
- {
- wnerror(WN_BAD_PAGE);
- return NIL;
- }
-
- /* Create new node. */
- if ((pnew_node = utalloc(WIN_NODE)) == NIL)
- {
- wnerror(WN_NO_MEMORY);
- return NIL;
- }
-
- strcpy(pnew_node->signature,BNODE_SIGN); /* Distinctive signature */
-
- pnew_node->pwin = pwindow; /* Attach to window. */
-
- pnew_node->below = b_wnlist[dev][page]; /* Attach to former */
- /* topmost window. */
-
- if (pnew_node->below != NIL)
- pnew_node->below->above = pnew_node; /* Attach former topmost */
- /* to this window. */
-
- return b_wnlist[dev][page] = pnew_node; /* New head of list. */
- }