home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 24 DOS / 24-DOS.zip / winlsapi.zip / WINLIST.H < prev    next >
C/C++ Source or Header  |  1991-03-22  |  4KB  |  85 lines

  1. #ifndef LIST_INCL
  2. #define LIST_INCL
  3.  
  4. /**************************************************************************
  5.  *                         Windows List Manager API                       *
  6.  *                                                                        *
  7.  *                              by Dave Fassett                           * 
  8.  *                                                                        * 
  9.  *                              Aries Graphics                            * 
  10.  *                           7835 Quebrada Circle                         * 
  11.  *                            Carlsbad, CA 92009                          *
  12.  *                 (619) 436-5511 VOICE   (619) 436-0265 FAX              *
  13.  *                                                                        *
  14.  *                                                                        *
  15.  *   This list manager lets you deal with large sets of data in Windows   *
  16.  * protected mode, while incurring very little overhead. It is            *
  17.  * designed to handle very large lists of data, but there is one          *
  18.  * catch: each element must be the same size, or at least have a known    *
  19.  * maximum size. I have been using it for some time, and with all kinds   *
  20.  * of different list types (even for large Windows bitmaps, which had to  *
  21.  * be broken into less-than-32K bands).                                   *
  22.  *                                                                        *
  23.  **************************************************************************/
  24.  
  25. typedef struct _LINK {
  26.     struct _LINK FAR *Prev;
  27.     struct _LINK FAR *Next;
  28.     unsigned char fPresent;
  29. } LINK;
  30.  
  31. #define MAX_64KBLOCKS    32        // max list size == 2 megs
  32.                                 // you may want to modify this aspect of the
  33.                                 // manager, such that the hBlocks array is
  34.                                 // allocated dynamically, and so there
  35.                                 // wouldn't need to be a size limit
  36.  
  37. typedef LINK FAR *LPLINK;
  38.  
  39. typedef struct _LISTSTRUCT {
  40.     GLOBALHANDLE hThis;        // Handle to the memory used for this structure
  41.     HANDLE hBlocks[MAX_64KBLOCKS];    // Array of allocated block handles
  42.     int ItemSize;            // Size of the individual items
  43.     int nSegs;                // Number of 64K segments in use
  44.     long CurSegLen;            // Length of current 64K segment
  45.     long ArrayLen;            // Size of the array/heap for the list
  46.     long ListLen;            // Length of the list (# of items)
  47.     LPLINK Cur;                // Current item
  48.     LPLINK Head;            // Start of list
  49.     LPLINK Tail;            // Last item of list
  50.     LPLINK FreeList;        // List of free items available for reuse
  51.     } LISTSTRUCT;
  52.  
  53. typedef LISTSTRUCT FAR *HLIST;
  54.  
  55. HLIST FAR PASCAL CreateList(int ItemSize);
  56. HLIST FAR PASCAL DeleteList(HLIST);
  57. long FAR PASCAL ResetList(HLIST );
  58. long FAR PASCAL ListSize(HLIST );
  59. void FAR PASCAL SetCurItem(HLIST, LPVOID);
  60. LPSTR FAR PASCAL GetCurItem(HLIST );
  61. LPSTR FAR PASCAL GetListNext(HLIST );
  62. LPSTR FAR PASCAL GetListPrev(HLIST );
  63. LPSTR FAR PASCAL AppendList(HLIST , LPVOID );
  64. void FAR PASCAL ClearList(HLIST );
  65. LPSTR FAR PASCAL DeleteListItem(HLIST, LPVOID );
  66. LPSTR FAR PASCAL UnlinkListItem(HLIST, LPVOID );
  67. LPSTR FAR PASCAL LastListItem(HLIST );
  68. LPSTR FAR PASCAL InsertListAfter(HLIST h, LPVOID pAfter, LPVOID pItem);
  69. LPSTR FAR PASCAL InsertListBefore(HLIST h, LPVOID pBefore, LPVOID pItem);
  70. LPSTR FAR PASCAL GetNextFrom(HLIST h, LPVOID pCur);
  71. LPSTR FAR PASCAL GetPrevFrom(HLIST h, LPVOID pCur);
  72. LPSTR FAR PASCAL MoveToEnd(HLIST h, LPVOID pItem);
  73. LPSTR FAR PASCAL MoveToStart(HLIST h, LPVOID pItem);
  74. long FAR PASCAL GetItemIndex(HLIST p, LPVOID pItem);
  75. LPSTR FAR PASCAL InsertItemAt(HLIST p, LPVOID pItem, long iPos);
  76. LPSTR FAR PASCAL GetItemAt(HLIST P, long iPos);
  77. HLIST FAR PASCAL DupList(HLIST );
  78. int FAR PASCAL IsItemDeleted(HLIST p, LPVOID pItem);
  79. long FAR PASCAL RelinkItem(HLIST p, LPVOID pItem);
  80. LPSTR FAR PASCAL GetNextDeleted(HLIST p);
  81.  
  82. #define ListItemSize(list)        (((list)->ItemSize)-sizeof(LINK))
  83.  
  84. #endif
  85.