IDZEBRA  2.2.7
d1_utils.c
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include <stdio.h>
24 #include <assert.h>
25 #include <stdlib.h>
26 
27 #include <yaz/log.h>
28 #include <idzebra/data1.h>
29 
31 {
32  /* n is first childen */
33  if (n->parent->child == n)
34  {
35  n->parent->child = n->next;
36 
37  /* n is the only child */
38  if(! n->next){
39  n->parent->last_child = 0;
40  }
41  }
42  /* n is one of the following childrens */
43  else
44  {
45  data1_node * before;
46 
47  /* need to find sibling before me */
48  before = n->parent->child;
49  while (before->next != n)
50  before = before->next;
51 
52  before->next = n->next;
53 
54  /* n is last child of many */
55  if ( n->parent->last_child == n)
56  n->parent->last_child = before;
57  }
58  /* break pointers to root, parent and following siblings */
59  n->parent = 0;
60  n->root = 0;
61  n->next = 0;
62 }
63 
65 {
66  if (n->which == DATA1N_tag && !strcmp(n->u.tag.tag, "idzebra")
67  && n->u.tag.attributes)
68  {
69  data1_xattr *xattr = n->u.tag.attributes;
70 
71  for (; xattr; xattr = xattr->next)
72  {
73  if (!strcmp(xattr->name, "xmlns")
74  && !strcmp(xattr->value, "http://www.indexdata.dk/zebra/"))
75  data1_remove_node(dh, n);
76  }
77  }
78  if (n->child)
80  if (n->next)
82 }
83 
84 /*
85  * Local variables:
86  * c-basic-offset: 4
87  * c-file-style: "Stroustrup"
88  * indent-tabs-mode: nil
89  * End:
90  * vim: shiftwidth=4 tabstop=8 expandtab
91  */
92 
void data1_remove_node(data1_handle dh, data1_node *n)
Definition: d1_utils.c:30
void data1_remove_idzebra_subtree(data1_handle dh, data1_node *n)
Definition: d1_utils.c:64
#define DATA1N_tag
Definition: data1.h:276
struct data1_node::@2::@3 root
struct data1_node * parent
Definition: data1.h:343
struct data1_node * child
Definition: data1.h:341
char * tag
Definition: data1.h:296
struct data1_node * next
Definition: data1.h:340
struct data1_node * last_child
Definition: data1.h:342
union data1_node::@2 u
int which
Definition: data1.h:285
char * value
Definition: data1.h:261
char * name
Definition: data1.h:260
struct data1_xattr * next
Definition: data1.h:262