51Degrees Device Detection C/C++  4.4

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


1 /* *********************************************************************
2  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3  * Copyright 2023 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  * ********************************************************************* */
91 #include <stdbool.h>
92 #include <stdint.h>
93 #include <stdlib.h>
94 #ifdef _MSC_FULL_VER
95 #include <string.h>
96 #else
97 #include <strings.h>
98 #define _stricmp strcasecmp
99 #define _strnicmp strncasecmp
100 #endif
101 #include "list.h"
102 #include "evidence.h"
103 #include "array.h"
104 #include "common.h"
109 typedef struct fiftyone_degrees_header_segment_t {
110  const char* segment;
111  size_t length;
117  );
119 typedef uint32_t fiftyoneDegreesHeaderID;
125 typedef struct fiftyone_degrees_header_t {
126  const char* name;
128  size_t nameLength;
132  bool isDataSet;
133  fiftyoneDegreesHeaderID uniqueId;
137 bool expectUpperPrefixedHeaders; \
140 uint32_t pseudoHeadersCount;
160  void *state,
161  uint32_t index,
170 EXTERNAL size_t fiftyoneDegreesHeadersSize(int count);
177 EXTERNAL bool fiftyoneDegreesHeadersIsPseudo(const char *headerName);
193  bool useUpperPrefixedHeaders,
194  void *state,
204 EXTERNAL int fiftyoneDegreesHeaderGetIndex(
205  fiftyoneDegreesHeaders *headers,
206  const char* httpHeaderName,
207  size_t length);
220  fiftyoneDegreesHeaders *headers,
221  fiftyoneDegreesHeaderID uniqueId);
228 EXTERNAL void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers);
236 EXTERNAL bool fiftyoneDegreesHeadersIsHttp(
237  void *state,
244 #endif
fiftyoneDegreesHeaders * fiftyoneDegreesHeadersCreate(bool useUpperPrefixedHeaders, void *state, fiftyoneDegreesHeadersGetMethod get)
Creates a new headers instance configured with the unique HTTP names needed from evidence.
size_t fiftyoneDegreesHeadersSize(int count)
Returns the number of bytes that will be allocated for a headers structure created using the fiftyone...
Count of the number of pseudo headers.
Definition: headers.h:136
size_t nameLength
Length of the name string excluding the terminating null.
Definition: headers.h:128
const char * name
Name of the header or pseudo header field as a null terminated string.
Definition: headers.h:126
Array of items of type fiftyoneDegreesHeaderSegment used to easily access and track the size of the a...
Definition: headers.h:117
fiftyoneDegreesHeader * fiftyoneDegreesHeadersGetHeaderFromUniqueId(fiftyoneDegreesHeaders *headers, fiftyoneDegreesHeaderID uniqueId)
Gets a pointer to the header in the headers structure with a unique id matching the one provided.
Null or PSEUDO_HEADER_SEP terminated string segment within a header.
Definition: headers.h:109
void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers)
Frees the memory allocated by the fiftyoneDegreesHeadersCreate method.
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition: collection.h:310
size_t length
Length of the segment in the name strings without the terminating character.
Definition: headers.h:111
Evidence key value pair structure which combines the prefix, key and value.
Definition: evidence.h:160
Array of items of type fiftyoneDegreesHeader used to easily access and track the size of the array.
Definition: headers.h:144
fiftyoneDegreesHeaderSegmentArray * segments
Segments within the name.
Definition: headers.h:130
Header structure to identify a header that either comes directly from the data set,...
Definition: headers.h:125
bool fiftyoneDegreesHeadersIsHttp(void *state, fiftyoneDegreesEvidenceKeyValuePair *pair)
Determines if the key of an evidence pair is an HTTP header.
bool isDataSet
True if the header originates from the data set.
Definition: headers.h:132
fiftyoneDegreesHeaderArray fiftyoneDegreesHeaders
Array of headers used to easily access and track the size of the array.
Definition: headers.h:144
int fiftyoneDegreesHeaderGetIndex(fiftyoneDegreesHeaders *headers, const char *httpHeaderName, size_t length)
Provides the integer index of the HTTP header name.
Simple array structure definition macro used for generic types.
Definition: array.h:48
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:159
const char * segment
Segment in the name string.
Definition: headers.h:110
bool fiftyoneDegreesHeadersIsPseudo(const char *headerName)
Check if a header is a pseudo header.