\r\n

51Degrees Device Detection C/C++  4.3

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 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
5  *
6  * This Original Work is licensed under the European Union Public Licence (EUPL)
7  * 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 
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 
105 #ifdef __cplusplus
106 #define EXTERNAL extern "C"
107 #else
108 #define EXTERNAL
109 #endif
110 
114 typedef struct fiftyone_degrees_header_t {
118  uint32_t* requestHeaders;
122  uint32_t uniqueId;
125 
126 #define FIFTYONE_DEGREES_HEADERS_MEMBERS \
127 bool expectUpperPrefixedHeaders; \
130 uint32_t* pseudoHeaders; \
131 uint32_t pseudoHeadersCount;
133 FIFTYONE_DEGREES_ARRAY_TYPE(
136 
141 
151  void *state,
152  uint32_t index,
154 
161 EXTERNAL size_t fiftyoneDegreesHeadersSize(int count);
162 
168 EXTERNAL bool fiftyoneDegreesHeadersIsPseudo(const char *headerName);
169 
184  bool useUpperPrefixedHeaders,
185  void *state,
187 
195 EXTERNAL int fiftyoneDegreesHeaderGetIndex(
196  fiftyoneDegreesHeaders *headers,
197  const char* httpHeaderName,
198  size_t length);
199 
211  fiftyoneDegreesHeaders *headers,
212  uint32_t uniqueId);
213 
219 EXTERNAL void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers);
220 
227 EXTERNAL bool fiftyoneDegreesHeadersIsHttp(
228  void *state,
230 
235 #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...
#define FIFTYONE_DEGREES_HEADERS_MEMBERS
Count number of pseudo headers.
Definition: headers.h:126
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:309
uint32_t * requestHeaders
Indices for unique headers that form this pseudo-header.
Definition: headers.h:118
fiftyoneDegreesHeader * fiftyoneDegreesHeadersGetHeaderFromUniqueId(fiftyoneDegreesHeaders *headers, uint32_t uniqueId)
Gets a pointer to the header in the headers structure with a unique id matching the one provided.
Evidence key value pair structure which combines the prefix, key and value.
Definition: evidence.h:165
uint32_t requestHeaderCount
Number of request headers.
Definition: headers.h:120
Array of items of type fiftyoneDegreesHeader used to easily access and track the size of the array.
Definition: headers.h:135
Header structure containing the name and unique id.
Definition: headers.h:114
bool fiftyoneDegreesHeadersIsHttp(void *state, fiftyoneDegreesEvidenceKeyValuePair *pair)
Determines if the key of an evidence pair is an HTTP header.
fiftyoneDegreesHeaderArray fiftyoneDegreesHeaders
Array of headers used to easily access and track the size of the array.
Definition: headers.h:135
int fiftyoneDegreesHeaderGetIndex(fiftyoneDegreesHeaders *headers, const char *httpHeaderName, size_t length)
Provides the integer index of the HTTP header name.
uint32_t uniqueId
Id which uniquely identifies the header within the data set.
Definition: headers.h:122
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:150
fiftyoneDegreesCollectionItem name
Collection item containing the name of the header as a fiftyoneDegreesString.
Definition: headers.h:115
bool fiftyoneDegreesHeadersIsPseudo(const char *headerName)
Check if a header is a pseudo header.