Accept topic changes from servers that do not send topic-set timestamps (fixes SF...
[ircu2.10.12-pk.git] / libs / dbprim / sh_move.c
1 /*
2 ** Copyright (C) 2002 by Kevin L. Mitchell <klmitch@mit.edu>
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Library General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ** Library General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Library General Public
15 ** License along with this library; if not, write to the Free
16 ** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
17 ** MA 02111-1307, USA
18 **
19 ** @(#)$Id$
20 */
21 #include "dbprim.h"
22 #include "dbprim_int.h"
23
24 RCSTAG("@(#)$Id$");
25
26 /** \ingroup dbprim_smat
27  * \brief Move an entry within a row or column list.
28  *
29  * This function allows the specified entry to be shifted within the
30  * linked list describing the row or column.  It is very similar to
31  * the ll_move() function.
32  *
33  * \param head  A pointer to a #smat_head_t.
34  * \param elem  A pointer to the #smat_entry_t describing the entry to
35  *              be moved.
36  * \param loc   A #link_loc_t indicating where the entry should be
37  *              moved to.
38  * \param elem2 A pointer to a #smat_entry_t describing another entry
39  *              in the list if \p loc is #LINK_LOC_BEFORE or
40  *              #LINK_LOC_AFTER.
41  *
42  * \retval DB_ERR_BADARGS       An argument was invalid.
43  * \retval DB_ERR_BUSY          \p elem and \p elem2 are the same
44  *                              entry.
45  * \retval DB_ERR_WRONGTABLE    \p elem or \p elem2 are in a different
46  *                              row or column.
47  * \retval DB_ERR_UNUSED        \p elem or \p elem2 are not in any row
48  *                              or column.
49  */
50 unsigned long
51 sh_move(smat_head_t *head, smat_entry_t *elem, link_loc_t loc,
52         smat_entry_t *elem2)
53 {
54   initialize_dbpr_error_table(); /* initialize error table */
55
56   /* Verify arguments--if elem is set, must be a valid element; if
57    * location is before or after, elem must be set
58    */
59   if (!sh_verify(head) || !se_verify(elem) || (elem2 && !se_verify(elem2)))
60     return DB_ERR_BADARGS;
61
62   /* OK, call out to the linked list operation--it'll figure
63    * everything else out
64    */
65   return ll_move(&head->sh_head, &elem->se_link[head->sh_elem], loc,
66                  elem2 ? &elem2->se_link[head->sh_elem] : 0);
67 }