2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2 of the License, or (at your option) any later version.
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 * Copyright (C) 2008 Liam Girdwood
20 #include <libastrodb/astro.h>
22 struct astrodb_schema_object astro_fields
[] = {
23 astrodb_member("ID", "ID", struct astrodb_object
, id
,
24 CT_STRING
, "", 0, NULL
),
25 astrodb_member("ID", "Star", struct astrodb_object
, id
,
26 CT_STRING
, "", 0, NULL
),
27 astrodb_member("Name", "Name", struct astrodb_object
, name
,
28 CT_STRING
, "", 0, NULL
),
31 int append_astro_field(struct astrodb_schema_object
*base
, char *field
)
35 /* check for wildcard */
36 if (!strncmp(field
, "*", 1)) {
38 /* append all columns */
39 memcpy(base
, astro_fields
,
40 sizeof(struct astrodb_schema_object
) *
41 astrodb_size(astro_fields
));
42 return astrodb_size(astro_fields
);
45 /* find and append specific column */
46 for (i
= 0; i
< astrodb_size(astro_fields
); i
++) {
47 if (!strncmp(field
, astro_fields
[i
].symbol
,
48 ADB_SCHEMA_SYMBOL_SIZE
)) {
49 memcpy(base
, &astro_fields
[i
],
50 sizeof(struct astrodb_schema_object
));
57 int get_astro_field_offset(char *field
)
61 /* check astro fields */
62 for (i
= 0; i
< astrodb_size(astro_fields
); i
++) {
63 if (!strncmp(field
, astro_fields
[i
].symbol
,
64 ADB_SCHEMA_SYMBOL_SIZE
))
65 return astro_fields
[i
].s_offset
;