1 /****************************************************************************
3 ** Program: pipe-handler - an AmigaDOS handler for named pipes
5 ** Author: Ed Puckett qix@mit-oz
7 ** Copyright 1987 by EpAc Software. All Rights Reserved.
9 ** History: 05-Jan-87 Original Version (1.0)
12 #include <exec/types.h>
14 #include "pipelists.h"
18 /*---------------------------------------------------------------------------
21 ** This module contains functions and macros for list manipulation.
22 ** To use its functions, a PIPELISTNODE must be part of the structure to be
23 ** inserted in a list. A list is identified by a PIPELISTHEADER (not a
24 ** pointer to, but an actual PIPELISTHEADER structure).
25 ** These routines, as implemented, use the fact that a PIPELISTHEADER
26 ** and a PIPELISTNODE have the same struture. Loops are started with the
27 ** scanning pointer referencing the header. This makes processing uniform,
28 ** even when the list is empty.
32 ** void InsertHead (headerp, nodep)
33 ** void InsertTail (headerp, nodep)
34 ** void Delete (headerp, nodep)
36 ** Macros (in pipelists.h)
37 ** -----------------------
39 ** FirstItem (headerp)
49 /*---------------------------------------------------------------------------
50 ** Insert the node pointed to by "nodep" at the head (front) of the list
51 ** identified by "headerp".
54 void InsertHead (headerp
, nodep
)
56 PIPELISTHEADER
*headerp
;
59 { nodep
->next
= headerp
->head
;
65 /*---------------------------------------------------------------------------
66 ** Insert the node pointed to by "nodep" at the tail (end) of the list
67 ** identified by "headerp".
70 void InsertTail (headerp
, nodep
)
72 PIPELISTHEADER
*headerp
;
75 { register PIPELISTNODE
*l
;
78 for (l
= (PIPELISTNODE
*) headerp
; l
->next
!= NULL
; l
= l
->next
)
87 /*---------------------------------------------------------------------------
88 ** Delete the node pointed to by "nodep" from the list identified by
89 ** "headerp". If the node is not found in the list, nothing is done.
92 void Delete (headerp
, nodep
)
94 PIPELISTHEADER
*headerp
;
100 for (l
= (PIPELISTNODE
*) headerp
; l
->next
!= NULL
; l
= l
->next
)
101 if (l
->next
== nodep
)
102 { l
->next
= l
->next
->next
;