The outage for Sunday 24th November has been cancelled.
Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
MovePDB.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file MovePDB.c
5 
6  \version V1.3
7  \date 07.07.14
8  \brief
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1993-2014
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.1 01.03.94
50 - V1.2 27.02.98 Removed unreachable break from switch()
51 - V1.2a 06.01.11 Corrected description
52 - V1.3 07.07.14 Use bl prefix for functions By: CTP
53 
54 *************************************************************************/
55 /* Doxygen
56  -------
57  #GROUP Handling PDB Data
58  #SUBGROUP Manipulating the PDB linked list
59  #FUNCTION blMovePDB()
60  Moves a PDB record from one linked list to another. from and to should
61 */
62 /************************************************************************/
63 /* Includes
64 */
65 #include "SysDefs.h"
66 #include "pdb.h"
67 #include "macros.h"
68 
69 /************************************************************************/
70 /* Defines and macros
71 */
72 
73 /************************************************************************/
74 /* Globals
75 */
76 
77 /************************************************************************/
78 /* Prototypes
79 */
80 
81 
82 /************************************************************************/
83 /*>BOOL blMovePDB(PDB *move, PDB **from, PDB **to)
84  -----------------------------------------------
85 *//**
86 
87  \param[in] *move PDB record to be moved
88  \param[in,out] **from Start of PDB linked list containing record
89  \param[in,out] **to Start of output linked list
90  \return Success?
91 
92  Moves a PDB record from one linked list to another. from and to should
93  point to the start of the 2 lists. If the to list hasn't been started,
94  to should be NULL. Returns TRUE if moved, FALSE otherwise.
95 
96 - 13.05.92 Original
97 - 19.06.92 Changed p=*to, etc. for crappy compilers
98 - 07.07.14 Use bl prefix for functions By: CTP
99 */
100 BOOL blMovePDB(PDB *move, PDB **from, PDB **to)
101 {
102  PDB *p;
103  BOOL ret = FALSE;
104 
105  if(move != NULL && *from != NULL)
106  {
107  /* Find the item before move in the *from list */
108  if(move == (*from)) /* Start of list */
109  {
110  p = NULL;
111  }
112  else /* Middle of list */
113  {
114  /* Move p to item before move */
115  for(p = (*from); p->next && p->next != move; NEXT(p)) ;
116  }
117 
118  /* Unlink move from *from */
119  if(p) /* We're moving something in the middle of the list*/
120  {
121  /* Unlink move */
122  p->next = move->next;
123  }
124  else /* We're moving the first one in the list */
125  {
126  /* If first in *from list, reset *from list */
127  *from = move->next;
128  }
129 
130  /* Add move onto the end of *to */
131  move->next = NULL;
132  if(*to)
133  {
134  /* Move p to end of *to list */
135  for(p=(*to); p->next; NEXT(p)) ;
136  /* Link in move */
137  p->next = move;
138  }
139  else
140  {
141  /* Initialise *to list */
142  *to = move;
143  }
144  ret = TRUE;
145  }
146  return(ret);
147 }
148 
Include file for PDB routines.
short BOOL
Definition: SysDefs.h:64
#define NULL
Definition: array2.c:99
Definition: pdb.h:298
#define FALSE
Definition: macros.h:223
#define NEXT(x)
Definition: macros.h:249
Useful macros.
#define TRUE
Definition: macros.h:219
BOOL blMovePDB(PDB *move, PDB **from, PDB **to)
Definition: MovePDB.c:100
System-type variable type definitions.
struct pdb_entry * next
Definition: pdb.h:307