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

headers.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_HEADERS_H_INCLUDED
24#define FIFTYONE_DEGREES_HEADERS_H_INCLUDED
25
26#ifdef FIFTYONE_DEGREES_IPI_SYMBOLS
27#include "ipiSymbols.h"
28#endif
29
95
96#include <stdbool.h>
97#include <stdint.h>
98#include <stdlib.h>
99#ifdef _MSC_FULL_VER
100#include <string.h>
101#else
102#include <strings.h>
103#define _stricmp strcasecmp
104#define _strnicmp strncasecmp
105#endif
106#include "list.h"
107#include "array.h"
108#include "common.h"
109
110#define FIFTYONE_DEGREES_PSEUDO_HEADER_SEP '\x1F'
114
118typedef uint32_t fiftyoneDegreesHeaderID;
119
123typedef struct fiftyone_degrees_header_t fiftyoneDegreesHeader;
124
128typedef fiftyoneDegreesHeader* fiftyoneDegreesHeaderPtr;
129
135 );
136typedef fiftyoneDegreesHeaderPtrArray fiftyoneDegreesHeaderPtrs;
137
142 uint32_t index;
143 const char* name;
145 size_t nameLength;
149 bool isDataSet;
151 fiftyoneDegreesHeaderPtrs* pseudoHeaders;
153 fiftyoneDegreesHeaderPtrs* segmentHeaders;
156};
157
158#define FIFTYONE_DEGREES_HEADERS_MEMBERS \
159bool expectUpperPrefixedHeaders;
162
168 fiftyoneDegreesHeader,
170
175
186 void *state,
187 uint32_t index,
189
205 bool useUpperPrefixedHeaders,
206 void *state,
208 fiftyoneDegreesException* exception);
209
219 fiftyoneDegreesHeaders *headers,
220 const char* httpHeaderName,
221 size_t length);
222
233EXTERNAL fiftyoneDegreesHeader* fiftyoneDegreesHeadersGetHeaderFromUniqueId(
234 fiftyoneDegreesHeaders *headers,
235 fiftyoneDegreesHeaderID uniqueId);
236
243
251EXTERNAL bool fiftyoneDegreesHeadersIsHttp(
252 void *state,
253 const char* field,
254 size_t length);
255
259
260#endif
#define FIFTYONE_DEGREES_ARRAY_TYPE(t, m)
Simple array structure definition macro used for generic types.
Definition array.h:55
fiftyoneDegreesHeader * fiftyoneDegreesHeaderPtr
Pointer to a header structure.
Definition headers.h:125
#define FIFTYONE_DEGREES_HEADERS_MEMBERS
True if the headers structure should expect input header to be prefixed with 'HTTP_'.
Definition headers.h:155
void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers)
Frees the memory allocated by the fiftyoneDegreesHeadersCreate method.
fiftyoneDegreesHeaderArray fiftyoneDegreesHeaders
Array of headers used to easily access and track the size of the array.
Definition headers.h:171
long(* fiftyoneDegreesHeadersGetMethod)(void *state, uint32_t index, fiftyoneDegreesCollectionItem *nameItem)
Gets the unique id and name of the header at the requested index.
Definition headers.h:182
fiftyoneDegreesHeaders * fiftyoneDegreesHeadersCreate(bool useUpperPrefixedHeaders, void *state, fiftyoneDegreesHeadersGetMethod get, fiftyoneDegreesException *exception)
Creates a new headers instance configured with the unique HTTP names needed from evidence.
uint32_t fiftyoneDegreesHeaderID
The unique id for the header field string in the data set.
Definition headers.h:115
fiftyoneDegreesHeader * fiftyoneDegreesHeadersGetHeaderFromUniqueId(fiftyoneDegreesHeaders *headers, fiftyoneDegreesHeaderID uniqueId)
Gets a pointer to the header in the headers structure with a unique id matching the one provided.
int fiftyoneDegreesHeaderGetIndex(fiftyoneDegreesHeaders *headers, const char *httpHeaderName, size_t length)
Provides the integer index of the HTTP header name, or -1 if there is no matching header.
bool fiftyoneDegreesHeadersIsHttp(void *state, const char *field, size_t length)
Determines if the field is an HTTP header.
Structure for a header known to the corresponding data set.
Definition headers.h:138
const char * name
Name of the header or pseudo header field as a null terminated string.
Definition headers.h:140
fiftyoneDegreesHeaderID headerId
Unique id in the data set for this full header.
Definition headers.h:144
fiftyoneDegreesHeaderPtrs * segmentHeaders
Array of pointers to raw headers that form this pseudo header.
Definition headers.h:150
uint32_t index
Index of the header in the array of all headers.
Definition headers.h:139
bool isDataSet
True if the header originates from the data set and the headerId is valid.
Definition headers.h:146
fiftyoneDegreesHeaderPtrs * pseudoHeaders
Array of pointers to related pseudo headers.
Definition headers.h:148
size_t nameLength
Length of the name string excluding the terminating null.
Definition headers.h:142
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition collection.h:315
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition exceptions.h:115
Array of Headers which should always be ordered in ascending order of fullHeaderId.
Definition headers.h:166
Array of header indexes.
Definition headers.h:132