A device detection library that is used natively or by 51Degrees products

evidence.h

1/* *********************************************************************
2 * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3 * Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
4 * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5 *
6 * This Original Work is licensed under the European Union Public Licence
7 * (EUPL) v.1.2 and is subject to its terms as set out below.
8 *
9 * If a copy of the EUPL was not distributed with this file, You can obtain
10 * one at https://opensource.org/licenses/EUPL-1.2.
11 *
12 * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13 * amended by the European Commission) shall be deemed incompatible for
14 * the purposes of the Work and the provisions of the compatibility
15 * clause in Article 5 of the EUPL shall not apply.
16 *
17 * If using the Work as, or as part of, a network application, by
18 * including the attribution notice(s) required under Article 5 of the EUPL
19 * in the end user terms of the application under an appropriate heading,
20 * such notice(s) shall fulfill the requirements of that article.
21 * ********************************************************************* */
22
23#ifndef FIFTYONE_DEGREES_EVIDENCE_H_INCLUDED
24#define FIFTYONE_DEGREES_EVIDENCE_H_INCLUDED
25
26#ifdef FIFTYONE_DEGREES_IPI_SYMBOLS
27#include "ipiSymbols.h"
28#endif
29
122
123#include <stdint.h>
124#include <stdbool.h>
125#include <stdlib.h>
126#include "data.h"
127#include "ip.h"
128#include "string.h"
129#include "array.h"
130#include "common.h"
131#include "pair.h"
132#include "headers.h"
133
138typedef enum e_fiftyone_degrees_evidence_prefix {
154
156typedef struct fiftyone_degrees_evidence_prefix_map_t {
157 const char *prefix;
161
165typedef struct fiftyone_degrees_evidence_key_value_pair_t {
168 const void *parsedValue;
170 fiftyoneDegreesHeader* header;
173
178typedef struct fiftyone_degrees_array_fiftyoneDegreesEvidenceKeyValuePair_t
180
185#define FIFTYONE_DEGREES_ARRAY_EVIDENCE_MEMBER \
186 fiftyoneDegreesEvidenceKeyValuePairArray *next; \
187 fiftyoneDegreesEvidenceKeyValuePairArray *prev;
188
195 FIFTYONE_DEGREES_ARRAY_EVIDENCE_MEMBER)
196
197
203typedef bool(*fiftyoneDegreesEvidenceIterateMethod)(
204 void *state,
206
213 fiftyoneDegreesEvidenceCreate(uint32_t capacity);
214
220EXTERNAL void fiftyoneDegreesEvidenceFree(
222
236EXTERNAL fiftyoneDegreesEvidenceKeyValuePair* fiftyoneDegreesEvidenceAddString(
239 const char *key,
240 const char *value);
241
254EXTERNAL fiftyoneDegreesEvidenceKeyValuePair* fiftyoneDegreesEvidenceAddPair(
258
264EXTERNAL fiftyoneDegreesEvidencePrefixMap* fiftyoneDegreesEvidenceMapPrefix(
265 const char *key);
266
272EXTERNAL const char* fiftyoneDegreesEvidencePrefixString(
274
286EXTERNAL uint32_t fiftyoneDegreesEvidenceIterate(
288 int prefixes,
289 void *state,
290 fiftyoneDegreesEvidenceIterateMethod callback);
291
321EXTERNAL bool fiftyoneDegreesEvidenceIterateForHeaders(
323 int prefixes,
324 fiftyoneDegreesHeaderPtrs* headers,
325 char* const buffer,
326 size_t const length,
327 void* state,
328 fiftyoneDegreesEvidenceIterateMethod callback);
329
333
334#endif
#define FIFTYONE_DEGREES_ARRAY_TYPE(t, m)
Simple array structure definition macro used for generic types.
Definition array.h:55
fiftyoneDegreesEvidencePrefix
@
Definition evidence.h:138
@ FIFTYONE_DEGREES_EVIDENCE_QUERY
A query string parameter.
Definition evidence.h:149
@ FIFTYONE_DEGREES_EVIDENCE_HTTP_HEADER_IP_ADDRESSES
A list of IP addresses as a string to be parsed into a IP addresses collection.
Definition evidence.h:141
@ FIFTYONE_DEGREES_EVIDENCE_COOKIE
A cookie value.
Definition evidence.h:150
@ FIFTYONE_DEGREES_EVIDENCE_HTTP_HEADER_STRING
An HTTP header value.
Definition evidence.h:139
@ FIFTYONE_DEGREES_EVIDENCE_IGNORE
The evidence is invalid and should be ignored.
Definition evidence.h:151
@ FIFTYONE_DEGREES_EVIDENCE_SERVER
A server value e.g.
Definition evidence.h:147
Definition GettingStarted.c:67
Array of evidence key value pairs and a pointer to the next array if present or NULL of not present.
Definition evidence.h:195
uint32_t capacity
Number of available items.
Definition evidence.h:195
Evidence key value pair structure which combines the prefix, key and value.
Definition evidence.h:165
size_t parsedLength
length of parsedValue string
Definition evidence.h:169
fiftyoneDegreesKeyValuePair item
the field key and original value
Definition evidence.h:167
fiftyoneDegreesEvidencePrefix prefix
e.g.
Definition evidence.h:166
fiftyoneDegreesHeader * header
Unique header in the data set, or null if not related to a header.
Definition evidence.h:170
const void * parsedValue
parsed value which may not be a string
Definition evidence.h:168
Map of prefix strings to prefix enum values.
Definition evidence.h:156
const char * prefix
Name of the prefix.
Definition evidence.h:157
fiftyoneDegreesEvidencePrefix prefixEnum
Enum value of prefix name.
Definition evidence.h:159
size_t prefixLength
Length of the prefix string.
Definition evidence.h:158
Definition pair.h:33