--- mstools/samples/deb/linklist.h 2018/08/09 18:20:39 1.1 +++ mstools/samples/deb/linklist.h 2018/08/09 18:21:33 1.1.1.2 @@ -1,9 +1,12 @@ // ************************************************************************ -// LinkList.H - (Ordered) Double Linked List Header -// ************************************************************************ -// PURPOSE: Provide a generalized sorted double linked list package // -// FUNCTIONS: +// Microsoft Developer Support +// Copyright (c) 1992 Microsoft Corporation +// +// ************************************************************************ +// HEADER : LinkList.H +// PURPOSE : Provide a generalized sorted double linked list package +// FUNCTIONS : // InitList - initialize/clear list // CreateNode - allocate a new node that can be put into list // InsertNode - insert a new node into the list @@ -30,62 +33,68 @@ // } // // ************************************************************************ -#include // for DWORD definition only +#ifndef LINKLIST_H -#define NO_ERROR_FOUND 1 -#define NO_FREE_MEM_ERROR -1 -#define NO_NODE_ERROR -2 -#define NO_MATCH_ERROR -3 -#define NO_NEXT_NODE_ERROR -4 -#define NO_PREV_NODE_ERROR -5 - -#define DEREFERENCE_NULL_ERROR -99 - -#define LEFT_OF -1 -#define MATCH 0 -#define OVERWRITE 0 -#define RIGHT_OF 1 + #define LINKLIST_H -// ************************************************************************ -// the NODE_DATA type should be modified to suit needs - -typedef struct NODE_DATA_STRUCT { - DWORD dwThreadId; - HANDLE hThread; - } NODE_DATA; - -//* End of custom NODE_DATA definition -// ************************************************************************ + #include // for DWORD definition only -typedef struct NODE_STRUCT* PNODE; + #define NO_ERROR_FOUND 1 + #define NO_FREE_MEM_ERROR -1 + #define NO_NODE_ERROR -2 + #define NO_MATCH_ERROR -3 + #define NO_NEXT_NODE_ERROR -4 + #define NO_PREV_NODE_ERROR -5 + + #define DEREFERENCE_NULL_ERROR -99 + + #define LEFT_OF -1 + #define MATCH 0 + #define OVERWRITE 0 + #define RIGHT_OF 1 + + // ************************************************************************ + // the NODE_DATA type should be modified to suit needs + + typedef struct NODE_DATA_STRUCT { + DWORD dwThreadId; + HANDLE hThread; + } NODE_DATA; + + //* End of custom NODE_DATA definition + // ************************************************************************ + + typedef struct NODE_STRUCT* PNODE; + + //-- definition of a node + typedef struct NODE_STRUCT { + NODE_DATA NodeData; + PNODE pLeftLink; + PNODE pRightLink; + } NODE; + + //-- definition of a list + typedef struct LIST_STRUCT* PLIST; + + typedef struct LIST_STRUCT { + int ListError; + PNODE pFirstNode; + PNODE pCurrentNode; + PNODE pLastNode; + int (*OrderFunction)(PNODE, PNODE); + } LIST; + + //-- prototypes + int GetListError( PLIST pList ); + int InitList( PLIST pList, int (*OrderingFunction)( PNODE pNodeOne, PNODE pNodeTwo ) ); + int CreateNode( PLIST pList, PNODE* pNewNode ); + int InsertNode( PLIST pList, PNODE pNewNode ); + int DestroyNode( PNODE pNode ); + int DeleteCurrentNode( PLIST pList ); + int GetNextNode( PLIST pList, PNODE* ppNode ); + int GetPreviousNode( PLIST pList, PNODE* ppNode ); + int GetNode( PLIST pList, PNODE* pKeyNode, + int (*MatchingFunction)( PNODE pNodeOne, PNODE pNodeTwo ), + int Occurence ); -//-- definition of a node -typedef struct NODE_STRUCT { - NODE_DATA NodeData; - PNODE pLeftLink; - PNODE pRightLink; - } NODE; - -//-- definition of a list -typedef struct LIST_STRUCT* PLIST; - -typedef struct LIST_STRUCT { - int ListError; - PNODE pFirstNode; - PNODE pCurrentNode; - PNODE pLastNode; - int (*OrderFunction)(PNODE, PNODE); - } LIST; - -//-- prototypes -int GetListError( PLIST pList ); -int InitList( PLIST pList, int (*OrderingFunction)( PNODE pNodeOne, PNODE pNodeTwo ) ); -int CreateNode( PLIST pList, PNODE* pNewNode ); -int InsertNode( PLIST pList, PNODE pNewNode ); -int DestroyNode( PNODE pNode ); -int DeleteCurrentNode( PLIST pList ); -int GetNextNode( PLIST pList, PNODE* ppNode ); -int GetPreviousNode( PLIST pList, PNODE* ppNode ); -int GetNode( PLIST pList, PNODE* pKeyNode, - int (*MatchingFunction)( PNODE pNodeOne, PNODE pNodeTwo ), - int Occurence ); +#endif // LINKLIST_H