/* $Id: $ * * Project: System/360 system environment distribution * Subsystem: Stupid bot to prevent kids (meppl says hi!) from taking * control over #arab * Scope: Bits::fagtrap * File: c_list.h * Synopsis: Self contained list handling primitives roughly reflecting * and/or reimplementing the behaviour of the system wide * Run Time Library. To quote the original source: * ,,[ ... ] These methods operate on the following * list types: * o Singly linked list with {head,tail} pointer. (linked list) * o Circular (doubly linked) list, (circular list) * o FIFO stack list, (queue list) * o LIFO stack list (LRU list.) ([LRU] stack list)'' * Notes: The sole reason for the code in c_*.c to exist is that Rtl * is only reliable in its own native environment. * * ------------------ * $Log: $ * ------------------ * * Copyright (c) 2006 Lucio 'arab-' Albornoz * * This software may be used, modified, copied, and distributed, in * both source and binary form provided that the above copyright and * these terms are retained. Under no circumstances is the author * responsible for the proper functioning of this software, nor does * the author assume any responsibility for damages incurred with its * use. * */ #ifndef _RTL_LIST_H_ #define _RTL_LIST_H_ /* {{{ COMMON */ /* ... */ /* }}} COMMON */ /* {{{ INTERNAL*/ /* --- Common list type definitions --- */ /* Common list */ typedef struct { pvoid_t m_pPayLoad; /* The node's payload. */ list_t *m_pNext; /* Pointer to next node or NULL. */ } list_t; /* Common circular * typdef struct { pvoid_t m_pPayLoad; /* The node's payload. */ circular_t \ *m_pPrevious, /* Pointers to previous and */ *m_pNext /* next nodes or NULL. */ } circular_t; /* Common queue */ typedef struct { pvoid_t m_pPayLoad; /* The node's payload. */ queue_t *m_pPrevious; /* Pointer to previous node or NULL. */ } queue_t; /* Common stack */ typedef struct { pvoid_t m_PayLoad; /* The node's payload. */ stack_t *m_pNext; /* Pointer to next node or NULL. */ } stack_t; /* --- Tagged list type definitions --- */ /* Tagged list */ typedef struct { refid_t m_tRefID; /* Internally used reference ID, only * used in tagged lists. */ pvoid_t m_pPayLoad; /* The node's payload. */ tagged_list_t \ *m_pNext; /* Pointer to next node or NULL. */ } tagged_list_t; /* Tagged circular * typdef struct { refid_t m_tRefID; /* Internally used reference ID, only * used in tagged circulars. */ pvoid_t m_pPayLoad; /* The node's payload. */ tagged_circular_t \ *m_pPrevious, /* Pointers to previous and */ *m_pNext /* next nodes or NULL. */ } tagged_circular_t; /* Tagged queue */ typedef struct { refid_t m_tRefID; /* Internally used reference ID, only * used in tagged queue. */ pvoid_t m_pPayLoad; /* The node's payload. */ tagged_queue_t \ *m_pPrevious; /* Pointer to previous node or NULL. */ } tagged_queue_t; /* Tagged stack */ typedef struct { refid_t m_tRefID; /* Internally used reference ID, only * used in tagged stack. */ pvoid_t m_PayLoad; /* The node's payload. */ tagged_stack_t \ *m_pNext; /* Pointer to next node or NULL. */ } tagged_stack_t; /* }}} INTERNAL */ /* {{{ EXPORTS */ /* --- Exported types --- */ /* Common list type */ RTL_EXPORT_PTYPE(list_t, RtlList_t, "Rtl list type primitive"); RTL_EXPORT_PTYPE(circular_t, RtlCircular_t, "Rtl circular type primitive"); RTL_EXPORT_PTYPE(queue_t, RtlQueue_t, "Rtl queue type primitive"); RTL_EXPORT_PTYPE(stack_t, RtlStack_t, "Rtl stack type primitive"); RTL_EXPORT_TYPE(list_t*, PLIST, "Rtl list pointer"); RTL_EXPORT_TYPE(circular_t*, PCIRCULAR, "Rtl circular pointer"); RTL_EXPORT_TYPE(queue_t*, PQUEUE, "Rtl queue pointer"); RTL_EXPORT_TYPE(stack_t*, PSTACK, "Rtl stack pointer"); /* Tagged list type */ RTL_EXPORT_PTYPE(tagged_list_t, RtlTagList_t, "Rtl taglist type primitive"); RTL_EXPORT_PTYPE(tagged_circular_t, RtlTagCircular_t, "Rtl tagcircular type primitive"); RTL_EXPORT_PTYPE(tagged_queue_t, RtlTagQueue_t, "Rtl tagqueue type primitive"); RTL_EXPORT_PTYPE(tagged_stack_t, RtlTagStack_t, "Rtl tagstack type primitive"); RTL_EXPORT_TYPE(tagged_list_t*, PTAGLIST, "Rtl taglist pointer"); RTL_EXPORT_TYPE(tagged_circular_t*, PTAGCIRCULAR, "Rtl tagcircular pointer"); RTL_EXPORT_TYPE(tagged_queue_t*, PTAGQUEUE, "Rtl tagqueue pointer"); RTL_EXPORT_TYPE(tagged_stack_t*, PTAGSTACK, "Rtl tagstack pointer"); /* --- Exported primitives --- */ /* Create a common list and initialize it with a node * holding the specified literal as a payload. */ RTL_EXPORT_PMETH(PLIST, RtlCreateListFromLiteral ( \ PLITERAL a_pPayLoad, \ RTLFLAGS a_fCreationFlags)); /* Create a common circular and initialize it with a node * holding the specified literal as a payload. */ RTL_EXPORT_PMETH(PCIRCULAR, RtlCreateCircularFromLiteral( \ PLITERAL a_pPayLoad, \ RTLFLAGS a_fCreationFlags )); /* Create a common queue and initialize it with a node * holding the specified literal as a payload. */ RTL_EXPORT_PMETH(PQUEUE, RtlCreateQueueFromLiteral( \ PLITERAL a_pPayLoad, \ RTLFLAGS a_fCreationFlags)); /* Create a common stack and initialize it with a node * holding the specified literal as a payload. */ RTL_EXPORT_PMETH(PSTACK, RtlCreateStackFromLiteral( \ PLITERAL a_pPayLoad, \ RTLFLAGS a_fCreationFlags)); /* Create a tagged list and initialize it with a node * holding the specified literal as a payload. */ RTL_EXPORT_PMETH(PTAGLIST, RtlCreateTaggedListFromLiteral( \ PLITERAL a_pPayLoad, \ RTLFLAGS a_fCreationFlags)); /* Create a tagged circular and initialize it with a node * holding the specified literal as a payload. */ RTL_EXPORT_PMETH(PTAGCIRCULAR, RtlCreateTaggedCircularFromLiteral( \ PLITERAL a_pPayLoad, \ RTLFLAGS a_fCreationFlags )); /* Create a tagged queue and initialize it with a node * holding the specified literal as a payload. */ RTL_EXPORT_PMETH(PTAGQUEUE, RtlCreateTaggedQueueFromLiteral( \ PLITERAL a_pPayLoad, \ RTLFLAGS a_fCreationFlags)); /* Create a tagged stack and initialize it with a node * holding the specified literal as a payload. */ RTL_EXPORT_PMETH(PTAGSTACK, RtlCreateTaggedStackFromLiteral( \ PLITERAL a_pPayLoad, \ RTLFLAGS a_fCreationFlags)); /* --- Primitive's RTLFLAGS --- */ /* Global list flags */ RTL_DEFINE_FLAG(RTLF_LIST_TAILP); /* List with tail pointer */ RTL_DEFINE_FLAG(RTLF_LIST_HEADP); /* List with head pointer */ RTL_DEFINE_FLAG(RTLF_LIST_TAGGED); /* Tagged list */ /* {{{ EXPORTS */