1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2012 Index Data
4 Pazpar2 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
9 Pazpar2 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
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
22 #include <yaz/yaz-util.h>
29 #include "pazpar2_config.h"
33 union data_types * data_types_assign(NMEM nmem,
34 union data_types ** data1,
35 union data_types data2)
46 *data1 = nmem_malloc(nmem, sizeof(union data_types));
54 struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys,
55 struct client *client, int position)
57 struct record * record = 0;
59 const char *name = client_get_id(client);
60 unsigned h = position;
64 record = nmem_malloc(nmem, sizeof(struct record));
67 record->client = client;
71 sizeof(struct record_metadata*) * num_metadata);
72 for (i = 0; i < num_metadata; i++)
73 record->metadata[i] = 0;
77 sizeof(union data_types*) * num_sortkeys);
78 for (i = 0; i < num_sortkeys; i++)
79 record->sortkeys[i] = 0;
81 record->position = position;
83 for (i = 0; name[i]; i++)
84 h = h * 65509 + ((unsigned char *) name)[i];
91 struct record_metadata * record_metadata_create(NMEM nmem)
93 struct record_metadata * rec_md
94 = nmem_malloc(nmem, sizeof(struct record_metadata));
96 rec_md->attributes = 0;
101 int record_compare(struct record *r1, struct record *r2,
102 struct conf_service *service)
105 for (i = 0; i < service->num_metadata; i++)
107 struct conf_metadata *ser_md = &service->metadata[i];
108 enum conf_metadata_type type = ser_md->type;
110 struct record_metadata *m1 = r1->metadata[i];
111 struct record_metadata *m2 = r2->metadata[i];
116 case Metadata_type_generic:
117 if (strcmp(m1->data.text.disp, m2->data.text.disp))
120 case Metadata_type_date:
121 case Metadata_type_year:
122 if (m1->data.number.min != m2->data.number.min ||
123 m1->data.number.max != m2->data.number.max)
139 * c-file-style: "Stroustrup"
140 * indent-tabs-mode: nil
142 * vim: shiftwidth=4 tabstop=8 expandtab