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 | { |
| 66 | ptr = malloc(len); |
| 67 | return ptr ? DA_OK : DA_NOMEM; |
| 68 | } |
| 69 | |
| 70 | void |
| 71 | da_atlas_close(da_atlas_t *atlas) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | da_evidence_id_t |
| 76 | da_atlas_clientprop_evidence_id(const da_atlas_t *atlas) |
| 77 | { |
| 78 | return (da_evidence_id_t)2; |
| 79 | } |
| 80 | |
| 81 | da_evidence_id_t |
| 82 | da_atlas_accept_language_evidence_id(const da_atlas_t *atlas) |
| 83 | { |
| 84 | return (da_evidence_id_t)3; |
| 85 | } |
| 86 | |
| 87 | da_evidence_id_t |
| 88 | da_atlas_header_evidence_id(const da_atlas_t *atlas, const char *evidence_name) |
| 89 | { |
| 90 | return (da_evidence_id_t)1; |
| 91 | } |
| 92 | |
| 93 | da_status_t |
| 94 | da_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 | |
| 100 | da_status_t |
| 101 | da_atlas_getpropname(const da_atlas_t *atlas, da_propid_t propid, const char **name) |
| 102 | { |
| 103 | *name = "isRobot"; |
| 104 | return DA_OK; |
| 105 | } |
| 106 | |
| 107 | da_status_t |
| 108 | da_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 | |
| 114 | size_t |
| 115 | da_atlas_getpropcount(const da_atlas_t *atlas) |
| 116 | { |
| 117 | return 1; |
| 118 | } |
| 119 | |
| 120 | void |
| 121 | da_atlas_setconfig(da_atlas_t *atlas, da_config_t *config) |
| 122 | { |
| 123 | } |
| 124 | |
| 125 | da_status_t |
| 126 | da_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 | |
| 133 | da_status_t |
| 134 | da_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 | */ |
| 153 | size_t |
| 154 | da_getpropcount(const da_deviceinfo_t *info) |
| 155 | { |
| 156 | return info->propcount; |
| 157 | } |
| 158 | |
| 159 | da_status_t |
| 160 | da_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 | |
| 168 | da_status_t |
| 169 | da_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 | |
| 177 | void |
| 178 | da_close(da_deviceinfo_t *sr) |
| 179 | { |
| 180 | } |
| 181 | |
| 182 | da_status_t |
| 183 | da_getpropname(const da_deviceinfo_t *info, da_propid_t propid, const char **name) |
| 184 | { |
| 185 | *name = "isRobot"; |
| 186 | return DA_OK; |
| 187 | } |
| 188 | |
| 189 | da_status_t |
| 190 | da_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 | |
| 196 | da_status_t |
| 197 | da_getpropinteger(const da_deviceinfo_t *info, da_propid_t property, long *vp) |
| 198 | { |
| 199 | *vp = -1; |
| 200 | return DA_OK; |
| 201 | } |
| 202 | |
| 203 | da_status_t |
| 204 | da_getpropstring(const da_deviceinfo_t *info, da_propid_t property, const char **vp) |
| 205 | { |
| 206 | *vp = NULL; |
| 207 | return DA_OK; |
| 208 | } |
| 209 | |
| 210 | da_status_t |
| 211 | da_getpropboolean(const da_deviceinfo_t *info, da_propid_t property, bool *vp) |
| 212 | { |
| 213 | *vp = true; |
| 214 | return DA_OK; |
| 215 | } |
| 216 | |
| 217 | const char * |
| 218 | da_get_property_name(const da_atlas_t *atlas, da_propid_t property) |
| 219 | { |
| 220 | return "isRobot"; |
| 221 | } |