\r\n

51Degrees Device Detection C/C++  4.4

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 #include "common.h"
105 
109 typedef struct fiftyone_degrees_header_segment_t {
110  const char* segment;
111  size_t length;
114 
117  );
118 
123 typedef struct fiftyone_degrees_header_t {
124  const char* name;
126  size_t nameLength;
130  bool isDataSet;
131  uint32_t uniqueId;
133 
134 #define FIFTYONE_DEGREES_HEADERS_MEMBERS \
135 bool expectUpperPrefixedHeaders; \
138 uint32_t pseudoHeadersCount;
140 FIFTYONE_DEGREES_ARRAY_TYPE(
143 
148 
158  void *state,
159  uint32_t index,
161 
168 EXTERNAL size_t fiftyoneDegreesHeadersSize(int count);
169 
175 EXTERNAL bool fiftyoneDegreesHeadersIsPseudo(const char *headerName);
176 
191  bool useUpperPrefixedHeaders,
192  void *state,
194 
202 EXTERNAL int fiftyoneDegreesHeaderGetIndex(
203  fiftyoneDegreesHeaders *headers,
204  const char* httpHeaderName,
205  size_t length);
206 
218  fiftyoneDegreesHeaders *headers,
219  uint32_t uniqueId);
220 
226 EXTERNAL void fiftyoneDegreesHeadersFree(fiftyoneDegreesHeaders *headers);
227 
234 EXTERNAL bool fiftyoneDegreesHeadersIsHttp(
235  void *state,
237 
242 #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 of the number of pseudo headers.
Definition: headers.h:134
size_t nameLength
Length of the name string excluding the terminating null.
Definition: headers.h:126
const char * name
Name of the header or pseudo header field as a null terminated string.
Definition: headers.h:124
Array of items of type fiftyoneDegreesHeaderSegment used to easily access and track the size of the a...
Definition: headers.h:117
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
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:160
Array of items of type fiftyoneDegreesHeader used to easily access and track the size of the array.
Definition: headers.h:142
fiftyoneDegreesHeaderSegmentArray * segments
Segments within the name.
Definition: headers.h:128
Header structure to identify a header that either comes directly from the data set,...
Definition: headers.h:123
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:130
fiftyoneDegreesHeaderArray fiftyoneDegreesHeaders
Array of headers used to easily access and track the size of the array.
Definition: headers.h:142
int fiftyoneDegreesHeaderGetIndex(fiftyoneDegreesHeaders *headers, const char *httpHeaderName, size_t length)
Provides the integer index of the HTTP header name.
#define FIFTYONE_DEGREES_ARRAY_TYPE(t, m)
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:157
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.