blob: 720dc6af4d39ccabfc602fa57edf2680d61744d1 [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
Willy Tarreaudcc70052019-11-15 13:39:16 +01006static char const __attribute__((unused)) rcsid[] = "$Id: dac.c, v dummy 1970/01/01 00:00:01 dcarlier Exp $";
David Carlier0470d702019-04-26 12:02:28 +00007
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{
Willy Tarreau4481bcf2020-07-12 09:12:07 +020066 void *ptr2 = malloc(len);
67 free(ptr2);
68 return ptr2 ? DA_OK : DA_NOMEM;
David Carlier0470d702019-04-26 12:02:28 +000069}
70
71void
72da_atlas_close(da_atlas_t *atlas)
73{
74}
75
76da_evidence_id_t
77da_atlas_clientprop_evidence_id(const da_atlas_t *atlas)
78{
79 return (da_evidence_id_t)2;
80}
81
82da_evidence_id_t
83da_atlas_accept_language_evidence_id(const da_atlas_t *atlas)
84{
85 return (da_evidence_id_t)3;
86}
87
88da_evidence_id_t
89da_atlas_header_evidence_id(const da_atlas_t *atlas, const char *evidence_name)
90{
91 return (da_evidence_id_t)1;
92}
93
94da_status_t
95da_atlas_getproptype(const da_atlas_t *atlas, da_propid_t propid, da_type_t *type)
96{
97 *type = DA_TYPE_BOOLEAN;
98 return DA_OK;
99}
100
101da_status_t
102da_atlas_getpropname(const da_atlas_t *atlas, da_propid_t propid, const char **name)
103{
104 *name = "isRobot";
105 return DA_OK;
106}
107
108da_status_t
109da_atlas_getpropid(const da_atlas_t *atlas, const char *propname, da_propid_t *property)
110{
111 *property = (da_propid_t)1;
112 return DA_OK;
113}
114
115size_t
116da_atlas_getpropcount(const da_atlas_t *atlas)
117{
118 return 1;
119}
120
121void
122da_atlas_setconfig(da_atlas_t *atlas, da_config_t *config)
123{
124}
125
126da_status_t
127da_searchv(const da_atlas_t *atlas, da_deviceinfo_t *result, da_evidence_t *evidence, size_t count)
128{
129 memset(result, 0, sizeof(*result));
130 result->propcount = count;
131 return DA_OK;
132}
133
134da_status_t
135da_search(const da_atlas_t *atlas, da_deviceinfo_t *result, ...)
136{
137 da_evidence_t vec[4]; /* XXX: this will have to grow if more evidence is supported. */
138 size_t i;
139 va_list args;
140 va_start(args, result);
141 for (i = 0; i < sizeof vec / sizeof vec[0];) {
142 vec[i].key = va_arg(args, da_evidence_id_t);
143 if (vec[i].key == 0)
144 break;
145 vec[i++].value = va_arg(args, char *);
146 }
147 va_end(args);
148 return da_searchv(atlas, result, vec, i);
149}
150
151/*
152 * Search-result centric functions.
153 */
154size_t
155da_getpropcount(const da_deviceinfo_t *info)
156{
157 return info->propcount;
158}
159
160da_status_t
161da_getfirstprop(const da_deviceinfo_t *info, da_propid_t **propid)
162{
163 if (info->propcount == 0)
164 return DA_NOMORE;
165 *propid = &info->proplist[0];
166 return DA_OK;
167}
168
169da_status_t
170da_getnextprop(const da_deviceinfo_t *info, da_propid_t **propid)
171{
172 if (*propid - info->proplist >= info->propcount - 1)
173 return DA_NOMORE;
174 ++*propid;
175 return DA_OK;
176}
177
178void
179da_close(da_deviceinfo_t *sr)
180{
181}
182
183da_status_t
184da_getpropname(const da_deviceinfo_t *info, da_propid_t propid, const char **name)
185{
186 *name = "isRobot";
187 return DA_OK;
188}
189
190da_status_t
191da_getproptype(const da_deviceinfo_t *info, da_propid_t propid, da_type_t *type)
192{
193 *type = DA_TYPE_BOOLEAN;
194 return DA_OK;
195}
196
197da_status_t
198da_getpropinteger(const da_deviceinfo_t *info, da_propid_t property, long *vp)
199{
200 *vp = -1;
201 return DA_OK;
202}
203
204da_status_t
205da_getpropstring(const da_deviceinfo_t *info, da_propid_t property, const char **vp)
206{
207 *vp = NULL;
208 return DA_OK;
209}
210
211da_status_t
212da_getpropboolean(const da_deviceinfo_t *info, da_propid_t property, bool *vp)
213{
214 *vp = true;
215 return DA_OK;
216}
217
218const char *
219da_get_property_name(const da_atlas_t *atlas, da_propid_t property)
220{
221 return "isRobot";
222}