LL_MAN.H 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. Copyright (C) 1994-1995 Apogee Software, Ltd.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /**********************************************************************
  16. module: LL_MAN.H
  17. author: James R. Dose
  18. date: February 4, 1994
  19. Public header for LL_MAN.C. Linked list management routines.
  20. (c) Copyright 1994 James R. Dose. All Rights Reserved.
  21. **********************************************************************/
  22. #ifndef __LL_MAN_H
  23. #define __LL_MAN_H
  24. enum LL_Errors
  25. {
  26. LL_Warning = -2,
  27. LL_Error = -1,
  28. LL_Ok = 0
  29. };
  30. typedef struct list
  31. {
  32. void *start;
  33. void *end;
  34. } list;
  35. void LL_AddNode( char *node, char **head, char **tail, int next, int prev );
  36. void LL_RemoveNode( char *node, char **head, char **tail, int next, int prev );
  37. void LL_UnlockMemory( void );
  38. int LL_LockMemory( void );
  39. #define LL_AddToHead( type, listhead, node ) \
  40. LL_AddNode( ( char * )( node ), \
  41. ( char ** )&( ( listhead )->start ), \
  42. ( char ** )&( ( listhead )->end ), \
  43. ( int )&( ( type * ) 0 )->next, \
  44. ( int )&( ( type * ) 0 )->prev )
  45. #define LL_AddToTail( type, listhead, node ) \
  46. LL_AddNode( ( char * )( node ), \
  47. ( char ** )&( ( listhead )->end ), \
  48. ( char ** )&( ( listhead )->start ), \
  49. ( int )&( ( type * ) 0 )->prev, \
  50. ( int )&( ( type * ) 0 )->next )
  51. #define LL_Remove( type, listhead, node ) \
  52. LL_RemoveNode( ( char * )( node ), \
  53. ( char ** )&( ( listhead )->start ), \
  54. ( char ** )&( ( listhead )->end ), \
  55. ( int )&( ( type * ) 0 )->next, \
  56. ( int )&( ( type * ) 0 )->prev )
  57. #define LL_NextNode( node ) ( ( node )->next )
  58. #define LL_PreviousNode( node ) ( ( node )->prev )
  59. #endif