blob: 7da6971526afe2a64ea33eddc048bf9399f667d4 [file] [log] [blame]
David Carlier0470d702019-04-26 12:02:28 +00001#include "dac.h"
2#include <stdlib.h>
3#include <string.h>
4#include <time.h>
5
6static char const rcsid[] = "$Id: dac.c, v dummy 1970/01/01 00:00:01 dcarlier Exp $";
7
8struct da_bitset {
9 unsigned long bits[8];
10 size_t bit_count;
11};
12
13/*
14 * Constructor/Destructor for possible globals.
15 */
16
17void
18da_init()
19{
20}
21
22void
23da_fini()
24{
25}
26
27
28void
29da_seterrorfunc(da_errorfunc_t callback)
30{
31}
32
33const char *
34da_typename(da_type_t fieldtype)
35{
36 return "none";
37}
38
39char *
40da_getdataversion(da_atlas_t *atlas)
41{
42 return "dummy library version 1.0";
43}
44
45time_t
46da_getdatacreation(da_atlas_t *atlas)
47{
48 return time(NULL);
49}
50
51int
52da_getdatarevision(da_atlas_t *atlas)
53{
54 return 1;
55}
56
57da_status_t
58da_atlas_compile(void *ctx, da_read_fn readfn, da_setpos_fn rewind, void **ptr, size_t *size)
59{
60 return DA_OK;
61}
62
63da_status_t
64da_atlas_open(da_atlas_t *atlas, da_property_decl_t *extraprops, const void *ptr, size_t len)
65{
66 ptr = malloc(len);
67 return ptr ? DA_OK : DA_NOMEM;
68}
69
70void
71da_atlas_close(da_atlas_t *atlas)
72{
73}
74
75da_evidence_id_t
76da_atlas_clientprop_evidence_id(const da_atlas_t *atlas)
77{
78 return (da_evidence_id_t)2;
79}
80
81da_evidence_id_t
82da_atlas_accept_language_evidence_id(const da_atlas_t *atlas)
83{
84 return (da_evidence_id_t)3;
85}
86
87da_evidence_id_t
88da_atlas_header_evidence_id(const da_atlas_t *atlas, const char *evidence_name)
89{
90 return (da_evidence_id_t)1;
91}
92
93da_status_t
94da_atlas_getproptype(const da_atlas_t *atlas, da_propid_t propid, da_type_t *type)
95{
96 *type = DA_TYPE_BOOLEAN;
97 return DA_OK;
98}
99
100da_status_t
101da_atlas_getpropname(const da_atlas_t *atlas, da_propid_t propid, const char **name)
102{
103 *name = "isRobot";
104 return DA_OK;
105}
106
107da_status_t
108da_atlas_getpropid(const da_atlas_t *atlas, const char *propname, da_propid_t *property)
109{
110 *property = (da_propid_t)1;
111 return DA_OK;
112}
113
114size_t
115da_atlas_getpropcount(const da_atlas_t *atlas)
116{
117 return 1;
118}
119
120void
121da_atlas_setconfig(da_atlas_t *atlas, da_config_t *config)
122{
123}
124
125da_status_t
126da_searchv(const da_atlas_t *atlas, da_deviceinfo_t *result, da_evidence_t *evidence, size_t count)
127{
128 memset(result, 0, sizeof(*result));
129 result->propcount = count;
130 return DA_OK;
131}
132
133da_status_t
134da_search(const da_atlas_t *atlas, da_deviceinfo_t *result, ...)
135{
136 da_evidence_t vec[4]; /* XXX: this will have to grow if more evidence is supported. */
137 size_t i;
138 va_list args;
139 va_start(args, result);
140 for (i = 0; i < sizeof vec / sizeof vec[0];) {
141 vec[i].key = va_arg(args, da_evidence_id_t);
142 if (vec[i].key == 0)
143 break;
144 vec[i++].value = va_arg(args, char *);
145 }
146 va_end(args);
147 return da_searchv(atlas, result, vec, i);
148}
149
150/*
151 * Search-result centric functions.
152 */
153size_t
154da_getpropcount(const da_deviceinfo_t *info)
155{
156 return info->propcount;
157}
158
159da_status_t
160da_getfirstprop(const da_deviceinfo_t *info, da_propid_t **propid)
161{
162 if (info->propcount == 0)
163 return DA_NOMORE;
164 *propid = &info->proplist[0];
165 return DA_OK;
166}
167
168da_status_t
169da_getnextprop(const da_deviceinfo_t *info, da_propid_t **propid)
170{
171 if (*propid - info->proplist >= info->propcount - 1)
172 return DA_NOMORE;
173 ++*propid;
174 return DA_OK;
175}
176
177void
178da_close(da_deviceinfo_t *sr)
179{
180}
181
182da_status_t
183da_getpropname(const da_deviceinfo_t *info, da_propid_t propid, const char **name)
184{
185 *name = "isRobot";
186 return DA_OK;
187}
188
189da_status_t
190da_getproptype(const da_deviceinfo_t *info, da_propid_t propid, da_type_t *type)
191{
192 *type = DA_TYPE_BOOLEAN;
193 return DA_OK;
194}
195
196da_status_t
197da_getpropinteger(const da_deviceinfo_t *info, da_propid_t property, long *vp)
198{
199 *vp = -1;
200 return DA_OK;
201}
202
203da_status_t
204da_getpropstring(const da_deviceinfo_t *info, da_propid_t property, const char **vp)
205{
206 *vp = NULL;
207 return DA_OK;
208}
209
210da_status_t
211da_getpropboolean(const da_deviceinfo_t *info, da_propid_t property, bool *vp)
212{
213 *vp = true;
214 return DA_OK;
215}
216
217const char *
218da_get_property_name(const da_atlas_t *atlas, da_propid_t property)
219{
220 return "isRobot";
221}