1 /* $Id: record.c,v 1.4 2007-04-24 13:50:07 marc Exp $
2 Copyright (c) 2006-2007, Index Data.
4 This file is part of Pazpar2.
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 /* $Id: record.c,v 1.4 2007-04-24 13:50:07 marc Exp $ */
27 #include <yaz/yaz-util.h>
34 //#define CONFIG_NOEXTERNS
40 union data_types * data_types_assign(NMEM nmem,
41 union data_types * data1,
42 union data_types data2)
50 data1 = nmem_malloc(nmem, sizeof(union data_types));
58 struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys)
60 struct record * record = 0;
64 record = nmem_malloc(nmem, sizeof(struct record));
67 // which client should I use for record->client = cl; ??
72 sizeof(struct record_metadata*) * num_metadata);
73 //memset(record->metadata, 0,
74 //(( sizeof(struct record_metadata*) * num_metadata);
78 sizeof(union data_types*) * num_sortkeys);
79 //memset(record->metadata, 0,
80 // sizeof(union data_types*) * num_sortkeys);
87 struct record_metadata * record_metadata_insert(NMEM nmem,
88 struct record_metadata ** rmd,
89 union data_types data)
91 struct record_metadata * tmp_rmd = 0;
97 // construct new record_metadata
98 tmp_rmd = nmem_malloc(nmem, sizeof(struct record_metadata));
102 // insert in *rmd's place
103 tmp_rmd->next = *rmd;
109 struct record_metadata * record_add_metadata_field_id(NMEM nmem,
110 struct record * record,
112 union data_types data)
114 if (field_id < 0 || !record || !record->metadata)
117 return record_metadata_insert(nmem, &(record->metadata[field_id]), data);
121 struct record_metadata * record_add_metadata(NMEM nmem,
122 struct record * record,
123 struct conf_service * service,
125 union data_types data)
129 if (!record || !record->metadata || !service || !name)
132 field_id = conf_service_metadata_field_id(service, name);
137 return record_metadata_insert(nmem, &(record->metadata[field_id]), data);
145 union data_types * record_assign_sortkey_field_id(NMEM nmem,
146 struct record * record,
148 union data_types data)
150 if (field_id < 0 || !record || !record->sortkeys)
153 return data_types_assign(nmem, record->sortkeys[field_id], data);
158 union data_types * record_assign_sortkey(NMEM nmem,
159 struct record * record,
160 struct conf_service * service,
162 union data_types data)
166 if (!record || !service || !name)
169 field_id = conf_service_sortkey_field_id(service, name);
171 if (!(field_id < service->num_sortkeys))
174 return record_assign_sortkey_field_id(nmem, record, field_id, data);
182 * indent-tabs-mode: nil
184 * vim: shiftwidth=4 tabstop=8 expandtab