home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Programming / icqsocket / include / libraries / llist.h < prev   
Encoding:
C/C++ Source or Header  |  1999-11-05  |  4.1 KB  |  157 lines

  1. //
  2. //    $VER: llist.h 2.0 (17.1.99)
  3. //
  4. //    Library base, tags, structures and macro definitions
  5. //    for llist.library.
  6. //
  7. //    ©1996-1997 Henrik Isaksson
  8. //    All Rights Reserved.
  9. //
  10.  
  11. #ifndef LIBRARIES_LLIST_H
  12. #define LIBRARIES_LLIST_H
  13.  
  14. #ifndef EXEC_TYPES_H
  15. #include <exec/types.h>
  16. #endif
  17.  
  18. #ifndef EXEC_LIBRARIES_H
  19. #include <exec/libraries.h>
  20. #endif
  21.  
  22. #ifndef UTILITY_TAGITEM_H
  23. #include <utility/tagitem.h>
  24. #endif
  25.  
  26. #define LINK_INFO    struct LinkInfo _LL_Link
  27. #define LINK_AUTO    struct LinkAuto _LL_Link
  28. #define LL_SIZE        sizeof(struct LinkList)
  29.  
  30. struct LinkInfo {
  31.     struct LinkInfo    *Prev;    //  0 Previuos item
  32.     struct LinkInfo    *Next;    //  4 Next item
  33.     ULONG        Size;    //  8 Size of this item
  34.     UWORD        Type;    // 12 Kind of item
  35. };              // size: 14
  36.  
  37. struct LinkList {
  38.     LINK_INFO;
  39.     struct LinkInfo *First;        // 14 First item
  40.     struct LinkInfo *Last;        // 18 Last item
  41.     struct LinkInfo *Current;    // 22 Current item
  42. };                  // size: 26
  43.  
  44. typedef struct LinkList LinkList;
  45. typedef struct LinkInfo LinkInfo;
  46.  
  47. //
  48. // Macros
  49. //
  50.  
  51. #define LL_Type(m)    (((struct LinkInfo *)m)->Type)
  52. #define LL_Size(m)    (((struct LinkInfo *)m)->Size)
  53. #define LL_VecSize(m)    (*((ULONG *)(((UBYTE *)m)-4)))
  54. #define LL_DataSize(m)    (LL_VecSize(m)-4)
  55. #define LL_Create(t)    (LL_New(sizeof(struct t)))
  56. #define LL_Current(l)    (((struct LinkList *)l)->Current)
  57.  
  58.  
  59. //
  60. // Node types
  61. //
  62.  
  63. #define LL_UNKNOWN    0    // Default
  64. #define LL_LIST        1    // Set by LL_NewList().
  65. #define LL_STOP        2    // Used in file I/O.
  66. #define LL_AUTO        3    // Automatic mode
  67.  
  68. #define LL_USER        100    // You may only use node types equal to, or
  69.                 // higher than, LL_USER.
  70.  
  71. #define LL_USERLIST    32000
  72.  
  73. //
  74. // File ID's
  75. // To reserve an ID of your own, just send me a mail.
  76. //
  77.  
  78. #define LLID_DEMO        1    // Used for the demo
  79. #define LLID_BOARDED        2    // BoardED's ID
  80. #define LLID_UBASE        3    // UltraBase
  81. #define LLID_BUILDER        4    // Magician
  82. #define LLID_CBAR        5    // ControlBar
  83. #define LLID_ICQ_CONTACT    6    // ICQSocket
  84. #define LLID_ICQ_CONFIG        7    // ICQSocket
  85. #define LLID_ICQ_RANDOM        8    // ICQSocket
  86. #define LLID_ICQ_UNKNOWN    9    // ICQSocket
  87. #define LLID_ICQ_INBOX        10    // ICQSocket
  88.  
  89. //
  90. // Error codes
  91. //
  92.  
  93. #define LLERR_FILETYPE    1    // Wrong file ID
  94. #define LLERR_MEM    2    // Out of memory
  95. #define LLERR_EOF    3    // Early end of file
  96.  
  97. #define LLERR_HOOK    100    // If you need to define your own returncodes
  98.                 // in the read/write hooks, only use numbers
  99.                 // higher than, or equal to this one.
  100.  
  101. //
  102. // Tags for LL_MergeData() & LL_ExtractData()
  103. //
  104.  
  105. #define XT_Base        TAG_USER
  106. #define MD_Base        TAG_USER+100
  107.  
  108. #define XT_Byte        (XT_Base+1)
  109. #define XT_Word        (XT_Base+2)
  110. #define XT_Long        (XT_Base+3)
  111. #define XT_IntelWord    (XT_Base+4)
  112. #define XT_IntelLong    (XT_Base+5)
  113. #define XT_BLBlock    (XT_Base+6)    // Block of data, length stored as a byte
  114. #define XT_WLBlock    (XT_Base+7)    // Block of data, length as Motorola Word
  115. #define XT_LLBlock    (XT_Base+8)
  116. #define XT_IWLBlock    (XT_Base+9)    // Length as Intel Word
  117. #define XT_ILLBlock    (XT_Base+10)
  118. #define XT_NullString    (XT_Base+11)    // NULL terminated string
  119. #define XT_MaxLen    (XT_Base+50)    // The length of your buffer. Defaults to 1k.
  120.  
  121. #define MD_Byte        (MD_Base+1)
  122. #define MD_Word        (MD_Base+2)
  123. #define MD_Long        (MD_Base+3)
  124. #define MD_IntelWord    (MD_Base+4)
  125. #define MD_IntelLong    (MD_Base+5)
  126. #define MD_BLBlock    (MD_Base+6)    // Block of data, length stored as a byte
  127. #define MD_WLBlock    (MD_Base+7)    // Block of data, length as Motorola Word
  128. #define MD_LLBlock    (MD_Base+8)
  129. #define MD_IWLBlock    (MD_Base+9)    // Length as Intel Word
  130. #define MD_ILLBlock    (MD_Base+10)
  131. #define MD_NullString    (MD_Base+11)    // NULL terminated string
  132. #define MD_String    (MD_Base+12)    // Just the string chars
  133. #define MD_Size        (MD_Base+50)    // Size of next block
  134.  
  135. //
  136. // Library base
  137. //
  138.  
  139. struct LListBase {
  140.     struct Library        ll_Library;
  141.     ULONG            ll_SegList;
  142.     ULONG            ll_Flags;
  143.     APTR            ll_MemPool;        // Memory pool
  144.     LONG            ll_MemFile;        // Not implemented
  145.     struct Library        *ll_ExecBase;
  146.     struct Library        *ll_UtilityBase;
  147.     struct Library        *ll_DOSBase;
  148. };
  149.  
  150. #define LLIST_VERSION    2L
  151. #define LLIST_NAME    "llist.library"
  152. #define OPEN_LLIST()    (LListBase = (struct LListBase *)OpenLibrary(LLIST_NAME, LLIST_VERSION))
  153. #define CLOSE_LLIST()    if(LListBase) CloseLibrary((struct Library *)LListBase);
  154. #define LL_FILE_ID    (0x4a4a3461)
  155.  
  156. #endif
  157.