David Carlier | 0470d70 | 2019-04-26 12:02:28 +0000 | [diff] [blame] | 1 | #include "dac.h" |
| 2 | #include <stdlib.h> |
| 3 | #include <string.h> |
| 4 | #include <time.h> |
| 5 | |
Willy Tarreau | dcc7005 | 2019-11-15 13:39:16 +0100 | [diff] [blame] | 6 | static char const __attribute__((unused)) rcsid[] = "$Id: dac.c, v dummy 1970/01/01 00:00:01 dcarlier Exp $"; |
David Carlier | 0470d70 | 2019-04-26 12:02:28 +0000 | [diff] [blame] | 7 | |
| 8 | struct da_bitset { |
| 9 | unsigned long bits[8]; |
| 10 | size_t bit_count; |
| 11 | }; |
| 12 | |
| 13 | /* |
| 14 | * Constructor/Destructor for possible globals. |
| 15 | */ |
| 16 | |
| 17 | void |
| 18 | da_init() |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | void |
| 23 | da_fini() |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | |
| 28 | void |
| 29 | da_seterrorfunc(da_errorfunc_t callback) |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | const char * |
| 34 | da_typename(da_type_t fieldtype) |
| 35 | { |
| 36 | return "none"; |
| 37 | } |
| 38 | |
| 39 | char * |
| 40 | da_getdataversion(da_atlas_t *atlas) |
| 41 | { |
| 42 | return "dummy library version 1.0"; |
| 43 | } |
| 44 | |
| 45 | time_t |
| 46 | da_getdatacreation(da_atlas_t *atlas) |
| 47 | { |
| 48 | return time(NULL); |
| 49 | } |
| 50 | |
| 51 | int |
| 52 | da_getdatarevision(da_atlas_t *atlas) |
| 53 | { |
| 54 | return 1; |
| 55 | } |
| 56 | |
| 57 | da_status_t |
| 58 | da_atlas_compile(void *ctx, da_read_fn readfn, da_setpos_fn rewind, void **ptr, size_t *size) |
| 59 | { |
| 60 | return DA_OK; |
| 61 | } |
| 62 | |
| 63 | da_status_t |
| 64 | da_atlas_open(da_atlas_t *atlas, da_property_decl_t *extraprops, const void *ptr, size_t len) |
| 65 | { |
Willy Tarreau | 4481bcf | 2020-07-12 09:12:07 +0200 | [diff] [blame] | 66 | void *ptr2 = malloc(len); |
| 67 | free(ptr2); |
| 68 | return ptr2 ? DA_OK : DA_NOMEM; |
David Carlier | 0470d70 | 2019-04-26 12:02:28 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | void |
| 72 | da_atlas_close(da_atlas_t *atlas) |
| 73 | { |
| 74 | } |
| 75 | |
| 76 | da_evidence_id_t |
| 77 | da_atlas_clientprop_evidence_id(const da_atlas_t *atlas) |
| 78 | { |
| 79 | return (da_evidence_id_t)2; |
| 80 | } |
| 81 | |
| 82 | da_evidence_id_t |
| 83 | da_atlas_accept_language_evidence_id(const da_atlas_t *atlas) |
| 84 | { |
| 85 | return (da_evidence_id_t)3; |
| 86 | } |
| 87 | |
| 88 | da_evidence_id_t |
| 89 | da_atlas_header_evidence_id(const da_atlas_t *atlas, const char *evidence_name) |
| 90 | { |
| 91 | return (da_evidence_id_t)1; |
| 92 | } |
| 93 | |
| 94 | da_status_t |
| 95 | da_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 | |
| 101 | da_status_t |
| 102 | da_atlas_getpropname(const da_atlas_t *atlas, da_propid_t propid, const char **name) |
| 103 | { |
| 104 | *name = "isRobot"; |
| 105 | return DA_OK; |
| 106 | } |
| 107 | |
| 108 | da_status_t |
| 109 | da_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 | |
| 115 | size_t |
| 116 | da_atlas_getpropcount(const da_atlas_t *atlas) |
| 117 | { |
| 118 | return 1; |
| 119 | } |
| 120 | |
| 121 | void |
| 122 | da_atlas_setconfig(da_atlas_t *atlas, da_config_t *config) |
| 123 | { |
| 124 | } |
| 125 | |
| 126 | da_status_t |
| 127 | da_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 | |
| 134 | da_status_t |
| 135 | da_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 | */ |
| 154 | size_t |
| 155 | da_getpropcount(const da_deviceinfo_t *info) |
| 156 | { |
| 157 | return info->propcount; |
| 158 | } |
| 159 | |
| 160 | da_status_t |
| 161 | da_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 | |
| 169 | da_status_t |
| 170 | da_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 | |
| 178 | void |
| 179 | da_close(da_deviceinfo_t *sr) |
| 180 | { |
| 181 | } |
| 182 | |
| 183 | da_status_t |
| 184 | da_getpropname(const da_deviceinfo_t *info, da_propid_t propid, const char **name) |
| 185 | { |
| 186 | *name = "isRobot"; |
| 187 | return DA_OK; |
| 188 | } |
| 189 | |
| 190 | da_status_t |
| 191 | da_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 | |
| 197 | da_status_t |
| 198 | da_getpropinteger(const da_deviceinfo_t *info, da_propid_t property, long *vp) |
| 199 | { |
| 200 | *vp = -1; |
| 201 | return DA_OK; |
| 202 | } |
| 203 | |
| 204 | da_status_t |
| 205 | da_getpropstring(const da_deviceinfo_t *info, da_propid_t property, const char **vp) |
| 206 | { |
| 207 | *vp = NULL; |
| 208 | return DA_OK; |
| 209 | } |
| 210 | |
| 211 | da_status_t |
| 212 | da_getpropboolean(const da_deviceinfo_t *info, da_propid_t property, bool *vp) |
| 213 | { |
| 214 | *vp = true; |
| 215 | return DA_OK; |
| 216 | } |
| 217 | |
| 218 | const char * |
| 219 | da_get_property_name(const da_atlas_t *atlas, da_propid_t property) |
| 220 | { |
| 221 | return "isRobot"; |
| 222 | } |